akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int d, g, ans = 10000000;
int p[14] = {0}, c[14] = {0}, sum[14] = {0};
bool solved[14] = {0};

bool asc(pair<int, int> l, pair<int, int> r) {
  if(l.second > r.second) return 1;
  return 0;
}

void solve(int x, int now, int nnum);

int main() {
  int i;
  cin >> d >> g;
  g /= 100;
  for(i = 0; i < d; ++i) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
    sum[i] = c[i] + (i + 1) * p[i];
  }
  solve(0, 0, 0);
  cout << ans << endl;
  return 0;
}

void solve(int x, int now, int nnum) {
  if(x == d) {
    // cout << now << " " << nnum << endl;
    if(now >= g && nnum < ans)
      ans = nnum;
    else if(now < g) {
      for(int i = d - 1; i >= 0; --i)
        if(solved[i] == 0) {
          for(int j = 0; j < p[i]; ++j) {
            ++nnum;
            now += i + 1;
            // cout << nnum << " " << now << endl;
            if(now >= g) break;
          }
          break;
        }
      if(now >= g && nnum < ans) ans = nnum;
    }
  }
  if(x < d) {
    solved[x] = 0;
    solve(x + 1, now, nnum);
    solved[x] = 1;
    solve(x + 1, now + sum[x], nnum + p[x]);
    solved[x] = 0;
  }
}

Measured memory_bytes: 256
def test():
    n = int(input())
    A,B,C = [list(sorted(map(int,input().split()))) for i in range(3)]
    ans = 0

    for b in B:
        ans += low_left(A,b) * (n-high_right(C,b))
    print(ans) 


def low_left(ls,t):
    low,high = 0,len(ls)
    while low<high:
        mid = (low+high)//2
        if ls[mid] < t:
            low = mid + 1
        else:
            high = mid
    return low


def high_right(ls,t):
    low,high = 0,len(ls)
    while low<high:
        mid = (low+high)//2
        if ls[mid] > t:
            high = mid
        else:
            low = mid + 1
    return low


if __name__ == "__main__":
    test()


Measured memory_bytes: 24264
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

struct Matrix
{
    vvi A;
    int dim;
    Matrix() {}
    Matrix(int n) : dim(n) { A.assign(n, vi(n));}
    vi &operator [](int n){ return A[n];}
};

Matrix operator *(Matrix A, Matrix B)
{
    int n = A.dim;
    Matrix C(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int k = 0; k < n; ++k)
                adds(C[i][j], mul(A[i][k], B[k][j]));
    
    return C;
}

