akhauriyash/Code-Regression huggingface dataset:
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

bool g[5][5];

void solve(bool __attribute__((unused)) read) {
	int n = 4;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        g[x][y] = g[y][x] = 1;
    }
    vector <int> p(n);
    for (int i = 0; i < n; ++i) {
        p[i] = i;
    }
    do {
        int fl = 1;
        for (int i = 0; i < (int)p.size() - 1; ++i) {
            if (!g[p[i]][p[i + 1]]) {
                fl = 0;
                break;
            }
        }
        if (fl) {
            cout << "YES\n";
            return;
        }
    } while (next_permutation(all(p)));

    cout << "NO\n";
}

// IDI OBRATNO KOD SMOTRET, RANO POKA SUBMITIT


Measured memory_bytes: 256
def gcd(a, b):
    bigger = max(a, b)
    smaller = min(a, b)
    while smaller != 0:
        bigger, smaller = smaller, bigger % smaller
    return bigger


n, entry = map(int, input().split())
X = list(map(int, input().split()))
X.append(entry)
X.sort()
for i in range(n, 0, -1):
    X[i] -= X[i - 1]
del X[0]
ans = X.pop()
for x in X:
    ans = gcd(ans, x)
print(ans)


Measured memory_bytes: 14252
//50000 for aizu0056
#define IN_MAX 1000000

char table[IN_MAX+1];

void createtable1(){ //0->prime 1->not prime
  int i=2,j;
  table[1]=1;
  for(;i<=IN_MAX;i++)
    if(!table[i])
      for(j=i*2;j<=IN_MAX;j+=i)
        table[j]=1;
}

void put(int n){
  int i=2,s=0;
  for(;i<=n/2;i++){
    if(table[i])continue;
    if(!table[n-i]){
      s++;
    }
  }
  printf("%d\n",s);
}

int main(){
  int n;
  createtable1();
  while(1){
    scanf("%d",&n);
    if(!n)return 0;
    put(n);
  }
}

Measured memory_bytes: 0
s,_,*q=open(0)
a=['',s[:-1]]
p=1
for q in q:
  q,*f=q[::2]
  if q>'1':
    f,c=f
    a[(1if f<'2'else 0)^p]+=c
  else:p^=1
print(a[p^1][::-1]+a[p])

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
pair < int, int > a[N];


int get (int l, int r) {
	if (l > r) return 0;
	return r - l + 1;
}

int main () {
   SpeedForce;
	cin >> n;
	int ans = 0;
	multiset < int > L1, R1, L2, R2;
   for (int i = 1; i <= n; i ++) {
		cin >> a[i].F >> a[i].S;
		L2.insert(a[i].F);
		R2.insert(a[i].S);
	}
	for (int i = 1; i <= n; i ++) {
	//	cin >> a[i].F >> a[i].S;
		L2.erase(L2.find(a[i].F));
   	R2.erase(R2.find(a[i].S));
   
		ans = max(ans, a[i].S - a[i].F + 1 + get(*L2.rbegin(), *R2.begin()));
		L2.insert(a[i].F);
		R2.insert(a[i].S);
	
	}
   
   sort(a + 1, a + n + 1);

   for (int i = 1; i < n; i ++) {
   	L1.insert(a[i].F);
   	R1.insert(a[i].S);
   	L2.erase(L2.find(a[i].F));
   	R2.erase(R2.find(a[i].S));
   //	cout << 
   	ans = max(ans, get(*L1.rbegin(), *R1.begin()) + get(*L2.rbegin(), *R2.begin()));
   	
   }

	cout << ans;
	
  
	return Accepted;
}

// B...a

