akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n;
vector <vector <int> > graph;
map <int, int> p;
vector <bool> used;
void dfs(int v){
    used[v] = true;
    for (auto to: graph[v]){
        if (!used[to]){
            p[to] = v;
            dfs(to);
        }
    }
}
int dfs_count(int v){
    used[v] = true;
    int now = 1;
    for (auto x: graph[v]){
        if (!used[x]){
            now += dfs_count(x);
        }
    }
    return now;
}
int main(){
    cin >> n;
    graph.resize(n);
    used.resize(n, false);
    for (int i = 0; i < n - 1; ++i){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector <int> path;
    path.push_back(n - 1);
    dfs(0);
    while (path[path.size() - 1] != 0){
        int x = p[path[path.size() - 1]];
        path.push_back(x);
    }
    reverse(path.begin(), path.end());
    int Fennec = 0;
    int Snuke = 0;
    for (int i = 0; i < n; ++i){
        used[i] = false;
    }
    used[0] = true;
    for (auto x: graph[0]){
        if (x != path[1]){
            Fennec += dfs_count(x);
        }
    }
    used[n - 1] = true;
    for (auto x: graph[n - 1]){
        if (x != path[path.size() - 2]){
            Snuke += dfs_count(x);
        }
    }
    for (int i = 1; i < path.size() - 1; ++i){
        if (i <= (path.size() - 2) / 2 + path.size() % 2){
            Fennec++;
            used[path[i]] = true;
            for (auto x: graph[path[i]]){
                if (x != path[i + 1] && x != path[i - 1]){
                    Fennec += dfs_count(x);
                }
            }
        }
        else{
            Snuke++;
            used[path[i]] = true;
            for (auto x: graph[path[i]]){
                if (x != path[i + 1] && x != path[i - 1]){
                    Snuke += dfs_count(x);
                }
            }
        }
    }
    if (Fennec - Snuke >= 1){
        cout << "Fennec" << "\n";
    }
    else{
        cout << "Snuke" << "\n"; 
    }
    return 0;
}

Measured memory_bytes: 18816
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
Sd = defaultdict(int)
for i in S:
    Sd[i] += 1
Sd = sorted(Sd.items(), key = lambda x: x[1], reverse=True)

maxv = Sd[0][1]
ans = []
for i, j in Sd:
    if maxv != j:
        break
    else:
        ans.append(i)

ans = sorted(ans)
for a in ans:
    print(a)

Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pii pair< int,int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define mxn 2000010
#define sqr 700
#define mx 100000
int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
   ll n;
   cin>>n;
   ll x=0,y=0,t=0,flg=0;
   while(n--)
   {
    ll tt,xx,yy;
    cin>>tt>>xx>>yy;
    if(flg==1)
        continue;
    ll zz = abs(xx-x)+abs(yy-y);
    ll op=tt-t;
    if(op<zz or (op-zz)%2==1)
    {
        flg=1;
    }
    x=xx,y=yy,t=tt;
   }
   cout<< ( flg ? "No" : "Yes" );
     return 0;
    }

Measured memory_bytes: 256
from collections import deque


def main():
    n, m = [int(x) for x in input().split()]
    corridors = [list() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        corridors[a].append(b)
        corridors[b].append(a)

    qu = deque()
    # dist = [-1] * n
    ans = [None] * n
    # initialize
    qu.append(0)
    ans[0] = 0
    # search
    while len(qu):
        v = qu.popleft()
        for new in corridors[v]:
            if ans[new] is not None:
                continue
            # dist[new] = dist[v] + 1
            ans[new] = v + 1
            qu.append(new)

    # for i, x in enumerate(ans):
    #     if i == 0:
    #         continue
    #     print('room', i+1, ':', x)

    print('Yes')
    for x in ans[1:]:
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37984
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const int INF = numeric_limits<T>::max();
	vector<T> cost(V, INF);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(st, cost[st]);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				p_que.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min costance to vertex idx from st
}

