akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a, b;
    cin >> a >> b;
    int ans;
    ans = max(2 * a - 1, 2 * b - 1);
    ans = max(ans, a + b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll b[n];
  rep(i,n) b[i]=a[i];
  sort(b,b+n,greater<ll>());
  rep(i,n) {
    if(a[i]==b[0]) pr(b[1]);
    else pr(b[0]);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> vec{a,b,c};

  sort(vec.begin(), vec.end());

  cout << vec[0] * vec[1] / 2 << endl;


  return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  cin >> M;
  vector<int> A(M);
  int sum = 0;
  for (int i=0; i<M; i++) {
    cin >> A[i];
    sum += A[i];
  }
  if (N < sum) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int n;
  cin>>n;
  int ans=111;
  while(n>ans){
    ans+=111;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   if(k<=a)
   {
           cout<<k;
           return;
   }
   ll ans = a;
   k-=a;
   if(k<=b)
   {
        cout<<ans;
        return;
   }
   k-=b;
   cout<<(ans-k);
   
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

#define eb emplace_back
#define INF 1LL<<62
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<int, int>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  //YYMM, MMYY, AMBIGUOUS or NA.

  ll date_val;
  cin >> date_val;

  ll date_val_left = date_val / 100;
  ll date_val_right = date_val % 100;

  string res = "NA";
  if (date_val_left > 0 && date_val_left <= 12) {
    if (date_val_right > 0 && date_val_right <= 12) {
      res = "AMBIGUOUS";
    } else {
      res = "MMYY";
    }
  } else {
    if (date_val_right > 0 && date_val_right <= 12) {
      res = "YYMM";
    }
  }
  cout << res;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort( a, a + 3 );
    if( a[2] == a[1] && a[1] == a[0] ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc165c()
}

fun abc165c() {
    val (n, m, q) = readLine()!!.split(" ").map { it.toInt() }
    val pattern = mutableListOf<IntArray>()
    for (i in 1..m) {
        makePattern(n, m, i, pattern, mutableListOf<Int>(i))
    }
    val query = mutableListOf<Query>()
    repeat(q) {
        val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
        // aとbはインデックスなので-1している
        val q = Query(a - 1, b - 1, c, d)
        query.add(q)
    }
    val poiints = pattern.map { calculatePoint(it, query) }
    println(poiints.max())
}

private fun makePattern(n: Int, m: Int, c: Int, pattern: MutableList<IntArray>, current: MutableList<Int>) {
    if (current.size == n) {
        pattern.add(current.toIntArray())
        return
    }
    for (i in c..m) {
        val next = mutableListOf<Int>()
        next.addAll(current)
        next.add(i)
        makePattern(n, m, i, pattern, next)
    }
}

private fun calculatePoint(list: IntArray, query: MutableList<Query>): Int {
    var total = 0
    for (q in query) {
        if (list[q.b] - list[q.a] == q.c) total += q.d
    }
    return total
}

data class Query(val a: Int, val b: Int, val c: Int, val d: Int)

Measured memory_bytes: 67188
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//sort(l,l+N,greater<int>());	降順ソート
//sort(l,l+N);	昇順ソート
//string 変数　　変数.size()で数字化


int main(void)
{
	int n;
	cin >> n;
	int i = 1;
	for (i; i <= n; i *= 2) {

	}
	i /= 2;
	cout << i << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define nfree -1
#define free 1
void putQueen(int);
void print();
int A[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int main(){

  int n;
  int i,j;
  int x,y;
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      A[i][j] = 0;
    }
  }
  
  for(j=0; j<N; j++){
    row[j]=0;
    col[j]=0;
  }
  for(j=0; j<2*N-1; j++){
    dpos[j]=0;
    dneg[j]=0;
  }
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d %d",&x,&y);
    A[x][y] = 1;
  }
  
  putQueen(0);

  return 0;
}

void putQueen(int i){
  int j;

  if(i==N){
    print();
    return;
  }
  
  for(j=0; j<N; j++){
    if(nfree==col[j]||nfree==dpos[i+j]||nfree==dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = nfree;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}

void print(){
  
  int i,j;
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(A[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}




    
    

Measured memory_bytes: 572
# ALDS1_5_A.

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def binary_search(S, k):
    a = 0; b = len(S) - 1
    if b == 0: return S[0] == k
    while b - a > 1:
        c = (a + b) // 2
        if k <= S[c]: b = c
        else: a = c
    return S[a] == k or S[b] == k

def show(a):
    # 配列aの中身を出力する。
    _str = ""
    for i in range(len(a) - 1): _str += str(a[i]) + " "
    _str += str(a[len(a) - 1])
    print(_str)

def main():
    n = int(input())
    A = intinput()
    q = int(input())
    m = intinput()
    # 配列Aの作る数を調べる。
    nCanMake = [0]
    for i in range(n):
        for k in range(len(nCanMake)):
            x = nCanMake[k] + A[i]
            if not x in nCanMake: nCanMake.append(x)
    # show(nCanMake)
    for i in range(q):
        if m[i] in nCanMake: print("yes")
        else: print("no")

if __name__ == "__main__":
    main()


Measured memory_bytes: 5628
#include <iostream>

void print_array(int a[], int n)
{
    for (int i = 0; i < n; ++i)
    {
        if (0 < i)
        {
            std::cout << " ";
        }

        std::cout << a[i];
    }

    std::cout << std::endl;
}

int selection_sort(int a[], int n)
{
    auto swap_count = 0;
    for (int i = 0; i < n; ++i)
    {
        auto min_index = i;

        for (int j = i; j < n; ++j)
        {
            if (a[j] < a[min_index])
            {
                min_index = j;
            }
        }

        if (i != min_index)
        {
            swap_count++;
            std::swap(a[i], a[min_index]);
        }
    }

    return swap_count;
}


int main()
{
    int n;
    std::cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
    }

    auto swap_count = selection_sort(a, n);
    print_array(a, n);
    std::cout << swap_count << std::endl;

    return 0;
}


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

int main() {
  int a,b;
  scanf("%d %d",&a,&b);
  int n;
  if (b<10) {
    n = a*10+b;
  } else {
    if (b<100) {
      n = a*100+b;
    } else {
      n = a*1000+b;
    }
  }
  if(floor(sqrt(n))*floor(sqrt(n)) == n) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    while (true) {
        string S = to_string(N);
        map <char, int> cnt;
        for (char s : S) {
            cnt[s]+=1;
        }
        if (cnt.size()==1) {
            cout << S;
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M,a[1<<17];
long ans=9e18,now;
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
		a[i]--;
	}
	vector<pair<int,int> >E;
	for(int i=1;i<N;i++)
	{
		if(a[i-1]<a[i])E.push_back(make_pair(a[i-1],a[i]));
		else E.push_back(make_pair(a[i-1]-M,a[i]));
		now+=(a[i]-a[i-1]+M)%M;
	}
	for(int i=0;i<N-1;i++)E.push_back(make_pair(E[i].first+M,E[i].second+M));
	sort(E.begin(),E.end());
	priority_queue<pair<int,int> >P;
	int id=0;
	for(int x=0;x<M;x++)
	{
		now-=P.size();
		while(id<2*N-2&&E[id].first<x)
		{
			P.push(make_pair(-E[id].second,E[id].second-E[id].first));
			now+=E[id].second-x+1;
			now-=E[id].second-E[id].first;
			id++;
		}
		ans=min(ans,now);
		while(!P.empty()&&-P.top().first==x)
		{
			now+=P.top().second-1;
			P.pop();
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3952
#include <iostream>
using namespace std;
	int main(){
		int a,b,c,x,y,n;
		n = 0;
		cin >> a >> b >> c ;
		a <= b ;
		1 <= a,b,c <= 10000;
		while ( x  <= b  ){
			for ( x = a ; x <= b ; x ++ )
			if ( c % x == 0 )
				n = n + 1;
			}
		cout << n << endl;
	}

Measured memory_bytes: 1160
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		ArrayList <Queue<Integer>> queues = new ArrayList <Queue<Integer>>();  //QueueのArrayListを生成
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			for (int i=0; i<n; i++) {
				queues.add(new ArrayDeque<Integer>());  //n個のqueueを追加
			}
			int times = sc.nextInt();
			for (int i=0; i<times; i++) {
				int request = sc.nextInt();  //命令 0 enqueue 1 front 2 dequeue
				int que = sc.nextInt();  //何個目のqueue
				switch (request) {
				//enqueue(que,x)
				case 0:
					int x = sc.nextInt();
					queues.get(que).add(x);
					break;
				//front(que)
				case 1:
					if (queues.get(que).size() != 0) { //空じゃなかったら
						System.out.println(queues.get(que).peek());
					}
					break;
				//dequeue(que)
				case 2:
					if (queues.get(que).size() != 0) { //空じゃなかったら
						queues.get(que).poll();
					}
					break;

				}
			}
		}
	}
}



Measured memory_bytes: 168648
s = input()
ans = 0
p = 0
g = 0
for e in s:
  if e=='g':
    if p==g:
      g += 1
    else:
      p += 1
      ans += 1
  else:
    if p==g:
      g += 1
      ans -= 1
    else:
      p += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30);
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
vector<vector<P>> G;
int n;
vector<int> co;
void dfs(int i, int c, int p) {
    co[i] = c;
    for(auto& e : G[i]) {
        if(e.first == p) {
            continue;
        }
        if(e.second) {
            dfs(e.first, (c ^ 1), i);
        } else {
            dfs(e.first, c, i);
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    G.resize(n);
    co.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        G[u].push_back(P(v, w % 2));
        G[v].push_back(P(u, w % 2));
    }
    dfs(0, 0, -1);
    for(int i = 0; i < n; i++) {
        cout << co[i] << endl;
    }
}


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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
    string S;cin>>S;
    map<char, int> als;
    for (auto c : S) als[c]++;
    int cnt = 0;
    bool ans = true;
    for (auto p : als) {
        cnt++;
        ans &= p.second == 2;
    }
    ans &= cnt == 2;

    cout << (ans ? "Yes" : "No") << endl; 
	
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main() {
	int N, K, L; cin >> N >> K >> L;
	
	UnionFind a(N), b(N);
	rep(i, K) {
		int p, q; cin >> p >> q;
		p--; q--;
		a.unionSet(p, q);
	}
	rep(i, L) {
		int p, q; cin >> p >> q;
		p--; q--;
		b.unionSet(p, q);
	}
	map<P, int> s;
	rep(i, N) {
		s[{ a.root(i), b.root(i) }]++;
	}
	rep(i, N) {
		cout << s[{ a.root(i), b.root(i) }] << " ";
	}
	//cout << endl;

	system("pause");
}

Measured memory_bytes: 15352
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[100000], b[100000], c[100000];
ll d[100000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    for (int i = 0; i < n; ++i)
        cin >> c[i];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for (int i = 0; i < n; ++i)
        d[i] = n - (lower_bound(c, c + n, b[i] + 1) - c);
    for (int i = n - 2; i >= 0; --i)
        d[i] += d[i + 1];

    ll sol = 0;
    for (int i = 0; i < n; ++i)
    {
        int k = lower_bound(b, b + n, a[i] + 1) - b;
        if (k != n)
            sol += d[k];
    }
    cout << sol;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int t[110000], x[110000], y[110000];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=0; i<N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
    bool can = true;
    
    for (int i=0; i<N; i++){
        int dis = abs(x[i] - x[i+1]) + abs(y[i] - y[i+1]);
        int can_dis = t[i+1] - t[i];
        // cout << "dis:     " << dis << endl;
        // cout << "can_dis: " << can_dis << endl;
        if (can_dis >= dis){
            if((can_dis - dis) % 2 != 0){
                can = false;
                break;
            }
        }else{
            can = false;
            break;
        }
    }
    
    if(can)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {

  int d;
  while( cin >> d ) {

    long long int s = 0;

    for ( int i = 0; i < 600/d; i++ ) {

      int x = i * d;
      s += x*x*d;

    }

    cout << s << endl;

  }

  return 0;

}

Measured memory_bytes: 1156
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 2e3 + 2;
const int OO = 1e9 + 7;
using namespace std;
int main() {
    IO;
    ld l; cin>>l;
    cout<<fixed<<setprecision(12)<<powl(l/3,3);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int head[N],col[N],dfn[N],low[N],s[N],in[N],xx[N],yy[N],pos[N];
int n,c,rt,ans,cnt,tmp,num,pre,top;
struct tree{
	int l,r;
}t[N<<2];
struct edge{
	int to,nex;
}e[N<<1];
struct node{
	int x,y;
	bool operator <(const node &b)const{
		return x<b.x;
	}
}a[N];
void add(int x,int y)
{

	e[++cnt].to=y;e[cnt].nex=head[x];head[x]=cnt;
}
void build(int &x,int l,int r)
{
	if(l==r){
		x=(a[l].y<=n)?a[l].y+n:a[l].y-n;
		pos[a[l].y]=l;return;
	}x=++num;
	int mid=l+r>>1;
	build(t[x].l,l,mid);build(t[x].r,mid+1,r);
	add(x,t[x].l);add(x,t[x].r);
	return;
}
void change(int x,int l,int r,int L,int R,int p)
{
	if(L>R)return;
	if(l==L&&r==R)
	{
		add(p,x);return;
	}
	int mid=l+r>>1;
	if(mid>=R)change(t[x].l,l,mid,L,R,p);
	else if(L>mid)change(t[x].r,mid+1,r,L,R,p);
	else change(t[x].l,l,mid,L,mid,p),change(t[x].r,mid+1,r,mid+1,R,p);
	return;
}
void dfs(int x)
{
	dfn[x]=low[x]=++tmp;
	s[++top]=x;in[x]=1;
	for(int i=head[x];i;i=e[i].nex)
	{
		int y=e[i].to;
		if(!dfn[y])
		{
			dfs(y);
			low[x]=min(low[x],low[y]);
		}
		else if(in[y])low[x]=min(low[x],dfn[y]);
	}
	if(low[x]==dfn[x])
	{
		c++;int a=-1;
		do{
			a=s[top--];
			in[a]=0;
			col[a]=c;
		}while(a!=x);
	}
	return;
}
void init()
{
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	memset(col,0,sizeof(col));
	tmp=c=0;
	return;
}
bool judge(int x)
{
	init();
	for(int i=1;i<=n*2;++i)head[i]=0;cnt=pre;
	for(int i=1;i<=n;++i)
	{
		int AL=lower_bound(a+1,a+1+2*n,(node){xx[i]-x+1,0})-a;
		int AR=upper_bound(a+1,a+1+2*n,(node){xx[i]+x-1,0})-a-1;
		if(AL<=AR)change(rt,1,n*2,AL,pos[i]-1,i),change(rt,1,n*2,pos[i]+1,AR,i);
		int BL=lower_bound(a+1,a+1+2*n,(node){yy[i]-x+1,0})-a;
		int BR=upper_bound(a+1,a+1+2*n,(node){yy[i]+x-1,0})-a-1;
		if(BL<=BR)change(rt,1,n*2,BL,pos[i+n]-1,i+n),change(rt,1,n*2,pos[i+n]+1,BR,i+n);
	}
	for(int i=1;i<=num;++i)
	if(!dfn[i])dfs(i);
	for(int i=1;i<=n;++i)
	if(col[i]==col[i+n])return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&xx[i],&yy[i]);
		a[i*2-1].x=xx[i];a[i*2].x=yy[i];
		a[i*2-1].y=i;a[i*2].y=i+n;
	}num=n*2;
	sort(a+1,a+1+n*2);
	build(rt,1,n*2);
	int l=0,r=1e9;pre=cnt;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(judge(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 36608
#include <iostream>

using namespace std;

int main(void){

	int N = 0;
	int ans;
	
	cin >> N;
	
	if(N % 2 == 0){
		ans = N / 2;
	}else
	{
		ans = (N / 2) + 1;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define ll long long
#define ull unsigned long long

#define PI (3.1415926535897932)
#define eps 1e-8

struct Query
{
	int vert;
	int dist;
	int col;
};
struct Edge
{
	int a, b;
};

list<int> ve[100001];
int dp[1000001][11];

void color(int v, int d, int c) {
	if (dp[v][d] < 0 && d >= 0) {
		dp[v][d] = c;
		color(v, d - 1, c);
		for (auto u : ve[v]) {
			color(u, d - 1, c);
		}
	}
}

void solve(int N, int M, int Q, Edge* e, Query* q) {
	SET(dp, -1);
	
	REP(i, M)ve[e[i].b].push_back(e[i].a);
	REP(i, M)ve[e[i].a].push_back(e[i].b);

	RREP(i, Q) color(q[i].vert, q[i].dist, q[i].col);
}

int main() {
	int N, M, Q;
	Edge e[100001];
	Query q[100001];

	cin >> N >> M;
	REP(i, M)cin >> e[i].a >> e[i].b;
	cin >> Q;
	REP(i, Q)cin >> q[i].vert >> q[i].dist >> q[i].col;

	solve(N, M, Q, e, q);

	REP(i, N) {
		cout << max(dp[i + 1][0], 0) << endl;
	}
}


Measured memory_bytes: 53376
def solve(string):
    a, b = map(int, string.split())
    if b == 0:
        return "0"
    bin_a = "{:040b}".format(a)
    bin_b = "{:040b}".format(b)
    aa = [-1 if _a == "0" else int(bin_a[i + 1:] or "0", 2) for i, _a in enumerate(bin_a)]
    bb = [-1 if _b == "0" else int(bin_b[i + 1:] or "0", 2) for i, _b in enumerate(bin_b)]
    index = 0
    while True:
        if bb[index] != -1:
            break
        index += 1
    ans = []
    for i in range(index, 40):
        tmp = 0
        tmp += (bb[i] + 1) % 2 if bb[i] >= 0 else 0
        tmp += aa[i] % 2 if aa[i] > 0 else 0
        ans.append(str(tmp % 2))
    ans[-1] = str((b - a) // 2 % 2) if a % 2 == b % 2 == 0 else str(((b - a) // 2 + 1) % 2)
    return str(int("".join(ans), 2))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int TRAIN = Math.min(A, B);
		int BUS = Math.min(C, D);
		System.out.println(TRAIN + BUS);
	}

}

Measured memory_bytes: 20820
def main():
  a, b = map(int, input().split())
  cnt = 0
  for i in range(a, b+1):
    if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]:
      cnt += 1
  print(cnt)
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))


s = input()
ans = 0
s_nox = s.replace('x', '')
if(s_nox != s_nox[::-1]): ans = -1
else:
    need = (len(s_nox)+1) // 2
    s = list(s)
    s_rev = s[::-1]
    si = 0
    srevi = 0
    si_tmp = -1
    srevi_tmp = -1
    for i in range(need):
        si_tmp = 0
        srevi_tmp = 0
        while(s[si] == 'x'):
            si += 1
            si_tmp += 1
        while(s_rev[srevi] == 'x'):
            srevi += 1
            srevi_tmp += 1
        ans += abs(si_tmp - srevi_tmp)
        si += 1
        srevi += 1
print(ans)



Measured memory_bytes: 4852
n, m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
queries = []
m.times { queries << gets.split.map(&:to_i) }
queries.sort! { |a, b| b[1] <=> a[1] }
after_changed = []
(0...n).each do |i|
  if after_changed.empty? && !queries.empty?
    count, changed = queries.shift
    after_changed = [changed] * count
  elsif after_changed.empty? && queries.empty?
    break
  end
  if cards[i] < after_changed[0]
    cards[i] = after_changed.shift
  end
end
puts cards.inject(:+)


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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

long twon(long n, long mod){
    if(n == 0)
        return 1;
    if(n == 1)
        return 2;
    if(n % 2 == 0){
        long temp;
        temp = twon(n/2, mod);
        temp *= temp;
        temp %= mod;
        return temp;
    }else{
        long temp1, temp2;
        temp1 = twon((n+1)/2, mod);
        temp2 = twon((n-1)/2, mod);
        temp1 *= temp2;
        temp1 %= mod;
        return temp1;
    }
}

int main()
{
    int n, k;
    cin >> n >> k;
    long ue[200005], shita[200005];
    long mod = 1000000007;
    ue[0] = 1;
    shita[0] = 1;
    REP(i, 200004){
        ue[i+1] = ue[i] * (long)(i+1);
        ue[i+1] %= mod;
        shita[i+1] = shita[i] * modinv((long)(i+1), mod);
        shita[i+1] %= mod;
    }
    long heya[200005];
    REP(i, n){
        heya[i] = ue[n] * ue[n-1];
        heya[i] %= mod;
        heya[i] *= shita[n-i-1];
        heya[i] %= mod;
        heya[i] *= shita[n-i-1];
        heya[i] %= mod;
        heya[i] *= shita[i+1];
        heya[i] %= mod;
        heya[i] *= shita[i];
        heya[i] %= mod;
    }
    long ans = 0;
    REP(i, n)
        if(k >= (n-1-i)){
            ans += heya[i];
            ans %= mod;
        }
    cout << ans << endl;



    return 0;
    
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100001];

int main() {
	ll n;
	cin >> n;
	ll h[100001];
	for (ll i = 0; i < n; i++) cin >> h[i];
	for (ll i = 1; i < 100001; i++) dp[i] = INF;

	ll ans = 0;
	for (ll i = 0; i <= n-2; i++) {
		int a = abs(h[i] - h[i + 1]);
		dp[i + 1] = min(dp[i + 1], dp[i] + a);
		if (i <= n-3) {
			int b = abs(h[i] - h[i + 2]);
			dp[i + 2] = min(dp[i + 2], dp[i] + b);
		}
		ans = min(dp[i + 1], dp[i + 2]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int a[6],k;
template<typename I>inline void read(I&ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0' && ch<='9'){x=10*x+ch-'0'; ch=getchar();}
	ot=x*f;}
template<typename I,typename... U>inline void read(I&x,U&... y){read(x); read(y...);}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a[1],a[2],a[3],a[4],a[5],k);
	for(int i=2;i<=5;i++)
	{
		if(a[i]-a[1]>k) 
		{
			printf(":(\n");
			return 0;
		}
	}
	printf("Yay!\n");
//	fclose(stdin); fclose(stdout);
	return 0;
}


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

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

  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  ll MOD = 1e9 + 7;
  vector<ll> dp(K + 2, 0), dp2(K + 2, 0);
  dp2[0] = 1;
  for (ll i = 0; i < N; i++) {
    vector<ll> S(K + 2, 0);
    for (ll j = 0; j <= K; j++) {
      S[j + 1] = (S[j] + dp2[j]) % MOD;
      dp[j + 1] = 0;
    }
    dp[0] = 0;

    for (ll j = 0; j <= K; j++) {
      ll l = max(0ll, j - A[i]);
      ll r = j + 1;
      dp[j] += (S[r] - S[l]);
      dp[j] = (dp[j] + MOD) % MOD;
    }
    // cout << S[0]; for (int i = 1; i < S.size(); i++) { cout << ' ' << S[i]; }
    // cout << '\n';
    // cout << dp[0]; for (int i = 1; i < dp.size(); i++) { cout << ' ' << dp[i]; }
    // cout << '\n';
    // cout << '\n';
    dp2 = dp;
  }

  cout << dp[K] << '\n';
  return 0;
}

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

using namespace std;
const long long MOD = (long long) 1e9 + 7;

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

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }

    // nが奇数のとき
    if (n % 2 == 1) {
        if (mp[0] != 1) {
            cout << 0 << endl;
            return 0;
        }

        for (int i = 2; i <= n - 1; i += 2) {
            if (mp[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    // nが偶数のとき
    if (n % 2 == 0) {
        for (int i = 1; i <= n - 1; i += 2) {
            if (mp[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    long long ans = 1;
    for (int i = 0; i < n / 2; ++i) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        int[] L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int N = L[0], Y = L[1];
        for (int x = 0; x <= N; x++)
        {
            for (int y = 0; y + x <= N; y++)
            {
                int z = N - x - y;
                if (z < 0) break;
                if (10000 * x + 5000 * y + 1000 * z == Y)
                {
                    Console.WriteLine(x + " " + y + " " + z);
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
struct Cake {
    long long x, y, z;
    Cake() {
        x = y = z = 0;
    }
};
long long ans, temp;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<Cake> C(N);
    for (auto &c : C) cin >> c.x >> c.y >> c.z;
    for (int t = 0; t < 8; t++) {
        sort(C.begin(), C.end(), [&t](const Cake &a, const Cake &b) {
            return (t%2 == 1 ? a.x : -a.x) + ((t>>1)%2 == 1 ? a.y : -a.y) + ((t>>2)%2 == 1 ? a.z : -a.z) > (t%2 == 1 ? b.x : -b.x) + ((t>>1)%2 == 1 ? b.y : -b.y) + ((t>>2)%2 == 1 ? b.z : -b.z); 
        });
        temp = 0;
        for (int i = 0; i < M; i++) {
            temp += (t%2 == 1 ? 1 : -1)*C[i].x+((t>>1)%2 == 1 ? 1 : -1)*C[i].y+((t>>2)%2 == 1 ? 1 : -1)*C[i].z;
        }
        ans = max(ans, temp);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

def main():
    n = int(input())
    count = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            return
    print('No')
    
main()



Measured memory_bytes: 9156
# BFS queue
import queue
import copy
import time
sss = time.time()
H, W = map(int,input().split())
b = [list(input()) for _ in range(H)]
dist = [[10**2 for _ in range(W)] for _ in range(H)]
start = (-1,-1)
qq = queue.Queue()
# start把握
for i in range(H):
    for j in range(W):
        if b[i][j] == '.':
            qq.put((i,j))
far = 0
move = [(-1,0), (0,-1), (1,0), (0,1)]
def BFS(start, bb):
    dist = [[10**2 for _ in range(W)] for _ in range(H)]
    far = 0
    q = queue.Queue()
    q.put(start)
    dist[start[0]][start[1]] = 0
    # BFS
    while 1:
        now = q.get()
        x = now[0]
        y = now[1]
        olddist = dist[x][y]
        bb[x][y] = '#'
        for elem in move:
            dx = elem[0]
            dy = elem[1]
            xx = x+dx
            yy = y+dy
            if xx>=0 and xx<= H-1 and yy>=0 and yy<=W-1:
                if bb[xx][yy] != '#':
                    if dist[xx][yy] == 10**2:
                        dist[xx][yy] = olddist + 1
                        far = max([far,olddist+1])
                        q.put((xx,yy))
        if q.empty():
            break
    return far
res = 0
while 1:
    ttt = time.time()
    if sss-ttt >= 1.8:
        break
    now = qq.get()
    res = max([res, BFS(now, copy.deepcopy(b))])
    if qq.empty():
        break
print(res)


Measured memory_bytes: 59864
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String str = sc.next();

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < str.length() - 2; i++) {
            int value = Integer.valueOf(str.substring(i, i + 3));
            ans = Math.min(Math.abs(753 - value) , ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
string s;
int p;

char let()
{
	char c = s[p];
	p++;
	while (p<s.size()&&(s[p] == '+' || s[p] == '-'))
	{
		if (s[p] == '+') c++;
		else c--;
		if (c < 'A') c += 26;
		if (c > 'Z') c -= 26;
		p++;
	}
	return c;
}


string solve()
{
	string ans;
	while (1) 
	{
		if (p >= s.size()) return ans;
		while (p < s.size() && (isalpha(s[p]) || s[p] == '?'))
		{
			if (isalpha(s[p])) ans += let();
			if (s[p] == '?')
			{
				ans += 'A';
				p++;
				while (s[p] == '+' || s[p] == '-')
				{
					p++;
				}
			}
		}
		if (p >= s.size() || s[p] == '[')
		{
			p++;
			return ans;
		}
		if (s[p] == ']')
		{
			p++;
			string t = solve();
			reverse(ALL(t));
			ans += t;
		}
	}
}

int main()
{
	while (cin >> s, s != ".")
	{
		reverse(ALL(s));
		p = 0;
		string ans = solve();
		reverse(ALL(ans));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
char a[10010]; 
bool c,f;
int main() {
    scanf("%s", a);
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f==true) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
def nasu(a, j):
  return [-2*j, j * j + a]

def tami(x, ab):
  a, b = ab
  return a * x + b

def renritu(ab1, ab2):
  a1, b1 = ab1
  a2, b2 = ab2
  return (b2 - b1) / (a1 - a2)

def add(a, b):
  ab3 = nasu(a, b)
  while len(L) >= 2:
    ab1 = L[-2]
    ab2 = L[-1]
    x1 = renritu(ab1, ab2)
    x2 = renritu(ab2, ab3)
    if x1 > x2:
      L.pop()
    else:
      break
  L.append(ab3)

N, C = list(map(int, input().split()))
h = list(map(int, input().split()))

DP = [0] * N
L = [nasu(0, h[0])]

cnt = 0
for i in range(1, N):
  while cnt < len(L) - 1:
    x = tami(h[i], L[cnt])
    y = tami(h[i], L[cnt + 1])
    if x >= y:
      cnt += 1
    else:
      break
  DP[i] = h[i] ** 2 + C + tami(h[i], L[cnt])
  add(DP[i], h[i])

print(DP[-1])

Measured memory_bytes: 113280
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int ans[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    for(int i=n;i>=1;i--){
        sum = 0;
        for(int j=2*i;j<=n;j+=i)
            sum+=ans[j];
        ans[i] = ((sum&1)^(A[i]&1));
    }

    cnt = 0;

    for(int i=1;i<=n;i++)
        if(ans[i])cnt++;

    cout<<cnt<<"\n";

    for(int i=1;i<=n;i++)
        if(ans[i])cout<<i<<" ";

    return 0;
}


Measured memory_bytes: 2560
n = int(input())
a = sorted([int(x) for x in input().split()])
ret = 0
for i in range(n-1, 0, -1):
	l = 0
	r = i-1
	while l<r:
		if a[l]+a[r]>a[i]:
			ret += r - l
			r -= 1
		else:
			l += 1

print(ret)

Measured memory_bytes: 3188
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	ll h, a;
	scanf("%lld%lld", &h, &a);
	if(h % a == 0) printf("%lld", h / a);
	else printf("%lld", h / a + 1);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define mk make_pair
#define pp pair<int,int>
#define ppl pair<long long int,long long int>
#define vec vector<int> 
#define finput ifstream cin;cin.open("input.txt")
#define foutput ofstream cout;cout.open("output.txt") 

int main(){
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA";
		return 0;
	}
 	if(s[1]-'a' >= 26 || s[1]-'a'< 0){
 		cout<<"WA";
 		return 0;
 	}
 	int count=0;
 	for(int i=2;i<s.size()-1;i++){
 		if(s[i]=='C') count++;
 		if(s[1]-'a' >= 26 || s[1]-'a'< 0){
 			cout<<"WA";
 			return 0;
 		}
 	}
 	if(s[s.size()-1]-'a' >= 26 || s[s.size()-1]-'a'< 0){
		cout<<"WA";
		return 0;
	}
 	if(count!=1){
 		cout<<"WA";
 		return 0;	
 	}
 	cout<<"AC";

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n;
  ll i,j,k,ans = 0;
  cin >> n;
  vl a(n);
  vl b(3);
  forn(0,n,i){
    cin >> a[i];
  }

  forn(1,n - 1,i){
    b[0] = a[i - 1];
    b[1] = a[i];
    b[2] = a[i + 1];
    sort(all(b));
    if(b[1] == a[i])
      ans++;
  }

  cout << ans << '\n';

  ktj();

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,n;
    string s,s1;
    cin >> n >> a >> b;
    if(n*a > b) cout << b << endl;
    else cout << n*a << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	sort(all(A));

	ll ans = 0;
	rep(i, 2) {
		deque<int> dq;
		int l = 0, r = N-1;
		// 小さい方から開始して、小→大大→小小→..
		if (i==0 ) dq.push_back(A[l++]);
		else dq.push_back(A[r--]);

		int now = i;
		while (r-l>=1) {
			if (now%2==0) {
				dq.push_front(A[r--]);
				dq.push_back(A[r--]);
			} else {
				dq.push_front(A[l++]);
				dq.push_back(A[l++]);
			}
			now++;
		}
		if (l==r) {
			if (abs(dq.back()-A[l])>abs(dq.front()-A[l])) dq.push_back(A[l]);
			else dq.push_front(A[l]);
		}

		ll tmp = 0;
		rep(j, N-1) {
			tmp += abs(dq[j]-dq[j+1]);
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;	
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int N;
    int x[200][3] = {};
	int a[200][3] = {};
	int ans[200] = {};
	int i, j, k;

    scanf("%d", &N);
	
    for(i = 0; i < N; i++){
        scanf("%d %d %d",&x[i][0],&x[i][1],&x[i][2]);
    }
    for(i = 0; i < 3; i++){
        for(j = 0; j < N; j++){
			for(k = 0; k < N; k++){
				if(x[j][i] == x[k][i]){
					a[j][i]++;
				}
			}
        }
        for(j = 0; j < N; j++){
            if(a[j][i] == 1){
                ans[j] = ans[j] + x[j][i];
            }
        }
    }
    for(i = 0; i < N; i++){
        printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char s[10010],*c;
  scanf("%d%*c",&n);
  while(n--){
    fgets(s,1010,stdin);
    while(c=strstr(s,"Hoshino"))*(c+6)='a';
    printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 616
c=[0,2,5,5,4,5,6,3,7,6]
N,M=gets.split.map &:to_i
A=gets.split.map &:to_i
d=Array.new(N+1,p)
d[0]=0
0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max}
p d[N]

Measured memory_bytes: 36220
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
}rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

int main() {
	int n = rd, x = rd, y = rd, z = rd;
	while(--n) {
		int a = rd, b = rd, c = rd;
		std::tie(x, y, z) = std::make_tuple(a + std::max(y, z), b + std::max(x, z), c + std::max(x, y));
	}
	std::cout << std::max({x, y, z});
	return 0;
}


Measured memory_bytes: 256