akhauriyash/Code-Regression huggingface dataset:
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func gcd(x int, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x % y)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	buttons := make([]int, n+1)

	for i := 1; i <= n; i++ {
		buttons[i] = nextInt()
	}

	idx := buttons[1]
	count := 1

	for {
		if idx == 2 {
			break
		}
		if count >= n {
			fmt.Println(-1)
			return
		}
		count++
		idx = buttons[idx]
	}
	
	fmt.Println(count)
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int first_digit(int n){
	while(n>=10){
		n%=10;
		return n;
	}
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	int d=first_digit(n);
	if(d==2||d==4 ||d==5||d==7||d==9){
		cout<<"hon"<<endl;
	}
	else if(d==0||d==1||d==6||d==8){
		cout<<"pon"<<endl;
	}
	else if(d==3){
		cout<<"bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3640
n = gets.to_i

char_map = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
ans = ""

while true
  index = n % 26 - 1
  ans += char_map[index]
  break if n <= 26
  n -= 1 if index == - 1
  n /= 26
end

puts ans.reverse


Measured memory_bytes: 14404
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
constexpr int gcd(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
 
constexpr int lcm(const int &a, const int &b) {
  return a / gcd(a, b) * b;
}
 
signed main() {
  int a, b;
  while (cin >> a >> b) cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
}


Measured memory_bytes: 3064
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

ll s=0,n,i;cin>>n;
int a[n];
for(i=0;i<n;i++) cin>>a[i];
unordered_map<int,int> m;
for(i=0;i<n;i++) {	
	m[a[i]]++;s+=a[i];}
int q;cin>>q;
while(q--){
	ll b,c;cin>>b>>c;
	if(m[b]){
		s+=(c-b)*m[b];
		m[c]+=m[b];
		m[b]=0;
	}
	cout<<s<<endl;
}

}

Measured memory_bytes: 7516
import itertools

#n桁のm値のbitを生成
def bit(n, m):
  bit_list = list(itertools.product([i for i in range(m)], repeat=n))
  return bit_list

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 10
bits = bit(N, 2)
for bit_ptr in  bits:
  und_algo = [0 for _ in range(M)]
  tmp = 0
  for i in range(N):
    if bit_ptr[i] == 1:
      for j in range(M):
        und_algo[j] += A[i][j+1]

      tmp += A[i][0]
  
  flag = True
  for i in range(M):
    if und_algo[i] < X:
      flag = False

  if flag:
    ans = min(ans, tmp)

if ans == 10 ** 10:
  print(-1)
else:
  print(ans)


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

int main() {
	ios_base::sync_with_stdio( false );

	int N, K;
	cin >> N >> K;

	int result = K;

	for( int i = 1; i < N; ++i ) {
		result *= K-1;
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    string s;
    cin>>s;
    bool flag=1;
    int query;
    cin>>query;
    while(query--)
    {
        int t;
        cin>>t;
        if(t==1)flag^=1;
        else
        {
            int f;
            char c;
            cin>>f>>c;
            if(!flag)
            {
                if(f==2)f=1;
                else f=2;
            }
            if(f==1)
            {
                s=c+s;
            }
            else
            {
                s+=c;
            }
        }
        
    }
    if(flag)print(s)
    else
    {
        reverse(s.begin(),s.end());
        print(s)
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 4692
#include <iostream>
#include <string>
using namespace std;
string s[] = {"AC","WA","TLE","RE"};
int ans[4];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >>n;
    for(int i = 0; i < n; ++i){
        string ss; cin >> ss;
        for(int i = 0; i < 4; ++i){
            if(s[i] == ss) ans[i]++;
        }
    }
    for(int i = 0; i < 4; ++i){
        cout << s[i] << " " << "x" << " " << ans[i] << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m;

int main() {
	cin >> n >> m;
	cout << (n-1)*(m-1) << ln;
}

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

int main(){
	string s;
	int len,i;
	cin>>s;
	len=s.size();
	if(len%2!=0){
		cout<<"No";
		return 0;
	}
	for(i=0;i<len-1;i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

long long dp[51][51];
long long cnt[51][51];

void solve(long long N, long long A, long long B, vector<long long> v){
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            dp[i][j] = -1;
            cnt[i][j] = 0;
        }
    }

    //dp[i番目まで考慮][使用した数]
    dp[0][0] = 0;
    cnt[0][0] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(cnt[i][j] == 0) continue;
            
            if(dp[i+1][j] < dp[i][j]){
                dp[i+1][j] = dp[i][j];
                cnt[i+1][j] = cnt[i][j];
            } else if(dp[i+1][j] == dp[i][j]) {
                cnt[i+1][j] += cnt[i][j];
            }
            
            if(dp[i+1][j+1] < dp[i][j] + v[i]){
                dp[i+1][j+1] = dp[i][j] + v[i];
                cnt[i+1][j+1] = cnt[i][j];
            } else if(dp[i+1][j+1] == dp[i][j] + v[i]) {
                cnt[i+1][j+1] += cnt[i][j];
            }
        }
    }

    long double max_val = 0.0;
    long long res_cnt = 0;

    for(int i=A; i<=B; i++){
        long double now_val = (long double) dp[N][i] / (long double)i;
        if(abs(max_val - now_val) < 0.00000001) {
            res_cnt += cnt[N][i];
        } else if (max_val < now_val) {
            max_val = now_val;
            res_cnt = cnt[N][i];
        }
    }

    printf("%.9llf\n", max_val);
    cout << res_cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, A, B, v);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int cnt1[2020][4040],cnt2[2020][4040];
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,2*n){
        char c;
        int x;
        cin>>c>>x;
        --x;
        if(c=='W'){
            a[x]=i;
            cnt1[x][i+1]++;
        }
        else {
            b[x]=i;
            cnt2[x][i+1]++;
        }
    }
    rep(i,n-1)rep(j,2*n+1){
        cnt1[n-i-2][j]+=cnt1[n-i-1][j];
        cnt2[n-i-2][j]+=cnt2[n-i-1][j];
    }
    rep(i,n)rep(j,2*n){
        cnt1[i][j+1]+=cnt1[i][j];
        cnt2[i][j+1]+=cnt2[i][j];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,longinf));
    dp[0][0]=0;
    rep(i,n+1)rep(j,n+1){
        if(i<n)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cnt1[i+1][a[i]]+cnt2[j][a[i]]);
        if(j<n)dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cnt1[i][b[j]]+cnt2[j+1][b[j]]);
    }
    cout<<dp[n][n]<<endl;

    return 0;
}

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

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

