akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

ll m = 3234566667;
/*void lunlun(string S,vector<string> &v,ll m){
  if(S.size() >= 1 && stoll(S) >= m) return; 
  
  if(S.size() == 0){
    for(int i = 1;i<=9;i++){
      string S2 = S;
      S2.push_back((char)(i+48));
      v.push_back(S2);
      lunlun(S2,v,K);
    }
  }
  //Sの末尾桁の数字の差の絶対値が1以下の数字を追加していく
  else{
    int c = (char)(S[S.size()-1]+48);
      for(int i = c-1;i<=c+1;i++){
        if(i < 0 || i >= 10) continue;
        string S2 = S;
        S2.push_back((char)(i+48));
        v.push_back(S2);
        lunlun(S2,v,K);
      }
  }
}*/
void bfs(vector<string> &v,int K){
  queue<string> que;

   for(int i = 1;i<=9;i++){
       string S2;
       S2.push_back((char)(i+48));
       que.push(S2);
       v.push_back(S2);
     }
  
  while(true){
    //queの先頭のsの末尾桁の数字の差の絶対値が1以下の数字を追加していく
    string s = que.front();
    que.pop();

    int c = (int)(s[s.size()-1])-48;
    for(int i = c-1;i<=c+1;i++){
        if(i < 0 || i >= 10) continue;
        string S2 = s;
        S2.push_back((char)(i+48));
        que.push(S2);
        v.push_back(S2);
      }
      if(v.size() >= K) break;
  }
}
int main(){
  int K;
  cin >> K;
  vector<string> v;
  bfs(v,K);
  
  cout << v[K-1] << endl;
 }

Measured memory_bytes: 7412
import java.io.*;
import java.util.*;

class Main {
	static final int M = 1000000007;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			int p = sc.nextInt();
			A[p]++;
			if (A[p] > 2) {
				System.out.println(0);
				return;
			}
		}
		if (N % 2 == 1) {
			if (A[0] != 1) {
				System.out.println(0);
				return;
			}
		} else if (A[0] != 0) {
			System.out.println(0);
			return;
		}

		for (int i = 1; i < A.length; i++) {
			if (A[i] == 1) {
				System.out.println(0);
				return;
			}
		}

		int a = 1;
		for (int i = 0; i < N / 2; i++) {
			a = a * 2 % M;
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 50380
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sc second
#define st first
#define pii pair<int, int>
#define arr array
#define task "A"
#define task_check "A"

const int maxn = 2e3 + 5;
const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;

using namespace std;

/// Count : 1

int n, m;
char a[maxn][maxn];
int dist[maxn][maxn];

int main()
{
    /*if(fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }*/
    cin >> n >> m;
    int sta1, sta2, fin1, fin2;
    cin >> sta1 >> sta2 >> fin1 >> fin2;
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>>pq;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin >> a[i][j];
            dist[i][j] = 1e9;
        }
    }
    pq.push({0, {sta1, sta2}});
    dist[sta1][sta2] = 0;
    int ans = 1e9;
    while(!pq.empty()){
        int w = pq.top().st;
        int u = pq.top().sc.st;
        int v = pq.top().sc.sc;
        //cout << u <<" "<<v<<" "<<w<<"\n";
        pq.pop();
        if(dist[u][v] != w) continue;
        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                int new_u = u + i;
                int new_v = v + j;
                if(new_u >= 1 && new_u <= n && new_v >= 1 && new_v <= m && a[new_u][new_v] == '.'){
                    int minn = min(abs(i), abs(j));
                    int maxx = max(abs(i), abs(j));
                    if(minn == 0 && maxx == 1){
                        if(dist[new_u][new_v] > dist[u][v]){
                            dist[new_u][new_v] = dist[u][v];
                            pq.push({dist[new_u][new_v], {new_u, new_v}});
                        }
                    }
                    else{
                        if(dist[new_u][new_v] > dist[u][v] + 1){
                            dist[new_u][new_v] = dist[u][v] + 1;
                             pq.push({dist[new_u][new_v], {new_u, new_v}});
                        }
                    }
                }
            }
        }
    }
    if(dist[fin1][fin2] == 1e9){
        cout << -1;
        return 0;
    }
    cout << dist[fin1][fin2];
}