Measured memory_bytes: 10368
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  if (s.back() == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 int main(){
   int n;
   cin>>n;
   vector<int>h(n);
   for(int i=0;i<n;i++){
     cin>>h[i];
   }

   int count=0;
   int ans = 0 ;
   

   

   for(int i=1;i<n;i++){
     if(h[i]<=h[i-1]){
       count++;
     }else{
       count=0;
     }

     ans=max(ans,count);

     

   
 }
     cout<<ans<<endl;
 }

Measured memory_bytes: 640
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(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 A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    vector graph(k, vector<Pll>());
    rep(i,1,k){
        graph[i].emplace_back(i * 10 % k, 0);
        if(i % 10 != 9){
            graph[i].emplace_back((i + 1) % k, 1);
        }
    }

    deque<Pll> deq;
    vector<ll> dat(k, INF);
    deq.emplace_back(1, 0);
    dat[1] = 0;
    while(!deq.empty()){
        auto [x, c] = deq.front();deq.pop_front();
        for(auto &p : graph[x]){
            if(p.second){
                if(chmin(dat[p.first], c + 1))
                    deq.emplace_back(p.first, c + 1);
            }
            else{
                if(chmin(dat[p.first], c))
                    deq.emplace_front(p.first, c);
            }
        }
    }

    cout << dat[0] + 1 << endl;
}

Measured memory_bytes: 11728
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      1000007

const int mod = 1e9 + 7;

int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

   int n, m;
   cin >> n >> m;
   vector<string> arr(n);
   int dp[n][m];
   for (int i = 0; i < n; ++i)
   {
      cin >> arr[i];
   }

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         if (arr[i][j] == '#')
            dp[i][j] = 0;
         else if (i == 0 and j == 0)
            dp[i][j] = 1;
         else if (i == 0)
            dp[i][j] = dp[i][j - 1];
         else if (j == 0)
            dp[i][j] = dp[i - 1][j];
         else
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
         dp[i][j] %= mod;
      }
   }
   cout << dp[n - 1][m - 1] << endl;
   return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
#define eps 1e-10
#define F first
#define S second

int main() {
    int w, h, x, y; cin >> w >> h >> x >> y;
    cout << fixed << setprecision(11) << (double)w * h / 2 << " ";
    cout << (2 * x == w && 2 * y == h) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();

		if (b.equals("A")) {
			System.out.println("T");
		}else if(b.equals("T")) {
			System.out.println("A");
		}
		if (b.equals("C")) {
			System.out.println("G");
		}else if(b.equals("G")) {
			System.out.println("C");
		}
	}
}


Measured memory_bytes: 21716
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#define FOR(i, n) for (int i = 1; i <= n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  printf("%d %d\n", min(a,b), max(0, a+b-n));
  return 0;
}


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

int main(){
    int n;
    while(cin>>n,n){
        vector<int> c(n),C(26);
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            c[i]=s[0]-'A';
        }
        for(int i=0;i<n;i++){
            C[c[i]]++;
            int first=0,second=0;
            for(int j=0;j<26;j++){
                if(first<C[j]){
                    second=first;
                    first=C[j];
                }else if(second<C[j]){
                    second=C[j];
                }
            }
            if(second+n-i-1<first){
                for(int j=0;j<26;j++){
                    if(C[j]==first){
                        cout<<char('A'+j)<<' '<<i+1<<endl;
                        break;
                    }
                }
                break;
            }else if(i==n-1){
                cout<<"TIE"<<endl;
            }
        }
    }
}

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    string answer = "Yes";
    if (x + r > w || x - r < 0) answer = "No";
    if (y + r > h || y - r < 0) answer = "No";
    cout << answer << endl;
}


Measured memory_bytes: 3216
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $count = 0;
  for($i=0; $i<$n; $i++){
      if($a[$i]%2 == 0){
        while($a[$i] >=  1 && $a[$i]%2 == 0){
            $count++;
            $a[$i] /= 2;
        }
      }
  }

  echo $count;

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

int  main()
{
	int n; cin >> n;
	priority_queue<int> q;
	int sum = 0;
	rep(i, n)
	{
		int p; cin >> p;
		sum += p;
		q.push(p);
	}
	sum -= q.top();
	sum += q.top()/2;
	cout << sum << endl;
	return (0);
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

vector<vector<int>> graph;
int ans = 0;
vector<int> vis;
vector<int> dp;
void dfs(int node)
{
    for(int i:graph[node])
    {
        if(!vis[i])
        {
            vis[i] = 1;
            dfs(i);
        }
        dp[node] = max(dp[node], dp[i]+1);
        ans = max(ans, dp[node]);
    }
}

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    graph.resize(n+1);
    dp.assign(n+1, 0);
    vis.assign(n+1, 0);
    for(int i=0;i<m;i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i]) 
        {
            pr(i);
            vis[i] = 1;
            dfs(i);
        }
    }
    cout << ans << "\n";

    return 0;
}



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

