akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  ll ans=0;
  for(int bit=0;bit<(1<<n-1);bit++){
    ll cu=s[0]-'0';
    for(int i=0;i<n-1;i++){
      if(bit&(1<<i)){
        ans+=cu;
        cu=0;
        cu+=s[i+1]-'0';
      }
      else{
        cu*=10;
        cu+=s[i+1]-'0';
      }
    }
    ans+=cu;
  }
  COUT(ans);
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 24 11:38:31 2019
//
package main

import (
	"fmt"
	"sort"
)

func scanSlice(slice []int) {
	for i := range slice {
		fmt.Scan(&slice[i])
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var N int
	fmt.Scan(&N)
	slice := make([]int, N)
	scanSlice(slice)

	for i := range slice {
		slice[i] -= i + 1
	}
	sort.Ints(slice)

	mid := slice[len(slice)/2]

	ans := 0
	sum := 0
	for _, s := range slice {
		sum += abs(s - mid)
	}

	ans = sum
	if len(slice) > 1 {
		mid = slice[len(slice)/2-1]
		sum = 0
		for _, s := range slice {
			sum += abs(s - mid)
		}
		if sum < ans {
			ans = sum
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int mod = 1E9 + 7;
const int inf = 1 << 29;

char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
int base = 26;

int main() {
  ll n;
  cin >> n;
  string name = "";
  n -= 1;
  while (n >= base) {
    name += alphabet[n % base];
    n /= base;
    n -= 1;
  }
  name += alphabet[n];
  reverse(name.begin(), name.end());
  cout << name << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
  int a[5];
  int i,j;
  int tmp;

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

  for(j=0;j<5;j++){
    for(i=0;i<4;i++){
      if(a[i]<a[i+1]){
        tmp=a[i];
        a[i]=a[i+1];
        a[i+1]=tmp;
      }
    }
  }

  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)


const ll MOD = 1e9+7; // modification needed.
const int MAX = 1e6; // modification needed.

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

void cominit(){

    fac[0]  = fac[1]  = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll com(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){

    ll n, m; cin >> n >> m;

    cominit();

    ll mtemp = m;
    ll index = 2;
    map<ll, ll> mp;
    while(mtemp > 1){
        if(mtemp % index == 0){
            mp[index]++;
            mtemp /= index;
        }
        else{
            index++;
        }
    }

    for(auto x : mp){
        // cout << x.first << " " << x.second << endl;
    }

    ll ans = 1;
    for(auto x : mp){
        ans = (ans * com(n + x.second - 1, x.second)) % MOD;
    }

    cout << ans;

    return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){

    int n,m;
    cin>>n>>m;

    int ch,dch;
    if(n>m){
        ch = m;
        dch = n;
    }else{
        ch = n;
        dch = m; 
    }

    for(int i=0;i<dch;i++){
        cout<<ch;
    }

}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int a;
	cin>>a;
	if(a<1000){
		cout<<"ABC"<<endl;
	}
	else{
		cout<<"ABD"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
  readLine()
  readLine()!!.split(" ").map { it.toInt() }.apply {
    val mid = max()!! / 2
    var dif = Int.MAX_VALUE
    sorted().forEach {
      if (it >= mid) {
        print(if (it - mid > dif || it == max()) "${max()} ${mid - dif}" else "${max()} $it")
        return
      } else if (mid - it < dif) dif = mid - it
    }
  }
}

Measured memory_bytes: 56256
#include<iostream>
#include<cstdio>
#include<vector> 
#include<cstring>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> list[maxn];
int vis[maxn];
int lose=0;
void bfs(int ne,int be,int re)
{
	if(!lose)
	{
		if(vis[ne]==-1)
			vis[ne]=re;
		else
			if(vis[ne]!=re)
			{
				lose=1;
				return;
			}
			else
				return;
		for(int i=0;i<list[ne].size();i++)
		{
			if(list[ne][i]!=be)
				bfs(list[ne][i],ne,!re);	
		}
	
	}
	
}
int main()
{
	long long m,n;
	scanf("%lld%lld",&m,&n);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		list[x].push_back(y);
		list[y].push_back(x);
	}
	memset(vis,-1,sizeof(vis));
	bfs(1,0,1);
	long long q=0,p=0;
	for(int i=1;i<=m;i++)
	{
		if(vis[i]==1)
			q++;
		else
			p++;
	}
	if(lose)
		printf("%lld\n",m*(m-1)/2-n);
	else
		printf("%lld\n",q*p-n);
	
	return 0;
}

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

using namespace std;

using ll = long long;
const int MOD = 998244353;

// dp[i][j] => starting from i items already considered and sum of such items(taken in set both U and T) is j

int main()
{
    int n, s;
    cin >> n >> s;
    vector<int> arr(n);
    for(auto& x : arr) cin >> x;
    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int sum = 0; sum <= s; sum++) {
            dp[i + 1][sum] += 2 * dp[i][sum]; // arr[i] not included in U, but may or may not be included in T.
            dp[i + 1][sum] %= MOD;
            if(sum + arr[i] <= s) {
                dp[i + 1][sum + arr[i]] += dp[i][sum];
                dp[i + 1][sum + arr[i]] %= MOD;
            }
        }
    }
    cout << dp[n][s];
    return 0;
}


Measured memory_bytes: 73656
import fractions

def resolve():
    a,b,c,d = map(int,input().split())
 
    dividable_by_c = b // c - (a-1) // c
    dividable_by_d = b // d - (a-1) // d
    lcm = c * d // fractions.gcd(c,d)
    dividable_by_c_and_d = b // lcm - (a-1) // lcm
 
    result = (b - a + 1) - dividable_by_c - dividable_by_d + dividable_by_c_and_d
    print(result)
resolve()

Measured memory_bytes: 66156
/* CODE BY NITIN 
	ON 5 April 2020--------------
	*/
	
	#include <bits/stdc++.h>
	//#include<boost/multiprecision/cpp_int.hpp>
	#define mod 1000000007
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
	#define REP(i, n) for (int i = 0; i < (n); i++)
	#define REPN(i, n) for (int i = 1; i <=(n); i++)
	#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
	#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
	#define T(a) ll a;  cin >> a;
	#define TT(t) T(t); while (t--)
	#define pb push_back
	#define mp make_pair
	 #define ll long long int
	using namespace std;
 
 
	void solve()
	{
	
	
 
		T(r)
		cout<<float(2*3.14*r)<<endl;
 
				
		
	}
	int main()
	{
		
		
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
		solve();
		return 0;
		
	}

Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}

bool is_integer( double x ){//https://qiita.com/Nabetani/items/3280a08340aeececfe33
  return std::floor(x)==x;
}
int main(){//
    
    double X, Y;
    cin >> X >> Y;

    double a, b;
    a = 2*X - Y/2;
    b = -X + Y/2;
    // cout << " a: " << a << " b: "  << b<< endl;
    // cout << is_integer(a) << endl;
    if( a < 0) {
        cout << "No" << endl;
        return 0;
    }
    if( b < 0){
        cout << "No" << endl;
        return 0;
    }
    if(is_integer(a) == false){
        cout << "No" << endl;
        return 0;
    }
    if(is_integer(b) == false){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    

    
}

Measured memory_bytes: 3808
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) sort(a.rbegin(),a.rend())
#define Sort(a) sort(a.begin(),a.end())
#define Sum(a)  accumulate(a.begin(), a.end(), 0)
#define rep(i,n) for(UI i=0;i<n;i++)

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, M;
	LL calc = 0;
	LL sum = 0;
	LL ans = 0;

	cin >> N >> M;

	vector<LL>X((UI)M);

	rep(i, M) {
		cin >> X[i];
	}

	Sort(X);
	vector<LL>Y;

	for (UI i = 0; i< X.size() - 1; i++) {
		Y.push_back(X[i + 1] - X[i]);
		sum += Y[i];
	}

	rSort(Y);

	if (N>=M) {
		ans = 0;
	}
	else {
		
		for (UI i = 0; i < N - 1; i++) {
			calc += Y[i]; // 除去する分
		}
		ans = sum - calc;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

bool isprime[60000];

vector<int> eratos(int n) {
	vector<int> v;

	for (int i = 2; i <= n; i++) isprime[i] = true;

    for (int i = 2; i <= n; i++) {
    	if ( isprime[i] == true ) {
    		v.push_back(i);
    		for (int j = i + i; j <= n; j += i) isprime[j] = false;
    	}
    }
    return v;
}

int ans, N;


int main(void) {
    scanf("%d", &N);
    eratos(55555);

    int c = 0;
    for (int i=2; i<=55555; i++) {
        if (isprime[i] && i%5==1) {
            if (c>0) printf(" ");
            printf("%d", i);
            c++;
        }
        if (c==N) {
            printf("\n");
            return 0;
        };
    }

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n, m, ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i = 1 ; i*i <= m ; i++ )
    {
        if( m%i == 0 )
        {
            if( m/i * n <= m )  ans = max( ans, m/i );
            if( i*n <= m ) ans = max( ans, (INT)i );
        }
    }
    cout<<ans<<endl;
}


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

bool p[500001] = {true, true};

int main()
{
	for (int i = 2; i * i < 500001; i++){
		for (int j = i * i; j < 500001; j += i){
			p[j] = true;
		}
	}
	
	int n;
	while(cin >> n){

		for (int i = n - 1; ; i--){
			if (!p[i]){
				cout << i << " ";
				break;
			}
		}
	
		for (int i = n + 1; ; i++){
			if (!p[i]){
				cout << i << endl;
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 1648
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#include<vector>
#include <cmath>


using namespace std;

long long gcd(long long a, long long b) {
	return (b == 0) ? a : gcd(b, a % b);
}

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

	long long n, m;
	cin >> n >> m;

	long long r = gcd(n, m);

	string s1, s2;
	cin >> s1 >> s2;

	long long a = n / r;
	long long b = m / r;

	for (long long i = 0; i < r; i++) {
		if (s1[i * a] != s2[i * b]) {
			cout << -1 << endl;
			return 0;
		}
	}

	long long Ans = a * b * r;

	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 640
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()

a = [2, 4, 5, 7, 9]
b = [0, 1, 6, 8]
c = [3]

if (n % 10) in a:
    print("hon")
elif (n % 10) in b:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9264
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i, h) cin >> s[i];
	int u[h][w] = {}, d[h][w] = {}, l[h][w]= {}, r[h][w]={};
	REP(i, h){
		REP(j, w){
			if(j == 0 || s[i][j] == '#' ||s[i][j-1] == '#') l[i][j] = 0;
			else l[i][j] = l[i][j-1] +1;  
		}
	}
	REP(i, h){
		for(int j = w-1; j >= 0; j--){
			if(j == w-1 || s[i][j] == '#' ||s[i][j+1] == '#') r[i][j] = 0;
			else r[i][j] = r[i][j+1] +1;  
		}
	}
	REP(j, w){
		REP(i, h){
			if(i == 0 || s[i][j] == '#' ||s[i-1][j] == '#') u[i][j] = 0;
			else u[i][j] = u[i-1][j] +1;  
		}
	}
	REP(j, w){
		for(int i = h-1; i >= 0; i--){
			if(i == h-1 || s[i][j] == '#' ||s[i+1][j] == '#') d[i][j] = 0;
			else d[i][j] = d[i+1][j] +1;  
		}
	}
	REP(i, h){
		REP(j , w){
			ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] + 1);
		}
	}
	cout << ans << endl;
}

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


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

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

int n,m;vector<int> a;
signed main(){
cin>>n>>m;
int c;
rep(i,n){
  int aa;cin>>aa;aa /= 2;
  a.push_back(aa);
  int k = 0;
  while(aa % 2 == 0){
    aa /= 2;k++;
  }
  if(i != 0 && k != c){
    cout << 0 << endl;return 0;
  }else{
    c = k;
  }
}
int g = 1;
rep(i,n)a[i] /= (int)pow(2,c);
rep(i,n)g = a[i]*g/(__gcd(g, a[i]));
m /= (int)pow(2,c);
cout << (m/g/2 + ((m-m%g)/g % 2 ? 1 : 0)) << endl;
}



Measured memory_bytes: 1528
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b) printf("%d\n",c);
    else if(a==c) printf("%d\n",b);
    else printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <ll, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	string s;
	cin >> s;
	cout << s.substr(0, 3);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define mod2 1000000009LL
