akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
	val Array(n, a, b) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val p = 1000000007L

	val p1 = powMod(2L, n, p)
	val p2 = combi(n, a, p)
	val p3 = combi(n, b, p)

	val ans = (p1 - p2 - p3 - 1L)%p

	if(ans < 0) println(p + ans)
	else println(ans)

	
	// https://atcoder.jp/contests/abc156/submissions/10731760
	def combi(n: Long, r: Long, p: Long): BigInt = {
		val tp1 = (n - r + 1L to n).foldLeft(1L)((z, i) => z * i % p)
		return (2L to r).foldLeft(BigInt(tp1))((z, i) => BigInt(i).modInverse(p) * z % p)
	}

	def powMod(a: Long, n: Long, p: Long): Long = {
    	def subpowMod(a: Long, n: Long, mul: Long): Long = {
    		n match{
				case 1L => a * mul % p
				case _  => subpowMod(a*a%p, n/2L, mul * (if((n&1) == 1) a else 1) % p )
    		}
    	}
    	subpowMod(a, n, 1L)
  	}
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e3 + 100;

ll mypow(ll a, ll b, ll m) {
	a %= m;
	ll r=1%m, p=a;
	while(b) {
		if(b%2) r=r*p%m;
		p=p*p%m;
		b>>=1;
	}
	return r;
}
int N, M;
ll C[MAX_N][MAX_N];
ll Dy[MAX_N][MAX_N];
void add(ll &a, ll b, ll m) {
	b %= m;
	a+=b;
	if(a>m) a-=m;
	if(a<0) a+=m;
}
int main() {
	cin >> N >> M;
	for(int i=0, j; i<=N; i++) for(C[i][0] = 1%M, j=1; j<=i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % M;
	for(int i=0, j; i<=N; i++) for(Dy[i][0] = 1%M, j=1; j<=i; j++) Dy[i][j] = (Dy[i-1][j-1] + Dy[i-1][j] * (j+1)) % M;

	ll ans = mypow(2, mypow(2, N, M-1), M);
	for(int k=1; k<=N; k++) {
		ll sum = 0, mul0 = 1, mulbase = mypow(2, mypow(2, N-k, M-1), M) % M;
		ll mul0_to = mypow(2, N-k, M);
		for(int i=0; i<=k; i++) {
			ll now = Dy[k][i] % M;
			now = now * mul0 % M;
			mul0 = mul0 * mul0_to % M;
			now = now * mulbase % M;
			//printf("%d %d : %d * %d * %d\n", k, i, Dy[k][i], mypow(mypow(2, N-k, M), i, M) % M, mypow(2, mypow(2, N-k, M-1), M) % M);
			add(sum, now, M);
		}
		add(ans, C[N][k] * sum % M * (k % 2 == 1 ? -1 : 1), M);
	}
	printf("%lld\n", ans);
	return 0;
}




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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  deque<int> r;
  rep(i, n) {
    int idx = lower_bound(r.begin(), r.end(), a[i]) - r.begin();
    --idx;
    if (idx < 0) {
      r.push_front(a[i]);
    } else {
      r[idx] = a[i];
    }
  }

  cout << r.size() << endl;
  return 0;
}


Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
    long long n;
    long long ai[100000];
    long long ti[100000];
    long long tmpi[100000];
    long long tfi[100000];
    bool flag=false;

    cin >> n;
    cin >> ti[0];
    tmpi[0]=1;
    tfi[0]=ti[0];
    for(long long i=1;i<n;i++){
        cin >> ti[i];
        if(ti[i-1] == ti[i]){
            tmpi[i]=ti[i];
            tfi[i]=0;
        }
        else{
            tmpi[i]=1;
            tfi[i]=ti[i];
        }

    }
    for(long long i=0;i<n;i++)
        cin >> ai[i];
    tmpi[n-1]=1;
    if(tfi[n-1]!=0 && ai[n-1] != tfi[n-1])
        flag=true;
    tfi[n-1]=ai[n-1];
    for(long long i=n-2;i>=0;i--){
        if(ai[i]==ai[i+1]){
            if(ai[i]<tmpi[i])
                tmpi[i]=ai[i];
        }
        else{
            tmpi[i]=1;
            if(tfi[i]==0)
                tfi[i]=ai[i];
            else if(tfi[i]!=ai[i])
                flag=true;
        }
    }
    tmpi[0]=1;

    for(long long i=0;i<n;i++){
        if(tfi[i]!=0 && (tfi[i]>ai[i] || tfi[i] > ti[i]))
            flag=true;
    }
    if(flag)
        cout << 0<<endl;
    else{
        long long ret=1;
        for(long long i=0;i<n;i++)
            ret=(ret*tmpi[i])%1000000007;
        cout <<ret <<endl;
    }


}


Measured memory_bytes: 3328
import java.util.Scanner;

import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			System.out.println((new ScriptEngineManager()).getEngineByName("JavaScript").eval(s));
		}
	}
}


