akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var x = myRead.readIntArray();
            var k = myRead.readInt();
            int count = 0;
            while (x[0] >= x[1])
            {
                x[1] *= 2;
                count++;
            }
            while (x[1] >= x[2])
            {
                x[2] *= 2;
                count++;
            }
            string str = "No";
            if (count <= k)
                str = "Yes";
            WriteLine(str);
            Out.Flush();
        }
    }




    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 28220
#include <stdio.h>
#define Max 100000

int A[Max];
int partition(int,int);


int main(){
  int n,q;
  int i;
  
  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  
  for(i=0; i < n; i++){
    if(i==q) printf("[");
    
    printf("%d",A[i]);
    
    if(i==q) printf("]");
    
    if(i != n-1) printf(" ");
  }
  printf("\n");
  
  return 0;
}

int partition(int p,int r){
  int x;
  int i,j;
  int s;
  
  x=A[r];
  i=p-1;
  for(j=p; j < r; j++){
    if(A[j]<= x){
      i++;
      s=A[i];
      A[i]=A[j];
      A[j]=s;
    }
  }
  s=A[i+1];
  A[i+1]=A[r];
  A[r]=s;
  
  return i+1;
}

Measured memory_bytes: 988
# your code goes here
#dice2
def np(dl,nu):
    l=0
    while dl[l]!=nu:
        l+=1
    return l
def si(n1,n2):
    if n1==1:
        if n2==2:
            return 3
        elif n2==3:
            return 5
        elif n2==4:
            return 2
        else:
            return 4
    elif n1==2:
        if n2==1:
            return 4
        elif n2==3:
            return 1
        elif n2==4:
            return 6
        else:
            return 3
    elif n1==3:
        if n2==2:
            return 6
        elif n2==5:
            return 1
        elif n2==1:
            return 2
        else:
            return 5
    elif n1==4:
        if n2==1:
            return 5
        elif n2==2:
            return 1
        elif n2==5:
            return 6
        else:
            return 2
    elif n1==5:
        if n2==1:
            return 3
        elif n2==3:
            return 6
        elif n2==4:
            return 1
        else:
            return 4
    elif n1==6:
        if n2==3:
            return 2
        elif n2==2:
            return 4
        elif n2==5:
            return 3
        else:
            return 5
D=[int(i) for i in input().split()]
q=int(input())
for i in range(q):
    n=[int(i) for i in input().split()]
 #   print(n)
    p=[]
    for j in range(2):
        p.append(np(D,n[j]))
  #  print(p)
    print(D[si(p[0]+1,p[1]+1)-1])

Measured memory_bytes: 7704
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define debug2(x, y) cerr << #x << ": " << (x) << " " << #y << ": " << y << endl;
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N = in();
  VII ps(2 * N);
  REP (i, 2 * N) {
    ps[i] = {in(), i < N};
  }
  sort(ALL(ps));
  int ans = 1;
  int acc = 0;
  REP (i, 2 * N) {
    if ((acc > 0 && !ps[i].se) || (acc < 0 && ps[i].se)) {
      (ans *= abs(acc)) %= MOD;
    }
    acc += ps[i].se ? 1 : -1;
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];

  int q;
  cin >> q;
  while(q--) {
    int l, r;
    cin >> l >> r;
    reverse(a.begin()+l, a.begin()+r);
  }

  for(int i = 0; i < n; ++i) cout << a[i] << " \n"[i==n-1];

  return 0;
}


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


int main() {
	string s; cin >> s;
	int sum = 0;
	for(auto c : s) {
		sum += (c - '0');
	}
	cout << (sum % 9 == 0 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3708
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

template <typename T> struct vec2 { T x, y; vec2(T _x, T _y) :x(_x), y(_y) {} };

const long double PI = 3.141592653589793;

int main()
{
	cout << fixed << setprecision(16);

	LLI a, b, h, m;
	cin >> a >> b >> h >> m;

	LLI min = h * 60 + m;

	long double hrad = min * PI * 2 / 60.0;
	long double mrad = min * PI * 2 / (60.0 * 12);


	vec2<long double> p1(a * cos(hrad), a * sin(hrad));
	vec2<long double> p2(b * cos(mrad), b * sin(mrad));


	cout << sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));

	return 0;
}


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,m;
	cin>>n>>m;
	vi check(n+3,0);
	loop(m){
		int a,b;
		cin>>a>>b;
		if(a==1) check[b]++;
		else if (b==n) check[a]++;
	}
	int ok=0;
	rep(i,n+1)if(check[i]==2) ok=1;

	cout<<(ok?"POSSIBLE":"IMPOSSIBLE")<<endl;

	return 0;
}