#define base1 19
#define base2 31
#define base3 137
#define MAX 1e12
#define MIN -10000000000
#define pi acos(-1)
#define esp 1e-6
#define memz(x) memset(x, 0, sizeof x)
#define memn(x) memset(x, -1, sizeof x)
#define pb push_back
#define nai string::npos
#define in1(a) scanf("%lld", &a)
#define in2(a,b) scanf("%lld%lld", &a, &b)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(i) printf("Case #%lld: ", ++i)
#define FILE    freopen("input.txt", "r", stdin); freopen("out.txt", "w", stdout);
using namespace std;
const ll N = 60;
ll n, a[N], b[N], cnt;
int main()
{
    in1(n);
    for(int i=0; i<n; i++)
    {
        in1(a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0; i<n; i++)
        if(a[i]!=b[i])
            cnt++;
    if(cnt>2)
        printf("NO\n");
    else printf("YES\n");
    return 0;
}


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

using namespace std;

long long  num[100005];
int main()
{
    long long n,k;
    scanf("%lld%lld",&n,&k);
    long long  sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(num[i-1]+num[i]>k)
        {
            sum+=(num[i-1]-k+num[i]);
            num[i]-=(num[i-1]-k+num[i]);
        }

    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

		double result = l * l * l / 27.0;
		System.out.println(String.format("%.9f", result));
	}
}


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

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

