akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(a>=b){
    b*=2;
    --k;
  }
  while(b>=c){
    c*=2;
    --k;
  }
  if(k>=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string S;
  cin >> S;
  ll N = S.size();
  bool ok = true;
  if (S[0] != 'A') {
    ok = false;
  }
  ll cnt = 0;
  for (ll i = 2; i < N - 1; ++i) {
    if (S[i] == 'C') {
      cnt += 1;
    }
  }
  if (cnt != 1) {
    ok = false;
  }
  for (ll i = 0; i < N; ++i) {
    if (S[i] == 'A' || S[i] - 'a' >= 0 || S[i] == 'C') {
      continue;
    }
    ok = false;
  }
  if (ok) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m), c(m);
    vector<P> p(m);
    rep(i, n) cin >> a[i];
    rep(i, m) {
        cin >> b[i] >> c[i];
        p[i] = P(c[i], b[i]);
    }

    sort(all(a));
    sort(all(p), greater<P>());

    vector<int> d;
    rep(i, m) {
        while (p[i].second > 0 && sz(d) < n) {
            d.push_back(p[i].first);
            p[i].second--;
        }
    }

    int k = min(n, sz(d));
    rep(i, k) {
        if (a[i] >= d[i]) break;
        a[i] = d[i];
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 2812
#include <stdio.h>
int main(void){
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n==0)
        break;
        int pm,pe,pj,ave,em,i;
        for(i=1;i<=n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            ave=(pm+pe+pj)/3;
            em=(pm+pe)/2;
            if(pm==100||pe==100||pj==100||em>=90||ave>=80){
                printf("A\n");
            }else if(ave>=70||(ave>=50&&(pm>=80||pe>=80))){
                printf("B\n");
            }else{
                printf("C\n");
            }
            
            
        }

    }
    
    
    
    
}


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

ll op(ll x) {
	return x * x * x * x * x;
}

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

	for (int i = -1000; i <= 1000; i++) {
	    for (int j = -1000; j <= 1000; j++) {
	    	if (op(i) - op(j) == x) {
	    		cout << i << " " << j << endl;
	    		return 0;
	    	}
	    }
	}

    return 0; 
} 


Measured memory_bytes: 3652
#include <algorithm>
#include <cstdio>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  map<string, vector<int>> index;
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    char word[40];
    int page;
    sscanf(line, "%s %d", word, &page);
    string key(word);
    index[key].push_back(page);
  }
  free(line);
  for (const auto& entry : index) {
    printf("%s\n", entry.first.c_str());
    vector<int> pages(entry.second);
    sort(pages.begin(), pages.end());
    for (auto iter = pages.cbegin(); iter != pages.cend(); ++iter) {
      printf("%d%c", *iter, (iter + 1 == pages.cend() ? '\n' : ' '));
    }
  }

  return 0;
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

//  U
// L R
//  D
//偶数ステップの行列と奇数ステップの行列に分けて判定する
string stepAll;
int count = 0;
bool flg = true;

cin >> stepAll ;


REP(i,0,stepAll.length()){
    //奇数
    if(!stepAll[i*2]) break;
    if(stepAll[i*2] == 'L') {
        cout << "No" << endl;
        flg = false;
        break;
        }
    if(!stepAll[i*2+1]) break;
    if(stepAll[i*2+1] == 'R') {
        cout << "No" << endl;
        flg = false;
        break;
        }
}

if(flg) cout << "Yes" << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    string alice,bob,charles;
    cin>>alice>>bob>>charles;
    int a = 0,b = 0,c = 0;
    char ch = 'a',ans;

    while(a < alice.size() or b < bob.size() or c < charles.size()) {
        if (ch == 'a')
        {
            if(a == alice.size()) {
                cout<<'A';
                break;
            }
            ch = alice[a];           
            a++;            
        }
        else if (ch == 'b')
        {
            if (b == bob.size())
            {
                cout<<'B';
                break;
            }
            ch = bob[b];
            b++;
        }
        else {
            if (c == charles.size())
            {
                cout<<'C';
                break;
            }
            ch = charles[c];
            c++;
        }
    }


    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <iostream>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 62;