int main(){
	int n,m,k;cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		int tmp=m*i;
		for(int j=0;j<=m;j++){
			if(tmp+(n-(i<<1))*j==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair < int,int> pii;
typedef pair < ll, ll > pll;

const int N = 105;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int BASE = 31337;
const int INF = 0x3f3f3f3f;

int dp[N * 10][N][N],n,x,y;

bool ok(int x){
    return x >= 0 && x < n;
}

int f(int x,int a,int b){
    if(x == N * 10) return 2;
    if(dp[x][a][b] != -1) return dp[x][a][b];
    if(x%2 == 0){
        int a1 = -1;
        int a2 = -1;
        if(ok(a - 1) && a - 1 != b) a1 = f(x + 1, a - 1, b);
        if(ok(a + 1) && a + 1 != b) a2 = f(x + 1, a + 1, b);
        if(abs(a1) == 1 && abs(a2) == 1) return dp[x][a][b] = 1;
        if(a1 == 0 || a2 == 0) return dp[x][a][b] = 0;
        return dp[x][a][b] = 2;
    }
    else{
        int b1 = -1;
        int b2 = -1;
        if(ok(b - 1) && b - 1 != a) b1 = f(x + 1, a , b - 1);
        if(ok(b + 1) && b + 1 != a) b2 = f(x + 1, a , b + 1);
        if(b1 < 1 && b2 < 1) return dp[x][a][b] = 0;
        if(b1 == 1 ||  b2 == 1) return dp[x][a][b] = 1;
        return dp[x][a][b] = 2;
    }
}

int main(){
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d",&n,&x,&y);
    int rez = f(0, x - 1, y - 1);
    if(rez == 2) printf("Draw\n");
    if(rez == 0) printf("Alice\n");
    if(rez == 1) printf("Borys\n");
    return 0;
}


Measured memory_bytes: 45568
#include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=128,a;i>0.03125;i/=2){
			str+=int(a=num/i)+'0';
			if(a>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num/0.03125>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<int> b,w;
  bool iswhite=true;
  int ncol=0;
  for(int i=0;i<n;++i){
    if(s[i]=='.'){
      if(iswhite)ncol++;
      else{
        b.push_back(ncol);
        ncol=1;
        iswhite=true;
      }
    }
    else{
      if(!iswhite)ncol++;
      else{
        w.push_back(ncol);
        ncol=1;
        iswhite=false;
      }
    }
  }
  if(ncol){
    if(iswhite){
      w.push_back(ncol);
      b.push_back(0);
    }
    else b.push_back(ncol);
  }
  reverse(w.begin(),w.end());
  for(int i=1;i<w.size();++i)w[i]+=w[i-1];
  for(int i=1;i<b.size();++i)b[i]+=b[i-1];
  b[b.size()-1]=0;
  w[w.size()-1]=0;
  sort(b.begin(),b.end());
  sort(w.begin(),w.end(),greater<>());
  int res=b[0]+w[0];
  for(int i=1;i<b.size();++i)res=min(res,b[i]+w[i]);
  cout<<res;
  return 0;
}


Measured memory_bytes: 1408
s = input()
n = len(s) -1
ans = 0

def DFS(plus=[], depth=0):
    global ans
    if depth >= n:
        command = s
        tmp = 1
        for i in plus:
            command = command[:tmp+i] + "+" + command[tmp+i:]
            tmp += 1
        # print(command)
        ans += eval(command)
        return
    DFS(plus[::], depth+1)
    DFS(plus[::] + [depth], depth+1)

DFS([], 0)
print(ans)


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::fs::File;
#[allow(unused_imports)]
use std::io::prelude::*;
#[allow(unused_imports)]
use std::io::Stdin;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

type BoxResult<T> = Result<T, Box<std::error::Error>>;

fn main() {
    let mut scanner = Scanner::new(stdin());
    let n = scanner.read::<usize>().unwrap();
    let mut tasks = vec![];
    for _ in 0..n {
        let line = scanner.read_vector::<usize>().unwrap();
        tasks.push((line[0], line[1]));
    }
    tasks.sort_by(|a, b| a.1.cmp(&b.1));
    let mut time = 0;
    for i in 0..n {
        time += tasks[i].0;
        if time > tasks[i].1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


#[allow(dead_code)]
struct Scanner<R> {
    reader: BufReader<R>,
    buffer: String,
}

impl<R> Scanner<R>
where
    R: Read,
{
    #[allow(dead_code)]
    fn new(inner: R) -> Scanner<R> {
        let reader = BufReader::new(inner);
        let buffer = String::new();
        Scanner { reader: reader, buffer: buffer }
    }

    #[allow(dead_code)]
    fn with_capacity(capacity: usize, inner: R) -> Scanner<R> {
        let reader = BufReader::with_capacity(capacity, inner);
        let buffer = String::new();
        Scanner { reader: reader, buffer: buffer }
    }

    #[allow(dead_code)]
    fn read<T>(&mut self) -> BoxResult<T>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed = self.buffer.trim().parse()?;
        self.buffer.clear();
        Ok(parsed)
    }

    #[allow(dead_code)]
    fn read_vector<T>(&mut self) -> BoxResult<Vec<T>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        self.reader.read_line(&mut self.buffer)?;
        let parsed_vec = self
            .buffer
            .trim()
            .split_whitespace()
            .map(|s| s.parse())
            .collect::<Result<Vec<_>, _>>()?;
        self.buffer.clear();
        Ok(parsed_vec)
    }

    #[allow(dead_code)]
    fn read_matrix<T>(&mut self, lines: usize) -> BoxResult<Vec<Vec<T>>>
    where
        T: FromStr,
        T::Err: std::fmt::Debug,
        T::Err: std::error::Error,
        T::Err: 'static,
    {
        let mut parsed_matrix = vec![];
        for _ in 0..lines {
            self.reader.read_line(&mut self.buffer)?;
            parsed_matrix.push(
                self.buffer
                    .trim()
                    .split_whitespace()
                    .map(|s| s.parse())
                    .collect::<Result<Vec<_>, _>>()?,
            );
            self.buffer.clear();
        }
        Ok(parsed_matrix)
    }
}



Measured memory_bytes: 9292
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if(x < 0) x *= -1;
    ll num = x / d; //何回左に移動できるか
    ll ans1 = x - num * d;
    if(num >= k){ //0近くをうろうろしない
        cout << x - (d * k) << endl;
        return 0;
    }
    ll ans2 = abs(x - num * d - d);
    if(k % 2 == num % 2) cout << ans1 << endl;
    else cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 3668
N = int(input())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 0
for i in range(N-2):
  count = 0
  if array[i][0] == array[i][1]:
    count += 1
  if array[i+1][0] == array[i+1][1]:
    count +=1
  if array[i+2][0] == array[i+2][1]:
    count +=1
  if count == 3:
    ans += 1
print( 'Yes' if ans >= 1 else 'No' )
      

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

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	rep(i,S.size()/2)
	{
		if (S[i] != S[S.size()-1-i])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int K;
    string S;

    cin >> K >> S;

    if (K < S.size()) {
        S = S.substr(0, K);
        S += "...";
    }

    cout << S << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

double c[3050];
double dp[3050][3050];

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, cap;

    while(sl(n) != EOF)
    {
        for (i = 1; i <= n; i++)
            sf(c[i]);

        dp[0][0] = 1;

        for (i = 1; i <= n; i++)
        {
            for (j = 0; j <= i; j++)
            {
                dp[i][j] = ((j-1>=0)?c[i]*dp[i-1][j-1]:0) + (1-c[i])*dp[i-1][j];
            }
        }

        double ans = 0;

        for (i = n/2 + 1; i <= n; i++)
        {
            ans += dp[n][i];
        }

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


Measured memory_bytes: 70272
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] a = new long[N];
		long ans = 0;
		for( int i=0; i<N; i++ ){
			a[i] = sc.nextLong();
			long count = 0;
			for( int j=0; j<30; j++ ){
				if( a[i]%2!=0 ){
					a[i] = count;
					break;
				}else{
					a[i] = a[i]/2;                  
					count++;
				}
			}
			ans += a[i];
		}
		System.out.println(ans);
	}
}


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

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    if (4 * a * b < (c - a - b) * (c - a - b) && c > a + b)
    {
        cout << "Yes" << endl;
    }
    else {cout << "No" << endl;}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int flag=1,sum=0;
        int N=sc.nextInt();
        int[] A=new int[N];
        for(int i=0;i<N;i++)A[i]=sc.nextInt(); 
        while(flag==1){
            flag=0;
            for(int j=N-1;j>0;j--){
                int data;
                if(A[j]<A[j-1]){
                    sum++;
                    data=A[j];
                    A[j]=A[j-1];
                    A[j-1]=data;
                    flag=1;
                }
            }
        }
        for(int i=0;i<N;i++){
            if(i!=N-1)System.out.printf(A[i]+" ");
            else System.out.println(A[i]);
        }
        System.out.println(sum);
    } 
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  sort(all(a));
  int dis=min(abs(a[n-1]/2-a[0]),abs((a[n-1]+1)/2-a[0]));
  int ch=a[0];
  rep(i,n-1)
  {
    int d=min(abs(a[n-1]/2-a[i]),abs((a[n-1]+1)/2-a[i]));
    if(d<dis)
    {
      dis=d;
      ch=a[i];
    }
  }
  cout<<a[n-1]<<' '<<ch<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++)
	{
		int q;
		cin>>q;
		a.push_back(q);
	}
	ll t=0;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
		{
			t+=a[i];
		}
		else
		{
			t-=a[i];
		}
	}
	int ans[n];
	for(int i=0;i<n;i++)
	{
		ans[i]=-1;
	}
	ans[n-1]=t;
	ans[0]=a[0]-(t/2);
	ans[0]*=2;
	t=ans[0];
	for(int i=0;i<n;i++)
	{
		if(ans[i]==(-1))
		{
			ans[i]=a[i]-t/2;
			ans[i]*=2;
			t=ans[i];
		}
	}
	int ans1[n];
	for(int i=0;i<n;i++)
	{
		ans1[(i+1)%n]=ans[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans1[i]<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 2552
N, Q = map(int,input().split())
S = input()

atgc_list= []

flag = 0
memo =0

for i in range (len(S)):
    if S[i]=='A':
        flag = 1
    elif flag == 1 and S[i] == 'C':
        memo+=1
        flag = 0
    elif S[i] in ['T','G','C']:
        flag = 0
    atgc_list.append(memo)
        

for j in range (Q):
    l, r = map(int,input().split())
    low = atgc_list[l-1]
    high = atgc_list[r-1]
    print(high - low)


Measured memory_bytes: 6132
H, W = map(int,input().split())
s = [list(input()) for i in range(H)]
ans = "Yes"
for i in range(H):
    for j in range(W):
        tmp = 1
        if s[i][j] == "#":
            tmp = 0
            if i > 0:
                if s[i-1][j] == "#":
                    tmp = 1
            if i < H - 1:
                if s[i+1][j] == "#":
                    tmp = 1
            if j > 0:
                if s[i][j-1] == "#":
                    tmp = 1
            if j < W - 1:
                if s[i][j+1] == "#":
                    tmp = 1
            if tmp == 0:
                ans ="No"
                break
    if tmp == 0:
        break
print(ans)

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

namespace abc164_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            int D = int.Parse(input[3]);

            while (true)
            {
                C -= B; //高橋君が青木君に攻撃
                if (C <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }

                A -= D; //青木君が高橋君に攻撃
                if (A <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }

            Console.Read();

        }
    }
}