Matrix operator ^(Matrix A, ll k)
{
    int n = A.dim;
    
    Matrix R(n);
    for (int i = 0; i < n; ++i)
        R[i][i] = 1;

    while (k > 0)
    {
        if (k % 2)
            R = R * A;

        A = A * A;
        k /= 2;
    }

    return R;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    Matrix m(n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> m[i][j];
    m = m ^ k;
    int sol = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            adds(sol, m[i][j]);
    cout << sol;
}


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

int main (){
  int a, b;
  cin >> a >> b;
  a = a * b;
  a %= 2;
  
  if (a == 1) {
    cout << "Odd" << endl;
  }else if (a == 0){
    cout << "Even" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
    string S, T;
    cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(),greater<int>());
    cout << (S < T ? "Yes" : "No") << endl;
}

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


int main(){
    long int H;
    cin >> H;

    long int i = 0;
    long int c;
    while (H != 0)
    {
        c += pow(2,i);
        i++;
        H /= 2;
    }
    
    cout << c << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

if n == 0:
  print(1)
else:
  rec('-')
  rec('+')
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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


int main() {
	string s; cin >> s;
	vector<int> v;
	rep(i,s.size()){
		
		if (s[i]=='0'){
			v.push_back(0);
		}else if (s[i]=='1'){
			v.push_back(1);
		}else {
			if (v.size()){
				v.erase(v.end()-1);
			}
		}
	}
	rep(i,v.size()){
		cout << v[i];
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
void prB(int S){
  for(int i=0;i<6;i++){
    int x=(S>>i);
    cout<<(x&1)<<" ";
  }
  cout<<endl;
}
double width;
int n;
int t[6];
 
int mem[(1<<7)];
int calc(int S){
  if(mem[S]!=-1)return mem[S];
  int x=S&-S;
  return mem[S]=calc(S-x)+calc(x);
}
 
vector<double> dp[(1<<7)];
vector<double> dp2[(1<<7)];
bool vd[(1<<7)];
void rec(int S){
  if(vd[S])return;
  vd[S]=true;
  int sub=S;
  do{
    if(sub!=S&&sub!=0){
      int lS=sub,rS=S-sub;
      rec(lS);rec(rS);
      double lsum=calc(lS),rsum=calc(rS);
     
      double ld=rsum/(lsum+rsum);
      double rd=lsum/(lsum+rsum);
      for(int i=0;i<(int)dp[lS].size();i++){
    for(int j=0;j<(int)dp[rS].size();j++){
      double nl=min(dp[lS][i]-ld,dp[rS][j]+rd);
      double nr=max(dp2[lS][i]-ld,dp2[rS][j]+rd);
      dp[S].push_back(nl);
      dp2[S].push_back(nr);
    }
      }
    }
    sub=(sub-1)&S;
  }while(sub!=S);
}
 
void solve(){
  for(int i=0;i<n;i++){
    vd[(1<<i)]=true;
    dp[(1<<i)].push_back(0);
    dp2[(1<<i)].push_back(0);
  }
  int U=(1<<n)-1;
  rec(U);
  double ans=-1.0;
  for(int i=0;i<(int)dp[U].size();i++){
    double d=dp2[U][i]-dp[U][i];
    if( d < width + 0.00001  )ans=max(ans,d);
  }
  if(ans==-1.0)cout<<"-1"<<endl;
  else printf("%.10f\n",ans);
}
 
void init(){
  for(int i=0;i<(1<<7);i++){
    vd[i]=0;
    mem[i]=-1;
    dp[i].clear();
    dp2[i].clear();
  }
  mem[0]=0;
  for(int i=0;i<n;i++)mem[(1<<i)]=t[i];
}
 
int main(){
  int Tc;
  cin>>Tc;
  for(int tc=1;tc<=Tc;tc++){
    cin>>width>>n;
    for(int i=0;i<n;i++)cin>>t[i];
    init();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1896
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,r;

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

 	if(n>=10){
 		printf("%d\n",r );
 	}
 	else	printf("%d\n",100*(10-n) + r );
}		


Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

ll n,a,b,c,d;
int main(){
    cin >> n >> a >> b >> c >> d;
    b -= a;
    ll upper = d-c;
    ll lower = c-d;
    n -= 1;
    REPN(i,n/2){
        ll ilow = lower*i;
        ll iupp = upper*i;
        ll res = n - i*2;
        if ( ilow - res*d <= b && b <= iupp - res*c ||
             ilow + res*c <= b && b <= iupp + res*d ){ 
            cout << "YES" << endl; 
            cerr << i << " " << res << endl;
            return 0;}
    }
    cout << "NO" << endl;
}

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

int main()
{
	int n,l,i; int s[32];
	while(cin >> n, n!=-1)
	{
		if(!n) 
		{
			cout << 0 << endl;
			continue;
		}

		for(i=0; n; i++)
		{
			s[i]=n&3; n>>=2;
		}
		for(i--; i>=0; i--)
		{
			cout << s[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int n, x, l, d=0, count=1;
  scanf("%d %d",&n,&x);
  for (int i = 1;i < n+1 ;i++) {
    scanf("%d",&l);
    d += l;
    if (d > x) {
      break;
    }
    count++;
  }
  printf("%d",count);  
}

Measured memory_bytes: 1692
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    int n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    int a = 0, b = 0, e = 0, d = 0;
    do
    {
        switch(getchar_unlocked())
        {
          case 'A': ++a;break;
          case 'W': ++b;break;
          case 'R': ++d;break;
          default: ++e;getchar_unlocked();
        }
        getchar_unlocked();
        getchar_unlocked();
    } while(--n);
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, b, e, d);
    return 0;
}


Measured memory_bytes: 1604
#include<stdio.h>
int main(){
	int H,W,m,n;
	for(;;){
		scanf("%d %d",&H,&W);
		if(H==W && H==0) break;
		for(m=0;m<H;m++){
			for(n=0;n<W;n++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; ++i){cin >> h[i];}
    vector<int> dp(n); dp[0] = 0; dp[1] = abs(h[1]-h[0]);
    //for(int j=0; j<n; ++j){cout << dp[j] << ",";} cout << endl;
    for(int i=0; i+2<n; ++i){
        dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]));
        //for(int j=0; j<n; ++j){
        //  	cout << dp[j] << ",";
        //  } cout << endl;
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
ll ans[1000000];
int main(){
  int n;
  cin >> n;
  REP(x,1,101)REP(y,1,101)REP(z,1,101){
    ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
    if(tmp > n)continue;
    ans[tmp]++;
  }
  REP(i,1,n + 1)cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>                          
using namespace std;
int k,n,a[200005],ans;
int main(){
    cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ans=a[n]-a[1];
    for(int i=2;i<=n;i++)
        ans=min(k-a[i]+a[i-1],ans);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.length() > b.length()) {
			System.out.println("GREATER");
		} else if(a.length() < b.length()) {
			System.out.println("LESS");
		} else if(a.compareTo(b) > 0) {
			System.out.println("GREATER");
		} else if(a.compareTo(b) < 0) {
			System.out.println("LESS");
		} else {
			System.out.println("EQUAL");
		}
	}
}

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

using namespace std;

int main(void)
{
	int n,m;
	long long ans=0,cnt=0;
	bool esc=false;

	cin>>n>>m;

	int a[n],b[n];
	pair<int,int> data[n];

	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		data[i]=make_pair(a[i],b[i]);
	}

	sort(data,data+n);

	for(int i=0;i<n;i++){
		 for(int j=0;j<data[i].second;j++){
			 	if(cnt<m){
			 		ans+=data[i].first;
					cnt++;
				}
				else{
					esc=true;
					break;
				}
		 }
		 if(esc) break;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
//MD. HASNAIN ALI (UNSOLVED)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(a,b) (a>b? a:b)
#define SWAP(a,b) {       \
                    a=a+b;\
                    b=a-b;\
                    a=a-b; }
#define lli long long int
#define lld long long double


int main ()
{
    int m,n;

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

    if(n>m) printf("safe\n");

    else printf("unsafe\n");



    return 0;

}


Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<string>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
const double PI	 = 3.141592;
const int	 MOD = static_cast<int>(1e9) + 7;
using namespace std;

void solve() {
	int n, m, ans = -1;
	cin >> n >> m;
	vector<pair<int, int>> sc(m);
	for (int i = 0; i < m; ++i) {
		cin >> sc[i].first >> sc[i].second;
	}
	int max = 1;
	for (int i = 0; i < n; ++i) max *= 10;
	int st = (n >= 2) ? max / 10 : 0;

	bool ok = true;
	for (int i = st; i < max; ++i) {
		string num = to_string(i);
		for (auto cond : sc) {
			string sec = to_string(cond.second);
			if (num.size() < (size_t)cond.first) { ok = false; continue; }
			if (num[cond.first - 1] != sec[0]) ok = false;
		}
		if (ok) {
			ans = i;
			break;
		}
		ok = true;
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  unmap  unordered_map<int,int>
#define	 unset	unordered_set<int>
#define  maxpq  priority_queue<int>
#define  minpq  priority_queue<int, vector<int>, greater<int>>
#define ll long long
#define fs first
#define ss second//typedef second ss;
#define fora(i,n) for(int i=0;i<n;i++)
#define endl "\n"
using namespace std;

int main(){
	fastio;
	int l,r,d;
    cin>>l>>r>>d;
  int count = 0;
  for(int i=l;i<=r;i++)
  {
    if(i%d == 0){
      count++;
    }
  }
  cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3648
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	if(S == "AAA" or S == "BBB"):
		print("No")
	else:
		print("Yes")

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val cards = Array.fill(n)(sc.nextLong()).sorted
    val operations = IndexedSeq.fill(m)((sc.nextInt(), sc.nextLong()))
    debug(n, m, cards.toSeq, operations)

    operations.sortBy(_._2).reverse.foldLeft(0) { case (acc, (b, c)) =>
      var replaced = false
      var i = acc
      while (i < b + acc && i < cards.length && cards(i) < c) {
        cards(i) = c
        replaced = true
        i += 1
      }
      i
    }
    cards.sum.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 112200
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

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

long long LCM(long long a, long long b)
{  // bracket to avoid overflow
    return a * (b / gcd(a, b));
}

LL n_fac2(LL a)
{
    LL cnt = 0;
    while (a % 2 == 0)
    {
        a /= 2;
        cnt++;
    }
    return cnt;
}

void solve()
{
    int N;
    LL M;
    cin >> N >> M;
    LL lcm      = 1;
    LL nf2_prev = 0;

    REP0 (i, N)
    {
        LL a;
        cin >> a;
        lcm = LCM(a, lcm);

        LL nf2 = n_fac2(a);
        if (i != 0 and nf2_prev != nf2)
        {
            cout << 0 << endl;
            return;
        }
        nf2_prev = nf2;
    }

    if (lcm % 2 == 1)
    {
        cout << 0 << endl;
        return;
    }

    cout << (M + lcm / 2) / lcm << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[200005];
int main()
{
    int i,j,m,n;
    cin>>a;
    i=0;
    j=strlen(a)-1;
    int count=0;
    while(i<j)
    {
        if(a[i]==a[j])
        {
            i++;
            j--;
        }
        else
        {
            if(a[i]=='x')
            {
                count++;
                i++;
            }
            else if(a[j]=='x')
            {
                count++;
                j--;
            }
            else
            {
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define SZ(x) int((x).size())
#define mp make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const LL mod=998244353;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}

LL qmod(LL a,LL b,LL c){
    LL ret=1;
    for(;b;b>>=1){
        if(b&1) ret=ret*a%c;
        a=a*a%c;
    }
    return ret;
}

inline void add(LL &x,LL y){
    x+=y;
    if(x>=mod) x-=mod;
}

LL has[205];

inline LL cal(int n){
    if(n<3) return 0;
    if(has[n]) return has[n];
    LL ans=qmod(2,n,mod);
    add(ans,mod-1-n);
    add(ans,mod-n*(n-1)/2);
    return has[n]=ans;
}

int x[205],y[205];

inline bool check(int i,int j,int k){
    int ax=x[k]-x[i];
    int bx=x[k]-x[j];
    int ay=y[k]-y[i];
    int by=y[k]-y[j];
    return (ax*by-ay*bx)==0;
}

int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    int n=readint();
    for(int i=1;i<=n;i++) x[i]=readint(),y[i]=readint();
    LL ans=cal(n);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int cnt=0;
            for(int k=1;k<=j;k++) cnt+=check(i,j,k);
            if(cnt>2) continue;
            for(int k=j+1;k<=n;k++) cnt+=check(i,j,k);
            add(ans,mod-cal(cnt));
        }
    }
    printf("%lld\n",ans);
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
#include <iostream>                                           
#include <algorithm>                                          
#include <vector>                                             
using namespace std;                                          
                                                              
int main() {                                                  
  vector<int> Sort;                                           
  for (int i=0; i<3; i++) {                                   
    int x;                                                    
    cin >> x;                                                 
    Sort.push_back(x);                                        
  }                                                           
  sort(Sort.begin(), Sort.end());                             
  for (int i=0; i<3; i++) {                                   
    cout << (i==0?"":" ") << Sort[i] << flush;                
  }                                                           
  cout << endl;                                               
  return 0;                                                   
}                                    

Measured memory_bytes: 3164
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll p[15],c[15],summ[15];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll d,g;cin>>d>>g;
  for(int i=0;i<=d-1;i++){
    cin>>p[i]>>c[i];
    summ[i]=100*(i+1)*p[i]+c[i];
  }
  int trys_min=INF;
  for(int bit=0;bit<(1<<d);++bit){
    ll sm=0;
    int trys=0;
    for(int i=0;i<d;++i){
      if(bit & (1<<i)){
        sm+=summ[i];
        trys+=p[i];
      }
    }
    if(g<=sm){
      trys_min=min(trys_min, trys);
    }else{
      ll new_g=g-sm;
      for(int i=d-1;i>=0;i--){
        if(bit & (1<<i))continue;
        for(int j=1;j<=p[i];j++){
          new_g-=100*(i+1);
          trys++;
          if(new_g<=0){
            trys_min=min(trys_min, trys);
            goto E;
          }
        }
      }
    }
    E:;
  }
  P(trys_min);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int x,t;
  string s;
  cin >> s;
  rep(i,s.size()){
    if (i%2 == 1) continue;
    else cout << s[i];
  }
  cout << endl;
  
  return 0;
}

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

using namespace std;

int n, m, p;
vector<int> dst;

int CWDist ( int s, int e ) { return (e - s + n)%n; }
int CCWDist ( int s, int e ) { return (s - e + n)%n; }

int CWNext ( int i ) { return i == m-1 ? dst[0] : dst[i+1]; }
int CCWNext ( int i ) { return i == 0 ? dst[m-1] : dst[i-1]; }

int CWTurn ( int p, int t, int e ) { return CWDist( p, t ) + CCWDist( t, e ); }
int CCWTurn ( int p, int t, int e ) { return CCWDist( p, t ) + CWDist( t, e ); }

int main() {

    cin >> n >> m >> p;
    dst.resize( m );
    
    for ( int i=0; i<m; ++i ) cin >> dst[i];
    sort( dst.begin(), dst.end() );

    int s = 0;
    while ( s < m ) {
	if ( dst[s] > p ) break;
	++s;
    }
    
    int cwNext  = s == m ? dst[0] : dst[s];
    int ccwNext = s == 0 ? dst[m-1] : dst[s-1];

    int dist = min( CCWDist(p, cwNext), CWDist(p, ccwNext) );

    for ( int i=0; i<m; ++i ) {
	dist = min( dist, CWTurn(p, dst[i], CWNext(i)) );
	dist = min( dist, CCWTurn(p, dst[i], CCWNext(i)) );
    }

    cout << 100*dist << endl;
    return 0;
}



Measured memory_bytes: 3208
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

ll N, K;
ll a[200010], f[200010];

bool eatable(ll t)
{
    ll train = 0;
    REP (i, N) {
        if (a[i] * f[i] > t) {
            train += a[i] - t/f[i];
            if (train > K) return false;
        }
    }
    return true;
}

void solve()
{
    sort(a, a+N, greater<ll>());
    sort(f, f+N);
    ll l = -1, u = a[0] * f[N-1];
    while (u - l > 1) {
        ll mid = (l + u) / 2;
        if (eatable(mid)) {
            u = mid;
        } else {
            l = mid;
        }
    }
    cout << u << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP (i, N) cin >> a[i];
    REP (i, N) cin >> f[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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 pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

//二項係数（nCk mod.p;1<=k<=n<=1e7,pは素数）
struct Combination {
    const int MOD = 1000000007;
    vector<ll> fac, finv, inv;
    Combination(const int MAX) : fac(MAX), finv(MAX), inv(MAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long comb(int n, int k) {
        if(n < k)
            return 0;
        if(n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    Combination C(10000);
    for(int i = 1; i <= K; i++) {
        cout << (C.comb(N - K + 1, i) * C.comb(K - 1, i - 1)) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let S = readLine()!.toArray()
let alphabet = "abcdefghijklmnopqrstuvwxyz".toArray()
for c in alphabet {
    if !S.contains(c) {
        print(c)
        break
    }
    if c == "z" {
        print("None")
    }
}


Measured memory_bytes: 8192
import math


def main():
    alphabets = [
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"]
    n = int(input())

    i = 1
    r = ''
    while True:
        r = alphabets[math.ceil((n % (26 ** i)) / (26 ** (i - 1))) - 1] + r
        if n - 26**i > 0:
            n -= 26**i
            i += 1
        else:
            break

    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
N = gets.to_i
S = gets.chomp
dp = Array.new(N + 1, 0)
('a' .. 'z').each do |c|
  s = S.index(c)
  t = S.rindex(c)
  unless s.nil?
    dp[s + 1] += 1
    dp[t + 1] -= 1
  end
end
ans = (1 .. N).inject(0) do |max, i|
  dp[i] += dp[i - 1]
  dp[i] > max ? dp[i] : max
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];

//LL power_int(int a, int b) {
//  return bs[b];
//}

void work() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

  LL parity = (x[0] + y[0]) % 2;

  for (int i = 0; i < n; i++) if ((x[i] + y[i] - parity) % 2 != 0) {cout<<"-1"<<endl;return;}

    if (parity == 0) {
        cout << 32 << endl;
        for (int i = 30; i > -1; i--) cout << bs[i] << " ";
        cout << 1 << endl;
        for (int i = 0; i < n; i++) x[i]++;
    } else {
        cout << 31 << endl;
        for (int i = 30; i > -1; i--) cout << bs[i] << " ";
        cout << endl;
    }

    for (int i = 0; i < n; i++) u[i] = x[i] + y[i], v[i] = x[i] - y[i];

    for (int i = 0; i < n; i++) {
        for (int j = 30; j > -1; j--) {
            if (u[i] > 0 && v[i] > 0) {cout << 'R'; u[i] -= bs[j]; v[i] -= bs[j]; }
            else if (u[i] > 0 && v[i] < 0) { cout << 'U'; u[i] -= bs[j]; v[i] += bs[j]; }
            else if (u[i] < 0 && v[i] > 0) { cout << 'D'; u[i] += bs[j]; v[i] -= bs[j]; }
            else { cout << 'L'; u[i] += bs[j]; v[i] += bs[j];}
        }
        if (parity == 0) cout << 'L';
        cout << endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    rep(i, N-2) for (int j = i+1; j < N-1; ++j) for (int k = j+1; k < N; ++k) {
        if (L[k] < L[i]+L[j] && L[i] != L[j] && L[j] != L[k]) {
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int a, b;

int main()
{
	scanf("%d%d", &a, &b);
	for (int i = (double)a / 0.08; int(i * 0.08) <= a; i++)
	{
		if (int(i * 0.08) == a && int(i * 0.1) == b)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

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

const int MAX_N = 100005;
const int MAX = 2000000005;

int N;
int mem[MAX_N];
int heights[MAX_N];

int dp(int stone) {
  if (stone == N) return 0;
  if (stone > N) return MAX;
  if (mem[stone] != -1) return mem[stone];

  int best = MAX;
  if (stone + 1 <= N) best = std::min(dp(stone + 1) +
    std::abs(heights[stone] - heights[stone+1])
    , best);
  if (stone + 2 <= N)
    best = std::min(dp(stone + 2) +
    std::abs(heights[stone] - heights[stone+2])
      , best);
  mem[stone] = best;
  return best;
}

int main() {
  memset(mem, -1, sizeof(mem));
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", heights + i + 1);
  }

  printf("%d\n", dp(1));
}


Measured memory_bytes: 9152
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
int N, arr[maxn];
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    N = read();
    for (ri i = 1; i <= N * 2; ++i) {
        arr[i] = read();
    }
    std::sort(arr + 1, arr + 1 + 2 * N);
    int sum = 0;
    for (ri i = 1; i <= 2 * N; i += 2) {
        int now = i, later = i + 1;
        if (later > 2 * N)
            break;
        sum += Min(arr[now], arr[later]);
    }
    writeln(sum);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

sosu = []
for i in range(2, int(pow(n, 0.5)) + 1):
    if n % i == 0:
        sosu.append(i)
        if i != n // i:
            sosu.append(n // i)

if sosu == []:
    print(n - 1)
    exit()
yakusu = []
tmpn = n
while n > 1:
    index = 2
    while True:
        if n % index == 0:
            yakusu.append(index)
            n //= index
            break
        else:
            index += 1

yakusu = list(set(yakusu))
ans = tmpn
for i in yakusu:
    ans *= (1 - (1 / i))

print(int(ans))


Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    ll a[5];
    for(int i=0;i<5;i++) cin>>a[i];
    for(int i=0;i<5;i++){
        if(a[i] == 0){
            cout<<(i+1);
            exit(0);
        }
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
string s;

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

  cin>>N>>s;

  int w=0,b=0;
  for(char c:s) if (c=='.') w++;

  int res=w;

  for (char c:s) {
    if (c=='.') w--; else b++;
    res = min(res, w+b);
  }

  cout << res << endl;


  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        final long N = sc.nextLong();
        long ans = Long.MAX_VALUE;
        for (long i = 1; i < Math.sqrt(N) + 1; i++) {
            if (N % i != 0) {
                continue;
            }
            long div = N / i;
            ans = Math.min(ans, (div-1)+(i-1));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int N = NK[0];
        int K = NK[1];

        var h = Enumerable.Repeat(0, N).Select(n => long.Parse(Console.ReadLine())).ToArray();

        h = h.OrderBy(n => n).ToArray();

        
        long ans = int.MaxValue;

        for(int i = 0; i <= N - K; i++)
        {
            var left = i;
            var right = i + K - 1;

            ans = Math.Min(ans, h[right] - h[left]);
        }

        Console.WriteLine(ans);
    }
    
    
}

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

int main() {
int N;
  cin >> N;
  vector<string> vote(N);
  map<string, int> votem;
  vector<int> count(N,1);
  for(int i = 0; i < N; i++){
  	cin >> vote[i];
     if(votem.count(vote[i])){
     	count[i]+= votem[vote[i]];
       votem[vote[i]] = votem[vote[i]] + 1;
     }
    else{
    	votem[vote[i]] = 1;
    }
  }
  
  int maximam = 0; 
  for(int i = 0; i < N; i++){
  	maximam = max(maximam, count[i]);
  }
for (auto p : votem) {
  auto k = p.first;
  auto v = p.second;
  if(v == maximam){
  	cout << k << endl;
  }
}

}

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

using namespace std;

typedef long long ll;

int p[200001];
int c[200001];
int find(int x){
    if(p[x] == x)return x;
    else return p[x] = find(p[x]);
}
void merge(int x,int y){
    x = find(x);
    y = find(y);
    p[y] = x;
}

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

    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++)p[i] = i;

    for(int i = 0; i < m; i++){
        int x,y; cin>> x >> y;
        merge(x,y);
    }
    for(int i =1;i<=n;i++){
        c[find(p[i])] += 1;
    }
    int ans = 0;
    for(int i =1;i<=n;i++){
ans = max(ans, c[i]);
    }
    cout << ans <<'\n';





}


Measured memory_bytes: 5120
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
using namespace std;


string s,t;
int n,m,result;

int main () {
  ios::sync_with_stdio(false);
  t = "No";
  cin >> n ;
  cout << n*n << endl;
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
k = int(input())
if (c > b) and (b > a): print("Yes")
else:
  while b <= a:
    k -= 1
    b *= 2
    if k < 0:
      break
 
  while (c <= a) or (c <= b) and (k > -1):
    k -= 1
    c *= 2
  if k < 0: cond = False
  else: cond = True
  if cond: print("Yes")
  else: print("No")

Measured memory_bytes: 9192
n = gets.to_i
@s = gets.chomp
r = 0
g = 0
b = 0
a = []
for i in 0..(n-1)
  if @s[i] == "R"
    r += 1
  elsif @s[i] == "G"
    g += 1
  else
    b += 1
  end
end

def sp(a,b,c)
  if @s[a] != @s[b] && @s[b] != @s[c] && @s[c] != @s[a]
    true
  else
    false
  end
end



x = 0
if sp(0,1,2)
  x = 1
else
  x = 0
end

dp = Array.new(n)
dp[2] = x

for j in 3..(n-1)
  y = 0
  for k in 1..(j/2)
    if sp(j,j-k,j-(2*k))
      y += 1
    end
  end
  dp[j] = dp[j-1] + y
end

puts (r*g*b) - dp[n-1]

Measured memory_bytes: 14356
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s, t, u;
	int k;
	int con1 = 0, con2 = 1;
	
	cin>>s>>k;
	
	t = s;
	u = s;
	
	for(int i = 1; i < s.size(); i++){
		if(s[i] == s[i-1]) {
			con1++;
			s[i] = 'X';
		}
	}
	
	t[0] = 'X';
	
	for(int i = 1; i < t.size(); i++){
		if(t[i] == t[i-1]) {
			con2++;
			t[i] = 'X';
		}
	}
	
	if(u.size() == 1){
		cout<<k/2<<endl;
	} else if(k == 1) {
		cout<<min(con1, con2)<<endl;
	} else if(s[s.size()-1] == 'X'){
		cout<<con1 * k <<endl;
	} else {
		// cout<<"X"<<endl;
		if(u[0] == u[u.size()-1]) {
			int ans = INF;
			if(t[t.size()-1] == 'X') {
				ans = (con1 + con2) * (k/2) + con1 * (k%2);
				ans = min(ans, (con1 + 1) * k - 1);
				cout<<ans<<endl;
			} else {
				ans = con1 + con2 * (k-1);
				ans = min(ans, (con1 + 1) * k - 1);
				
				cout<< ans <<endl;
			}
		} else {
			cout<<con1 * k <<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


ll calc(vll&w, vll&p, int n, ll&x)
{
	ll ret=0;

	if(x<=0 || n<0) return 0;
	if(x>=w[n])
	{
		x-=w[n];
		return p[n];
	}

	x--;
	ret+=calc(w, p, n-1, x);
	if(x>0)
	{
		x--;
		ret++;
	}
	ret+=calc(w, p, n-1, x);
	x--;

	return ret;
}


int main(void)
{
	int n;
	ll x;

	while(scanf("%d%lld", &n, &x)==2)
	{
		vll p(n+1), w(n+1);

		p[0]=1;
		w[0]=1;
		for(int i=1;i<=n;i++)
		{
			w[i]=w[i-1]*2+3;
			p[i]=p[i-1]*2+1;
		}

		ll ans=0;
		ans=calc(w, p, n, x);
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, ans;
	int m;

	while (true)
	{
		cin >> s;
		if (s == "-")
			break;

		cin >> m;

		while (m--)
		{
			int h;
			cin >> h;

			string temp = s.substr(h);
			s.replace(s.size() - h, h, s.substr(0, h));
			s.replace(0, temp.size(), temp);
		}

		ans += s + "\n";
	}

	cout << ans;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int v[N];
  for(int i=0; i<N; i++){
    cin >> v[i];
  }
  sort(v, v+N);
  
  /*
  for(int i=0; i<N; i++){
    cout << v[i];
  }
  */
  
  double Vmax= (double)v[0] / (double)pow(2,N-1);
  //cout << Vmax;
  for(int i=1; i<N; i++) 
    {
    Vmax += (double)v[i] / (double)pow(2,N-i);
    }
  cout << Vmax;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  ios::sync_with_stdio(false);
  int N, A, B; cin >> N >> A >> B;
  string S; cin >> S;
  for(char c : S) {
    if(c == 'a') {
      if(A + B > 0) {
        cout << "Yes" << endl;
        if(A > 0) {
          --A;
        }
        else {
          --B;
        }
      }
      else {
        cout << "No" << endl;
      }
    }
    else if(c == 'b') {
      if(B > 0) {
        cout << "Yes" << endl;
        --B;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 848
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n = Integer.parseInt(br.readLine().trim());
        int a = Integer.parseInt(br.readLine().trim());
        if (n % 500 <= a){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }




    }

}



Measured memory_bytes: 25348
#include <iostream>
#include <vector>

using namespace std;

int main() {
  // Get input.
  int numStones;
  cin >> numStones;
  vector<int> stones;
  for (int i = 0; i < numStones; ++i) {
    int stone;
    cin >> stone;
    stones.push_back(stone);
  }
  // cost[i] = min(cost[i - 1] + abs(stone[i] - stone[i - 1]), cost[i - 2] +
  // abs(stone[i] + stone[i - 2])).
  vector<int> minCost;
  minCost.resize(numStones);
  minCost.front() = 0;
  for (int i = 1; i < minCost.size(); ++i) {
    int cost = minCost[i - 1] + abs(stones[i] - stones[i - 1]);
    if (i > 1) {
      cost = min(cost, minCost[i - 2] + abs(stones[i] - stones[i - 2]));
    }
    minCost[i] = cost;
  }
  cout << minCost.back() << endl;
  return 0;
}

Measured memory_bytes: 1144