int n, k;
struct Point {
	LL x, y;
	bool friend operator < (const Point a, const Point b) {
		if(a.x == b.x) return a.y < b.y;
		else return a.x < b.x;
	}
}PP[55];
LL ans;

void solve(LL l, LL r) {
	int tot = 0;
	LL Y[55];
	for(int i = 1; i <= n; i++)
		if(PP[i].x >= l && PP[i].x <= r)
			Y[++tot] = PP[i].y;
	sort(Y + 1, Y + tot + 1);
	if(tot < k) return;
	for(int i = 1; i <= tot - k + 1; i++) {
		ans = min(ans, (r - l) * (Y[i + k - 1] - Y[i]));
	}
}

int main()
{
	while(scanf("%d %d", &n, &k) != EOF)
	{
		ans = INF;
		for(int i = 1; i <= n; i++)
			scanf("%lld %lld", &PP[i].x, &PP[i].y);
		sort(PP + 1, PP + n + 1);
		for(int i = 1; i <= n; i++) {
			for(int j = i; j <= n; j++) {
					solve(PP[i].x, PP[j].x);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

int n ; 
long long int a[3003];
long long int dp[3003][3003];
long long int func(int st , int en,int t)
{
	if(t)
	{
		if(st==en)
		return(a[st]);
		
		if(dp[st][en]!=-1)
		return(dp[st][en]); 
		
		return(dp[st][en]= max(func(st+1,en,0)+a[st],func(st,en-1,0)+a[en]));
	}
	else
	{
		if(st==en)
		return(-a[st]);
		
		if(dp[st][en]!=-1)
		return(dp[st][en]); 
		
		return(dp[st][en]= min(func(st+1,en,1)-a[st],func(st,en-1,1)-a[en]));
	}
	
}

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);
cin>>n ; 
for(int i = 0; i<n ; i++)
cin>>a[i];
memset(dp,-1,sizeof(dp));
cout<<func(0,n-1,1);
return(0);
}


Measured memory_bytes: 70912
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int dp[2010][2010], sum[2010][2010];

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

  int N, M, S[2000], T[2000]; cin >> N >> M;
  REP(i, N) cin >> S[i];
  REP(i, M) cin >> T[i];
  
  REP(i, N) REP(j, M){
    if(S[i] == T[j]) dp[i+1][j+1] = (sum[i][j] + 1) % MOD;
    else dp[i+1][j+1] = 0;
    sum[i+1][j+1] = (dp[i+1][j+1] + sum[i][j+1] + sum[i+1][j] + MOD - sum[i][j]) % MOD;
  }
  int ans = 1;
  REP(i, N+1) REP(j, M+1){
    ans += dp[i][j]; ans %= MOD;
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin>>n;
  vector<ll> deg(n);
  vector<pll> a(n-1);
  vector<vector<ll>> adj(n);
  rep(i,n-1){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    deg[u]++;deg[v]++;
    if(u>v)swap(u,v);
    a[i]=pll(u,v);
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }

  ll k = *max_element(deg.begin(),deg.end());
  ll sv=-1;
  rep(i,n)if(deg[i]==k)sv=i;
  
  queue<pll> que;
  que.emplace(sv,-1);
  vector<bool> seen(n);
  map<pll,ll> color;
  while(!que.empty()){
    ll v,c;
    tie(v,c) = que.front();
    que.pop();
    if(seen[v])continue;
    seen[v]=1;
    ll col=1;
    for(auto const& nv:adj[v]){
      if(seen[nv])continue;
      if(col==c)col++;
      color[pll(min(v,nv),max(v,nv))]=col;
      que.emplace(nv,col);
      col++;
    }
  }

  cout<<k<<endl;
  for(auto const& key:a){
    cout<<color[key]<<"\n";
  }

}

Measured memory_bytes: 15232
#include <cmath>
#include <iostream>
#include <cstdio>
#include <ctype.h>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
	int num[5];
	
	for (int i=0; i<5; i++)
	{
		cin >> num[i];
	}
	
	sort(num, num+5);
	
	for (int i=4; i>=0; i--)
	{
		if (i != 0)
		{
			cout << num[i] << " ";
		} else {
			cout << num[i] << endl;
		}
	}
}

Measured memory_bytes: 1176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int mochis[] = new int[n];
		for (int i = 0; i < n; i++) {
			mochis[i] = sc.nextInt();
		}
		Arrays.sort(mochis);
		int count = 0;
		int nowHaba = 0;
		for (int i = 0; i < n; i++) {
			if (nowHaba < mochis[i]) {
				nowHaba = mochis[i];
				count++;
			}
		}
		System.out.println(count);
	}

}


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

