akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<stdlib.h>

using namespace std;


int main()
{	
	long long caseNum;
	while(cin>>caseNum)
	{
		if(caseNum == 0) break;
		else
		{	
			int *table;
			table = (int *)malloc(10000000*sizeof(int));
			memset(table,0,10000000);	
			long long big = -100;
			long long small = 100;

			for(long i = 0;i < caseNum; i ++)
			{	
				long long deal;
				cin>>deal;
				if(big < deal) big = deal;
				if(small > deal) small = deal;

				table[deal] ++;
			}
			
			long threadhold = caseNum / 2;
			//cout<<"t "<<threadhold<<endl;

			long j;
			for( j = small; j <= big; j ++)
			{
				//cout<<j<<" "<<table[j]<<endl;
				if(table[j] > threadhold) 
				{
					cout<<j<<endl;
					break;
				}
			}
			if(j > big)
			{
				cout<<"NO COLOR"<<endl;
			}
			free(table);
		}
	}
	return 0;
}

Measured memory_bytes: 12300
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define ll int64_t
const ll MOD = 1e9 + 7;


int main()
{

  ll n, m;
  cin >>  n ;

  vector<long> a(n);

  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  ll ans = 0;

  map<long,long> nummp;

  // long num[1000000000];


  for (int i = 0; i < n; ++i){
    nummp[a[i]]++;
  }

  // for (int i = 0; i < 1000000000; ++i){
  //   if (num[i]%2 ==1)ans++;
  // }

  for(auto v : nummp){
    if (v.second%2 == 1)ans++;
  }

  cout << ans <<endl;


  return 0;
}


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

using namespace std;

set<int> Pasta, Juice;

int main() {
	int price;

	for (int i = 0; i < 3; ++i) {
		cin >> price;
		Pasta.insert(price);
	}
	for (int i = 0; i < 2; ++i) {
		cin >> price;
		Juice.insert(price);
	}
	cout << *Pasta.begin() + *Juice.begin() - 50 << endl;
	
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define Nmax 500005
using namespace std;

int uz[Nmax], n, m, x, y;
vector<int> ans, v[Nmax];

void dfs(int nod){
    ans.push_back(nod);
    uz[nod] = 1;
    for (auto it : v[nod]){
        if (uz[it]) continue;
        dfs(it);
        return;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=1;i<=m;i++){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1);
    reverse(ans.begin(),ans.end());
    ans.pop_back();
    dfs(1);
    cout << ans.size() << '\n';
    for (auto it : ans) cout << it << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 19576
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define show(x) std::cerr << #x << "=" << x << std::endl
using namespace std;
typedef long long ll;
const double eps=1e-8;
const int maxn = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int t;
int n,q;
int a[maxn],cnt[maxn];
int main()
{
    memset(cnt,0,sizeof cnt);
    scanf("%d",&n);
    ll sum = 0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
        sum+=a[i];
    }
    int b,c;
    scanf("%d",&q);
    for(int i=1;i<=q;++i)
    {
        scanf("%d%d",&b,&c);
        sum+=(c-b)*cnt[b], cnt[c]+= cnt[b],cnt[b] = 0 ;
        printf("%lld\n",sum);
    }
    return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    auto cmp = [](pair<int,int> l, pair<int,int> r){
        if(l.first != r.first) return l.first > r.first;
        else return l.second < r.second;
    };
    priority_queue<pair<int,int>, vector<pair<int,int>>, decltype(cmp)> works{cmp};
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        works.push({a,b});
    }

    int ans = 0;
    priority_queue<int> workable;
    for(int i=m-1;i>=0;--i) {
        if(works.empty() && workable.empty()) break;

        while(!works.empty() && works.top().first+i <= m)
        {
            workable.push(works.top().second);
            works.pop();
        }     
        
        if(!workable.empty())
        {
            ans += workable.top();
            workable.pop();
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    double n,m,d;
    cin>>n>>m>>d;
    if(d==0)cout<<setprecision(15)<<(m-1)/(n)<<endl;
    else cout<<setprecision(15)<<(n-d)*2*(m-1)/(n*n)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<string>>result;
  vector<int> flg(n,0);
  result.resize(n);
  int acnum = 0;
  for(int i = 0; i < m; i++){
    int p;
    string s;
    cin >> p >> s;
    result[p-1].push_back(s);
    if(flg[p-1] == 0 && s == "AC"){
      flg[p-1] = 1;
      acnum++;
    }
  }
  int wanum = 0;
  for(int i = 0; i < n; i++){
    int wacnt = 0;
    for(unsigned int j = 0; j < result[i].size(); j++){
      if(result[i][j] == "AC"){
        wanum += wacnt;
        break;
      }
      if(result[i][j] == "WA"){
        wacnt ++;
      }
    }
  }
  cout << acnum << " " << wanum;
  return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
const int N=500;
typedef long long ll;
const ll inf=1e15+7;
ll arr[N][N];
ll brr[N][N];
int main(){
	ll n,m,l;
	cin>>n>>m>>l;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(i!=j) arr[i][j]=brr[i][j]=inf;
		}
	
	ll x,y,z;
	
	for(int i=1;i<=m;i++){
		scanf("%lld%lld%lld",&x,&y,&z);
		arr[x][y]=z;
		arr[y][x]=z;
	}
	
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				arr[i][j]=min(arr[i][j],arr[i][k]+arr[k][j]);
	}
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(arr[i][j]<=l&&i!=j) brr[i][j]=1; 
		}
	
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				brr[i][j]=min(brr[i][j],brr[i][k]+brr[k][j]);
	}
	
	int q;
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(brr[a][b]>=inf) cout<<-1<<endl;
		else cout<<brr[a][b]-1<<endl;
	}	
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
const double pi=3.14159265358979323846;
using namespace std;
int main()
{
	double a,b,h,m;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	h=h*30+30*(m*1.0/60);m=m*6;double o=abs(h-m);//cout<<o<<endl;
	double c=a*a+b*b-2*a*b*1.0*cos(pi*o*1.0/180.0);
//	cout<<cos(pi*o*1.0/180.0)<<endl;
	printf("%.20lf",sqrt(c));
}