Measured memory_bytes: 57160
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
//#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 1e6 + 5;

ll n, a[nax], b[nax], one, zero, ans[nax];
string s;

int countSetBits(int x) 
{ 
    if (x == 0) 
        return 0; 
    else
        return 1 + countSetBits(x & (x - 1)); 
} 

ll f(ll x){
	if(x == 0){
		return 0ll;
	}
	else{
		ll y = countSetBits(x);
		x = x % y;
		return 1ll + f(x);
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	cin >> s;
	reverse(s.begin(), s.end());
	for(ll i = 0; i < n; i++){
		if(s[i] == '1'){
			one++;
		}
		else{
			zero++;
		}
	}
	ll A = 0, B = 0;
	ll pa = 1;
	ll pb = 1;
	if(one <= 1){
		pb = 0;
	}
	for(ll i = 0; i < n; i++){
		a[i] = pa;
		if(s[i] == '1'){	
			A = (A + pa) % (one + 1);
		}
		pa = (pa * 2) % (one + 1);
		if(one <= 1){
			continue;
		}
		else{
			b[i] = pb;
			if(s[i] == '1'){		
				B = (B + pb) % (one - 1);
			}
			pb = (pb * 2) % (one - 1);
		}
	}
	for(ll i = 0; i < n; i++){
		if(s[i] == '1'){
			if(one == 1){
				ans[i] = 0;
			}
			else{
				ll bb = B - b[i];
				bb = (bb + (one - 1)) % (one - 1);
				ll ret = f(bb);
				ans[i] = ret + 1;
			}
		}
		else{
			ll aa = A + a[i];
			aa = (aa + one + 1) % (one + 1);
			ll ret = f(aa);
			ans[i] = ret + 1;
		}
	}
	for(ll i = n - 1; i >= 0; i--){
		cout << ans[i] << '\n';
	}
}



Measured memory_bytes: 8380
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  ll N;
  cin >> N;
  vector<ll> load_lim(5);
  for (int i = 0; i < 5; ++i) {
    cin >> load_lim[i];
  }
  ll min_v = *min_element(load_lim.begin(), load_lim.end());
  ll quot = (N + (min_v - 1)) / min_v;
  ll result = quot - 1 + 5;
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int e = sc.nextInt();
		
		V = x + y;

		//グラフの隣接リスト表現
		@SuppressWarnings("unchecked")
		Vector<Integer> G[] = new Vector[V];
		for(int i = 0; i < G.length; i++){
			G[i] = new Vector<Integer>();
		}
		
		for(int i = 0; i < e; i++){
			addEdge(G, sc.nextInt(), sc.nextInt() + x);
		}
		
		System.out.println(bipartiteMatching(G));

	}
	//頂点数
	static int V;
	//マッチングのペア
	static int match[];
	//DFSで既に使用したか
	static boolean[] used;

	static void addEdge(Vector<Integer>[] G, int u, int v){
		G[u].add(v);
		G[v].add(u);

		//			System.out.println("add "+u+" and "+v);
	}

	//二部グラフの最大マッチングを求める
	static int bipartiteMatching(Vector<Integer>[] G){
		int result = 0;
		match = new int[G.length];
		Arrays.fill(match, -1);

		used = new boolean[G.length];
		for(int v = 0; v < G.length; v++){
			if(match[v] < 0){
				Arrays.fill(used, false);
				if(dfs(G, match, used, v)){
					result++;
				}
			}
		}
		return result;
	}

	//増加パスを探す
	static boolean dfs(Vector<Integer>[] G, int[] match, boolean[] used, int v){
		used[v] = true;

		for(int i = 0; i < G[v].size(); i++){
			int u = G[v].get(i);
			int w = match[u];

			if(w < 0 || !used[w] && dfs(G, match, used, w)){
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}


}



Measured memory_bytes: 49100
//        _                                  _               
//    |  | |                                | |              
//  __|  | |     __,   _  _    __,   ,   _  | |   __,   ,_   
// /  |  |/ \   /  |  / |/ |  /  |  / \_|/  |/_) /  |  /  |  
// \_/|_/|   |_/\_/|_/  |  |_/\_/|_/ \/ |__/| \_/\_/|_/   |_/(FIGLET)

#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
typedef vector<ll> vll;
typedef vector <vll> vvll;
typedef pair <ll,ll> pll;
typedef vector <pll> vpll;
 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define gcd __gcd
#define forl(i,k,n) for(ll i=k;i<n;i++)
#define MOD 1000000007 //10^9 + 7
#define all(x) x.begin(),x.end()
#define VALUE(x) cout << #x << " : " << x << '\n' 

void pprint(){;}
template<typename T>
void print(pair<T,T> var1)
{	cout<<var1.fi<<' '<<var1.se<<' ';cout<<'\n';}
template<typename T>
void print(T var1)
{	cout<<var1<<'\n';}
template<typename T>
void print(vector<T> &var1)
{	for(auto &i:var1)cout<<i<<' ';cout<<'\n';}
template<typename T,typename... Types>
void print(T var1,Types...var2)
{	cout<<var1<<' ';print(var2...); }
template<typename T,typename... Types>
void pprint(T var1,Types...var2)
{	print(var1);pprint(var2...); }

template<typename T>
void read(T &x)
{	cin>>x;}
template<typename T,typename...Types>
void read(T &var1,Types&... var2)
{	cin>>var1;read(var2...);}
template<typename T>
void read(vector<T> &var1)
{	for(auto &i:var1)read(i);}
template<typename T>
void read(pair<T,T> &var1)
{	cin>>var1.fi>>var1.se;}


template<typename T>
T Max(T x)
{	return x; }
template<typename T,typename... Types>
T Max(T var1,Types...var2)
{	return var1>=Max(var2...)?var1:Max(var2...); }

template<typename T>
T Min(T x)
{	return x; }
template<typename T,typename... Types>
T Min(T var1,Types...var2)
{	return var1<=Min(var2...)?var1:Min(var2...); }

bool isEven(ll x){return x%2==0;}
bool isOdd(ll x){return x%2;}

ll INF = 1000000000000000005LL;
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };

void solve(); 
int main() { 
ios_base::sync_with_stdio(false);cin.tie(NULL); 

#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin); freopen("error.txt", "w", stderr); 
freopen("output.txt", "w", stdout); 
#endif 

int t=1; 
 
while(t--) 
{    solve();     } 
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;return 0; 
} 


void solve() 
{ 
  ll n;
  cin>>n;
  cout<<(1000-((n+1000)%1000))%1000;
  
} 





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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define ll long long
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD ll(1000000007)

int main()
{ FAST
    int n; cin >> n;
    map<string, int> votes;
    string arr[n];
    for(int i = 0; i < n; i++){
        string a; cin >> a;
        arr[i] = a;
        votes[a]++;
    }
    vector<string> ans;
    int MAX = 0;
    for(int i = 0; i < n; i++){
        MAX = max(MAX, votes[arr[i]]);
    }
    for(int i = 0; i < n; i++){
        if(votes[arr[i]] == MAX){
            ans.pb(arr[i]);
            votes[arr[i]] = -1;
        }
    }
    sort(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main(void){
	vector<int> a(200000,0);
	int n, k, at;
	cin >> n >> k;
	for(int i = 0; i < n; ++i){
		cin >> at;
		a[at]++;
	}
	sort(a.rbegin(), a.rend());
	int sum = 0;
	int count = 0;
	for(auto x: a){
		if(x != 0){
			count++;
		}
	}
	for(int i = 0; i < k; ++i){
			sum += a[i];
	}
		cout << n - sum  << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define STR_LEN 100000
int judge(char *);
int judge(char *s)
{
    int i,j;
    int n=strlen(s);
    if(n%2!=0)
    {
        return 0;
    }
    for(i=0,j=n-1;i<j;i++,j--)
    {
        if((s[i]=='p'&&s[j]=='q')||(s[i]=='q'&&s[j]=='p')||(s[i]=='b'&&s[j]=='d')||(s[i]=='d'&&s[j]=='b'))
        {
            continue;
        }
        else
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    char a[STR_LEN+1]={0};
    scanf("%s",a);
    printf((judge(a)==1)?"Yes\n":"No\n");
    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[] tmp = new int[3];

    for(int i = 0; i < 3; i++){
      tmp[i] = sc.nextInt();
    }

    Arrays.sort(tmp);

    System.out.println(tmp[0] + " " + tmp[1] + " " + tmp[2]);
  }
}



Measured memory_bytes: 26328
N,M,Q=map(int,input().split())
g=0
lst=[[0 for e in range(4)] for f in range(Q)]
for k in range(Q):
 lst[k]=list(map(int,input().split()))
for i in range(2**(M+N)):
 E=0
 W=1
 Sui=[0]*(M+N)
 for j in range(M+N):
  if ((i >> j) & 1):
   Sui[E]=W
   E+=1
  else:
   W+=1
 if E==N and Sui[N-1]<=M:
  f=0
  for s in range(Q):
   if Sui[lst[s][1]-1]-Sui[lst[s][0]-1]==lst[s][2]:
    f+=lst[s][3]
  g=max(g,f)
print(g)


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

int main(){
    int n;
    cin >> n;
    int cnt=0;
    for(int i=0; i<n; i++){
        int m;
        cin >> m;
        int j=2;
        int prime_flg=1;
        while(j*j<=m){
            if(m%j==0){
                prime_flg=-1;
                break;
            }
            else{
                if(j==2) j++;
                else j+=2;
            }
        }
        if(prime_flg==1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;

int f(int x){
  int r = x%4;
  if(r == 0)
      return x;
  else if(r == 1)
    return  1;
  else if(r == 2)
    return x + 1;
  else
    return 0;
}
signed main(){
 int a , b;
   cin >> a >> b;
   if(a == 0){
      cout << f(b) << endl;
      return 0;
   }
   else{
    cout << (f(b) ^ f(a-1)) << endl;
   }

}	



// agc;  021
// acg;  012
// gac;  201

Measured memory_bytes: 256
S=input()
ng = 0
for i in range(len(S)):
  if ( i%2 == 1 ):
    if S[i] == 'R':
      ng = 1
  else:
    if S[i] == 'L':
      ng = 1
if ng == 1:
  print("No")
else:
  print("Yes")
  

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

cnt = Counter()
ques = []
for _ in range(n):
    a = list(map(int, input().split()))
    cnt[a[0]] += 1
    ques.append(deque(a))

ans = n
used = [False for _ in range(m+1)]
while True:
    cnt_most = cnt.most_common()
    if cnt_most[0][1] == 0:
        break
    ans = min(ans, cnt_most[0][1])
    for x, t in cnt_most:
        if t >= ans:
            used[x] = True
        else:
            break
    for i in range(n):
        while len(ques[i]) > 0 and used[ques[i][0]]:
            x = ques[i].popleft()
            cnt[x] -= 1
            if len(ques[i]) > 0:
                cnt[ques[i][0]] += 1

print(ans)

Measured memory_bytes: 47068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

void solve() {
    string str;
    cin >> str;
    map<char, int> mp;
    rep(i, SZ(str)) mp[str[i]]++;
    // for (auto e : mp) out(e.F << " " << e.S);
    if ((mp['N'] == 0 && mp['S'] != 0) || (mp['N'] != 0 && mp['S'] == 0) || (mp['W'] != 0 && mp['E'] == 0) || (mp['W'] == 0 && mp['E'] != 0)) out("No");
    else out("Yes");
}
int main() {
    solve();
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(s: int):

    def f(x: int):
        return x // 2 if x % 2 == 0 else x * 3 + 1

    d = set()
    ai = s
    i = 1
    while ai not in d:
        d.add(ai)
        ai = f(ai)
        i += 1

    print(i)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  # type: int
    solve(s)


if __name__ == '__main__':
    main()


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

int main(){
  int A,B;
  cin>>A>>B;
  for(int i=0;i<=1000;i++)
    if(i*8/100==A && i*10/100==B){
      cout<<i<<endl;
      return 0;
    }
  cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 2010;
const int MOD = (int) 1e9 + 7;

int n, k, a[N];

int main() {

	scanf("%d %d", &n, &k);

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

	long long d = (k - 1LL) * (k - 0LL) / 2LL;
	long long res = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] > a[j]) {
				res += ((i < j) ? k : 0);
				res += d;
				res %= MOD;
			}
		}
	}

	printf("%lld\n", res);

	return 0;

}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

daylist = [31,29,31,30,31,30,31,31,30,31,30,31]
namelist = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

N = list(get_input())
m,d = [int(i) for i in N[0].split()]
cnt = 1
while m != 0 or d != 0:
    ans = 2
    for i in range(m-1):
        ans += daylist[i]
    ans += d
    ans %= 7
    print(namelist[ans])

    m,d = [int(i) for i in N[cnt].split()]
    cnt += 1


Measured memory_bytes: 5596
import os
import sys

import numpy as np

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

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

N, L, T = list(map(int, sys.stdin.readline().split()))
X, W = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

X = np.array(X)
W = np.array(W)

w1 = W == 1
X1 = X[w1]
X2 = X[~w1]
# W1[0] の本来のインデックス
x1_i = np.argmax(w1)

positions = np.concatenate([(X1 + T) % L, (X2 - T) % L])
positions.sort()

if len(X1) > 0 and len(X2) > 0:
    # MOD L で X1[0] がすり抜ける時間
    collisions = np.concatenate([(X2 - X1[0]) % L / 2, (X2 - X1[0]) % L / 2 + L / 2])
    # T 秒間にすり抜ける回数
    collision_count = T // L * len(collisions) + np.searchsorted(sorted(collisions), T % L)

    # (X1[0] + T) % L にいるのが (x1_i + collision_count) % N ばんめのあり
    idx = np.searchsorted(positions, (X1[0] + T) % L)
    ans = np.roll(positions, (x1_i + collision_count) % N - idx)
elif W[0] == 1:
    ans = (X + T) % L
elif W[0] == 2:
    ans = (X - T) % L
else:
    assert False
print('\n'.join(map(str, ans)))


Measured memory_bytes: 59248
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        int ans = 0;

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            for(int j=0; j<100; j++){
                if(a[i]%2==0){
                    ans += 1;
                    a[i] = a[i] / 2;
                }
                else{
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36212
n,m,k = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
  a_sum.append(a_sum[i] + a_list[i])
for i in range(m):
  b_sum.append(b_sum[i] + b_list[i])
 
ans = 0
for i in range(n+1):
  if a_sum[i] > k:
    break
        
  rem = k - a_sum[i]
  while b_sum[m] > rem:
    m -= 1
  if ans < i + m:
    ans = i + m
        
print(ans)


Measured memory_bytes: 47476
#include <iostream>
#include <cstdio>

using namespace std;

int pa[100000+10];

int find(int v)
{
    if(pa[v]==v)
    return v;
    return find(pa[v]);
}

int main()
{
    int n,q,a,b;
    while(~scanf("%d%d",&n,&q))
    {
        if(n==0&&q==0)
        break;
        for(int i=2;i<=n;i++)
        scanf("%d",&pa[i]);
        pa[1]=1;
        long long sum=0;
        char s[5];
        while(q--)
        {
            scanf("%s%d",s,&b);
            if(s[0]=='Q')
            sum=sum+find(b);
            else
            pa[b]=b;
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <vector>
#include <limits>

constexpr auto INF = std::numeric_limits<int>::max();

using Pair = std::pair<int, int>;

int n, m;
Pair size[210];
int dp[210];

int main() {
    while(std::cin >> n, n) {
        for(int i = 0; i < n; ++i) {
            std::cin >> size[i].first >> size[i].second;

            size[i].second *= -1;
        }
        std::cin >> m;
        for(int i = 0; i < m; ++i) {
            std::cin >> size[n + i].first >> size[n + i].second;

            size[n + i].second *= -1;
        }

        std::sort(size, size + n + m);
        std::fill(dp, dp + 210, INF);

        int max = 0;
        for(int i = 0; i < n + m; ++i) {
            size[i].second *= -1;

            auto p = std::lower_bound(dp, dp + 210, size[i].second);

            *p = size[i].second;

            max = std::max<int>(max, p - dp);
        }

        std::cout << max + 1 << std::endl;
    }
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
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); }

/*--------------------template--------------------*/

typedef int Weight;
typedef int Flow;
struct Edge {
	int src, dest, rev;
	Flow cap;
	Weight cost;
	bool operator < (const Edge &rhs) const
	{
		return cost > rhs.cost;
	}
	Edge(int s, int d) : src(s), dest(d) { ; }
	Edge(int s, int d, int c) : src(s), dest(d), cost(c) { ; }
	Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int src, int dest, Flow cap)
{
	g[src].push_back(Edge{ src, dest, (int)g[dest].size(), cap, 0 });
	g[dest].push_back(Edge{ dest, src, (int)g[src].size() - 1, 0, 0 });
}
Flow dfs(Graph &g, vector<bool> &used, int v, int t, Flow f)
{
	if (v == t) return f;
	used[v] = true;
	for (Edge& e : g[v])
	{
		if (!used[e.dest] && e.cap > 0)
		{
			Flow d = dfs(g, used, e.dest, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				g[e.dest][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

Flow ford_fulkerson(Graph &g, int s, int t)
{
	Flow flow = 0;
	for (;;)
	{
		vector<bool> used(g.size(), false);
		Flow f = dfs(g, used, s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	Graph g(n);
	vector<pii> v;
	REP(i, m)
	{
		int s, t; cin >> s >> t;
		s--; t--;
		add_edge(g, s, t, 1);
		add_edge(g, t, s, 1);
		v.emplace_back(s, t);
	}
	int s, t; cin >> s >> t;
	s--; t--;
	int ans = ford_fulkerson(g, s, t);
	cout << ans << endl;
	vi ansv;
	REP(i, m)
	{
		int from = v[i].second;
		REP(j, g[from].size())
		{
			if (g[from][j].dest != v[i].first) continue;
			if (g[from][j].cap == 0)
			{
				ansv.push_back(i+1);
				break;
			}
		}
	}
	cout << ansv.size() << endl;
	REP(i, ansv.size()) cout << ansv[i] << endl;
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int m=INT_MAX,ma=INT_MIN;
	int m1=INT_MAX,ma1=INT_MIN;
	int x,y;
	for(int i=0;i<n;i++)
	{
			cin>>x>>y;
			m=min(m,x+y);
			m1=min(m1,x-y);
			ma=max(ma,x+y);
			ma1=max(ma1,x-y);
	}
	cout<<max(abs(m-ma),abs(m1-ma1))<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    string s;
    cin >> s;
    //cout << s.front() << endl;
    if(s.front() != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    bool ok1 = false;
    bool ok2 = false;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            if(!ok1) ok1 = true;
            else ok2 = true;
        }
    }
    if(!ok1){
        cout << "WA" << endl;
        return 0;
    }
    if(ok2){
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for(int i=0;i<s.size();i++){
        if(isupper(s[i])) cnt++;
    }
    //cout << cnt << endl;
    if(cnt == 2){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

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

template<class T> inline T sq(T x){return x*x;}

int main(void){
  int ans,n;
  double ave=0;
  vector<int> v;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int t; cin >> t;
    v.push_back(t);
    ave += t;
  }
  ave /= n;
  ans = 0;
  for (int i=0; i<n; i++){
    int cost = sq((int)round(ave)-v[i]);
    ans += cost;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='R') a++;
        else b++;
    if(a>b) printf("Yes");
    else printf("No");
}


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

int main(){
	string s;
  	cin >> s;
  	int n = s.size();
  	rep(i, n) s[i] = 'x';
  	cout << s << endl;
}

Measured memory_bytes: 3608
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_D() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    vi A(N); REP(i, N) cin >> A[i];
    vi B(M), C(M); REP(i, M) cin >> B[i] >> C[i];

    priority_queue<pii> pq;
    REP(i, N) {
        pq.push(pii(A[i], 1));
    }

    REP(i, M){
        pq.push(pii(C[i], B[i]));        
    }

    ll ans = 0;
    REP(i,N) {
        pii hi = pq.top(); pq.pop();
        ans += hi.first;
        if (hi.second-1 >= 1) {
            pq.push(pii(hi.first, hi.second - 1));
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int A = 0, B = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) A += a.at(i);
        else B += a.at(i);
    }
    cout << A - B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int a, b;
	scanf("%d %d", &a, &b);
	char str [a+b+1];
	scanf("%s", str);
	int atr = 0;
	
	for ( int i = 0 ; i < a+b+1 ; i++) {
		if (str[a] != '-') {
			printf("No\n");
			return 0;	
		}
		if (str[i] >= '0' && str[i] <= '9') {
			++atr;
		}
	}
	int total = a+b; 
	if (atr == total) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

int main(){
    int N, Q;
    cin >> N >> Q;
    string ac = "AC";

    string S;
    cin >> S;
    int l[100000], r[100000];       
    int answer[100000];

    for (int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
        answer[i] = 0;
    }


    int t[100000];
    t[0] = 0;

    for (int i = 1; i < S.size(); i++){
        if (S.substr(i - 1, 2) == ac){
            t[i] = t[i - 1] + 1;
        }
        else t[i] = t[i - 1];
    }
/*
    for (int i = 0; i < Q; i++){
        string sub;
        sub = S.substr(l[i] - 1, r[i] - l[i] + 1);
        for (int j = 0; j < sub.size() - 1; j++){
            if (sub.substr(j, 2) == ac){
                answer[i]++;
            }
        }
    }
*/
    for (int i = 0; i < Q; i++){
        cout << t[r[i] - 1] - t[l[i] - 1] << endl;  
    }
    return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  char C;
  
  for(int i = 0; i <N ; i++){
    cin >> C;
      if(i == N-1){
          cout << "Three" << endl;
      }
    if(C == 'Y'){
        cout << "Four" << endl;
        break;
    }
    
    else {
        continue;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int H, A;
	cin >> H >> A;

	cout << (H+A-1)/A << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

ll dp[2005][2005];

void max_self(ll& a,ll b){
	if(b>a) a=b;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<pair<ll,int>> a;
	for(int i=0;i<n;++i){
		ll x;
		cin>>x;
		a.emplace_back(x,i);
	}
	sort(all(a));
	reverse(all(a));
	for(int l=0;l<n;++l){
		for(int r=0;r<n-l;++r){
			ll num=a[l+r].first;
			int id=a[l+r].second;
			//~ if(!l&&!r){
				//~ cout<<id-l<<" ~ "<<n-1-r-id<<endl;
			//~ } 
			max_self(dp[l+1][r],dp[l][r]+num*(id-l));
			max_self(dp[l][r+1],dp[l][r]+num*(n-1-r-id));
		}
	}
	ll ans=0;
	for(int i=0;i<n;++i) max_self(ans,dp[i][n-i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b; cin >> a >> b;
    cout << max(a+a-1, max(b+b-1, a+b)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

#include <array>

/*
    nCk, nPk, 階乗をmodをとりつつ求めるライブラリ
*/
template <int MAX_N = 100000, long long MOD = 1000000007LL>
class Combination {
    std::array<long long, MAX_N + 1> _fact;
    std::array<long long, MAX_N + 1> _fact_inv;

public:
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long inv(long long a) const {
        long long b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);

            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0)
            u += MOD;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // 1 / n!
    long long fact_inv(long long n) const {
        return _fact_inv[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * fact_inv(n - k) % MOD;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * fact_inv(k) % MOD;
    }

    Combination() : _fact{}, _fact_inv{} {
        _fact[0] = _fact[1] = 1LL;
        for (int i = 2; i <= MAX_N; ++i) {
            _fact[i] = _fact[i - 1] * i % MOD;
        }
        _fact_inv[MAX_N] = inv(_fact[MAX_N]);
        for (int i = MAX_N - 1; i >= 0; --i) {
            _fact_inv[i] = _fact_inv[i + 1] * (i + 1) % MOD;
        }
    }
};

Combination<> cm;

int main() {
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll ans = 0;
    constexpr ll mod = inf;
    for (int i = 0; i < n; ++i) {
        int rmin = i;
        int rmax = n - (i + 1);

        if (rmin >= k - 1) ans += a[i] * cm.comb(rmin, k - 1) % mod;
        ans %= mod;
        if (rmax >= k - 1) ans -= a[i] * cm.comb(rmax, k - 1) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;

  int ans = 0;

  for(int i = 0; i < 3; i++){
    if(s[i] == t[i]){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MaxN = 100000;

int N;

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		int neg = 0;
		LL sum = 0LL;
		int M = 1 << 30;
		for(int i = 1; i <= N; i++) {
			int x; scanf("%d", &x);
			if(x < 0) neg++;
			sum += abs(x);
			M = min(M, abs(x));
		}
		//printf("sum = %d neg = %d M = %d\n", sum, neg, M);
		if(neg & 1) sum = sum - 2 * M;
		printf("%lld\n", sum);
	}
	return 0;
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

const int MXN = 2e5;
vector<pair<int, int>> city[MXN + 1];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    int c = 1;
    unordered_set<int> pre;
    for (int i=0; i<m; ++i) {
        int p, y; cin >> p >> y;
        pre.insert(p);
        city[p].PB(MP(y, c));
        c++;
    }
    vector<pair<int, string>> ans;
    for (auto i : pre) {
        vector<pair<int, int>> pi = city[i];
        sort(pi.begin(), pi.end());
        for (int j = 0; j < pi.size(); ++j) {
            string s1(6 - to_string(i).size(), '0'), s2(6 - to_string(j + 1).size(), '0');
            s1 += to_string(i);
            s2 += to_string(j + 1);
            ans.PB(MP(pi[j].second, s1 + s2));
        }
    }
    sort(ans.begin(), ans.end());
    for (auto i : ans) {
        cout << i.second << "\n";
    }
}

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

using lint = long long;

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

typedef Point<double> P;
double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

pair<P, double> mec(vector<P> ps) {
	shuffle(ps.begin(),ps.end(), mt19937(time(0)));
	P o = ps[0];
	double r = 0, EPS = 1 + 1e-8;
	for(int i = 0; i < ps.size(); ++i) 
	    if ((o - ps[i]).dist() > r * EPS) {
		    o = ps[i], r = 0;
		    for(int j = 0; j < i; ++j) if ((o - ps[j]).dist() > r * EPS) {
			    o = (ps[i] + ps[j]) / 2;
			    r = (o - ps[i]).dist();
			    for(int k = 0; k < j; ++k) 
			        if ((o - ps[k]).dist() > r * EPS) {
				        o = ccCenter(ps[i], ps[j], ps[k]);
				        r = (o - ps[i]).dist();
			        }
		    }
	    }
	return {o, r};
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    cout << fixed << setprecision(19);
    vector<P> points(n);
    for (int i = 0; i < n; ++i) cin >> points[i].x >> points[i].y;
    auto ret = mec(points);
    cout << ret.second << '\n';
}

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

int main(){
 int Th, Ts, Ah, As;
  cin>>Th>>Ts>>Ah>>As;
  while(1){
  	Ah -= Ts;
    if(Ah<=0){
    	cout<<"Yes"<<endl;
    	break;
    }
    Th -= As;
    if(Th<=0){
    	cout<<"No"<<endl;
    	break;
      }
  }
}

Measured memory_bytes: 3620
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,M = II()
A,B = Line(N-1+M,2)

parent = [[] for _ in range(N)]
parent_num = [0]*N
pt = [[] for _ in range(N)]

for i in range(N-1+M):
    parent[B[i]-1].append(A[i]-1)
    parent_num[B[i]-1] += 1
    pt[A[i]-1].append(B[i]-1)

for i in range(N):
    if parent[i]==[]:
        root = i

ans = ['0']*N
q = [root]
while q:
    q_new = []
    for q1 in q:
        for v in pt[q1]:
            if parent_num[v]==1:
                ans[v] = q1+1
                q_new.append(v)
            parent_num[v] -= 1
    q = q_new

for i in range(N):
    print(ans[i])

Measured memory_bytes: 90332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#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 repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    ll n, x, t;
    cin >> n >> x >> t;
    ll a = (n+x-1)/x;
    cout << a*t << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bits/c++config.h>
using namespace std;


int main()
{

   int h;
   int w;
   cin>> h>>w;

   char image [h][w];
   for (int a=0;a<h;a++)
   {
       for(int b=0;b<w;b++)
       {
           cin>>image[a][b];
       }
   }
    int hh=h+2;
    int ww=w+2;
    char newimage[hh][ww];

     for (int d=0;d<ww;d++)
    {
        newimage[0][d]='#';
    }

    for (int c=1;c<hh-1;c++)
   {

       newimage[c][0]='#';

        for (int e=1;e<ww;e++)
    {
        newimage[c][e]=image [c-1][e-1];
    }
     newimage[c][ww-1]='#';
   }
    for (int f=0;f<ww;f++)
    {
        newimage[hh-1][f]='#';
    }

   for (int g=0;g<hh;g++)
   {
       for (int j=0;j<ww;j++)
       {
           cout<< newimage[g][j];
       }

        cout <<endl;

   }

}



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

int main()
{

        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        double dx = abs(x2 - x1);
        double dy = abs(y2 - y1);

        double ans = sqrt(dx * dx + dy * dy);
        printf("%.8lf\n", ans);


}



Measured memory_bytes: 3288
#include <algorithm>
#include <iostream>
#include <functional>
using namespace std;

const int MAX_N = 100002;
int house[MAX_N];
int dist[MAX_N];

int main() {
    int t, n, k, i, j, ans;
    ios_base::sync_with_stdio(0);
    cin >> t;
    for(i=0;i<t;i++){
        cin >> n >> k;
        
        for(j=0;j<n;j++){
            cin >> house[j];
        }
        
        if(k>=n){
            cout << 0 << endl;
            continue;
        }
        for(j=0;j<n-1;j++){
            dist[j]=house[j+1]-house[j];
        }
        sort(dist,dist+n-1, greater<int>());
        
        ans=house[n-1]-house[0];
        for(j=0;j<k-1;j++){
            ans-=dist[j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3868
using System;

namespace arc068_a
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long x = 0;
            x += n / 11 * 2;
            n = n % 11;
            if (n != 0)
            {
                x++;
                if (n > 6)
                {
                    x++;
                }
            }
            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x1fffffffffffffff;
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(auto& i : a) cin >> i;
  ll ans = INF;
  for(ll p = 1; p <= 100; p++){
    ll cnt = 0;
    for(auto& x : a) cnt += (x - p) * (x - p);
    chmin(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
    sum=c
    for j in range(m):
        sum+=a[i][j]*b[j]
    if sum > 0:
        cnt+=1
    else:
        cnt=cnt
print(cnt)


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[20], t; double dp[20][200000]; vector<int> s[200000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), t = max(t, a[i]);
	for (int i = 1; i < 2 * t; i++) {
		for (int j = i; j < 2 * t; j += i) {
			s[j].push_back(i);
		}
	}
	for (int i = 1; i < 2 * t; i++) dp[0][i] = 1.0 * abs(a[0] - i) / a[0];
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < 2 * t; j++) {
			dp[i][j] = 1.0;
			for (int k = 0; k < s[j].size(); k++) {
				dp[i][j] = min(dp[i][j], max(dp[i - 1][s[j][k]], 1.0 * abs(a[i] - j) / a[i]));
			}
		}
	}
	double ret = 1.0;
	for (int i = 1; i < 2 * t; i++) {
		ret = min(ret, dp[n - 1][i]);
	}
	printf("%.9f\n", ret);
	return 0;
}

Measured memory_bytes: 53996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() {
    fastio
    ll n, x, t;
    cin>>n>>x>>t;
    cout<<(n/x + (n%x!=0))*t<<endl;
}

Measured memory_bytes: 3612
#!/usr/bin/env python3
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))

dst = defaultdict(int)

for i, a in enumerate(A, 1):
    dst[i] = a

done = [0 for _ in range(N + 1)]
done[1] = 1
hist = [1]

now = 1
cnt = 0

while cnt < K:
    now = dst[now]
    cnt += 1
    if done[now] == 0:
        done[now] = 1
        hist.append(now)
    else:
        syuki = cnt - hist.index(now)
        print(hist[hist.index(now) + (K - cnt) % syuki])
        exit()
print(hist[-1])

Measured memory_bytes: 40336
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long 
#define MAX 25 * 1e13


using namespace std;

int MOD = 1000000007;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 0 ; i < n ; i++) {
    cin >> a[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll> (n+1));
  vector<ll> suma(n+1);
  //len = 1
  for( int i = 0 ; i < n ; i++ ){
    dp[i][i] = 0;//span [i,i]
  }
  suma[0] = a[0];
  for(int i = 1 ; i < n ; i++ ){
    suma[i] = suma[i-1] + a[i];
  }

  for( int len = 2 ; len <= n ; len++ ){
    for( int i = 0 ; i <= n - len ; i++ ){// n-1 , len , n-1 - x + 1 == len, i is start point
      int e = i + len-1;// span : [i,e]
      //split to 2 spans : [i,m] and [m+1,e]
      ll mincost = MAX;
      for( int mid = i ; mid <= e - 1 ; mid ++ ){
        mincost = min( mincost , dp[i][mid] + dp[mid+1][e] + (suma[e] - suma[i] + a[i] ));
      } 
      dp[i][e] = mincost;
      //printf("%d %d %lld\n",i,e,mincost);
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 1536