int main(){
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
       }
     return 0;
    }

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
	int W, H;
	for (int a = 0;; a++) {
		cin >> H >> W;
		if (W == 0 && H == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int a[10101][1010], d[1010][1010];
int dy[] = {-1, 0, 0, 1}, dx[] = {0, -1, 1, 0};
signed main(){
  int h, w;cin >> h >> w;
  rep(i,h){
    string str;cin >> str;
    rep(j,w)a[i+1][j+1] = (str[j] == '#');
  }
  rep(i,1010)rep(j,1010)d[i][j] = INF;
  
  queue<PP> q;
  rrep(i,h)rrep(j,w)if(a[i][j] == 1){
    q.push(PP(0, P(i, j)) );
    d[i][j] = 0;
  }
  
  while(!q.empty()){
    PP p = q.front();q.pop();
    int y = p.se.fi, x = p.se.se, dis = p.fi;
    rep(i,4){
      int xx = x+dx[i], yy = y+dy[i];
      if(xx < 1 or w < xx or yy < 1 or h < yy or a[yy][xx])continue;
      if(dis+1 < d[yy][xx]){
        q.push(PP(dis+1, P(yy, xx)));
        d[yy][xx] = dis+1;
      }
    }
  }
  
  int ans = 0;
  rrep(i,h)rrep(j,w)ans = max(ans, d[i][j]);
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 40756
#include<stdio.h>

int main(void){
  int W,H,x,y,r;
  int flg=0;

  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);

  if( r<=x && x<=(W-r)){
    if(r<=y && y<=(H-r)){
      flg = 1;
    }
  }

  if(flg==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

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

int main() {
	int n; CI n;
	VI a(n); CI a;

	ll ans = a[0];
	REP(i, n) {
		ans = gcd(ans, a[i]);
	}
	CO ans EN;
}


Measured memory_bytes: 640
int n,a,b,M[1<<20]={1},i,k;
main(){
    scanf("%d%d%d",&n,&a,&b);
    if(n>1L*a*b||n<a+b-1) puts("-1");
    else{
        int N=b,C=n;
        while(1){
            for(i=0;i<b;++i) {
                if(a==C){
                    for(k=0;k<=n;++k) if(!M[k]) printf("%d ",k);
                    exit(0);
                }
                C--;printf("%d ",N-i);M[N-i]=1;
            }
            a--;
            N=n<N+b?n:N+b;
        }
    }
}


Measured memory_bytes: 2944
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

// infinity の初期値
#define INF 1e+9
// 最大頂点数
#define MAX_V 500

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<(int)G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    const int DIST = 2;
    int ans;
    while(true){
        ans = 0;
        cin >> V;
        int E;
        cin >> E;
        if(V == 0 && E == 0){
            break;
        }
        for (int i=0; i<E; ++i) {
            int v1, v2;
            cin >> v1 >> v2;
            edge e1 = {v2-1, 1};
            edge e2 = {v1-1, 1};
            G[v1-1].push_back(e1);
            G[v2-1].push_back(e2);
        }
        dijkstra(0);
        for (int i=1; i<V; ++i) {
            if(d[i] <= DIST){
                ans++;
            }
        }
        cout << ans << endl;
        for (int i=0; i<V; ++i) {
            G[i].clear();
        }
    }
}


Measured memory_bytes: 3288
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: u64, b: u64);
    let mut ans: String = "".to_string();
    if a > b {
        for i in 0..a {
            ans.push(std::char::from_digit(b as u32, 10).unwrap());
        }
    } else {
        for i in 0..b {
            ans.push(std::char::from_digit(a as u32, 10).unwrap());
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2204
#include<bits/stdc++.h>
typedef unsigned long long int ull;
using namespace std;
int main()
{
    ull h,v;
    cin>>h>>v;
    if(h==1|v==1)
    {
        cout<<1;
    }
    else
    {
        cout<<(ull)((h*v+1)/2);
    }

    return 0;
}


Measured memory_bytes: 256
N,P = map(int,input().split())
A = list(map(int,input().split()))

tmp = -1
for i in range(N):
    if A[i] % 2 != 0:
        tmp = i
        break

if tmp == -1:
    if P == 0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] ai;
		ai = new int[n];

		for (int i = 0; i < n; i++) {
			ai[i] = scan.nextInt();
		}

		//??????1???????????????????¬???????(" " + ai[j])
		System.out.print(ai[n - 1]);
		for (int j = n - 2; j >= 0; j--) {
			System.out.print(" " + ai[j]);
		}
		//????????????
		System.out.println();
	}

}

Measured memory_bytes: 26092
import sys
input = sys.stdin.readline

def solve():
    N, T = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]

    items.sort()

    capW = T-1
    dp = [0] * (capW+1)
    ans = 0
    for wi, vi in items:
        ans = max(ans, dp[-1]+vi)
        for w in reversed(range(wi, capW+1)):
            v0 = dp[w-wi] + vi
            if v0 > dp[w]:
                dp[w] = v0

    print(ans)