using namespace std;
using lint=long long;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

int f(int a){
	if(a==0) return 0;
	return f(a%popcount(a))+1;
}

int main(){
	int n;
	string s; cin>>n>>s;

	int pc=0;
	rep(i,n) if(s[i]=='1') pc++;

	lint fs[2]={};
	rep(i,n){
		fs[0]=(fs[0]*2+s[i]-'0')%(pc+1);
		if(pc>1) fs[1]=(fs[1]*2+s[i]-'0')%(pc-1);
	}

	rep(i,n){
		int ans;
		if(s[i]=='0'){
			ans=f((fs[0]+modpow(2,n-1-i,pc+1))%(pc+1))+1;
		}
		else{
			if(pc==1){
				ans=0;
			}
			else{
				ans=f((fs[1]-modpow(2,n-1-i,pc-1)+pc-1)%(pc-1))+1;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
using namespace std;
int cnt,fst[MAXN],nxt[MAXN<<1],to[MAXN<<1];
int n,deg[MAXN],f[MAXN],q[MAXN],head=1,tail,ans,res;
bool used[MAXN];
char ch[MAXN];
inl void AddEdge(reg int u,reg int v)
{
	to[++cnt]=v;
	nxt[cnt]=fst[u];
	fst[u]=cnt;
}
inl void TopoSort()
{
	for(reg int i=1;i<=n;i++) if(ch[i]=='B' && deg[i]==1) q[++tail]=i;
	while(head<=tail)
	{
		reg int u=q[head++];
		used[u]=1;
		for(reg int i=fst[u];i;i=nxt[i])
		{
			reg int v=to[i];
			if(deg[v]) deg[v]--;
			if(deg[v]==1 && ch[v]=='B' && !used[v]) q[++tail]=v;
		}
	}
}
inl int F(reg int x)
{
	return ((deg[x]&1)^(ch[x]=='W'));
}
void Dfs(reg int u,reg int pre)
{
	ans+=2+F(u);
	f[u]=(F(u)?-2:0);
	for(reg int i=fst[u];i;i=nxt[i])
	{
		reg int v=to[i];
		if(v==pre || used[v]) continue;
		Dfs(v,u);
		res=min(res,f[u]+f[v]);
		f[u]=min(f[u],f[v]+(F(u)?-2:0));
	}
}
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<n;i++)
	{
		reg int x,y;
		scanf("%d %d",&x,&y);
		AddEdge(x,y); AddEdge(y,x);
		deg[x]++; deg[y]++;
	}
	scanf("%s",ch+1);
	TopoSort();
	reg int pos=0;
	for(reg int i=1;i<=n;i++)
	{
		if(!used[i]) 
		{
			pos=i;
			break;
		}
	}
	if(!pos) puts("0");
	else
	{
		Dfs(pos,0);
		ans-=2;
		printf("%d\n",ans+res);
	}
	return 0;
}

Measured memory_bytes: 7296
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

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

		/* コンソールから、数値を受け取る */
		List<Integer> list = new ArrayList<>();
		for (int i = 0; sc.hasNext(); i++) {
			list.add(sc.nextInt());
		}

		int n5 = 0;
		int n7 = 0;

		/* 入力された数値のカウント */
		for (int n : list)  {
			if (n == 5) {
				n5++;
			}
			if (n == 7) {
				n7++;
			}
		}

		/* 入力された数値が 5・7・7に並び替えられるかを判定 */
		System.out.println(n5 == 2 && n7 == 1 ? "YES" : "NO");

	}

}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> takasa(N);
  
  for (int i=0; i<N; i++){
    cin >> takasa.at(i);
  }
  
  vector<int> handan(N,1);
  
  for (int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    
    if (takasa.at(a-1) > takasa.at(b-1)){
      handan.at(b-1) = 0;
    }
    else if(takasa.at(a-1) < takasa.at(b-1)){
      handan.at(a-1) = 0;
    }
    else{
      handan.at(a-1) = 0;
      handan.at(b-1) = 0;
    }
  }
  
  int count = 0;
  
  for (int i=0; i<N; i++){
    if (handan.at(i) == 1){
      count++;
    }
  }
  
  cout << count << endl;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int imos[100005]={}, a, b;
	for (int i = 0; i < n; ++i)
	{
		cin >> a >> b;
		++imos[a];
		--imos[b+1];
	}
	int cs[100005]={};
	cs[0]=imos[0];
	for (int i = 1; i < 100005; ++i)
	{
		cs[i] = cs[i-1] + imos[i];
	}

	int ans=0;
	for (int i = 2; i < 100005; ++i)
	{
		if(cs[i]+1>=i) ans = i-1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3916
loop do
  s = (1..8).map { gets.chomp }.join
  puts case s
       when /110{6}11/ then 'A'
       when /10{7}10{7}10{7}1/ then 'B'
       when /1111/ then 'C'
       when /10{6}110{6}1/ then 'D'
       when /110{7}11/ then 'E'
       when /10{7}110{7}1/ then 'F'
       when /110{5}11/ then 'G'
       end
  break unless gets
end

Measured memory_bytes: 8676
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.next().split("");
        
        Set<String> set = new HashSet<>();
        for (String s : line) {
            set.add(s);
        }
        
        String result = "No"; 
        if (set.size() == 2) result = "Yes"; 
        
        System.out.println(result);
    }
}