Measured memory_bytes: 4200
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, u, v) = readLine.trim.split(' ').map(_.toInt)
  val shrine = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  for (_ ← 1 until n){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    shrine(a) ::= b
    shrine(b) ::= a
  }
  val subTreeSize = Array.tabulate(n){_ ⇒ 1}
  val childCount = Array.tabulate(n){_ ⇒ 0}
  val prevNode = calPrevNode(shrine, u - 1)
  for (i ← prevNode) childCount(i) += 1
  var stack = childCount.indices.filter(p ⇒ childCount(p) == 0).toList
  while (stack.nonEmpty){
    val top = stack.head
    stack = stack.tail
    childCount(prevNode(top)) -= 1
    subTreeSize(prevNode(top)) += subTreeSize(top)
    if (childCount(prevNode(top)) == 0) stack ::= prevNode(top)
  }
  var current = v - 1
  while (subTreeSize(current) * 2 < n){
    current = prevNode(current)
  }
  if (subTreeSize(current) * 2 != n){
    println("No")
  }else {
    shrine(current) = shrine(current).filterNot(p ⇒ p == prevNode(current))
    shrine(prevNode(current)) = shrine(prevNode(current)).filterNot(p ⇒ p == current)
    if (hasSinglePath(shrine, u - 1) && hasSinglePath(shrine, v - 1)) println("Yes")
    else println("No")
  }

  def hasSinglePath(forest: Array[List[Int]], start: Int): Boolean = {
    if (forest(start).length != 1) false
    else {
      @tailrec
      def sub(current: Int, prev: Int): Boolean = {
        forest(current).filterNot(_ == prev).length match {
          case 0 ⇒ true
          case 1 ⇒ sub(forest(current).filterNot(_ != prev).head, current)
          case _ ⇒ false
        }
      }
      sub(forest(start).head, start)
    }
  }

  def calPrevNode(tree: Array[List[Int]], root: Int): Array[Int] = {
    val result = Array.tabulate(tree.length){_ ⇒ -1}.also{arr ⇒ arr(root) = root}
    var stack: List[Int] = List(root)
    while (stack.nonEmpty){
      val top = stack.head
      stack = stack.tail
      for (next ← tree(top) if result(next) == -1){
        result(next) = top
        stack::=next
      }
    }
    result
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 177044
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, d[2];
    cin >> n >> d[0] >> d[1];

    VVI a(2*n, VI(2*n));
    REP(k,2){
        set<P> ng;
        REP(x,sqrt(d[k]) + 1){
            int y = sqrt(d[k] - x * x);
            if (x * x + y * y == d[k]){
                ng.insert(P(x, y));
                ng.insert(P(x, -y));
                ng.insert(P(-x, y));
                ng.insert(P(-x, -y));
            }
        }
        VVI visit(2*n, VI(2*n));
        REP(i,2*n) REP(j,2*n){
            if (visit[i][j]) continue;
            queue<P> que;
            que.push(P(i,j));
            while (!que.empty()){
                P p = que.front();
                que.pop();
                for (P q : ng){
                    int ii = p.first + q.first, jj = p.second + q.second;
                    if (ii < 0 || jj < 0 || ii >= 2 * n || jj >= 2 * n || visit[ii][jj]) continue;
                    visit[ii][jj] = 1;
                    if (((a[p.first][p.second] >> k) & 1) == 0) a[ii][jj] |= (1 << k);
                    que.push(P(ii,jj));
                }
            }
        }
    }

    VI cnt(4);
    REP(i,2*n) REP(j,2*n){
        cnt[a[i][j]]++;
    }
    int x = max_element(ALL(cnt)) - cnt.begin();

    int c = 0;
    REP(i,2*n) REP(j,2*n){
        if (a[i][j] == x){
            c++;
            cout << i << " " << j << endl;
        }
        if (c == n * n){
            i = 2 * n;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


// 最小全域有向木 O(EV)
// 1-index
const int MAXV = 10010;
const int MAXE = 10010;
const int MAXW = 2147483647;
struct Edge {
    int u, v, c;
    Edge(int x = 0, int y = 0, int z = 0) : u(x), v(y), c(z) {}
};
int V, E, root;
Edge edges[MAXE];
inline int newV() { return ++V; }
inline void addEdge(int u, int v, int c)
{
    edges[++E] = Edge(u, v, c);
}
bool con[MAXV];
int mnInW[MAXV], prv[MAXV], cyc[MAXV], vis[MAXV];
inline int DMST() {
    fill(con, con + V + 1, 0);
    int r1 = 0, r2 = 0;
    while (1) {
        fill(mnInW, mnInW + V + 1, MAXW);
        fill(prv, prv + V + 1, -1);
        for (int i = 1; i <= E; i++) {
            int u = edges[i].u, v = edges[i].v, c = edges[i].c;
            if (u != v && v != root && c < mnInW[v]){mnInW[v] = c; prv[v] = u;}
        }
        fill(vis, vis + V + 1, -1);
        fill(cyc, cyc + V + 1, -1);
        r1 = 0;
        bool jf = 0;
        for (int i = 1; i <= V; i++) {
            if (con[i]) continue;
            if (prv[i] == -1 && i != root) {
                return -1;
            }
            if (prv[i] > 0) r1 += mnInW[i];
            int s;
            for (s = i; s != -1 && vis[s] == -1; s = prv[s])
                vis[s] = i;
            if (s > 0 && vis[s] == i) {
                // get a cycle
                jf = 1; int v = s;
                do {
                    cyc[v] = s, con[v] = 1;
                    r2 += mnInW[v]; v = prv[v];
                } while (v != s);
                con[s] = 0;
            }
        }
        if (!jf) break;
        for (int i = 1; i <= E; i++) {
            int &u = edges[i].u;
            int &v = edges[i].v;
            if (cyc[v] > 0) edges[i].c -= mnInW[edges[i].v];
            if (cyc[u] > 0) edges[i].u = cyc[edges[i].u];
            if (cyc[v] > 0) edges[i].v = cyc[edges[i].v];
            if (u == v) edges[i--] = edges[E--];
        }
    }
    return r1 + r2;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int e;
    cin >> V >> e >> root;
    root++;
    for(int i = 0; i < e;i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a++; b++;
        addEdge(a, b, c);
    }
    cout << DMST() << endl;
    
    return 0;
}



Measured memory_bytes: 3308
N,X,Y = map(int, input().split())
cnt = [0]*N
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N):
    print(int(cnt[i]))




Measured memory_bytes: 3444
#include <stdio.h>

int main() {

  int a,N,i,j,A[100],count;

  while(1) {
    scanf("%d",&N);
    if(N<1 || 100<N) printf("error\n");
    else break;
  }

  while(1) {
    count = 0;
    for(i=0; i<N; i++) scanf("%d",&A[i]);
    for(i=0; i<N; i++) if(A[i]<0 || 100<A[i]) count++;
    if(count==0) break;
    else printf("error\n");
  }

  for(i=0; i<N-1; i++) {
    for(j=N-1; j>=0; j--) {
      if(A[j] < A[j-1]) {
        a = A[j];
        A[j] = A[j-1];
        A[j-1] = a;
        count++;
      }
    }
  }

  for(i=0; i<N; i++) {
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<string.h>

int main(){
  char d[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  char s[4];
  int i;
  scanf("%s",s);
  for(i=0;i<7;i++){
    if(strcmp(s,d[i])==0){
      printf("%d",7-i);
    }
  }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n, m;
	cin >> n >> m;
	string grid[n];
	For(i,n) {
		cin >> grid[i];
	}

	int dp[n+1][m+1];
	memset(dp, 0, sizeof dp);
	For(i,n) {
		For(j,m) {
			if (i == 0 && j == 0) {
				dp[i+1][j+1] = 1;
			} else if (grid[i][j] == '.') {
				dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
			}
		}
	}
	cout << dp[n][m] << nl;

	return 0;
}


Measured memory_bytes: 5248
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
A = l()
for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 32512
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,k;
int vt[11];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<k;i++) {
        int tmp; cin>>tmp;
        vt[tmp] = 1;
    }
    for(int i=n;i<=100001;i++) {
        int val = i;
        while(val) {
            if(vt[val % 10]) break;
            val /= 10;
        }
        if(val == 0) {
            cout<<i;
            return 0;
        }
    }
    return 0;
}

/*
god taekyu
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int n;
      cin>>n;
      int ctr=0;
      for(int i=1;i<=9;i++){
        if(n%i==0 && (n/i)<=9){
          ctr=1;
          break;
        }
      }
      
      if(ctr==0)
        cout<<"No";
      else
        cout<<"Yes";
      return 0;
    }

Measured memory_bytes: 256
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = abs(t0 - t)
    if abs(kyori - time) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 55;
const int M = 1e9 + 7;
ll dp[N][2];

void solve();

int main() {
  int t = 1;
  // int t;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  string l;
  cin >> l;
  ll n = (int)l.size();
  l = '$' + l;
  dp[0][0] = 1;
  dp[0][1] = 0;
  for (int i = 1; i <= n; ++i) {
    if (l[i] == '0') {
      // NOT same
      dp[i][0] = dp[i - 1][0];
      // same
      dp[i][1] = 3 * dp[i - 1][1];
    } else {
      // NOT same
      dp[i][0] = 2 * dp[i - 1][0];
      // same
      dp[i][1] = 3 * dp[i - 1][1] + dp[i - 1][0];
    }
    dp[i][0] %= M;
    dp[i][1] %= M;
  }
  cout << (dp[n][0] + dp[n][1]) % M;
}


Measured memory_bytes: 2044
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n),b(n);
    long long suma=0, sumb=0;
    for(int i=0;i<n;i++) {cin >> a[i]; suma+= a[i];}
    for(int i=0;i<n;i++) {cin >> b[i]; sumb+= b[i];}
    if(sumb > suma){cout << -1 << endl; return 0;}
    vector<long long> c(n);
    for(int i=0;i<n;i++) c[i] = a[i] - b[i];
    sort(c.begin(), c.end());
    long long ms=0,ps=0;
    int ans = 0;
    for(int i=0;i<n;i++){
        if(c[i] < 0){ ms -= c[i]; ans++;}
        else if(c[i] >= 0) break;
    }
    for(int i=n-1;i>=0;i--){
        if(ps >= ms) break;
        ps += c[i];
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
count=1
flag=0
for i in range(n-1):
  if flag==0:
    if a[i+1]<a[i]:
      flag=-1
    elif a[i+1]>a[i]:
      flag=1
  elif flag==1:
    if a[i+1]<a[i]:
      flag=0
      count+=1
  elif flag==-1:
    if a[i+1]>a[i]:
      flag=0
      count+=1
print(count)

Measured memory_bytes: 14224
#include <stdio.h>
#define N 200000
int main(){
  int n,i,ans,min;
  int A[N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  min=A[1];
  ans=A[2]-A[1];
  for(i=2;i<=n;i++){
    if(A[i]-min>ans) ans=A[i]-min;
    if(min>A[i]) min=A[i];
  }
  printf("%d\n",ans);
  return 0;
}

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

public class ABC0125_A3v9 {
    private static void Main(string[] args) {
        var inputs = new List<string>(){
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
        };
        Prepare(inputs);
    }

    private static void Prepare(List<string> inputs) {
        var length = int.Parse(inputs[0]);
        var numbers = inputs[1].Split()
            .Select(x => int.Parse(x))
            .OrderBy(n => n)
            .ToArray();
        Compute(length, numbers);
    }

    private static void Compute(int length, int[] numbers) {
        var candidateA = GetCandidateAgcdA(numbers);
        var candidateB = GetCandidateAgcdB(numbers);
        OutputAnswer(Math.Max(candidateA, candidateB).ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);

    private static int GetCandidateAgcdA(int[] numbers) {
        var standard = numbers[0];
        var tempAGCD = 1;

        for (int divisor = 1; divisor * divisor < standard; divisor++) {
            if (standard % divisor == 0) {
                tempAGCD = GetACD(tempAGCD, numbers, divisor);
                tempAGCD = GetACD(tempAGCD, numbers, standard / divisor);
            }
        }

        return tempAGCD;
    }
    private static int GetACD(int tempGCD, int[] numbers, int divisor) {
        if (tempGCD < divisor && IsACD(numbers, divisor))
            return divisor;
        else
            return tempGCD;
    }
    private static bool IsACD(int[] numbers, int divisor) {
        if (divisor <= 0) {
            return false;
        }

        var count = 0;

        foreach (var number in numbers) {
            if (number % divisor != 0) {
                count++;

                if (count > 1)
                    return false;
            }
        }

        return true;
    }
  
    private static int GetCandidateAgcdB(int[] numbers) {
        var tempGCD = numbers[1];

        for (int index = 2; index < numbers.Length; index++) {
            tempGCD = GetGcdFrom2Ints(tempGCD, numbers[index]);
        }
        return tempGCD;
    }
    private static int GetGcdFrom2Ints(int a, int b) => a > b ? CalcGCD(a, b) : CalcGCD(b, a);
    private static int CalcGCD(int a, int b) => b == 0 ? a : CalcGCD(b, a % b);
}


Measured memory_bytes: 28508
S = int(input())

if 0 < S // 100 <= 12 and 0 < S % 100<= 12:
    print("AMBIGUOUS")
elif 0 < S // 100 <= 12:
    print("MMYY")
elif 0 < S % 100 <= 12:
    print("YYMM")
else :
    print("NA")

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

int main(){
    long int H,sum=0;
    int i, count;
    cin >> H;
    
    for(count=0;H>0;count++) H = H/2;
    for(i=0;i<count;i++) sum = sum + pow(2,i);
	
    cout << sum << endl; 

}

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

using namespace std;

vector<pair<int,int>>adj[100005];
vector<pair<int,int>>radj[100005];
vector<bool>visited(100005);
vector<bool>visited1(100005);
vector<tuple<int,int,int>>edges;

int n,m,p;

void dfs(int v)
{
    visited[v]=true;
    for(auto u:radj[v])
    {
        int vertex=u.first;
        if(!visited[vertex])
            dfs(vertex);
    }
}

void dfs1(int v)
{
    visited1[v]=true;
    for(auto u:adj[v])
    {
        int vertex=u.first;
        if(!visited1[vertex])
            dfs1(vertex);
    }
}

int main(){

    cin>>n>>m>>p;
    for(int i=0;i<m;i++)
    {
        int a,b,w;
        cin>>a>>b>>w;
        w-=p; w*=-1;
        adj[a].push_back({b,w});
        radj[b].push_back({a,w});
        edges.push_back(make_tuple(a,b,w));
    }

    dfs(n);
    dfs1(1);

    vector<int>distance(n+1,2e9);
    distance[1]=0;

    for(int i=1;i<=n-1;i++)
    {
        for(auto e:edges)
        {
            int a,b,w;
            tie(a,b,w)=e;

            if(visited1[a]&&visited[a]&&visited[b]&&visited1[b]){

            if(distance[a]+w<distance[b]){

                    distance[b]=distance[a]+w;

                    }
            }

            else
                continue;
        }
    }

    int has_negative_cycle=0;

    for(int i=1;i<=n;i++)
    {
        for(auto e:edges)
        {
            int a,b,w;
            tie(a,b,w)=e;

            if(visited1[a]&&visited[a]&&visited[b]&&visited1[b]){

            if(distance[a]+w<distance[b]){
                    has_negative_cycle=1;
                    break;

                    }
            }

            else
                continue;
        }
    }
    if(has_negative_cycle)
        cout<<"-1"<<endl;
    else
        cout<<max(0,-distance[n])<<endl;
return 0;
}


Measured memory_bytes: 5376
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] sum = new int[N + 1];
		for(int i=0;i<N;i++){
			sum[i + 1] = sum[i] + (S[i] == 'R' ? 1 : 0);
		}
		
		int min = (int) 1e9;
		
		for(int i=0;i<=N;i++){
			int lr = sum[i];
			int rr = sum[N] - sum[i];
			int lw = i - lr;
			int rw = (N - i) - rr;
			
			int cnt = 0;
			
			// 右から持ってくる
			int swap = Math.Min(lw, rr);
			cnt += swap;
			lw -= swap;
			rr -= swap;
			lr += swap;
			rw += swap;
			
			// 反転する
			int lx = lw;
			cnt += lx;
			lw -= lx;
			lr += lx;
			
			int rx = rr;
			cnt += rx;
			rr -= rx;
			rw += rx;
			
			Debug.Assert(lr == i && lw == 0 && rw == N - i && rr == 0);
			min = Math.Min(min, cnt);
		}
		
		Console.WriteLine(min);
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 29080
#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
# ---- ここまで -----------------------
 
input = sys.stdin.readline
 
S = input().rstrip()
T = input().rstrip()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

Measured memory_bytes: 3948
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static int to_bit(int owner, boolean j_at, boolean o_at, boolean i_at){
		return ((((((owner) << 2) + (j_at ? 1 : 0)) << 1) + (o_at ? 1 : 0)) << 1) + (i_at ? 1 : 0);
	}
	
	public static void main(String[] args) throws IOException {
		//Scanner sc = new Scanner(System.in);
		
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int[] responsive = new int[n];
		char[] input = sc.next().toCharArray();
		for(int i = 0; i < n; i++){
			if(input[i] == 'J'){
				responsive[i] = 0;
			}else if(input[i] == 'O'){
				responsive[i] = 1;
			}else if(input[i] == 'I'){
				responsive[i] = 2;
			}
		}
		final int max_bit = 1 << 3;
		int[][] DP = new int[n][max_bit];
		for(int i = 0; i < 8; i++){
			if((i & 1) == 0){
				continue;
			}else if((i & (1 << responsive[0])) == 0){
				continue;
			}
			
			//System.out.println(Integer.toBinaryString(i));
			DP[0][i] = 1;
		}
		//System.out.println(Arrays.toString(DP[0]));
		
		int sum = 0;
		boolean[] duplicate = new boolean[max_bit];
		for(int day = 0; day < n; day++){
			for(int bit = 0; bit < 8; bit++){
				//1 => J, 2 => O, 4 => I
				if((bit & (1 << responsive[day])) == 0){ //責任者がいないとかありえない
					continue;
				}
				
				final int current_times = /*(owner << 3) + */bit;
				
				if(day == n - 1){
					sum += DP[day][current_times];
					sum %= 10007;
					continue;
				}
				
				Arrays.fill(duplicate, false);
				for(int owner = 0; owner < 3; owner++){
					//0 => J, 1 => O, 2 >= I
					final int owner_bit = 1 << owner;
					
					if((bit & owner_bit) == 0){ //持って帰る人は居ないと不味い
						continue;
					}
					
					for(int next_bit = 0; next_bit < 8; next_bit++){
						if((next_bit & owner_bit) == 0){ //持って帰った人が持ってこないと開催できない
							continue;
						}else if((next_bit & (1 << responsive[day + 1])) == 0){ //次の日の責任者も出席する
							continue;
						}else if(duplicate[next_bit]){
							continue;
						}
						duplicate[next_bit] = true;
						
						final int next_times = next_bit;
						
						DP[day + 1][next_times] += DP[day][current_times];
						DP[day + 1][next_times] %= 10007;
					}
				}
			}
		}
		/*
			for(int bit = 0; bit < 8; bit++){
				final int to_bit = bit;
				if(DP[n-1][to_bit] == 0){
					continue;
				}
				
				if((bit & 1) != 0){ System.out.print("J"); }
				if((bit & 2) != 0){ System.out.print("O"); }
				if((bit & 4) != 0){ System.out.print("I"); }
				System.out.println();
			}
		System.out.println(Arrays.toString(DP[1]));
		*/
		System.out.println(sum);
		
		
	}
}

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