solve()


Measured memory_bytes: 3444
/*
    dp[v][i] - minimum weight from weights[i:n]
    dp[v][i] = min(dp[v][i+1],weights[i] + dp[v-values[i]][i+1])
    weights[3, 4, 5]
    values[30, 50, 60]
       0   1   2  
    0  0   0   0        
    1  
    2
    3
    4
    .
    .
    180
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,c;
int weights[101];
int values[101];

int32_t main()
{
    cin >> n >> c;
    int vmax =0;
    for(int i=0;i<n;++i)
    {
        cin >> weights[i] >> values[i];
        vmax = max(vmax,values[i]);
    }
    int v_max = n*vmax;
    int dp[v_max+1][n+1];
    int ans = INT_MAX;
    for(int i=0;i<=v_max;++i)
    {
        for(int j=n;j>=0;--j)
        {
            if(i==0) 
            {
                dp[i][j] = 0;
                continue;
            }
            if(j==n)
            {
                dp[i][j] = INT_MAX;
                continue;
            }
            
            if(values[j]>i) dp[i][j] = dp[i][j+1];
            else
            {
                dp[i][j] = min(dp[i][j+1],weights[j]+dp[i-values[j]][j+1]);
            }
            
        }
    }
    // for(int i=0;i<v_max;++i)
    // {
    //     for(int j=0;j<n;++j)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    for(int i=v_max;i>=0;--i)
    {
        if(dp[i][0] <=c)
        {
            cout << i << endl;
            return 0;
        } 
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 82516
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

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

signed main(){
	int n;
	cin>>n;
	int sum=0,a=0,b=0,c=0;
	r(i,n){
		string s;
		cin>>s;
		r(j,s.size()-1){
			if(s[j]=='A'&&s[j+1]=='B')sum++;
		}
		if(s[s.size()-1]=='A' && s[0]=='B')c++;
		else if(s[0]=='B')b++;
		else if(s[s.size()-1]=='A')a++;
	}

	int x=c-1;
	x=max(x,0LL);
	if(c&&b)x++,b--;
	if(c&&a)x++,a--;
	x+=max(0LL,min(a,b));
	cout<<sum+x<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
ll a[N];
main() {
  file("threesum");
  ios;
  cin >> n;
  fo(i, 1, n, 1) cin >> a[i];
  sort(a + 1, a + n + 1);
  ll cur = 1;
  ll Mx = 1e18 + 1;
  if (a[1] == 0) return !(cout << 0);
  fo(i, 1, n, 1) {
    ll mx = ((Mx / cur));
    if (a[i] > mx) return !(cout << -1);
    cur *= a[i];
  }
  cout << cur;
  return 0;
}
/**

*/