Measured memory_bytes: 27372
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<string> s(n);
    vec t(n);
    rep(i,n) cin>>s[i]>>t[i];
    string x;
    cin>>x;
    int sum=0;
    int flag=true;
    int a=0;
    rep(i,n){
        sum+=t[i];
        if(flag)a+=t[i];
        if(s[i]==x) flag=false;

    }
    cout<<sum-a<<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int H,W;
	int i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MOD 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define P pair<ll, ll>
#define VII vector<P>
#define P_B push_back

double DP[2999][2999];
int n;
int n_l;
double p[2999];
double answer = 0;

double backtrack(int n_h, int pos) {

	if(pos >= n) {
		if(n_h >= n_l) return 1;
		else return 0;
	}

	if(DP[n_h][pos] != -1) return DP[n_h][pos];

	double answer =   p[pos] * backtrack(n_h+1, pos+1) + (1-p[pos]) * backtrack(n_h, pos+1);

	return DP[n_h][pos] =  answer;
}

int main() {
	
	// ll T; cin>>T; while(T--) 
	{
		

		cin>>n;
		for (int i = 0; i < n; i++) cin>>p[i];
		n_l = n/2+1;
		for (int i = 0; i < 2999; i++) 
			for (int j = 0; j < 2999; j++) 
				DP[i][j] = -1;
		cout<< fixed<< setprecision(9) <<  backtrack(0, 0);
	}	
	return 0;
}