using namespace std;

class two_edge_connected_components{
	int idx;
	vector<int> ord,low,tecc;
	const vector<vector<int>>& G;

	void dfs1(int u,int p){
		ord[u]=low[u]=idx++;
		bool f=true;
		for(int v:G[u]){
			if(v==p && f){ f=false; continue; }
			if(ord[v]==-1){
				dfs1(v,u);
				low[u]=min(low[u],low[v]);
			}
			else{
				low[u]=min(low[u],ord[v]);
			}
		}
	}

	void dfs2(int u,int p){
		if(p==-1 || ord[p]<low[u]) tecc[u]=idx++;
		else                       tecc[u]=tecc[p];
		for(int v:G[u]) if(tecc[v]==-1) dfs2(v,u);
	}

public:
	vector<vector<int>> tree;

	two_edge_connected_components(const vector<vector<int>>& G):G(G){
		int n=G.size();

		idx=0;
		ord.assign(n,-1);
		low.assign(n,-1);
		rep(u,n) if(ord[u]==-1) dfs1(u,-1);

		idx=0;
		tecc.assign(n,-1);
		rep(u,n) if(tecc[u]==-1) dfs2(u,-1);

		tree.resize(idx);
		rep(u,n) for(int v:G[u]) if(tecc[u]!=tecc[v]) tree[tecc[u]].emplace_back(tecc[v]);
	}

	int operator[](int i)const{ return tecc[i]; }
};