Measured memory_bytes: 4412
// atcoder/abc091/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  string s;
  while (cin >> n) {
    map<string, int> cnt;
    for (int i = 0; i < n; ++i) {
      cin >> s;
      ++cnt[s];
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> s;
      --cnt[s];
    }
    int mx = 0;
    each (i, cnt) setmax(mx, i.second);
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ans;
	ans=a*a+b*b-2*a*b*cos(2*M_PI*((h+m/60)/12-m/60));
	ans=sqrt(ans);
	printf("%.101f",ans);
}

Measured memory_bytes: 4168
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt()
	K := readInt()
	p := make([]Pair, N)
	for i := range p {
		p[i].a = readInt()
		p[i].b = readInt()
	}
	sort.Sort(PairSlice(p))
	i := 0
	j := 0
	for ; i < N && j+p[i].b < K; i++ {
		j += p[i].b
	}
	println(p[i].a)
}

type Pair struct {
	a, b int
}

type PairSlice []Pair

func (pq PairSlice) Len() int {
	return len(pq)
}

func (pq PairSlice) Less(i, j int) bool {
	return pq[i].a < pq[j].a
}

func (pq PairSlice) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}


Measured memory_bytes: 3840
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))

A.sort()

required = sum(A)
# 飴が余るか足りないか
if required == x:
    ans = N
elif required < x:  # 雨の数は足りている
    ans = N - 1
else:  # 飴が足りていない
    sm = 0
    ans = 0
    for ai in A:
        sm += ai
        if sm <= x:
            ans += 1
        else:
            break

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int N;
  float M,L,S,K;
  scanf("%d",&N);

if(N%2==0){
  M=N/2;
  S=M/N;
  printf("%6f",S);
}
else{
  L=(N+1)/2;
  K=L/N;
  printf("%6f",K);
}
return 0;
}
  
  

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

using namespace std;
#define IOS                 \
    cin.sync_with_stdio(0); \
    cin.tie(0);             \
    cout.tie(0);

using ll = long long;
using ld = long double;

#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
const int inf = 1e9;
const int hax = 25;
char s[hax][hax];

int h, w;
map<pii, int> d;
// map<pii, pii>p;
//map<pii, bool> u;

bool isValid(int x, int y)
{
    return ((x >= 1 && x <= h && y >= 1 && y <= w) && (s[x][y] != '#'));
}

