akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  if(sz(s)<4){
    print("No");
    return 0;
  }
  s.erase(4);
  if(s=="YAKI"){
    print("Yes");
  }
  else{
    print("No");
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main() {
    int lower=0, C=0;
 string s;
 cin>>s;
for(int i=2;i<s.length()-1;i++){
    if( s[i]=='C'){
        C++;
    }
}
for(int j=0;j<s.length();j++){
    if(islower(s[j])){
      lower ++  ;
    }
}
if(s[0]=='A' && C==1 && lower==s.length()-2){
    cout<<"AC";
}else{
    cout<<"WA";
}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    string ans;
    if(e-a<=k){ans="Yay!";}
    else{ans=":(";}

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
  int N, T;
  cin >> N >> T;
  vector<int> c(N), t(N);
  rep(i,N) cin >> c[i] >> t[i];
  
  int tempmin = INT_MAX;
  int flag_exist = 0;
  rep(i,N){
  	if(t[i] <= T){
    	tempmin = min(c[i], tempmin);
      	flag_exist = 1;
    }  
  }
  if(flag_exist == 0){ puts("TLE");}
  else { cout << tempmin << endl;}
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<cctype>
using namespace std;


string A(string s){
	return string(s.rbegin(),s.rend());
}
string C(string s){
	return s[s.size()-1]+string(s.begin(),s.end()-1);
}
string J(string s){
	return string(s.begin()+1,s.end())+s[0];
}
string E(string s){
	for(int i=0;i<s.size()/2;i++)swap(s[i],s[i+(s.size()+1)/2]);
	return s;
}
string M(string s){
	for(int i=0;i<s.size();i++){
		if(!isdigit(s[i]))continue;
		s[i]='0'+(s[i]-'0'-1+10)%10;
	}
	return s;
}
string P(string s){
	for(int i=0;i<s.size();i++){
		if(!isdigit(s[i]))continue;
		s[i]='0'+(s[i]-'0'+1)%10;
	}
	return s;
}
int main(){
	map<char,string (*)(string) > ifunc;
	ifunc['A']=A;ifunc['E']=E;
	ifunc['J']=C;ifunc['C']=J;
	ifunc['M']=P;ifunc['P']=M;
	int n;
	cin>>n;
	while(n--){
		string ord,mes;
		cin>>ord>>mes;
		for(int i=ord.size()-1;i>=0;i--)
			mes=(*ifunc[ord[i]])(mes);
		cout<<mes<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

ll snuke_havenum[1000];

int main(void){
    ll n;
    ll k;
    cin >> n;
    cin >> k;

    REP(i,k){
        ll tmpd;
        cin >> tmpd;
        REP(j,tmpd){
            ll tmpa;
            cin >> tmpa;
            snuke_havenum[tmpa-1]++;
        }
    }

    ll ans =0;

    REP(i,n){
        if(snuke_havenum[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;

    return 0;
}



Measured memory_bytes: 3636
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{int X,A,B;
cin>>X>>A>>B;
X=X-A;
int a=X/B;
X=X-B*a;
cout<<X;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

    int A, B, C;
    cin >> A >> B >> C;

    int ans = B + C - A;
    cout << max(ans, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N = ii()
A = smii()

ans = 0
for i in range(N, N * 3, 2):
    ans += A[i]

print(ans)


Measured memory_bytes: 37084
#include <stdio.h>
#include <stdlib.h>


typedef struct{
	int start;
	int end;
}DATA_T;


int Center_pos(DATA_T *box, int l, int r)
{
	int mid;

	mid = (l + r) / 2;

	if(box[l].end < box[mid].end && box[mid].end < box[r].end
	|| box[r].end < box[mid].end && box[mid].end < box[l].end)
		return mid;
	else if(box[mid].end < box[l].end && box[l].end < box[r].end
	|| box[r].end < box[l].end && box[l].end < box[mid].end)
		return l;
	else
		return r;

}


int Partition(DATA_T *box, int l, int r)
{
	DATA_T tmp;
	int i = l - 1;
	int j = r;
	int x, soeji;

	soeji = Center_pos(box, l, r);
	x = box[soeji].end;
	tmp = box[r];
	box[r] = box[soeji];
	box[soeji] = tmp;

	while(1){
		while(box[++i].end < x);

		while(i < --j && x < box[j].end);

		if(j <= i)
			break;

		tmp = box[i];
		box[i] = box[j];
		box[j] = tmp;
	}

	tmp = box[i];
	box[i] = box[r];
	box[r] = tmp;

	return i;
}


void Quick_sort(DATA_T *box, int l, int r)
{
	int pivot;

	if(r <= l)
		return;

	pivot = Partition(box, l, r);

	Quick_sort(box, l, pivot - 1);

	Quick_sort(box, pivot + 1, r);
}


int main()
{
	int n;
	DATA_T *activity;
	int *array;
	int count, etime;
	int i, j;

	scanf("%d", &n);

	activity = (DATA_T *)malloc(sizeof(DATA_T) * n);

	for(i = 0; i < n; i++)
		scanf("%d %d", &activity[i].start, &activity[i].end);


	Quick_sort(activity, 0, n - 1);

/*	printf("<sorted>\n");
	for(i = 0; i < n; i++)
		printf("%d %d\n", activity[i].start, activity[i].end);
*/
	etime = count = 0;
	for(i = 0; i < n; i++){
		if(etime < activity[i].start){
			count++;
			etime = activity[i].end;
		}
	}


	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  string s_a, s_b;
  for (int i = 0; i < b; ++i)
    s_a += a + '0';
  for (int i = 0; i < a; ++i)
    s_b += b + '0';
  cout << min(s_a, s_b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(){
  int h,w,cnt=0;
  vector<pair<int,int>> list;
  cin >> h >> w;
  string a[h];
  for(int i=0;i<h;i++){
    cin >> a[i];
    for(int j=0;j<w;j++){
      if(a[i][j]=='#')cnt++;
    }
  }
  if(cnt==w+h-1)cout << "Possible\n";
  else cout <<"Impossible\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll x;
  cin >> x;
  printf("%.10f\n",acos(0) * x * 4);
}

Measured memory_bytes: 3760
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#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;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long x,y,ans=0;
  cin>>x>>y;
  if(x%y==0){
    cout<<-1<<'\n';
    return(0);
  }
  else{
    ans+=x;
    while(true){
      ans+=x;
      if(ans%y!=0){
	break;
      }
    }
  }
  cout<<ans<<'\n';
  return(0);
}


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

int main(){
    int N=0;
    cin >> N;
    int Max = 100000;
    unsigned long long int A[Max] = {}, num; 
    int S = 0;


    for(int i=0; i<N; i++){
        cin >> A[i];

        if(A[i] == 0){
            S = 1;
            cout << 0;
            break;
        }
    }

    num = A[0];
    for(int i=1; i<N && S==0; i++){

       if(log10(num) + log10(A[i]) >18){
            S = 2;
            cout << -1;
            break;
        }

         num *= A[i];

            if(num > 1000000000000000000){
                cout << -1;
                S = 2;
                break;
        }
        

        
        
    }

    if(S == 0){
    cout << num;
    }

 }



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N;
    cin >> S;
    string sub = S.substr(0,N/2);
    string sub2 = S.substr(N/2);
    // cout << sub << endl;
    // cout << sub2 << endl;
    if (sub == sub2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

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

    int p[n] = {0};

    rep(i,n - 1) {
        int k;
        cin >> k;
        p[k - 1] = p[k - 1] + 1;
    }

    rep(i,n) {
        cout << p[i] << endl;
    }

    return 0;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  int ans=0;
  rep(i,N){
    int h;
    cin>>h;
    if(h>=K) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&f);
	if(a<=40){
		a=40;
	}
	if(b<=40){
		b=40;
	}
	if(c<=40){
		c=40;
	}
	if(d<=40){
		d=40;
	}
	if(f<=40){
		f=40;
	}
	x=(a+b+c+d+f)/5;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2696
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

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

    int count[101] = {0};
    int n;
    string s;
    cin >> n >> s;
    for(int i=0;i<26;i++)
    {
        int first = 0;
        int last = 0;
        for(size_t j=0;j<s.length();++j)
        {
            if(s[j] == ('a' + i))
            {
                first = j;
                break;
            }
        }

        for(size_t j=s.length() - 1;j>0;--j)
        {
            if(s[j] == ('a' + i))
            {
                last = j;
                break;
            }
        }
        count[first] += 1;
        count[last] -= 1;
    }

    int ans = 0;
    int tmp = 0;
    for(int i=0;i<101;++i)
    {
        tmp += count[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> adj(100001);
int n,m;

int bfs(int start, int target){
	deque<pair<int,int>> q;
	vector<vector<int>> vu(3,vector<int>(n+1,INT_MAX));
	q.emplace_back(0,start);
	while (!q.empty()){
		auto f=q.front();
		q.pop_front();
		int node=f.second,prev_weight=f.first;
		for (int i:adj[node]){
			int weight=1,new_node=i;
			if (vu[(prev_weight+weight)%3][new_node] > weight+prev_weight){
				vu[(prev_weight+weight)%3][new_node] = weight+prev_weight;
				q.emplace_back(weight+prev_weight,new_node);
			}
		}
	}
	return (vu[0][target] == INT_MAX ? -1 : vu[0][target]/3);
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i=0; i<m; ++i){
		int a,b;
		cin >> a >> b;
		adj[a-1].emplace_back(b-1);
	}
	int s,t;
	cin >> s >> t;
	cout << bfs(s-1,t-1) << '\n';
	return 0;
}

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

const int MN = 200010;

int fa[MN], sz[MN];
void init() {
    for(int i = 0; i < MN; i++) fa[i] = i, sz[i] = 1;
}
int find(int u) {
    if(fa[u] == u) return u;
    else return fa[u] = find(fa[u]);
}
void mrg(int u, int v) {
    u = find(u);
    v = find(v);
    if(u == v) return;
    fa[v] = u;
    sz[u] += sz[v];
}

int N;
vector<int> adj[MN];
stack<int> stk;
int par[MN], dp[MN];

struct Query {
    int u, x, s;
    bool operator <(const Query &i) const {
        return x < i.x;
    }
};
vector<Query> query;

void dfs0(int u, int p) {
    if(p != -1) {
        if(stk.empty() || stk.top() < p) {
            if(!stk.empty()) {
                query.push_back({ u, p, 1 });
                if(u < stk.top()) query.push_back({ u, stk.top(), -1 });
            }
            else dp[u]++;
            stk.push(p);
        }
        else {
            if(u > stk.top()) query.push_back({ u, stk.top(), 1 });
        }
    }

    par[u] = p;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dfs0(v, u);
    }

    if(!stk.empty() && stk.top() == p) stk.pop();
}

void dfs1(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dp[v] += dp[u];
        dfs1(v, u);
    }
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs0(0, -1);

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

    init();
    int pos = 0;
    for(int n = 0; n < N; n++) {
        while(pos < query.size() && query[pos].x == n) {
            int u = query[pos].u;
            int s = query[pos].s;

            if(u < n) {
                dp[u] += s * sz[u];
            }
            else {
                for(int i = 0; i < adj[u].size(); i++) {
                    int v = adj[u][i];
                    if(v == par[u]) continue;
                    if(v < n) {
                        dp[u] += s * sz[v];
                    }
                }
                dp[u] += s;
            }
            pos++;
        }

        for(int i = 0; i < adj[n].size(); i++) {
            int v = adj[n][i];
            if(v == par[n]) continue;
            if(v < n) {
                mrg(n, v);
            }
        }
        if(n && par[n] < n) {
            mrg(par[n], n);
        }
    }

    dp[0] = 1;
    dfs1(0, -1);

    for(int i = 1; i < N; i++) {
        printf("%d ", dp[i] - 1);
    }
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

ll num( ll a, ll b, ll i ) {
    ll ans = (int)(a*i/b)-a*(int)(i/b);
    // cout << "a " << ans << endl;
    return ans;
}

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = 0;
    if ( n < b ) {
        std::vector<ll> v;
        /*
        rep2(i, n) {
            v.push_back( num(a, b, i) );
        }
        ans = *max_element(ALL(v));*/
        ans = num(a, b, n);
    } else {
        ll nn = b;
        ll i = 2;
        // std::vector<ll> v;
        priority_queue<ll> q;
        while (nn <= n) {
            // v.push_back( num(a, b, nn-1) );
            // v.push_back( num(a, b, nn) );
            ll k = num(a, b, nn-1);
            if ( !q.empty() && k < q.top() ) {
                break;
            }
            q.push(k);
            q.push( num(a, b, nn) );
            nn = b*i;
            i++;
        }
        ans = q.top();
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n;
cin>>n;
if(n!=0){
cout<<n/3<<endl;
}
}









Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()[::-1]

sm = 0

cnts = [0] * 2019
cnts[0] = 1

d = 1

for c in s:
  sm += int(c) * d
  sm %= 2019
  d *= 10
  d %= 2019
  cnts[sm] += 1

ans = 0

for cnt in cnts:
  ans += cnt * (cnt - 1) // 2

print(ans)


Measured memory_bytes: 9216
int main(){
        int n, k, d, i, syu;
        scanf("%d %d", &n, &k);
        int sunu[n], kasi[k];
        for(i=0; i<n; i++){
                sunu[i]=0;
        }
        for(i=0; i<k; i++){
                scanf("%d",&d);
                for(int j=0; j<d; j++){
                        scanf("%d", &syu);
                        sunu[syu-1]=1;
                }
        }
        int count=0;
        for(i=0; i<n; i++){
                if(sunu[i]==0){
                        count++;
                }
        }
        printf("%d", count);
        return 0;
}


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

int main(){
	int A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	int x,y,z;
	int ans=0;
	int tmp;
	for(int z=0;z<=max(X,Y);++z){
		x=max(X-z,0);
		y=max(Y-z,0);
		tmp=A*x+B*y+C*z*2;
		if((ans==0) || (ans>tmp)) ans=tmp;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARatingGoal {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int r, g;
	    in >> r >> g;
	    out << 2*g - r << endl;
	}
};


int main() {
	ARatingGoal solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

int h[100010];
int dp[100010];
int n;

int solveR(int i){
	if(i == n)
		return 0;
		
	if( (i+2) <= n)
		return min(abs(h[i]-h[i+1]) + solveR(i+1), abs(h[i]-h[i+2]) + solveR(i+2));
	else
		return abs(h[i]-h[i+1]) + solveR(i+1);
}

int solveI(){
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	
	for(int i=3; i<=n; i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	
	return dp[n];
}

int main() {
	
	scanf("%d", &n);
	
	for(int i=1; i<=n; i++)
		scanf("%d", &h[i]);

//	memset(dp, -1, sizeof(dp));
//	printf("%d\n", solveR(1));
	printf("%d\n", solveI());
		
	return 0;	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
  int n, ans = 0;
  cin >> n;
  int a[n + 3];
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  for(int i = 2; i <= n; i++){	
    if(a[i] < a[i - 1]){
      ans += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }  
  cout << ans;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 998244353; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(ll &a, ll b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n)return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
}
const int MAXN = 1e6 + 5;
signed main()
{
	#ifndef ONLINE_JUDGE
		file("pro");
	#endif
	string s; cin >> s;
	if(s.back() == 's') cout <<s + "es" <<endl;
	else cout <<s + "s" <<endl;
    return FastIO::Fflush(), 0;
}
/*

*/



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Map<String, Long> data = new LinkedHashMap<>();
        while (true){
            final int times = Integer.parseInt(br.readLine());
            if (times == 0) { break; }
            
            data.clear();
            for (int i=1; i <= times; i++) {
                String[] e = br.readLine().split(" ");
                data.merge(e[0], Long.parseLong(e[1]) * Long.parseLong(e[2]), Long::sum);
            }
            
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0) { System.out.println("NA"); }
        }
    }
}

Measured memory_bytes: 31844
#入力
n=int(input())
a=list(map(int,input().split()))
#dpテーブル dp[i-1]はi番目の箱に入っているボールの数
dp=[0 for i in range(n)]
#初期条件
dp[n-1]=a[n-1]

for i in range(n,0,-1):
  num=0
  for j in range(i*2,n+1,i):
    num=num+dp[j-1]
  if num%2==a[i-1]:
    dp[i-1]=0
  else:
    dp[i-1]=1

print(dp.count(1))
for i in range(n):
  if dp[i]==1:
    print(i+1,end=" ")
    

    

Measured memory_bytes: 12508
import java.util.*;
 
public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < 2; i++) {
			if(a>b) {
				ans+=a;
				a--;
			}
			else {
				ans+=b;
				b--;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
//#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int r;
  cin >> r;
  cout << r*r;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node {
    int x, y;
} h[105], l[105];
int link[105];
bool used[105];
int n;
bool dfs(int u)
{
    for(int v = 0; v < n; v++)
        if(!used[v])
        if(h[u].x<l[v].x&&h[u].y<l[v].y)
        {
            used[v] = true;
            if(link[v] == -1 || dfs(link[v]))
            {
                link[v] = u;
                return true;
            }
        }
    return false;
}
int hungry() {
    int res = 0;
    for(int u = 0; u < n; u++) {
        memset(used, false, sizeof(used));
        if(dfs(u))
        res++;
    }
    return res;
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &h[i].x, &h[i].y);
    }
    for(int i = 0; i < n; i++)
        scanf("%d%d", &l[i].x, &l[i].y);
    memset(link, -1, sizeof(link));
    printf("%d\n", hungry());
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

ll p[3];  //kazu
ll g[3];  //p[i]no kazu

int main(){
    ll n;
    ll c=0;   //cor
    int t=1;   //tigau num
    int l;     //tigau sum
    cin >> n;
    ll a[100007];

    rep(i,n){
        cin >> a[i];
    }

    p[0]=a[0];

    rep(i,n-1){      //同じ個数判定
        l=0;
        rep(j,t){
            if(a[i+1]!=p[j]){
                l++;
            }
            else{
                g[j]++;
            }
        }
        if(l==t){
            p[t]=a[i+1];
            t++;
        }
        if(t==4){
            c++;
            break;
        }
    }

    if(t==1){
        if(a[0]!=0){
            c++;
        }
    }
    if(t==2){
        if(p[0]==0){
            if(p[1]!= (p[0] xor p[1]) || (g[0]+1)*2!=g[1]+1){
                c++;
            }
        }
        else if(p[1]==0){
            if(p[0]!= (p[0] xor p[1]) || (g[1]+1)*2!=g[0]+1){
                c++;
            }
        }
        else{
            c++;
        }
    }
    if(t==3){
        if(p[0]!= (p[1] xor p[2]) || g[0]!=g[1] || g[1]!=g[2] || g[2]!=g[0]){
            c++;
        }
    }
    if(c==0){
        cout << "Yes" << endl;
    }
    else{
        cout <<  "No" << endl;
    }
}


Measured memory_bytes: 1024
n = int(input())
x = [list(map(str,input().split())) for i in range(n)]
for i in range(n):
    x[i][1]=int(x[i][1])
a = [i for i in range(1,n+1)]
a = sorted(a,key=lambda y:(x[y-1][0],-x[y-1][1]))
for i in a:
    print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli N=0,A;
  string S;
  cin >> S;
  rep(i,3){
  if(S[i]=='o')N++;
  }
  Out(700+100*N);
}

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

int main(){
  int N;
  cin>>N;
  vector<int> a;
  for(int i=0;i<N;i++){
    int val;
    cin>>val;
    a.push_back(val);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<a.size();i++){
    if(i%2==0){
      ans+=a[i];
    }else{
      ans-=a[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int mn = std::max(A, C);
  int mx = std::min(B, D);
  cout << std::max(mx - mn, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  int d=N%10;
  string ans="hon";
  if(d==0||d==1||d==6||d==8)ans="pon";
  if(d==3)ans="bon";
  cout<<ans<<endl;
}

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

void quicksort(int* A,int left,int right){
  if(right - left <= 1) return;

  int pivot_index = (left + right)/ 2;
  int pivot = A[pivot_index];
  swap(A[pivot_index],A[right - 1]);

  int i = left;
  for(int j = left;j < right - 1;j++){
    if(A[j] < pivot){
      swap(A[i],A[j]);
      i++;
    }
  }
  swap(A[i],A[right - 1]);
  quicksort(A,left,i);
  quicksort(A,i+1,right);

}

/* i 1-Nで i==A[j]　ならその分加える*/

int main(){
  int i,j;
  long int N,K,Q,s;
  int A[100010] = {};

  cin>>N>>K>>Q;

  for(i = 0; i<Q ;i++){
    cin >> A[i];
  }

  quicksort(A,0,Q);

  for(i=0;A[i] == 0;i++){}
  j = i;

  for(i = 1; i<N+1 ; i++){
    if(A[j] == i){
      s = 0;

      while(1){
        s++;
        if(A[j] == A[j+1]){
          j++;
        }else{
          j++;
          break;
        }
      }

      if(K + s - Q <= 0){
        cout<<"No"<<endl;
      }else{
        cout<<"Yes"<<endl;
      }

    }else{

      if(K - Q <= 0){
        cout<<"No"<<endl;
      }else{
        cout<<"Yes"<<endl;
      }

    }
  }

}


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

int main(){
  int s; cin>>s;
  int a,b;
  a=s%100;
  b=s/100;

  int x=0,y=0;

  if(a==0 || 12<a)x=1;
  else if(a!=0)x=2;
  if(b==0 || 12<b)y=1;
  else if(b!=0)y=2;

  if(x==1 && y==1)cout<<"NA"<<endl;
  else if(x==2 && y==1)cout<<"YYMM"<<endl;
  else if(x==1 && y==2)cout<<"MMYY"<<endl;
  else cout<<"AMBIGUOUS"<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(B/A,C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	char c1,c2,c3;
	cin>>c1>>c2>>c3;
	int ans;
	if(c1==c2&&c2==c3&&c3=='R')ans=3;
	else if(c1=='R'&&c2=='R')ans=2;
	else if(c2=='R'&&c3=='R')ans=2;
	else if(c1=='R'||c2=='R'||c3=='R')ans=1;
	else ans=0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<ll>A(N);
	ll sum = 0, a = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum += A[i];
		if (i != N - 1 && i % 2 == 0)a += A[i];
	}
	vector<ll>ans(N);
	ans[N - 1] = sum - 2 * a;
	rREP(i, 0, N-1) {
		ans[i] = 2 * A[i] - ans[i + 1];
	}
	rep(i, 0, N) {
		cout << ans[i];
		if (i != N - 1)cout << " ";
		else cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(0);
	
	ll a, b;
	cin >> a >> b;
	a -= 2;
	b -= 2;
	cout << abs(a*b);
	
	return 0;
}

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define vvll vector<vector<ll>>
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
ll mod=1000000007;  double pi=3.1415926535;

void solve()
{
    ll a,b;     cin>>a>>b;
    cout<<a*b<<nl;
}

int main() {
	fast_io;
	
	    solve();
	return 0;
}


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

int main(){
    int n;cin>>n;double ans=0;
    for(int i=0;i<n;i++){
        double x;string y;cin>>x>>y;
        if(y=="JPY") ans+=x;
        else ans+=x*380000.0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.11 00:27:02
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int n;
vector< vector< int > > g;
vector< bool > is_end;
vector<string> s;
int dfs(int m, ll &f, int t = 0, int node = 0) {
    if (t == s[m].size()) {
        f = 0;
        return 0;
    }
    else if (t == s[m].size() - 1) {
        dfs(m,f,t+1,g[node][s[m][t]-'a']);
        f |= 1<<(s[m][t]-'a');
        return 0;
    }
    else {
        int ret = 0;
        ret += dfs(m,f,t+1,g[node][s[m][t]-'a']);
        f |= 1<<(s[m][t]-'a');
        for(int i = 0;i < 26;i++) {
            if (g[node][i] == 0) continue;
            if (is_end[g[node][i]] && (f & (1 << i))) {
                ret++;
            }
        }
        return ret;
    }
}
int main() {
    cin >> n;
    s.resize(n);
    g.resize(1, vector< int >(26, 0)); 
    is_end.resize(1,false); 
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        int node = 0;
        int t = 0;
        while (t < s[i].size()) {
            
            if (g[node][s[i][t] - 'a'] == 0) {
                g[node][s[i][t] - 'a'] = (int)g.size();
                g.push_back(vector< int >(26, 0));
                is_end.push_back(false);
            }
            node = g[node][s[i][t] - 'a'];
            t++;
        }
        is_end[node] = true;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll f;
        ans += dfs(i,f);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 181180
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, m;
string fi[110];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> fi[i];
        bool loop = false;
        bool seen[110][110] = {0};
        int x = 0, y = 0;
        while (fi[x][y] != '.') {
            if (fi[x][y] == '>') ++y;
            if (fi[x][y] == 'v') ++x;
            if (fi[x][y] == '<') --y;
            if (fi[x][y] == '^') --x;
            if (seen[x][y]) { loop = true; break; }
            seen[x][y] = true;
        }
        if (!loop) cout << y << " " << x << endl;
        else puts("LOOP");
    }
    return 0;
}


Measured memory_bytes: 1244
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
typedef tuple<ll,int,int> T;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int cal(int x,int y){
    if(x<=y)return y-x;
    else return 2+x-y;
}
int main(){
int x,y;
cin>>x>>y;
cout<<min({cal(x,y),cal(-x,y)+1,cal(-x,-y)+2,cal(x,-y)+1})<<endl;
}


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

int main(void){
    int n, l, sum = 0, cnt=0, zero = -1;
    cin >> n >> l;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
        a[i] = l + i +1 - 1;
        sum += a[i];
        if(a[i] < 0) ++cnt;
        else if(zero==-1){
            zero = i;
        }
    }
    if(cnt==n){
        zero = n-1;
    }else if(cnt==0){
        zero = 0;
    }else{
        if(abs(a[zero])<abs(a[zero-1])){
            zero = zero;
        }else{
            zero = zero-1;
        }
    }
    cout << sum - a[zero] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

ll func(ll n){
    return n * (n-1) / 2;
}

int main(){
    int N;
    cin >> N;
    map<string, ll> mp;
    rep(i, N){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll cnt = 0;
    for(auto p : mp){
        if(p.second >=2){
            cnt += func(p.second);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 11312
#include "bits/stdc++.h"
using namespace std;
int main() {
  int count[50 + 1]{0};
  int N, M; cin >> N >> M;
  int a, b;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    ++count[a];
    ++count[b];
  }
  for (int i = 1; i <= N; ++i) cout << count[i] << "\n";
  return 0;
}


Measured memory_bytes: 256