akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int N; cin >> N;
    while(N--) {
        int from, to; cin >> from >> to;
        vector<int> route;
        if(from <= 5 && to < from) {
            for(int i = from; i >= to; i--) {
                route.push_back(i);
            }
        }
        else {
            if(from >= 6 && to >= 6 && to < from) {
                for(int i = from; i <= 9; i++) {
                    route.push_back(i);
                }
                for(int i = 5; i >= 0; i--) {
                    route.push_back(i);
                }
                for(int i = 1; i <= 5; i++) route.push_back(i);
                for(int i = 6; i <= to; i++) route.push_back(i);
            }
            else if(from >= 6 && to <= 5) {
                for(int i = from; i <= 9; i++) {
                    route.push_back(i);
                }
                for(int i = 5; i >= to; i--) {
                    route.push_back(i);
                }
            }
            else {
                for(int i = from; i <= to; i++) {
                    route.push_back(i);
                }
            }
        }
        for(int i = 0; i < (int)route.size() - 1; i++) cout << route[i] << ' ';
        cout << *route.rbegin() << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int a,b;
    cin >> a >> b;
    int ans=a-b*2;
    if (ans>0) cout << ans << endl;
    else cout << 0 << endl;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

struct union_find_tree {
    vector<ll> par;
    vector<ll> rnk;
    union_find_tree() = default;
    explicit union_find_tree(size_t n) : par(n+1), rnk(n+1, 0) {iota(ALL(par), 0);}
    
    ll find(ll x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        
        if (rnk[x] < rnk[y]) par[x] = y;
        else {
            par[y] = x;
            if (rnk[x] == rnk[y]) rnk[x]++;
        }
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
};

int main() {
    ll N, M; cin >> N >> M;
    
    vector<vector<ll>> lang(M);
    REP(i, N) {
        ll K; cin >> K;
        REP(j, K) {
            ll L; cin >> L;
            L--;
            lang[L].push_back(i);
        }
    }
    
    union_find_tree uf = union_find_tree(N);
    REP(i, M) {
        vector<ll> g = lang[i];
        REP(j, SZ(g)-1) {
            if (!uf.same(g[j], g[j+1])) uf.unite(g[j], g[j+1]);
        }
    }
    
    FOR(i, 1, N) {
        if (!uf.same(0, i)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> vote(N);  // N個の票数データ
  
  // 票数データを受け取る(入力)
   for (int i = 0; i < N; i++) {
    cin >> vote.at(i);
   }
  
  // 総投票数をsumとおく
  int sum = 0;
  
    for (int i = 0; i < N; i++) {
    sum += vote.at(i);
  }
  
  // 配列の中で1/4M以上のものの個数を数える(＝aとおく)
int a = 0;

 for (int i = 0; i < N; i++) {
   if (vote.at(i)*(4*M) >= sum) {
     a++;
   }
 }
  
   if (a < M) {
    cout << "No" << endl;
  }
  
  else {   
    cout << "Yes" << endl;
  }
  
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int point[100],sum=0;
		for(int i=0,s;i<n;++i){
			cin>>s;
			point[i]=s;
		}
		for(int i=0,s;i<n;++i){
			for(int j=i+1;j<n;++j){
				if(point[i]>point[j])swap(point[i],point[j]);
			}
		}
		for(int i=1;i<n-1;++i){
			sum+=point[i];
		}
		cout<<(sum/(n-2))<<"\n";
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 

bool judge(string s){
    for(auto& e : s){
        if(e != 'A' && e != 'C' && e != 'G' && e != 'T')
            return false;
    }
    return true;
}

signed main()
{
    string S;
    cin >> S;
    int counter = 0;
    REP(i, S.size()){
        FOR(j, 1,S.size()-i)
            {
                string T ;
                T = S.substr(i, j);
                if(judge(T) && counter < T.size())
                    counter = T.size();
            }
    }
    //判定，出力
    cout << counter << endl;

}



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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n %2 != 0){
        cout << "No" << endl;

    }
    else{
        REP(i,n/2){
            if(s[i] != s[i + n / 2]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        
    }

}

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int x = abs(a-b);
	if(x%2==0){
		cout << "Alice" << endl;
	}
	else{
		cout << "Borys" << endl;
	}
	return 0;
}

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

int main(void){
    int i,j,k,d[100005],n,m,s;
    cin>>n>>m>>s;
    for(i=0;i<m;i++)cin>>d[i];
    d[m]=s;
    int ans,left,right;
    ans = 21000000;
    sort(d,d+m+1);d[m+1]=d[0];
    for(i=0;i<=m;i++){
        left = d[i]-s;
        if(left<0)left +=n;
        right = s-d[i+1];
        if(right<0)right+=n;
        ans = min(ans,right*2 + left);
        ans= min(ans,left*2 + right);
    }
    cout<<ans*100<<endl;
    
}


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

using namespace std;

#define lint long long
#define P pair<int, int>

int main(){
    int N, M;
    cin >> N >> M;

    vector<int> A(N), B(M), C(M);
    map<int, int> lis;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    for(int i = 0; i < M; ++i){
        cin >> B[i] >> C[i];
        lis[C[i]] += B[i];
    }

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

    lint sum = 0;
    auto itr = lis.end();
    itr--;
    for(int i = 0; i < N; ++i){
        int tmp = A[i];
        // cout << itr->first << " ";
        if(itr == lis.begin()){

        }
        if(itr->first > A[i] && itr->second > 0){
            sum += itr->first;
            // cerr << itr->first << endl;
            itr->second--;
            if(itr != lis.begin() && itr->second == 0){
                itr--;
            }
        } else {
            sum += A[i];
            // cerr << A[i] << endl;
        }
    }

    cout << sum << endl;


}



Measured memory_bytes: 6144
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> a(n);
    int total = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        total += a[i];
    }
    double num = (double)total * (1.0 / (4.0 * m));

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (num <= (double)a[i]) ++ans;
    }

    if (ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

void insertion_sort(int* A, int n);
void print_line(int* A, int n);

int main(void){
    int N;
    int A[100];
    int i;
    scanf("%d", &N);

    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
    }
    insertion_sort(A, N);
    return 0;
}

void insertion_sort(int* A, int N){
    int i, j;
    int v;
    print_line(A, N);
    for(i = 1; i <= N-1; ++i){
        v = A[i];
        j =i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print_line(A, N);
    }
}

void print_line(int *A, int N){
    int i;
    for(i = 0; i < N-1; ++i){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}


Measured memory_bytes: 2104
// Problem : 
// 			C - Repsept
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define tos(x) string(1,x)
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int ll

signed main() {
	fast_io;
	int k; cin>>k;
	if(k%2==0 || k%5==0){
		cout<<"-1";
		return 0;
	}
	int cnt=1,rem=7;
	while(rem%k!=0){
		cnt++;
		rem=(rem*10+7)%k;
	}
	cout<<cnt;
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3544
from itertools import * 
n = int(input())
L = list(map(int,input().split()))
p = list(combinations(L, 3))

ans = 0
for i,j,k in p:
    if len(set([i,j,k])) == 3:
        if i + j > k  and j + k > i and k + i > j:
            ans += 1
print(ans)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int TLE = 1000000;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, t; cin >> n >> t;
    int mint = TLE;
    for(int i=0;i<n;i++){
        int a, b; 
        cin >> a >> b;
        if(b > t) continue;
        mint = min(a, mint);
    }
    if(mint == TLE) cout << "TLE" << endl;
    else cout << mint << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
        int A,B,C,X;
        int count = 0;
        cin >> A >> B >> C >> X;
        for(int a = 0; a <= A; a++){
                for(int b = 0; b <= B; b++){
                        for(int c = 0; c <= C;c++){
                        if(X == 500*a+100*b+50*c) ++count;
                        }
                }
        }
        cout << count << endl;
        return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N, zero = 0;
priority_queue<ll, vector<ll>, greater<ll> > neg;
priority_queue<ll, vector<ll>, less<ll> > pos;
deque<ll> deq;
vector<pll> ope;

signed main(){
    in(N);
    int A, neg = 0, pos = 0;
    REP(i, N){
        in(A);
        if(A < 0) neg++;
        else if(A > 0) pos++;
        deq.push_back(A);
    }
    sort(ALL(deq));
    ll head, tale;
    while(deq.size() > 1){
        head = deq.front();
        tale = deq.back();
        deq.pop_front(); deq.pop_back();
        if(head < 0) neg--; else if(head > 0) pos--;
        if(tale < 0) neg--; else if(tale > 0) pos--;
        if(neg >= pos){
            deq.push_back(tale - head);
            ope.push_back(pll(tale, head));
            if(tale - head > 0) pos++;
            else if(tale - head > 0) neg++;
        }else{
            deq.push_front(head - tale);
            ope.push_back(pll(head, tale));
            if(head - tale < 0) neg++;
            else if(head - tale > 0) pos++;
        }
    }
    PRINT(deq.front());
    for(auto p : ope){
        cout << p.first << " " << p.second << ENDL;
    }
    return 0;
}

Measured memory_bytes: 4468
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long y = scan.nextLong();
        long tmp = y / x;
        for (int i = 0; i < 100; i++) {
            if(1L << i > tmp) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(200010)

def main():
    def input():
        return sys.stdin.readline()[:-1]

    N, Q = map(int,input().split())
    G = [[] for k in range(N)]


    for k in range(N-1):
        a, b = map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    ans = [0 for k in range(N)]
    for k in range(Q):
        p, x = map(int,input().split())
        ans[p-1] += x

    V = [0 for k in range(N)]
    V[0] = 1
    def dfs(ima):
        for tsugi in G[ima]:
            if V[tsugi] == 0:
                V[tsugi] = 1
                ans[tsugi] += ans[ima]
                dfs(tsugi)
    dfs(0)

    print(*ans,sep=" ")

if __name__ == '__main__':
    main()


Measured memory_bytes: 269972
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, D;
  std::cin >> N >> D;
  std::vector<std::vector<int>> X(N);
  for (int i = 0; i < N; ++i) {
    X[i].resize(D);
    for (int j = 0; j < D; ++j)
      std::cin >> X[i][j];
  }

  // Main
  int res = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int s = 0;
      for (int k = 0; k < D; ++k)
        s += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      // std::cout << s << std::endl;
      for (int k = 0; k < 1000; ++k) {
        if (s == k * k)
          res += 1;
        if (s < k * k)
          break;
      }
    }
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        double N, M;
        N = Double.parseDouble (arr[0]);
        M = Double.parseDouble (arr[1]);
        System.out.printf ("%.0f%n", Math.ceil (N * (N - 1) / 2) +
                                         Math.ceil (M * (M - 1) / 2));
    }
}

Measured memory_bytes: 23124
N = int(input())
*A, = map(int, input().split())
a = 0
for i in range(N-1):
    if A[i] < 0:
        A[i] = -A[i]
        A[i+1] = -A[i+1]
    a += A[i]
if A[N-1] >= 0:
    print(a+A[N-1])
else:
    a = [abs(v) for v in A]
    a.sort()
    print(sum(a)-a[0]*2)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>

using namespace std;

int main(void) {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int m = max(a,max(b,c));
    int o = a + b + c - m;
    int ret = m * pow(2, k) + o;
    cout << ret << endl;
}


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

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if( a+b==15 ){
		cout << "+" << endl;
	} else if( a*b ==15){
		cout << "*" << endl;
	} else{
		cout << "x" << endl;
	}
}


Measured memory_bytes: 764
N = int(input())
S = input()
Q = int(input())
*K, = map(int,input().split())

nD = S.count("D")
nC = S.count("C")
if nD < nC:
    S = S[::-1].replace("D","c").replace("C","d").upper()

D = [0]*(N+1)
cntM = [0]*(N+1)
sumM = [0]*(N+1)
ans = [0]*Q
for i,s in enumerate(S):
    D[i+1] = D[i]
    cntM[i+1] = cntM[i]
    sumM[i+1] = sumM[i]
    if s=="D":
        D[i+1] += 1
    elif s=="M":
        cntM[i+1] += 1
        sumM[i+1] += D[i]
    elif s=="C":
        for j,k in enumerate(K):
            ik = max(0,i-k+1)
            d = D[ik]
            ans[j] += (sumM[i]-sumM[ik]) - d*(cntM[i]-cntM[ik])
for out in ans:
    print(out)

Measured memory_bytes: 111472
#include <stdio.h>

int main(void)
{
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if(a==1 && b==0 && c==0){
		printf("Close\n");
	}

	if(a==0 && b==1 && c==0){
		printf("Close\n");
	}

	if(a==0 && b==0 && c==0){
		printf("Close\n");
	}

	if(a==1 && b==1 && c==0){
		printf("Open\n");
	}

	if(a==0 && b==0 && c==1){
		printf("Open\n");
	}


	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
using namespace std;
int main(){
  string nums,text,ch;
  ch = "abcdefghijklmnopqrstuvwxyz.?! ";
  while(cin>>nums){
    text = "";
    if(nums.size()%2){
      cout<<"NA"<<endl;
    }
    else{
      for(int i=0;i<nums.size()/2;i++){
	if('0'<nums[i*2]&&nums[i*2]<'7'&&'0'<nums[i*2+1]&&nums[i*2+1]<'6')
	  text=text+ch[5*(nums[i*2]-49)+(nums[i*2+1]-49)];
	else{
	  text="NA";
	  break;
	}
      }
      cout<<text<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint ans=0;
    lint sum=0;
    rep(i,N){
        if(A[i]!=0) sum+=A[i];
        else ans+=sum/2,sum=0;
    }
    ans+=sum/2;
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int s =sc.nextInt();
		int n =sc.nextInt();
		int re = s*s-n;
		System.out.print(re);
	}

}


Measured memory_bytes: 21972
import math
import itertools
X = int(input())
# a = math.floor((math.pow(X, 1/5)))
lst = [i**5 for i in range(0, 10000)]
comb = itertools.combinations(lst, 2)
for i in comb:
    if i[0]-i[1] == X:
        a = math.pow(i[0], 1/5)
        b = math.pow(i[1], 1/5)
        print("{} {}".format(int(a), int(b)))
        break
    elif i[0]+i[1] == X:
        a = math.pow(i[0], 1/5)
        b = -math.pow(i[1], 1/5)
        print("{} {}".format(int(a), int(b)))
        break
    elif -i[0]-i[1] == X:
        a = -math.pow(i[0], 1/5)
        b = math.pow(i[1], 1/5)
        print("{} {}".format(int(a), int(b)))
        break
    elif -i[0]+i[1] == X:
        a = -math.pow(i[0], 1/5)
        b = -math.pow(i[1], 1/5)
        print("{} {}".format(int(a), int(b)))
        break

Measured memory_bytes: 9928
#                         author:  kagemeka 
#                         created: 2019-11-09 18:08:09(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    x1, y1, x2, y2 = (int(i) for i in sys.stdin.readline().split())
    
    x3 = x2 + (y1 - y2)
    x4 = x1 + (y1 - y2)
    y3 = y2 - (x1 - x2)
    y4 = y1 - (x1 - x2)
    
    print(x3, y3, x4, y4)


if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main(){
    string line;
    getline(cin, line);

    int i;
    int counter = 0;
    for(i=0; i<line.size(); i++){
        if(line[i] == 'o')
            counter++;
    }
    cout << 700+counter*100 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string s;
    string s1 = "C";
    string s2 = "F";
    long ans;
    string::size_type pos1, pos2;

    cin >> s;
    pos1 = s.find_first_of(s1);
    pos2 = s.find_last_of(s2);
    if ((pos1 != string::npos) &&(pos2 != string::npos) && (pos2 > pos1)) {
        ans = 1;
    } else {
        ans = 0;
    }
    if (ans != 0) { cout << "Yes" << "\n"; }
    else { cout << "No" << "\n"; }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
// gcdも呼ぶ！！！
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

int main(void){


    ll a,b;
    cin>>a>>b;
    fin(lcm(a,b));
}


Measured memory_bytes: 256
using System;

public class education
{

	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());

		if(n == 1)
		{
			Console.WriteLine("Hello World");
		}
		else if(n == 2)
		{
			int a = int.Parse(Console.ReadLine());
			int b = int.Parse(Console.ReadLine());

			Console.WriteLine(a + b);
		}
		else
		{
			return;
		}
	}
}

Measured memory_bytes: 11092
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int to_int(string s) {
	map<char, int> gogo;
	gogo['m'] = 1000;
	gogo['c'] = 100;
	gogo['x'] = 10;
	gogo['i'] = 1;
	int ans = 0;
	int now = 1;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] >= '2' && s[i] <= '9') {
			now = s[i] - '0';
		}
		else {
			ans += now * gogo[s[i]];
			now = 1;
		}
	}
	return ans;
}
string to_mcxi(int a) {
	string ans;
	map<int,char> gogo;
	gogo[1000] = 'm';
	gogo[100] = 'c';
	gogo[10] = 'x';
	gogo[1] = 'i';
	for (int i = 1000; i >= 1; i /= 10) {
		if (i <= a) {
			if (i*2 <= a) {
				ans.push_back((char)('0' + a / i));
			}
			ans.push_back(gogo[i]);
			a %= i;
		}
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		string a, b;
		cin >> a >> b;
		cout << to_mcxi(to_int(a) + to_int(b)) << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
  ll n;
  cin >> n;
  vector<ll> as = {};
  for (auto i = 0; i < n; i++)
  {
    ll a;
    cin >> a;
    as.push_back(a);
  }

  ll ans = 0;
  ll two_factor = 1;
  for (auto i = 0; i < 60; i++)
  {
    ll odd_num = 0, even_num = 0;
    for (auto a : as)
    {
      if ((a >> i) & 1)
        odd_num++;
      else
        even_num++;
    }
    ans += (((odd_num * even_num) % MOD) * two_factor) % MOD;
    ans %= MOD;
    two_factor = (two_factor * 2) % MOD;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int Amax = 0;
    int Amin = 1000000001;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        if(A > Amax) Amax = A;
        if(A < Amin) Amin = A;
    }
    cout << Amax - Amin << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<p> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(make_pair(temp, i));
    }
    sort(ALL(a));
    int b[n];
    for (int i = 0; i < n; i++)
    {
        b[i] = a[n - 1].first;
    }
    b[a[n - 1].second] = a[n - 2].first;
    for (int i = 0; i < n; i++)
    {
        cout << b[i] << "\n";
    }
}

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