int ans = INT_MIN;
void djikstra(int x, int y)
{
    d.clear();
    // u.clear();
    // p.clear();
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            //u[{i,j}] = false;
            d[{i, j}] = inf;
            // p[{i,j}] = {-1, -1};
        }
    }

    d[{x, y}] = 0;

    set<pair<int, pii>> q;
    q.insert({0, {x, y}});

    while (!q.empty())
    {
        pii v = q.begin()->second;
        q.erase(q.begin());

          int i = v.first, j = v.second;

    if (isValid(i, j - 1))
        if (d[{i, j - 1}] > d[v] + 1)
        {
            q.erase({d[{i,j-1}],{i,j-1}});
            d.erase(d.find({i, j - 1}));
            d[{i, j - 1}] = d[v] + 1;
            q.insert({d[{i,j-1}], {i,j-1}});
        }

    if (isValid(i, j + 1))
        if (d[{i, j + 1}] > d[v] + 1)
        {
            q.erase({d[{i,j+1}],{i,j+1}});
            d.erase(d.find({i, j + 1}));
            d[{i, j + 1}] = d[v] + 1;
            q.insert({d[{i,j+1}], {i,j+1}});
        }

    if (isValid(i - 1, j))
        if (d[{i - 1, j}] > d[v] + 1)
        {
            q.erase({d[{i-1,j}],{i-1,j}});
            d.erase(d.find({i - 1, j}));
            d[{i - 1, j}] = d[v] + 1;
            q.insert({d[{i-1,j}], {i-1,j}});
        }
    if (isValid(i + 1, j))
        if (d[{i + 1, j}] > d[v] + 1)
        {
            q.erase({d[{i+1,j}],{i+1,j}});
            d.erase(d.find({i + 1, j}));
            d[{i + 1, j}] = d[v] + 1;
            q.insert({d[{i+1,j}], {i+1,j}});
        }

    }

  
    //cout << "(" << x << "," << y << ") : \n";

    for (auto i : d)
    {
        //cout << "(" << i.first.first << "," << i.first.second << ") = " << i.second << "\n";
        if (i.second != inf)
            ans = max(ans, i.second);
    }
}

int main()
{
    IOS

            cin >>
        h >> w;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> s[i][j];
        }
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (isValid(i, j))
            {
                //cout << "(" << i << "," << j << ")\n";
                djikstra(i, j);
            }
        }
    }

    cout << ans << "\n";
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int N,K;
    cin>>N>>K;
    Vi A(N);
    REP(i,N) cin>>A[i];

    cout<<ceil(double(N-1)/double(K-1))<<endl;

    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll solve(ll n, ll d)
{
    ll a = d;
    ll s = 0;
    REP(i, n - 1)
    {
        s += 127;
        a ^= 127;
    }
    return s + a;
}

