akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

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

    int R;

    cin >> R;

    if( 0 <= R && R <1200){
        cout << "ABC" << endl;
        return 0;
    }
    if( 1200 <= R && R <2800){
        cout << "ARC" << endl;
        return 0;
    }
    if( 2800 <= R && R <= 4208){
        cout << "AGC" << endl;
        return 0;
    }

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define lb long double
using namespace std;


int main()
{
	ll n;
	cin >> n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin >>a[i];
	}
	sort(a,a+n);
	cout << a[n/2]-a[(n/2)-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pi pair<int, int>
#define all(x) (x).begin(), (c).end()

using namespace std;

const int N = 2e5 + 5;

int n, a[N], s[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    n++;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = n; i > 0; i--)
        s[i] = s[i + 1] + a[i];
    int k = 1, ans = 1;
    for (int i = 1; i <= n; i++) {
        //cout << k << endl;
        if (a[i] > k) {
            cout << -1;
            return 0;
        }
        if (i == n) {
            ans -= (k - a[i]);
            break;
        }
        k -= a[i];
        int nk = min(s[i + 1], k * 2);
        ans += nk;
        k = nk;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5188
A, B = map(int, input().split(' '))

def is_palindromic(n):
    sep_idx = len(n) // 2
    if n[:sep_idx] == n[sep_idx+1:][::-1]:
        return True
    return False

count = 0
for n in range(A, B+1):
    n_str = str(n)
    if is_palindromic(n_str):
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,H;
    cin >> N >> H;
    vector<pair<ll,ll>> sword(N);
    vector<pair<ll,ll>> ss(N);
    REP(i,N){
        cin >> sword[i].S >> sword[i].F;
        ss[i].F = sword[i].S;
        ss[i].S = sword[i].F;
    }
    sort(ALL(ss),greater<>());
    ll zan = ss[0].F;
    ll chinpo = ss[0].S;
    REP(i,N){
        if(ss[0].F == ss[i].F)chmin(chinpo,ss[i].S);
    }
    REP(i,N){
        if(sword[i].S == zan&&sword[i].F == chinpo){
            sword[i].F = 0;
            sword[i].S = 0;
            break;
        }
    }
    ll count = 1;
    ll last = max(zan,chinpo);
    sort(ALL(sword),greater<>());
    ll inq = 0;
    while(H > last){
        if(inq < N){
            H -= max(sword[inq].F,zan);
            if(H <= 0)count--;
        }else{
            ll cc = 0;
            cc = (H - last+zan-1)/zan;
            if(H - cc*zan > 0){
                count += cc;
            }else{
                count += cc-1;
            }
            break;
        }
        count++;
        inq++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	ArrayList<P> calc(Circle c1, Circle c2) {
		ArrayList<P> ret = new ArrayList<>();
		double d = c1.center.dist(c2.center);
		double cos = (c1.r * c1.r + d * d - c2.r * c2.r) / (2 * d * c1.r);
		P p12 = c2.center.sub(c1.center);
		P midP = c1.center.add(p12.normalize().mul(c1.r * cos));
		double h = c1.r * Math.sqrt(1 - cos * cos);
		ret.add(midP.add(p12.normalize().rot(Math.PI / 2).mul(h)));
		if (h > 0)
			ret.add(midP.add(p12.normalize().rot(Math.PI / 2).mul(-h)));
		return ret;
	}

	void run(double c1x, double c1y, double c1r, double c2x, double c2y, double c2r) {
		P center1 = new P(c1x, c1y);
		P center2 = new P(c2x, c2y);
		Circle c1 = new Circle(center1, c1r);
		Circle c2 = new Circle(center2, c2r);
		ArrayList<P> ret = calc(c1, c2);
		Collections.sort(ret);
		if (ret.size() == 2)
			for (int i = 0; i < ret.size(); ++i) {
				System.out.printf("%.10f %.10f", ret.get(i).x, ret.get(i).y);
				System.out.print(i == ret.size() - 1 ? "\n" : " ");
			}
		else {
			System.out.printf("%.10f %.10f %.10f %.10f\n", ret.get(0).x, ret.get(0).y, ret.get(0).x, ret.get(0).y);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double c1x, c1y, c1r, c2x, c2y, c2r;
		c1x = sc.nextDouble();
		c1y = sc.nextDouble();
		c1r = sc.nextDouble();
		c2x = sc.nextDouble();
		c2y = sc.nextDouble();
		c2r = sc.nextDouble();
		new Main().run(c1x, c1y, c1r, c2x, c2y, c2r);

	}

	class Circle {
		P center;
		double r;

		public Circle(P center, double r) {
			this.center = center;
			this.r = r;
		}

	}

	class P implements Comparable<P> {
		double x, y;

		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}

		double norm() {
			return Math.sqrt(x * x + y * y);
		}

		P normalize() {
			return this.mul(1 / this.norm());
		}

		P add(P p) {
			return new P(x + p.x, y + p.y);
		}

		P sub(P p) {
			return this.add(p.mul(-1));
		}

		P mul(double coe) {
			return new P(x * coe, y * coe);
		}

		double dist(P p) {
			return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
		}

		P rot(double ang) {
			double c = Math.cos(ang);
			double s = Math.sin(ang);
			return new P(c * x - s * y, s * x + c * y);
		}

		@Override
		public int compareTo(P o) {
			if (Math.abs(x - o.x) > 1e-6)
				return Double.compare(x, o.x);
			else {
				return Double.compare(y, o.y);
			}
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 28252
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	typedef pair<int,int> P;
	const int N=1e5+9,mod=998244353,inv2=(mod+1)/2;
	int head[N],nex[N],to[N],cnt;
	inline void add(int u,int v){
		nex[++cnt]=head[u];
		head[u]=cnt;to[cnt]=v;
	}

	int n,m,pw[N],sg[N],f[1<<20],limit=1,ans[1<<20];
	inline void fwt_xor(int *a,int opt){
		for(int mid=1;mid<limit;mid<<=1)
			for(int i=0,R=mid<<1;i<limit;i+=R)
				for(int j=0;j<mid;j++){
					int x=a[i+j],y=a[i+j+mid];
					a[i+j]=1LL*(x+y)*(opt?1:inv2)%mod;
					a[i+j+mid]=(1LL*(x-y)*(opt?1:inv2)%mod+mod)%mod;
				}
	}
	map<P,bool> mp;
	int main(){
		n=read<int>();
		while(limit<=n) limit<<=1;
		int bas=((long long)1e18)%mod;pw[0]=1;
		for(int i=1;i<=n;i++) pw[i]=1LL*pw[i-1]*bas%mod;
		for(int i=0;i<limit;i++) ans[i]=1;
		for(int num=0;num<3;num++){
			m=read<int>();
			for(int i=1;i<=n;i++) head[i]=0,sg[i]=0;cnt=0;
			for(int i=1;i<=m;i++){
				int u=read<int>(),v=read<int>();
				add(min(u,v),max(u,v));
			}
			mp.clear();
			for(int u=n;u>=1;u--){
				for(int i=head[u];i;i=nex[i])
					if(~sg[to[i]]) mp[P(u,sg[to[i]])]=1;
				while(mp[P(u,sg[u])]) sg[u]++;
			}
		//	for(int i=1;i<=n;i++)
		//		cout<<sg[i]<<endl;
			for(int i=0;i<limit;i++) f[i]=0;
			for(int i=1;i<=n;i++) f[sg[i]]=(f[sg[i]]+pw[i])%mod;
			fwt_xor(f,1);
			for(int i=0;i<limit;i++) ans[i]=1LL*ans[i]*f[i]%mod;
		}
		fwt_xor(ans,0);
		printf("%d\n",ans[0]);
		return 0;
	}
}
int main(){
#ifdef my
	freopen("graph.in","r",stdin);
	freopen("graph.out","w",stdout);
#endif
	return run::main();
}

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

int main()
{
    char s;
    cin >> s;
    if((s >= 'A')&&(s <= 'Z')) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


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

int main()
{
  long long int n,i,ans;
  cin>>n;
  long long int arr[n];
  for( i=0;i<n;i++)
    cin>>arr[i];
  long long int count=0;
  long long int res=0;
  long long int j = arr[n-1];
  for( i=n-2;i>=0;)
  {
   if(arr[i]>=arr[i+1])
   {
   while((i>=0)&&arr[i]>=arr[i+1])
   {
     count++;
     i--;
   }
    res=max(res,count);
    count=0;
   }
    else
    {
      i--;
    }
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 1024
# F - Intervals on Tree
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += i*(N+1-i)
for _ in range(N-1):
    u,v = map(int,input().split())
    u,v = min(u,v),max(u,v)
    ans -= u*(N+1-v)
print(ans)

Measured memory_bytes: 9140
#include<stdio.h>

int main() {

int A, B;

scanf("%d""%d", &A, &B);

if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
  printf("Possible");
  
} else {
  printf("Impossible");
}
  
  return 0;
}
  

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

struct SegmentTree{
      int n;
      vector<ll> node;
      SegmentTree(vector<ll>v){
         int sz = v.size();
         n = 1;while(n < sz)n*=2;
         node.resize(2*n-1,0);
         for(int i=0;i<sz;i++)node[i+n-1]=v[i];
         for(int i=n-2;i>=0;i--)node[i]=node[2*i+1]+node[2*i+2];
      }
      void update(ll x,ll val){
         x+=(n-1);
         node[x]=val;
         while(x>0){
            x=(x-1)/2;
            node[x]=node[2*x+1]+node[2*x+2];
         }
      }
};

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

   int N,K;
   cin>>N>>K;
   vector<pair<ll,ll> >sushi;
   for(int i=0;i<N;i++){
      ll value,kind;
      cin>>kind>>value;
      sushi.push_back({value,kind});
   }
   sort(rrng(sushi));
   //for(auto it:sushi)cout<<it.first<<" "<<it.second<<endl;
   ll fx = 0;
   ll x = 0;
   vector<bool>usedx(N+1,false);
   vector<ll>firstnum;
   //for(auto it:sushi)cout<<it.first<<" "<<it.second<<endl;
   //cout<<endl;
   for(int i=0;i<K;i++){
      if(!usedx[sushi[i].second]){
         x++;
         firstnum.insert(firstnum.begin(),sushi[i].first);
      }
      else {
         firstnum.insert(firstnum.end(),sushi[i].first);
      }
      usedx[sushi[i].second]=true;
   }

   vector<ll>new_sushi;
   for(auto it:sushi){
      //cout<<it.second<<endl;
      if(!usedx[it.second])new_sushi.push_back(it.first);
      usedx[it.second]=true;
   }
   //cout<<fx<<endl;

   //for(auto it:firstnum)cout<<it<<endl;
   //for(auto it:sushi)cout<<it.first<<" "<<it.second<<endl;

   SegmentTree seg(firstnum);
   ll Max = 0;

   for(int i=0;i+x<=K;i++){
      if(i!=0){
         if(i-1<new_sushi.size())seg.update(firstnum.size()-i,new_sushi[i-1]);
         else continue;
      }
      ll res = seg.node[0];
      res+=(i+x)*(i+x);
      Max = max(Max,res);
      //cout<<i<<" "<<res<<endl;
      //for(int i=0;i<seg.n;i++)cout<<seg.node[seg.n-1+i]<<" ";
      //cout<<endl;
   }
   cout<<Max<<endl;
   return 0;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

vector<int> to[500000];
int tab[1005][1005];

int toID(int i, int j) {
    if (i>j) swap(i, j);
    return tab[i][j];
}

int dp[500000];
bool used[500000];
bool calculated[500000];

int dfs(int x) {
    if (used[x]) {
        if (!calculated[x]) return -1;
        return dp[x];
    }
    used[x] = true;
    int now = 1;
    for (int e: to[x]) {
        int res = dfs(e);
        if (res<0) return -1;
        now = max(res+1, now);
    }
    dp[x] = now;
    calculated[x] = true;
    return dp[x];
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) rep(j, n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }
    int id = 0;
    rep(i, n) rep(j, n) {
        if (i<j) tab[i][j] = id++;
    }
    rep(i, n) {
        rep(j, n-1) {
            a[i][j] = toID(i, a[i][j]);
        }
        rep(j, n-2) {
            to[a[i][j]].push_back(a[i][j+1]);
        }
    }

    
    int ans = 0;
    rep(i, id) {
        int res = dfs(i);
        ans = max(ans, res);
        if (res==-1) {
            cout << "-1" << endl;
            return 0;
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38400
N=int(input())
ans = 0

if N <= 9:
    ans=N
elif N<=99:
    ans=9
elif N<=999:
     ans=N-100+1+9
elif N<=9999:
    ans=999-100+1+9
elif N<=99999:
    ans=N-10000+1+999-100+1+9
else:
    ans=99999-10000+1+999-100+1+9

print(ans)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
cs = [A[0]] + [0] * (N - 1)
a = 0
b = 0
for i in range(N - 1):
  cs[i + 1] = cs[i] + A[i + 1]
temp = 0
for i in range(N):
  if i % 2:
    if cs[i] + temp >= 0:
      a += abs(cs[i] + temp) + 1
      temp -= abs(cs[i] + temp) + 1
  else:
    if cs[i] + temp <= 0:
      a += abs(cs[i] + temp) + 1
      temp += abs(cs[i] + temp) + 1
temp = 0
for i in range(N):
  if i % 2:
    if cs[i] + temp <= 0:
      b += abs(cs[i] + temp) + 1
      temp += abs(cs[i] + temp) + 1
  else:
    if cs[i] + temp >= 0:
      b += abs(cs[i] + temp) + 1
      temp -= abs(cs[i] + temp) + 1
print(min(a, b))

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

int main() {
  long long N;
  cin >> N;
  string ans;
  while (N) {
    --N;
    ans += N % 26 + 'a';
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


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

const int mod = 1000000007;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

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

  int n = s.size();

  mint ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if(s[i] == '1') {
      mint two = 2;
      mint three = 3;
      ans += two.pow(cnt) * three.pow(n - i - 1);
      cnt++;
    }
  }
  ans += mint(2).pow(cnt);
  cout << ans.x << '\n';
}

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

int main(void)
{
    long long N, K;
    map<long long, long long> a_map;
    // N回配列に挿入を行う
    // K番目に小さい値を求める
    cin >> N >> K;
    long long temp = 0;
    for (int i = 0; i < N; i++)
    {
        long long a, b;

        cin >> a >> b;
        if(0 < a_map.count(a))
        {
            a_map[a] = a_map[a]+b;
        }
        else
        {
            a_map[a] = b;
        }
    }
    long long ans = 0;
    for (auto x : a_map)
    {
        temp += x.second;
        // cout << x.first << ":" << x.second << endl;
        if (K <= temp)
        {
            ans = x.first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] after = s.split(",");
    for(int i=0;i<after.length-1;i++){        
      System.out.print(after[i]+" ");
    }
     System.out.println(after[after.length-1]);
  }
}


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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/


/**************************************/

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,m,k; cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll sum = 0;
    rep(i,m) sum += b[i];
    int last = m-1;
    ll ans = 0;
    ll now = 0;
    while(sum > k){
        sum -= b[last];
        last--;
    }

    ans = last + 1;
    rep(i,n){
        now += a[i];
        while(now + sum > k){
            if(last == -1) break;
            sum -= b[last];
            last--;
        }
        if(now + sum <= k){
            chmax(ans, (ll)i + 1 + last + 1);
        }
    }

    cout << ans << endl;

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 6316
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1 << 30);

class Edge {
    public:
        int w, t;
        Edge() {}
        Edge(int w, int t) : w(w), t(t) {}
};

vector<Edge> G[MAX];
int d[MAX], n;

void bfs(int s)
{
    for (int i = 0; i != n; ++i) d[i] = INFTY;
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    int u;

    while (!Q.empty())
    {
        u = Q.front();
        Q.pop();
        for (int i = 0; i != G[u].size(); ++i)
        {
            Edge e = G[u][i];
            if (d[e.t] == INFTY)
            {
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve()
{
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for (int i = 0; i != n; ++i)
    {
        if (d[i] == INFTY) continue;
        if (d[i] > maxv)
        {
            maxv = d[i];
            tgt = i;
        }
    }
    bfs(tgt);
    maxv = 0;
    for (int i = 0; i != n; ++i)
    {
        if (d[i] == INFTY) continue;
        maxv = max(d[i], maxv);
    }

    cout << maxv << endl;
}

int main()
{
    int s, t, w;
    cin >> n;
    for (int i = 1; i != n; i++)
    {
        cin >> s >> t >> w;
        G[s].push_back(Edge(w, t));
        G[t].push_back(Edge(w, s));
    }
    solve();
    return 0;
}


Measured memory_bytes: 9928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005,mod=1e9+7;
int n,h[N],f[N][N],g[N],size[N];
struct edge{
	int to,next;
}e[N*2];
void addedge(int x,int y){
	static int cnt;
	e[++cnt]=(edge){y,h[x]};h[x]=cnt;
}
void dfs(int x,int fa){
	static int tmp[N];
	f[x][1]=size[x]=1;
	for(int i=h[x];i;i=e[i].next){
		int y=e[i].to;
		if(y==fa)continue;
		dfs(y,x);
		for(int j=1;j<=size[x]+size[y];j++)tmp[j]=0;
		for(int j=1;j<=size[x];j++)
			for(int k=1;k<=size[y];k++){
				tmp[j+k]=(tmp[j+k]+(ll)f[x][j]*f[y][k])%mod;
				tmp[j]=(tmp[j]-(ll)f[x][j]*f[y][k]%mod*g[k])%mod;
			}
		memcpy(f[x],tmp,sizeof(tmp));
		size[x]+=size[y];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);addedge(y,x);
	}
	g[0]=1;
	for(int i=2;i<=n;i+=2)g[i]=(ll)g[i-2]*(i-1)%mod;
	dfs(1,0);
	int ans=0;
	for(int i=0;i<=n;i++)ans=(ans+(ll)f[1][i]*g[i])%mod;
	cout<<(ans+mod)%mod<<"\n";
}

Measured memory_bytes: 98560
f = True
cnt = 0
l = [0,0,0]
while f:
    t = [int(s) for s in input().split()]
    t.sort()
    if t[0]+t[1] <= t[2]:
        f = False
        break
    if t[0]**2+t[1]**2 > t[2]**2:
        l[0]+=1
    elif t[0]**2+t[1]**2 == t[2]**2:
        l[1]+=1
    else:
        l[2]+=1
print(sum(l),l[1],l[0],l[2])
    


Measured memory_bytes: 5608
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    int a,b; cin >> a >> b;
    int ans;
    if(13<=a) ans = b;
    if(6<=a && a<=12) ans = b/2;
    if(a<=5) ans = 0;
    
    cout << ans << endl;
    


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int a,b,c,x,y;
  cin>>a>>b>>c;
  x=4*a*b;
  y=c-a-b;
  if(y<0){
    cout<<"No";
    return 0;
  }
  y=y*y;
  if(x<y){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

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

 int main() {
   int N, M, sum = 0;
   cin >> N >> M;

   vector<int> A(N);

   rep(i, 0, N) {
     cin >> A.at(i);
     sum += A.at(i);
   }

   sort(A.begin(), A.end(), greater<int>());

   if (A.at(M - 1) * 4 * M >= sum) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  vector<double> dp(n + 1, 0.0);
  dp[0] = 1.0;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      dp[j + 1] += dp[j] * p[i];
      dp[j] = dp[j] * (1.0 - p[i]);
    }
  }
  double res = 0.0;
  for (int i = n / 2 + 1; i <= n; i++) {
    res += dp[i];
  }
  cout << fixed << setprecision(10) << res << "\n";
  return 0;
}


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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n <= k) {
    cout << x * n << endl;
  }
  else {
    cout << x * k + y * (n - k) << endl;
  }  
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repe(i, a, b) for (ll i = (a); i <= (b); i++)

template<class T> inline bool chmax(T& a, T b){
  if (a < b) { a = b; return true; } return false;
}
ll INF = 1LL<<60;

int
main(void)
{
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;

  rep(i , 0, n - 2){
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }

  cout << ans << endl;

  return 0;
}

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

#define N 20

int main(void) {
	int n;
	int p[N + 1]; //添え字が参加者番号、値は釣った匹数
	int a, v;
	int ans;
	
	cin >> n;
	
	for(int i = 0; i < n; ++i) {
		cin >> a >> v;
		p[a] = v;
	}
	
	ans = 1;
	for(int i = 1; i <= n; ++i) {
		if(p[ans] < p[i]) ans = i;
	}
	
	cout << ans << ' ' << p[ans] << endl;
	
	return 0;
}


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

bool isPrime(int a){
	for(int i = 2; i * i <= a; i++) {
		if(a % i == 0) return false;
	}
	return true;
}

int main(){
	int n;
	scanf("%d", &n);
	int a, ans = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a);
		if(isPrime(a)) ans++;
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 3200
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    as <- concat <$> replicateM 3 getIntList
    n <- getInt
    bs <- replicateM n getInt
    let ans = [elem a bs| a <- as]
    putStrLn $ check ans

check [a1, a2, a3, a4, a5, a6, a7, a8, a9]
    | and [a1, a2, a3] = "Yes"
    | and [a4, a5, a6] = "Yes"
    | and [a7, a8, a9] = "Yes"
    | and [a1, a4, a7] = "Yes"
    | and [a2, a5, a8] = "Yes"
    | and [a3, a6, a9] = "Yes"
    | and [a1, a5, a9] = "Yes"
    | and [a3, a5, a7] = "Yes"
    |otherwise = "No"

Measured memory_bytes: 380
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


A, B, C = MI()
if (A == B and B != C) or (A != B and B == C) or (A == C and B != C):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>


#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  int a;
  scanf("%d", &a);

  int output = a + (int)pow(a, 2) + (int)pow(a, 3);

  printf("%d\n", output);
  return 0;
}


Measured memory_bytes: 2596
#!/usr/bin/env python
# encoding: utf-8

from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        for i in range(array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(map(str, unsorted_array)))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()

Measured memory_bytes: 7656
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  s <- getLine
  p <- getLine
  putStrLn $ if solve s p then "Yes" else "No"

solve :: String -> String -> Bool
solve s p = p `isInfixOf` (s ++ s)



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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  int64_t answer=0;
  
  int64_t r;
  r= N % (A+B);
  
  if(r >= A)
  answer += (N/(A+B))*A + A;
  else
  answer += (N/(A+B))*A + r ;
  
  cout << answer << endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;
typedef long long ll;

struct Sushi
{
	ll pos;
	ll nut;
};

const int maxn = 100005;
int N;
ll C;
Sushi A[maxn], B[maxn];
ll pfxA[maxn], pfxB[maxn];
ll maxA[maxn];
ll maxA2[maxn];

int main()
{
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	//freopen("input.in","r",stdin);
	cin >> N >> C;
	for (int i = 1; i <= N; i++) {
		ll xi, vi; cin >> xi >> vi;
		A[i] = {xi,vi};
		B[i] = {xi,vi};
	}
	B[N+1] = {C,0};
	for (int i = 1; i <= N; i++) {
		pfxA[i] = pfxA[i-1] + A[i].nut;
		pfxB[N-i+1] = pfxB[N-i+2] + B[N-i+1].nut;
	}
	//calculate max A
	for (int i = 1; i <= N; i++) {
		maxA[i] = max(maxA[i-1],pfxA[i]-A[i].pos);
		maxA2[i] = max(maxA2[i-1],pfxA[i]-2*A[i].pos);
		//cout << maxA[i] << '\n';
	}
	//calculate in O(n^2) maximum
	ll ans = 0;
	for (int j = N+1; j > 0; j--) {
		//cout << pfxB[j] << ' ' << (C - B[j].pos) << '\n';
		ll T = maxA[j-1] + pfxB[j] - 2*(C - B[j].pos);
		ans = max(ans,T);
		ll T2 = maxA2[j-1] + pfxB[j] - (C-B[j].pos);
		ans = max(ans,T2);
		/*
		for (int i = 0; i < j; i++) {
			ll OA = A[i].pos, OB = C - B[j].pos;
			ll d = OA + OB + min(OA,OB);
			ll nut = pfxA[i] + pfxB[j];
			ll T = nut - d;
			ans = max(ans,T);
			//cout << A[i].pos << ' ' << A[i].nut << '\n';
			//cout << B[j].pos << ' ' << B[j].nut << '\n';
			//cout << T << "\n\n";
		}
		*/
	}
	//output ans
	cout << ans << '\n';
	
	
	
	
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void){
    int b[3];
    int fr,to,tmp;
    char buf[8];
    
    b[2]=1; b[1]=b[0]=0;
    while (scanf("%s", buf)!=EOF){
        fr = buf[0]=='A'?2:buf[0]=='B'?1:0;
        to = buf[2]=='A'?2:buf[2]=='B'?1:0;
        if (fr==to) continue;
        tmp = b[fr]; b[fr] = b[to]; b[to]=tmp;
    }
    printf("%c\n", b[2]?'A':b[1]?'B':'C');

    return 0;
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<ll,ll>
#define maxn 100009
using namespace std;
vector<pii> adj[maxn];
ll dis[maxn],vis[maxn];
void addedge(ll a,ll b,ll c){
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
}
void dfs(int x,int dist){
    vis[x]=1;
    for(auto e: adj[x]){
        if(vis[e.first]==-1){
            dis[e.first]=dist+e.second;
            dfs(e.first,dist+e.second);
        }
    }
} 
int main(){
    ios::sync_with_stdio(false);
    memset(vis,-1,sizeof vis);
    int n;
    cin>>n;
    int k=n-1;
    int ans[maxn];
    while(k--){
        ll a,b,c;
        cin>>a>>b>>c;
        addedge(a,b,c);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
        if(dis[i]%2==0)cout<<"0"<<endl;
        else cout<<"1"<<endl;
    }
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

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

using namespace std;

struct st {
	int dm{};
	int cs{};
	bool operator<(const st& o) {
		return dm < o.dm;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	int hp;
	int n;
	cin >> hp >> n;
	vector<st> at(n);
	for (int i = 0; i < n; i++) {
		cin >> at[i].dm;
		cin >> at[i].cs;
	}
	vector<int> cost(hp + 1, 0);
	for (int i = 1; i <= hp; i++) {
		int q = numeric_limits<int>::max();
		for (int j = 0; j < n; j++) {
			if (at[j].dm >= i and q > at[j].cs)
				q = at[j].cs;
		}
		for (int j = 1; j <= (i >> 1); j++)
			q = min(q, cost[j] + cost[i - j]);
		cost[i] = q;
	}
	cout << cost[hp];
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[200005];

ll comb(ll a, ll b) {
  ll ue = frac[a];
  ll shita1=1, shita2=1;
  ll tmpshita1, tmpshita2;
  ll h=mod-2;
  ll two;
  while(h>0) {
    two = 1;
    tmpshita1 = frac[b];
    tmpshita2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita2 *= tmpshita2;
      tmpshita1 %= mod;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<200005;++i) {
    frac[i] = frac[i-1]*i%mod;
  }
  ll N, M, K;
  cin>>N>>M>>K;
  ll dist = 0;
  for(ll i=0;i<N;++i) {
    dist += (N-1-i)*(N-i)/2%mod*M%mod*M%mod;
    dist %= mod;
    dist += i*(i+1)/2%mod*M%mod*M%mod;
    dist %= mod;
  }
  for(ll j=0;j<M;++j) {
    dist += (M-1-j)*(M-j)/2%mod*N%mod*N%mod;
    dist %= mod;
    dist += j*(j+1)/2%mod*N%mod*N%mod;
    dist %= mod;
  }
  ll h = mod - 2;
  ll two;
  ll tmp;
  while(h>0) {
    two = 1;
    tmp = 2;
    while(2*two<h) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    h -= two;
    dist *= tmp;
    dist %= mod;
  }
  cout<<dist*comb(N*M-2, K-2)%mod<<endl;
}



Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<ll>;
using p = pair<ll,ll>;
using m = map<ll,ll>;
using vv = vector<v>;
int gcd(int a,int b){
    return b==0? a :gcd(b,a%b);
}


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << (c%gcd(a,b)==0?"YES":"NO");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	long int N;
	scanf("%ld",&N);
	int K;
	scanf("%d",&K);
	int i;
	int a,b;
	for(i=0;i<K;i++){
		scanf("%d %d",&a,&b);
		if(a<=(N+1)/2&&b<=(N+1)/2){
			printf("%d\n",a>b?(b-1)%3+1:(a-1)%3+1);
		}
		else if(a<=(N+1)/2){
			printf("%ld\n",a>N-b+1?(N-b)%3+1:(a-1)%3+1);
		}
		else if(b<=(N+1)/2){
			printf("%ld\n",N-a+1>b?(b-1)%3+1:(N-a)%3+1);
		}
		else{
			printf("%ld\n",a>b?(N-a)%3+1:(N-b)%3+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt(); 
        int x = sc.nextInt(); 
        
        WaterBottle wb = new WaterBottle(a, b, x);
        
        System.out.println(wb.search());
        
    }
    
}

class WaterBottle {
    private int a;
    private int b;
    private int x;
    
    public WaterBottle(int a, int b, int x){
        this.a = a;
        this.b = b;
        this.x = x;
    }
    
    public boolean judge(double Theta){
        
        double cos = Math.cos(Math.toRadians(Theta));
        double sin = Math.sin(Math.toRadians(Theta));
        
        if( (a * cos / sin) <= (double)b){
            return (  a * a * b - cos * a * a * a / sin / 2  >= (double)x);
        } else{
            return (a * b * b * sin / cos / 2 >= (double)x);
        }
        
    }
    
	public double search() {
		double left = 0;
		double right = 90;
		for(int i = 0; i <= 100; i++){
			double mid = (left + right) / 2;
			
			if(judge(mid)){
			    // 溢れなかったのでより小さい角度
			    right = mid;
			}else{
			    // 溢れたのでより大きい角度
			    left = mid;
			}
		}
		return 90.0 - right;
	}
    
}



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

int main()
{
    string w[100];
    int n,i,j,t,ans=1;
    cin >>n;
    for (i=0;i<n;i++){
        cin >>w[i];
    }
    for (i=0;i<n;i++){
        t=i;
        while (t>=0){
            if (w[i]==w[t] && i!=t){
                ans=0;
            }
            t--;
        }
    }
    for (i=0;i<n-1;i++){
        if (w[i][w[i].size()-1]!=w[i+1][0]){
            ans=0;
        }
    }
    if (ans==0){
        cout <<"No"<< endl;
    }
    else{
        cout <<"Yes"<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# encoding: utf-8

import copy


class Solution:
    def stable_sort(self):
        # write your code here
        array_length = int(input())
        array = [str(x) for x in input().split()]
        array_2 = copy.deepcopy(array)

        bubble_result = self.bubble_sort(array=array, array_length=array_length)
        selection_result = self.selection_sort(array=array_2, array_length=array_length)

        # check whether selection sort is stable
        if bubble_result == selection_result:
            print("Stable")
        else:
            print("Not stable")

    @staticmethod
    def selection_sort(array, array_length):
        # selection sort
        selection_count = 0
        for i in range(array_length):
            min_j = i
            for j in range(i, array_length):
                if array[j][1] < array[min_j][1]:
                    min_j = j
            array[i], array[min_j] = array[min_j], array[i]
            if i != min_j:
                selection_count += 1

        result = " ".join(map(str, array))
        print(result)
        return result

    @staticmethod
    def bubble_sort(array, array_length):
        flag, bubble_count, cursor = 1, 0, 0
        while flag:
            flag = 0
            for j in range(array_length - 1, cursor, -1):
                if array[j][1] < array[j - 1][1]:
                    array[j], array[j - 1] = array[j - 1], array[j]
                    flag = 1
                    bubble_count += 1
        cursor += 1
        result = " ".join(map(str, array))
        print(result)
        print("Stable")
        return result


if __name__ == '__main__':
    solution = Solution()
    solution.stable_sort()

Measured memory_bytes: 8140
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	ll h, w, n;
	cin >> h >> w >> n;

	map<pair<int, int>, int> m;
	vector<ll> ans(10);
	int x, y;
	rep(i, n){
		cin >> x >> y;
		rep(j, 3)
			rep(k, 3)
			m[make_pair(x - 1 + j, y - 1 + k)]++;
	}

	for (auto z : m){
		if(z.first.first > 1 && z.first.first < h && z.first.second > 1 && z.first.second < w) ans[z.second]++;
	}
	ans[0] = (h - 2) * (w - 2);
	rep(i, 9) ans[0] -= ans[i + 1];

	rep(i, 10) cout << ans[i] << endl;
}


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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 56704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] a = new int[n+1][n+2];
		for(int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			int u = Integer.parseInt(str[0]);
			for(int j = 2; j < str.length; j++){
				//a[u][0] = number of visited nodes 
				a[u][j-1] = Integer.parseInt(str[j]);
			}
		}
		
		int[] d = new int[n+1];
		int[] f = new int[n+1];
		int t = 0; // time
		int[] st = new int [n]; // stack
		int p = 0; // stack pointer
		
		for(int i = 1; i <= n; i++){
			if(d[i] != 0){
				continue;
			}
			p = 0;
			st[p] = i; // first node
			
			while(p >= 0){
				int pn = st[p]; // present node
				if(d[pn] == 0){
					t += 1;
					d[pn] = t;
				}
				// nn?????°???????
				int nn;
				do{
					// increase visited num
					a[pn][0] += 1;
					nn = a[pn][a[pn][0]];
				}while(d[nn] != 0);
				
				if(nn != 0){
					// the present node has unvisited adjacent node(s)
					// push the next node to the stack
					p += 1;
					st[p] = nn;
				}else if(f[pn] == 0){
					// does not have
					// write finish time
					t += 1;
					f[pn] = t;
					// pop from the stack
					p -= 1;
				}else{
					p -= 1;
				}
				
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i <= n; i++){
			sb.append(i + " " + d[i] + " " + f[i] + "\n");
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 24248
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>

using namespace std;

#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define ctoi(c) c - '0'
#define tos(s) to_string(s)

typedef long long ll;


int main() {
    int n;
    cin >> n;
    int p = 0;
    int m[n+1];
    rep(i,n) {
        m[i] = 0;
    }
    rep(i,1000) {
        rep(j,1000) {
            rep(k,1000) {
                p = i*i + j*j + k*k + i*j + j*k + k*i;
                if (p <= n) {
                    m[p]++;
                } else {
                    break;
                }
            }
        }
    }

    rep(i,n) {
        cout << m[i] << endl;
    }

    return 0;
}

/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC                                                                              
                                   ******,  .,, .,, ,,,    ****.**              
                                   ** . .,,,,,,,,,,,,,,,,,,,,,. .,*             
                                   **,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.            
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                    ****      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,      
              ***************,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,    
         ********************,,,,,,,,,,,,,,@@@,,,,,,,,,,,/@@@,,,,,,,,,,,,,,,    
        ******************,,,,,,,,,,,,,,,,,,(,,.         ,,,,,,,,,,,,,,,,,,,    
       ********************,,,,,,,,,,,*,,,,,.     %&&&     .,,,,*,,,,,,,,,,,,.  
       ***,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,               ,,,,,,,,,,,,,,,,,   
       ,,,,,,,,,,,,,,,,,,,**,,,,,,,,,,.......      ##(     ........,,,,,,,,,,.  
     .,,,,,,,,,,,,,,,,,,**,,,,,,,,,,..............    ..............,,,,,,,,    
    .,,,,,,,,,,,,,,,,,,,**,,,,,,,,,.................................,,,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,***,,,,,,,....................................,,,,,,,,,  
   ,,,,,,,,,,,,,,,,,,,,**,,,,,,,,.....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,**,,,,,,,,....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,,,     
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,.,,,,,     
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,        
     ,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................................,,,        
      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,          
       ..,,,,,,,,,,,,,,,,,,,,,,,,,,.................................,           
       .........**.....       ,,,,,..............................               
        .......*......                  ****,**,       ,..****                  
        .......*,....                   .......        ......                   
          .......*....                   .....          .....                   
                                         ......          .....                  
*/

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<int> t(n+2);
  vector<int> v(n+2);
  rep(i,n)cin>>t[i+1];
  rep(i,n)cin>>v[i+1];
  int T=0;
  vector<int> l(n+2);
  vector<int> r(n+2);
  rep(i,n) {
    l[i+1]=T;
    r[i+1]=T+t[i+1];
    T+=t[i+1];
  }
  double V=0;
  vector<double> maxv(400000);
  for(int tt=1; tt<=2*T; tt++) {
    double ttt = 0.5*tt;
    double pv=V;
    V+=0.5;
    rep(i,n+2) {
      if(ttt<l[i]) {
        V=min(V,v[i]+(l[i]-ttt));
      } else if(l[i]<=ttt&&ttt<=r[i]) {
        V=min(V,static_cast<double>(v[i]));
      } else {
        V=min(V,v[i]+(ttt-r[i]));
      }
    }
    maxv[tt]=V;
    //cout << "t="<<ttt<<",V="<<V<<endl;
  }
  maxv[2*T]=0;
  V = 0;
  for(int tt=2*T-1; tt>=0;tt--) {
    double ttt=0.5*tt;
    double pv = V;
    V+=0.5;
    rep(i,n+2) {
      if(ttt<l[i]) {
        V=min(V,v[i]+(l[i]-ttt));
      } else if(l[i]<=ttt&&ttt<=r[i]) {
        V=min(V,static_cast<double>(v[i]));
      } else {
        V=min(V,v[i]+(ttt-r[i]));
      }
    }
    maxv[tt]=min(maxv[tt],V);
  }
  double ans=0;
  repeat(tt, 1,2*T+1) {
    ans+=(maxv[tt]+maxv[tt-1])*0.5*0.5;
    //cout << 0.5*tt<< " " << maxv[tt]<<endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
bool flg[60000];

int main() {
	memset(flg, 1, sizeof(flg));
	flg[1] = 0;
	for(int i = 2; i <= 55555; i++) {
		for(int j = 2; j <= sqrt(i); j++) {
			if(i % j == 0) {
				flg[i] = 0;
				break;
			}
		}
	}
	flg[2] = 0;
	//for(int i = 1; i <= 100; i++) if(flg[i]) printf("%d ", i);
	scanf("%d", &n);
	for(int i = 1; i <= 55555; i++) {
		if(n == 0) break;
		if(flg[i] && i % 10 == 7) {
			printf("%d ", i);
			n--;
		}
	}
	printf("\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc107_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			List<List<char>> list = new List<List<char>>();
			for (int i = 0; i < x[0]; i++)
			{
				list.Add(new List<char>());
				string s = Console.ReadLine();
				for (int j = 0; j < x[1]; j++)
				{
					list[i].Add(s[j]);
				}
			}
			for (int i = x[0] - 1; i >= 0; i--)
			{
				bool flag = list[i][0] == '.';
				for (int j = 1; j < x[1]; j++)
				{
					if (list[i][j - 1] != list[i][j]) flag = false;
				}
				if (flag) { list.RemoveAt(i); x[0]--; }
			}
			for (int i = x[1] - 1; i >= 0; i--)
			{
				bool flag = list[0][i]=='.';
				for (int j = 1; j < x[0]; j++)
				{
					if (list[j - 1][i] != list[j][i]) flag = false;
				}
				if (flag)
				{
					foreach (var item in list)
					{
						item.RemoveAt(i);
					}
				}
			}
			foreach (var item in list)
			{
				foreach (var ret in item)
				{
					Console.Write(ret);
				}
				Console.WriteLine();
			}
		}
	}
}

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

int main () {
  int a;
  string s;
  cin >> a >> s;
  
  if (a >=  3200) {
    cout << s << endl;
  }
  if (a < 3200) {
    cout << "red" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

stones = [int(i) for i in input().split()]

def solve(stones, N, K):
    dp = [0] + [float('inf')] * (N-1)

    for i in range(N-1):
        k = 1
        while k <= K and (i + k) < N:
            dp[i+k] = min(dp[i+k], dp[i] + abs(stones[i] - stones[i+k]))
            k += 1
    
    return dp[-1]

print(solve(stones, N, K))





Measured memory_bytes: 54752
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){

    ll n;
    cin >> n;

    vector<ll> a(n);
    for(int i = 0; i< n; i++){
        cin >> a.at(i);
    }

    ll max1 = 0;
    ll max2 = 0;



    for(int i = 0; i< n; i++){
        if(max1< a.at(i)){
            max1 = a.at(i);
        }
    }

    for(int i = 0; i< n; i++){
        if(max2< a.at(i) && a.at(i)!= max1){
            max2 = a.at(i);
        }
    }


    ll max1count;

    max1count = count(a.begin(),a.end(),max1);

    if(max1count >=2){
        for(int i = 0; i< n; i++){
            cout << max1 << endl;
        }
    }else{
        for(int i = 0; i< n; i++){
            if(a.at(i) != max1){
                cout << max1 << endl;
            }else{
                cout << max2 << endl;
            }
        }
    }
}

Measured memory_bytes: 3200
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int x1[n], x2[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &x1[i]);
        x2[n-1-i] = x1[i];
    }
    for (int j=0; j<n; j++) {
        printf("%d", x2[j]);
        if (j == n - 1) {break;}
        putchar(' ');
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2052