Measured memory_bytes: 35576
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	int i,minn=100000;
	for(i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(a<minn&&b<=t){
			minn=a;
		}
	} 
	if(minn==100000){
		cout<<"TLE"<<endl;
	}else{
		cout<<minn<<endl;
	}
	
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll X;
    cin >> X;
    ll M = 200000;
    bool judge = false;
    for(ll i = 1; i < M; i++){
        if(i * 100 <= X && X <= i * 105){
            judge = true;
        }
    }
    if(judge){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int compareInt(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum - bNum;
}
int main(){
  int N;
  cin >> N;
  int NNN[N] = {};
  for (int i = 0;i < N;i++){
    int X;
    cin >> X;
    NNN[i] = X;
  }
  qsort(NNN,N,sizeof(int),compareInt);
  for (int j = 0;j < N;j++){
      if (NNN[j] == NNN[j+1]){
        cout << "NO" << endl;
        return 0;
      }
  }
  cout << "YES" << endl;
  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
		int k; cin >> k;
		int n = 1e6;
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum = sum * 10 + 7;
			sum %= k;
			if(sum == 0){
				cout << i + 1;
				return 0;
			}
		}
		cout << -1;
	
	}
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,m,ans;
       cin>>n>>m;
       ans=((n*(n-1))/2)+((m*(m-1))/2);
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 256
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