Measured memory_bytes: 4816
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits>

#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()
#define INF (INT_MAX/2)
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool shortestPath(const Graph g, int s, vector<Weight> &dist) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  bool negative_cycle = false;
  REP(k, n) REP(i, n) if(dist[i]<INF) FOR(e,g[i]) {
    if (dist[e->dst] > dist[e->src] + e->weight) {
      dist[e->dst] = dist[e->src] + e->weight;
      if (k == n-1) {
        dist[e->dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main(){
  int r,V,E,s,t,e,i;
  cin >> V >> E >> r;
  Graph g(V);
  vector<Weight> dist;
  while(E--){
    cin >> s >> t >> e;
    g[s].push_back(Edge(s,t,e));
  }
  if(!shortestPath(g,r,dist)) cout << "NEGATIVE CYCLE" << endl;
  else{
    for(i=0;i<V;i++){
      if(dist[i] >= INF) cout << "INF" << endl;
      else cout << dist[i] << endl;
    }
  }
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,i=0,j,s=10000000,p[200010],min=1000000,ans=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> p[i];
    }
    for(i=0;i<n;i++)
    {
        if(s>p[i])
        {
            s=p[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;

}


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


void solve() {
	string s;
	cin >> s;
	if (s == "ARC")
		cout << "ABC";
	else
		cout << "ARC";
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	solve();

	return 0;
}

Measured memory_bytes: 3640
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  for(int d=1;d<=D;d++){
    int mi=1;
    int max=-1e9;
    for(int i=1;i<=26;i++){
      int tmp=S[d][i];
      for(int j=1;j<=26;j++){
        if(j!=i) tmp-=C[j]*(d-last[d-1][j]);
      }
      if(max<tmp){
        max=tmp;
        mi=i;
      }
    }
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    if(d==1){
      last[1][1]=1;
      cout<<1<<endl;
    }
    else{
      last[d][mi]=d;
      cout<<mi<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s,t,u;
int a,b;

int main(void){
	cin >> s >> t;
	scanf("%d%d",&a,&b);
	cin >> u;
	if(s==u){
		a--;
	}else{
		b--;
	}
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n,r;cin>>n>>r;
    if(n<10){
        cout<<r+100*(10-n)<<endl;
    }else{
        cout<<r<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int H, W;
    cin >> H >> W;
    vector<vector<char>> G(H, vector<char>(W));
    vector<vector<int>> up(H, vector<int>(W)), down(H, vector<int>(W)),
        left(H, vector<int>(W)), right(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> G[i][j];
            if (G[i][j] == '.')
                up[i][j] = 1, down[i][j] = 1, left[i][j] = 1, right[i][j] = 1;
        }
    }

    rep(i, H) {
        rep(j, W - 1) {
            left[i][j + 1] += left[i][j];
            if (G[i][j + 1] == '#')
                left[i][j + 1] = 0;
        }
    }

    rep(i, H) {
        for (int j = W - 1; j > 0; j--) {
            right[i][j - 1] += right[i][j];
            if (G[i][j - 1] == '#')
                right[i][j - 1] = 0;
        }
    }

    rep(j, W) {
        rep(i, H - 1) {
            down[i + 1][j] += down[i][j];
            if (G[i + 1][j] == '#')
                down[i + 1][j] = 0;
        }
    }

    rep(j, W) {
        for (int i = H - 1; i > 0; i--) {
            up[i - 1][j] += up[i][j];
            if (G[i - 1][j] == '#')
                up[i - 1][j] = 0;
        }
    }

    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (G[i][j] == '#')
                continue;
            ll tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}

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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

// DP
int main() {
    const int FACT[] = {1, 2, 6, 24, 120, 720, 5040, 40320};
    const int INF    = 1001001001;
    int n;
    cin >> n;

    vector<int> p(n), q(n);
    rep(i, 0, n) { cin >> p[i]; }
    rep(i, 0, n) { cin >> q[i]; }

    vector<int> cmp(n);
    repe(i, 1, n) { cmp[i - 1] = i; }
    bool pmatch = false, qmatch = false, enabcnt = false;
    int cnt = 0;

    do {
        // for (int a : cmp) { cout << a << " "; }
        // cout << endl;

        if (cmp == p) {
            if (!enabcnt) { enabcnt = true; }
            pmatch = true;
            // cout << " pmatch" << endl;
        }
        if (cmp == q) {
            if (!enabcnt) { enabcnt = true; }
            qmatch = true;
            // cout << " qmatch" << endl;
        }
        if (pmatch && qmatch) {
            cout << cnt << endl;
            return 0;
        }
        if (enabcnt) cnt++;
    } while (next_permutation(cmp.begin(), cmp.end()));

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if( 0 <= x && 0 <= y){
        if(x <= y){
            ans += abs(y-x);
        }else{
            ans +=min(abs(-x-y)+1,abs(y-x)+2);
        }
    }else if (0 <= x && y < 0){
        ans += abs(-x - y);
        ans += 1;
    }else if (x < 0 && 0 <= y){
        ans += min(y-x,abs(-x - y)+1);
    }else{
        if(x <= y){
            ans += abs(y - x);
        }else{
            ans += abs(y - x);
            ans += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;

int main()
{
	int N;	cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	sort(A.begin(), A.end());
	int ans = 1;
	bool b = true;
	
	if (N % 2 == 1)
	{
		if (A[0] != 0) b = false;
		for (int i = 1; i < N; i++)
		{
			if (i % 2 == 1) { if (A[i] != A[i - 1] + 2) b = false; }
			else { if (A[i] != A[i - 1]) b = false; }
		}
	}
	else
	{
		if (A[0] != 1 || A[1] != 1) b = false;
		for (int i = 2; i < N; i++)
		{
			if (i % 2 == 0) { 
				if (A[i] != A[i - 1] + 2) b = false; 
			}
			else { 
				if (A[i] != A[i - 1]) b = false; 
			}
		}
	}
	if (b)
	{
		if (N % 2 == 0) rep(i, N / 2) ans = ans * 2 % mod;
		else rep(i, (N - 1) / 2) ans = ans * 2 % mod;
	}
	else ans = 0;
	cout << ans << endl;
	cin >> N;
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> v(n);
    for(auto&& i : v) cin >> i;

    REP(i, n){
        if(v[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    REP(i, n){
        if(2 * INF / ans < v[i]){
            ans = -1;
            break;
        }else{
            ans *= v[i];
        }
    }
    if(ans > INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
typedef struct range
{
	int left,right,value;
	bool operator <(const struct range & t) const
	{
		return right<t.right;
	}
}RANGE,*PRANGE;
long long tree[1<<19],lazy[1<<19];
RANGE arr[200001];
long long search(int index,int lb,int rb,int lq,int rq)
{
	if(lq==lb&&rq==rb)
		return tree[index];
	int mid=(lb+rb)>>1;
	tree[index<<1]+=lazy[index];
	tree[index<<1|1]+=lazy[index];
	lazy[index<<1]+=lazy[index];
	lazy[index<<1|1]+=lazy[index];
	lazy[index]=0;
	if(rq<=mid)
		return search(index<<1,lb,mid,lq,rq);
	else if(lq>mid)
		return search(index<<1|1,mid+1,rb,lq,rq);
	else
		return max(search(index<<1,lb,mid,lq,mid),search(index<<1|1,mid+1,rb,mid+1,rq));
}
void update(int index,int lb,int rb,int lq,int rq,long long value)
{
	if(lq==lb&&rq==rb)
	{
		lazy[index]+=value;
		tree[index]+=value;
		return;
	}
	int mid=(lb+rb)>>1;
	tree[index<<1]+=lazy[index];
        tree[index<<1|1]+=lazy[index];
	lazy[index<<1]+=lazy[index];
        lazy[index<<1|1]+=lazy[index];
	lazy[index]=0;
	if(rq<=mid)
                update(index<<1,lb,mid,lq,rq,value);
        else if(lq>mid)
                update(index<<1|1,mid+1,rb,lq,rq,value);
        else
	{
                update(index<<1,lb,mid,lq,mid,value);
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
	}
	tree[index]=max(tree[index<<1],tree[index<<1|1]);
}
int main()
{
	int i,n,m,cnt=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d %d %d",&arr[i].left,&arr[i].right,&arr[i].value);
	sort(arr,arr+m);
	for(i=1;i<=n;i++)
	{
		update(1,0,n,i,i,search(1,0,n,0,i-1));
		while(i==arr[cnt].right&&cnt<m)
		{
			update(1,0,n,arr[cnt].left,arr[cnt].right,arr[cnt].value);
			cnt++;
		}
	}
	printf("%lld",search(1,0,n,0,n));
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if(a < b) swap(a, b);
  int cnt = 0;
  for(int div = b; div >= 1; div--) {
    if(a % div == 0 && b % div == 0) {
      cnt++;
      if(cnt == k) {
        cout << div << endl;
        return 0;
      }
    }
  }
}

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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0



int main ()

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

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);

    ll x;
    cin >> x;
    ll p = 100;
    for (ll i =1; ;i++)
    {
        p += p*0.01;
        if (p >= x)
        {
            cout << i << endl;
            return 0;
        }
    }
       
    
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	
	static class Drinks implements Comparable<Drinks>{
		long cost, drinks;
		public Drinks (long c, long d) {
			cost = c;
			drinks = d;
		}
		@Override
		public int compareTo(Drinks o) {
			// TODO Auto-generated method stub
			return (int) (cost - o.cost);
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt(), M = sc.nextInt(), cost = 0;
		PriorityQueue<Drinks> q = new PriorityQueue<Drinks>();
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			q.add(new Drinks(a, b));
		}
		for (int i = 0; i < N; i++) {
			Drinks p = q.poll();
			long c = p.cost, d = p.drinks;
			if (M - d < 0) {
				cost += c*M;
				M = 0;
			}
			else {
				cost += c*d;
				M -= d;
			}
			if (M == 0) break;
		}
		System.out.println(cost);
	}

}

Measured memory_bytes: 85172
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();
        int ans = 0;
        while(X<=Y){
            X *= 2;
            ans++;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 21588
n = gets.to_i
s = 8
if n < 600
  s = 8
elsif n < 800
  s = 7
elsif n < 1000
  s = 6
elsif n < 1200
  s = 5
elsif n < 1400
  s = 4
elsif n < 1600
  s = 3
elsif n < 1800
  s = 2
else
  s = 1
end
puts s
 

Measured memory_bytes: 14324
#include<bits/stdc++.h>
using namespace std;
int EOorder(int i);
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a-(b*2),0)<<endl;
}
int EOorder(int i){
	if(i%2==1){
		i++;
	}
	i=i/2;
	return i;
}


Measured memory_bytes: 256
def check(mid):
	val = 0
	for i in c:
		if(i[0]*i[1] > mid):
			val += i[0] - (mid//i[1])
	return val <= k

def bs():
	l = 0
	r = 1e18
	while(l <= r):
		mid = (l+r)//2
		if(check(mid)):
			r = mid-1
		else:
			l = mid+1
	return r+1

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse = True)
c = [[a[i],b[i]] for i in range(n)]
print(int(bs()))

Measured memory_bytes: 128588
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, _ = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt())
  val last = sc.nextInt()
  val dp = Array.fill(n, 2)(0)

  for (i <- n-1 to 0 by -1) {
    val ai = a(i)
    val s = (ai - last).abs
    dp(i)(0) = s.max(dp.drop(i+1).map(_(1)).maxOption.getOrElse(0))
    dp(i)(1) = s.min(dp.drop(i+1).map(_(0)).minOption.getOrElse(Int.MaxValue))
  }

  println(dp(0)(0))
}


Measured memory_bytes: 58264
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{

 int a;
 int b;
 int d;
 int r;
 double f;

 cin >> a >> b;

 d = a / b;
 r = a % b;

 double x = static_cast<double>(a);
 double y = static_cast<double>(b);

 f = x / y;

 printf("%d%s%d%s%f\n", d," ", r, " ", f);

}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w,h,x,y,r;
	
	Main() {
		readData();
		
		
		if (isRange())
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
	private boolean isRange() {
		
		if (((r <= x) && (x <= w-r)) && ((r <= y) && (y <= h-r)))
			return true;
		
		return false;
	}
	
	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			w = nextInt();
			h = nextInt();
			x = nextInt();
			y = nextInt();
			r = nextInt();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 16996
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s,k,ans=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++)
			if(s-i-j<=k&&s-i-j>=0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
long long n,a,b;
cin >> n >> a >> b;
if(a>b){cout << "0" << endl;
return 0;}
if(n==1){
    if(a==b){cout << "1" << endl;
    return 0;}
    else{cout << "0" << endl;
    return 0;}
}
cout << (n-2)*(b-a)+1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int gcd(int a, int b) {
	if (a == 0) {
		return b;
	}
	return gcd(b % a, a);
}
int main() {
	int a, b;
	cin >> a >> b;
	//cout << gcd(a, b) << endl;
	cout << ((LL)((a / gcd(a, b))) * (LL)(b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

int main(){
	int n,m;
	while(cin>>n>>m,n|m){
		vector<pair<int,pii> > tsd(m);
		REP(i,m){
			cin>>tsd[i].first>>tsd[i].second.first>>tsd[i].second.second;
		}
		sort(ALL(tsd));
		vi inf(n+1);
		inf[1]=1;
		REP(i,m){
			if(inf[tsd[i].second.first]){
				inf[tsd[i].second.second]=1;
			}
		}
		cout<<count(inf.begin()+1,inf.end(),1)<<endl;
	}
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1100;


char grid[MAXN][MAXN];

void run3 (int R, int C){
    grid[R][C] = grid[R][C+1] = 'a';
    grid[R+1][C+2] = grid[R+2][C+2] = 'a';
}

void run32 (int R, int C){
    grid[R][C] = grid[R][C+1] = 'a';
    grid[R][C+2] = grid[R+1][C+2] = 'b';
    grid[R+2][C+2] = grid[R+2][C+1] = 'a';
    grid[R+2][C] = grid[R+1][C] = 'b';
}


void donine(int row){
    for (int i=0;i<9;i+=3)for (int j=0;j<9;j+=3)run3(row+i,row+j);
}

void run4(int R, int C){
    grid[R][C] = grid[R+1][C] = 'a';
    grid[R][C+1] = grid[R+1][C+1] = 'b';
    grid[R+2][C] = grid[R+2][C+1] = 'c';
    grid[R+3][C] = grid[R+3][C+1] = 'd';
    grid[R][C+2] = grid[R][C+3] = 'e';
    grid[R+1][C+2] = grid[R+1][C+3] = 'f';
    grid[R+2][C+2] = grid[R+3][C+2] = 'g';
    grid[R+2][C+3] = grid[R+3][C+3] = 'h';
}

void out(int _N){
    for (int i=1;i<=_N;++i){
        for(int j=1;j<=_N;++j)cout<<grid[i][j];
        cout<<'\n';
    }
}

void doseven(int R){
    int C=R;
    run32(R,R);
    run32(R+3,R+3);
    grid[R][C+6] = grid[R+1][C+6] = 'c';
    grid[R+2][C+6] = grid[R+3][C+6] = 'd';
    grid[R+4][C+6] = grid[R+5][C+6] = 'e';
    grid[R+6][C] = grid[R+6][C+1] = 'c';
    grid[R+6][C+2] = grid[R+6][C+3] = 'd';
    grid[R+6][C+4] = grid[R+6][C+5] = 'e';
}

void dofive(int R){
    run3(R+1,R+1);
    grid[R+0][R+0] = grid[R+0][R+1] = 'h';
    grid[R+0][R+2] = grid[R+0][R+3] = 'i';
    grid[R+0][R+4] = grid[R+1][R+4] = 'j';
    grid[R+2][R+4] = grid[R+3][R+4] = 'k';
    grid[R+4][R+4] = grid[R+4][R+3] = 'l';
    grid[R+4][R+2] = grid[R+4][R+1] = 'm';
    grid[R+4][R+0] = grid[R+3][R+0] = 'n';
    grid[R+2][R+0] = grid[R+1][R+0] = 'o';
}

int main(){
    int N;
    cin>>N;
    int R = N;
    
    for (int i=1;i<=N;++i)for (int j=1;j<=N;++j)grid[i][j]='.';

    if (N==7){
        doseven(1);
        out(R);
        return 0;
    }else if (N == 11){
        doseven(1);
        run4(8,8);
        out(R);
        return 0;
    }

    if (N%3==0){ // 1 per row
        while (N!=0){
            run3(N-2,N-2);
            N -= 3;
        }
        out(R);
        return 0;
    }

    while (N>=5&&N%4!=0){
        dofive(N-4);
        N -= 5;
    }
    if (N<0 || N%4!=0){ 
        cout<<-1;
        return 0;
    }

    while (N){ // Mix of 4 and 9
        run4(N-3,N-3);
        N -= 4;
    }
    out(R);
    
}

Measured memory_bytes: 2304
#include<stdio.h>
int a[105];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
    scanf("%d",&a[i]);
}
int l,r;
r=n-1;
l=0;
int sum1=a[l];
int sum2=a[r];
while((r-l)>1)
{
if(sum1>sum2)
{
    r-=1;
    sum2+=a[r];
}
else if(sum1<sum2)
{
    l+=1;
    sum1+=a[l];
}
else{
    l+=1;
    sum1+=a[l];
    r-=1;
    sum2+=a[r];
}
}
if(sum1>sum2)
{
    printf("%d\n",sum1-sum2);
}
else{
    printf("%d\n",sum2-sum1);
}
return 0;
}


Measured memory_bytes: 128
n=int(input())
a=[]
s=input().split()
for i in range(n):
  a.append(int(s[i]))
Min=1000000000
min=1000000000
while(True):
  a=sorted(a)
  d=0
  for i in range(n):
    if a[i]==0:
      continue
    elif d==0:
      d=a[i]
      if d<min:
        min=d
      continue
    a[i]=a[i]%d
    if a[i]!=0 and a[i]<min:
      min=a[i]
  if min<Min:
    Min=min
  else:
    break
print(Min)

Measured memory_bytes: 15760
n, _ = map(int, input().split())
CST = {} # {c:[max_t, [s,t],...[,]]}
for i in range(n):
    s, t, c = map(int, input().split())
    if c in CST: CST[c] += [[s,t]]
    else: CST[c] = [t, [s,t]]
    CST[c][0] = max(CST[c][0], t)
R = [0]*200002
for c, ST in CST.items():
    mx_t = ST[0]*2+2
    TZ = [0]*mx_t
    for s,t in ST[1:]:
        TZ[2*s - 1] += 1
        TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))


Measured memory_bytes: 136408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int N, A;
    cin >> N >> A;
    vl X(N);
    rep(i, N) {
        cin >> X[i];
    }

    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vl(3000)));
    dp[0][0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < 3000; k++) {
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + X[i]] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    rep(j, N) {
        ans += dp[N][j + 1][(j + 1) * A];
    }

    cout << ans << endl;
}

Measured memory_bytes: 65556
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
 
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0b00010000000000000000000000000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}
 
 
void execute()
{
  int a[12][12];
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
 
  int ans = iINF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == iINF) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 3660
import math


def is_squre(number):
  sqrted =int(math.sqrt(number))
  return(number == sqrted * sqrted)

if __name__ == "__main__":
  a, b = input().split()
  combind = int(a + b)
  if is_squre(combind):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))

flag = True
for i in range(n-1,0,-1):
  if h[i]>=h[i-1]:
    continue
  elif h[i-1]-h[i]==1:
    h[i-1] -= 1
  else:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 15020
#include  <bits/stdc++.h>
  using namespace std ;
  
  int main()
  {
  	int a , b , c , d , e ;
  	cin >> a >> b >> c ;
  	d = c / a ;
  	e = d * b ;
  	
  	cout << e << endl ;
  	return 0 ;
  }

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

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

using namespace std;

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

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<bool> okwater(30001, false), oksuger(30001, false);
    okwater[0] = true; oksuger[0] = true;
    for (int i = 0; i <= 30000; i++) {
        if (okwater[i]) {
            if (i+100*A <= 30000) okwater[i+100*A] = true;
            if (i+100*B <= 30000) okwater[i+100*B] = true;
        }
        if (oksuger[i]) {
            if (i+C <= 30000) oksuger[i+C] = true;
            if (i+D <= 30000) oksuger[i+D] = true;
        }
    }

    int water, suger;
    pair<int, int> ans;
    double conow = 0, comax = -1;
    for (water = 100; water <= 3000; water += 100) {
        if (!okwater[water]) continue;
        suger = water / 100 * E;
        while (suger >= 0 && !oksuger[suger] || water + suger > F) suger--;

        conow = suger / (double) (water + suger);
        if (conow > comax) {
            comax = conow;
            ans = make_pair(suger + water, suger);
        }

    }

    cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10**7)

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
  x, y = map(lambda x: int(x)-1, input().split())
  graph[x].append(y)

dp = [-1]*N
def rec(v):
  if dp[v] != -1:
    return dp[v]
  
  res = 0
  for nv in graph[v]:
    res = max(res, rec(nv)+1)
  dp[v] = res
  return res

res = 0
for v in range(N):
  res = max(res, rec(v))
print(res)

Measured memory_bytes: 61228
def main(): 

    n = int(input())
    p = list(map(int,input().split()))

    cnt = 0

    for i in range(1,n+1):
        if p[i-1] != i:
            cnt += 1

    print('YES' if cnt == 0 or cnt == 2 else 'NO')


if __name__ == "__main__":
    main() 

Measured memory_bytes: 3060
import java.util.Scanner;

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

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int ipt = 100 * r + 10 * g + b;

        String ans = (ipt % 4 == 0) ? "YES" : "NO";

        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
function Main(input) {
  var N = input.trim().length;
  var count = 0;
  var color = 0;
  
  for(i=0;i<N;i++){
    if (parseInt(input.charAt(i)) == color) count++;
    color = (color + 1)%2;
  }
  console.log(Math.min(count,N-count));
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int n, p, rest;
	while(cin>> n >> p , n){
		int player[50];
		for(int i = 0; i< n; i++)
			player[i] = 0;
		int i = 0;
		rest = p;
		while(1){
			if(rest > 0){
				player[i % n]++;
				if(player[i % n] == p)
					break;
				rest--;
			}else if(player[i % n] > 0){
				rest += player[i % n];
				player[i % n] = 0;
			}
			i ++ ;
		}
		cout << i % n << endl;
	}
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<string> s(100000);
    map<string, int> mp;
    long long ans =0;
    for(int i=0; i<n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        if(mp.count(s[i])){
            ans += mp[s[i]];
            mp[s[i]]++;
        }else{
            mp[s[i]] = 1;
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 14048
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


ll dfs(ll h){
  if (h==1) return 1;
  return dfs(h/2)*2+1;
}


int main(void){
  ll h;
  
  cin >> h;
  
  cout << dfs(h) << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int M = 1e9+7;

long long a , b;
vector < long long > common;

int gcd(int a , int b){
    if(b == 0)
        return a;
    return gcd(b , a%b);
}

vector < int > primeFactors(long long num){
    vector < int > prm;
    while (num % 2 == 0){
        prm.push_back(2);
        num = num/2;
    }
    for (long long i = 3; i*i <= num; i = i + 2){
        while (num % i == 0){
            prm.push_back(i);
            num = num/i;
        }
    }
    if (num > 2)
        prm.push_back(num);
    return prm;
}

int main(){
    cin >> a >> b;
    map < int , bool > taken , did;
    vector < int > A[2] = {primeFactors(a) , primeFactors(b)};
    for(int i = 0; i < A[0].size(); i++){
        taken[A[0][i]] = 1;
    }
    int cnt = 1;
    for(int i = 0; i < A[1].size(); i++){
        if(taken[A[1][i]] && !did[A[1][i]]){
            cnt++;
            did[A[1][i]] = 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}

int main(int argc, char **argv) {
    int n = get_uint();
    int a;
    // makeable array, 0 is makeable anytime
    char b[50000] = {1};
    for(int i = 0; i < n; ++i) {
        a = get_uint();
        for(int j = 40000; j >= 0; --j) {
            // if number j is makeable, number j+a is also makeable
            b[j] ? b[j + a] = 1 : 0;
        }
    }
    int q = get_uint();
    for(int i = 0; i < q; ++i) {
        a = get_uint();
        puts(b[a] ? "yes" : "no");
    }
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  cout << a+a*a+a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 22

ll dp[1<<N];

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

    int n,i;
    cin>>n;
    bool a[n][n];
    ifr(i,0,n) ifr(j,0,n) cin>>a[i][j];
    dp[0]=1;
    ifr(mask,0,(1<<n)-1) {
        i = __builtin_popcount(mask);
        ifr(j,0,n) {
            if(!((mask>>j)&1) && a[i][j])
                dp[mask^(1<<j)] = (dp[mask^(1<<j)]+dp[mask])%mod;
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <algorithm>
#include <cstdio>

int main() {
    int h, w, d;
    scanf("%d%d%d", &h, &w, &d);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int x = (i + j + w) / d, y = (i - j + w) / d;
            x &= 1, y &= 1;
            if (x && y) printf("Y");
            else if (x && !y) printf("B");
            else if (!x && y) printf("G");
            else printf("R"); 
        }
        printf("\n");
    }
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    static final int MAX = 1000000001;
    static int count = 0;

    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] S = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] R = mergeSort(S, 0, n-1);
        
        StringBuilder sb = new StringBuilder();
        sb.append(R[0]);
        for(int i = 1; i < R.length - 1; i++) {
            sb.append(" ");
            sb.append(R[i]);
        }
        System.out.println(sb.toString());
        System.out.println(count);
    }

    public static int[] mergeSort(int[] s, int left, int right) {
        if(left == right) {
            int[] ret = new int[2];
            ret[0] = s[left];
            ret[1] = MAX;
            return ret;
        } else {
            int mid = left + (right - left) / 2;
            int[] l = mergeSort(s, left, mid);
            int[] r = mergeSort(s, mid+1, right);
            return merge(l, r);
        }
    }

    public static int[] merge(int[] left, int[] right) {
        int[] r = new int[(left.length-1) + (right.length-1) + 1];
        int ri = 0;
        int li = 0;
        for(int i = 0; i < r.length - 1; i++) {
            if(left[li] <= right[ri]) {
                r[i] = left[li];
                li++;
            } else {
                r[i] = right[ri];
                ri++;
            }
            count++;
        }
        r[r.length - 1] = MAX;

        return r;
    }
}

Measured memory_bytes: 159816
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");
    // String nyu=sc.nextLine();

//int[] num=new int[6];

int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);

int result=B/A;


//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);

System.out.println(result>C-1 ? C : result) ;

	}
}

Measured memory_bytes: 21972
N=int(input())
s=[]
t=[]
for i in range(N):
    a,b=map(int,input().split())
    t+=[(a,b)]
for j in range(N):
    c,d=map(int,input().split())
    s+=[(c,d)]
s=sorted(s)
t=sorted(t)
for k in range(N):
    (x,y)=(-1,-1)
    for ii in range(len(t)):
        if s[k][0]>t[ii][0] and s[k][1]>t[ii][1] and y<t[ii][1]:
            (x,y)=t[ii]
    if (x,y) in t:        
        t.remove((x,y))
print(N-len(t))

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
int x,y;
int i;
while(1){
scanf("%d %d",&x,&y);
if(x==0 && y==0)
break;
if(x<y)
printf("%d %d\n",x,y);
else
printf("%d %d\n",y,x);
}
return 0;
}


Measured memory_bytes: 2688
s = input()
s = s[::-1]

l = [0 for i in range(2019)]
n = len(s)
l[0] = 1
prev = 0
digit = 1
for c in s:
    t = (int(c) * digit + prev) % 2019
    l[t] += 1
    digit = (digit * 10) % 2019
    prev = t

res = 0
for i in l:
    res += i * (i-1) // 2

print(res)

Measured memory_bytes: 9240
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  long[] a; readA(n, a);

  auto as = a.cumulativeSum;
  auto dp = new long[][](n, n+1);

  long f(int i, int j)
  {
    if (i+1 == j) return 0;
    if (dp[i][j]) return dp[i][j];

    auto r = 10L^^18;
    foreach (k; i+1..j)
      r = min(r, f(i, k) + f(k, j) + as[i..j]);

    return dp[i][j] = r;
  }

  writeln(f(0, n));
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }


Measured memory_bytes: 3836
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i;i<(int)n;i++)
#define rep2(i,begin_i,end_i) for(int i=(int)begin;i<(int)end;i++)

int main(){
    int N,A,B,n;
    cin>>N>>A>>B;
    int check=0;
    for(int i=1;i<=N;i++){
        int sum=0;
        n=i;
       while(n){
        sum+=n%10;
        n/=10;
       }
       if(sum>=A){
           if(sum<=B){
               check+=i;
           }
       }
    }
    cout<<check<<endl;
    return 0;
}


Measured memory_bytes: 256