using namespace std;

int main() {
    long r = 0, D = 0, x = 0, ans = 0;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; ++i) {
        ans = r * x - D;
        cout << ans << endl;
        x = ans;
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll n;
    cin >> n;
    vector<ll> v;
    for (ll i = 1; i * i <= n; ++i) {
        if(n % i == 0){
            v.push_back(i);
        }
    }

    ll res = 1e17;
    for (auto i = v.begin(); i != v.end(); ++i) {
        res = min(res, *i + n / *i - 2);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =202;
int n , m , r;
int mem[N+N][10];
int dis[N][N];
int town[N];
int dp ( int mask , int last ){
    //cerr << mask <<endl;
if ( mask == 0 ) return 0 ;
int &ret = mem[mask][last] ;
if ( ret != -1 ) return ret ;
ret = inf ;
   for ( int j = 0 ; j < r ; j++ ){
     if ( mask&(1<<j)){
         ret = min( ret , dp(mask-(1<<j),j) + ( last == 9 ? 0 : dis[town[last+1]][town[j+1]]));
     }
 }
return ret ;
}
int main ( ){

 scanf("%d%d%d",&n,&m,&r);
 for ( int i = 1 ; i <= r ;i++ ) scanf("%d",town+i);
 for ( int i = 1;  i <= n ;i++ )
    for ( int j = 1;  j<= n ;j++ )
    dis[i][j] = 10000002 ;
 int x , y, c ;
 for ( int i = 1 ; i<=m ; i++ ){
    scanf("%d%d%d",&x,&y,&c);
    dis[x][y] = c ;
    dis[y][x] = c ;
 }

 for ( int k = 1; k<= n ; k++ ){
    for ( int i = 1 ; i<=n ; i++ ){
        for ( int j = 1;  j<= n ; j++ )
         dis[i][j] = min ( dis[i][j] , dis[i][k]+dis[k][j]);
    }
 }

 memset( mem , -1 ,sizeof mem );
 printf("%d",dp((1<<r)-1 , 9 ));
return 0 ;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
using namespace std;
typedef long long ll;

int const SIZ = 100000001;
bitset<SIZ> chk;

void sieve() {
    chk.set();
    chk.set(0, 0);
    chk.set(1, 0);
    for (int i=4; i<SIZ; i+=2) {
        chk.set(i, 0);
    }
    for (int i=3; i*i<SIZ; i+=2) {
        if ( ! chk[i]) continue;
        for (int j=2; i*j<SIZ; ++j) {
            chk.set(i*j, 0);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    sieve();

    int n;
    cin >> n;
    int m, ans = 0;
    for (int i=0; i<n; ++i) {
        cin >> m;
        if (chk[m]) {
            ++ ans;
            chk[m] = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        return s > p.s;
    }
    ll x[3], s;
};

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

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

    vector<P> a(n);
    for (int i = 0; i < n; i++) {
        auto& t = a[i].x;
        cin >> t[0] >> t[1] >> t[2];
    }

    ll r = 0;
    for (int k = 0; k < 8; k++) {
        for (int i = 0; i < n; i++) {
            ll t = 0;
            for (int j = 0; j < 3; j++) {
                ll c = 1;
                if (k >> j & 1) c *= -1;
                t += a[i].x[j] * c;
            }
            a[i].s = t;
        }
        sort(a.begin(), a.end());
        ll t = 0;
        for (int i = 0; i < m; i++) {
            t += a[i].s;
        }
        r = max(r, t);
    }

    cout << r << endl;

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<char> P(N);
	for (char& i : P) cin >> i;
	char ans = P.front();
	for (int i = 1; i < N; ++i) {
		if ('F' == P[i] && 'T' == ans) ans = 'F';
		else ans = 'T';
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    int i, j, n;
    cin >> n;
    vector<pair<int, int> > res;
    if (n % 2 == 0) {
        xrep(i, 1, n) {
            xrep(j, i + 1, n + 1) { 
                if (i + j != n + 1) {
                    res.pb({i, j});
                }
            }
        }
    } else {
        xrep(i, 1, n) {
            xrep(j, i + 1, n + 1) {
                if (i + j != n) {
                    res.pb({i, j});
                }
            }
        }
    }
    cout << res.size() << endl;
    rep(i, res.size()) {
        cout << res[i].first << ' ' << res[i].second << endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,A;
    cin >> N>>  A;
    if(N%500 <= A){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << enld;
    }
    return 0;
}

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

remain = 0
kill = 0
for i in range(N):
    kill += min(A[i], B[i] + remain)
    remain = max(0,min(B[i], B[i] + remain - A[i]))
if remain > 0:
    kill += min(remain, A[N])
print(kill)


Measured memory_bytes: 19156
#include<cstdio>
using ull = unsigned long long;

int main(){
	int N;
	scanf("%d", &N);
	ull A[N], sum = 0;
	for (int i = 0; i < N; ++i){
		scanf("%llu", A + i);
		sum += A[i];
	}
	sum >>= 1;
	for (int i = 0; i < N >> 1; ++i){
		sum -= A[(i << 1) + 1];
	}
	printf("%llu", sum << 1);
	for (int i = 1; i < N; ++i){
		printf(" %llu", (sum = A[i - 1] - sum) << 1);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	string str;	cin >> str;	int count=0;	string curr="";	string prev="";
	for(int i=0; i<str.size(); i++){
		curr.clear();
		curr+=str[i];
		if(prev != curr){
			count++;	prev =curr;
		}
		else{
			i++;
			if(i >= str.size())	break;
			prev = curr+str[i];
			count++;
		}
		//cout<<prev<<endl;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 5;
vector<int> G[MAXN];

int dp[MAXN][2];

void dfs(int node, int f) {
    int cnt = 0;
    for(auto temp : G[node]) {
        if(temp == f)
            continue;
        dfs(temp, node);
        dp[node][0] += max(dp[temp][0], dp[temp][1]);
        if(dp[temp][0] == dp[temp][1]) {
            cnt = 1;
        }
    }

    dp[node][1] = dp[node][0] + cnt;
}

int main() {
    //ifstream cin("D.in");
    int n; cin >> n;
    
    for(int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    

    dfs(0, -1);

    int match = max(dp[0][0], dp[0][1]);
    
    if(2 * match < n) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
}

Measured memory_bytes: 6656
# 累積和の手法をとる
# 簡単にいうと要素が ある区間の和 であるようなリストを先に作成しておき
# 必要な時に取り出すという手法である
# 同じ計算過程を何回も繰り返す（上の解法）ことなく結果がでる
N = int(input())
S = input()
w = [0 for _ in range(N)]       # Wを向いている人の番号に１、逆の方角の人に０を割り当てる
sw = [0 for _ in range(N+1)]    # リストwの累積和のリスト、つまり sw[i] は 0~i-1 でWを向いている人の累積和
e = [0 for _ in range(N)]       # Eを向いている人の番号に１、逆の方角の人に０を割り当てる
se = [0 for _ in range(N+1)]    # リストeの累積和のリスト
l = []

for i in range(N):
    if S[i] == "W":
        w[i] = 1
    else:
        e[i] = 1

# 累積和を格納したリストを求める
for i in range(N):
    sw[i+1] = sw[i] + w[i]
    se[i+1] = se[i] + e[i]

# 本計算
for i in range(N):      # i 番目がリーダーだとする
    counter = sw[i] + (se[N] - se[i+1])
    l.append(counter)

print(min(l))


Measured memory_bytes: 44068
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

a = A[0]
b = 0
if a % 2 == 0:
    for i in A[1:]:
        if i % 2 == 1:
            b = i
            
if b < a:
    b = A[1]

b -= int(b/a) * a

if b == 0:
    print(a)
    exit()

res = 0
while b > 0 and a > 0:
    na = max(a,b)
    nb = min(a,b)
    a = na - nb
    b = nb
    res = b
    #print(a,b)

print(res)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m ;
  cin >> n >> m ;
  int a[m] ;
  int sum = 0 ;
  for(int i=0;i<m;i++){
    cin >> a[i] ;
    sum += a[i] ;
  }
  if(sum > n){
    cout << "-1" ;
    return 0 ;
  }
  cout << n - sum ;
  return 0 ;
}

Measured memory_bytes: 3592
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
char ch[200001]; int a,b,c,d,n;
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	int f=(d<c); scanf("%s",ch+1);
	for(int i=b-1;i<=d-1;i++)
	{
		if(i+2>n)	continue;
		if(ch[i]=='.'&&ch[i+1]=='.'&&ch[i+2]=='.')
			f=0;
	}
	for(int i=a;i<=max(c,d)-1;i++)
		if(ch[i]=='#'&&ch[i+1]=='#'){f=1;break;}
	if(f==1)	printf("No\n");
	else	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 998244353;

template <class T, T MOD>
class ModuloCombination {
 private:
  std::vector<T> factrial, inverse_factrial;
  T Pow(T x, T y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return Pow(x * x % MOD, y / 2);
    return x * Pow(x, y - 1) % MOD;
  }

 public:
  ModuloCombination(T n) : factrial(n + 1), inverse_factrial(n + 1) {
    inverse_factrial[0] = factrial[0] = 1;
    for (T i = 1; i <= n; i++) {
      factrial[i] = factrial[i - 1] * i % MOD;
      inverse_factrial[i] = Pow(factrial[i], MOD - 2);
    }
  }
  T operator()(T n, T k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse_factrial[k] % MOD * inverse_factrial[n - k] % MOD;
  }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  vector<ll> p(n + 1);
  p[0] = 1;
  p[1] = m;
  for (ll i = 2; i <= n; i++) p[i] = p[i - 1] * (m - 1) % MOD;

  ModuloCombination<ll, MOD> c(n - 1);

  ll r = 0;
  for (ll i = 0; i <= k; i++) {
    r += c(n - 1, i) * p[n - i] % MOD;
    r %= MOD;
  }
  cout << r << endl;
}


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

const int N = 1e3 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

typedef pair<int,int> pun;
typedef long long ll;

int naj[N][N];
int wsk[N];

int counter[N];
int ex[N];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			scanf("%d", naj[i] + j);
		}
	}
	for (int i = 0; i < n; i ++) {
		counter[naj[i][0]] ++;
		wsk[i] = 0;
	}
	int res = n;
	for (int t = 0; t < m; t ++) {
		int MAX = 0;
		int where = 0;
		for (int i = 0; i <= m; i ++) {
			if (counter[i] > MAX) {
				MAX = counter[i];
// 				printf("MAX %d\n", MAX);
				where = i;
			}
		}
		res = min(MAX, res);
// 		printf("%d\n", res);
		ex[where] = true;
// 		printf("ex %d\n", where);
		for (int i = 0; i < n; i ++) {
			while (ex[naj[i][wsk[i]]]) {
// 				printf("rusz %d bo %d\n", i, naj[i][wsk[i]]);
				counter[naj[i][wsk[i]]] --;
				wsk[i] ++;
				counter[naj[i][wsk[i]]] ++;
// 				printf("new c %d -- %d\n", naj[i][wsk[i]], counter[naj[i][wsk[i]]]);
			}
		}
	}
	printf("%d\n", res);
}


Measured memory_bytes: 1408
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int m = sc.nextInt();
        if (n % 2 == 1) {
            int count = 0;
            for (int i = 1; i <= n /2 + 1 && count < m; i++) {
                System.out.println(i + " " + (n + 1 - i));
                count++;
            }
        } else {
            if ((n / 2) % 2 == 0) {
                int count = 0;
                for (int i = 1; i <= n /4 - 1 && count < m; i++) {
                    System.out.println(i + " " + (n/2 - i));
                    count++;
                }
                if (m > n / 4 - 1) {
                    for (int i = 1; i <= n /4 && count < m; i++) {
                        System.out.println((i + n / 2) + " " + (n + 1 - i));
                        count++;
                    }
                }
            } else {
                int count = 0;
                for (int i = 1; i <= n /4 && count < m; i++) {
                    System.out.println(i + " " + (n/2 - i));
                    count++;
                }
                if (m > n / 4) {
                    for (int i = 1; i <= n /4 && count < m; i++) {
                        System.out.println((i + n / 2) + " " + (n + 1 - i));
                        count++;
                    }
                }
            }
        }


    }


}


Measured memory_bytes: 53096