akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>

//ios::sync_with_stdio(false);

using namespace std;

const int INF = (1<<30) - 1;

const int MAX_N = 100000;

int _par[MAX_N];

int ancestor(vector<int>& parents, vector<int>& marked, int u){
    int& p = parents[u];
    if(marked[p])
        return _par[u] = p;
    return _par[u] = ancestor(parents, marked, p);
}

void init(vector<int>& parents, vector<int>& marked){
    int n = marked.size();
    for(int i=0; i<n; i++)
        _par[i] = i;
    
    for(int i=1; i<n; i++){
        if(marked[i]==0 && _par[i]==i)
            ancestor(parents, marked, i);
    }
}

int root(int u){
    if(_par[u] == u)
        return u;
    return _par[u] = root(_par[u]);
}

int main(){
    int N, Q;
    while(cin >> N >> Q, N|Q){
        vector<int> parents(N);
        parents[0] = 0;
        for(int i=1; i<N; i++){
            cin >> parents[i];
            parents[i]--;
        }
        
        vector<pair<string, int>> operations(Q);
        for(int i=0; i<Q; i++){
            cin >> operations[i].first >> operations[i].second;
            operations[i].second--;
        }
        
        vector<int> marked(N);
        marked[0] = 1;
        for(auto& o : operations){
            if(o.first == "M")
                marked[o.second]++;
        }
        
        init(parents, marked);
        
        long long int ans = 0;
        for(int i=Q-1; i>=0; i--){
            auto& o = operations[i];
            int& u = o.second;
            if(o.first == "M"){
                if(--marked[u] == 0)
                    _par[u] = parents[_par[u]];
            }else if(o.first == "Q"){
                ans += root(u) + 1;
            }
        }
        cout << ans << endl;
    }
    
	return 0;
}

Measured memory_bytes: 8444
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll a,b;cin>>a>>b;
	if(a>b) for(ll i=0;i<a;i++) cout<<b;
	else for(ll i=0;i<b;i++) cout<<a;
}


Measured memory_bytes: 256
s = input()
s = s[:-1]
len_s = len(s)
for i in range(len_s):
    if len(s) % 2 == 1:
        s = s[:-1]
    elif s[0:int(len(s)/2)] == s[int(len(s)/2):len(s)]:
        print(len(s))
        break
    else:
        s = s[:-1]



Measured memory_bytes: 3060
Xss = [[0]*(3) for _ in range(3)]
Xss[0][0] = int(input())
Xss[0][1] = int(input())
Xss[1][1] = int(input())

S = Xss[1][1] * 3

Xss[0][2] = S - Xss[0][0] - Xss[0][1]
Xss[2][1] = S - Xss[0][1] - Xss[1][1]
Xss[2][2] = S - Xss[0][0] - Xss[1][1]
Xss[1][2] = S - Xss[0][2] - Xss[2][2]
Xss[1][0] = S - Xss[1][1] - Xss[1][2]
Xss[2][0] = S - Xss[2][1] - Xss[2][2]

for Xs in Xss:
    print(*Xs)


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int n,a[200],s=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  while(n){
    for(i=0;i<n;i++){
      if(a[i]%2){
        n=0;
        break;
      }
      a[i]/=2;
    }
    s++;
  }
  printf("%d",s-1);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;


