akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef __int128_t ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
ll costX;
ll x[MAXN];
ll s[MAXN];

int main()
{
	
	n = inp();
	costX = inp();
	for (int i = 1; i <= n; ++ i)
	{
		x[i] = inp();
		s[i] = s[i-1]+x[i];
	}
	ll ans = 1LL<<62;
	for (int k = 1; k <= n; ++ k)
	{
		ll cost = k*costX;
		for (int i = n, c = 1; i >= 1; i -= k, c ++)
		{
			int j = max(i-k, 0);
			cost += (s[i]-s[j])*(c == 1 ? 5 : 2*c+1);
		}
		ans = min(ans, cost);
	}
	ans += n*costX;
	cout << (long long)ans << endl;
	
	return 0;
}


Measured memory_bytes: 7552
#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 <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#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 <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n,m; cin >> n >> m;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    map<int,int> mp;
    for(int i = 0;i < n;i ++) mp[a.at(i)] ++;

    for(int i = 0;i < m;i ++){
        int b = mp.rbegin() -> first;
        mp[b] --;
        mp[b/2] ++;
        if(mp[b] == 0) mp.erase(b);
    }

    int ans = 0;
    for(auto i = mp.begin();i != mp.end();i ++){
        ans += i -> first * i -> second;
    }

    cout << ans << endl;

}