Measured memory_bytes: 74248
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int OR (int a, int b) {
	int r = 0, p = 1;
	while (a || b) {
		r += (a % 2 || b % 2)*p;
		a /= 2; b /= 2; p *= 2;
	}
	return r;
}
int n, m, dp[1200][5000], a[1200], b, c[1200];
signed main() {
	cin >> n >> m;
	for (int i = 0; i <= m; i++)for (int j = 0; j < pow(2, n); j++)dp[i][j] = mod;
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b;
		for (int j = 1; j <= b; j++) {
			int k; cin >> k;
			c[i] += pow(2, k - 1);
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < pow(2, n); j++) dp[i][j] = dp[i - 1][j];
		for (int j = 0; j < pow(2, n); j++) {
			dp[i][OR(j, c[i])] = min(dp[i][OR(j, c[i])], dp[i - 1][j] + a[i]);
		}
	}
	int ans = dp[m][(int)pow(2, n) - 1];
	if (ans == mod)cout << -1 << endl;
	else cout << ans << endl;
}

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

int i;

int main()
{
    int n, m, sum = 0;

    cin >> n >> m;
    vector<int> a(n);

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

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

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

    if (a[m - 1] >= (double)sum / (4.0 * m))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
num_list = list(map(int, input().split()))

# 逆順ソート
num_list.sort(reverse=True)
# K番目まで足し合わせる
ans = 0
for i in range(K):
    ans += num_list[i]
print(ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>

using namespace std;

int main(){
	int hills[10];
    for(int i=0;i<10;i++){
        cin >> hills[i];
    }

	partial_sort( hills, hills + 3, hills+10, greater<int>() );
    
    for(int i=0;i<3;i++){
        cout << hills[i] <<endl;
    }
    
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

//Dinic法、蟻本そのまま
//最大流(=最小カット)を求めるアルゴリズム
//隣接リスト表現での実装
//計算量はO(|E||V|^2)だが、実際は非常に高速
//Ford-Fulkerson法の上位互換？？

//辺を表す構造体（行き先、容量、逆辺）
struct edge{ll to, cap, rev;};

vector<vector<edge>> G(203, vector<edge>(0));;//$１には最大頂点数+3を入れよう！
ll level[203];//sからの距離
ll iter[203];//どこまで調べ終わったか

//辺を追加する！
//fromからtoへ向かう容量capの辺
void add_edge(ll from, ll to, ll cap){
    G[from].emplace_back(edge{to,cap,(ll)G[to].size()});
    G[to].emplace_back(edge{from,0,(ll)G[from].size()-1});
}

//sからの距離をBFSで計算する
void bfs(ll s){
    memset(level,-1,sizeof(level));
    queue<ll> que;
    level[s]=0;
    que.emplace(s);
    while(!que.empty()){
        ll v=que.front();que.pop();
        for(ll i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                que.emplace(e.to);
            }
        }
    }
}

//増加パスをdfsで探す！
ll dfs(ll v, ll t, ll f){
    if(v==t)return f;
    for(ll &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからdへの最大流を求める
ll max_flow(ll s,ll t){
    ll flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while((f=dfs(s,t,INF))>0)flow+=f;
    }
}



int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1,0);
    vector<ll> B(N+1,0);
    vector<ll> C(N+1,0);
    vector<ll> D(N+1,0);
    for(ll i=1;i<=N;i++)cin>>A[i]>>B[i];
    for(ll i=1;i<=N;i++)cin>>C[i]>>D[i];

    //辺の追加
    for(ll i=1;i<=N;i++)
        for(ll j=1;j<=N;j++)
            if(A[i]<C[j]&&B[i]<D[j])add_edge(i,j+N,1);
    
    for(ll i=1;i<=N;i++)add_edge(0,i,1);
    for(ll i=N+1;i<=2*N;i++)add_edge(i,2*N+1,1);

    ll ans=0;

    for(ll i=0;i<10000;i++)ans+=max_flow(0,2*N+1);
    for(ll i=0;i<9999;i++)ans-=max_flow(0,2*N+1);
    print(ans)

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n, m, q;
    cin >> n >> m >> q;

    vector<char[2001]> s(n);
    vector<int[2001]> v(n + 1), e0(n + 1), e1(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    for (int i = 1; i <= n; i++) {
        int t = 0;
        for (int j = 1; j <= m; j++) {
            if (s[i - 1][j - 1] == '1') t++;
            v[i][j] = v[i - 1][j] + t;
        }
    }

    for (int i = 1; i <= n; i++) {
        int t = 0, u = 0;
        for (int j = 1; j <= m; j++) {
            int x = s[i - 1][j - 1] - '0';
            u = u >> 1 ^ x << 1;
            if (u == 3) t++;
            e0[i][j] = e0[i - 1][j] + t;
        }
    }

    for (int i = 2; i <= n; i++) {
        int t = 0;
        for (int j = 1; j <= m; j++) {
            if (s[i - 1][j - 1] == '1' && s[i - 2][j - 1] == '1') t++;
            e1[i][j] = e1[i - 1][j] + t;
        }
    }

    for (int i = 0; i < q; i++) {
        int x0, y0, x1, y1;
        cin >> y0 >> x0 >> y1 >> x1;
        int x2 = x0 - 1, y2 = y0 - 1;

        cout << (v[y1][x1] - v[y1][x2] - v[y2][x1] + v[y2][x2]) - (e0[y1][x1] - e0[y1][x0] - e0[y2][x1] + e0[y2][x0]) - (e1[y1][x1] - e1[y1][x2] - e1[y0][x1] + e1[y0][x2]) << endl;
    }

    return 0;
}

Measured memory_bytes: 52608
loop {
  m, f, r = gets.split(" ").map(&:to_i)
  if m == -1 && f == -1 && r == -1
    break
  end
  if m == -1 || f == -1
    puts "F"
  elsif m+f >= 80
    puts "A"
  elsif m+f >= 65 && m+f < 80
    puts "B"
  elsif m+f >= 50 && m+f < 65
    puts "C"
  elsif m+f >= 30 && m+f < 50
    if r >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;

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

}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	string s;
	ll ans=0;
	cin>>s;
	for(auto c :s){
		(c=='-')?ans--:ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

typedef long long ll;

struct hoge{
    ll s, n;
    hoge(ll s, ll n) : s(s), n(n) { }
};
bool operator < (const hoge &a, const hoge &b){
    return a.n != b.n ? a.n < b.n : a.s < b.s;
}

int main(void){
    while(true){
        ll n;
        cin >> n;
        if(n==0) break;
        vector<hoge> v;
        ll id, m1, s1, m2, s2, m3, s3, m4, s4;
        
        for(ll i=0; i<n; i++){
            cin >> id >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
            ll sum=60*m1+s1+60*m2+s2+60*m3+s3+60*m4+s4;
            v.push_back(hoge(id, sum));
        }
        sort(v.begin(), v.end());
        
        cout << v[0].s << "\n";
        cout << v[1].s << "\n";
        cout << v[n-2].s << "\n";
         
    }
     
     
    return 0;
}


Measured memory_bytes: 3204
#include <cstdio>
#include <cctype>
#include <map>
#include <algorithm>
#define MAXIOLG 25
#define FILENAME(x) \
freopen(x".in","r",stdin); \
freopen(x".out","w",stdout);
#define MD(x) (((x)>=MOD)?((x)-=MOD):(0))
using namespace std;

typedef long long ll;
typedef long double ld;
typedef ll io_t;
io_t shin[MAXIOLG];
io_t seto(void);
void seto_deci(void);
void ayano(io_t x,char spliter='\n');

typedef pair<int,int> pii;

ll ret_p,ret_q;
map<pii,int> mp;

ll gcd(ll a,ll b);
int check(const pii& a,const pii& b);

int main(void){
    int n=seto();
    int ints=0;
    for (int i=1;i<=n;i++){
        seto_deci();
        ints+=(ret_q==1);
        int deg2=0,deg5=0;
        ll d;
        d=ret_p/2;
        while (d*2==ret_p)
            deg2++,ret_p=d,d=ret_p/2;
        d=ret_p/5;
        while (d*5==ret_p)
            deg5++,ret_p=d,d=ret_p/5;
        d=ret_q/2;
        while (d*2==ret_q)
            deg2--,ret_q=d,d=ret_q/2;
        d=ret_q/5;
        while (d*5==ret_q)
            deg5--,ret_q=d,d=ret_q/5;
        pii tcp=make_pair(deg2,deg5);
        if (mp.count(tcp))
            mp[tcp]++;
        else
            mp[tcp]=1;
    }
    ll ans=0;
    for (auto upi:mp){
        pii ucp=upi.first;
        ll ucnt=upi.second;
        for (auto vpi:mp){
            if (upi<vpi)
                continue;
            if (upi==vpi){
                if (check(ucp,ucp))
                    ans+=ucnt*(ucnt-1)/2;
                continue;
            }
            pii vcp=vpi.first;
            ll vcnt=vpi.second;
            if (check(ucp,vcp))
                ans+=ucnt*vcnt;
        }
    }
    ayano(ans);
    return 0;
}

ll gcd(ll a,ll b){
    ll t;
    while (b)
        t=a,a=b,b=t%b;
    return a;
}
int check(const pii& a,const pii& b){
    return (a.first+b.first>=0) && (a.second+b.second>=0);
}

io_t seto(void){
    io_t x=0;
    int symbol=0;
    char ch=getchar();
    while (!isdigit(ch))
        (ch=='-')?(symbol=1):(0),
        ch=getchar();
    while (isdigit(ch))
        x=(x*10)+(ch-'0'),
        ch=getchar();
    return (symbol)?(-x):(x);
}
void seto_deci(void){
    io_t x=0;
    char ch=getchar();
    while (!isdigit(ch))
        ch=getchar();
    while (isdigit(ch))
        x=(x*10)+(ch-'0'),
        ch=getchar();
    io_t tq=1;
    if (ch=='.')
        ch=getchar();
    while (isdigit(ch))
        x=(x*10)+(ch-'0'),tq*=10,
        ch=getchar();
    ll tgcd=gcd(x,tq);
    ret_p=x/tgcd,ret_q=tq/tgcd;
}
void ayano(io_t x,char spliter){
    if (!x){
        putchar('0'),putchar(spliter);
        return;
    }
    if (x<0)
        putchar('-'),x=-x;
    int len=0;
    while (x){
        io_t d=x/10;
        shin[len++]=x-(d*10);
        x=d;
    }
    while (len--)
        putchar(shin[len]+'0');
    putchar(spliter);
}

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

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

fn main() {
    let n: usize = read();
    for _ in 0..n {
        let mut a: i64 = read();
        let mut b: i64 = read();
        if a > b {
            std::mem::swap(&mut a, &mut b);
        }
        let mut c = std::cmp::max(((a * b) as f64).sqrt() as i64 - 10, 0);
        while ((c + 1) * (c + 1) < a * b) {
            c += 1;
        }
        let ans;
        if a == b {
            ans = 2 * a - 2;
        } else if a + 1 == b {
            ans = 2 * a - 2;
        } else if c * (c + 1) >= a * b {
            ans = 2 * c - 2;
        } else {
            ans = 2 * c - 1;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder str = new StringBuilder(sc.nextLine());
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String com = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt()+1;
            if ("replace".equals(com)) {
                String str2 = sc.next();
 
                str = str.replace(a,b, str2);
            } else if ("reverse".equals(com)) {
 
                StringBuilder temp  = new StringBuilder(str.substring(a, b));
                temp.reverse();
                str.replace(a, b, temp.toString());
 
            } else if ("print".equals(com)) {
 
                System.out.println(str.substring(a, b));
            }
        }
        sc.close();
    }
    
}



Measured memory_bytes: 28860
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;
#define MPI  3.14159265358979323846

struct Dice{
	int d[6];
	void input();
	void rotation(int&, int&, int&, int&);
	void roll(char);
	string c1 = "WWWWSWW", c2 = "RRRR";
	bool equal(int*);
};

void Dice::rotation(int& a, int& b, int& c, int& d){
	int p = a; a = b; b = c; c = d; d = p;
}

void Dice::roll(char c){
	if (c == 'W')rotation(d[0], d[2], d[5], d[3]);
	if (c == 'S')rotation(d[0], d[4], d[5], d[1]);
	if (c == 'E')rotation(d[0], d[3], d[5], d[2]);
	if (c == 'N')rotation(d[0], d[1], d[5], d[4]);
	if (c == 'R')rotation(d[1], d[2], d[4], d[3]);
}

void Dice::input(){
	for (int i = 0; i < 6; i++){
		cin >> d[i];
	}
}

bool Dice::equal(int* a){
	bool flag1 = false;
	int count;
	for (int i = 0;; i++){
		count = 0;
		if (a[0] == d[0]){
			flag1 = true;
			for (int i2 = 0; i2 < c2.size(); i2++){
				flag1 = true;
				for (int j = 1; j < 6; j++){
					if (a[j] != d[j]){ flag1 = false; break; }
				}
				if (flag1)break;
				else {
					count++;
					roll(c2[i2]);
				}
			}
			if (count != c2.size()) break;
		}
		if (i == c1.size())break;
		roll(c1[i]);
	}
	return flag1;
}

int main(){

	Dice Dice[101];

	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++){
		Dice[i].input();
	}

	bool flag=true;
	for (int s = 0; s < n; s++){
		for (int t = s+1; t < n; t++){
			if (Dice[s].equal(Dice[t].d))flag = false;
			//cout << flag << endl;
		}
	}

	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >>t >> a >> b >>u;
  if(s==u) cout << a-1 << " "<< b << endl;
  else cout << a <<" " << b-1 << endl;
}

Measured memory_bytes: 256