int main(void) {
    int A, B, K;
    cin >> K >> A >> B;
    bool ok = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            ok = true;
        }
    }
    if (ok) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3636
import sys

input = sys.stdin.readline


def main():
    N = input()
    digit_sum = 0
    for i in range(len(N)-1):
        digit_sum += int(N[i])
    if digit_sum % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

int main() {
    ll n; cin>>n;
    
    // ll ans=0;
    // for (ll i=1;i<n;i++) {
    //     ans += (i % (i+1));
    //     cout << (i % (i+1)) << endl;
    // }
    // ans += n % 1;

    n = n-1;
    cout << n*(n+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
if x <= y:
  M = y
  m = x
  Mp = b
  mp = a
else:
  M = x
  m = y
  Mp = a
  mp = b
print(min(a*x+b*y,2*m*c+(M-m)*Mp,2*M*c))

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

using namespace std;

int main(){
    int N,now=1;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    for(int i=0;i<N;i++){
        if(a[i]==now){
            now++;
        }
    }

    if(now==1){
        cout << -1 << endl;
    }else{
        cout << N-now+1 << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string s; int K;
	cin>>s>>K;
	rep(i,s.size()){
		if(i == s.size()-1){
			K %= 26;
			// cout<<K<<endl;
			int c = s[i] - 'a' + K;
			if(c >25)c -= 26;
			s[i] = (char)('a' + c);
			break;
		}
		if(s[i] == 'a')continue;
		int dist = 'z' - s[i] + 1;
		if(dist <= K){
			s[i] = 'a';
			K -= dist;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

cnt = 0
for i in range(N-1,-1,-1):
  t = min(A[i+1],B[i])
  A[i+1] -= t
  B[i] -= t
  cnt += t
  t = min(A[i],B[i])
  A[i] -= t
  B[i] -= t
  cnt += t
  
print(cnt)


Measured memory_bytes: 18476
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int N = S.length();
    int count =0, countF =0, countL =0;
    for (int i =0; i<N/2; i++) {
      if(S.charAt(i) == S.charAt(N-1-i)) count++;
    }
    String SF = S.substring(0,(N-1)/2);
    String SL = S.substring((N+1)/2,N);
    for (int i =0; i<SF.length()/2; i++) {
      if(SF.charAt(i) == SF.charAt(SF.length()-1-i)) countF++;
      if(SL.charAt(i) == SL.charAt(SF.length()-1-i)) countL++;
    }
    if (count == N/2 && countF == SF.length()/2 && countL == SF.length()/2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
vector<P> v;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int main(){
	int n,m;
	int a,b,r;
	int i,j,k;
	while(1){
	scanf("%d",&n);
	if(n==0)return 0;
	scanf("%d",&m);
	scanf("%d %d %d",&a,&b,&r);
	a--;
	v.clear();
	v.push_back(P(0,1));
	for(i=0;i<m;i++){
		int p,q;
		scanf("%d %d",&p,&q);
		P lp=P(-1,0),up=P(-1,0);
		for(j=0;j<v.size();j++){
			if(v[j].first<=p&&v[j].first>lp.first){
				lp.first=v[j].first;
				lp.second=(p-v[j].first)+v[j].second;
			}
			if(v[j].first<=q&&v[j].first>up.first){
				up.first=v[j].first;
				up.second=(q-v[j].first)+v[j].second;
			}
			if(v[j].first<p)v[j].first+=n-p;
			else if(v[j].first<q)v[j].first=v[j].first-p+n-q;
			else v[j].first-=q;
		}
		v.push_back(P(n-q,lp.second));
		v.push_back(P(0,up.second));
	}
	v.push_back(P(n,0));
	sort(v.begin(),v.end());
	int ans=0;
	for(i=0;i<v.size()-1;i++){
		if(v[i].first==v[i+1].first)continue;
		if(v[i].second<=r){
			int l=max(v[i].first,a)-v[i].first+v[i].second;
			int u=min(min(v[i+1].first,b)-v[i].first+v[i].second,r+1);
			ans+=max(0,u-l);
		}
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s, pref(""), suf("");
  cin >> s;
  int n, flag(0);
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    if (x == 1 and flag == 0) {
      flag = 1;
    }
    else if (x == 1 and flag == 1) {
      flag = 0;
    }
    else if (x == 2) {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if ((f == 1 and flag == 0) or (f == 2 and flag == 1)) {
        pref = c + pref;
      }
      else {
        suf = suf + c;
      }
    }
  }
  s = pref + s;
  s = s + suf;
  if (flag == 1) {
      reverse(s.begin(), s.end());
      cout << s << endl;
  }
  else {
      cout << s << endl;
  }
  return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    rep(i, n){
        cin >> a[i];
    }
    SORT(a);
    int ans1 = a[n-1], ans2 = a[0];
    double tmp = abs(a[0] - a[n-1]/2.0);
    rep(i, n-1){
        if(tmp > abs(a[i] - a[n-1]/2.0)){
            ans2 = a[i];
            tmp = abs(a[i] - a[n-1]/2.0);
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

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

  int n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << "\n";  
  return 0;
}


Measured memory_bytes: 3644
from math import gcd
def gcd_sum():
  K = int(input())
  sum=0
  for i in range(1,K+1):
    for j in range(1,K+1):
      i_j=gcd(i,j)
      for k in range(1,K+1):
        sum=sum+gcd(i_j,k)
  return sum
print(gcd_sum())

Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main() {
	int A, B, K; cin >> A >> B >> K;
	for (int i = min(A, B); i >= 1; --i) {
		if (A % i == 0 && B % i == 0) {
			--K;
			if (K == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  S="R"+S+"L";
  int h=0;
  FOR(i,1,N+1){
    if(S[i]=='R' and S[i+1]=='R')h++;
    else if(S[i]=='L' and S[i-1]=='L')h++;
  }
  cout<<min(h+2*K,N-1)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	vector<int> h(100001);
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> h[i];

	vector<int> dp(100001);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		for (int j = 1; j <= min(k, i); j++) {
			if (j == 1)dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
			else if (dp[i] > dp[i - j] + abs(h[i] - h[i - j]))dp[i] = dp[i - j] + abs(h[i] - h[i - j]);
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << r * r * M_PI << " " << fixed << setprecision(6) << 2 * r * M_PI << endl;
    return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int vector_finder(std::vector<int> vec, int number)
{
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size())
  { // 発見できたとき
    return 1;
  }
  else
  { // 発見できなかったとき
    return 0;
  }
}
int main(void)
{
  int sheet[3][3];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> sheet[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int> bingo(n);
  bool flag = true;
  for (int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    bingo[i] = temp;
  }
  //横
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if (!vector_finder(bingo, sheet[i][j]))
        flag = false;
    }
    if (flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
    flag = true;
  }

  //縦
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if (!vector_finder(bingo, sheet[j][i]))
        flag = false;
    }
    if (flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
    flag = true;
  }

  //斜め
  for (int i = 0; i < 3; i++)
  {
    if (!vector_finder(bingo, sheet[i][i]))
      flag = false;
  }
  if (flag)
  {
    cout << "Yes" << endl;
    return 0;
  }
  flag = true;
  for (int i = 0; i < 3; i++)
  {
    if (!vector_finder(bingo, sheet[2 - i][i]))
      flag = false;
  }
  if (flag)
  {
    cout << "Yes" << endl;
    return 0;
  }
  flag = true;
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100009];
int res[100009];
/*lets try to understand how to write recursive eqn for the current problem
 mincost(i,n)={min(a[i+1]-a[i]+mincost(i+1,n),a[i+2]-a[i]+mincost(i+2,n)) if i<n
                  ,0 if i>=n}         
 */
int mincost(int i)
{
   if(res[i]>=0)
	   return res[i];
if(i==n)
return 0;
	
	
  if(i<n-1)
  res[i]=min(abs(a[i+1]-a[i])+mincost(i+1),abs(a[i+2]-a[i])+mincost(i+2));
  else
    res[i]=abs(a[i+1]-a[i])+mincost(i+1);
 return res[i]; 
}
int main()
{  
for(int i=1;i<=100000;i++)
    res[i]=-1;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	 cout<<mincost(1);
}


Measured memory_bytes: 3328
#include <stdio.h>

using namespace std;


int main(){
	char buf[21];
	int length=0;

	scanf("%s",buf);
	for(int i=0;buf[i]!='\0';i++)length++;
	for(int i=length-1;i>=0;i--)printf("%c",buf[i]);
	printf("\n");

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  int64 sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    sum += xs[i];
  }

  int64 ans = sum;
  int64 c = 0;
  for (int i = 0; i < n; i++) {
    c += xs[i];
    UpdateMin(ans, abs(c - (sum - c)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
long long int knapsack(long long int wt[], long long int val[], long long int w, long long int n)
{
	long long int knap[n+1][w+1];
	for(int i = 0; i < n+1; i++ ){
		for(int j = 0; j < w+1; j++ ){
			if(i == 0 || j == 0)
				knap[i][j] = 0;
			else if( wt[i-1] <= j)
				knap[i][j] = max(val[i-1] + knap[i-1][j-wt[i-1]], knap[i-1][j]);
			else
				knap[i][j] = knap[i-1][j];
		}
	}
	return knap[n][w];
}
int main()
{
  long long int n,w;
  cin>>n>>w;
  long long int wt[n],val[n];
  for(int i = 0; i < n; i++){
  	cin>>wt[i]>>val[i];
  }
  cout<<knapsack(wt,val,w,n);
}

Measured memory_bytes: 82300
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x==a**2*b:
        print(0)
        sys.exit()
    if x<=a**2*b/2:
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
static const int N=100;

int main(){
  int M[N][N];
  int n,u,k,v;

  cin >>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j]=0;
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<M[i][j];
    }
    cout <<endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <cstdio>
using namespace std;

const int N_MAX = 100000;
const int Q_MAX = 50000;

int main() {
  int n, q;
  int s[N_MAX], t[Q_MAX];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) scanf("%d", &t[i]);

  int ans = 0;
  int left, right, mid;
  for (int i = 0; i < q; i++) {
    left = 0;
    right = n;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        ans++;
        break;
      } else if (s[mid] > t[i]) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3268
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
    return strcmp(a,b);
}
int main(){
  int n,l;
  scanf("%d%d",&n,&l);
  char s[n][l+1];
  char temp[l+1];
  for(int i=0;i<n;i++)scanf("%s",&s[i]);
  qsort(s,n,sizeof(s[0]),cmp);
  for(int i=0;i<n;i++)printf("%s",s[i]);
  return 0;
}


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

int main(){
string S;
cin >> S;
int count = 0;
for (int i = 0; i < 3; i++){
    if (S.at(i) == 'o'){
        count++;
    }
}
cout << 700 + 100*count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, K;
  cin >> N >> K;
  int ans;
  int h;
  rep(i, N){
    cin >> h;
    if(h >= K) ans++;
  }
  cout << ans << endl;
  return 0;
}      

Measured memory_bytes: 256