akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

bool comp(const pair<ll,ll>& left,const pair<ll,ll>& right){
    if(left.first==right.first){
        return left.second > right.second;
    }else{
        return left.first < right.first;
    }
}

int main() {
    IOS;
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<P> p(n);
    REP(i,n){
        cin >> a[i];
        p[i].first = a[i];
        p[i].second = i;
    }
    vector<P> b;
    b.push_back(P(a[0],0));
    REP(i,n){
        if(a[i]>b.back().first){
            b.push_back(P(a[i],i));
        }
    }
    
    sort(all(p),comp);
    ll cnt = 0;
    ll t1 = 0, t2 = 0;
    vector<ll> res(n,0);
    REP(i,n){
        if(p[i]==b[cnt]){
            cnt++;
            res[p[i].second] += t1;
            res[p[i].second] += (n-i)*(p[i].first-t2);
            t1 = 0;
            t2 = p[i].first;
            if(cnt==b.size())break;
        }else{
            t1 += p[i].first-t2;
        }
    }
    REP(i,n){
        put(res[i]);
    }
    return 0;
}


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

int main() {
    int n;
    cin >>n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    if (n<3) {
        cout << ans << endl;
        return 0;
    }
    sort(l.begin(), l.end());
    for(int i=0; i<n ; ++i) {
        for(int j=i+1; j<n; ++j) {
            for(int k=j+1; k<n ; ++k) {
                if (l[i]==l[j] || l[i]==l[k] || l[j]==l[k]) continue;
                if (l[i]+l[j]>l[k]) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> solveFor(int n, int a, int b) {
	if(n == 1) {
		if(a == 0) return {0, 1};
		else return {1, 0};
	}
	int x;
	for(int i=0; ; i++) {
		if(((a >> i) & 1) != ((b >> i) & 1)) {
			x = i;
			break;
		}
	}
	int na = 0, nb = 0, ati = 0;
	for(int i=0; i<n; i++) {
		if(i == x) continue;
		if((a >> i) & 1) na |= (1 << ati);
		if((b >> i) & 1) nb |= (1 << ati);
		ati++;
	}
	int nc = na ^ 1;
	vector<int> A = solveFor(n-1, na, nc);
	vector<int> B = solveFor(n-1, nc, nb);
	vector<int> C;
	for(auto it : A) {
		int ati = 0, num = 0;
		for(int i=0; i<n; i++) {
			if(i == x) {
				if((a >> i) & 1) num |= (1 << i);
				continue;
			}
			if((it >> ati) & 1) num |= (1 << i);
			ati++;
		}
		C.pb(num);
	}
	for(auto it : B) {
		int ati = 0, num = 0;
		for(int i=0; i<n; i++) {
			if(i == x) {
				if((b >> i) & 1) num |= (1 << i);
				continue;
			}
			if((it >> ati) & 1) num |= (1 << i);
			ati++;
		}
		C.pb(num);
	}
	return C;
}

int main() {

	boost;
	int n, a, b; cin>>n>>a>>b;
	if((__builtin_popcount(a) & 1) == (__builtin_popcount(b) & 1)) {
		cout<<"NO\n";
		exit(0);
	}
	vector<int> ans = solveFor(n, a, b);
	cout<<"YES\n";
	for(auto it : ans) {
		cout<<it<<" ";
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1756
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let N = read int
    let A = reada int
    let mutable ok = false
    let memo = SortedDictionary<int, int>()
    for a in A do
        if memo.ContainsKey(a) then memo.[a] <- memo.[a] + 1 else memo.Add(a, 1)

    if memo.Count = 3 && N%3=0 then 
        let ok1 = 
            memo
            |> Seq.forall (fun x -> x.Value = N/3)

        let ok2 = 
            memo
            |> Seq.map (fun kv -> kv.Key)
            |> Seq.reduce (^^^)
            |> fun x -> x = 0
        ok <- ok1 && ok2
    else if memo.Count = 2 && N%3=0 then 
        let a = Array.ofSeq memo
        if a.[0].Key = 0 && a.[0].Value = N/3 && a.[1].Value = N/3*2 then ok <- true
    else if memo.Count = 1 && memo.ContainsKey(0) then ok <- true

    if ok then "Yes" else "No"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


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

using namespace std;

int main()
{
    long n;
    cin >> n;
    long answer = 0;

    for (int i = 1; i <= sqrt(n); i++)
    {
        if(i * i <= n)
        {
            answer = i * i;
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    long n;
    cin >> n;
    vector<int> a(n), count(n, 0);
    ll sum = 0;

    rep(i, n)
    {
        cin >> a[i];
        sum += count[a[i]];
        count[a[i]]++;
    }

    rep(i, n)
    {
        cout << sum - count[a[i]] + 1 << endl;
    }
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

bool visited[50],graph[50][50];
int n,m;

void dfs (int v){
    visited[v]=true;
    for (int v2=0; v2<n; v2++){
        if (graph[v][v2]==false){
            continue;
        }
        if (visited[v2]==true){
            continue;
        }
        dfs (v2);
    }
}

int main(void){
    scanf("%d%d",&n,&m);
    int a[50],b[50];
    
    for (int i=0; i<m; i++){
        scanf("%d%d",&a[i],&b[i]);
        a[i]--;
        b[i]--;
    }
    
    for (int i=0; i<m; i++){
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
        visited[i]=true;
    }
    
    int ans=0;
    
    for (int i=0; i<m; i++){
        graph[a[i]][b[i]] =false;
        graph[b[i]][a[i]] =false;
        
        for (int j=0; j<n; j++){
            visited[j]=false;
        }
        
        dfs(0);
        
        bool bridge =false;
        for (int j=0; j<n; j++){
            if (visited[j]==false){
                bridge=true;
            }
        }
        if (bridge ==true){
            ans++;
        }
        
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    printf("%d\n",ans);
	return 0 ;
}

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

int main() {
	string s;
	int n,m;
	cin >> s;
	for (int i = 0;;i++) {
		if (s[i] == 'A') {
			n = i;
			break;
		}
	}
	for (int i = s.length()-1;;i--) {
		if (s[i] == 'Z') {
			m = i;
			break;
		}
	}
	cout << m - n + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

typedef vector<vector<int>> UnWeightedGraph;

template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  UnWeightedGraph gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return (comp[k]);
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(UnWeightedGraph &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};

int N;
double p[105];

bool visited[105];
vector<int> Nodes[105];
double ans;
void solve() {
    ans = 1;
    UnWeightedGraph g(N), t;
    for(int i = 0; i < N; i++) {
        visited[i] = false;
        Nodes[i].clear();
        cin >> p[i];
        int m;
        cin >> m;
        while(m--) {
            int a;
            cin >> a;
            a--;
            g[i].push_back(a);
        }
    }
    StronglyConnectedComponents<UnWeightedGraph> SCC(g);
    SCC.build(t);
    for(int i = 0; i < N; i++) {
        Nodes[SCC[i]].push_back(i);
    }
    for(int i = 0; i < t.size(); i++) {
        for(auto to : t[i]) {
            visited[to] = true;
        }
        if(visited[i]) continue;
        double now = 1;
        for(auto person : Nodes[i]) {
            now *= p[person];
        }
        ans *= 1 - now;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> N;
        if(N == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
bool uneven(int a)
{
int sum=0;
while(a)
{
sum++;
a/=10;
}
return sum%2;
}
int main()
{
int N,sum=0;
cin>>N;
for(int i=1;i<=N;i++)if(uneven(i))sum++;
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair<ll, ll> P;
const int MAXN = 1e5 + 7;
const int LOG = 20;
const int INF = 0x3f3f3f3f;

bool check(string s) {
    int len = s.size();
    for(int i = 0,j = s.size()-1;i <= j;i++,j--){
        if(s[i] != s[j])
            return false;
    }
    return true;
}

void solve() {
    double n;
    cin >> n;
    double ans = n*0.333333333333333333333333;
    printf("%.10f\n",ans*ans*ans);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int T;
    T = 1;
    while(T--) {
        solve();
    }
    return 0;
}


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

int main(){
  int h, w; cin >> h >> w;
  vector<vector<int>> dist(10, vector<int>(10));
  vector<vector<int>> A(h, vector<int>(w));
  
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> dist.at(i).at(j);
    }
  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        dist.at(i).at(j) = min(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }
  
  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(A.at(i).at(j) == -1){
        continue;
      }
      ans += dist.at(A.at(i).at(j)).at(1);
    }
  }
  
  cout << ans << endl;
      
  
}



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

int main(){
  int A; cin>>A;
  string S; cin>>S;
  if(A>=3200) cout<<S<<endl;
  else cout<<"red\n";
  return 0;
}


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

int main(int, char **) {

  char str[11];
  scanf("%s", str);
  regex re(R"([ACGT]+)");
  int len = strlen(str);
  int max = 0;

  cmatch results;
  int p = 0;
  while (regex_search(str + p, results, re)) {
    if (max < results.str().size()) {
      max = results.str().size();
    }
    p += results.position() + results.str().size();

    if (p >= len) {
      break;
    }
  }
  cout << max;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin>>s;
  string ans="2018";
  int n=s.size();
  rep(i,4,n){
   ans+=s[i]; 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int C[500], S[500], F[500];

// _t秒に_ix駅にいるときに次の駅に着く時間をreturn
int getNextTime(int _t, int _stat_ix) {
	if (_t < S[_stat_ix]) {
		return S[_stat_ix] + C[_stat_ix];
	}
	else {
		if (_t%F[_stat_ix] == 0) {
			return _t + C[_stat_ix];
		}
		else {
			return (_t / F[_stat_ix] + 1)*F[_stat_ix] + C[_stat_ix];
		}
	}
	return 0;
}

int main() {
	int N = 0;
	cin >> N;
	REP(i, N-1) {
		cin >> C[i] >> S[i] >> F[i];
	}

	REP(i, N) {
		int time = 0;
		REPS(j, i, N-1) {
			time = getNextTime(time, j);
		}
		cout << time << endl;
	}

	system("pause");
	return 0;
}

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

typedef long long ll;

int main() {
    ll N, A, s = 0, Q, B, C;
    cin >> N;
    vector<ll> cnt(100001, 0);
    rep(i, N) {
        cin >> A;
        cnt[A]++;
        s += A;
    }
    cin >> Q;
    rep(i, Q) {
        cin >> B >> C;
        s = s + (C - B) * cnt[B];
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << s << "\n";
    }
}

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

const int maxn = 100005;

int n, a;
vector < int > g[maxn];

int dfs (int u) {
	int res = 0;
	vector < int > prior;
	for (int v: g[u]) 
		prior.push_back(dfs(v));
	sort(prior.rbegin(), prior.rend());
	if (prior.empty())
		return res;
	else {
		for (int i = 0; i < int(prior.size()); ++i)
			prior[i] += i + 1, res = max(res, prior[i]);
		return res;
	}
}

signed main () {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		scanf("%d", &a);
		g[a].push_back(i);
	}
	printf("%d\n", dfs(1));
}


Measured memory_bytes: 20076
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


S = input()
A, B, C, D = map(int, [S[0], S[1], S[2], S[3]])
dump(A, B, C, D)
for op1, op2, op3 in it.product(['+', '-'], repeat=3):
    dump(op1, op2, op3)

    def f(op, a): return a * (1 if op == '+' else -1)
    ans = A + f(op1, B) + f(op2, C) + f(op3, D)
    dump(A, f(op1, B), f(op2, C), f(op3, D))
    if(ans == 7):
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
        exit(0)
print("")


Measured memory_bytes: 4720
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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() {   
    ll x; cin >> x;
    int cnt = 0;
    ll m = 100;
    while(m < x){
        ll d = m / 100;
        m += d;
        cnt++;
    }
    cout << cnt << ln;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
    std::string s;
    long long int k;
    std::cin >> s >> k;
    int ans = 1;
    for(int i=0;i<std::min((long long int)s.length(), k);i++)
    {
        if(s[i] != '1')
        {
            ans = s[i] - '0';
            break;
        }
    }
    std::cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
int in[55]={0,1,3,1,2,1,2,1,1,2,1,2,1};;
int n,m,k;
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		if(in[n]==in[m]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
MOD = 998244353

N, S = map(int, input().split())
A = list(map(int, list(input().split())))

ans = 0
dp = [[0]*(S+1) for _ in range(N+1)]
for i in range(N):
    dp[i][0] += 1       # Lがiからを足す
    for j in range(S+1):
        dp[i+1][j] += dp[i][j]             # A[i]を選ばない
        dp[i+1][j] %= MOD
        if j+A[i]<=S:
            dp[i+1][j+A[i]] += dp[i][j]    # A[i]を選ぶ
            dp[i+1][j+A[i]] %= MOD
    ans += dp[i+1][S]    # Rがiまでを足す
    ans %= MOD

print(ans)

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

const int MAX = 105;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  for(int i = 0; i < MAX; i++){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double inputRadius = sc.nextDouble();
        System.out.print(String.format("%f", Math.pow(inputRadius, 2) * Math.PI));       //円の面積
        System.out.println(" " + String.format("%f\n", inputRadius * 2 * Math.PI));        //円周の長さ
    }
}



Measured memory_bytes: 28240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		PrintStream out = System.out;
		int n = Integer.parseInt(in.readLine());// 要素数n
		String[] str = new String[n];
		str = in.readLine().split(" ");
		for (int i = 1; i <= n; i += 1) {
			if (i == n) {
				sb.append(str[n - i]);
				break;
			} else {
				sb.append(str[n - i]);
				sb.append(" ");
			}
		}
		out.println(sb);
	}
}

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

int main(void) {
    int X;
    cin >> X;
    int A, B;
    for (int i = -120; i < 120; i++) {
        for (int j = -120; j < 120; j++) {
            if (i*i*i*i*i - j*j*j*j*j == X) {
                A = i;
                B = j;
                break ;
            }
        }
    }
    cout << A << ' ' << B << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
int mod=1e9+7;
int gcd (int a, int b) {
   while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll fast(ll a,ll n){
	a%=mod;
	ll res=1;
	while(n>0){
		if(n&1)res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}
int digit_sum(int a){
	int sum=0;
	while(a){
		sum+=a%10;
		a/=10;
	}
	return sum;
}
	// vector<int> v;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	f(i,n){
		cin>>a[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	// memset(dp,, sizeof dp);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<vector<int>>v;
vector<bool>check;
queue<int>q;

int main() {
	int n, m;
	cin >> n >> m;
	v.assign(n, vector<int>(0, 0));
	check.assign(n, false);
	rep(i, 0, m) {
		int a, b, c;
		cin >> a >> b >> c;
		v[a - 1].push_back(b - 1);
		v[b - 1].push_back(a - 1);
	}
	int ans = 0;
	rep(i, 0, n) {
		if (check[i] == false) {
			q.push(i);
			ans++;
			check[i] = true;
			while (!q.empty()) {
				int hoge = q.front();
				q.pop();
				rep(j, 0, v[hoge].size()) {
					if (check[v[hoge][j]] == false) {
						q.push(v[hoge][j]);
						check[v[hoge][j]] = true;
					}
				}
			}
		}
	}
	cout << ans << endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    map<ll, ll> m;
    m[0] = 1;
    ll sum[n];
    sum[0] = a[0];
    repd(i, 1, n) { sum[i] = sum[i - 1] + a[i]; }

    ll ans = 0;
    rep(i, n) {
        ans += m[sum[i]];
        m[sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15872
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key){
  int left=0, right=n, mid;
  while(left<right){
    mid = (left+right)/2;
    if(key==A[mid]) return 1;
    if(key>A[mid]) left=mid+1;
    else if(key<A[mid]) right=mid;
  }
  return 0;
}

int main(){
  int i, q, k, sum=0;

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

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &k);
    if(binarySearch(k)) sum++;
  }

  printf("%d\n", sum);
  
  return 0;
}



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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,x;
  cin >> n >> m >> x;
  ll ans = LLONG_MAX/4;

  vector<ll> cost(n);
  vector<vector<ll> > a(n,vector<ll>(m));
  rep(i,n){
    cin >> cost[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }

  rep(i,1<<n){
    vector<int> und(m,0);
    ll tot =0;
    rep(j,n){
      if(i & (1<<j)){
        rep(l,m){
          und[l] += a[j][l];
        }
        tot += cost[j];
      }
    }
    bool ok=true;
    rep(j,m){
      if(und[j]<x) ok = false;
    }
    if(ok) ans = min(ans,tot);
  }

  if(ans != LLONG_MAX/4)cout <<ans << endl;
  else cout << -1 << endl;

  return 0;
    

}


Measured memory_bytes: 3652
import sys
from pprint import pprint
import math

h, n = map(int, sys.stdin.readline().strip().split(" "))

a, b = [], []
for _ in range(n):
    a_i, b_i = map(int, sys.stdin.readline().strip().split(" "))
    a.append(a_i)
    b.append(b_i)

a_max = max(a)
dp = [[10**12] * (h+a_max+1) for _ in range(n+1)]

# dp[i][0]はコスト0
for i in range(n+1):
    dp[i][0] = 0

# i個の魔法
for i in range(n):
    # hの体力
    for j in range(h+a_max+1):
        if j < a[i]:
            dp[i+1][j] = dp[i][j]
        # 通常時
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]] + b[i])


print(min(dp[n][h:]))

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

int main() {
    int N, M, X;
    std::cin >> N >> M >> X;

    int C[N];
    int A[N][M];

    for (int i = 0; i < N; ++i) {
        std::cin >> C[i];
        for (int j = 0; j < M; ++j) {
            std::cin >> A[i][j];
        }
    }

    int min = INT32_MAX;
    for (int i = 1; i <= (1 << N); ++i) {
        int p[M] = {0};  
        int score = 0;
        for (int j = 0; j < N; ++j) {
            if ((i >> j) & 1) {
                score += C[j];
                for (int k = 0; k < M; ++k) {
                    p[k] += A[j][k];
                }
            }
        }

        bool ok = true;
        for (int j = 0; j < M; ++j) {
            if (p[j] < X) {
                ok = false;
                break;
            }
        }

        if (ok) {
            min = std::min(min, score);
        }
    }

    if (min == INT32_MAX) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << min << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<998244353> mint;

/*
*/

ll n,s,a[3010];
mint dp[3010],dp2[3010];

int main(void){
	cin>>n>>s;
	rep(i,n)cin>>a[i];	
	dp[0]=1;
	rep(i,n){
		reg(j,0,s)dp2[j] += dp[j]*2;
		reg(j,0,s-a[i])dp2[j+a[i]] += dp[j];
		reg(j,0,s){
			dp[j] = dp2[j];
			dp2[j] = 0;
		}
	}
	cout<<dp[s].get()<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,A,B;cin>>N>>A>>B;
  cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 764
a,b,c,d=gets.chomp.split(' ').map(&:to_i)
m=c.lcm(d)
s=(b-a+1)-(b/c.to_i)+((a-1)/c.to_i)-(b/d.to_i)+((a-1)/d.to_i)+(b/m.to_i)-((a-1)/m.to_i)
print("#{s}\n")

Measured memory_bytes: 1788
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n,m,hoshi,d;
char maze[32][16];

bool judge(){
  int point =m-1;
  for(int i  =0;i < d;i++){
    if(point==0){
      if(maze[i][point]=='1'){
	point +=1;
      }
    }
    else if(point ==n-1){
      if(maze[i][point-1]=='1'){
	point -=1;
      }
    }
    else{
      if(maze[i][point-1] =='1')
	point -=1;
      else if(maze[i][point]=='1')
	point +=1;
    }
  }
  if(point ==hoshi)
    return true;
  return false;
}

int main()
{
  while(cin>>n,n){
    scanf("%d%d%d",&m,&hoshi,&d);
    hoshi -=1;
    for(int i =0;i < d;i++){
      cin>>maze[i];
    }
    if(judge())
      cout <<"0"<<endl;
    else{
      int x,y;
      bool f = false;
      for(int i =0;i <d&&!f;i++){
	for(int j = 0;j <n-1&&!f;j++){
	  if(maze[i][j]=='0'&&(maze[i][j-1]!='1'&&maze[i][j+1]!='1')){
	    maze[i][j] ='1';
	    if(judge()){
	      f = true;
	      x = j;
	      y = i;
	      break;
	    }
	    maze[i][j]='0';
	  }
	}
      }
      if(f)
	cout <<y+1<<" "<<x+1<<endl;
      else
	cout <<"1"<<endl;
    }
  }
	    
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	string s,t;
	cin>>s>>t;
	int len = t.length();
	int f = INT_MAX;
	for(int i=0;i<s.length()-len+1;i++)
	{
		int l =0;
		for(int j=0;j<len;j++)
		{
			if(s[i+j] != t[j]) {
				l++;
			}
		}
		f = min(f,l);
		
	}
	cout<<f<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    if(b > c){
        ans = b+c;
    } else {
        ans += 2*b;
        c -= b;
        if(a >= c){
            ans += c;
        } else {
            ans += a+1;
            
        }
    }

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

Measured memory_bytes: 128
n = int(input())
s = input()
count = 0

fullcount= s.count('R')*s.count('G')*s.count('B')

for i in range(n-2):
    for j in range(i+1,n):
        k = 2*j-i
        if k > (n-1):
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            count += 1
ans = fullcount - count
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, n = 0, dup_a, dup_b;
    ll l, a, b, c;
    vl L;
    std::cin >> N;

    floop(N)
    {
        std::cin >> l;
        L.push_back(l);
    }

    if(N < 3)
    {
        print(n);
    }

    else
    {
        std::sort(L.begin(), L.end());

        for(int i = 0; i < N; ++i)
        {
            dup_a = 1;
            a = L[i];

            for(int j = i+1; j < N; ++j)
            {
                b = L[j];
                if(a == b)
                {
                    dup_a++;
                    continue;
                }

                for(int k = j+1; k < N; ++k)
                {
                    c = L[k];
                    if(b == c)
                    {
                        dup_b++;
                        continue;
                    }

                    if(a+b>c && b+c>a && a+c>b)
                        n += dup_a*dup_b;
                }

                j += (dup_b - 1);
                dup_b = 1;
            }

            i += (dup_a - 1);
            dup_a = 1;
        }

        print(n);
    }

    return 0;
}

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

int main(){
  
  int N,M;
  long long K;
  cin >> N >> M >> K;
  vector<long long> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  vector<long long> B(M);
  for(int i=0;i<M;i++) cin >> B[i];
  
  vector<long long> ruiseki_A(N+1);
  ruiseki_A[0] = 0;
  for(int i=1;i<=N;i++)	ruiseki_A[i] = ruiseki_A[i-1] + A[i-1];
  
  vector<long long> ruiseki_B(M+1);
  ruiseki_B[0] = 0;
  for(int i=1;i<=M;i++) ruiseki_B[i] = ruiseki_B[i-1] + B[i-1];
  
  int result = 0;
  for(int i=0;i<=N;i++){
    int t;
    long long K2 = K - ruiseki_A[i];
    if(K2 < 0) break;
    else{
      auto it = upper_bound(ruiseki_B.begin(),ruiseki_B.end(),K2);
      if(it != ruiseki_B.end())
        t = i + distance(ruiseki_B.begin(), it) - 1;
      else
        t = i + M;
      if(result < t) result = t;
    }
  }
  
  cout << result;
  return 0;
}

Measured memory_bytes: 9584
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    defer w.Flush()

    a := nextInt()
    b := nextInt()
    c := nextInt()
    k := nextInt()

    t := 0
    if k < a {
        t = k
        k = 0
    } else {
        t = a
        k -= a
    }

    if k < b {
        k = 0
    } else {
        k -= b
    }

    if k < c {
        t -= k
    } else {
        t -= c
    }
    fmt.Fprintln(w, t)
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(void){
	int n;
	string s;
	cin >> n >> s;
	int a[26]={0};
	for(int i = 0; i < n; ++i){
		a[s[i]-'a']++;
	}
	long long ans = 1;
	for(int i = 0; i < 26; ++i){
		ans *= (a[i]+1);
		ans %= MOD;
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(int argc, char *argv[])
{
  const int BIG = 1000000;
  const int CMAX = 50000;
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ps;
    for(int i = 0; i < n; i++) {
      int p; cin >> p; ps.push_back(p);
    }
    // shop : at most 100
    // change : at most 49900...
    // value : (-(# 500 yen so far), minimum payment)
    //
    //   NOTE: the first element is negated.
    //
    // for the same amount of change, pairs (k1, p1) and (k2, p2),
    //   if k1 < k2 then (k2, p2) has no chance to be the best solution
    //     because # of coins to be got depends only on the current change
    // so, we can use lexicographical order of pairs here.
    vector<pair<int,int>> dp(CMAX+1, pair<int,int>(BIG, BIG));
    vector<pair<int,int>> dpnew(CMAX+1, pair<int,int>(BIG, BIG));
    dpnew[0] = make_pair(0, 0);
    int cmax = 0;
    for(int i = 0; i < n; i++) {
      // not buying
      for(int j = 0; j <= cmax; j++) {
        dp[j] = dpnew[j];
      }
      // buying
      for(int j = 0; j <= cmax; j++) {
        if(dp[j].first > 0) continue;
        const int p = ps[i] % 1000;
        if(p != 0 && p <= 500) { // got 500!
          const int jj = min(j + 500 - p, CMAX);
          cmax = min(max(cmax, jj), CMAX);
          pair<int,int> dd(dp[j].first - 1, dp[j].second + ps[i]);
          if(dd < dpnew[jj]) {
            dpnew[jj] = dd;
          }
        } else {
          // get 500 if possible!
          const int q = (p == 0 ? 1000 : p) - 500;
          if(j >= q) {
            const int jj = j - q;
            pair<int,int> dd(dp[j].first - 1, dp[j].second + ps[i]);
            if(dd < dpnew[jj]) {
              dpnew[jj] = dd;
            }
          } else { // get change
            const int jj = (j + 1000 - p) % 1000;
            cmax = min(max(cmax, jj), CMAX);
            if( jj <= CMAX) {
              pair<int,int> dd(dp[j].first, dp[j].second + ps[i]);
              if(dd < dpnew[jj]) {
                dpnew[jj] = dd;
              }
            }
          }
        }
      }
    }
    pair<int,int> dd(BIG, BIG);
    for(int j = 0; j <= cmax; j++) {
      if(dpnew[j] < dd) {
        dd = dpnew[j];
      }
    }
    cout << -dd.first << " " << dd.second << endl;
  }
  return 0;
}



Measured memory_bytes: 3684
#include<string.h>
#include<math.h>
int main()
{
    int i,j=0;
    char c[100000],d[100000];
    gets(c);
    for(i=0;i<100000;i+=2)
        d[j++]=c[i];
        d[j]='\0';
    puts(d);

}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int d,n, ans;
    cin >> d >> n;
    if(n == 100) n++;
    ans = pow(100, d)*n;
   
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

  	ll a,b,k;
  	cin >> a >> b >> k;
	ll xa =0;
  	ll xb =0;
  	if(a!=0){
    	if(a>k){  	
          cout << a-k << " " << b << endl;
  		  return 0;
        }
      	else{
        	k-=a;
          	if(b!=0){
            	if(b>k){
                	cout << xa <<" " << b-k << endl;
                	return 0;
                }
            cout << xa  <<" " << xb << endl;
            return 0;
            }          
        }
    }
  	if(b!=0){
      if(b>k){
      	cout << xa  <<" " << b-k << endl;
        return 0;
      }
    }
  	
  	cout << xa << " " << xb << endl;
  	return 0;
}

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

int main() {
	int i;
	vector<int> v(10000);


	for (i = 0; i < 10000;i++) {
		cin >> v[i];
		if (v[i] == 0)
			break;
	}
	

	for (i = 0; i < 10000; i++) {
		if (v[i] == 0) {
			break;
		}
		else {
			cout << "Case " << i + 1 << ": " << v[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int h, w, k;
    cin >> h >> w >> k;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    VVI r(h + 2, VI(w + 2, 0));
    for (i = 1; i <= h; i++) {
        for (j = 1; j <= w; j++) {
            char c;
            cin >> c;
            if (c == '.') r[i][j] = 1;
        }
    }
    VVI d(h + 2, VI(w + 2, INF));
    queue<P> que;
    d[x1][y1] = 0;
    que.push(P(x1, y1));
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        int nx = p.fi;
        int ny = p.se;
        int nd = d[nx][ny];
        for (j = 0; j < 4; j++) {
            for (int l = 1; l <= k; l++) {
                int x = nx + l * dx[j];
                int y = ny + l * dy[j];
                if (r[x][y] == 0) break;
                if (d[x][y] <= nd)
                    break;
                else if (nd + 1 < d[x][y]) {
                    que.push(P(x, y));
                    d[x][y] = nd + 1;
                }
            }
        }
    }
    if (d[x2][y2] == INF)
        cout << -1 << endl;
    else
        cout << d[x2][y2] << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int N; cin >> N;
  for (int i=1; i<=N; i++) {
    for (int j=i+1; j<=N; j++) {
      int ti = i, tj = j, count = 0;
      while ((ti&(1<<count))==(tj&(1<<count))) count++;
      cout << count+1 << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define PI 3.141592653

bool cross(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
    double a,b,c,d;
    
    a=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
    b=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
    c=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
    d=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
    
    if((c<0)^(d<0))
        return true;
    else
        return false;
}

int main(){
    double x[3],y[3],x_p,y_p;
    
    while(EOF!=scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x_p,&y_p)){

        bool f = true;
        
        for(int i=0;i<3;i++){
    
            if(cross(x[i], y[i], x[(i+1)%3], y[(i+1)%3],x[(i+2)%3], y[(i+2)%3], x_p, y_p)){
                f=false;
            }
            
        }
        
        if(f){
            puts("YES");
        }else{
            puts("NO");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<int,int>> fri(m),blo(k);
    UnionFind tree(n);

    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        fri[i]=make_pair(a,b);
        tree.merge(a,b);
    }
    for(int i=0; i<k; i++){
        int c,d;
        cin>>c>>d;
        c--;d--;
        blo[i]=make_pair(c,d);
    }
    map<int,int> fri_mp,blo_mp;
    for(int i=0; i<m; i++){
        fri_mp[fri[i].first]++;
        fri_mp[fri[i].second]++;
    }
    for(int i=0; i<k; i++){
        blo_mp[blo[i].first]++;
        blo_mp[blo[i].second]++;
    }
    
    //広義の友達候補の中で相互ブロックである数を知りたい
    //友達マップに含まれる相互ブロックの組み合わせをあらかじめカウントしておく
    map<int,int> friblo_mp;
    for(int i=0; i<k; i++){
        if(tree.issame(blo[i].first,blo[i].second)){
            friblo_mp[blo[i].first]++;
            friblo_mp[blo[i].second]++;
        }
    }
    for(int i=0; i<n; i++){
        //広義の友達候補(現友達を含める)はm人
        //すでに友達なのはfri_mp[i]]なので引く
        //ブロックマップと友達マップに含まれる組み合わせの数を引く
        int cnt=tree.size(i)-1;
        cnt-=fri_mp[i];
        cnt-=friblo_mp[i];
        cout<<cnt<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 17408
#include<cstdio>
int n,a[200010];
inline int read(){ 
    register int ret=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();
    return ret;
}
int main()
{
    n=read();
    for(register int i=1;i<=n;++i)a[i]=read();
    for(register int i=n;i>0;i-=2)printf("%d ",a[i]);//first 
    for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);//second 
    return 0;
}

Measured memory_bytes: 2816