Measured memory_bytes: 13392
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 1123456789;
LL D, G, ans;
std::vector<std::pair<LL, LL>>task;

int main()
{
	in >> D >> G;
	std::vector<LL>p(D), c(D);
	rep(i, D)
	{
		in >> p[i] >> c[i];
		rep(j, p[i] - 1) task.push_back(std::make_pair(1, 100 * (i + 1)));
		task.push_back(std::make_pair(p[i], 100 * (i + 1)*p[i] + c[i]));
	}
	std::sort(task.begin(), task.end());
	ans = inf;
	rep(bit, (1 << D))
	{
		LL sum = 0, cnt = 0;
		rep(k, D)
		{
			if (bit&(1 << k))
			{
				sum += 100 * (k + 1)*p[k];
				sum += c[k];
				cnt += p[k];
			}
		}
		if (sum >= G) ans = std::min(ans, cnt);
		else
		{
			for (int k = D - 1; k >= 0; --k)
			{
				LL want = G - sum;
				if (bit&(1 << k)) continue;
				LL tmp = want / (100 * (k + 1));
				if (want % (100 * (k + 1)) != 0) ++tmp;
				if (tmp >= p[k]) tmp = p[k] - 1;
				sum += (100 * (k + 1))*tmp;
				cnt += tmp;
				if (sum >= G)
				{
					ans = std::min(ans, cnt);
					break;
				}
			}
		}
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
#define PFD(x)         printf("%lf\n" , x)
#define PFI(x)         printf("%d\n" , x)
#define PFC(x)         printf("%c\n" , x)
#define PFS(x)         printf("%s\n" , x)
#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int INF = 0X3fffffff;
typedef long long LL;
typedef double DB;
template<class T> inline
T read(T &x)
{
    x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}
static const int MAXN = 66;
char s1[MAXN] , s2[MAXN] , s3[MAXN];
int main()
{
#ifdef LOCAL
    //freopen("D:\\系统优化\\Desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    SFS(s1);SFS(s2);SFS(s3);
    printf("%c%c%c" , s1[0] - 32 , s2[0] - 32 , s3[0] - 32);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int money=1000;
  int bell,hess;
  while(1){
    bell=0;
    cin >> hess;
    if(hess==0){
      break;
    }
    money=1000-hess;
    while(money>0){
      if(money>=500){
	money-=500;
	bell++;
      }
      else if(money>=100){
	money-=100;
	bell++;
      }
      else if(money>=50){
	money-=50;
	bell++;
      }
      else if(money>=10){
	money-=10;
	bell++;
      }
      else if(money>=5){
	money-=5;
	bell++;
      }
      else if(money>=1){
	money-=1;
	bell++;
      }
    }
    cout << bell << endl;
  }
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	int n;cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				cout << "Yes";
				return;
			}
		}
	}
	cout << "No";
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

//XORが各桁について、その 0,1 を他方に入れ替える性質があることに注目。
//各桁について、1の方が多くなるように、Xを貪欲的に決めていけば良い。

