akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
	int M, D;
	cin >> M >> D;
	int d1, d10;
	int count = 0;
	rep(i,M+1) {
		rep(j,D+1) {
			d1 = j % 10;
			d10 = (j - d1) / 10;
			if (i == d1 * d10&&d1 >= 2 && d10 >= 2) {
				++count;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n;
  vi ans;
  while(cin>>n, n)
  {
    vi s(n);
    each(v,s) cin>>v;
    sort(ALL(s));
    s.pop_back();
    s.erase(s.begin());
    int sum=0;
    rep(i,s.size()) sum+=s[i];
    ans.push_back(sum/s.size());
  }
  each(v,ans) print(v);

  return 0;
}



Measured memory_bytes: 3108
/*
  AOJ 1252
  Title:Confusing Login Name
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define diff(x,y) (((x)>(y))?((x)-(y)):((y)-(x)))
int n,d;
char name[200][16];
int ans [19900][2];


comp_word_pair(void * w1,void * w2)
{
  int ret;

  ret=strcmp(&name[((int *)w1)[0]][0],&name[((int *)w2)[0]][0]);
  if(ret!=0)
    return(ret);
  ret=strcmp(&name[((int *)w1)[1]][0],&name[((int *)w2)[1]][0]);
  return(ret);
}

void swap_alpha1(int a[2])
{
  int wk;
  if(0<strcmp(&name[a[0]][0],&name[a[1]][0]))
    {
      wk=a[1];
      a[1]=a[0];
      a[0]=wk;
    }
}
void swap_alpha_all(int a[][2],int ans_cnt)
{
  int i;
  for(i=0;i<ans_cnt;i++)
    swap_alpha1(&a[i][0]);
}

pretty_print(int a[][2],int ans_cnt)
{
  int i;
  swap_alpha_all(a,ans_cnt);
  qsort(a,ans_cnt,sizeof(int)*2,comp_word_pair);
  for(i=0;i<ans_cnt;i++)
    printf("%s,%s\n",name[a[i][0]],name[a[i][1]]);
  printf("%d\n",ans_cnt);
}

struct x_st 
{
  char len1;
  char len2;
  char cmp_cnt;
  char cmp_off[2][2];
  char next1;
  char next2;
  int  dist_use;
}  
table[]  ={{0,0,1,0,0,0,0,1,1,0},
	   {0,1,0,0,0,0,0,0,1,1},
	   {1,0,0,0,0,0,0,1,0,1},
	   {1,1,0,0,0,0,0,1,1,1},
	   {2,2,2,0,1,1,0,2,2,1},
	   {3,2,2,0,1,2,0,3,2,2},
	   {2,3,2,1,0,0,2,2,3,2}
};
int check(char s1[],char s2[],int dist,int lv,int met)
{
  int l1,l2;
  int ret;
  int i,j;

  l1=strlen(s1);
  l2=strlen(s2);
  if(0==strcmp(s1,s2))
    ret=1;
  else if(dist<=0)
    ret=0;
  else if(diff(l1,l2)>dist)
    ret=0;
  else if(l1<=1 && l2<=1 && dist>0)
    ret=1;
  else
    {
      ret=0;
      for(i=0;i<7 && ret==0;i++)
	{
	  if((l1<table[i].len1) || (l2<table[i].len2) || \
	     (dist < table[i].dist_use))
	      goto NEXT;

	  for(j=0;j<table[i].cmp_cnt;j++)
	    if(s1[table[i].cmp_off[j][0]]!=s2[table[i].cmp_off[j][1]])
	      goto NEXT;
	  ret=check(s1+table[i].next1,s2+table[i].next2,
		    dist-table[i].dist_use,lv+1,i+1);
	NEXT:;
	}
    }
  return(ret);
}

int solve(char name[][16],int ans[][2])
{
  int i,j,ans_cnt;

  ans_cnt=0;
  for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++)
      if(check(&name[i][0],&name[j][0],d,0,0))
	{
	  ans[ans_cnt][0]=i;
	  ans[ans_cnt][1]=j;
	  ans_cnt++;
	}
  return(ans_cnt);
}

main()
{
  int i,ans_cnt;
  while(scanf("%d",&n)  && n)
    {

      scanf("%d",&d);
      for(i=0;i<n;i++)
	scanf("%s",&name[i][0]);
      ans_cnt=solve(name,ans);
      pretty_print(ans,ans_cnt);
    }
  return(0);
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    
    vector<int> d;
    for (int i=0; i < n; i++)
    {
        int val;
        cin >> val;
        d.push_back(val);
    }
    
    ll sum = 0;
    for (int i=0; i < n-1; i++)
    {
        for (int j=i+1; j < n; j++)
        {
            sum += d[i] * d[j];
        }
    }

    cout << sum;
    
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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, m, x;
  cin >> n >> m >> x;
  vector<int> costs(n);
  auto value_matrix = MakeVector2D(n, m, 0);
  for (int i = 0; i < n; i++) {
    cin >> costs[i];
    for (int j = 0; j < m; j++) {
      cin >> value_matrix[i][j];
    }
  }

  int min_cost = 1E9;
  for (int b = 0; b < (1 << n); b++) {
    int cost = 0;
    vector<int> values(m);
    for (int i = 0; i < n; i++) {
      if (b & (1 << i)) {
        cost += costs[i];
        for (int j = 0; j < m; j++) {
          values[j] += value_matrix[i][j];
        }
      }
    }

    bool valid = true;
    for (int j = 0; j < m; j++) {
      if (values[j] < x) {
        valid = false;
      }
    }
    if (valid) {
      UpdateMin(min_cost, cost);
    }
  }

  if (min_cost == 1E9) {
    cout << -1 << endl;
  } else {
    cout << min_cost << endl;
  }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int from, to;
	Weight weight;
	Edge(int src, int dst) :
		from(src), to(dst), weight(0) { }

	Edge(int src, int dst, Weight weight) :
		from(src), to(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.from != f.from ? e.from < f.from : e.to < f.to;
}

struct UndirectionalCompare {
	bool operator() (const Edge& e, const Edge& f) const {
		if (min(e.from, e.to) != min(f.from, f.to))
			return min(e.from, e.to) < min(f.from, f.to);
		return max(e.from, e.to) < max(f.from, f.to);
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef set<Edge, UndirectionalCompare> Edgeset;

struct topoloricalSort_runnner {
	bool visit(const Graph& g, int v, vector<int>& order, vector<int>& color) {
		color[v] = 1;
		for (auto e : g[v]) {
			if (color[e.to] == 2) continue;
			if (color[e.to] == 1) return false;
			if (!visit(g, e.to, order, color)) return false;
		}
		order.push_back(v); color[v] = 2;
		return true;
	}
	
	bool topologicalSort(const Graph& g, vector<int>& order) {
		int n = g.size();
		vector<int> color(n);
		rep(u, n) if (!color[u] && !visit(g, u, order, color))
			return false;
		reverse(order.begin(), order.end());
		return true;
	}
};

int main(void)
{
	int v, e;
	cin >> v >> e;

	Graph g(v);
	rep(i, e) {
		int s, t;
		cin >> s >> t;
		g[s].push_back({s,t,0});
	}
	topoloricalSort_runnner runner;
	vector<int> order;
	if (!runner.topologicalSort(g, order)) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 3168
n,m=map(int,input().split())
L=[0]*n
for i in range(n):
    a,b=map(int,input().split())
    L[i]=[a,b]
L=sorted(L,key=lambda x:x[0])
cnt=m
ans=0
for i in L:
    if cnt<=i[1]:
        ans+=i[0]*cnt
        break
    ans+=i[1]*i[0]
    cnt-=i[1]
print(ans)

Measured memory_bytes: 25972
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,j,k,f;
	char s[1005],k1[]="Hoshino",k2[]="Hoshina";
	scanf("%d\n",&n);
	while(n--){
		fgets(s,1003,stdin);
		if(strlen(s)>=7){
			for(i=0;i<strlen(s)-7;i++){
				f=0;
				for(j=0;j<7;j++){
					if(s[i+j]==k1[j])f++;
					else break;
				}
				if(f==7){
					for(j=0;j<7;j++)s[i+j]=k2[j];
				}
			}
		}
		printf("%s",s);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		int n = 0;
		
		for (int i = a; i <= b; i++) {
			if (c % i == 0)
				n++;
		}

		System.out.println(n);
	}

}



Measured memory_bytes: 26392
#include <iostream>

int main() {
	int n, x, cnt = 0;
	while(std::cin >> n >> x && (x || n)) {
		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j++)
				for(int k = j + 1; k <= n; k++) if(i + j + k == x) cnt++;
		std::cout << cnt << '\n';
		cnt = 0;
	}
	return 0;
}


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

using namespace std;
// using Graph = vector<vector<ll>>;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

ll acnum[500000], wanum[500000];
int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n, m, p, ac = 0, wa = 0;
  string s;
  cin >> n >> m;
  for (i = 0; i < m; i++)
  {
    wanum[i] = 0;
  }

  for (i = 0; i < m; i++)
  {
    cin >> p >> s;
    if (s == "WA")
    {
      wanum[p - 1]++;
    }
    else
    {
      if (acnum[p - 1] == 0)
      {
        ac++;
        wa += wanum[p - 1];
        acnum[p - 1]++;
      }
    }
  }

  cout << ac << ' ' << wa;
}


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

int main(){
    int train_fee,train_free,bus_fee,bus_free,cost;
    cin >> train_fee >> train_free >> bus_fee >> bus_free;
    cost = 0;
    cost += min(train_fee,train_free);
    cost += min(bus_fee,bus_free);
    cout << cost << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int x, a, b, c, tot, count;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  count = 0;
  for (int i=0;i<=a;i++) {
    int tot1 = 500 * i;
    if (tot1 == x) count++;
    if (tot1 >= x) break;
    for (int j=0;j<=b;j++) {
      int tot2 = tot1 + 100 * j;
      if (tot2 == x) count++;
      if (tot2 >= x) break;
      for (int k=0;k<=c;k++) {
	int tot3 = tot2 + 50*k;
	if (tot3 == x) count++;
	if (tot3 >= x) break;
      }
    }
  }
  cout << count << endl;
  return(0);
}


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

int main(void){
    
   char txt[4] = {}; cin >> txt;
   
   if(txt[0] == txt[1] && txt[1] == txt[2] && txt[2] == txt[3]) {
       
       cout << "No" << endl;
   }else{
   
   if(txt[0] == txt[1]){
       
       if(txt[2] == txt [3]){
       
           cout << "Yes" << endl;
       
       }else{
           
           cout << "No" << endl;
       }
   }else if(txt[0] == txt[2]){
       
         if(txt[1] == txt [3]){
           
           cout << "Yes" << endl;
           
       }else{
           
           cout << "No" << endl;
       }
   }else if(txt[0] == txt[3]){
       
         if(txt[1] == txt [2]){
           
           cout << "Yes" << endl;
       }else{
           
           cout << "No" << endl;
       }
   }else{
       cout << "No" << endl;
   }
}
    return 0;
}

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

int n;
string s;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> s;
    int lb = 0, rb = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') lb++;
        else {
            if (lb) lb--;
            else rb++;
        }
    }

    for (int i = 0; i < rb; i++) cout << '(';
    cout << s;
    for (int i = 0; i < lb; i++) cout << ')';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,ans;cin>>h>>w;
  if(h==1||w==1) ans=1;
  else ans=((w+1)/2)*((h+1)/2)+(w/2)*(h/2);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  unsigned long long int m;
  scanf("%d %llu",&n,&m);
  int i,A[n+1],time,ch=0,B[n+1],cur=1;
  for(i=1;i<n+1;i++){
    A[i]=0;
    scanf("%d",&time);
    B[i]=time;
  }
  time=0;
  A[1]=1;
  while(m>0){
    cur=B[cur];
    m -= 1;
    if(A[cur]!=2){
      int ha;
      ha=A[cur];
      ha=ha+1;
    }else{
      for(i=1;i<n+1;i++){
        if(A[i]==2){
          ch+=1;
        }
      }
      m=m%ch;
      for(i=1;i<n+1;i++){
        A[i]=0;
      }
    }
    A[cur]+=1;
  }
  printf("%d",cur);
  return 0;
}

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

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;

int main(){
    ll N;
    cin>>N;
    ll ans=0;
    ans+=(N/500)*1000;
    ll ama=N%500;
    ans+=(ama/5)*5;
    cout<<ans<<endl;
}


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

class Program {
    static void Main (string[] args) {
        string[] input1 = Console.ReadLine ().Split (' ');
        int S = int.Parse (input1[0]);
        int W = int.Parse (input1[1]);
        if (S <= W) {
            Console.WriteLine ("unsafe");
        } else {
            Console.WriteLine ("safe");
        }

    }
}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;

i32 main() {
    i32 N; cin >> N;
    i32 A[N];
    for (i32 i = 0; i < N; i++) cin >> A[i], cout << (i == 0 ? "" : " ") << A[i];
    cout << "\n";
    
    for (i32 i = 1; i <= N - 1; i++) {
        i32 v = A[i];
        i32 j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (i32 i = 0; i < N; i++) cout << (i == 0 ? "" : " ") << A[i];
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3056
#include<stdio.h>
#include<vector>
using namespace std;
vector<int> map[100001];
int v[100001][2];
void dfs(int x, int c) {
	v[x][c] = 1;
	for (auto e : map[x]) {
		if (v[e][1 - c] != 0) continue;
		dfs(e, 1 - c);
	}
}
int main() {
	int n, m, a, b;
	scanf("%d%d", &n, &m);
	for(int i=1; i<=m; i++){
		scanf("%d%d", &a, &b);
		map[a].push_back(b);
		map[b].push_back(a);
	}
	dfs(1, 0);
	int c0=0, c1=0, c2=0;
	for (int i = 1; i <= n; i++) {
		if (v[i][0]==1 && v[i][1]==1) c2++;
		else if (v[i][0]==1) c1++;
		else c0++;
	}
	long long ans = -m + 1ll * c2*(n - 1) - 1ll*c2*(c2-1)/2 + 1ll * c0*c1;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8320
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int x = scan.nextInt();
    	int h,m,s;
    	h = x / (60*60);
    	m = (x-h*60*60)/60;
    	s = x-h*60*60-m*60;
        System.out.println(h+":"+m+":"+s);
    }
}

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

typedef long long ll;

int main(void)
{
    char name1[15], name2[15];

    gets(name1);
    gets(name2);

    int len1 = strlen(name1);

    if(strncmp(name1,name2, len1) == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1488
n = int(input())
a = list(map(int, input().split()))
import math
result = 10**9
for i in range(n):
  temp = -1
  while a[i] == math.floor(a[i]):
    a[i] = a[i]/2
    temp += 1
  result = min(temp, result)
print(result)

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N+2, 0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    int sum = 0;
    for(int i=0;i<N+1;i++){
        sum += abs(A[i+1] - A[i]);
    }
    for(int i=1;i<N+1;i++){
        auto res = sum;
        res -= abs(A[i+1] - A[i]);
        res -= abs(A[i] - A[i-1]);
        res += abs(A[i+1] - A[i-1]);
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
    public static void main(String []args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        ArrayList<Integer> num=new ArrayList<>();
        int c=1;
        while (st.hasMoreTokens()){
            int temp=Integer.parseInt(st.nextToken());
            if(temp==0)
                break;
            c++;
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 25184
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m,pr,opct,op,memo;
  cin >> n >> m;
  int all = mypow(2,n,MOD);
  Vi ans(all,INF);
  ans[0]=0;
  
  rep(i,0,m){
    memo = 0;
    cin >> pr >> opct;
    rep(j,0,opct){
      cin >> op;
      memo += mypow(2,op-1,MOD);
    }
    rep(i,0,all){
      ans[(i|memo)] = min(ans[(i|memo)],ans[i]+pr);
    }
  }
  if(ans[all-1] >= INF/2) cout<<-1<<endl;
  else cout << ans[all-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
using namespace std;
ll n;
int main() {
	cin >> n;
	ll s = 0, t, ans = 0;
	map<ll, ll> mp;
	mp[0] = 1;
	rep(i, n) {
		cin >> t;
		ans+= mp[s += t]++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

  string ret="No";
  if(N[0]==N[1]&&N[1]==N[2]||N[1]==N[2]&&N[2]==N[3])ret="Yes";
  cout<< ret<< endl;

  return 0;
}


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

const int INF = 100;
int main () {
  vector<int> res(26, 100);
  int n;
  cin >> n;
  rep(i,n) {
    vector<int> c(26, 0);
    string s;
    cin >> s;
    rep(j,s.size()) {
      c[s[j] - 'a']++;
    }
    rep(j,26) res[j] = min(res[j], c[j]);
  }

  rep(i,26) {
    while(res[i] != 0) {
      printf("%c", char(i + 'a'));
      res[i]--;
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

M = []
A = []
R = []
C = []
H = []

for i in S:
    if i[0] == "M":
        M.append(i)
    elif i[0] == "A":
        A.append(i)
    elif i[0] == "R":
        R.append(i)
    elif i[0] == "C":
        C.append(i)
    elif i[0] == "H":
        H.append(i)

L = [M,A,R,C,H]
L = list(map(len,L))
ans = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += L[i]*L[j]*L[k]

print(ans)

Measured memory_bytes: 10792
N = gets.to_i
G = (1..N).map{ Array.new(N, 0) }
N.times do
  u, k, *v = gets.split(' ').map(&:to_i)
  v.each do |vi|
    G[u - 1][vi - 1] = 1
  end
end

Q = [0] #?§????0?????\??£????????\???
D = Array.new(N, -1)
D[0] = 0 #?§???????????????¢???0??????????????¢???-1??¨????????????

while Q.size > 0
  cur = Q.shift
  (0..N-1).each do |dst|
    if G[cur][dst] == 1 && D[dst] == -1
      D[dst] = D[cur] + 1
      Q << dst
    end
  end
end

(0..N-1).each do |id|
  puts "#{id + 1} #{D[id]}"
end



# g.each do |r|
#   puts r.join(" ")
# end

Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool isYes = true;
    rep(i,4){
        if(count(all(s),s[i]) != 2) isYes = false;
    }
    if(isYes) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int m, d;
	int c[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	while(cin >> m >> d && (m || d)) {
		int total = 0;
		rep(i,m-1) {
			total += c[i];
		}
		total += d;
		switch(total % 7) {
		case 0: cout << "Wednesday" << endl;
			break;
		case 1: cout << "Thursday" << endl;
			break;
		case 2: cout << "Friday" << endl;
			break;
		case 3: cout << "Saturday" << endl;
			break;
		case 4: cout << "Sunday" << endl;
			break;
		case 5: cout << "Monday" << endl;
			break;
		case 6: cout << "Tuesday" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  ll n, X;
  cin >> n >> X;
  lvec x(n);
  REP(i, n) cin >> x[i];
  lvec c = x;
  x.push_back(X);
  sort(ALL(x));
  lvec a(n);
  REP(i, n) { a[i] = x[i + 1] - x[i]; }
  ll ans = 1e10;
  REP(i, n - 1) ans = min(ans, gcd(a[i], a[i + 1]));
  if (n == 1) ans = abs(c[0] - X);
  print(ans);
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define BUF_S 18000000
#define N 1010
#define in I()
using namespace std;
typedef long long ll;
int a,b,f[N][N];
inline int calc(int a,int b){
	if(f[a][b]>=0)return f[a][b];
	if(a<b)swap(a,b);
	bool vis[N];mset(vis,0);
	for(int i=1;i+i<=a;i++)vis[calc(a-i-i,b+i)]=1;
	for(int i=1;i+i<=b;i++)vis[calc(a+i,b-i-i)]=1;
	for(int i=0;;i++)if(!vis[i])return f[a][b]=i;
}
ll x,y;
int main(){
	cin>>x>>y;
	if(abs(x-y)>=2)puts("Alice");else puts("Brown");
//	mset(f,-1);
//	f[0][0]=f[0][1]=f[1][0]=f[1][1]=0;
//	for(int i=0;i<=15;i++,puts(""))for(int j=0;j<=15;j++)cout<<(calc(i,j)>0)<<" ";
//	for(int i=0;i<=15;i++,puts(""))for(int j=0;j<=15;j++)cout<<(abs(i-j)>=2)<<" ";
	return 0;
}

Measured memory_bytes: 384
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

r, d, x = na()

for i in range(10):
	x = r * x - d
	print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

const string eof = "END OF INPUT";
typedef vector <string> VS;
typedef vector <int> VI;
typedef istringstream ISS;

int main() {
    string line;
    while ( getline( cin, line ) ) {
        if ( line == eof ) break;
        string s = line;
        int n = s.size();
        int cnt = 0;
        VI L;
        for ( int i = 0; i < n; ++ i ) {
            cnt = 0;
            for ( ; i < n; ) {
                if ( s[i] == ' ' ) break;
                cnt ++;
                i ++;
            }
            L.push_back( cnt );
        }
        for ( VI::iterator it_i = L.begin(); it_i != L.end(); ++ it_i ) {
            cout << *it_i;
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
using namespace std;
const double INF =0x3f3f3f3f;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(abs(a-c)<=d)
      cout<<"Yes";
   else if(abs(a-b)<=d&&abs(b-c)<=d)
      cout<<"Yes";
   else
      cout<<"No";
}

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

const int N=200100,inf=1e9;
int a[N],ans,n,q1,q2,q3,q,mn[N*4];
vector<int>vec[N];

void bt(int o,int l,int r){
	if(l==r){
		mn[o]=(l?inf:0);
		return;
	}
	int mid=(l+r)/2;
	bt(o*2,l,mid);bt(o*2+1,mid+1,r);
	mn[o]=min(mn[o*2],mn[o*2+1]);
}

void query(int o,int l,int r){
	if(q1<=l&&r<=q2){
		q3=min(q3,mn[o]);
		return;
	}
	int mid=(l+r)/2;
	if(q1<=mid)query(o*2,l,mid);
	if(q2>mid)query(o*2+1,mid+1,r);
}

void modify(int o,int l,int r){
	if(l==r){
		mn[o]=min(mn[o],q3);
		return;
	}
	int mid=(l+r)/2;
	if(q1<=mid)modify(o*2,l,mid);
	else modify(o*2+1,mid+1,r);
	mn[o]=min(mn[o*2],mn[o*2+1]);
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i],ans+=!a[i];
	for(cin>>q;q --> 0;){
		int l,r;cin>>l>>r;
		vec[l].push_back(r);
	}
	bt(1,0,n);
	for(int i=1;i<=n;++i){
		for(int j:vec[i]){
			q1=i-1;q2=j;q3=inf;
			query(1,0,n);
			q1=q2=j;
			modify(1,0,n);
		}
		q1=q2=i-1;q3=inf;
		query(1,0,n);
		q1=q2=i;q3+=2*a[i]-1;
		modify(1,0,n);
	}
	q1=q2=n;q3=inf;query(1,0,n);
	cout<<(ans+q3)<<'\n';
	return 0;
}


Measured memory_bytes: 12800
N, X = map(int, input().split())
L = list( map(int, input().split()) )

d0 = 0
#d1 = d0 + L[0]

D = []
D.append(d0)

for i in range(1,N+1):
    D.append(D[i-1] + L[i-1])
    
print(len([i for i in D if i <= X ]))


Measured memory_bytes: 3060
#include<stdio.h>
int main(void) {
	long long A,B,N;
	scanf("%lld %lld %lld", &A, &B, &N);
	if (N >= B) {
		printf("%lld", A * (B - 1) / B);
		return 0;
	}
	printf("%lld", A * N / B);

	return 0;
}

Measured memory_bytes: 2152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int p[11];
int c[11];
int D,G;
int pmin = 10000;

void DFS(int now,int psum,int gsum,int a[]) {
    if (now == D)  {
        if (gsum >= G) {
            pmin = min(psum,pmin);
        }
        else {
            for (int i = D-1; i >= 0; i--) {
                if (a[i] == 0) {
                    if (G <= gsum+100*(i+1)*(p[i]-1)) {
                        psum += ((G-gsum-1)/(100*(i+1)))+1;
                        pmin = min(psum,pmin);
                    }
                    break;
                }
            }
        }
        return;
    }
    a[now] = 1;
    DFS(now+1,psum+p[now],gsum+100*p[now]*(now+1)+c[now],a);
    a[now] = 0;
    DFS(now+1,psum,gsum,a);
}

int main()
{
    cin >> D >> G;
    for (int i = 0; i <D; i++) {
        cin >> p[i] >> c[i];
    }
    int a[D];
    DFS(0,0,0,a);
    cout << pmin << endl;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
c=[0]*n
for i in a:c[i-1]+=1
ind=c.index(2)
x=[]
for i in range(n+1):
    if a[i]==ind+1:x.append(i)
m=n+x[0]-x[1]
ans=1
anss=1
for k in range(1,n+2):
    ans=(ans*(n-k+2))%mod
    ans=ans*pow(k,mod-2,mod)%mod
    if k==1:print(n);continue
    anss=(anss*(m-k+2))%mod
    anss=anss*pow(k-1,mod-2,mod)%mod
    if k-1>m:print(ans);continue
    print((ans-anss)%mod)

Measured memory_bytes: 14264
#!/usr/bin/env python
#coding:utf-8

def input_strs():
    return input().split(" ")

def input_nums():
    return [int(i) for i in input_strs()]


w = input()
ok = True

for c in w:
    p = 0
    for k in w:
        if c == k:
            p += 1
    ok = ok and (p % 2 == 0)

if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
N = gets.to_i
A = gets.split.map(&:to_i)

m = 0
sum = 0
min_abs = nil
N.times do |i|
  sum += A[i].abs
  if A[i] < 0
    if i != 0 && A[i - 1] == 0 || N - 1 > i && A[i + 1] == 0
      next
    end
    m += 1
  end
  if min_abs.nil? || min_abs > A[i].abs
    min_abs = A[i].abs
  end
end

if m.even?
  puts sum
else
  puts sum - min_abs * 2
end

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll mod = pow(10, 9) + 7;
    int n;
    cin >> n;
    ll a = modpow(10, n, mod);
    ll b = modpow(9, n, mod);
    ll c = modpow(8, n, mod);
    //cout << a << ' ' << b << ' ' << c << endl;
    ll ans = (a - (2 * b % mod - c)) % mod;
    if(ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
SS = input()
T = input()
S = ""
for i in range(len(SS) - len(T) + 1):
    flg = True
    for j in range(len(T)):
        if SS[i+j] == "?":
            continue
        elif SS[i+j] == T[j]:
            continue
        else:
            flg = False
            break
    if flg == True:
        S = SS[0:i] + T + SS[i+len(T):]

if S :
    print(S.replace('?','a'))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define REP(i,a,b)               for(int i = a; i<=b; i++)
int main()
{
    vector<int>v;
    int n,k;
    cin>>n>>k;
    while(n>0){
        int num=n%k;
        n=n/k;
        v.push_back(num);
    }
    cout<<v.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
s = list(input().rstrip())
ht = []
ponds=[]
for i, ch in enumerate(s):
    if ch == "\\":
        ht.append(i)
    elif ch == "/":
        if ht:
            b = ht.pop()
            ap = i - b
            if not ponds:
                ponds.append([b, ap])
            else:
                while ponds:
                    p = ponds.pop()
                    if p[0] > b:
                        ap += p[1]
                    else:
                        ponds.append([p[0],p[1]])
                        break
                ponds.append([b,ap])
    else:
        pass

ans = ""
area = 0
for point, ar in ponds:
    area += ar
    ans += " "
    ans += str(ar)
print(area)
print(str(len(ponds)) + ans)


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  auto a = vector<int>(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  long max = a[n - 1];
  a.pop_back();
  int index = lower_bound(ALL(a), max / 2.0) - a.begin();

  if(index >= (int)a.size()) {
    cout << max << " " << a[index - 1] << endl;
  } else if(index == 0) {
    cout << max << " " << a[index] << endl;
  } else if(abs(max / 2.0 - a[index]) > abs(max / 2.0 - a[index - 1])) {
    cout << max << " " << a[index - 1] << endl;
  } else {
    cout << max << " " << a[index] << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int flagc = 0, flagf = 0;
    rep(i, s.size()) {
        if(s[i] == 'C') {
            flagc = 1;
        }
        if(flagc && s[i] == 'F') {
            flagf = 1;
        }
    }

    if(flagf) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
int A[200000] = {};             //入力された数値を代入する配列A
int B[200000] = {};             //比較した後の数値を代入する配列B
int N, max[2];                  //max

scanf("%d",&N);                 //Nの入力
for(int i = 0; i < N; i++)
    scanf("%d",&A[i]);          //Aの入力

/*最大値をmaxに保存していく。ただし、i=jの時には比較を行わないようにした。 */
/*
for(int i = 0; i < N; i++){
    max = 0;
    for(int j = 0; j < N; j++){
        if(i != j){
            if(max<A[j]){
                max=A[j];
                B[i]=max;
            }
        }
    }
}*/
int max_num;
for(int i= 0;i < N+1;i++){
    if(max[0]<A[i]){
        max[1]=max[0];
        max[0]=A[i];
        max_num = i;
    }
    if(max[1]<A[i+1])
        max[1]=A[i+1];
}

//printf("一番大きいのは%d 二番目は%d\n",max[0],max[1]);

for(int k = 0; k < N; k++){
    if(k != max_num)
        printf("%d\n",max[0]);
    else
    {
        printf("%d\n",max[1]);
    }
    

}

}

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

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

int m,n;

int main2(){
	int S=m*m+n*n,C=0;
	for(int s=1;s<=S;s++)if(S%s==0){
		for(int x=-sqrt(s)-1e-9;x<=sqrt(s)+1e-9;x++){
			int y1=sqrt(s-x*x+1e-9);
			if(y1*y1!=s-x*x)continue;
			if((x*m+y1*n)%(x*x+y1*y1)==0 && (x*n-y1*m)%(x*x+y1*y1)==0)C++;
			if(y1>0){
				int y2=-y1;
				if((x*m+y2*n)%(x*x+y2*y2)==0 && (x*n-y2*m)%(x*x+y2*y2)==0)C++;
			}
		}
	}
	cout<<(C==8 ? "P":"C")<<endl;
	return 0;
}

int main(){
	int TC;
	cin>>TC;
	while(TC--){
		cin>>m>>n;
		main2();
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

bool possible(ll X, vector<int>& dp) {
	if(dp[X] != -1) {
		if(dp[X] == 0)
			return false;
		return true;
	}
	for(ll i = 100; i <= 105; i += 1) {
		if(dp[X - i] == 1) {
			dp[X] = 1;
			return true;
		}
		if(dp[X - i] == -1) {
			bool temp = possible(X - i, dp);
			if(dp[X - i] == 1) {
				dp[X] = 1;
				return true;
			}
		}
	}
	dp[X] = 0;
	return false;
}

int main() {

    zoom;
    ll X, i;
    cin >> X;
    vector<int> dp(100001, -1);
    for(i = 100; i <= 105; i += 1)
    	dp[i] = 1;
    for(i = 0; i < 100; i += 1)
    	dp[i] = 0;
    if(possible(X, dp))
    	cout << '1';
    else
    	cout << '0';
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    val a = Array.fill(n)(s.nextInt)
    var next = a(0) - 1
    for (i <- 1 until n) {
      if (next == 1) return i.toString
      next = a(next) - 1
    }
    "-1"
  }

  val tests = List(
    """3
      |3
      |1
      |2""".stripMargin -> """2""",
    """4
      |3
      |4
      |1
      |2""".stripMargin -> """-1""",
    """5
      |3
      |3
      |4
      |2
      |4""".stripMargin -> """3"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

if N<=111:
    ans=111
elif N<=222:
    ans=222
elif N<=333:
    ans=333
elif N<=444:
    ans=444
elif N<=555:
    ans=555
elif N<=666:
    ans=666
elif N<=777:
    ans=777
elif N<=888:
    ans=888
else:
    ans=999

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int n, k;
	cin>>n>>k;

	int h[n];
	for(int i = 0; i<n; i++) cin>>h[i];

	int ans = 0;
	for(int i = 0; i<n; i++) if(h[i] >= k) ans++;
	cout<<ans<<endl;
	
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 100003

int main(void)
{
  string st;
  cin>>st;

  st += "-----";

  string tmp;

  for(int i=0;i<4;i++) tmp += st[i];

  if(tmp == "YAKI")
  	puts("Yes");
  else
  	puts("No");
  return 0;
}


void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

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

  // LW[i]:i番目の人よりLeft にいる人のうち、Wを向いている人の数
  // RE[i]:i番目の人よりRightにいる人のうち、Lを向いている人の数
  // 求める答えは、LW[i]+RE[i]のうち最小のもの
  vi LW(n),RE(n);

  // LW の決定。LW[0]=0 としてよい
  for (int i = 1; i < n; i++) {
    if(s[i-1]=='W') LW[i] = LW[i-1] + 1;
    else LW[i] = LW[i-1];
  }
  // RE の決定。RE[n-1]=0
  for (int i = n-2; i >= 0; i--) {
    if(s[i+1]=='E') RE[i] = RE[i+1] + 1;
    else RE[i] = RE[i+1];
  }

  int ans = 1e9;
  rep(i, n) chmin(ans,LW[i]+RE[i]);
  std::cout << ans << '\n';
}


Measured memory_bytes: 2948
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[100005];
int sorted[100005];

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> dp;
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    sorted[i] = l[i];
  }
  sort(sorted, sorted+n);
  for(int i = 0; i < n; i += 2) {
    dp[sorted[i]]++;
  }
  int r = 0;
  for(int i = 0; i < n; i += 2) {
    if(!dp.count(l[i])) {
      r++;
    }
    else {
      if(--dp[l[i]] == 0) {
        dp.erase(l[i]);
      }
    }
  }
  printf("%d\n", r);
}


Measured memory_bytes: 3328
#include<stdio.h>

long long  F[1000000] = { 0 };

long long fibonacchi(int n)
{
	F[0] = F[1] = 1;
	for (int i = 2; i <= n; i++)
		F[i] = F[i - 1] + F[i - 2];
	return F[n];
}

int main()
{
	int n;
	scanf("%d", &n);
	printf("%lld\n", fibonacchi(n));
}


Measured memory_bytes: 2108