Measured memory_bytes: 10296
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e5 + 5;
vector<Pii>G;
template<class T>class BIT{
    T tree[maxn];
public:
    BIT(){
        memset(tree,0,sizeof tree);
    }
    void add(int a,T b){
        ++a;
        for(;a < maxn;a += a & -a)tree[a] += b;
    }
    T get(int a){
        ++a;
        T b = 0;
        for(;a > 0;a -= a & -a)b += tree[a];
        return b;
    }
};
BIT<int> T;
struct node {
    int l,r;
    bool operator < (const node &A)const{
        return (r - l) < (A.r - A.l);
    }
}L[maxn << 2];
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int m;
    cin>>n>>m;
    for(int i = 0; i < n; i++){
        int l,r;
        cin>>l>>r;
        L[i] = (node){l,r};
    }
    sort(L,L+n);
    int l = 0;
    for(int i = 1; i <= m ; i++){
        while(l < n && L[l].r - L[l].l + 1 < i){
            T.add(L[l].l,1);
            T.add(L[l].r+1,-1);
            l++;
        }
        LL res = n - l;
        for(int j = i; j <= m + 1; j += i){
            res += T.get(j);
        }
        cout<<res<<"\n";
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;
  long long N = stoll(S);
  long long sum = 0;
  string s;
  for(int i = 0;i < S.size();i++){
    s = S.substr(i,1);
    sum += stoll(s);
  }

  if(N % sum == 0)cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
def solve():
    S = input()
    n = len(S)
    if S[0]==S[1]:
        return [1,2]
    for i in range(1,n):
        if S[i]==S[i-1]:
            return [i,i+1]
        if i>=2 and S[i]==S[i-2]:
            return [i-1,i+1]
    return [-1,-1]
print(*solve())

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

long long mod = 998244353;
vector<long long> fact;
vector<long long> factinv;

void initfact(long long n) {
    fact.push_back(1);
    for (long long i = 1; i < n+1; i++) {
        fact.push_back((fact.back()*static_cast<long long>(i))%mod);
    }
}

long long sqr(long long n) {
    return static_cast<long long>(n)*n%mod;
}

long long bipow(long long c, long long n) {
    if (n == 0) {
        return 1;
    } else if(n == 1) {
        return c;
    } else if(n%2 == 0) {
        return sqr(bipow(c, n/2))%mod;
    } else {
        return (static_cast<long long>(c)*sqr(bipow(c, (n-1)/2)))%mod;
    }
}

void initfactinv() {
    factinv.push_back(bipow(fact.back(), mod-2));
    for (long long i = fact.size()-1; i > 0; i--) {
        factinv.push_back((factinv.back()*static_cast<long long>(i))%mod);
    }
    reverse(factinv.begin(), factinv.end());
}

long long C(long long n, long long m) {
    if (n < m) {
        return 0;
    }
    return (((static_cast<long long>(fact[n])*factinv[m])%mod)*factinv[n-m])%mod;
}

void solve(long long N, long long A, long long B, long long K){
    initfact(N + 10);
    initfactinv();
    long long ret = 0;
    for (int i = 0; i < N+1; i++) {
        long long r = i;
        long long rest = K - A*r;
        if (rest%B != 0 || rest < 0) {
            continue;
        }
        long long b = rest/B;
        long long w, x, y, z, t;
        w = min(r, b);
        x = 0;
        y = max(r, b);
        z = N - r - b;
        if (z < 0) {
            if (y+z < 0 || w+z < 0) {
                continue;
            }
            t = C(N, y + z);
            t *= C(N, w + z);
        } else {
            t = C(N, y);
            t *= C(N, w);
        }
        t %= mod;
        ret += t;
        ret %= mod;
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long B;
    long long K;
    long long N;
    long long A;
    scanf("%lld",&N);
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&K);
    solve(N, A, B, K);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 11628
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int maxcnt = 0;
    int num = 0;
    for (int i = 1; i <= N; i++)
    {
        int j = i;
        int cnt = 0;
        while (j % 2 == 0)
        {
            j = j / 2;
            cnt++;
        }
        maxcnt = max(maxcnt, cnt);
        if (maxcnt == cnt) num = i;
    }

    printf("%d\n", num);
    return 0;
}


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

int arr[15][15],n,m,x,c[15];

ll compute(int ans[],int sum,int index){
    
    
    
    int flag = 0;
    for(int i=1;i<=m;i++){
        if(ans[i]<sum){
            flag =1;
            break;
        }
    }
    
    
    if(!flag){
        return 0;
    }
    
    if(index>=n){
        return INT_MAX;
    }
    
    int take[m+1];
    
    for(int i=1;i<=m;i++){
        take[i]=ans[i]+arr[index][i];
        
    }
    
    return min(c[index]+compute(take,sum,index+1),compute(ans,sum,index+1));
}
int main(){
    cin>>n>>m>>x;
    
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    
    for(int i=1;i<=m;i++){
        int ans=0;
        for(int j=0;j<n;j++){
            ans+=arr[j][i];
        }
        
        if(ans<x){
            cout<<-1;
            return 0;
        }
    }
    int ans[m+1]={0};
    cout<<compute(ans,x,0);
    return 0;
}

Measured memory_bytes: 3652
object Main extends App{
    // Your code here!
    import scala.io.StdIn
    def sort(a: Array[Int], n: Int):Array[Int] = {
        for(i <- 0 until a.length) {
            var v = a(i)
            var j = i - 1
            while(j >= 0 && a(j) > v) {
                a(j+1) = a(j)
                j -= 1
            }
            a(j+1) = v
            print(a.mkString(" ") + "\n")
        }
        a
    }
    val inputN = io.StdIn.readLine().toInt
    val inputArray = io.StdIn.readLine().split(" ").map{_.toInt}
    sort(inputArray, inputN)
}



Measured memory_bytes: 45340
import java.util.Scanner;

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

        int N=0,A=0,B=0;
        int num = 0;
        int fo=0;
        String S;
        char[] c;
        
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        S = sc.next();
        c = S.toCharArray();
        
        
        for(int i=0;i<c.length;i++){
        	if(c[i]=='a' && num<A+B){
        		System.out.println("Yes");
        		num++;
        	}else if(c[i]=='a' && num>=A+B){
        		System.out.println("No");
        	}else if(c[i]=='b' && num<A+B && fo<B){
        		System.out.println("Yes");
        		num++;
        		fo++;
        	}else if(c[i]=='c'){
        		System.out.println("No");
        	}else{
        		System.out.println("No");
        	}
        }
    }
}

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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