int main(){
  char buf[1024];
  int N;
  long K;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %ld", &N, &K);

  long *A=(long *)malloc(sizeof(long)*N);
  rep(i,N){
    scanf("%ld",&A[i]);
  }

  int K_digit;
  rrep(i,40){
    //(1<<i)という書き方をすると、iは最大でも31
    if(K&(1ull<<i)){
      K_digit=i;
      break;
    }
  }

  int *count=(int *)calloc(40, sizeof(int));
  rep(i,40){
    rep(j,N){
      if(A[j]&(1ull<<i)){
        count[i]++;
      }
    }
  }

  // rep(i,40){
  //   printf("count[%d] = %d\n", i, count[i]);
  // }
  // printf("K_digit = %d\n", K_digit);

  bool sick_to_top=1;
  RREP(i,K_digit){
    if(sick_to_top==1){
      if(K&(1ull<<i)){
        if(count[i]<(N+1)/2){
          //printf("1\n");
          count[i]=N-count[i];
        }
        else{
          //printf("2\n");
          sick_to_top=0;
        }
      }
      else{
        //printf("3\n");
        ;
      }
    }
    else{
      if(count[i]<(N+1)/2){
        //printf("4\n");
        count[i]=N-count[i];
      }
      else{
        //printf("5\n");
        ;
      }
    }
  }

  long ans=0;
  rep(i,40){
    ans+=(long)count[i]*(1ull<<i);
  }

  printf("%ld\n", ans);

  return 0;

}


Measured memory_bytes: 896
// https://atcoder.jp/contests/abc104/tasks/abc104_c
#include <bits/stdc++.h>
using namespace std;

#define INF 1000000000  // 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl;

int main() {
  int D, G;
  cin >> D >> G;

  vector<int> p(D), c(D);
  rep(i, D) cin >> p.at(i) >> c.at(i);

  int ans = INF;
  rep(bit, 1 << D) {
    int curr = 0, amt = 0;

    rep(i, D) if (bit & (1 << i)) {
      curr += p.at(i);
      amt += (i + 1) * 100 * p.at(i) + c.at(i);
    }
    // 100i 点問題を完答するかどうかでbit全探索
    // この時点で val が規定値を超えていてcnt が一番小さい場合
    // or valが規定値を超えていないがcntがそれより下回る場合の２択
    if (G <= amt) {
      ans = min(ans, curr);
    } else {
      // 完答しないケースにおいて配点の大きいものから解いていく。
      for (int i = D - 1; i >= 0; i--) {
        // 完答するケースをのぞく
        if (bit & (1 << i)) continue;
        bool flag = false;

        rep(j, p.at(i) - 1) {
          if (flag) break;
          curr++;
          amt += 100 * (i + 1);
          if (G <= amt) {
            ans = min(ans, curr);
            flag = true;
          }
        }
      }
    }
  }
  print(ans);
  return 0;
}


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