int main() {
	int N;
	int cnt = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		if (p != i)cnt++;
	}
	cout << (cnt <= 2 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main() {
  int K;
  std::cin >> K;
  std::cout << arr[K - 1] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000


int linearSearch(){
  int i,j,count,k,l;
  int s[MAX],t[MAX];

  count = 0;
  
  scanf("%d",&k);
  for(i = 0; i < k; i++)
    scanf("%d",&s[i]);
  
  scanf("%d",&l);
  for(i = 0; i < l; i++)
    scanf("%d",&t[i]);

    for(i = 0; i < l; i++)
      for(j = 0; j < k; j++)
	if(t[i] == s[j]){
	  count++;
	  break;
	}
    
  return count;
}

int main(){
  
  printf("%d\n",linearSearch());
  
  return 0;
}



Measured memory_bytes: 2144
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int N;
int A[200];
int ct;

int main(){
    cin >> N;
    for (size_t i = 0; i < N; i++) {
      cin >> A[i];
    }
    ct = 0;
    while (true) {
      bool odd = false;
      for (size_t i = 0; i < N; i++) {
        if (A[i] % 2 != 0) odd = true;
      }
      if (odd) break;
      for (size_t i = 0; i < N; i++) {
        A[i] /= 2;
      }
      ++ct;
    }
    
    cout << ct; 
    return 0;
}


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

typedef long double ld;
typedef pair<ld, int> ld_i;

int main() {
	ld PI = acosl(-1);
	int N; cin >> N;
	vector<int> x(N), y(N);
	for (int i = 0; i < N; i++)
		cin >> x[i] >> y[i];
	for (int k = 0; k < N; k++) {
		vector<ld_i> v;
		for (int i = 0; i < N; i++) {
			if (i == k) continue;
			ld a = atan2l(x[i] - x[k], y[i] - y[k]);
			v.push_back(ld_i(a, i < k));
		}
		int n = v.size();
		sort(v.begin(), v.end());
		for (int i = 0; i < n; i++) {
			v.push_back(v[i]);
			v.back().first += PI*2;
		}
		int a = 0, b = 0, j = 0;
		bool ok = false;
		for (int i = 0; i < n; i++) {
			for (; v[j].first < v[i].first + PI; j++)
				if (v[j].second) a++;
				else b++;
			if ((a == k && b == 0) || (a == 0 && b == N - 1 - k))
				ok = true;
			if (v[i].second) a--;
			else b--;
		}
		if (!ok) {
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;
}

Measured memory_bytes: 1332
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

int main() {
	int N, T;
	cin >> N >> T;
	int Cost = 999999;
	bool any = false;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			any = true;
			Cost = min(c, Cost);
		}
	}
	if (any) {
		cout << Cost << endl;
	} else {
		cout << "TLE" << endl;
	}
}


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

const int INF = 1 << 30;

void solve(int E) {
    int ans = INF;
    for (int z = 100; z >= 0; z--) {
        if (z * z * z > E) continue;
        int rest = E - z * z * z;
        for (int y = 1000; y >= 0; y--) {
            if (y * y > rest) continue;
            int x = rest - y * y;
            ans = min(ans, x + y + z);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int E;
    while (true) {
        cin >> E;
        if (E == 0) break;
        solve(E);
    }
    return 0;
}


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

using namespace std;

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

typedef long long ll;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> p1(4), p2(2);
  int sum = 0;
  for (int i = 0; i < 4; i++) {
    cin >> p1[i];
    sum += p1[i];
  }
  for (int i = 0; i < 2; i++) {
    cin >> p2[i];
    sum += p2[i];
  }
  sort(p1.begin(), p1.end());
  sum -= (p1[0] + min(p2[0], p2[1]));
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll n,m,p[11],ans;
bool s[11];
vector<vector<ll>>a(11);

void cal(){
	for(int i=0;i<m;i++){
		ll cnt=0;
		for(int j=0;j<a[i].size();j++){
			if(s[a[i][j]]==1){
				cnt++;
			}
		}
		if(cnt%2!=p[i]){
			return;
		}
	}
	ans++;
}
void dep(ll d){
	if(d==n){
		cal();
		return;
	}
	s[d]=0;dep(d+1);
	s[d]=1;dep(d+1);
}
int main() {
	cin>>n>>m;//電球がm
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		for(int j=0;j<z;j++){
			ll x;
			cin>>x;
			x--;
			a[i].push_back(x);
		}
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	dep(0);
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<map>
int F(int*a)
{
	int s,f,c,r;
	for(s=f=c=r=0;c<9;)
	{
		r+=*a;
		if(*a+s==10)
		{
			if(f)r+=a[1];
			else r+=a[1]+a[2];
			f=0,s=0;
			++c;
		}
		else
		{
			if(f)f=0,++c,s=0;
			else f=1,s=*a;
		}
		++a;
	}
	s=*a+a[1];
	if(s>9)s+=a[2];
	return r+s;
}
int main()
{
	int m,i,j,x[32],l;
	char*p,s[256];
	std::pair<int,int>a[40];
	while(scanf("%d",&m),m)
	{
		for(i=0;i<m;++i)
		{
			scanf("%d",&a[i].second);
			fgets(s,256,stdin);
			for(l=0,p=strtok(s," ");p;p=strtok(0," "))
				x[l++]=atoi(p);
			a[i].first=-F(x);
		}
		std::sort(a,a+m);
		for(i=0;i<m;++i)printf("%d %d\n",a[i].second,-a[i].first);
	}
	return 0;
}

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

int main(void){
    ll n;
    cin >> n;

    if(n % 2 == 0){
        cout << n << endl;
    }
    else{
        cout << n * 2 << endl;
    }

    return 0;
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

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

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int n, sum = 0;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        int p, x;
        cin >> p >> x;
        cout << sum - a[p-1] + x << endl;
    }
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> abc(N,vector<int>(3,0)),dp(N,vector<int>(3,0));
  for (int i=0;i<N;i++){
    for (int j=0;j<3;j++){
      cin >> abc.at(i).at(j);
    }
  }
  dp.at(0)=abc.at(0);
  for (int i=1;i<N;i++){
    dp.at(i).at(0)=max(dp.at(i-1).at(1),dp.at(i-1).at(2))+abc.at(i).at(0);
    dp.at(i).at(1)=max(dp.at(i-1).at(0),dp.at(i-1).at(2))+abc.at(i).at(1);
    dp.at(i).at(2)=max(dp.at(i-1).at(0),dp.at(i-1).at(1))+abc.at(i).at(2);
  }
  cout << *max_element(dp.at(N-1).begin(),dp.at(N-1).end()) << endl;
}

Measured memory_bytes: 11136
S = input()

res = [0] * 2019
res[0] = 1

d = 1
a = 0

for c in reversed(S):
    a += int(c) * d
    a %= 2019
    res[a] += 1
    d *= 10
    d %= 2019

ans = 0
for r in res:
    ans += r*(r-1) // 2
print(ans)

Measured memory_bytes: 9284
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, tmp, cnt, N, Q, t1, t2;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;


int main(void) {
	scanf("%d %d", &N, &Q);
	cin >> s;
	vector<int> flag(s.size()+1,0);
	vector<int> ans;
	vector<int>l;
	vector<int>r;
	REP(i, s.size()) {
		if (s.substr(i, 2) == "AC") {
			flag.at(i+1) = flag.at(i) + 1;
		}
		else {
			flag.at(i+1) = flag.at(i);
		}
	}
	REP(i, Q) {
		scanf("%d %d", &t1, &t2);
		t1--;
		t2--;
		l.push_back(t1);
		r.push_back(t2);
	}
	REP(i, Q) {
		ans.push_back(flag.at(r.at(i)) - flag.at(l.at(i)));
	}


	REP(i, ans.size()) {
		printf("%d\n", ans.at(i));
	}
	return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll N;
ll ans = 1;

int main() {
    cin >> N;
    rep(i, N) {
        ans *= 10;
        ans %= MOD;
    }

    ll ans2 = 1;

    rep(i, N) {
        ans2 *= 9;
        ans2 %= MOD;
    }
    ans -= ans2;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans -= ans2;
    ans %= MOD;
    if (ans < 0) ans += MOD;

    ans2 = 1;

    rep(i, N) {
        ans2 *= 8;
        ans2 %= MOD;
    }

    ans += ans2;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define max 1000000000000000000

using namespace std;

int main()
{
    CIN;
    int arr[5],i,j,p;
    for(i=0,j=1;i<5;i++,j++)
    {
    	cin>>arr[i];
    	if(!arr[i])p=j;

    }
   cout<<p<<nw;
    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
int main(){
  int r,s,rs;
  scanf("%d%d%d",&r,&s,&rs);
  if(r==1&&s==0&&rs==0){
    printf("Close\n");
  }
  else  if(r==0&&s==1&&rs==0){
    printf("Close\n");
  }
  else  if(r==1&&s==1&&rs==0){
    printf("Open\n");
  }
  else  if(r==0&&s==0&&rs==1){
    printf("Open\n");
  }
  else  if(r==0&&s==0&&rs==0){
    printf("Close\n");
  }
  return 0;
}

Measured memory_bytes: 584
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let r = read double ()
printfn "%f" (r*2.0*Math.PI)

Measured memory_bytes: 30120
while True:
    a = input().split(' ')
    for i in range(len(a)):
        a[i] = int(a[i])
    if a[0] == 0 and a[1] == 0:break
    if a[0] < a[1]:
        print(str(a[0])+' '+str(a[1]))
    else:
        print(str(a[1])+' '+str(a[0]))


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

int main(){
  int N,Y,m,g,s,t=1;cin>>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;(i+j)<=N;j++){
      if(i*10000+j*5000+(N-i-j)*1000==Y){
        t=0;
        m=i;g=j;s=(N-i-j);
      }
      }
    }
  if(t==0){
    cout<<m<<" "<<g<<" "<<s<<endl;
  }else{
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {

    int a,b,c;

    scanf("%d%d%d",&a,&b,&c);

    if(a < b && b < c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}




Measured memory_bytes: 2044
// m-solutions2020_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int A, B, C, K, count = 0;
  cin>>A>>B>>C>>K;

  while (true) {
    if (A >= B) {
      B = B*2;
      count++;
    }
    if (B >= C) {
      C = C*2;
      count++;
    }
    if (A < B && B < C) break;
  }

  if (count <= K) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<b){
    if(a<=c){
      if(c<=b) printf("Yes\n");
      else printf("No\n");
    }
   else printf("No\n");
  }
  else{
    if(c<=a){
      if(b<=c) printf("Yes\n");
      else printf("No\n");
    }
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
    int i,n;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    for(i=0;i<n;i++){
        printf("node %d: key = %d,",i+1,A[i]);
        if(i!=0) printf(" parent key = %d,",A[(i-1)/2]);
        if((i+1)*2>=0 && (i+1)*2<=n) printf(" left key = %d,",A[i*2+1]);
        if((i+1)*2+1>=0 && (i+1)*2+1<=n) printf(" right key = %d,",A[i*2+2]);
        printf(" \n");
    }
    return 0;
}


Measured memory_bytes: 2048
# PROBLEM D
Q = int(input())
for _ in range(Q):
    a, b = sorted([int(s) for s in input().split()])
    c_max = int((a * b) ** 0.5)
    if c_max * c_max == a * b:
        c_max -= 1
    sol = 2 * c_max
    if a <= c_max:
        sol -= 1
    if (c_max * c_max < a * b) and (c_max * (c_max + 1) >= a * b):
        sol -= 1
    print(sol)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;

#define INF 1000000000
#define rep(i, n) for (int i = 0; i < n; i++)
#define D(x) cout << #x " is " << x << endl
#define pb push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int n, l; cin >> n >> l;
    vi knots(n);
    rep(i, n) cin >> knots[i];

    rep(i, n - 1)
    {
        if (knots[i] + knots[i + 1] >= l)
        {
            i++;
            cout << "Possible\n";
            for (int j = 1; j < i; j++) cout << j << endl;
            for (int j = n - 1; j > i; j--) cout << j << endl;
            cout << i << endl;
            return 0;
        }
    }
    cout << "Impossible\n";

    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N, M;
    cin >> N >> M;

    int result = (N * (N - 1) / 2) + (M * (M - 1) / 2);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define lint long long
using namespace std;
const lint MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<lint> x(n), y(m);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i];
    }

    lint xsum = 0, xprev = 0;
    for (int i = 1; i < n; i++) {
        lint dx = x[i] - x[i - 1];
        xprev = (xprev + i*dx)%MOD;
        xsum = (xsum + xprev)%MOD;
    }
    lint ysum = 0, yprev = 0;
    for (int i = 1; i < m; i++) {
        lint dy = y[i] - y[i - 1];
        yprev = (yprev + i*dy)%MOD;
        ysum = (ysum + yprev)%MOD;
    }

    cout << (xsum*ysum)%MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int i,a,b,c,k=1,flag=0;
	scanf("%d %d",&a,&b);
	c=b;
	while(c>0){
		c/=10;
		k*=10;
	}
	c=a*k+b;
	for(i=1;i<c;i++){
		if(i*i==c){
			flag=1;
		}
	}
	if(flag==1){
		printf("Yes");
	}else{
		printf("No");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
long long a,b,c,d;
long long fzx_max(long long x,long long y) {
        return x<y ? y : x;
}
signed main()
{
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
        cout<<fzx_max(a*c,fzx_max(a*d,fzx_max(b*c,b*d)))<<"\n"; return 0;
}


Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }
    else if(a>b){
        cout<<"a > b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		System.out.println( (a*b) + " " + (2*a + 2*b) );
		
	}

}

Measured memory_bytes: 26112
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

vii v;
int n,dp[5000][5001];

int f(int i,int k){// f(i,j) min price when j items taken and i items included
    if(k<0)return INF;
    if(i==-1){
        if(k>0)return INF;
        return 0;
    }
    
    int &ans=dp[i][k];
    if(ans!=-1)return ans;
    
    ans=INF;
    int picheka=f(i-1,k-1);
    if(picheka<=v[i].first)ans=min(ans,picheka+v[i].second);
    ans=min(ans,f(i-1,k));
    
    return ans;
}

signed main(){
    FASTER;
    memset(dp,-1,sizeof dp);
    cin>>n;
    v=vii(n);cin>>v;
    sort(all(v),[](const pii &a,const pii &b){return a.first+a.second<b.first+b.second;});
    
    for(int i=n;i>=0;i--){
        if(f(n-1,i)!=INF){
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 195968
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#define MAX 55555//求MAX范围内的素数  

using namespace std;  
typedef long long LL;
LL su[MAX],cnt;  
bool isprime[MAX];  
void prime()  
{  
    cnt = 1;  
    memset(isprime, 1, sizeof(isprime));//初始化认为所有数都为素数  
    isprime[0] = isprime[1] = 0;//0和1不是素数  
    for(LL i = 2; i <= MAX; i++)  
    {  
        if(isprime[i])  
            su[cnt++] = i;//保存素数i  
        for(LL j = 1; j < cnt && su[j] * i < MAX; j++)  
        {  
            isprime[su[j] * i] = 0;//筛掉小于等于i的素数和i的积构成的合数  
        }  
    }  
}  
int main()  
{  
    prime();  
    int n;
    scanf("%d", &n);
	int j = 0;
	for (int i = 11; j < n; i += 10) {
		if (isprime[i]) {
			if(j == 0) printf("%d", i);
			else printf(" %d", i);
			j++;
		}
	}
	printf("\n");
    return 0;  
}

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

using namespace std;

#define int long long
#define endl '\n'
const int N = 1e5 + 10;

struct DSU {
    int par[N], sz[N];

    DSU() {}

    DSU(int n) {
        for (int i = 0; i < n; i++)
            par[i] = i, sz[i] = 1;
    }

    int getPar(int k) {
        while (k != par[k]) {
            par[k] = par[par[k]];
            k = par[k];
        }
        return k;
    }

    void unite(int u, int v) {
        int par1 = getPar(u), par2 = getPar(v);

        if (par1 == par2)
            return;
        if (sz[par1] > sz[par2]) {
            par[par2] = par1;
            sz[par1] += sz[par2];
        } else {
            par[par1] = par2;
            sz[par2] += sz[par1];
        }
    }
};

void solve() {
    int n, q;
    cin >> n >> q;

    DSU d(n);

    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;

        int x, y;
        cin >> x >> y;
        if (type == 0) {
            d.unite(x, y);
        } else {
            if (d.getPar(x) == d.getPar(y))
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int line = sc.nextInt();
        sc.close();
        int d = line % 10;
        int c = (line / 10) % 10;
        int b = (line / 100) % 10;
        int a = (line / 1000) % 10;

        boolean endFlag = false;
        for(int i = 0; i <=1; i++){
            for(int j = 0; j <=1; j++){
                for(int k = 0; k <=1; k++){
                    int tmp = calc(a,b,i);
                    tmp = calc(tmp,c,j);
                    tmp = calc(tmp,d,k);
                    if(tmp == 7){
                        System.out.println(a + op(i) + b + op(j) + c + op(k) + d + "=7");
                        endFlag = true;
                        break;
                    }
                }
                if(endFlag){
                    break;
                }
            }
            if(endFlag){
                break;
            }
        }

    }

    private static String op(int i) {
        if(i == 0){
            return "+";
        }
        return "-";
    }

    private static int calc(int a, int b, int i) {
        if(i == 0){
            return a + b;
        }
        return a - b;
    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,C;cin>>A>>B>>C;
  
  if(A+B>=C){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

bool is_prime(int n) {
    int d = (int)sqrt(n);
    for(int i=2;i<=d;i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    int ans=0;
    cin >> n;
    vector<int> arr;
    rep(i, n) {
        int t;
        cin >> t;
        arr.push_back(t);
    }
    
    rep(i,arr.size()){
        if(is_prime(arr[i])){
            ans++;
        }
    }

    cout << ans << endl;
}


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

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const long long int INF=0x3f3f3f3f3f;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
	vivek_ghosh;
	
	cin>>n;
	
	ans = 3*pow(n,2);
	cout<<ans<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}








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

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    double ans = 0;
    for(int i = 0;i < n;i ++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    ans += v[0]/pow(2,n-1);
    for(int i = 1;i < n;i ++){
        ans += v[i]/pow(2,n-i);
    }
    cout << std::setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


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

    ll N, A, B; cin >> N >> A >> B;
    ll ans = N / (A+B) * A;
    N -= N / (A+B) * (A+B);
    ans += min(N, A);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<vector<ll> > A(n, vector<ll>(m));
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < m; j++)
		{
			cin >> A[i][j];
		}
	}
	vector<ll> b(m);
	for (ll i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	vector<ll> ans(n);
	for (ll i = 0; i < n; i++)
	{
		ll temp = 0;
		for (ll j = 0; j < m; j++)
		{
			temp += A[i][j] * b[j];
		}
		cout << temp << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<pair<int, int>> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i).first;
    data.at(i).second = i + 1;
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < N; i++)cout << data.at(i).second << ' ';
  cout << endl;
  return 0;
}

Measured memory_bytes: 1536
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    string s;
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')cout << 3 << endl;
    else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))cout << 2 << endl;
    else if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S')cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

int main() {
  int n,m;
  int ans=0;
  cin >> m >> n;

  if(m>=n) {
    cout << ans << endl;
    return 0;
  }

  vector<int> X(n);
  for (int i=0; i<n; i++) {
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());

  vector<int> D(n-1);
  for (int i=0; i<n-1; i++) {
    D.at(i) = abs(X.at(i+1)-X.at(i));
  }
  sort(D.begin(), D.end());

  for (int i=0; i<n-m; i++) {
    ans += D.at(i);
  }

  cout << ans << endl;
  
}

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

int main(){
	int n,m,s;
	while(cin>>n>>m>>s&&(n||m||s)){
		ll dp[51][3001] = {};
		dp[0][0]=1;
		
		for(int i=1;i<=m;i++){
			for(int j=n*n;j>=1;j--){
				for(int k=1;k<=s;k++){
					if(k-i>=0)dp[j][k] = ( dp[j][k] + dp[j-1][k-i] )%100000 ;
				}
			}
		}
		cout<<dp[n*n][s]<<endl;
	}
}

Measured memory_bytes: 4168
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
 #ifdef LOCAL_EXEC
 #else
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 #endif // LOCAL_EXEC
  long long int x,y,n,k,i,j,sum=0,q;
  cin>>n;
  long long int A[n];
  map<long long int,long long int>mt;
  for(i=0;i<n;i++){
    cin>>A[i];
    sum+=A[i];
    mt[A[i]]+=1;
  }
  cin>>q;
  for(i=0;i<q;i++){
    cin>>x>>y;
    if(mt[x]>0){
        sum+=mt[x]*(y-x);
        mt[y]+=mt[x];
        mt[x]=0;
    }
    cout<<sum<<endl;
  }
  return 0;
}


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

int main(int argc, char *argv[]) {
  char str1[5], str2[5];
  int i;

  scanf("%s", str1);
  scanf("%s", str2);
  for(i=0; i<3; i++) {
    if(str1[i] != str2[2-i]) {
      printf("NO\n");
      exit(0);
    }
  }
  printf("YES\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    string S; cin >> S;

    int ans = 0;
    rep(i, 4){
        if(S[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define anin(a) printf("%d\n",a);


int main(void){
	int a,ans(0);
	char mozi[10];
	scanf("%d %s",&a,mozi);
	if(a >= 3200) printf("%s\n",mozi); else printf("red\n");
	return 0;
}

Measured memory_bytes: 760
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
class RootedTree:
    def __init__(self):
        self.id = None
        self.child = []
        self.parent = -1
        self.node_type = "root"
        self.depth = 0

    def show(self):
        print("node {}: parent = {}, depth = {}, {}, {}".format(self.id, self.parent, self.depth, self.node_type, self.child))

def cal_depth(tree, node, cur_depth):
    node.depth += cur_depth
    #node.show()
    for index in node.child:
        cal_depth(tree, tree[index], cur_depth + 1)
        
def make_tree(tree_data):#?????????,?¨???????n^2
    tree = [RootedTree() for i in range(len(tree_data))]
    
    for data in tree_data:
        focus = tree[data[0]]
        focus.id = data[0]
        
        if data[2:]:
            focus.child = data[2:]
            
            for child_index in data[2:]:
                tree[child_index].parent = data[0]
                
                if tree_data[[a[0] for a in tree_data].index(child_index)][2:]:
                    tree[child_index].node_type = "internal node"
                else:
                    tree[child_index].node_type = "leaf"
            
    root_index = [n.node_type for n in tree].index("root")
    cal_depth(tree, tree[root_index], 0)
    return tree

def set_tree_data(tree, target, parent, depth):
    tree[target]["depth"] += depth
    tree[target]["parent"] = parent

    for c in tree[target]["child"]:
        set_tree_data(tree, c, target, depth + 1)

def make_tree_revision(tree_data, n_tree):
    tree = [{"parent": None, "depth":0, "child" : None} for i in range(n_tree)]
    root = sum(range(n_tree))
    
    for node_data in tree_data:
        tree[node_data[0]]["child"] = node_data[2:]
        root -= sum(node_data[2:])

    set_tree_data(tree, root, -1, 0)
    return tree
def main():
    n_tree = int(input())
    tree_data = [[int(a) for a in input().split()] for i in range(n_tree)]
    
    for i, node in enumerate(make_tree_revision(tree_data, n_tree)):
        category = "root"
        if (not node["parent"] == -1) and node["child"]:
            category = "internal node"
        elif not node["parent"] == -1:
            category = "leaf"

        print("node {}: parent = {}, depth = {}, {}, {}".format(i, node["parent"], node["depth"], category, node["child"]))
if __name__ == "__main__":
    main()

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> vals[n];
    for (int i = 0; i < n; i++) {
        int t, d; cin >> t >> d;
        vals[t-1].push_back(d);
    }
    vector<int> rest, top;
    for (int i = 0; i < n; i++) {
        vector<int> &v = vals[i];
        if (!v.empty()) {
            sort(v.begin(), v.end());
            top.push_back(v.back());
            rest.insert(rest.end(), v.begin(), prev(v.end()));
        }
    }
    sort(top.rbegin(), top.rend());
    sort(rest.begin(), rest.end());
    if (top.size() > k) top.resize(k);
    long long sum = accumulate(top.begin(), top.end(), 0LL), count = top.size();
    for (int i = 0; i < k - top.size(); i++) {
        sum += rest.back();
        rest.pop_back();
    }
    long long ans = sum + count * count;
    while (!top.empty() && !rest.empty() && count > 0) {
        count--;
        sum += rest.back() - top.back();
        rest.pop_back(); top.pop_back();
        ans = max(ans, sum + count * count);
    }
    cout << ans << endl;
}


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


int main () {

    long long int N,sum=0,cmp=0,ans;
    cin >> N;
    int A[N+2];
    A[0] = 0;
    A[N+1] = 0;
    for(int i = 1; i < N+2; i++) {
        cin >> A[i];
        sum += abs(cmp - A[i]);
        cmp = A[i];
    }

    for(int i = 1; i <= N; i++) {
        ans = sum;
        cmp = abs(A[i-1]-A[i]) + abs(A[i] - A[i+1]);
        ans -= cmp - abs(A[i-1] - A[i+1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2*1e9

int main()
{
    fastio;
    int k;
    cin >> k;
    int dp[10][11];
    for(int i=0;i<10;i++)
        dp[i][1]=1;
    for(int i=2;i<11;i++)
    {
        for(int j=0;j<10;j++)
        {
            if(j==0)
                dp[j][i]=dp[j][i-1]+dp[j+1][i-1];
            else if(j==9)
                dp[j][i]=dp[j][i-1]+dp[j-1][i-1];
            else
                dp[j][i]= dp[j-1][i-1]+dp[j][i-1]+dp[j+1][i-1];
        }
    }
    // for(int i=1;i<3;i++)
    // {
    //     for(int j=0;j<10;j++)
    //         cout << dp[j][i] << " ";
    //     cout << endl;
    // }
    string ans="";
    int f=0,imp=1;
    for(int i=1;i<11 and f==0;i++)
    {
        for(int j=imp;j<10;j++)
        {
            if(k>dp[j][i])
                k-=dp[j][i];
            else
            {
                ans+=to_string(j);
                if(j!=0)
                {
                    imp=j-1;
                }
                else
                    imp=j;
                if(i!=1)
                    i-=2;
                else
                    f=1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <stack>
#include<cassert>
#include <cfloat>
#include <list>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define testMyStupedCode TCF--
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
void ReadFromFile( string name , string extention ){
    string fullPath = name + "." + extention ;
    freopen( fullPath.c_str() , "r" , stdin ) ;
}
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline char C(){
    char c ;
    scanf( "%c" , &c ) ;
    return c ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e5 + 5;
ll dp[N];
int v[N], w[N];
int main(){
     int n = D(), W = D();
     for(int i = 0; i < n; ++i)
          w[i] = D(), v[i] = D();
     dp[0] = 0;
     for(int i = 1; i <= W; ++i)
          dp[i] = -1;
     ll ans = 0;
     for(int i = 0; i < n; ++i)
          for(int j = W - w[i]; j >= 0; --j){
               dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
               ans = max(ans, dp[j + w[i]]);
               ans = max(ans, dp[j]);
          }
     printf("%lld", ans);
     return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back

typedef vector<int> vint;
typedef long long ll;


int main() {
    int ans = 0;
    int a, b;
    cin >> a >> b;
    if(max(a, b) == a){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }

    ans += max(a,b);

    cout << ans << endl;
}


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

using namespace std;

int main() {
	long long n, m;
	cin >> n >> m;

	if (n > m) {
		swap(n, m);
	}

	if (n == 1) {
		if (m == 1) {
			cout << 1 << endl;
		} else if (m == 2) {
			cout << 0 << endl;
		} else {
			cout << m - 2 << endl;
		}
	} else {
		cout << (n - 2) * (m - 2) << endl;
	}
	return 0;
}


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

int main() {
  int A, B, C, D;
  int L, R;
  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;
  
  if (L == R) {
    cout << "Balanced" << endl;
  } else if (L > R){
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int H,W,i,j;
 
  while( scanf("%d %d",&H,&W),!(H==0&&W==0)){
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if((i+j)%2==0){
	  printf("#");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
      
  return 0;
}

Measured memory_bytes: 572