const ll P = 1000000007;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	ll n, m;
	cin >> n >> m;
	if(abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	
	ll ans = 1;
	if(n == m) {
		for(int i = 1; i <= n; i++) ans = ((ans % P) * (i % P) % P);
		ans = (ans * ans) % P;
		ans = (ans * 2) % P;
	} else {
		if(m < n) swap(n, m); 
		for(int i = 1; i <= n; i++) ans = ((ans % P) * (i % P) % P);	
		ans = (((ans * ans) % P) * m) % P;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
while
  hands = Array.new(5)
  5.times do |idx|
    hand = gets.to_i
    exit if hand == 0
    hands[idx] = hand
  end
  uniqs = hands.uniq
  answers = case uniqs.length
  when 1, 3
    Array.new(5, 3)
  when 2
    if uniqs.include? 1
      if uniqs.include? 3
        hands.map {|hand| (hand == 1) ? 2 : 1 }
      else
        hands.map {|hand| (hand == 1) ? 1 : 2 }
      end
    else
      hands.map {|hand| (hand == 2) ? 1 : 2 }
    end
  end
  answers.each { |ans| puts ans }
end

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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

bool judge(string s)
{
  if (s[0] != 'A')
    return false;

  if (count(s.begin() + 2, s.end() - 1, 'C') != 1)
    return false;

  for (char c : s)
  {
    if (c != 'A' && c != 'C' && isupper(c))
      return false;
  }

  return true;
}

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

  cout << (judge(s) ? "AC" : "WA") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

vector<ll>graph[N];
bool vis[N], f;
ll lvl[N], ans[N];

void bfs(ll src)
{
    deque<ll> dq;
    dq.eb(src);
    lvl[src] = 1;
    vis[src] = 1;
    while(!dq.empty())
    {
        ll ma_src = dq.front();
        dq.pop_front();
        for(auto adj: graph[ma_src]){
            if(!vis[adj]){
                vis[adj] = 1;
                lvl[adj] += lvl[ma_src];
                ans[adj] = ma_src;
                dq.eb(adj);
                f = 1;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m, i, u, v;
    cin >> n >> m;
    for(i = 0; i < m; i++){
        cin >> u >> v;
        graph[v].eb(u);
        graph[u].eb(v);
    }
    bfs(1);
    if(!f) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for(i = 2; i <= n; i++){
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 18676
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
 int n; cin >> n;
 vector<int> H;
 vector<int> dp(n+10,1e9);
 for(int i=0;i<n;i++){
   int h; cin >> h;
   H.push_back(h);
 }
  dp[0] = 0;
 for(int i=0;i<n;i++){
   if(i+1<n) dp[i+1] = min(dp[i+1],dp[i]+abs(H[i+1]-H[i]));
   if(i+2<n) dp[i+2] = min(dp[i+2],dp[i]+abs(H[i+2]-H[i]));
 }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1276
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        
        int[] input1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[] input2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        
        int N = input1[0];
        int K = input1[1];
        double X = (double)(N-K)/(K-1) + 1;
        double gmin = Math.Ceiling(X);
        
       
        
            
        Console.WriteLine(gmin);
        
       
        
    }
}

Measured memory_bytes: 18016
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int s[1001];
  while(cin >> n) {
    if (n == 0) break;
    double m = 0, result = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++) {
      result += pow((s[i] - m), 2);
    }
    cout << fixed << setprecision(8);
    cout << sqrt(result / n) << endl;
  }
}


Measured memory_bytes: 3260
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

int main(){
    string s;
    cin >> s;
    long int k;
    cin >> k;
    vector<long int> num;
    char u = s[0];
    num.push_back(1);
    long int count = 0;
    for (int i = 1; i < s.size(); i++){
        if (s[i] != u){
            num.push_back(1);
            count++;
            u = s[i];
        }else{
            num[count]++;
        }        
    }
    long int ans = 0;
    // rep(i, num.size()) cout << num[i] << " ";
    // cout << endl;

    if (num.size() == 1){
        ans = (num[0] * k) / 2;
    }else{
        if (s[0] == s[s.size()-1]){
            for (int i = 1; i < num.size() - 1; i++){
                ans += num[i] / 2;
            }
            ans *= k;
            ans += ((num[0] + num[num.size()-1]) / 2) * (k - 1);
            ans += (num[0] / 2) + (num[num.size()-1] / 2);
        }else{
            for (int i = 0; i < num.size(); i++){
                ans += num[i] / 2;
            }
            ans *= k;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7
#
# n = int(input())
# a = list(map(int, input().split()))
a,b,x = map(float, input().split())

if x >= a * a * b / 2:
    ans = math.atan(2*(b/a - x/(a**3)))

else:
    ans = math.atan(a /2 /x *(b**2))

print(ans*180/math.pi)

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int M;
	cin >> M;
	ll lengSum=0, valueSum=0;
	for(int i=0; i<M; ++i){
		int d;
		ll c;
		cin >> d >> c;
		lengSum += c;
		valueSum += c*d;
	}
	ll kuri=valueSum/9;
	if(valueSum%9==0){
		--kuri;
	}
	cout << kuri+lengSum-1 << endl;
	return 0;
}

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

int main(void) {
  char s[11];
  
  scanf("%s", s);  
    
  if ((int)(s[5] - '0') == 0 && (int)(s[6] - '0') <= 4 && (int)(s[8] - '0') <= 3) {
    printf("Heisei");
  } else {
    printf("TBD");
  }
  
  return 0;
}

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

int  main()
{
	int c[3][3];
	int x = 0;
	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> c[i][j];
			x = max(c[i][j], x);
		}
	}
	int a[3],b[3];
	a[0] = 0; /* a1を0と仮定し、残りa2~b3を決まられる */
	rep1(i, x)
	{
		rep(i, 3)
		{
			b[i] = c[0][i] - 0;
		}
	}
	for (int i = 1; i < 3; i++)
		a[i] = c[i][0] - b[0];

	rep(i, 3)
	{
		rep(j , 3)
		{
			if(c[i][j] != a[i] + b[j])
			{
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	return (0);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int [] count = new int[n];
			Arrays.fill(count, 1);
			boolean [] flg = new boolean[n];
			flg[0] = true;
			
			for(int i = 0; i < m; i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				count[a]--;
				
				count[b]++;
				if(flg[a]){
					flg[b] = true;
				}
				
				if(flg[a] && count[a] == 0){
					flg[a] = false;
				}
			}
			
			int ans = 0;
			for(int i = 0; i < n; i++){
				if(flg[i])ans++;
			}
			System.out.println(ans);
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23696
N,M,X=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
ans=[]
for i in range(2**N):
    cost=0
    m=[0]*M
    for j in range(N):
        if ((i>>j)&1):
            cost+=A[j][0]
            for k in range(M):
                m[k]+=A[j][k+1]
    m7=[l for l in m if X<=l]
    if len(m7)==M:
        ans.append(cost)
if len(ans)>0:
    print(min(ans))
else:
    print(-1)

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9216
def main():
  from collections import deque
  n,m,*t=map(int,open(0).read().split())
  i,o=[0]*n,[[]for _ in range(n)]
  for a,b in zip(*[iter(t)]*2):
    o[a-1]+=b-1,
    i[b-1]+=1
  q=deque(v for v in range(n)if i[v]<1)
  r=[]
  while q:
    v=q.popleft()
    r+=v,
    for w in o[v]:
      i[w]-=1
      if i[w]==0:q+=w,
  print(-(len(r)==n))
main()

Measured memory_bytes: 3820
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(n-1,-1,-1):
    temp = A[i]
    beki = 1
    if C[temp] == 0:
        continue
    while beki <= temp:
        beki *= 2
    counterpart = beki-temp
    if C[counterpart] > 0 and C[temp] > 0 and counterpart != temp:
        C[counterpart] -= 1
        C[temp] -= 1
        ans += 1
    elif counterpart == temp and C[counterpart] > 1:
        C[counterpart] -= 2
        ans += 1
print(ans)


Measured memory_bytes: 110292
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	vector< bool > p(101, true);
	p[0] = false;
	p[1] = false;
	for (int i = 2; i < p.size(); i++)
		if (p[i])
			for (int j = i + i; j < p.size(); j += i)
				p[j] = false;
	vector< int > prime;
	rep(i, p.size()) if (p[i] == true) prime.push_back(i);
	//rep(i, prime.size()) cout << prime[i] << endl;
	cin >> N;
	vector< int > pn(prime.size(), 0);
	for (int i = 2; i <= N; i++) {
		int j = i;
		rep(k, prime.size()) {
			while (j % prime[k] == 0) {
				j /= prime[k];
				pn[k]++;
			}
		}
	}
	int ans = 0;
	int M = prime.size();
	rep(i, M) if (pn[i] >= 74) ans++;
	rep(i, M) rep(j, M) if (i != j) {
		if (pn[i] >= 4 && pn[j] >= 14)
			ans++;
		if (pn[i] >= 2 && pn[j] >= 24)
			ans++;
	}
	rep(i, M) rep(j, M) rep(k, M) if (i != j && j < k && k != i) {
		if (pn[i] >= 2 && pn[j] >= 4 && pn[k] >= 4)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string A,B,C;
  cin>>A>>B>>C;
  int a=A.size();
  int b=B.size();
  int c=C.size();
  if(A.at(a-1)==B.at(0)&&B.at(b-1)==C.at(0)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}




	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC087
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Enumerable.Range(0, 2).Select(i => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

            var sum = new int[n];
            for (int i = 0; i < n; i++)
            {
                sum[i] = Enumerable.Range(0, i).Select(x => a[0][x]).Sum() + a[0][i] + a[1][i] + Enumerable.Range(i + 1, n - i - 1).Select(x => a[1][x]).Sum();
            }

            Console.WriteLine(sum.Max());
        }
    }
}


Measured memory_bytes: 28432
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

been = [False]*N
n_been=0
loops = []

while True:
    #スタート地点を選ぶ
    for i in range(N):
        if not been[i]:
            now=i
            break
    else:
        break
    cand=[]       
    for _ in range(N):
        if been[now]:
            break
        else:
            cand.append(C[now])
            been[now]=True

        now = P[now]-1
    loops.append(cand)

ans=-10**20
for l in loops:
    m=len(l)
    sum_l = sum(l)
    
    rui =[None]*(m+1)
    rui[0]=0
    for i in range(m):
        rui[i+1] = rui[i]+l[i]

    if sum_l>0:
        k_gene = range(max(0,K-m), K+1)
    else:
        k_gene = range(1,min(m,K)+1)
    for k in k_gene:
        for i in range(m):
            if m-i>=k:
#                cand = sum(l[i:i+k]) 
                cand =rui[i+k]-rui[i]
            else:
#                cand = sum(l[i:])     +sum_l* ((k-m+i)//m) + sum(l[:(k-m+i)%m] ) 
                cand = rui[-1]-rui[i] +sum_l* ((k-m+i)//m) + rui[(k-m+i)%m] 
            ans=max(ans,cand)
            

print(ans)

Measured memory_bytes: 69172
#include <stdio.h>

int main(void) {
	int a,b,c,n=0,i;
	scanf("%d %d %d",&a,&b,&c);
	if(a>=1&&a<=10000&&b>=1&&b<=10000&&c>=1&&c<=10000){
		if(a<=b){
			for(i=a;i<=b;i++){
				if(c%i==0) n++;
			}
		}
	}
	printf("%d\n",n);
	return 0;
}



Measured memory_bytes: 2748
/***************************************************
 * Problem Name : B - Frog 2.cpp
 * Problem Link : https://atcoder.jp/contests/dp/tasks/dp_b
 * OJ           : atCoder
 * Verdict      : Trying
 * Date         : 2019-01-26
 * Problem Type : Basic DP
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FileRead freopen ("/home/saikat/Desktop/logN/input.txt", "r", stdin);
#define FileWrite freopen ("/home/saikat/Desktop/logN/output.txt", "w", stdout);
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int ar[MAX];
int dpp[MAX];
int iterative (int n, int k) {
    dpp[0] = INF;
    dpp[1] = 0;
    dpp[2] = abs (ar[2] - ar[1]);

    for (int i = 3; i <= n; i++) {
        int mn  = INF;

        for (int j = 1; j <= min (k, i); j++) {
            int tmp = abs (ar[i] - ar[i - j]);
            tmp += dpp[i - j];
            mn = min (mn, tmp);
        }

        dpp[i] = mn;
    }

    return dpp[n];
}
int main () {
    __FastIO;
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        cin >> ar[i];
    }

    int ans = iterative (n, k);
    cout << ans << "\n";
    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  int A = 1;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    if (A * 2 < A + K) {
      A *= 2;
    }
    else {
      A += K;
    }    
  }
  cout << A << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.nextLine();
        List<Character> l = new ArrayList<>();
        char r='R';
        char ll='L';
        for (int i = 0; i < str.length(); i++) {
            l.add(str.charAt(i));
        }
        
        for (int i = 1; i <str.length(); i += 2) {
            if (l.get(i).equals(r)) {
                System.out.print("No");
                System.exit(0);
            }
        }
        for (int i = 0; i < str.length(); i += 2) {
            if (l.get(i).equals(ll)) {
                System.out.print("No");
                System.exit(0);
            }
        }
        System.out.print("Yes");

    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <math.h>
using namespace std;
int dp[100100][4];
int v[100100][4];
int main(){
	int n;
	cin>>n;
	dp[0][1]=0;
	dp[0][2]=0;
	dp[0][3]=0;
	for(int i=1;i<=n;i++)
		cin>>v[i][1]>>v[i][2]>>v[i][3];
	for(int i=1;i<=n;i++)
		{
			dp[i][1]=max(dp[i-1][2],dp[i-1][3])+v[i][1];
			dp[i][2]=max(dp[i-1][1],dp[i-1][3])+v[i][2];
			dp[i][3]=max(dp[i-1][1],dp[i-1][2])+v[i][3];
		}
	int ans=dp[n][1];
	if(dp[n][1]>max(dp[n][2],dp[n][3]))
	cout<<dp[n][1];
	else
	cout<<max(dp[n][2],dp[n][3]);
}

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

long long int fact(long long int n){
	long long int r=1;
	for(long long int i=1;i<=n;i++)
		r=(r*i)%1000000007;
	return r;
}

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

	if((N-M)>1||(M-N)>1){
		cout<<0<<endl;
		return 0;
	}

	if(N==M){
		cout<<(fact(N)*fact(M)*2)%1000000007<<endl;
	}else{
		cout<<(fact(N)*fact(M))%1000000007<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// 2^n 全探索

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

long long solve0(long long var);


int main(void)
{
	long long in;
	std::cin >> in;

	long long ans = 0;
	ans = solve0(in);

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

	return EXIT_SUCCESS;
}

long long solve0(long long var)
{
	long long rtn = 0;
	int n = (int)std::log10(var) + 1;

	// 全パターン探索
	for(int bit = 0; bit < (1 << n-1); ++bit) {
		std::vector<long long> v;
		long long p = var, q = std::pow(10, n-1);

		for(int i = 0; i < n; ++i) {	
			if(bit & (1 << i)) {
				v.push_back(p / q);
				p = p % q;
			}
			q = q / 10;
		}

		v.push_back(p);

		for(std::vector<long long>::iterator it = v.begin(); it != v.end(); ++it)
			rtn += *it;
	}

	return rtn;
}




Measured memory_bytes: 3988
#include <iostream>
#include <cstring>
#include <climits>


using namespace std;


using ll = long long;


int main()
{
    ll N, W;
    cin >> N >> W;

    ll dp[N + 1][W + 1];
    ll weight[N + 1], value[N + 1];

    memset(dp, 0, sizeof(dp));

    for (ll i = 1; i <= N; i++)
        cin >> value[i] >> weight[i];
    for (ll i = weight[1]; i <= W; i++)
        dp[1][i] = value[1];

    for (ll i = 2; i <= N; i++) {
        for (ll w = 1; w <= W; w++) {
            dp[i][w] = max(dp[i - 1][w],
                            w - weight[i] >= 0 ? dp[i - 1][w - weight[i]] + value[i] : 0);
        }
    }

    cout << dp[N][W] << endl;
}



Measured memory_bytes: 11004
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;



int main(void){
      int h,w,a,b;
      cin>>h>>w>>a>>b;
      int f[h][w];
      rep0(i,h)rep0(j,w){
            if(i<b&&j<a) f[i][j]=0;
            else if(i<b) f[i][j]=1;
            else if(j<a) f[i][j]=1;
            else f[i][j]=0;
      }
      rep0(i,h){
            rep0(j,w){
                  cout<<f[i][j];
            }
            cout<<endl;
      }
      return 0;
}

Measured memory_bytes: 5120
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;


public class Main {
	public static int[] s;
	public static int len;
	public static TreeSet<Integer> set;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			char[] tmp = in.next().toCharArray();
			if(tmp[0] == '#') break;
			s = new int[tmp.length];
			for(int i=0; i<tmp.length; i++){
				s[i] = tmp[i]-'a';
			}
			len = s.length;
			set = new TreeSet<Integer>();
			dfs(len-1, 0, 0, 0);
			out();
		}
	}
	
	public static void out(){
		System.out.println(set.size());
		if(set.size() > 10){
			Stack<Integer> stack = new Stack<Integer>();
			for(int i=0; i<5; i++){
				int idx = set.pollFirst();
				stack.push(set.pollLast());
				for(int j=0; j<len; j++){
					System.out.print(toc(s[j]+(get(idx, j, len)?1:0)));
				}
				System.out.println();
			}
			for(int i=0; i<5; i++){
				int idx = stack.pop();
				for(int j=0; j<len; j++){
					System.out.print(toc(s[j]+(get(idx, j, len)?1:0)));
				}
				System.out.println();
			}
		}else{
			for(int i:set){
				for(int j=0; j<len; j++){
					System.out.print(toc(s[j]+(get(i, j, len)?1:0)));
				}
				System.out.println();
			}
		}
	}
	
	public static char toc(int i){
		return (char)(i+'a');
	}
	
	public static void dfs(int idx, int alp, int change, int left){
		if(idx == -1){
			if(clear(left, 0, 26) == 0) set.add(change);
			return;
		}
		if(s[idx] != 25 && !get(alp, (s[idx]+1), 26)){
			dfs(idx-1, set(alp, s[idx]+1, 26), set(change, idx, len), clear(left, s[idx]+1, 26));
		}
		if(!get(alp, s[idx], 26)){
			dfs(idx-1, alp, change, set(left, s[idx], 26));
		}
	}
	
	public static int clear(int flag, int idx, int len){
		return flag & ~(1<<(len-idx-1));
	}
	
	public static int set(int flag, int idx, int len){
		return flag | 1<<(len-idx-1);
	}
	
	public static boolean get(int flag, int idx, int len){
		return (flag & 1<<(len-idx-1)) > 0;
	}
}

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

using namespace std;

int main() {

    int n;
    int d;
    vector<int> v;
    vector<int> vv;

    cin >> n;

    if(n == 3) v.push_back(1 << 24);

    for(int i = 0; i < n; ++i) {
        cin >> d;
        v.push_back(d);
    }

    sort(v.begin(), v.end());

    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < 4; ++j) {
            stringstream ss;
            if(i != j) {
                ss << v[i] << v[j];
                vv.push_back(atoi(ss.str().c_str()));
            }
        }
    }

    sort(vv.begin(), vv.end());

    cout << vv[2] << endl;

}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  char a;
  cin >> a;
  cout << (char)(a + 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

string add(string a, string b) {
  string ret;
  int c = 0;
  for(int i=a.size()-1,j=b.size()-1; i>=0||j>=0; i--,j--) {
    int tmp = c;
    if(i>=0) tmp += a[i]-'0';
    if(j>=0) tmp += b[j]-'0';
    c = (tmp)/10;
    ret += char(tmp%10 + '0');
  }
  if (c) ret += '1';
  reverse(ALL(ret));
  return ret;
}

int main() {
  string s;
  while(cin >> s) {
    int aa = s.find('+');
    int bb = s.find('=');
    string a[3];

    a[0]= s.substr(0,aa);
    a[1] = s.substr(aa+1,bb-aa-1);
    a[2] = s.substr(bb+1);
    
    int f = 0;
    REP(i,10) {
      string aa[3];
      REP(k,3)
        aa[k] = a[k];
      int fff = 0;
      REP(k,3) {
        REP(j,a[k].length()) {
          if (a[k][j] == 'X') {
            aa[k][j] = '0'+i;
          }
        }
        if (aa[k].length() >= 2 && aa[k][0] == '0') fff = 1;
      }
      if (fff) continue;
      // REP(k,3)
      //   cout << aa[k] << " ";
      // cout << endl;
      // cout << add(aa[0],aa[1]) << endl;;
      if (add(aa[0],aa[1]) == aa[2]) {
        cout << i << endl;
        f = 1;
        break;
      }
    }
    if (!f)
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int a,b,k;cin>>k>>a>>b;
    if(a%k==0 || b%k==0 || abs(a/k-b/k)){
        cout<<"OK"<<endl;
    }
    else
    {
        cout<<"NG"<<endl;
    }
    
}

Measured memory_bytes: 3624
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as BS

main = do
  [n,y] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  let result = [ (man,gosen,sen)
               | let maxMan = min n (y `quot` 10000)
               , man <- [maxMan, maxMan - 1 .. 0]
               , let maxGosen = min (n-man) ((y - 10000*man) `quot` 5000)
               , gosen <- [maxGosen, maxGosen - 1 .. 0]
               , let sen = n - man - gosen
               , sen >= 0
               , (y - 10000*man - 5000*gosen) == 1000 * sen
               ]
  putStrLn $ unwords $ map show $ case result of
    (man,gosen,sen):_ -> [man,gosen,sen]
    [] -> [-1,-1,-1]


Measured memory_bytes: 1020
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        s = s + "es";
    }
    else{
        s = s + "s";
    }
    out(s);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  static const double pi = 3.141592653589793;
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double shts = sin(m / 30 * pi) * b;
  double shtc = cos(m / 30 * pi) * b;
  double lngs = sin((h * 60 + m) / 360 * pi) * a;
  double lngc = cos((h * 60 + m) / 360 * pi) * a;
//  cout << shts << " " << shtc << " " << lngs << " " << lngc << endl;
  double dify = sqrt(pow(shts - lngs, 2) + pow(shtc - lngc, 2));
  printf("%.16f", dify);
//  cout << dify;
}


Measured memory_bytes: 4100
n,k=map(int,input().split())
h=list(map(int,input().strip().split()))[:n]
h.sort()
if(k>=n):
    print(0)

elif(k==0):
    b=sum(h)
    print(b)
elif(k<n):
    b=sum(h[:-k])
    print(b)

Measured memory_bytes: 31756
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a=sc.nextInt();
        int b=sc.nextInt();
        
        if(a<b) System.out.println("a < b");
               
        else if(a>b) System.out.println("a > b");
               
        else System.out.println("a == b");
               
    }
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, m;
  cin >> n >> m;
  vector<ll> x(n + 1);
  ll a, b;
  for(i = 0; i < m; i++){
    cin >> a >> b;
    if(x[a] == 0)
      x[a] = b;
    else
      chmin(x[a], b);
  }
  
  
  ll bufl = 0, bufr = 0;
  ll result = 0;
  for(i = 1; i <= n; i++){
    //cout << i spa x[i] << endl; 
    if(x[i] != 0){
    
    if(bufl == 0){
      result++;
      bufl = i; bufr = x[i];
    }
    else if(bufr >= x[i]){
      bufl = i; bufr = x[i];
    }
    else if(bufr > i)
      bufl = i;
    else{
      result++;
      bufl = i;  bufr = x[i];
    }
      
    }
  } 
  cout << result << endl;
  

  return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N;

void solve() {
	cin >> N;
	int ans = 1;
	rep2(i, 1, N + 1) {
		ans *= i;
		ans %= mod_n;
	}
	cout << ans << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N, X, M; cin >> N >> X >> M;
    vector<vector<long long> > mov(61, vector<long long>(M));
    vector<vector<long long> > sum(61, vector<long long>(M));

    for (long long i = 0; i < M; i++) {
        mov[0][i] = i * i % M;
        sum[0][i] = i;
    }
    for (int i = 1; i < 61; i++) {
        for (int j = 0; j < M; j++) {
            mov[i][j] = mov[i-1][mov[i-1][j]];
            sum[i][j] = sum[i-1][j] + sum[i-1][mov[i-1][j]];
        }
    }

    long long ans = 0, pos = X;
    for (int i = 0; i < 61; i++) {
        if (N & 1LL<<i) {
            ans += sum[i][pos];
            pos = mov[i][pos];
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 99500
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
  cin >> a.at(i);
  }
  for(int i = 0; i < 5; i++){
    if(a.at(i)==0){
      cout<<i+1;
      break;
    }
  }
}

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

 int main(){
 string S, T;
 cin >> S >> T;
 int N = S.size(), ans = 0;
 for(int i = 0; i < N; ++i){
 if(S[i] != T[i]) ++ans;
 }
 cout << ans << endl;
 }

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int a, b;
	cin >> a >> b;
	int ans =  (a * b) / __gcd(a, b);
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3552
from itertools import combinations
from copy import copy


def judge(color, rows, cols, H, W):
    h_ = list("_"*H)
    w_ = list("_"*W)
    for row in rows:
        color[row] = w_
    color = list(zip(*color))
    for col in cols:
        color[col] = h_
    color = sum(map(tuple, color), ())
    return color.count("#")


H, W, K = map(int, input().split())
c = []
for _ in range(H):
    c.append(list(input()))

h_selector = []
w_selector = []
for i in range(H+1):
    h_selector.extend(list(combinations(range(H), i)))
for i in range(W+1):
    w_selector.extend(list(combinations(range(W), i)))

ans = 0
calc = 0
for rows in h_selector:
    for cols in w_selector:
        calc += 1
        t = copy(c)
        if judge(t, rows, cols, H, W) == K:
            ans += 1

print(ans)


Measured memory_bytes: 9236