int main(){
	int n, r, p, c;
	int card[50], tmp;

	
	while(cin >> n >> r){
		if(n ==0 && r == 0)
			break;

		for(int i=0; i<n; i++){
			card[i] = n-i;
		}

		for(int i=0; i<r; i++){
			cin >> p >> c;

			for(int j=0; j<c; j++){
				tmp = card[p-1+j];
				for(int k=p-2+j; k>=j; k--){
					card[k+1] = card[k];
				}
				card[j] = tmp;
			}
		}
	cout << card[0]  << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int n, m;
const long long Mod = 1e9 + 7;
long long g[500001];
long long ig[500001];
long long power(long long x, int n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return x * power(x * x % Mod, n / 2) % Mod;
    return power(x * x % Mod, n / 2);
}
long long Nck(int n, int k)
{
    return g[n] * ig[k] % Mod * ig[n - k] % Mod;
}
long long Npk(int n, int k)
{
    return g[n] * ig[n - k] % Mod;
}
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //-------------------------------
    cin >> n >> m;
    g[0] = 1;
    for (int i = 1; i <= m; i++)
    {
        g[i] = g[i - 1] * i % Mod;
    }
    ig[m] = power(g[m], Mod - 2);
    for (int i = m - 1; i >= 0; i--)
    {
        ig[i] = ig[i + 1] * (i + 1) % Mod;
    }
    long long ans = Npk(m, n);
    ans *= ans;
    ans %= Mod;
    long long st = -1;
    for (int i = 1; i <= n; i++)
    {
        long long x = Npk(m - i, n - i);
        x = x * x;
        x %= Mod;
        long long K = Nck(m, i) * Nck(n, i) % Mod * g[i] % Mod * x % Mod;
        K = st * K;
        if (K < 0)
            K += Mod;
        ans += K;
        ans %= Mod;
        st = -st;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }
    operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
using UnweightedGraph = vector<vector<T>>;

template <typename T>
using Matrix = vector<vector<T>>;

#include <vector>
#include <utility>
#include <queue>

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
    WeightedGraph<int> g(V);
    for (int i = 0; i < E; i++)
    {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    printf("%d\n", Prim(g));
}


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define N 500005
using namespace std;

inline void rd(int &x){
	x=0;char ch=0;int w=0;
	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';
	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=w?-x:x;
}

int l,r;
int n,m;
int a[N],b[N];

bool ok(int x){
	for(int i=1;i<=m;i++)
		b[i]=(a[i]>=x);
	for(int i=0;i<n;i++){
		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;
		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;
	}
	return b[1];
}
signed main(){
	rd(n);m=n*2-1;l=1;r=m+1;
	for(int i=1;i<=m;i++) rd(a[i]);
	while(l<r){
		int mid=(l+r)>>1;
		ok(mid) ? l=mid+1 : r=mid;
	}
	cout<<l-1<<endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  int numA=0, numB=0, numC=0; // 各アルファベットの出現回数
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='a') numA++;
    else if (S[i]=='b') numB++;
    else numC++;
  }
  int m = min(numA, min(numB, numC)), M = max(numA, max(numB, numC));
  if (M-m<=1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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


N = int(input())
ans = 1
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

memory = [0]*1000000
tmp = N
memory[N]=1
while True:
    ans+=1
    tmp=f(tmp)
    if memory[tmp] == 1:
        break
    else:
        memory[tmp]=1

print(ans) 



Measured memory_bytes: 46064
import math
A,B,H,M = list(map(int,input().split()))
hd = (30 * H + M * 0.5)
md = M * 6
d = abs(hd - md)

a = A**2 + B**2 - 2 * A * B * math.cos(math.radians(d))
print(f'{a ** 0.5}')


Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n;
int a[300000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < 3 * n; i++) cin >> a[i];
	sort(a, a + 3 * n);
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans += a[3 * n - 2 - 2 * i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  int N, K;
  string tmp, S;
  char s;
  locale l = locale::classic();
  
  cin >> N;
  cin >> K;
  cin >> S;
  
  s = S[K-1];
  
  S.replace(K-1, 1, 1, tolower(s, l));
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int a[101010];
vector<int> G[101010];
bool used[101010];

int minv, minp;

void serch(int pos) {
	queue<int> q;
	q.push(pos);
	while (q.size()) {
		int que = q.front();
		q.pop();
		used[que] = true;
		if (minv > a[que]) {
			minv = a[que];
			minp = que;
		}
		REP(i, G[que].size()) {
			if (!used[G[que][i]])q.push(G[que][i]);
		}
	}
}


int main() {
	cin >> n >> m;
	REP(i, n)cin >> a[i];
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	LL ans = 0;
	int count = 0;
	REP(i, n) {
		if (!used[i]) {
			count++;
			minv = INF;
			minp = -1;
			serch(i);
			ans += a[minp];
			a[minp] = INF;
		}
	}
	if (count == 1) {
		cout << 0 << endl;
		return 0;
	}
	sort(a, a + n);
	REP(i, count - 2) {
		if (a[i] == INF) {
			cout << "Impossible" << endl;
			return 0;
		}
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    int n,m;cin>> n >> m;
    priority_queue<int> q;
    for(int i = 0; i < n; i++) {
        int a;cin >> a;
        q.push(a);
    }

    for(int i = 0; i < m; i++) {
        int x=q.top();
        q.pop();
        x/=2;
        q.push(x);
    }

    ll sum=0;
    for(int i = 0; i < n; i++) {
        int x=q.top();
        q.pop();
        sum += x;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String answer = "No";
		try {
			// TODO 自動生成されたメソッド・スタブ

			//数取得
			float D = sc.nextFloat();
			float T = sc.nextFloat();
			float S = sc.nextFloat();
			//System.out.println(D/S);

			if(D/S <= T) {
				answer = "Yes";
			}


		}finally {
			System.out.println(answer);
			sc.close();
		}

	}

}


Measured memory_bytes: 28796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int a=0,b=0,x1,y1,x2,y2;
    ll s;
    cin>>s;
    if(s<=P-7){
        cout<<0<<" "<<0<<" "<<0<<" "<<1<<" "<<s<<" "<<0<<endl;
        return 0;
    }
    x1=P-7;
    x2=1;
    y2=ceil(s/(double)x1);
    y1=x1*y2-s;
    cout<<a<<" "<<b<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;

//////////////////////////////////////////////////////
return 0;}

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

int main(){
    string s;
    cin >> s;
    set<char> c;
    for(auto x: s) c.insert(x);
    cout << (c.size()==2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
//#include <vector>
#include <string>

using namespace std;

int main() {
    string othello;
    bool flag = 0;
    int count = 0;
    int piece;

    cin >> othello;


    //if (othello[0] == 'B' )
    //{
    //    piece = BLACK;
    //}
    //else
    //{
    //    piece = WHITE;
    //}

    for (int i = 1; i < othello.length() ; i++)
    {
        if (othello[i] != othello[i - 1])
        {
            count++;
        }
    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    if a == 0 && b == 0 {
        println!("{}", 0);
        return;
    }

    let mut ans = -1;
    for i in 1..2000 {
        if (i as f64 * 0.08).floor() == a as f64 && (i as f64 * 0.1).floor() == b as f64 {
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())


## 約数の列挙O(√N)
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return len(table)
  
i = 1
answer = 0
while i <= N:
  if divisor(i) == 8:
    answer += 1
  i += 2
print(answer)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

void solve(vector<int>& v) {
  sort(v.begin(), v.end());
  int m = *v.rbegin();

  int max_r = 0;
  int ans_r = 0;
  for(int r : v) {
    int actual_r = r <= m/2 ? r : m - r;
    if(max_r<actual_r){
      max_r = actual_r;
      ans_r = r;
    }
  }
  cout << m << " " << ans_r << endl;
}

int main() {
  int N;
  vector<int> v;
  cin>>N;
  CIN_VEC(v,N);
  solve(v);

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    int a,b; cin >> a >> b;
    char x[100][100];
    rep(i,100){
        rep(j,100){
            if(i<50) x[i][j]='#';
            else x[i][j]='.';
        }
    }
    int cnt=a-1;
    int p=0,q=0;
    while(cnt>0){
        x[p][q]='.';
        cnt--;
        q+=2;
        if(q==99){
            q=0; p+=2;
        }else if(q==100){
            q=1; p+=2;
        }
    }
    cnt=b-1;
    p=51; q=0;
    while(cnt>0){
        x[p][q]='#';
        cnt--;
        q+=2;
        if(q==99){
            q=0; p+=2;
        }else if(q==100){
            q=1; p+=2;
        }   
    }
    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100) cout << x[i][j]; cout << endl;
    }
}


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

int main(){
    int n,ta=0,ha=0,i;
    string ts,hs;
    cin>>n;
    for(i=0; i<n; i++){
        cin>>ts>>hs;
        if(ts==hs){
            ta+=1;
            ha+=1;
        }else if(ts>hs){
            ta+=3;
        }else if(hs>ts){
            ha+=3;
        }
    }
    cout<<ta<<" "<<ha<<endl;
    return 0;
}


Measured memory_bytes: 3172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[] c = in.na(n);
            long mod = (int) 1e9 + 7;
            int MAX = 200_001;
            long[] dp = new long[MAX];
            dp[c[0]] = 1;

            for (int i = 1; i < n; i++) {
                if (c[i] != c[i - 1])
                    dp[c[i]] = (dp[c[i]] + dp[c[i - 1]]) % mod;
            }
            out.println(dp[c[n - 1]]);


        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}



Measured memory_bytes: 46036
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash() = default;
    
  void set(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

int main() {
    int n;
    cin >> n;
    
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        s[i] += s[i];
    }
    
    vector<string> tmp = s;
    
    s.insert(s.end(), tmp.begin(), tmp.end());
        
    vector<string> t(s.size(), string(2 * n, 0));
    
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            t[i][j] = s[j][i];       
        }
    }
    
    vector<RH> sh(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        sh[i].set(s[i]);
    }
    
    vector<RH> th(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        th[i].set(t[i]);
    }
    
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            bool ok = true;
            
            for (int k = 0; k < n; k++) {
                if (sh[i + k].get(j, j + n) != th[j + k].get(i, i + n)) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}


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

double memo[3002][3002];
double p[3002];
int vis[3002][3002];
double rec_sol(int n,int h){
	if (h<0){
		return 0;
	}
	if(n==0){
		if(h==0)
			return 1;
		else
			return 0;
	}
	if(vis[n][h]){
		return memo[n][h];
	}
	vis[n][h]=1;
	return memo[n][h]=p[n]*rec_sol(n-1,h-1)+(1-p[n])*rec_sol(n-1,h);
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	double ans=0;
	memset(memo,0,sizeof(memo));
	memset(vis,0,sizeof(vis));
	for(int i=0;i<=n;i++){
		int t=n-i;
		if(i>t){
			ans+=rec_sol(n,i);
		}
	}
	cout<<setprecision(9)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 106112
#include <iostream>
using namespace std;
int abs (int x, int y) {
  if (x > y) {
    return x - y;  
  }  
  return y - x;
}

int main () {
  long long n;
  cin >> n;
  long long x[n], y[n], h[n];
  // 全部0だったら
  long long h_nonzero = -1;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];  
    if (h_nonzero == -1 && h[i] != 0) {
      h_nonzero = i;  
    }
  }  
  if (h_nonzero == -1) {
    // この状態はなし.  
  }
  long long cx, cy;
  long long sub = 0;
  bool forbool = false;
  for (long long cx = 0; cx <= 100; cx++) {
    for (long long cy = 0; cy <= 100; cy++) {
      forbool = false;
      
      // h_nonzeroの時を考える.
      sub = abs(cx - x[h_nonzero]) + abs(cy - y[h_nonzero]) + h[h_nonzero];
      for (long long i = 0; i < n; i++) {
        if (h[i] == 0) {
          if (sub - abs(cx - x[i]) - abs(cy - y[i]) <= 0) {
            // ok  
          }  
          else {
            break;  
          }
        } 
        else {
          if (sub == abs(cx - x[i]) + abs(cy - y[i]) + h[i]) {
            // ok  
          }    
          else {
            break;  
          }
        }
        if (i == n - 1) {
          cout << cx << " " << cy << " " << sub << endl;  
        }
      }
    }  
  }
}

Measured memory_bytes: 256
sousuu = int(input())
listnum = list(map(int, input().split()))
_list = []
for i in range(sousuu):
    _list.append(listnum[i] - (1 + i))
num = sorted(_list)[sousuu//2]
dst = 0
for i in range(sousuu):
    dst += abs(listnum[i] - (i+1+num))
print(dst)


Measured memory_bytes: 25200
import java.util.Scanner;

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

		if(S.equals("AAA") || S.equals("BBB")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		scan.close();
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int main()
{
  int n; cin >> n;
  vector<int> a(2*n);
  REP(i,2*n) cin >> a[i];
  sort(a.begin(),a.end());
  int ans=0;
  REP(i,n) ans+=a[i*2];
  cout << ans << endl;
}


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

long long int compare(const void *arg1, const void *arg2);

int main()
{
	long long int n,k,max,maxi,t;
	long long int i,j;
	
	scanf("%lld %lld",&n,&k);
	
	long long int h[n];
	
	t = 0;
	
	for(i = 0;i < n;i++)
		scanf("%lld",&h[i]);
		
	qsort(h,n,sizeof(long long int),compare);
		
	for(i = k;i < n;i++)
		t += h[i];
			
	printf("%lld\n",t);
		
	return 0;
}

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

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
vector<ll>v[205];
ll vis[205];
string str;

ll bfs(ll x,ll k)
{
	queue<ll>q;
	q.push(x);
	vis[x]=k;
	while(!q.empty())
	{
		ll p=q.front();
		q.pop();
		for(ll i=0;i<v[p].size();i++)
		{
			if(vis[v[p][i]]==0)
			{
				vis[v[p][i]]=vis[p]+1;
				q.push(v[p][i]);
			}
			else
			{
				if(abs(vis[v[p][i]]-vis[p])!=1)
					return 1;
			}
		}
	}
	return 0;
}	

int main()
{
	boost
	ll maxi=-1,mini=ass,n,i,j,ind;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>str;
		for(j=1;j<=n;j++)
		{
			if(str[j-1]=='1')
			{
				v[i].pb(j);
				v[j].pb(i);
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		if(!bfs(i,1))	
		{
			for(ll j=1;j<=n;j++)
				maxi=max(maxi,vis[j]);
		}
	}
	cout<<maxi;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<pair<int, int> > v;
	for (int i=0; i<n; i++){
		int x;
		cin >> x;
		v.push_back(make_pair(x, i+1));
	}
	sort(v.begin(), v.end());
	for (int i=0; i<v.size()-1; i++){
		cout << v[i].second << " ";
	}
	cout << v[v.size()-1].second << "\n";
}

Measured memory_bytes: 1780
import math
a,b,x = map(int, input().split())
if x <= a*b*a/2:
    a1 = x*2/(a*b)
    theta = math.degrees(math.atan(b/a1))
    print("%.10f"%(theta))
else:
    b1 = b-(a*a*b-x)*2/(a*a)
    theta = math.degrees(math.atan((b-b1)/a))
    print("%.10f"%(theta))

Measured memory_bytes: 3060
N = gets.to_i
ans = 1 << 60
(1..(N / 2)).each do |n|
  m = N - n
  a = n.to_s.chars.map(&:to_i).reduce(&:+)
  b = m.to_s.chars.map(&:to_i).reduce(&:+)
  c = a + b
  ans = c if c < ans
end
puts ans


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (a + b >= a - b && a + b >= a * b)
            {
                Console.WriteLine(a + b);
            }
            else if (a - b >= a + b && a - b >= a * b)
            {
                Console.WriteLine(a - b);
            }
            else
                Console.WriteLine(a * b);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

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

Measured memory_bytes: 1736
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{long int n;
cin>>n;
double a[n];
for(long int i=0;i<n;i++)
cin>>a[i];

    double dp[n+1][n+1];
    for(long int i=0;i<=n;i++)
    {
        for(long int j=0;j<=n;j++)
        dp[i][j]=0;
    }
    dp[1][0]=1.0-a[0];
    dp[1][1]=a[0];
    for(long int i=2;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1.0-a[i-1]);
        for(long int j=1;j<=n;j++)
          dp[i][j]=(dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*a[i-1]);
    }
    double pp=0;
    for(long int i=n/2+1;i<=n;i++)
    pp+=dp[n][i];
    printf("%0.20f",pp);
}

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

#define ll long long
int main() {
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll n;
      cin>>n;
      if(n>=30)
            cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
        
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    char a[4];
    cin>>a;
    if(a[1]=='B') cout<<"ARC";
    else cout<<"ABC";
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;++i) cin >> A[i];
    sort(A.begin(),A.end());
    ll ans=0,cnt=0;
    for (int i=0;i<N/2;++i) ans-=A[i]*2;
    for (int i=N/2;i<N;++i) ans+=A[i]*2;
    ans-=A[N/2];
    if (N&1){
        ans-=A[N/2+1];
        for (int i=0;i<=N/2;++i) cnt-=A[i]*2;
        for (int i=N/2+1;i<N;++i) cnt+=A[i]*2;
        cnt+=A[N/2]+A[N/2-1];
        ans=max(ans,cnt);
    } else ans+=A[N/2-1];
    cout << ans << '\n';
}

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

#define N 100005

int n,k,a[N];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>n>>k;
}

int gcd(int cmp1,int cmp2){
	int r;
	while(cmp1%cmp2!=0){
		r=cmp1%cmp2;
		cmp1=cmp2;
		cmp2=r;
	}
	return cmp2;
}

int main(){
	init();
	for(int i=1;i<=n;++i)
	read(a[i]);
	int Gcd=abs(k-a[1]);
	for(int i=2;i<=n;++i)
	Gcd=gcd(Gcd,abs(k-a[i]));
	cout<<Gcd<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int check;
   for(int i=1;i<=n;i++)
   {
      int a,b;
      cin>>a>>b;
      if(a==b)
      {
         check++;
         if(check>=3)
         {
            cout<<"Yes"<<endl;
            return 0;
         }
      }
      else
      {
         {
            check=0;
         }
      }
      
   }
   cout<<"No"<<endl;
   return 0;
}

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

int main(){
	int N, K, i, d, count=0;
	cin>>N>>K;
	bool A[N];
	
	for(int j=0; j<N; j++){
		A[j]=false;
	}
	
	for(int h=K; h>=0; h--){
		cin>>d;
	
		for(; d>0; d--){
			cin>>i;
			A[i-1]=true;
		}
	}
	
	for(int n=0; n<N; n++){
		if(!A[n]){
			count++;
		}
	}
	cout<<count;
	
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)

char s[3*MAXN + 1];

int main(void)
{
    int n;
    scanf("%d",&n);
    scanf("%s", s);

    int R = 1;
    int G = 2;
    int B = 4;
    int64_t ans = 1;
    int64_t cn[8]={1,0,0,0,0,0,0,0};
    for(int i=1;i<=3*n;i++)
    {
        char c = s[i-1];
        switch(c)
        {
            case 'R':
                if(cn[B+G])
                {
                    ans *= cn[B+G];
                    ans %= MOD;
                    cn[B+G]--;
                }else if(cn[B])
                {
                    ans *= cn[B];
                    ans %= MOD;
                    cn[B+R]++;
                    cn[B]--;
                }else if(cn[G])
                {
                    ans *= cn[G];
                    ans %= MOD;
                    cn[G+R]++;
                    cn[G]--;
                }else
                {
                    cn[R]++;
                }

                break;
                
            case 'G':
                if(cn[B+R])
                {
                    ans *= cn[B+R];
                    ans %= MOD;

                    cn[B+R]--;
                }else if(cn[B])
                {
                    ans *= cn[B];
                    ans %= MOD;
                    cn[B+G]++;
                    cn[B]--;
                }else if(cn[R])
                {
                    ans *= cn[R];
                    ans %= MOD;
                    cn[G+R]++;
                    cn[R]--;
                }else
                {
                    cn[G]++;
                }
                break;

            case 'B':
                if(cn[R+G])
                {
                    ans *= cn[R+G];
                    ans %= MOD;

                    cn[R+G]--;
                }else if(cn[R])
                {
                    ans *= cn[R];
                    ans %= MOD;
                    cn[B+R]++;
                    cn[R]--;
                }else if(cn[G])
                {
                    ans *= cn[G];
                    ans %= MOD;
                    cn[G+B]++;
                    cn[G]--;
                }else
                {
                    cn[B]++;
                }

                break;
        }
    }
    for(int i=2;i<=n;i++)
    {
        ans *= i;
        ans %= MOD;
    }

    printf("%ld\n",ans);
    return 0;
}







Measured memory_bytes: 512