akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	long long int k;
	cin>>n>>k;
	long long int a[100010],b[100010];
	long long int c[100010];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		c[a[i]]+=b[i];
	}
	sort(a,a+n);
	for(int i=1;i<=100010;i++){
		if(k<=c[i]){
			cout<<i<<endl;
			return 0;
		}
		k-=c[i];
	}
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String result = "";
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        if (a <= c && c <= b || c <= a && b <= c){
            result = "Yes";
        } else {
            result = "No";
        }
        
        System.out.println(result);
    }
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    std::vector<std::vector<long long>> c(3, std::vector<long long>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> c[i][j];
        }
    }
    V<int> a(3), b(3);
    a[0] = 0;
    b[0] = c[0][0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    bool f = true;
    rep(i, 3) rep(j, 3) {
        if (c[i][j] != a[i] + b[j]) f = false;
    }
    if (f)
        cout << YES << endl;
    else
        cout << NO << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i,cnts = 0;
	int deleted = 0;
	for(i=0;i<s.length();i++)
	 {
	 	 if(s[i]=='S')
	 	   cnts++;
	 	 else if(s[i]=='T'&&cnts>0)
	 	   {
	 	   	 cnts--;
	 	   	 deleted+=2;
		  }
	 }
	 cout<<s.length()-deleted;
	return 0;
	
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+5;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int sum=0;
	for(int i=2;i<=n;i++){
		sum^=(a[1]^a[i]);
	}
	for(int i=1;i<=n;i++){
		printf("%d ",(sum^a[i]));
	}
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

vector<int> ans1; //訪れた時間を格納する
vector<int> ans2; //再び訪れた時間

int t = 0;

void dfs(Graph &G, int v = 0){ //vは現在の頂点
    t++;
    ans1.at(v) = t; //行くときに時間を記録する
    for(auto nv: G.at(v)){
        if(ans1.at(nv)) continue; //一回以上訪れたなら行かない
        dfs(G, nv);
    }
    t++;
    ans2.at(v) = t;
}

int main(){
    int n; cin >> n;
    Graph G(n); //以下0-indexed
    ans1.resize(n);
    ans2.resize(n);
    for(int i = 0; i < n; i++){ //グラフを隣接リストとして入力
        int a, b; cin >> a >> b;
        for(int j = 0; j < b; j++){
            int k; cin >> k; k--;
            G.at(i).push_back(k);
        }
    }
    for(int i = 0; i < n; i++){
        if(ans1.at(i) == 0) dfs(G, i);
    }
    for(int i = 0; i < n; i++){ //答えの出力
        cout << i+1 << " " << ans1.at(i) << " " << ans2.at(i) << endl;
    }
}


Measured memory_bytes: 3152
A, B = map(int, input().split())
z = (["#"]*100 + ["\n"])*50

for a in range(A-1):
    j = a%50
    z[(j*2)+((a//50)%2)+202*(a//50)] = "."
z2 = (["."]*100 + ["\n"])*50

for a in range(B-1):
    j = a%50
    z2[(j*2)+((a//50)%2)+101+202*(a//50)] = "#"
print(100, 100)
print("".join(z)+"".join(z2))


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

using namespace std;

int a[260001];
int fa[260001];
int kol[260001];
int used[260001];
int zhanbolat[260001];
int wased[260001];
set <pair <int, int> > st;

int main () {
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		fa[a[i]] += i;
		used[a[i]] = i;
		wased[a[i]] = i;
		kol[i] = i - 1;
		if (i > 1) st.insert (make_pair (a[i], i));
	}
	for (int i = 1;i <= n * n;i ++) {
		fa[i] += fa[i - 1];
		if (fa[i] > i) {
			cout << "No";
			return 0;
		}
	}
	for (int i = 1;i <= n * n;i ++) {
		if (used[i]) continue;
		if (!st.size ()) continue;
		int pos = st.begin () -> second;
		kol[pos] --;
		used[i] = pos;
		if (!kol[pos]) st.erase (st.begin ());
	}               
	for (int i = 1;i <= n;i ++) {
		kol[i] = n - i;
	}
	for (int i = 1;i <= n * n;i ++) {
		if (!used[i]) {
			for (int j = 1;j <= n;j ++) {
				if (kol[j] && zhanbolat[j]) {
					used[i] = j;
					kol[j] --;
					break;
				}               	
			}                       	
		}
		if (wased[i]) zhanbolat[wased[i]] = 1;
		if (!used[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 1;i <= n * n;i ++) cout << used[i] << ' ';
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

auto main() -> int
{
  using std::cin;
  std::string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (u == s)
  {
    a--;
  }
  else
  {
    b--;
  }
  std::cout << a << " " << b << std::endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 21:05:25 2017

@author: taichiNakamura
"""

S = input()

def main(S):
    if len(S) < 4:
        return 'No'
    if S[:4] == 'YAKI':
        return 'Yes'
    else:
        return 'No'

print(main(S))

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
int main(void)
{
  int a, b, d, r;
  double f;
  std::cin >> a >> b;
  d = a / b;
  r = a % b;
  f = a / static_cast<double>(b);
  std::cout << d << " " << r << " " << std::fixed << std::setprecision(5) << f << std::endl;
}

Measured memory_bytes: 1240
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Runtime.CompilerServices;
using static MyIO;
using static BinarySearch;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = GetInt();
		
		int[] b = new int[N];
		for(int i = 0; i < N; i++)
			b[i] = GetInt();

		int xor = 0;
		int[] bMod = new int[N];
		for(int k = 0; k < 29; k++)
		{
			int T = 1 << k;
			int TT = T << 1;
			int TTT = T + TT;
			int TTTT = TT + TT;

			for(int i = 0; i < N; i++)
				bMod[i] = b[i] % TT;
			Array.Sort(bMod);

			int cnt = 0;
			for(int i = 0; i < N; i++)
			{
				int aMod = a[i] % TT;

				int lb1 = LowerBound(bMod, T - aMod);
				int ub1 = UpperBound(bMod, TT - aMod - 1);
				if(lb1 != -1)
					cnt += ub1 - lb1;

				int lb2 = LowerBound(bMod, TTT - aMod);
				int ub2 = UpperBound(bMod, TTTT - aMod - 1);
				if(lb2 != -1)
					cnt += ub2 - lb2;
			}

			xor |= (cnt & 1) << k;
		}

		Console.WriteLine(xor);
	}
}


public static class BinarySearch
{
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static int LowerBound(int[] array, int key)
	{
		int len = array.Length;
		if(array[len - 1] < key)
			return -1;

		int left = 0;
		int right = len - 1;
		while(right > left)
		{
			int mid = (left + right) / 2;
			if(array[mid] >= key)
				right = mid;
			else
				left = mid + 1;
		}

		return left;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static int UpperBound(int[] array, int key)
	{
		int len = array.Length;
		if(array[len - 1] <= key)
			return len;

		int left = 0;
		int right = len - 1;
		while(right > left)
		{
			int mid = (left + right) / 2;
			if(array[mid] > key)						
				right = mid;
			else			
				left = mid + 1;	
		}

		return left;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
}


Measured memory_bytes: 45820
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
def solve(x):
    kk = k
    for i in a:
        kk -= (i+x-1)//x - 1
    return kk>=0

ok = 10**9
ng = 0
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 94016
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int X; cin >> X;
    vector<int> v;

    v.push_back(0);
    v.push_back(1);
    for(int i=2;i<32;++i)
    {
        int t=i*i;
        while(t<=1000)
        {
            v.push_back(t);
            t=t*i;
        }
    }

    sort(v.begin(),v.end());
    v.push_back(10000000);
    for(int i=0;i<v.size();++i)
    {
        if(v[i]>X)
        {
            cout<<v[i-1]<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int i=0,N=0,K=0;
  	
  	scanf("%d %d",&N,&K);
	
  	while(N>0)
    {
      N=N/K;
      i++;
    }
  
  	printf("%d",i);
  
  	return 0;
}



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

int main(){
	int n,h,w;
	cin >> n >> h >> w;
	vector<int> s(n*w, 0);
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		int b = (i%2==0)? i*w+x: i*w-x;
		for(int j=b; j<b+w; j++){
			s[j] = 1;
		}
	}
	int ans = 0;
	for(int i=0; i<n*w; i++){
		if(s[i]==0) ans++;
	}
	ans *= h;
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n = (int)s.size();
    ll k;
    cin >> k;
    int i;
    for (i = 0; i < n; ++i) {
        if (s[i] != '1') break;
    }

    if (i > k - 1){
        cout << 1 << endl;
    }else{
        cout << s[i] << endl;
    }
}

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

using namespace std;

using LL = long long;

void solver() {
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    for(int &x : p) cin >> x, --x;

    vector<int> c(n);
    for(int &x : c) cin >> x;

    LL ans = -1e18;

    for(int start = 0; start < n; ++start) {
        
        int u = start;
        vector<LL> cycle;
        LL total = 0;
        
        while(true) {
            u = p[u];
            total += c[u];
            cycle.push_back(total);
            if (u == start) break;
        }

        int len = cycle.size();
        
        for(int i = 0; i < len; ++i) {
            if (i + 1 > k) break;
            int cnt = (k - i - 1) / len;
            if (total <= 0)
                ans = max(ans, cycle[i]);
            else ans = max(ans, cycle[i] + cnt * 1LL *  total);
        }
                
    }

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

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    solver();

    return 0;
}

Measured memory_bytes: 3804
fun main(args: Array<String>) {
    val n = readInteger()
    val tmp = Array(10) { LongArray(10) }
    for (i in 1..n) {
        val s = i.toString()
        tmp[s[0] - '0'][s[s.length - 1] - '0']++
    }
    var ans = 0L
    for (i in 0 until 10) {
        for (j in 0 until 10) {
            ans += tmp[i][j] * tmp[j][i]
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36716
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>;


using namespace std;



int main() {
    string str;
    int num[1000] = {};
    int i,j;
    j = 0;
    while (1) {
        cin >> str;
        if (str == "0") {
            break;
        }
        for (i = 0; i < str.size(); i++) {
            num[j] += str[i] - '0';
        }
        j++;
        
    }
    for (i = 0; i < j; i++) {
        cout << num[i] << endl;
    }



}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  vector<double> p(n);
  vector<double> cum_exp(n+1);
  rep(i, n) {
      cin >> p[i];
      p[i] = (1+p[i])/(double)2;
  }

  double exp = 0; double max_exp = 0;
  for (ll i = 1; i <= n; i++)
  {
      /* expectation + cum_sum */
      cum_exp[i] += p[i-1] + cum_exp[i-1];
      if (i>=k)
      {
          /* code */
          exp = cum_exp[i];
          cum_exp[i] -= p[i-k];
          max_exp = max(max_exp, exp);
      }
  }
//   cout << max_exp << endl;
  printf("%.10f\n", max_exp);
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cstring>
#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 ;
#define PI 3.141592653589793

int main(){
  ll dp[55][3000][55];
  int N, A;
  cin >> N >> A;
  int x[N];
  rep(i, N){
    cin >> x[i];
  }
  dp[0][0][0]=1;
  rep(i, N){
    rep(j, 2700){
      rep(k, N){
       dp[i+1][j+x[i]][k+1] += dp[i][j][k];
       dp[i+1][j][k] += dp[i][j][k];
      }
    }
  }
  ll ans=0;
  for(int i=1; i<=N; i++){
    int y = A*i; ans += dp[N][y][i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 67840
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long a[100000];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long w=0,sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(i%2==0)
		{
			if(sum<=0)
			w+=1-sum,sum=1;
		}
		else
		{
			if(sum>=0)
			w+=sum+1,sum=-1;
		}
	}
	long long ans=w;
	w=0;
	sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(i%2==1)
		{
			if(sum<=0)
			w+=1-sum,sum=1;
		}
		else
		{
			if(sum>=0)
			w+=sum+1,sum=-1;
		}
	}
	ans=min(ans,w);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    if(s=="Sunny"){
      cout << "Cloudy" << endl;
    }
    else if(s=="Cloudy"){
      cout << "Rainy" << endl;
    }
    else{
      cout << "Sunny" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#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()
using namespace std;
typedef long long ll;

int main(){
    vector<int> X(3,0);
    REP(i,3) cin >> X[i];
    sort(ALL(X));
    
    int cost=0;
    cost = X[2]-X[1];
    X[0] += X[2]-X[1];
    X[1] += X[2]-X[1];

    if((X[1]-X[0])%2==0) cost+=(X[1]-X[0])/2;
    else{
        cost+=(X[1]-X[0])/2;
        cost+=2;
    }
    cout << cost << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        int k = stdin.nextInt();
        
        long ans = 0;
        int t = c(n * m - 2, k - 2);
        for (long i = 0; i < n; i++) ans = (ans + ((n - i) * m * m * i) % 1000000007) % 1000000007;
        for (long i = 0; i < m; i++) ans = (ans + ((m - i) * n * n * i) % 1000000007) % 1000000007;
        System.out.println((ans * t) % 1000000007);
    }
    
    private static List<BigInteger> fct = new ArrayList<>();
    private static List<BigInteger> inv = new ArrayList<>();
    private static BigInteger mod = BigInteger.valueOf(1000000007);
    private static int c(int n, int r) {
        if (fct.isEmpty()) {
            fct.add(BigInteger.ONE);
            inv.add(fct.get(0).modInverse(mod));
        }

        for (int i = fct.size(); i <= n; i++) {
            fct.add(fct.get(i - 1).multiply(BigInteger.valueOf(i)).mod(mod));
            inv.add(fct.get(i).modInverse(mod));
        }

        return fct.get(n).multiply(inv.get(n - r).multiply(inv.get(r)).mod(mod)).mod(mod).intValue();
    }
}

Measured memory_bytes: 125732
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	long long sum = 0;
	long long rui[n];
	rep(i,0,n){
		long a;
		cin >> a;
		sum += a;
		rui[i] = sum;
	}
	
	long long ans = 0x7FFFFFFF;
	rep(i,0,n-1){
		ans = min( abs( rui[i] - (sum - rui[i])) , ans);
	}
	
	P(ans);
	ret 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 + 10;


vector<ll> vec;

ll n, a, b;

bool check(ll exp) {
    ll ext = 0;
    for (auto cur : vec) {
        if (cur > exp * b) {
            ll q = cur - exp * b;
            ext += (q - 1) / (a - b) + 1;
        }
    }
    if (ext <= exp) return true;
    return false;
}

int main() {
    fastInp;

    cin >> n >> a >> b;

    ll l = -1, r = INF;

    vec.resize(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

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

    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        }
        else {
            l = mid;
        }
    }

    cout << r;
    return 0;
}



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

using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        string s = to_string(i);
        if(s.size() % 2 == 0) continue;
        else count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
bool comp(const pair<int,int>& a,const pair<int,int>& b){
    return a.second<b.second;
}
int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    int cnt=0,ans;
    vector<int>hoge;
    for(int i=101;i>0;i--){
        if(a%i==0&&b%i==0){
            cnt++;
        }
        if(cnt==k){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}




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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 

bool judge(string s){
    for(auto& e : s){
        if(e != 'A' && e != 'C' && e != 'G' && e != 'T')
            return false;
    }
    return true;
}

signed main()
{
    string S;
    cin >> S;
    int counter = 0;
    REP(i, S.size()){
        FOR(j, 1,S.size()-i)
            {
                string T ;
                T = S.substr(i, j);
                
                if(judge(T) && counter < T.size())
                    counter = T.size();
            }
    }
    //判定，出力
    cout << counter << endl;

}



Measured memory_bytes: 256
// 現在のレーティングが Rで, 次のコンテストでレーティングをちょうど Gにしたい
#include<iostream>
using namespace std;

int main(){
  double R, G;
  cin >> R >> G;
  //必要なパフォーマンスをxとすると、r + x / 2= gだから、x = 2g -r
  cout<<2*G-R<<endl;
}

Measured memory_bytes: 256
//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
typedef unsigned long long ull;
using namespace std;
int n;
char s[100005][15];
ull a[100005];

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

	for (int i = 0; i < n; i++) scanf("%s", s[i]);

	for (int i = 0; i < n; i++) {
		sort(s[i], s[i] + 10);
		for (int j = 0; j < 10; j++) {
			a[i] = (a[i] * 27) + (s[i][j] - 'a' + 1);
		}
	}

	sort(a, a + n);

	ull cnt = 1, ans = 0;
	for (int i = 1; i < n; i++) {
		// printf("%lld\n", a[i]);
		if (a[i] == a[i - 1]) cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}

	ans += cnt * (cnt - 1) / 2;

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

	// sort(a, a + n);

	// for (int i = 0; i < n; i++) {
		// if ()
	// }

	return 0;
}

Measured memory_bytes: 2432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = LI()
    if N < sum(A):
        print(-1)
    else:
        print(N - sum(A))

main()



Measured memory_bytes: 11836
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10396
fun solve(a:Int, b:Int, s:String): Boolean {
    if (s.count { it=='-'} != 1)
        return false
    val idx = s.indexOf('-' )

    return idx == a && s.length==(a+b+1)
}

fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!

    val ans = if(solve(a,b,S)) "Yes" else "No"
    println(ans)

}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
N=int(input())
xp=yp=0
xn=yn=10**9
zs=[0]*N
ws=[0]*N
for i in range(N):
    xi,yi=map(int,input().split())
    zs[i]=xi+yi
    ws[i]=xi-yi
zs.sort()
ws.sort()
ans=max(zs[-1]-zs[0],ws[-1]-ws[0])
print(ans)

Measured memory_bytes: 25740
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

dp = [[0] * (k + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    dp[i + 1][0] = dp[i][0]
    for j in range(1, k+1):
        dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % mod
    for j in range(k, a[i], -1):
        dp[i + 1][j] = (dp[i + 1][j] - dp[i + 1][j - a[i] - 1]) % mod
print(dp[n][-1])

Measured memory_bytes: 146728
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = {}
    mod = 10**9+7
    for _ in range(M):
        k = int(input())
        l = int(k)
        A[k] = 1
    answer = [0] * (N+1)
    answer[0] = 1
    if 1 in A:
        answer[1] = 0
    else:
        answer[1] = answer[0]
    
    for i in range(2,N+1):
        if i in A:
            answer[i] = 0
        else:
            answer[i] = (answer[i-1] + answer[i-2])%mod
    print(answer[-1])
    
    
    
main()

Measured memory_bytes: 50008
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

fun <A : Comparable<A>> min(a: A, b: A) = if (a < b) a else b
fun <A : Comparable<A>> max(a: A, b: A) = if (a > b) a else b

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val A = LongArray(N) { sc.next().toLong() }

        val AP = A.filter { it > 0 }.sortedBy { -it }.toLongArray() // positive
        val AN = A.filter { it <= 0 }.sorted().toLongArray() // negative
        val CN = AN.count()

        var ans = 1L

        var kp = min(K, AP.count())
        var kn = K - kp
        if (kn % 2 == 1) {
            //dprint("kp=$kp kn=$kn")
            //if (kp == 0 || kn + 1 > CN) {
            if (kp == 0) {
                // マイナスしかできないので絶対値の小さいほうから K 個
                AN.reversed().take(K).forEach {
                    ans *= it
                    ans += 1000000007L
                    ans %= 1000000007L
                }
                pw.println(ans)
                return
            } else if (K == N) {
                // すべて選ぶしかない
                A.forEach {
                    ans *= it
                    ans += 1000000007L
                    ans %= 1000000007L
                }
                pw.println(ans)
                return
            }
            kp--
            kn++
        }

        while (true) {
            //dprint("kp=$kp kn=$kn")
            if (kp < 2 || kn + 2 > CN) break
            val a1 = AP[kp - 2] * AP[kp - 1]
            val a2 = AN[kn] * AN[kn + 1]
            if (a1 > a2) break
            kp -= 2
            kn += 2
        }

        for (i in 0 until kp) {
            ans *= AP[i]
            ans %= 1000000007L
        }
        for (i in 0 until kn) {
            ans *= -AN[i]
            ans %= 1000000007L
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 68924
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	int T;
	cin >> T;
	rep(_i, 0, T) {
		ll N, A, B, C, D, V[3], a, b, x[3] = {2, 3, 5}, c = 0;
		cin >> N >> A >> B >> C >> D;
		V[0] = A;
		V[1] = B;
		V[2] = C;
		deque<pair<ll, ll>> v;
		map<ll, ll> mp;
		v.push_back(make_pair(N, 0));
		ll ans = 1ll << 60;
		while (v.size()) {
			c++;
			auto it = v.front();
			v.pop_front();
			//printf("%lld %lld\n", it.second, it.first);
			if(D < 10000)ans = min(ans, it.second + it.first * D);
			if (c % 500000 == 0) {
				sort(all(v));
				v.erase(v.begin() + v.size() / 2, v.end());
			}
			if (it.first == 0) {
				ans = min(ans, it.second);
			}
			else {
				if (it.second >= ans)continue;
				rep(i, 0, 3) {
					a = (it.first - it.first % x[i]) / x[i];
					b = it.second + (a != 0) * V[i] + it.first % x[i] * D;
					if (mp[a] == 0 || mp[a] > b) {
						v.push_back(make_pair(a, b));
						mp[a] = b;
					}
					a = (it.first - it.first % x[i]) / x[i] + 1;
					b = it.second + V[i] + (x[i] - it.first % x[i]) * D;
					if (mp[a] == 0 || mp[a] > b) {
						v.push_back(make_pair(a, b));
						mp[a] = b;
					}
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 4844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int K = GetInt();
		int X = GetInt();
		WriteLine(500 * K >= X ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

const int N = 1e5 + 100;

int n, fa[N], fb[N], is_odd[2][N];

struct Edge {
    int e, *h, *nx, *to, V, E;
    Edge(int V, int E):V(V), E(E) {
        e = 0;
        h = new int [V];
        nx = new int [E];
        to = new int [E];
        memset(h, -1, 4 * V);
    }
    ~Edge() {
        delete h;
        delete nx;
        delete to;
    }
    void clear() {
        e = 0;
        memset(h, -1, 4 * V);
    }
    void add(int u, int v) {
        to[e] = v, nx[e] = h[u], h[u] = e++;
        to[e] = u, nx[e] = h[v], h[v] = e++;
    }
} *tr, *bi;

int dfs(int u, int f) {
    vector<int> odd_son;
    for (int i = tr->h[u]; i != -1; i = tr->nx[i]) {
        int v = tr->to[i];
        if (v != f) {
            v = dfs(v, u);
            if (v != 0)
                odd_son.push_back(v);
            else assert(false);
        }
    }
    if (!is_odd[0][u])
        odd_son.push_back(u);
    for (int i = 0; i < (int)odd_son.size() - 1; i += 2) {
        bi->add(odd_son[i], odd_son[i + 1]);
    }
    return odd_son.size() % 2 == 0 ? 0 : odd_son.back();
}

bool vis[N], col[N];

void coloring(int u, int c) {
    vis[u] = true;
    col[u] = c;
    for (int i = bi->h[u]; i != -1; i = bi->nx[i]) {
        int v = bi->to[i];
        if (!vis[v])
            coloring(v, c ^ 1);
    }
}

int main() {
#ifdef lol
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &fa[i]);
        if (fa[i] != -1) {
            is_odd[0][fa[i]] ^= 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &fb[i]);
        if (fb[i] != -1)
            is_odd[1][fb[i]] ^= 1;
    }
    for (int i = 1; i <= n; ++i) {
        if (is_odd[0][i] ^ is_odd[1][i]) {
            puts("IMPOSSIBLE");
            return 0;
        }
    }
    tr = new Edge(n + 1, (n + 1) * 2);
    bi = new Edge(n + 10, (n + 10) * 4);
    int rt;
    for (int i = 1; i <= n; ++i) {
        if (fa[i] == -1) {
            rt = i;
            continue;
        }
        tr->add(i, fa[i]);
    }
    dfs(rt, -1);
    tr->clear();
    for (int i = 1; i <= n; ++i) {
        if (fb[i] == -1) {
            rt = i;
            continue;
        }
        tr->add(i, fb[i]);
    }
    dfs(rt, -1);
    for (int i = 1; i <= n; ++i)
        if (!vis[i]) {
            coloring(i, 1);
        }
    puts("POSSIBLE");
    for (int i = 1; i <= n; ++i) {
        if (is_odd[0][i]) {
            printf("%d ", 0);
        } else {
            printf("%d ", col[i] ? 1 : -1);
        }
    }
    puts("");

    return 0;
}

Measured memory_bytes: 10240
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

H, W = map(int, input().split())
N, = map(int, input().split())
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()

m = [[0 for _ in range(W)] for _ in range(H)]

def bfs(i, j, remain, now):
    if now > N:
        return

    if remain == 0:
        bfs(i, j, L[now], now + 1)
        return

    if m[i][j] == 0:
        m[i][j] = now
    else:
        return

    if i + 1 < H and m[i + 1][j] == 0:
        bfs(i + 1, j, remain - 1, now)

    if i - 1 >= 0 and m[i - 1][j] == 0:
        bfs(i - 1, j, remain - 1, now)

    if j + 1 < W and m[i][j + 1] == 0:
        bfs(i, j + 1, remain - 1, now)

    if j - 1 >= 0 and m[i][j - 1] == 0:
        bfs(i, j - 1, remain - 1, now)        

bfs(0, 0, L[0], 1)

for v in m:
    print(*v)

Measured memory_bytes: 20716
n,m,x = map(int,input().split())
skl = [[] for i in range(n)]
buy = [0]*n
for i in range(n):
    a = list(map(int,input().split()))
    buy[i] = a[0]
    skl[i] = a[1:]
    
INF = 114514191981036436433-4
ans = INF

for i in range(2**n):
    ls = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            ls[j] = 1
        
    fl = True
    for j in range(m):
        gu = 0
        for k in range(n):
            gu += ls[k]*skl[k][j]
            
        if gu < x:
            fl = False
            break
            
    if fl:
        a = 0
        for i in range(n):
            a += buy[i]*ls[i]
            
        ans = min(ans,a)
        
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68464
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
	ll n;
	cin>>n;
	cout<<n*n*n<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = gets.chomp.split.map(&:to_i)
k = gets.chomp.to_i

flag = false

[:c, :b, :a].repeated_permutation(k).each do |abc_per|
  hash = { a: a, b: b, c: c }
  abc_per.each do |abc|
    hash[abc] = hash[abc] * 2
    if hash[:b] > hash[:a] && hash[:c] > hash[:b]
      flag = true
      break
    end
  end
  break if flag
end

puts(flag ? 'Yes' : 'No')

Measured memory_bytes: 14380
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0
for x in A:
  sum += x
  sum %= (10**9+7)

sum2 = 0
for x in A:
  sum2 += x*x
  sum2 %= (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    char c; cin >> c;
    if(islower(c))out("a");
    else out("A");
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    printf("%d %d %d\n", z, x, y);
    return 0;
}

Measured memory_bytes: 256
def solve(S):
    max_count = 0
    count = 0
    for i in range(len(S)):
        if S[i] in ["A", "G", "C", "T"]:
            count += 1
            if count > max_count:
                max_count = count
        else:
            count = 0
    return max_count


S = input()
print(solve(S))

Measured memory_bytes: 3060
import math

n = int(input())
ans = []
for x in range(1, math.ceil(n**(1/2))+1):
    for y in range(1, math.ceil(n**(1/2))+1):
        for z in range(1, math.ceil(n**(1/2))+1):
            ans.append(x**2 + y**2 + z**2 + x*y + y*z + z*x)
ans.sort()
for i in range(1, n+1):
    tmp = 0
    for x in ans:
        if x == i:
            tmp += 1
        elif x > i:
            print(tmp)
            break

Measured memory_bytes: 145532
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
K = INT()


n = [-1]*11
cnt = 0

def DFS(n):
    global cnt
    for i in range(1, 11):
        if n[-i] == 9:
            continue
        elif n[-i-1] != -1 and n[-i] == n[-i-1]+1:
            continue
        else:
            if n[-i] == -1:
                n[-i] = 1
            else:
                n[-i] += 1

            for j in range(i-1, 0, -1):
                n[-j] = max(0, n[-j-1] - 1)
            break
    cnt += 1
    if cnt == K:
        print(*n[bisect(n, -1):], sep = "")
        exit()
    DFS(n)


DFS(n)


Measured memory_bytes: 100780
#include<stdio.h>
 
const int N = 55;
 
int main(void) 
{
    int n, s[N]={0} , h[N]={0} ,c[N]={0} ,d[N]={0};
    
	scanf("%d",&n);
    
    for(int i =0 ; i < n ;i++)
    {
    	char k;
    	
    	int p;
    	
    	scanf(" %c %d",&k ,&p);
    	
    	if(k == 'S')
    	{
    		s[p]++;
		}
		else if(k == 'H')
    	{
    		c[p]++;
		}
		else if(k == 'C')
    	{
    		h[p]++;
		}
		else
    	{
    		d[p]++;
		}
	}
		
		for(int i = 1 ; i <= 13 ; i++)
		{
			if(s[i] == 0)
			{
				printf("S %d\n", i);
			}
	    } 
	    for(int i = 1 ; i <= 13 ; i++)
		{
			if(c[i] == 0)
			{
				printf("H %d\n", i);
			}
	    } 
	    for(int i=1 ; i<=13 ; i++)
		{
			if(h[i] == 0)
			{
				printf("C %d\n", i);
			}
	    } 
	    for(int i = 1 ; i <= 13 ; i++)
		{
				if(d[i] == 0)
			{
				printf("D %d\n", i);
			}
		}

}


Measured memory_bytes: 2732
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <cstdint>
#include <chrono>
const long long MOD = (long long)1e9+7;
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
const long long INF = INT64_MAX;


ll patty(ll lv, ll x) {
    if(lv == 0) return 1;
    if(x <= 1) {
        return 0;
    }else if (x >= 2 && x <= pow(2, lv + 1) - 2) {
        return patty(lv - 1, x - 1);
    }else if (x == pow(2, lv + 1) - 1) {
        return pow(2, lv);
    }else if (x >= pow(2, lv + 1) && x <= pow(2, lv + 2) - 4) {
        return pow(2, lv) + patty(lv - 1, x - (pow(2, lv + 1) - 1));
    }else {
        return pow(2, lv + 1) - 1;
    }
}

int main () {
    ll N, X;
    cin >> N >> X;
    cout << patty(N, X) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  char a[4],b[4];
    for (int j=1;j<=3;j++)
   cin>>a[j];
   for (int j=1;j<=3;j++)
   cin>>b[j];
  for (int i=1,j=3;i<=3,j>=1;i++,j--)
    if (a[i]!=b[j])
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256