#a=[int(x) for x in input().split()]
#n=int(input())

def main():
    n,k=[int(x) for x in input().split()]
    a=[int(x)-1 for x in input().split()]
    
    pr=0
    if k<n:
        for _ in range(k):
            pr=a[pr]
        print(pr+1)    
        exit(0)
    else:
        k-=n
        for _ in range(n):
            pr=a[pr]
    st=pr
    cnt,pr=1,a[st]
    while pr!=st:
        cnt+=1
        pr=a[pr]
    k%=cnt
    pr=st
    for _ in range(k):
        pr=a[pr]
    print(pr+1)
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 93048
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll x;
    cin >> x;
    ll ans = 1;
    while (true) {
        ll num = ((ans + 1) * ans) / 2;
        if (num >= x) {
            break;
        }
        ans++;
    }
    cout << ans << endl;
}


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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int mod = 1e9 + 7;

struct mat {
	int n, m;
	vector<vector<num>> w;
	mat() {}
	mat(int n, int m) {
		this->n = n;
		this->m = m;
		this->w.resize(n, vector<num>(m));
	}
	mat operator * (mat b) {
		mat res = mat(this->n, b.n);
		loop (i, this->n) {
			loop (j, b.m) {
				loop (k, b.n) {
					res.w[i][j] += this->w[i][k] * b.w[k][j] % mod;
					if (res.w[i][j] >= mod) {
						res.w[i][j] -= mod;
					}
				}
			}
		}
		return res;
	}
};