int main() {

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

	int H, W;
	cin >> H >> W;

	vector<vector<Edge<int>>> c(10);
	int tmp;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> tmp;
			c[j].emplace_back(i, tmp); // あえて逆に入れる（stまでの最小がほしいので）
		}
	}

	auto d = Dijkstra(c, 1);

	lint ans = 0;
	for (int i = 0; i < H*W; i++) {
		cin >> tmp;
		if(tmp != -1) ans += d[tmp];
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int x, n;
	cin >> x >> n;
	int a[n+5];
	int val[205]={0};
	rep(i,n){
		cin >> a[i];
		val[a[i]] = 1;
	}
	sort(a,a+n);
	int v1 = -100, v2 = -100;
	for(int i = x; i >= -1; i--){
		if(val[i] == 0){
			v1 = i;
			break;
		}
	}
	for(int i = x; i <= 101; i++){
		if(val[i] == 0){
			v2 = i;
			break;
		}
	}
	if(abs(x-v2) < abs(x-v1)){
		cout << v2 << endl;
	}else if(abs(x-v1) < abs(x-v2)){
		cout << v1 << endl;
	}else{
		cout << v1 << endl;
	}
	return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	//	srand(time(NULL));
	int n; cin >> n;
	vector<int>a(n + 1), in(n), mx(n + 1, 1);
	for(int i = 0; i < n; i++){
		int tmp; cin >> tmp;
		a[tmp] = i;
		in[i] = tmp;
	}
	mx[1] = 1;
	for(int i = 2; i <= n; i++)
		if(a[i] > a[i - 1])
			mx[i] = mx[i - 1] + 1;
	int res = *max_element(mx.begin(), mx.end());
	cout << n - res << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (ll i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<ll, ll>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	ll n,x,y; cin>>n>>x>>y;
	vii(dp,n+1,n+1,-1);
	lp(i,1,n+1){
		lp(j,1,n+1){
			dp[i][j]=abs(i-j);
		}
	}
	lp(i,1,n+1){
		lp(j,1,n+1){
			dp[i][j]=min(dp[i][j],dp[i][x]+1+dp[y][j]);
		}
	}
	vl cnt(n+1);
	lp(i,1,n+1){
		lp(j,i,n+1)
			cnt[dp[i][j]]++;
	}
	lp(i,1,n)
		cout<<cnt[i]<<"\n";
}

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

const int MAX = 20202;
const int INF = 1e9;
int h, n, a[1010], b[1010];
int dp[1010][MAX + 1];

int main()
{
    cin >> h >> n;
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, n) rep(j, MAX + 1) dp[i][j] = INF;

    dp[0][0] = 0;
    for(int i = a[0]; i <= MAX; i += a[0])
    {
        if(dp[0][i - a[0]] != INF)
        {
            dp[0][i] = dp[0][i - a[0]] + b[0];
        }
    }

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j <= MAX; j ++)
        {
            if(dp[i - 1][j] != INF)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
            if(j >= a[i] && dp[i][j - a[i]] != INF)
            {
                dp[i][j] = min(dp[i][j], dp[i][j - a[i]] + b[i]);
            }
        }
    }
    
    int res = INF;
    for(int i = h; i <= MAX; i++)
    {
        res = min(res, dp[n - 1][i]);
    }
    cout << res << endl;


    return 0;
}

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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;


void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

bool compare(int &a, int &b){
    return a>b;
}

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n))+1;
}

ull pow (ll a, ll b);




/*


*/

ll BN ();
map<int ,int > mp;
int main()
{
    JULEE_DO_THE_THING;
    //freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    int arr[n];
    for(int i=0; i<n; i++){
    	cin>>arr[i];
    }
    for(int i=0; i<n; i++){
    	if(!isOdd(arr[i])){
    		if(arr[i]%3!=0 && arr[i]%5!=0)return cout<<"DENIED", 0;
    	}
    }
    cout<<"APPROVED";
    return 0;
}


ll BN (){
    ll low = 0;
    ll up = 0;
    ll ans = 0;
    while(low<=up){
        ll mid = ((low+ up)/2);
        if(mid) {
            ans = mid;
            low = mid+1;
        }else up = mid-1;
    }
    return ans;
}


