akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int K, N; 
    cin>>K>>N;
    vector<long> A(N, 0), A_D(N,0), D(N*2, 0);
    REP(i, 0, N){
        cin >> A[i];
    }
    REP(i, 0, N){
        if(i == N - 1) A_D[i] = A[0] - A[i] + K;
        else A_D[i] = A[i+1] - A[i];
    }
    D[0] = A[0];
    REP(i, 0, N-1){
        D[i+1] = D[i] + A_D[i];
    }
    REP(i, N, 2*N-1){
        D[i] = D[i-N] + K;
    }
    long ans = __INT_MAX__;
    /*
    REP(i, 0, N*2-1){
        cout << D[i] << " ";
    }
    */

    REP(i, N-1, N*2-1){
        ans = min(ans, D[i]-D[i-N+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    ll func(ll n) {
//        ll m = n - (n % 4) + 1;
//        while (m > n) m -= 4;
        if (n == 0) return 0ll;
        ll m = n;
        while (!(m % 4 == 0 || m == 0)) m--;

        ll ret = 0;
        for (ll i = m; i <= n; ++i) {
            ret ^= i;
        }
        return ret;
    }

    void solve() {
        input();
//        int n;
//
//        cin >> n;
//        for (int k = 0; k <= n; ++k) {
//            int val = 0;
//            for (int i = 0; i <= k; ++i) {
//                val ^= i;
//            }
//            if (val == 0)
//                cout << k << " " << val << endl;
//        }

        ll A, B;
        cin >> A >> B;
//        cout << func(A - 1) << endl;
//        cout << func(B) << endl;
        ll ans = func(A - 1) ^func(B);
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 500005
#define INF 16843009
#define LL long long
#define LD long double
#define len(l,r) (r-l+1)
#define P int(1e9+7)
using namespace std;
 
string s;
int work(){
	
	int N = s.length();
	int ans = N + 1;
	for(int i=0;i<N-1;i++){
		if(s[i]!=s[i+1]) ans = min(ans, max(i+1, N-i-1));
	}
	if(ans == N + 1){
//		if(s[0]=='0') return -1;
//		else 
		return N;
	}
	else{
		return ans;
	}	
}

int main(){
	//freopen("5.in", "r", stdin);
	//freopen("5.ans", "w", stdout);
	
	int T = 1;
	//cin>>T;
	while(T--){
		cin>>s;
		cout<<work()<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
 
using namespace std;

int n, k;
vector<int> a(n);
bool dfs(int i, int sum){
    if(i==n) return sum == k;
    
    if(dfs(i+1, sum)) return true;
    
    if(dfs(i+1, sum+a[i])) return true;
    
    return false;
}

int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    
    long long ans=0;
    
    if(k>a){
        ans+=a;
        k-=a;
        if(k>b){
            k-=b;
            ans-=k;
            
        }
        
    }
    else ans+=k;
    
    cout << ans << endl;
    return 0;
 }


Measured memory_bytes: 3620
use std::io;


/// https://beta.atcoder.jp/contests/arc085/tasks/arc085_a
/// t = 1900 * m + 100 * (n - m)
fn main() {
    let (n, m) = {
        let i = read::<u32>();
        (i[0], i[1])
    };
    println!("{}", (1900 * m + 100 * (n - m)) * 2u32.pow(m));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
  int N, K;
  int r = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (r < K) {
      r *=2;
    }
    else {
      r += K;
    }
  }
  cout << r << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
vector<int> a[100001];

int *dp=new int[1000001];
int lpg(vector<int> a[],int i)
{   if(dp[i]==-1)
    {

        for( vector<int>::iterator it=a[i].begin();it!=a[i].end();it++)
        {
            dp[i]=max(dp[i],1+lpg(a,*it));
        }


    }

    return dp[i];

}
int main()
{
    int n,m,c,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>b>>c;
        a[b].push_back(c);
    }
    dp[0]=0;
    for(int i=1;i<=n;i++)
        {
         if(a[i].size()==0)
              dp[i]=0;
         else
            dp[i]=-1;
        }
        int e;
for (int i=1;i<=n;i++)
    if(dp[i]==-1)
       e=lpg(a,i);
int ans=*max_element(dp+1,dp+n+1);
cout<<ans<<endl;



}


Measured memory_bytes: 8192
// abc048_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    int idx = S.size();
    while (idx > 0){
        if (idx >= 5 && S.substr(idx-5, 5) == "dream"){
            idx -= 5;
        } else if (idx >= 5 && S.substr(idx-5, 5) == "erase"){
            idx -= 5;
        } else if (idx >= 7 && S.substr(idx-7, 7) == "dreamer"){
            idx -= 7;
        } else if (idx >= 6 && S.substr(idx-6, 6) == "eraser"){
            idx -= 6;
        } else {
            print("NO");
            return 0;
        }
    }
    print("YES");

    return 0;
}


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

using namespace std;
const int MAXN = 2e5+2;

int arr[MAXN];
int main()
{
    int N;
    cin >> N;

    for(int i = 2; i <= N; i++){
        int pos; cin >> pos;
        arr[pos]++;
    }
    for (int i = 1; i <= N; i++){
        cout << arr[i] << "\n";
    }
    return 0;
}


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

int main() {        
    long long int n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n == 1 && m == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (n == 1) {
        cout << max((long long int)0, m - 2) << endl;
        return 0;
    }
    cout << (n - 2) * (m - 2) << endl;
}


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

int main(void){
    string a, b;
    cin >> a >> b;

    int l = a.size();
    int n = b.size();

    if(l < n){
        cout << "LESS" << endl;
    }
    else if(l > n){
        cout << "GREATER" << endl;
    }
    else if(a == b){
        cout << "EQUAL" << endl;
    }
    else{
        if(a < b){
            cout << "LESS" << endl;
        }
        else{
            cout << "GREATER" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    X = int(input())
    
    X = X//100

    if X < 6:
        res = 8
    elif X < 8:
        res = 7
    elif X < 10:
        res = 6
    elif X < 12:
        res = 5
    elif X < 14:
        res = 4
    elif X < 16:
        res = 3
    elif X < 18:
        res = 2
    else:
        res = 1
    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9192
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  string s, t;
  cin >> n >> s >> t;

  ll tot = s.size() + t.size();
  if (n >= tot) {
    cout << n << endl;
    return 0;
  }

  ll m = min(s.size(), t.size());

  ll cnt = 0;
  repLRE(i, 1, m) {
    bool ok = true;
    rep(j, i) {
      if (s[n - i + j] != t[j]) {
        ok = false;
        break;
      }
    }
    if (ok) cnt = i;
  } // i

  ll ans = max(tot - cnt, n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> pt;
pt dot(pt a,pt b){return (conj(a)*b).real();}
pt cros(pt a,pt b){return (conj(a)*b).imag();}
pt proj(pt a,pt to){
  return dot(a,to)/norm(to)*to;
}

pt refle(pt a,pt mirror){
  return pt(2)*proj(a,mirror)-a;
}

pt pt3(pt a,pt b,pt c){
  pt p=b-a,q=c-a;
  return p;
}

int main(){
  int i,j,k,n;
  pt o,p,q;
  cin>>o.real()>>o.imag()>>p.real()>>p.imag();
  cin>>n;
  rep(i,n){
    cin>>q.real()>>q.imag();
    q=refle(q-o,p-o)+o;
    printf("%.9f %.9f\n",q.real(),q.imag());
  }
  return 0;
}

Measured memory_bytes: 1272
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C
 */
#include <iostream>
#include <sstream>
#include <map>
#include <vector>
#include <utility>

using namespace std;

typedef vector<pair<char, int> > VPCI;
typedef map<int, vector<char> > MIVC;

bool
cardcomp(const string a, const string b)
{
    return a.substr(2) <= b.substr(2);
}

int
partition(VPCI &a, const int p, const int r)
{
    int x = a[r].second;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (a[j].second <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[r]);
    return i + 1;
}

void
quicksort(VPCI &a, const int p, const int r)
{
    if (p >= r) { return; }
    int q = partition(a, p, r);
    quicksort(a, p, q - 1);
    quicksort(a, q + 1, r);
}

void
checkstable(const VPCI &original, const VPCI &sorted)
{
    auto sit = sorted.begin();
    for (auto oit = original.begin(); oit != original.end(); oit++, sit++) {
        if (*oit != *sit) {
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
}

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

    int n;
    cin >> n; cin.ignore();

    VPCI A(n);
    MIVC O;
    for (int i = 0; i < n; i++) {
        char M;
        int L;
        cin >> M >> L; cin.ignore();
        A[i] = make_pair(M, L);
        if (O.find(L) == O.end()) {
            vector<char> t(1);
            t[0] = M;
            O.insert(decltype(O)::value_type(L, t));
        } else {
            O.at(L).push_back(M);
        }
    }
    quicksort(A, 0, n - 1);

    VPCI S(n);
    int c = 0;
    for (auto& itk : O) {
        for (auto& itv : itk.second) {
            S[c++] = make_pair(itv, itk.first);
        }
    }

    checkstable(S, A);
    for (auto it : A) {
        cout << it.first << ' ' << it.second << endl;
    }

    return 0;
}

Measured memory_bytes: 7060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	if (K == 1000000000) {
		vector<int>v(N, 1);
		for (int i = 0; i < M; i++)v[i] = K;
		for (auto i : v)cout << i << " ";
		cout << endl;
		return 0;
	}
	vector<int>v(N, 1000000000);
	for (int i = 0; i < M; i++)v[i] = K;
	for (auto i : v)cout << i << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1792
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int a=s.size()-2;
  std::cout << s[0] << a << s[a+1];
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<iomanip>
#define MAX 500005
#define MOD 1000000007
#define lo long long
#define INF 1e18
#define pp pair<long long , long long>
#define ppp pair<long long, pair<long long, long long> >
#define pb(a) push_back(a)
#define fi first
#define se second
#define PI 3.14159265
using namespace std;

lo a[MAX];
int main() {

    lo a, b, c, d;
    cin>>a>>b>>c>>d;
    
    lo ans = -INF;
        
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    ans = max(ans, a*c);

    cout<<ans<<endl;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int dp[100000];
int mi[100000];

int dfs(int now, int pre, const Graph& G) {
    for (auto nxt : G[now]) {
        if (nxt == pre) continue;
        chmax(dp[now], dfs(nxt, now, G) + 1);
    }
    return dp[now];
}

void dfs2(int now, int pre, int prop, const Graph& G) {
    vector<Pii> vp;
    vp.emplace_back(0, -1);
    for (auto nxt : G[now]) {
        if (nxt == pre) vp.emplace_back(prop + 1, nxt);
        else vp.emplace_back(dp[nxt] + 1, nxt);
    }
    sort(rall(vp));
    mi[now] = vp[0].first;
    for (auto nxt : G[now]) {
        if (nxt == pre) continue;
        dfs2(nxt, now, vp[vp[0].second == nxt].first, G);
    }
}

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

    int n;
    cin >> n;
    Graph G(n);
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    dfs(0, -1, G);
    dfs2(0, -1, 0, G);

    rep(i, n) cout << 2 * (n - 1) - mi[i] << endl;
}

Measured memory_bytes: 31844
#include<stdio.h>

int main()
{
 int N;
 int K;
 long x[100005];
 long dist;
 long mindist=4000000000;
 long distp;
 long distm;
 int i;

 scanf("%d %d",&N,&K);
 for(i=0;i<N;i++) scanf("%ld",&x[i]);
 for(i=K-1;i<N;i++)
 {
  if(x[i]<0) dist=-x[i-K+1];
  if(x[i-K+1]>0) dist=x[i];
  if((x[i]>=0)&(x[i-K+1]<=0))
  {
   distp=2*x[i]-x[i-K+1];
   distm=x[i]-2*x[i-K+1];
   if(distp<distm)
   {
    dist=distp;
   }else{
    dist=distm;
   }
  }
  if(mindist>dist) mindist=dist;
 }
 printf("%ld\n",mindist);
 return 0;
}


Measured memory_bytes: 896
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(A, 1):
  if a == i:
    if i != len(A):
      x = A[i - 1]
      y = A[i]
      A[i - 1] = y
      A[i] = x    
      cnt += 1
    else:
      x = A[i - 2]
      y = A[i - 1]
      A[i - 2] = y
      A[i - 1] = x    
      cnt += 1
print(cnt)

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

int main() {

    int n;
    
    cin >> n;

    char abc[] = {'A', 'B', 'C'};

    int count = 0;

    vector<char> s(n);

    cin >> s[0];
    cin >> s[1];

    for(int i = 2; i < n; ++i) {

        cin >> s[i];

        int j;
        for(j = 0; j < 3 && abc[j] == s[i - 2 + j]; j++) ;

        if(j == 3)
            count++;

    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int x; cin >> x;
    if(x == 3 || x == 5 || x == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct qj{
    int l,r;

    bool operator <(const qj &b)const{
        return r<b.r;
    }

}a[100005];
int main(){
    int m,n,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
        cin>>a[i].l>>a[i].r;
    sort(a,a+m);
    int last=-1;
    for(int i=0;i<m;i++){
        if(a[i].l>=last)
            sum++,last=a[i].r;
    }
    cout<<sum<<'\n';


}


Measured memory_bytes: 1024
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#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 INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int N;
int x[110];
int main()
{
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    cin >> x[i];
  }
  ll min = INF;
  for (int p = 1; p < 101; p++)
  {
    ll tmpMin = 0;
    for (int j = 0; j < N; j++)
    {
      int div = p - x[j];
      tmpMin += div * div;
    }
    if (tmpMin < min)
    {
      min = tmpMin;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

a = 10000
b = 5000
c = 1000

# p = 1 q = 1
# cの枚数 = 5


def solve(n):
    for i in range(N+1):
        for j in range(N-i+1):
            tmp = Y - a * i - b * j
            k = N - i - j
            if (tmp == 0 and k == 0) or tmp // c == k:
                return i, j, k
    return -1, -1, -1


i, j, k = solve(N)
print(i, j, k)


Measured memory_bytes: 38896
// https://atcoder.jp/contests/abc157/tasks/abc157_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  ll res = (N + 1) / 2;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main () {
	int R;
	cin >> R;
	
	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

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

N = int(input())

lst_A = []
l_A_append = lst_A.append
lst_B = []
l_B_append = lst_B.append
for i in range(N):
    A, B = map(int, input().split())
    l_A_append([A + B, A, B, i])
    l_B_append([A + B, B, A, i])
    
lst_A.sort(reverse = True)
lst_B.sort(reverse = True)
# print (lst)
ans = 0
check_lst = [False] * N

index_A = 0
index_B = 0
count = 0
while count < N:
    if count % 2 == 0: #高橋くんの番
        while check_lst[lst_A[index_A][3]]: #使われているとき-->index_Aを増やす
            index_A += 1
        ans += lst_A[index_A][1]
        check_lst[lst_A[index_A][3]] = True
        index_A += 1
    else: #青木さんの番
        while check_lst[lst_B[index_B][3]]: #使われていないとき -->index_Bを増やす
            index_B += 1
        ans -= lst_B[index_B][1]
        check_lst[lst_B[index_B][3]] = True
        index_B += 1
    count += 1
print (ans)


Measured memory_bytes: 43724
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair<int, int> pii;

const ll mod = 998244353;
const int N = (int)2e5 + 5;

string x;
int n;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    vector<int> divs;
    vector<ll> ans;
    for(ll i = 1; i * i <= n; i++){
        if(n%i != 0)cont;
        divs.pb(i);
        if(i * i != n)
            divs.pb(n/i);
    }
    sort(all(divs));
    ans.resize(divs.size());
    int k = divs.size();
    F(i, 0, k){
        ans[i] = 0;
        if(n/divs[i]%2 == 0)cont;
        int d = divs[i];
        ll kek = 0;
        F(j, 0, d){
            kek = (kek<<1) + (x[j] - '0');
            kek %= mod;
        }
        ++kek;
        if(kek >= mod)kek -= mod;
        F(j, d, n){
            int curr = (j/d&1)? (1 - (x[j%d] - '0')) : (x[j%d] - '0');
            if(curr > x[j] - '0'){
                --kek;
                break;
            }
            if(curr < x[j] - '0')
                break;
        }
        if(kek < 0)kek += mod;
        ans[i] = kek;
        F(j, 0, i){
            if(d%divs[j])cont;
            ans[i] -= ans[j];
            ans[i] += ans[i] < 0 ? mod : 0;
        }
    }
    ll tot = 0;
    F(i, 0, k){
        //cout << divs[i] << ' ' << ans[i] << endl;
        tot += ans[i] * 2 * divs[i] % mod;
    }
    cout << tot%mod;
    return 0;
}


Measured memory_bytes: 848
/* ex9_2
    fmuacshai */

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
# define SIZE 100001
//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    //node型のcubefurstを初期化して定義
    node *cubefirst=NULL;
    //消去数カウントのcountとfor文で使うiを定義
    int count=0,i;
    //入力された配列をarrayとして定義
    char array[SIZE];
    //入力
    scanf("%s",array);
    //入力数だけ繰り返す
    for(i=0;i<strlen(array);i++){
        //空だった時と同じ数字が連続しているときは追加
        if(cubefirst==NULL||array[i]==cubefirst->elem){
            push(&cubefirst,array[i]);
        //異なる数字が入力されたときは取り出す
        }else{
            pop(&cubefirst);
            //消去した分を追加
            count+=2;
        }
    }
    //結果を出力
    printf("%d\n",count);
    return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> d(N);

    for(int i=0; i<N;i++){
        cin >> d.at(i).first >> d.at(i).second;
    }

    bool ans = false;
    for(int i=2; i<N; i++){
        if(d.at(i).first == d.at(i).second){
            if(d.at(i-1).first == d.at(i-1).second){
                if(d.at(i-2).first == d.at(i-2).second){
                    ans = true;
                }
            }
        }
    }

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

Measured memory_bytes: 3628
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n,x;
  cin>>n>>x;

  int ans=1;

  REP(i,n){

    int y;
    cin>>y;

    x-=y;

    ans+=x>=0;

  }

  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
ac = [list(map(int,input().split())) for _ in range(n)]
ttlmmin = 10**8
for i in range(1<<n):
    ttlm = 0
    skl = [0]*m
    for k in range(n):
        if i & (1<<k):
            for l in range(m):
                skl[l] += ac[k][l+1]
            ttlm += ac[k][0]
    flag = True
    for l in range(m):
        if skl[l] < x:
            flag = False
            break
    if flag: ttlmmin = min(ttlmmin,ttlm)    
if ttlmmin == 10**8:
    print(-1)
else:
    print(ttlmmin)

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll x,y;
  cin>>x>>y;
  if(x>0&&y>0&&x>y)
    cout<<x-y+2<<endl;
  if(x>=0&&y>0&&x<y)
    cout<<y-x<<endl;
  if(x>0&&y<=0)
   cout<<abs(x-abs(y))+1<<endl;
  if(x<0&&y<=0&&x<y)
    cout<<y-x<<endl;
  if(x<0&&y<0&&x>y)
    cout<<x-y+2<<endl;
  if(x<0&&y>0)
    cout<<abs(y-abs(x))+1<<endl;
  if(x==0&&y<0)
    cout<<x-y+1<<endl;
  }


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int N, M; 
	int a, b;
	int i;
	int count[51] = { 0 };

	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &a, &b);
		count[a-1]++;
		count[b-1]++;
	}

	for (i = 0; i < N; i++) {
		printf("%d\n", count[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18+10;
int main(){
    ll n,k;cin >> n >> k;
    vector<ll> p,m;
    for(int i=0;i<n;i++){
        ll a;cin >> a;
        if(a>0){
            p.push_back(a);
        }
        else if(a<0){
            m.push_back(-a);
        }
    }
    sort(p.begin(),p.end());
    sort(m.begin(),m.end());
    ll a=p.size(),b=m.size(),c=n-a-b;
    ll d=a*b+(a+b)*c+c*(c-1)/2;
    if(k<=a*b){
        ll l=-INF,r=0;
        while(r-l>1){
            ll mid=(l+r)/2;
            ll sum=0;
            for(int i=0;i<a;i++){
                int u=upper_bound(m.begin(),m.end(),-mid/p[i])-m.begin();
                sum+=b-u;
            }
            if(sum<k){
                l=mid;
            }
            else{
                r=mid;
            }
        }
        cout << l << endl;
    }
    else if(k<=d){
        cout << 0 << endl;
    }
    else{
        ll l=0,r=INF;
        while(r-l>1){
            ll mid=(l+r)/2;
            ll sum=0;
            for(int i=0;i<a;i++){
                int u=upper_bound(p.begin(),p.end(),mid/p[i])-p.begin();
                sum+=max(0,u-i-1);
            }
            for(int i=0;i<b;i++){
                int v=upper_bound(m.begin(),m.end(),mid/m[i])-m.begin();
                sum+=max(0,v-i-1);
            }
            if(d+sum<k){
                l=mid;
            }
            else{
                r=mid;
            }
        }
        cout << r << endl;
    }
}

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

int main() {
  string S;
  cin>>S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='?'){
      cout<<'D';
    }
    else{
      cout<<S.at(i);
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3760
/*
AizuOnline A0010
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
double x1,y10,x2,y2,x3,y3;
int n;
//
extern double det3(double a[3][3]);
void solve_3ren(double a[3][3],double x[3],double r[3])
{
  double d3,a1,a2,a3;
  double aa[3][3];
  int i,j,p,q;

  d3=det3(a);
  //printf("D3 %lf\n",d3);
  for(j=0;j<3;j++)
    {

      for(p=0;p<3;p++)
	for(q=0;q<3;q++)
	  aa[p][q]=a[p][q];

      for(i=0;i<3;i++)
	aa[i][j]=x[i];
      r[j]=det3(aa);
      r[j]/=d3;
      //printf("%d %d\n",j,r[j]);
    }
}

double det3(double a[3][3])
{
  double s;
  //printf("A202122=%lf %lf %lf\n",a[2][0],a[2][1],a[2][2]);
  s =a[0][0]*(a[1][1]*a[2][2]-a[1][2]*a[2][1]);
  s-=a[0][1]*(a[1][0]*a[2][2]-a[2][0]*a[1][2]);
  s+=a[0][2]*(a[1][0]*a[2][1]-a[1][1]*a[2][0]);

  return(s);
}

main()
{
  double a[3][3];
  double r[3];
  double res[3];
  int i;
  double cx,cy,cr;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%lf %lf %lf %lf %lf %lf",&x1,&y10,&x2,&y2,&x3,&y3);
      a[0][0]=x1;a[0][1]=y10;a[0][2]=1;r[0]=-x1*x1-y10*y10;
      a[1][0]=x2;a[1][1]=y2;a[1][2]=1;r[1]=-x2*x2-y2*y2;
      a[2][0]=x3;a[2][1]=y3;a[2][2]=1;r[2]=-x3*x3-y3*y3;
      solve_3ren(a,r,res);
      //printf("%lf %lf %lf\n",res[0],res[1],res[2]);

      cx=-res[0]/2.0;cy=-res[1]/2.0;
      cr=sqrt(-res[2]+res[0]*res[0]/4.0+res[1]*res[1]/4.0);
      printf("%.3lf %.3lf %.3lf\n",cx,cy,cr);
    }
return(0);
}

Measured memory_bytes: 656
def c_colon_dist():
    from math import pi, sin, cos, dist
    A, B, H, M = [int(i) for i in input().split()]

    hour_hand_rad = (60 * H + M) * pi / 360
    minute_hand_rad = M * pi / 30
    hour_hand_pos = (sin(hour_hand_rad) * A, cos(hour_hand_rad) * A)
    minute_hand_pos = (sin(minute_hand_rad) * B, cos(minute_hand_rad) * B)
    return dist(hour_hand_pos, minute_hand_pos)

print(c_colon_dist())

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int score[2] = {0} ;
    int cmp = 0 ;

    for (int i = 0 ; i < 2 ; i++ )
    {
        for ( int j = 0 ; j < 4 ; j++ )
        {
            cin >> cmp ;
            score[i] += cmp ;
        }
    }

    if ( score[0] >= score[1] )
    {
        cout << score[0] << endl ;
    } else cout << score[1] << endl ;

    return 0 ;
}

Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int a[5],k;
    rep(i,5) { cin >> a[i]; }
    cin >> k;
    
    rep(i,5) {
        rep(j,i) {
            //cout << a[i]-a[j] << ",";
            if(a[i]-a[j] > k) { 
                cout << ":(" << endl;
                return 0;
            }
        }
        //cout << endl;
    }

    cout << "Yay!" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//

int main() {
    int N;
    cin >> N;
    ll tmp;
    ll ans=0;
    while(N--){
        ll a,b;
        cin >> a >> b;
        if(a>tmp){
            tmp = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n,k,mx1=0,mx2=0,i;
    cin>>k>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=1;i<n;i++)
    {
        mx1=a[i]-a[i-1];
        if(mx1>mx2)
            mx2=mx1;
    }
    mx1=k-a[n-1]+a[0];
    if(mx1>mx2)
        mx2=mx1;
    cout<<(k-mx2)<<endl;
	return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
//const int MOD = 1e9+7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), d(m-1);
    for(int i=0; i<m; ++i)
        cin >> a[i];
    
    if(n>=m){
        cout << 0;
        return 0;
    }

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

    for(int i=0; i<m-1; ++i)
        d[i] = a[i+1]-a[i];
    
    sort(d.begin(), d.end());

    ll ans = 0;
    for(int i=0; i<m-n; ++i)
        ans += d[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 3948
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;



//#[proconio::fastout]
fn main() {
    input! {
        mut x: i64,
        mut k: i64,
        d: i64,
    }

    x = x.abs();

    let n = x / d;
    if k <= n {
        x -= k*d;
    } else {
        x -= n*d;
        k -= n;

        if k % 2 != 0 {
            x = (x-d).abs();
        }
    }

    println!("{}", x);
}


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

const int mod=1e9+7;

ll K(ll x,ll y=mod-2){
    ll t=1;
    for (;y;y>>=1,x=x*x%mod)
        if (y&1) t=t*x%mod;
    return t;
}

int n, m, fa[1010]; ll aim, c0, c1, c2;
struct E{
    int u, v, w;
}e[2020];

int GF(int x){
    return x==fa[x]? x: fa[x]=GF(fa[x]);
}

ll calc(int id){
    ll res=e[id].w;
    for (int i=1;i<=n;++i) fa[i]=i;
    fa[GF(e[id].u)]=GF(e[id].v);
    for (int i=1;i<=m;++i){
        if (i==id) continue;
        int u=e[i].u, v=e[i].v;
        if (GF(u)!=GF(v)){
            fa[GF(u)]=GF(v);
            res+=e[i].w;
        }
    }
    return res;
}

int main(){
    cin>>n>>m>>aim;
    for (int i=1;i<=m;++i)
        cin>>e[i].u>>e[i].v>>e[i].w;
    sort(e+1,e+m+1,[](E a,E b){return a.w<b.w;});
    
    for (int i=1;i<=m;++i){
        ll t=calc(i);
        if (t==aim) ++c1;
        else if (t<aim) ++c0;
        else ++c2;
    }
    ll ans;
    if (!c1) return puts("0"), 0;
    if (c0){
        ans=2*(K(2,c1)-1)*K(2,c2)%mod;
    }else{
        ans=(K(2,c1)-2+mod)*K(2,c2)%mod;
    }
    cout<<ans<<endl;
}

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

int main()
{
     ios::sync_with_stdio(0);
     cin.tie(0);
   string s;
   cin>>s;

if(s[s.size()-1]=='s'){
cout<<s<<"es";
}
else{
 cout<<s<<"s";
 }

return 0;
}

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

int MOD = 1e9 + 7;
long long mod_pow(long long x, int n, int mod) {
  if (n == 0) return 1;
  if (n & 1) return x * mod_pow(x, n - 1, mod) % mod;
  long long h = mod_pow(x, n / 2, mod);
  return h * h % mod;
}

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

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

  int ans = 0;
  if (n % 2 == 0 || c[0] == 1) {
    bool flag = true;
    for (int i = 1 + (n & 1); i < n; i += 2) {
      if (c[i] != 2) {
        flag = false;
        break;
      }
    }
    if (flag) ans = mod_pow((long long)2, n / 2, MOD);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 300000
#define MAX_E 300000
typedef pair<int,int> P;

int par[MAX_N];
int ran[MAX_N]; 

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ran[i]=0;
  }
}

int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(ran[x]<ran[y])par[x]=y;
  else {
    par[y]=x;
    if(ran[x]==ran[y])ran[x]++;

  }
}

bool same(int x,int y){
  return find(x)==find(y);
}

struct edge{int u,v,cost;};

bool comp(const edge& e1,const edge e2){
  return e1.cost < e2.cost;
}

edge es[MAX_E];
int V,E; //頂点数、辺数

int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}

int main(){
  cin>>V;
  vector<P> vx,vy;
  for(int i=0;i<V;i++){
    int x,y;
    cin>>x>>y;
    vx.push_back(P(x,i));
    vy.push_back(P(y,i));
  }
  sort(vx.begin(),vx.end());
  sort(vy.begin(),vy.end());
  int cnt=0;
  for(int i=1;i<vx.size();i++){
    int u=vx[i-1].second;
    int v=vx[i].second;
    int cost=vx[i].first-vx[i-1].first;
    es[cnt++]=(edge){u,v,cost};
  }
  
  for(int i=1;i<vy.size();i++){
    int u=vy[i-1].second;
    int v=vy[i].second;
    int cost=vy[i].first-vy[i-1].first;
    es[cnt++]=(edge){u,v,cost};
  }
  E=cnt;
  cout<<kruskal()<<endl;
  
  return 0;
}


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

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

    int count = 0 ;
    for (int i = 0; i < n-2; i++)
    {
        if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')
        {
            count ++ ;
        }
    }
    cout << count << endl ;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//ダイクストラ法
vll dijkstra(ll n, vector<vector<vll>> &nx, ll start) {
	vll ret(n, inf);
	ret[start] = 0;
	queue<ll> task;
	task.push(start);
	priority_queue<vll, vector<vll>, greater<vll>> pq;
	while (task.size()) {
		while (task.size()) {
			ll x = task.front();
			task.pop();
			for (ll i = 0; i < nx[x].size(); i++) {
				vll v = nx[x][i];
				if (ret[v[1]] < inf) continue;
				pq.push({ret[x] + v[0], v[1]});
			}
		}
		while (pq.size() && ret[pq.top()[1]] < inf) pq.pop();
		if (pq.size()) {
			vll v = pq.top();
			pq.pop();
			ret[v[1]] = v[0];
			task.push(v[1]);
		}
	}
	return ret;
}

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

	ll n, m, s;
	cin >> n >> m >> s;
	s = min(s, 2500ll);

	//頂点aで銀貨b枚所持
	auto index = [&] (ll a, ll b) {return a + b * n;};

	vector<vector<vll>> nx(n * 2501, vector<vll>(0));
	for (ll i = 0; i < m; i++) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		for (ll j = a; j <= 2500; j++) {
			nx[index(u, j)].push_back({b, index(v, j - a)});
			nx[index(v, j)].push_back({b, index(u, j - a)});
		}
	}

	for (ll i = 0; i < n; i++) {
		ll c, d;
		cin >> c >> d;
		for (ll j = 0; j <= 2500 - c; j++) {
			nx[index(i, j)].push_back({d, index(i, j + c)});
		}
	}

	vll ans = dijkstra(n * 2501, nx, index(0, s));
	for (ll i = 1; i < n; i++) {
		ll x = inf;
		for (ll j = 0; j <= 2500; j++) {
			x = min(x, ans[index(i, j)]);
		}
		cout << x << endl;
	}
}


Measured memory_bytes: 57372