int n;
num k, ans;
mat a, res;

void qpow(num p) {
	while (p) {
		if (p & 1) {
			res = res * a;
		}
		a = a * a;
		p >>= 1;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	a = mat(n, n);
	res = mat(n, n);
	loop (i, n) {
		loop (j, n) {
			cin >> a.w[i][j];
		}
		res.w[i][i] = 1;
	}
	qpow(k);
	loop (i, n) {
		loop (j, n) {
			ans += res.w[i][j];
			if (ans >= mod) {
				ans -= mod;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n);
  rep(i,n)cin>>a[i];
  reverse(rng(a));
  ll R = 2,L=2;
  rep(i,n){
    L=(L+a[i]-1)/a[i]*a[i];
    if(R<L){
      print(-1);
      return 0;
    }
  R = (R/a[i]+1)*a[i]-1;
  //R=a[i]*2;
  }
  cout<<L<<" "<<R<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;

ll calc_value(const vector<int>& v, const vector<vector<int>>& F, const vector<vector<int>>& P)
{
    vector<int> counts(F.size(), 0);

    for (int j = 0; j < v.size(); ++j) {
        if (v[j] == 0) {
            continue;
        }

        for (int i = 0; i < F.size(); ++i) {
            if (F[i][j] == 1) {
                ++counts[i];
            }
        }
    }

    ll value = 0;
    for (int i = 0; i < counts.size(); ++i) {
        value += P[i][counts[i]];
    }

    return value;
}

bool all_zero(const vector<int>& v)
{
    for (const auto& vi : v) {
        if (vi == 1) {
            return false;
        }
    }

    return true;
}

ll func(vector<int> v, int i, const vector<vector<int>>& F, const vector<vector<int>>& P)
{
    if (i >= 10) {
        if (all_zero(v)) {
            return -INT_MAX;
        }

        return calc_value(v, F, P);
    }

    ll max_value = -INT_MAX;

    v[i] = 0;
    max_value = max(max_value, func(v, i+1, F, P));
    v[i] = 1;
    max_value = max(max_value, func(v, i+1, F, P));

    return max_value;
}

int main()
{
    int N;
    cin >> N;

    vector<vector<int>> F(
        N, vector<int>(10, 0)
    );

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }

    vector<vector<int>> P(
        N, vector<int>(11, 0)
    );

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    vector<int> v(10, 0);
    cout << func(v, 0, F, P) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
//#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
using namespace std;

int dp[100000];
P a[100000];
bool b[100000];
vector<int>V;
vector<int>c[100000];
vector<int>d[100000];
void saiki(int k) {
	if (b[k])return;
	for (int i : c[k]) {
		saiki(i);
	}
	V.push_back(k);
	b[k] = true;
}
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		a[i].first--; a[i].second--;
		c[a[i].second].push_back(a[i].first);
		d[a[i].first].push_back(a[i].second);
	}
	for (int i = 0; i < n; i++) {
		saiki(i);
	}
	for (int i : V) {
		for (int j : d[i]) {
			dp[j] = max(dp[j], dp[i] + 1);
		}
	}
	int MAX = 0;
	for (int i : V) {
		MAX = max(MAX, dp[i]);
	}
	cout << MAX << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> imos(n+1,0);
	ll sum = 0;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		sum += a[i];
		imos[i+1] = a[i] + imos[i];
	}

	ll ans = LLONG_MAX;
	for(int i=0;i<=n;i++) {
		ll right = sum - imos[i];
		ll left = imos[i];
		ans = min(ans, llabs(left-right));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
n,m = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort()
CB = []
for i in range(m):
   b,c = map(int,input().split())
   CB.append([c,b])
CB.sort(reverse=True)
ans = sum(A)
index = 0
for c,b in CB:
    for i in range(b):
        if index >=n:
            print(ans)
            exit()
        if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit()
print(ans)



Measured memory_bytes: 23996
import sys
from itertools import combinations

# https://ikatakos.com/pot/programming_algorithm/data_structure/union_find_tree
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    for i in range(m):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 27196
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = do
  { [n] <- getInts
  ; call n
  }

call :: Int -> IO ()
call n = check_num n 1 1

check_num :: Int -> Int -> Int -> IO ()
check_num n i x = if x `mod` 3 == 0
  then putStr " " >> putStr (show i) >> end_check_num n i x
  else include3 n i x

include3 :: Int -> Int -> Int -> IO ()
include3 n i x = if x `mod` 10 == 3
  then putStr " " >> putStr (show i) >> end_check_num n i x
  else let x' = x `div` 10
       in if x' /= 0 then include3 n i x'
          else end_check_num n i x' 

end_check_num :: Int -> Int -> Int -> IO ()
end_check_num n i x = let i' = i + 1
                      in if i' <= n then check_num n i' i'
                         else putStrLn ""

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4212
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e9+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	//dp????????????
	int n,m,i,j;cin>>n>>m;
	vector<int>aitm(n);
	vector<int>cowa(n+1);
	vector<int>dp(n+1,-big);//i?????§????????´???????????§???????????????
	vector<int>ddp(n+1,-big);//?????????????????´???
	dp[0]=0;
	for(i=0;i<n;i++){cin>>cowa[i+1]>>aitm[i];cowa[i+1]+=cowa[i];}
	int lat=0;
	for(i=0;i<m;i++){
		int t,s;cin>>t>>s;
		lat=t;
		for(j=0;j<=n;j++){
			if(cowa[j]>t){break;}
			int bo=0;
			if(j>=2){bo=abs(aitm[j-1]-aitm[j-2]);}
			if(j>0){ddp[j]=max(dp[j-1]+aitm[j-1],ddp[j-1]+aitm[j-1]+bo);}
			maxeq(dp[j],ddp[j]);
		}
		for(j=0;j<=n;j++){if(dp[j]<s){dp[j]=-big;}}
	}
	for(i=0;i<=n;i++){
		if(dp[i]>0){cout<<lat-cowa[i]<<endl;return 0;}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3152
import collections
n = int(input())
S = 0
s = input()
maximum = 0
for i in range(n):
  l = s[:i]
  r = s[i:]
  c = collections.Counter(l)
  c = c.most_common()
  for j in range(len(c)):
    if c[j][0] in r:
      S += 1
  maximum = max(maximum,S)
  S = 0
print(maximum)

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

int compare(const void * a, const void * b)
{
  return (*(int*)b - *(int*)a);
}

int main()
{
  int al[10];
  int i;
  for (i = 0; i < 10; i++) {
    int temp;
    scanf("%d", &temp);
    al[i] = temp;
  }
  qsort(al,10,sizeof(int),compare);
  for (i = 0; i < 3; i++) {
    printf("%d\n", al[i]);
  }

  return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	char s[100010];
	cin>>s;
	int i=0;
	while(s[i]!='\0'){
		if(i%2==0)printf("%c",s[i]);
		i++;
	}
	cout<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;

const int MOD = 924844033;
inline void add(int &a, int b) { a += b; a %= MOD; }

const int N = 5000001;
long long fact[N];
void init() {
        fact[0] = fact[1] = 1;
        for (int i = 2; i < N; i ++) fact[i] = fact[i - 1] * i % MOD;
}

int main() {
        init();
        int n, K;
        scanf("%d%d", &n, &K);
        int dp[2][2001][2] = {};
        bool f = false;
        dp[f][0][0] = 1;
        for (int i = 0; i < 2 * K; i ++) {
                for (int j = i; j < n; j += 2 * K) {
                        for (int k = 0; k <= n; k ++) {
                                if (k + 1 <= n && K <= j)    add(dp[!f][k + 1][0], dp[f][k][0]);
                                if (k + 1 <= n && j + K < n) add(dp[!f][k + 1][1], dp[f][k][0] + dp[f][k][1]);
                                add(dp[!f][k][0], (dp[f][k][0] + dp[f][k][1]) % MOD);
                                dp[f][k][0] = dp[f][k][1] = 0;
                        }
                        f = !f;
                }
                for (int k = 0; k <= n; k ++) {
                        add(dp[f][k][0], dp[f][k][1]);
                        dp[f][k][1] = 0;
                }
        }
        long long ans = 0;
        for (int k = 0; k <= n; k ++) {
                (ans += (long long) dp[f][k][0] * fact[n - k] % MOD * (k % 2 == 0 ? 1 : MOD - 1) % MOD) %= MOD;
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 39296
import math

a, b, x = map(int, input().split(' '))

if x / (a ** 2) >= b / 2:
    y = (b - x / (a ** 2)) * 2
    print(math.atan2(y, a) / math.pi * 180)
else:
    y = x / a / b * 2
    print(math.atan2(b, y) / math.pi * 180)

Measured memory_bytes: 3060
import sys
for line in sys.stdin:
    roman = list(line)
    roman.pop()
    for i in range(len(roman)):
        if roman[i] == 'I':
            roman[i] = 1
        elif roman[i] == 'V':
            roman[i] = 5
        elif roman[i] == 'X':
            roman[i] = 10
        elif roman[i] == 'L':
            roman[i] = 50
        elif roman[i] == 'C':
            roman[i] = 100
        elif roman[i] == 'D':
            roman[i] = 500
        elif roman[i] == 'M':
            roman[i] = 1000
    x = 0
    for i in range(len(roman)):
        if i == len(roman) - 1:
            x += roman[i]
        elif roman[i] < roman[i+1]:
            x -= roman[i]
        else:
            x += roman[i]
        
    print(x)

Measured memory_bytes: 7460
/*
 * coder: @SumitRaut
 */
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

inline void solve() {
    int n;
    cin>>n;
    vector<int>cnt(1000001);
    int tmp,gc;
    cin>>gc;
    ++cnt[gc];
    for(int i=1;i<n;++i) {
        cin>>tmp;
        ++cnt[tmp];
        gc=__gcd(gc,tmp);
    }
    bool f=1;
    for(int i=2;i<1000001;++i) {
        int c=0;
        for(int j=i;j<1000001;j+=i) {
            c+=cnt[j];
        }
        if(c>1) {
            f=0;
            break;
        }
    }
    if(f) {
        cout<<"pairwise coprime\n";
        return;
    }
    if(gc==1) {
        cout<<"setwise coprime\n";
        return;
    }
    cout<<"not coprime\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        solve();
    return 0;
}


Measured memory_bytes: 7144
mod = 10**9+7
n = int(input())
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
dp[0][0][0][0] = 1
# 0 -> T
# 1 -> C
# 2 -> G
# 3 -> A

def chk(s):
# NG Case : AG*C A*GC *ACG *GAC *AGC
  if   s[0] == 3 and s[1] == 2 and s[3] == 1: return False
  elif s[0] == 3 and s[2] == 2 and s[3] == 1: return False
  elif s[1] == 3 and s[2] == 1 and s[3] == 2: return False
  elif s[1] == 2 and s[2] == 3 and s[3] == 1: return False
  elif s[1] == 3 and s[2] == 2 and s[3] == 1: return False
  else: return True

def dfs(c, j, k, l):
  for m in range(4):
    if chk([j, k, l, m]):
      dp[c][k][l][m] += dp[c-1][j][k][l]

for i in range(1, n+1):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        dfs(i, j, k, l)

ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans += dp[n][i][j][k]
print(ans % mod)

Measured memory_bytes: 3444
package main

import (
  "fmt"
)

func main() {
  var a, b, c, d int
  
  fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
  
  ans := 0
  if a * b >= c * d {
    ans = a * b
  }
  if a * b < c * d {
    ans = c * d
  }
  fmt.Printf("%d", ans)
}

Measured memory_bytes: 1832
#include <cstdio>

using namespace std;

int main() {
  long long n;
  scanf("%lld", &n);
  if (n % 2 == 1) {
    puts("0");
    return 0;
  }
  long long ans = 0;
  while (n > 0) {
    n /= 5;
    ans += n / 2;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int ans=0;
  int a=0,b=0;
  rep(i,n+1){
    a+=i;
    b+=(n-i);
    a%=MOD;
    b%=MOD;
    if(i+1 >= m){
      ans+=b;
      ans-=a;
      ans++;
      while(ans<0) ans+=MOD;
      ans%=MOD;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double x1=0.0,x2=0.0,y1=0.0,y2=0.0;
    double x=0.0,y=0.0,z=0.0;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    x = x2-x1;
    y = y2-y1;
    z = x*x + y*y;
    z = sqrt(z);
    
    printf("%.8f\n",z);
    return 0;
}

Measured memory_bytes: 656