ull pow (ll a, ll b){
    ull res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<string> vec;

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  vec.resize(h);
  rep(i, h) cin >> vec[i];
  int ans = 0;
  rep(rc, 1 << h) {
    rep(cc, 1 << w) {
      int tmp = 0;
      rep(i, h) {
        rep(j, w) {
          if (rc >> i & 1) {
            if (cc >> j & 1) {
               if (vec[i][j] == '#') tmp++;
            }
          }          
        }
      }
      if (tmp == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,A,B;cin >> N >> A >> B;
    if(N==2){
        cout<<"Borys"<<endl;
        return 0;
    }
    if((B-A)%2 != 0){
        cout<<"Borys"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
    return 0;
}


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


int main(){   
    int n, m; ll k;
    cin >> n >> m >> k;
    vector<int> a(n) , b(m);
    rep(i ,n) cin >> a[i];
    rep(i, m) cin >> b[i];
    
    vector<long long> b2(m);
    b2[0] = b[0];
    for(int i=1;i<m;++i){
        b2[i] = b2[i - 1] + b[i];
    }
    int sum = 0, ans = 0;
    for(int i = 0; i <= n; i++){
        if(k - sum < 0) break;
        int count = upper_bound(b2.begin(), b2.end(), k-sum) - b2.begin();
        if(ans < i + count) ans = i + count; 
        
        if(i < n) sum += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	int X;
	int Y;
	cin >> X >> Y;
	int two_Leg = X * 2;
	int four_Leg = X * 4;
	
	if(Y % 2 != 0){
		std::cout << "No" << endl; 	
		return 0;
	}
	
	if(two_Leg <= Y && four_Leg >= Y){
		std::cout << "Yes" << endl; 	
		return 0;
	}else{
		std::cout << "No" << endl; 	
		return 0;
	}
	
}


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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int cnt=0;
    if(s[0]=='R'){
        if(s[1]=='R'){
            if(s[2]=='R'){
                cout << 3 << "\n";
            }else{
                cout << 2 << "\n";
            }
        }else{
            if(s[2]=='R'){
                cout << 1 << "\n";
            }else{
                cout << 1 << "\n";
            }
        }
    }else{
        if(s[1]=='R'){
            if(s[2]=='R'){
                cout << 2 << "\n";
            }else{
                cout << 1 << "\n";
            }
        }else{
            if(s[2]=='R'){
                cout << 1 << "\n";
            }else{
                cout << 0 << "\n";
            }
        }
    }
}   




Measured memory_bytes: 3536
N=input()
li=list(map(int,input().split()))
check=0
count=0

while check==0:
    
    
    for i in range(len(li)):
        if li[i]%2==1:
            check=1
        else:
            li[i]=li[i]/2
    
    

    count+=1

print(count-1)


Measured memory_bytes: 2940
# cook your dish here
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
  
def lcm(a,b): 
    return (a*b) // gcd(a,b) 
  
n = int(input())
arr=input()
a=list(map(int,arr.split(' ')))
l = a[0]
ans = 0
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans = ans + l//a[i]
print(ans%1000000007)


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

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *d=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",d+i);
  int m;
  scanf("%d",&m);
  int *t=(int *)malloc(sizeof(int)*m);
  for(i=0;i<m;i++) scanf("%d",t+i);
  qsort(d,n,sizeof(int),cmp);
  qsort(t,m,sizeof(int),cmp);
  i=0;
  int j=0;
  while(i<n && j<m){
    while(i<n && d[i]<t[j]) i++;
    if(d[i]!=t[j]) break;
    i++;
    j++;
  }
  printf("%s\n",j==m?"YES":"NO");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> s(M),c(M);
    rep(i,M){
        cin >> s[i] >> c[i];
    }
    bool flg = true;
    for(int i=0;i<1000;i++){
        bool flg2 = true;
        string num;
        num = to_string(i);
        if(num.size()!=N) continue;
        for(int j=0;j<M;j++){
            if(s[j]-1>num.size()-1){
                flg2 = false;
                break;
            }else{
                if(num[s[j]-1]!=(c[j]+'0')){
                    flg2 = false;
                }
            }
        }
        if(flg2){
            cout << num << endl;
            return 0;
        } 
    }
    cout << -1 << endl;
    return 0;
}

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

#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 0 ; i <= VMAX ; i++)
    {
      C[i]=0;
    }

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&A[i+1]);
      C[A[i+1]]++;

    }

  for(i = 1 ; i <= VMAX ; i++)
    {
      C[i] = C[i] + C[i - 1];
    }

  for(j = 0 ; j <= n ; j++)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  for(i = 1 ; i <= n ; i++)
    {
      if(i > 1) printf(" ");

      printf("%d",B[i]);
    }
  printf("\n");

  return 0;
}



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