int main(){
	int n,m; cin>>n>>m;
	vector<vector<int>> G(n);
	rep(i,m){
		int u,v; cin>>u>>v; u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	two_edge_connected_components Te(G);

	int ans=0;
	rep(u,n) for(int v:G[u]) if(Te[u]!=Te[v]) ans++;
	cout<<ans/2<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int Euc(int a, int b) {
    if (a <= 0 || b <= 0) {
        return -1;
    }
    if (a > b) {
        if (a % b == 0) {
            return b;
        } else {
            Euc(b, a % b);
        }
    } else if (a < b) {
        if (b % a == 0) {
            return a;
        } else {
            Euc(a, b % a);
        }
    } else {
        return a;
    }
}

int main(int argc, char *argv[])
{
    int N, X;
    std::cin >> N >> X;

    std::vector<int> x(N);
    for (int i = 0; i < N; i++) {
        std::cin >> x[i];
    }
    x.push_back(X);

    std::sort(x.begin(), x.end());

    int ans = 0;
    if (N == 1) {
        ans = std::abs(x[1] - x[0]);
    } else {
        ans = Euc(std::abs(x[2] - x[1]), x[1] - x[0]);
        for (int i = 2; i < N; i++) {
            ans = Euc(x[i+1] - x[i], ans);
        }
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char s[200005];
int main(){
	scanf("%s",&s);
	int ans=0,l=0;
	for (int i=0;s[i];i++){
		if (s[i]=='T'){
			if (l)l--;
			else ans++;
		}
		else l++;
	}
	printf("%d",2*ans);
}

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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(998244353)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
#define ff first
#define ss second

	int n, k;
	cin >> n >> k;
	vector<int> p(n + 1), m(n  + 1);
	vector<int> pref(n + 1);
	vector<pair<int, int>> seg(k);

	for (auto &it : seg) cin >> it.ff >> it.ss;

	int cur = 0;
	p[0]++, m[1]--;
	for (int i = 0; i < n; i++) {
		cur += (p[i] + m[i]) % mod;
		cur = (cur + mod) % mod;
		pref[i] = cur;
		for (auto &it : seg) {
			if (i + it.ff < n) {
				p[i + it.ff] += cur;
				m[min(n, i + it.ss + 1)] -= cur;

				p[i + it.ff] = (p[i + it.ff] + mod) % mod;
				m[min(n, i + it.ss + 1)] = (m[min(n, i + it.ss + 1)] + mod) % mod;
			}
		}
	}

	cout << pref[n - 1] << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 7936
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();
        int ans = c - (a - b);
        if(ans < 0){
            ans = 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
import numpy as np

num = np.array(list(map(int, input().split())))
surplus = num % 2

sum_sur = sum(surplus)

count = 1
if sum_sur == 1:
    index = np.argmax(surplus)
    num += 1
    num[index] -= 1
    
elif sum_sur == 2:
    index = np.argmin(surplus)
    num += 1
    num[index] -= 1
else:
    count = 0

max_num = max(num)
max_index = np.argmax(num)

num = max_num - num
count += sum(num // 2)

print(count)


Measured memory_bytes: 19996
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
int n, k;
int main() {
    //freopen("greedy.in", "r", stdin);
    //freopen("greedy.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>k;
    cout<<(k==1 ? 0 : (n-k))<<"\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n[26]={0};
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    n[int(s[i])-'a']++;
  }
  for(int i=0;i<26;i++){
    //cout<<i<<":"<<n[i]<<endl;
    if(n[i]%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
while 1:
    n,m = map(int,input().split())
    if n==0: break
    t = sorted([int(input()) for _ in range(n)])
    h = sorted([int(input()) for _ in range(m)])
    d = sum(t) - sum(h)
    if d%2 != 0: print(-1);continue
    for i in range(n):
        if t[i] - d//2 in h:
            print(t[i], t[i] - d//2)
            break
    else:
        print(-1)



Measured memory_bytes: 5600
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int a,b,c;
    cin >> a >> b >> c;
    int k; cin >> k;

    bool ok = false;
    FOR(i,0,k) {
        FOR(j,0,k-i) {
            FOR(l,0,k-i-j) {
                int aa = a*pow(2,i);
                int bb = b*pow(2,j);
                int cc = c*pow(2,l);
                if(aa < bb and bb < cc) ok = true;
            }
        }
    } 
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 && i % 5){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;

typedef long long ll;

int main(void){
    int n;
    bool flag[10];
    
    cin >> n;

    for (int i = 0; i < 9; i++){
        flag[i] = false;
    }

    int count = 0;
    for (int i = 0; i < n; i++){
        int s;
        cin >> s;
        if (1 <= s && s < 400) flag[0] = true;
        else if (400 <= s && s < 800) flag[1] = true;
        else if (800 <= s && s < 1200) flag[2] = true;
        else if (1200 <= s && s < 1600) flag[3] = true;
        else if (1600 <= s && s < 2000) flag[4] = true;
        else if (2000 <= s && s < 2400) flag[5] = true;
        else if (2400 <= s && s < 2800) flag[6] = true;
        else if (2800 <= s && s < 3200) flag[7] = true;
        else count++;
    }

    int min = 0;
    
    for (int i = 0; i < 8; i++){
        if (flag[i]) min++;
    }

    if (min == 0){
        cout << 1 << ' ' << count << endl;
    }
    else{
        cout << min << ' ' << min + count << endl;
    }
   
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> cntR(n, 0);
  vector<int> cntL(n, 0);
  rep(i, n) {
    if(i == 0)
      cntR[0] = 1;
    else if(s[i] == 'R')
      cntR[i] = cntR[i - 1] + 1;
  }
  rep(i, n) {
    int j = n - 1 - i;
    if(j == n - 1)
      cntL[n - 1] = 1;
    else if(s[j] == 'L')
      cntL[j] = cntL[j + 1] + 1;
  }

  rep(i, n) {
    int ans = 0;
    if(i < n - 1)
      if(0 < cntR[i] && 0 < cntL[i + 1])
        ans += (cntR[i] + 1) / 2 + cntL[i + 1] / 2;
    if(0 < i)
      if(0 < cntL[i] && 0 < cntR[i - 1])
        ans += (cntL[i] + 1) / 2 + cntR[i - 1] / 2;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1408
class SegmentTree:
    ele = 0

    def func(self, a, b):
        return a + b

    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    def update(self, idx, val):
        idx += self.num
        self.SEG[idx] += val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    def query(self, left, right):
        # 開区間
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


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

ST = SegmentTree(n)
ST.initialize(A)
for _ in range(q):
    s, a, b = map(int, input().split())
    if s:
        print(ST.query(a, b))
    else:
        ST.update(a, b)


Measured memory_bytes: 136940
#include<iostream>
#include<utility>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int N;
	
	int ans = 99999999999;
	cin >> N;
	vector<int> W(N);
	for (int i = 0; i < N; i++){
		
		cin >> W[i];
	}
	for (int i = 0; i < N ; i++){
		int sum1 = 0, sum2 = 0;
		for (int k = 0; k < i; k++){
			sum1 += W[k];
		}
		for (int l = i; l < N; l++){
			sum2 += W[l];
		}
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;
const ll MAX = ll(1e10) * 300 + 10;
ll dp[310][int(1e3+10)];
ll A[int(1e6) + 1];
ll B[int(1e6) + 1];
ll S2[int(1e6) + 1];

vector<pair<ll, ll> > P;

ll N, M;
string S;

int main()
{
    cin >> N >> M;
    cin >> S;
    A[N] = N;
    int next = N;
    rep(i, N + 1){
        if (S[N - i] == '1'){
            A[N - i] = next;
        } else {
            A[N - i] = N - i;
            next = N - i;
        }
    }
    //rep(i, N + 1){
    //    fprintf(stderr, "%d, %d\n", i, A[i]);
    //}
    ll ans = 0;
    int i = N;
    while (1){
        
        if (i - M <= 0){
            B[ans++] = i;
            break;
        }
        if (A[i - M] == i){
            cout << -1 << endl;
            return 0;
        }
        B[ans++] = i - A[i - M];
        i = A[i - M];
    }
    rep(i, ans)
        cout << B[ans - 1 - i] << endl;
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long n, a, b;
	cin >> n;
	vector<long long> A(n), B(n);
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < n; ++i) cin >> B[i];
  
	int cnt = 0;
	long long diff = 0;
	vector<long long> D;
	for (int i = 0; i < n; ++i) {
		if (A[i] < B[i]) {
			++cnt;
			diff += B[i] - A[i];
		}
		else if (A[i] > B[i]) {
			D.push_back(A[i] - B[i]);
		}
	}
	if (!D.empty()) {
		sort(D.begin(), D.end(), greater<long long>());
		for (int i = 0; i < D.size(); ++i) {
			if (diff <= 0) break;
			diff -= D[i];
			++cnt;
		}
	}
	cout << (diff <= 0 ? cnt : -1) << endl;
	return 0;
}

Measured memory_bytes: 2428
// AOJ 2160: Voronoi Island
// 2018.1.8 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-8

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;

PP pi[11], pc[11];

int dcmp(double x)
{
	if (fabs(x) < EPS) return 0;
	return x < 0 ? -1 : 1;
}

double cross(double ax, double ay, double bx, double by) { return ax*by - ay*bx; }

void lineIntersection(PP *p, LINE *a, PP *vs, PP *ve)
{
    double a1, a2;

	a1 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->s.x - vs->x, a->s.y - vs->y);
	a2 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->e.x - vs->x, a->e.y - vs->y);
	p->x = (a->s.x*a2 - a->e.x*a1) / (a2-a1);
	p->y = (a->s.y*a2 - a->e.y*a1) / (a2-a1);
}

int convex_cut(LINE *u, int n, PP *p, PP *po)
{
	int i, d1, d2, top = 0;

    for (i = 0; i < n; i++) {
        d1 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
						p[i].x - u->s.x, p[i].y - u->s.y));
        d2 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
				      p[i+1].x - u->s.x, p[i+1].y - u->s.y));
        if (d1 >= 0) po[top++] = p[i];
        if (d1*d2 < 0) lineIntersection(po + top++, u, p+i, p+i+1);
    }
	po[top].x = po[0].x, po[top].y = po[0].y;
    return top;
}

// 垂直二等分線
void bisector(LINE *u, PP a, PP b)
{
	double ax = (a.x + b.x)/2;
	double ay = (a.y + b.y)/2;
	u->s.x = ax, u->s.y = ay;
	if (fabs(a.y - b.y) <= EPS) u->e.x = ax, u->e.y = ay + (b.x-a.x)*100;
	else u->e.x = ax-(b.y-a.y)*100, u->e.y = (ax - u->e.x)*(b.x - a.x)/(b.y - a.y) + ay;
}

double polygonArea(int n, PP *p)
{
    double area = 0;
    for (int i = 1; i < n-1; i++) {
        area += cross(p[i].x-p[0].x, p[i].y-p[0].y, p[i+1].x-p[0].x, p[i+1].y-p[0].y);
    }
    return fabs(area) / 2;
}

int main()
{
	int n, m, i, j, k, x, y, k1, k2;
	PP pol[2][100];
	LINE u;

	while(scanf("%d%d", &n, &m) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d%d", &x, &y), pi[i].x = x, pi[i].y = y;
		pi[n] = pi[0];

		for (i = 0; i < m; i++) scanf("%d%d", &x, &y), pc[i].x = x, pc[i].y = y;
		pc[m] = pc[0];

		for (i = 0; i < m; i++) {
			memcpy(pol[0], pi, sizeof(PP) * (n+1));
			k = n, k1 = 0, k2 = 1;
			for (j = 0; j < m; j++) {
				if (j == i) continue;
				bisector(&u, pc[i], pc[j]);
				k = convex_cut(&u, k, pol[k1], pol[k2]);
				k1 = k2, k2 = !k2;
			}
			printf("%.5lf\n", polygonArea(k, pol[k1]));
		}
	}
	return 0;
}


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

using namespace std;

int main(){
    long long x,y;
    int ans = 0;
    long long memo;

    cin>>x>>y;   

    memo = x;
    while(1){
        if (memo <= y){
            ans += 1;
            memo *= 2;
        }
        

        else{
            break;
        }
        
       
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std;
int main() {
 int a,b;
 cin>>a>>b;
 int sum=a+b;
 int sub=a-b;
 int mul =a*b;
 int l =max(sum,sub);
 if (mul>l){
    cout <<mul;
 }
 else{
   cout <<l;
 }
}

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

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    map<ll, int> cnt;
    cnt[0] = 1;
    vector<ll> p(n + 1);
    for (int i = 1; i <= n; ++i) {
        if (i >= k)
            cnt[p[i - k]]--;
        cin >> p[i];
        p[i] = (p[i] - 1) % k;
        p[i] = (p[i] + p[i - 1]) % k;
        ans += cnt[p[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
        
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,sum_b=1,sum_a=1,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u1,u2;
    bool ok=false;
    cin >> s >> k;
    char a = s[0], b=s[s.size()-1];
    if(s == string(s.size(),a)){
        cout << (s.size()*k)/2 << endl;
        return 0;
    }   

    if(a==b){
        for(int i=s.size()-2; i>=0;i--){
            if(b == s[i]){ sum_b++;}
            else{ break; }
        }
        for(int i=1; i<s.size();i++){
            if(a == s[i]){ sum_a++;}
            else{ break;}
        }
        if(sum_a%2==1 && sum_b%2==1){ ok = true; }
    }
 
    sum++;
    for(int i=1; i<s.size();i++){
        if(a == s[i]){
            sum++;
            if(i==s.size()-1){
                ans += sum/2;
            }
        }
        else{   
            ans += sum/2;
            sum = 1;
            a = s[i];
        }
    }
    if(ok)
        cout << ans*k + (k-1) << endl;
    else
        cout << ans*k << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
int main()
{
    IOS;
    long long a,b,c,d,e,g,h,k,l,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long co2=0,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6,c1;
    //double pi=2 * acos (0.0);
    string str,str1;
    char ch,ch1;

        cin>>a>>b;
        map<int, int>mp;
        for(int i=0; i<b; i++)
        {
            cin>>c;
            mp[c]++;
        }
        for(int i=0; ;i++)
        {
            d=a+i;
            e=a-i;
            if(mp[d]==0 && mp[e]==0)
            {
                cout<<min(d,e)<<endl;
                break;
            }
            if(mp[d]==0)
            {
                cout<<d<<endl;
                break;
            }
            if(mp[e]==0)
            {
                cout<<e<<endl;
                break;
            }
        }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    double r;
    cin>>r;
    double pi=3.141592653589793238;
    cout<<fixed<<setprecision(6)<<2*pi*r;
}
int main()
{
    go();
    return 0;
}


Measured memory_bytes: 3752
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ans = 0
cnt = 0
for xys in list(itertools.permutations([inpl() for _ in range(N)])):
    tmp = 0
    for i in range(1,N):
        bx,by = xys[i-1]
        x , y = xys[i]
        tmp += math.sqrt((bx-x)**2 + (by-y)**2)

    ans += tmp
    cnt += 1

print(ans/cnt)


Measured memory_bytes: 8940
N = int(input())
S = input()

ans = S
count = 0

for i in range(N):
    if(S[i] == "("):
        count += 1
    else:
        count -= 1
    
    if(count<0):
        ans = "(" + ans
        count += 1

count = 0

for i in range(N-1,-1,-1):
    if(S[i] == "("):
        count += 1
    else:
        count -= 1

    if(count>0):
        ans = ans + ")"
        count -= 1

print(ans)


Measured memory_bytes: 8892
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n,x;
	cin>>n>>x;
	int mi=inf;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		x-=t;
		mi=min(mi,t);
	}
	cout<<n+floor(x*1.0/mi)<<endl;
}


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


int main() {
	int n;
	cin>>n;
	int hi=0;
	int ans=0;
	while(n--){
		int p;
		cin>>p;
		if(p>hi){
			hi=p;
		}
		ans+=p;
	}
	ans-=hi/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    S = raw_input()

    if S[0] == 'A' and S[2:-1].count('C') == 1 and (S[1:S.index('C')] + S[S.index('C')+1:]).islower():
        if S[1:].split('C')[0].islower() and S[1:].split('C')[1].islower():
            print 'AC'
    else:
        print 'WA'

main()


Measured memory_bytes: 2696
import collections
import math
def P(n,r):
    return math.factorial(n) // math.factorial(n-r)
def C(n,r):
    return P(n,r) // math.factorial(r)
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
s = 0
for i in list(c.values()):
    s += i*(i-1)//2
for i in a:
    ans = s - (int(c[str(i)] - 1))
    print(ans)

Measured memory_bytes: 86608
#include<stdio.h>

int A[1000000], n;

/* ????????¢?´¢ */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1; /* key ?????????*/
    if ( key > A[mid] ) left = mid + 1; /* ???????????¢?´¢*/
    else if ( key < A[mid] ) right = mid; /* ???????????¢?´¢*/
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int sum = 0;
  
  for (int i = 0; i < 3; i++){
    if (S.at(i) == T.at(i)){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    ll max_k = (n - 2) * (n - 1) / 2;
    if(k > max_k){
        cout << -1 << endl;
        return 0;
    }

    set<pair<ll, ll>> edges;
    vector<pair<ll, ll>> pairs;

    for(ll i = 2; i <= n; ++i){
        edges.insert(make_pair(1, i));
    }
    for(ll i = 2; i <= n; ++i){
        for(ll j = i + 1; j <= n; ++j){
            pairs.push_back(make_pair(i, j));
        }
    }

    while(pairs.size() > k){
        auto p = pairs.back();
        pairs.pop_back();
        edges.insert(p);
    }

    cout << edges.size() << endl;
    for(auto p : edges){
        cout << p.first << ' ' << p.second << endl;
    }
    return 0;
}


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

template<typename T>
struct segment_tree{
    function<T(T,T)> f = [](T a, T b){return min(a,b);};
    T inf=INT_MAX;
    vector<T> value;
    int N;
    segment_tree(int n){
        N=1;
        while(N<n)N*=2;
        value.assign(2*N-1,inf);
    }
    segment_tree(int n, function<T(T,T)> func, T t1){
        N=1;
            while(N<n)N*=2;
        value.assign(2*N-1,t1);
        f=func;
        inf=t1;
    }
    void update(int i,T x){
        i+=N-1;
        value[i]=x;
        while(i>0){
            i=(i-1)/2;
            value[i]=f(value[i*2+1],value[i*2+2]);
        }
    }
    T query(T a,T b){
        return query(a,b,0,0,N);
    }
    T query(T a,T b, int k, int l, int r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b){
            return value[k];
        }else{
            ll c1=query(a,b,2*k+1,l,(l+r)/2);
            ll c2=query(a,b,2*k+2,(l+r)/2,r);
            return f(c1,c2);
        }
    }
    void print(){
        for(int i=0;i<ceil(log2(N))+1;i++){
            for(int j=0;j<(1<<i);j++){
                cout<<value[j+(1<<i)-1]<<((j==(1<<i)-1)?"":",");
            }
            cout<<endl;
        }
    }
};

int main(){
    ll n;
    cin>>n;
    segment_tree<ll> tree(n,[](ll a,ll b){if(a==1e10){return b;}else if(b==1e10){return a;}return __gcd(a,b);},1e10);
    rep(i,n){
        ll a;
        cin>>a;
        tree.update(i, a);
    }
    ll ans=0;
    rep(i,n){
        ll l=tree.query(0,i);
        ll r=tree.query(i+1,n);
        if(l==1e10 && r!=1e10){
            ans=max(ans,r);
        }else if(l!=1e10 && r==1e10){
            ans=max(ans,l);
        }else if(l!=1e10 && r!=1e10){
            ans=max(ans,__gcd(l,r));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int N; cin>>N;
    vector<int> divisor;
    for(int i=1;i*i<=N;i++){
        if(N%i==0){
            divisor.push_back(i);
            if(N/i!=i){
                divisor.push_back(N/i);
            }
        }
    }
    
    int ans=0;
    for(int d:divisor){
        if(d==1) continue;
        int m=d-1;
        if(N/m==N%m){
            ans+=m;
        }
    }
    cout<<ans<<endl;
}


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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

set<char> st;
char c[11] = {'y', 'u', 'i','o','p','h','j','k','l','n','m'};

int main() {
  REP(i,0,11){
    st.insert(c[i]);
  }
  string s;
  while(1){
    cin>>s;
    if(s == "#") break;
    int side, ans = 0;
    if(st.find(s[0]) == st.end()) side = 0;
    else side = 1;
    REP(i,1,s.size()){
      if((side == 0 && st.find(s[i]) != st.end()) || (side == 1 && st.find(s[i]) == st.end())) ans++;
      if(st.find(s[i]) == st.end()) side = 0;
      else side = 1;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

ans = sorted(dic.items(), key=lambda x:x[1])
ans = ans[::-1]
check = ans[0][1]
ans2 = []
for i in range(len(ans)):
    if ans[i][1] == check:
        ans2.append(ans[i][0])
ans2.sort()
for i in ans2:
    print(i)



Measured memory_bytes: 45788
#include <iostream>

using namespace std;

int main()
{
  	int A, B, n = 0;
  	string S;
  	cin >> A >> B >> S;
  	for(int i = 0; i < A + B; i++){
      	if(S.at(i) == '-'){
			n++;
        }
    }
  	if(n == 1 && S.at(A) == '-'){
      	cout << "Yes";
    }else{
      	cout << "No";
    }
  	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int main(){
	llong H, W;
	vector<string> A;
	queue<P> q;


	cin >> H >> W;
	A.resize(H, string(W, '.'));
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] == '#') {
				q.push(P(i,j));
			}
		}

	llong ans = 0;
	while (q.size()) {
		bool check = false;
		queue<P> n;
		while(q.size()) {
			P now = q.front();
			q.pop();
			for (int i = 0; i < 4; i++) {
				P next(now.first + nh[i], now.second + nw[i]);
				if (next.first < 0 || next.second < 0 || next.first >= H || next.second >= W) continue;
				if (A[next.first][next.second] == '.') {
					A[next.first][next.second] = '#';
					n.push(next);
					check = true;
				}
			}
		}

		ans += check;
		swap(q, n);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 17588
#include <iostream>

using namespace std;

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

	int A[N];
	for (int i=0; i<N; i++) cin >> A[i];

	bool flg = false;
	for (int i=0; i<N; i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				flg = true;
			}
		}
	}

	if (flg) cout << "DENIED";
	else cout << "APPROVED";

}


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

int main() {
  int x,y; cin >> x >> y;
  if (x == 2 && y == 2) {
    cout << "Yes" << endl;
  } else if ( (x==4 || x==6 || x==9 || x==11) && (y==4 || y==6 || y==9 || y==11)){
    cout << "Yes" << endl;
  } else if ( (x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) && (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)){
    cout <<"Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main()
{
	long long n, t;
	cin >> n >> t;
	
	long long a[n+1];
	for(int i=1; i<=n; i++)
		cin >> a[i];
		
	sort(a+1, a+n+1);
	
	long long f=n-t, total=0;
	
	for(int i=1; i<=f; i++)
		total+=a[i];
	
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n,q,m,i;
  int c=0;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m,n,A) == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m,int n,int A[]){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+1,m,n,A) || solve(i+1,m-A[i],n,A);
  return res;
}



Measured memory_bytes: 2052
// Time limit exceeded

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n, T;
    cin >> n >> T;
    
    vector<int> c(n);
    vector<int> t(n);

    for (int i = 0; i < n; i++) {
        cin >> c[i] >> t[i];
    }

    int cost = 1001;
    for (int i = 0; i < n; i++) {
        if (t[i] <= T) {
            if (c[i] < cost) {
                cost = c[i];
            }
        } else {
            continue;
        }
    }

    if (cost == 1001) {
        cout << "TLE" << endl;
    } else {
        cout << cost << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.format;

void main()
{
	auto ip = readln.split.to!(float[]);
	writef("%.6f", ip[0]/ip[1]);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n,T,t[200020]={},str=0,ans=0;
	cin>>n>>T;
	rep(i,0,n)cin>>t[i];
	if(n==1)ans+=T;
	rep(i,1,n){
		if(t[i-1]+T<t[i]){
			ans+=t[i-1]+T-str;
			str=t[i];
		}
		if(i==n-1)ans+=t[i]+T-str;
	}
	cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    int sum = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;
   return 0;
}

Measured memory_bytes: 3568