int main()
{
    ll T;
    cin >> T;
    REP(i, T)
    {
        ll n, d;
        cin >> n >> d;
        cout << solve(n, d) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	bool increasing = true;
	for(int i = 1; i < n; ++i){
		if(a[i] <= a[i - 1]){ increasing = false; }
	}
	if(increasing){
		cout << 1 << endl;
		return 0;
	}
	int lo = 2, hi = n;
	while(lo < hi){
		const int mid = lo + (hi - lo) / 2;
		bool accept = true;
		map<int, int> nonzero;
		for(int i = 1; accept && i < n; ++i){
			if(a[i] > a[i - 1]){ continue; }
			nonzero.erase(nonzero.lower_bound(a[i]), nonzero.end());
			int index = a[i] - 1;
			auto it = nonzero.end();
			while(index >= 0){
				if(it == nonzero.begin()){
					nonzero.emplace(index, 1);
					break;
				}
				--it;
				if(it->first < index){
					nonzero.emplace(index, 1);
					break;
				}
				if(it->second + 1 < mid){
					it->second += 1;
					break;
				}
				it = nonzero.erase(it);
				--index;
			}
			if(index < 0){
				accept = false;
			}
		}
		if(accept){
			hi = mid;
		}else{
			lo = mid + 1;
		}
	}
	cout << lo << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    vector<vector<int>> groups = {
      {1,3,5,7,8,10,12},
      {4,6,9,11},
      {2},
    };
    
    int x, y;
    cin >> x >> y;
    
    for (vector<int> group : groups) {
        bool flag_x = false, flag_y = false;
        for (int p : group) {
            if (p == x) {
                flag_x = true;
            }
            if (p == y) {
                flag_y = true;
            }
        }
        if (flag_x && flag_y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

signed main() {
	int n, k; cin >> n >> k;
	int r, s, p; cin >> r >> s >> p;
	string t; cin >> t;
	vector<char> taka(n, ' ');
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i < k) {
			if (t[i] == 'r') {
				ans += p;
				taka[i] = 'p';
			}
			else if (t[i] == 's') {
				ans += r;
				taka[i] = 'r';
			}
			else {
				ans += s;
				taka[i] = 's';
			}
		}
		else {
			if (t[i] == 'r' && taka[i - k] != 'p') {
				ans += p;
				taka[i] = 'p';
			}
			else if (t[i] == 's' && taka[i - k] != 'r') {
				ans += r;
				taka[i] = 'r';
			}
			else if (t[i] == 'p' && taka[i - k] != 's'){
				ans += s;
				taka[i] = 's';
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
sort(a.begin(),a.end());
vector<ll> sum;
sum.push_back(0);
rep(i, n)
{
  sum.push_back(a[i] + sum[i]);
}
rep(i,n-1){
  if(sum[n-i-1]*2>=a[n-i-1])ans++;
  else break;
}
cout << ans+1 << endl;
return 0;
}

Measured memory_bytes: 2168
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:56:20 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B = na()

C = int(str(A) + str(B))

i = 1
flag = False
while i * i <= C:
    if i * i == C:
        flag = True
        break
    i += 1

print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    N %= 10;
    if(N == 3) cout << "bon" << endl;
    else if(N == 1||N == 6|| N == 8|| N == 0) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 3005;
vector < vector < int > > DP(N + 5, vector < int > (N + 5, 0));
char s[N + 5], t[N + 5];
string ans;
void afis(int x, int y) {
  if (x == 0 || y == 0) {
    return;
  }
  if (s[x] == t[y]) {
    ans += s[x];
    afis(x - 1, y - 1);
    return;
  }
  if (DP[x - 1][y] > DP[x][y - 1]) {
    afis(x - 1, y);
  }
  else {
    afis(x, y - 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  string a, b; cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    s[i + 1] = a[i];
  }
  for (int i = 0; i < b.size(); i++) {
    t[i + 1] = b[i];
  }
  for (int i = 1; i <= a.size(); i++) {
    for (int j = 1; j <= b.size(); j++) {
      if (s[i] == t[j]) {
        DP[i][j] = max(DP[i][j], DP[i - 1][j - 1] + 1);
      }
      DP[i][j] = max(DP[i][j], DP[i - 1][j]);
      DP[i][j] = max(DP[i][j], DP[i][j - 1]);
    }
  }
  afis(a.size(), b.size());
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

vector<lli> fac;

lli power(lli x, lli y) {
    // log y complexity
    // return (x^y) % MOD
    lli ans = 1;
    x = x % MOD;
    while (y > 0) {
        if (y & 1) {
            ans *= x;
            ans %= MOD;
        }
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return ans;
}

lli inverseMod(lli a) {
    return power(a, MOD - 2);
}

lli nCr(lli n, lli r) {
    if (r > n) {
        return 0;
    }
    lli ans = fac[n];
    lli val = (inverseMod(fac[n - r]) * inverseMod(fac[r])) % MOD;
    ans *= val;
    ans %= MOD;
    return ans;
}

void solve() {
    fac.resize(2e6 + 2, 1);
    for (lli i = 1; i <= 2e6 + 1; i++) {
        fac[i] = (fac[i - 1] * i) % MOD;
    }

    lli n, a, k;
    cin >> k;
    string st;
    cin >> st;
    n = st.length();
    lli N = n + k;

    lli ans = 0;
    for (lli i = n; i <= N; i++) {
        lli val = (nCr(N, i) * (power(25, N - i))) % MOD;
        ans += val;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 19876
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;

    int A[N];
    int B[N];
    int A_sum = 0;
    int B_sum = 0;

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

    for (int i = 0; i < N; i++) {
        cin >> B[i];
        B_sum += B[i];
    }

    if (A_sum < B_sum) {
        cout << -1 << endl;
        return 0;
    }

    int ret = 0;
    int shortage = 0;
    vector<int> resource;

    for (int i = 0; i < N; i++) {
        if (A[i] >= B[i]) {
            resource.push_back(A[i] - B[i]);
        } else {
            ret++;
            shortage += B[i] - A[i];
        }
    }

    sort(resource.begin(), resource.end(), greater<>());

    for (int r : resource) {
        if (shortage <= 0) break;

        shortage -= r;
        ret++;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 2808
#include <iostream>
#include <string>
#include <bitset>
  
class Baseball{
    u_int score, out_count;
    std::bitset<4> runners;
public:
    Baseball() : score(), out_count(){} //initializer list
    ~Baseball() = default;
    void hit();
    void homerun();
    void out() {++out_count;}
    u_int get_score() {return score;}
    u_int get_out() {return out_count;}
};
 
void Baseball::hit(){
    runners <<= 1; //shift
	runners.set(0); //set runner
    if(runners.test(3)){
        ++score;
        runners.reset(3);
    }
}
 
void Baseball::homerun(){
    score += runners.count() + 1;
    runners.reset();
}
 
int main(){
    u_int inning;
    std::cin >> inning;
    
    for(u_int i = 0; i < inning; ++i){
        Baseball game;
        while(game.get_out() != 3){
            std::string event;
            std::cin >> event;
            
            // check event
            if(event == "HIT"){
                game.hit();
            }else if(event == "HOMERUN"){
                game.homerun();
            }else if(event == "OUT"){
                game.out();
            }
        }
        std::cout << game.get_score() << std::endl; //show score
    }
    
    return 0;
}

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

int main(){
	int N,K;
	char *S; 
	scanf("%d %d",&N,&K);
	S=(char*)malloc(sizeof(char)*(N+1));
	scanf("%s",S);
	if(S[K-1]=='A'){
		S[K-1]='a';
	}
	else if(S[K-1]=='B'){
		S[K-1]='b';
	}
	else{
		S[K-1]='c';
	}
	printf("%s\n",S);
	return 0;
}


Measured memory_bytes: 128
### subroutines

def lower_bound(arr, key, i0 = 0, i1 = arr.length)
  lb = i0 - 1
  ub = i1

  while lb + 1 < ub
    m = (lb + ub) / 2
    if arr[m] <= key
      lb = m
    else
      ub = m
    end
  end
  lb
end

def div_three?(k)
  #puts "k=#{k}"
  for i in (0...$n)
    imax = i + $n
    #puts " i=#{i}, imax=#{imax}"
    i0 = lower_bound($asums, k + $asums[i] - 1, i, imax) + 1
    #puts "  i0=#{i0}"
    if i0 < imax
      i1 = lower_bound($asums, k + $asums[i0] - 1, i0, imax) + 1
      #puts "  i1=#{i1}"
      if i1 < imax &&
          $asums[imax] - $asums[i1] >= k
        return true
      end
    end
  end

  false
end

### main

$n = gets.strip.to_i

$ais = $n.times.map{gets.strip.to_i}
$ais += $ais
#p $ais

$asums = [0]
(1..(2 * $n)).each{|i| $asums[i] = $asums[i - 1] + $ais[i - 1]}
#p $asums

k0 = 0
k1 = $asums[$n] / 3

while k0 + 1 < k1
  km = (k0 + k1) / 2
  if div_three?(km)
    k0 = km
  else
    k1 = km
  end
end

puts k0

Measured memory_bytes: 10172
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string S;
  cin >> S;
  ll K;
  cin >> K;
  for (ll i = 0; i < K; ++i) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}


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

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

	ll N, M;
	cin >> N >> M;

	ll ok = 0, ng = 1e18;
	while(abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		ll crem = M - mid * 2;
		ll ssum = N + crem / 2;
		if(crem >= 0 && ssum >= mid) ok = mid;
		else ng = mid;
	}

	cout << ok << endl;
}

Measured memory_bytes: 256