int main(){
  char s[4];
  cin >> s;
  int ans = 0;

  for(int i=0; i<4; i++){
    if(s[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    for (int i=0;i<k;i++) {
        if (i%2==0) {
            if (a%2==1) {a--;}
            b += a/2;
            a/=2;
        }
        else {
            if (b%2==1) {b--;}
            a += b/2;
            b/=2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

int N, M;
char inp[10];

int main() {
   scanf("%d%d", &N, &M);
   int cc = 0;
   for(int i = 0; i < N; i++) {
      scanf("%s", inp);
      cc += count(inp, inp + M, '#');
   }
   if(cc == N+M-1) printf("Possible\n");
   else printf("Impossible\n");
}


Measured memory_bytes: 256
import math

while True:
    N = int(input())
    if N == 0:
        break
    s = list(map(int, input().split()))
    mean_ = sum(s) / N
    std = 0
    for i in range(N):
        std += ((s[i] - mean_) ** 2)
    print(math.sqrt(std / N))


Measured memory_bytes: 5700
// Shift-JIS（シフトジス）

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

int N;
vector<long long> A(100000);

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

    long long S = 0;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < 0)
        {
            count++;
        }
        S += abs(A[i]);
    }

    long long minAbsA = 1000000000;
    for (int i = 0; i < N; i++)
    {
        if (minAbsA > abs(A[i]))
        {
            minAbsA = abs(A[i]);
        }
    }

    if (count % 2 == 0)
    {
        cout << S << endl;
    }
    else
    {
        cout << S - 2 * minAbsA << endl;
    }
}

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


int main() {
    long long n;
    cin >> n;
    string s[n];
    long long i;
    map<string,int> mp;
    bool ok = true;
    for(i=0;i<n;i++)
    {
        cin >> s[i];
        if(mp.find(s[i]) != mp.end())
        {
            ok = false;
            break;
        }
        if(i == 0)
            mp[s[i]]++;
        else
        {
            if(s[i][0] != s[i-1][s[i-1].length()-1])
            {
                ok = false;
                break;
            }
            mp[s[i]]++;
            
        }
    }
    cout <<(ok ? "Yes": "No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);


int main() {
  int n,a,b; cin >> n >> a >> b;
  int x = min(n*a,b);
  cout << x << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int pm[200005];
int dp[200005];
int ksn = 0;

signed main() {
    int n, k;
    vector<P> v;
    cin >> n >> k;

    rep(i, 0, k) {
        int l, r;
        cin >> l >> r;
        v.pb(P(l, r));
    }

    dp[0] = 1;

    rep(i, 0, n) {
        if(pm[i]) ksn += pm[i], ksn %= 998244353;
        if(ksn < 0) ksn += 998244353;
        dp[i] += ksn;
        rep(j, 0, v.size()) {
            P p = v[j];
            if(i + p.first < n) {
                pm[i + p.first] += dp[i];
                pm[i + p.first] %= 998244353;
            }

            if(i + p.second + 1 < n) {
                pm[i + p.second + 1] -= dp[i];
            }
        }
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 6728
#include <stdio.h>

int main(void)
{
    int x,i=0;
    int a[1024] = {0};
    while(~scanf("%d", &x)) {
        if(x != 0) {
            a[i++] = x;
        } else {
            printf("%d\n",a[--i]);
        }
    }

    return (0);
}

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

int main(){
	string s,t;
	cin >> s >> t;
	int n(s.size()), m(t.size());
	vector<vector<string>> dp(2, vector<string>(m+10));
	rep(i,n){
		rep(j,m){
			if(s[i] == t[j]){
				dp[1][j+1] = dp[0][j] + s[i];
			}else{
				if(dp[1][j].size() > dp[0][j+1].size()){
					dp[1][j+1] = dp[1][j];
				}else{
					dp[1][j+1] = dp[0][j+1];
				}
			}
		}
		dp[0] = dp[1];
	}
	cout << dp[1][m] << endl;
	return 0;
}

Measured memory_bytes: 16836
s = ['C']+list(input())
n = len(s)
res = 0
p = []

def f(p):
    if len(p) == 0:
        return 0
    cnt = 0
    ans = 0
    for e in p:
        if e == 'A':
            cnt += 1
        else:
            ans += cnt
    return ans

for i in range(1,n):
    if s[i] == 'A':
        p.append('A')
    elif s[i] == 'B':
        if s[i-1] == 'B' or (i+1<=n-1 and s[i+1] != 'C'):
            res += f(p)
            p = []
    else:
        if s[i-1] == 'B':
            p.append('B')
        else:
            res += f(p)
            p = []
res += f(p)
print(res)



Measured memory_bytes: 6308
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;

 int main()
 {
   int n;
   int arr[100000+5];
   while(cin>>n)
   {
     for(int i=0;i<n;i++) cin>>arr[i];
     sort(arr,arr+n);
     int cnt=1;
     int cur=arr[0];
     int result=0;
     for(int i=1;i<n;i++)
     {
       if((arr[i]-cur)==0) cnt++;
       else
       {
         if(cnt%2==1) result++;
         cur=arr[i];
         cnt=1;    
       }  
     }  
     if(cnt%2==1) result++;
     cout<<result<<endl;
   }
   return 0;    
 }
 
 

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
//1~200000の範囲
#define MYSTRINGMAX 200000 // 配列20万分取る
#define SIZE MYSTRINGMAX + 2 // MYSTRINGMAX+2した値をSIZEに入れたものを定義する SIZE = 200002

int main(void) {
	//[s]=[t]
	char s[SIZE], t[SIZE], c1, c2; // char s[200002],t[200002],c1,c2
	int flag = 0, i, j; // 判定するためのflag変数は0で宣言
	
	fgets(s, SIZE, stdin); // sの文字列を200002文字分標準入力できる。改行文字とEOS対策の為に＋2
	fgets(t, SIZE, stdin); // tの文字列を200002文字分標準入力できる。改行文字とEOS対策の為に＋2
	
	int length = strlen(s); // lengthに文字列の長さを返すstrlen関数を配列sにて判定する
	
	for (i = 0; i < length; i++) { // 文字列の長さ（length）分判定
		if (s[i] != t[i]) { // s[i]とt[j]が等しくない場合に操作開始
			c1 = s[i]; // c1にif文で引っかかった文字sを代入
			c2 = t[i]; // c2にif文で引っかかった文字tを代入
			for (j = 0; j < length; j++) { // 文字列の長さ（length）分判定 
				if (s[j] == c2 || s[j] == c1) { //s[j]とc2を比較し、s[j]とc1を比較してどちらかが等しければ以下を実行
					if (j < i) { //文字列を見ていき、変更し終わった部分を変えてしまう場合は以下の動作を実行
						flag = 1; 
						break;
					}
					if (s[j] == c1) { // 1つ上のインシデントのif文でどちらかが正しく、変更できているならs[j] == c1を判定し、正しければ以下を実行
						s[j] = c2; // s[j]の値と入っているc2の値を交換する
					}
					else { // それ以外のs[j] == c2パターンなら以下を実行
						s[j] = c1; 
					}
				}
			}
			if (flag == 1) { // flag1なら以下の動作
				printf("No\n");
				return 0;
			}
		}
		if (flag == 1) { // flag1なら以下の動作
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n"); // それ以外ならYesを実行
	return 0;
}


Measured memory_bytes: 512
n,x=map(int,input().split())
B=[1] #レベルiバーガーの厚さ
P=[1] #レベルiバーガーのパティの数
for i in range(n-1):
    B.append(B[-1]*2+3)
    P.append(P[-1]*2+1)
ans=0
for i in range(n):
    if x==1:
        break
    elif 1<x<B[n-i-1]+2:
        x-=1
    elif x==B[n-i-1]+2:
        ans+=P[n-i-1]+1
        break
    elif x>B[n-i-1]+2:
        ans+=P[n-i-1]+1
        x-=B[n-i-1]+2
    else:
        ans+=2*P[n-i-1]+1
        break
else:
    ans+=1
print(ans)

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int N;
	string S;

	cin >> N >> S;

	vector<int> nums1(N);
	vector<int> nums2(N);

	for (int i = 1; i < S.size(); i++)
	{
		if (S[i - 1] == 'W') nums1[i] = nums1[i - 1] + 1;
		else nums1[i] = nums1[i - 1];

		if (S[S.size() - i] == 'E') nums2[S.size() - i - 1] = nums2[S.size() - i] + 1;
		else nums2[S.size() - i - 1] = nums2[S.size() - i];

	}

	int min_ = inf;

	for (int i = 0; i < nums1.size(); i++)
	{
		min_ = min(min_, nums1[i] + nums2[i]);
	}
	cout << min_ << endl;
}


Measured memory_bytes: 3076
n = int(input())
x = list(map(int, input().split()))
x_ave = sum(x) // n
def moment(val):
    list_init = [0]*n
    for i in range(n):
        list_init[i] = (x[i] - val)**2
    return(sum(list_init))

print(min(moment(x_ave), moment(x_ave + 1)))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin>>n;
    
    int temp;
    for(int i=1; i<n+1; i*=2){
        temp=i;
    }
    
    cout<<temp<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();

            
            int count = 1;
            int pos = 0;
            for(int i = 0; i < N-1;i++){
                
                if(pos == 1 && A[i+1] < A[i]){
                    count++;
                    pos = 0;
                    continue;
                }
                if(pos == -1 && A[i+1] > A[i]){
                    count++;
                    pos = 0;
                    continue;
                }
                if(A[i+1] > A[i])
                    pos = 1;
                if(A[i+1] < A[i])
                    pos = -1;
                
            }
            System.out.println(count);
    }
}

Measured memory_bytes: 50196
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long x;
cin>>x;
// vector<int>rohan;
long long rohan=0;
while(x!=0){
	int count=x%10;
	if (count==9)
	{
		rohan=rohan*10+1;
		/* code */
	}
	else{

		rohan=rohan*10+9;
	}
	x=x/10;
}
int rahul=0;
while(rohan!=0){
	int count=rohan%10;
	rahul=rahul*10+count;
	rohan/=10;
}
cout<<rahul<<endl;

return 0;
}




Measured memory_bytes: 3596
d = '0123456789'
A,B = map(int, input().split())
S = input()
if S[A] != '-' or len(S) != A+B+1:
  print('No')
else:
  for i in S[:A]:
    if i not in d:
      print('No')
      exit()
  for i in S[A+1:]:
    if i not in d:
      print('No')
      exit()
  print('Yes')


Measured memory_bytes: 3060
def main():
    number_of_person = int(input())
    array = [int(x) for x in input().split()]
    pre_h = 0
    step_total = 0
    for height in array:
        step_total += max(pre_h - height, 0)
        pre_h = max(height, pre_h)
    return step_total


if __name__ == '__main__':
    ans = main()
    print(ans)


Measured memory_bytes: 32012
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    vl power(n + 1);
    power[0] = 1;
    rep (i, n) {
        power[i + 1] = power[i] * 3 % MOD;
    }

    ll x = 0, y = 0, z = 0;
    ll ques = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            x += power[ques];
        }
        else if (s[i] == 'B') {
            y += x;
        }
        else if (s[i] == 'C') {
            z += y;
        }
        else {
            ll nx, ny, nz;
            nx = power[ques] + 3 * x;
            ny = x + 3 * y;
            nz = y + 3 * z;
            x = nx;
            y = ny;
            z = nz;
            ques++;
        }
        x %= MOD;
        y %= MOD;
        z %= MOD;

        // cout << x << " " << y << " " << z << endl;
    }
    cout << z << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

vector<char> ans;
char s[200005][2];

int main()
{
    int n;
    cin >> n;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    for (int i = 0; i < n; i++)
    {
        string t;
        cin >> t;
        for (int j = 0; j < t.size(); j++)
            s[i][j] = t[j];
    }

    for (int i = 0; i < 2; i++)
        s[n][i] = s[n - 1][i];

    for (int i = 0; i < n; i++)
    {
        // cout << a[0] << " " << a[1] << "  " << a[2] << endl;

        if (a[s[i][0] - 'A'] == 0 && a[s[i][1] - 'A'] == 0)
        {
            cout << "No" << endl;
            return 0;
        }
        if (a[s[i][0] - 'A'] > a[s[i][1] - 'A'])
        {
            ans.push_back(s[i][1]);
            a[s[i][1] - 'A']++;
            a[s[i][0] - 'A']--;
        }
        else if (a[s[i][0] - 'A'] < a[s[i][1] - 'A'])
        {
            ans.push_back(s[i][0]);
            a[s[i][1] - 'A']--;
            a[s[i][0] - 'A']++;
        }
        else
        {

            ans.push_back(s[i][1]);
            a[s[i][1] - 'A']++;
            a[s[i][0] - 'A']--;
            if (a[s[i + 1][0] - 'A'] == 0 && a[s[i + 1][1] - 'A'] == 0)
            {
                ans.pop_back();
                a[s[i][1] - 'A']--;
                a[s[i][0] - 'A']++;

                ans.push_back(s[i][0]);
                a[s[i][1] - 'A']--;
                a[s[i][0] - 'A']++;
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 3932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZU {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			List<int> G = new List<int>();
			int[] I = cins();
			int N = I[0], K = I[1];
			I = cins();
			foreach (int j in I) { G.Add(j); }
			G.Sort();
			print(G.Skip(G.Count-K).Sum());
			Console.ReadLine();
		}

	}
}

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

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

long long MOD = 1000000000 + 7;

int N,K;
vector<vector<int>> v;

ll nPr(ll n, ll r){
  ll ret = 1;
  for(ll i = 0; i < r; i++){
    ret *= (n - i);
    ret %= MOD;
  }
  return ret;
}

int main(){
  cout << setprecision(10);
  cin >> N >> K;
  v.assign(N, vector<int>());
  for(int i = 0; i < N-1; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--; tmp2--;
    v.at(tmp1).push_back(tmp2);
    v.at(tmp2).push_back(tmp1);
  }

  ll ans = K;
  map<int,bool> m;
  queue<int> q;
  q.push(0);

  m[0] = true;

  while(!q.empty()){
    int now = q.front();
    q.pop();
    // cerr << "now: " << now << " ans: " << ans << endl; 
    
    // number of child
    ll tmp = 0;
    for(auto next: v.at(now)){
      if(m.count(next) == 0){
        tmp++;
        m[next] = true;
        q.push(next);
      }
    }
    if(tmp != 0){
      if(now == 0){
        ans *= nPr(K-1, tmp);
        ans %= MOD;
      } else { 
        ans *= nPr(K-2, tmp);
        ans %= MOD;
      }
    } 
  }
  cout << ans << endl;
}



Measured memory_bytes: 11256
i=0
while i<4:
    t,n=map(int,input().split())
    if t==1:
        money=n*6000
        print(money)
    elif t==2:
        money=n*4000
        print(money)
    elif t==3:
        money=n*3000
        print(money)
    elif t==4:
        money=n*2000
        print(money)
    i+=1


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


vector<ll> z_algorithm(const string &s){
  ll n = s.size();
  vector<ll> z_box(n, 0);
  ll left = 0;
  rep1(i, n-1){
    if(i + z_box[i - left] < left + z_box[left]){
      z_box[i] = z_box[i - left];
      continue;
    }
    ll k = max(0ll, left + z_box[left] - i);
    while(i + k < n && s[k] == s[i + k]) k++;
    z_box[i] = k;
    left = i;
  }
  z_box[0] = n;
  return z_box;
}

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

  ll res = 0;
  rep(i, n){
    vector<ll> z_box = z_algorithm(s.substr(i));
    rep(j, z_box.size()) res = max(res, min((ll)j, z_box[j]));
  }
  
  cout << res << endl;


  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(s) printf("%c",s)
int main(void){
  int n,r,l,ans=0;
  scanf("%d",&n);
  FOR(n){
    scanf("%d %d",&l,&r);
    ans+=r-l+1;
  }
  PRN(ans);
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double
const int N= 1e5+5;
int32_t main()
{
	IOS;
 	int x=0;
 	cin>>x;
 	int p=100, cou=0;
 	while(p<x){
 		p+= (p/100);
 		cou++;
 	}
 	cout<<cou<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
  int n; cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int u = a.back();
  a.pop_back(); n -= 1;
  int v = 0;
  for (int cv: a) {
    if (std::abs(u - 2 * cv) < std::abs(u - 2 * v)) {
      v = cv;
    }
  }
  cout << u << ' ' << v << endl;
}


Measured memory_bytes: 640
def cal(n): return n*(n+1)//2
 
x=int(input())
ans=[1,cal(x)]
a=0
while 1:
    a+=1
    tmp=cal(sum(ans)//2)
    if tmp>x:
        ans[1]=sum(ans)//2
    elif tmp<x:
        ans[0]=sum(ans)//2
    elif tmp==x:
        print(sum(ans)//2)
        break
    if ans[1]-ans[0]==1:
        print(ans[1])
        break

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        double p;
        cin >> p;
        for (int j = 0;j < n;++j) {
            dp[i+1][j+1] += dp[i][j]*p;
            dp[i+1][j] += dp[i][j]*(1-p);
        }
    }
    double ans = 0;
    for (int i = n/2+1;i < n+1;++i) ans += dp[n][i];
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 70912
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        if (x <= 500 * k) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 24020
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int N,M;
bool path[700][700];
int cnt[1400];
int f[700];
bool dp[701]={};
bool dfs(int r,int v){
	f[r]=v;
	cnt[v]++;
	//cerr << r+1 << ": " << v << endl;
	for(int i=0;i<N;i++){
		if(i==r||path[r][i])continue;
		if(f[i]==-1){
			if(!dfs(i,v^1)){
				return false;
			}
		}
		else if(f[i]==v){
			return false;
		}
	}
	return true;
}
int main() {
	cin >> N >> M;
	auto g=[](int u){
		return u*(u-1)/2;
	};
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		path[a][b]=true;
		path[b][a]=true;
	}
	memset(f,-1,sizeof(f));
	int r=0;
	for(int i=0;i<N;i++){
		if(f[i]==-1){
			if(!dfs(i,r)){
				//cerr << "aaa" << endl;
				cout << -1 << endl;
				return 0;
			}
			r+=2;
		}
	}
	dp[0]=true;
	for(int i=0;i<r;i+=2){
		//cerr << cnt[i] << ", " << cnt[i+1] << endl;
		for(int j=N;j>=0;j--){
			dp[j]=(j-cnt[i]>=0&&dp[j-cnt[i]])||
				(j-cnt[i+1]>=0&&dp[j-cnt[i+1]]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(f[i]==f[j]){
				if(!path[i][j]){
					//cerr << "bbb" << endl;
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	int ret=M;
	for(int i=0;i<=N;i++){
		if(dp[i]){
			//cerr << i << endl;
			ret=min(ret,g(i)+g(N-i));
		}
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    


int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n;
  
  cout << 2*n*M_PI << endl;
  return 0;
}

Measured memory_bytes: 3752