akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int func(int b[], int n)
{
	int s = 0;
	for(int i=0;i<n-1;i++)
	{
		s = s+abs(b[i]-b[i+1]);
	}
	return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	double t,a;
	cin>>t>>a;
	double avg_t = 1231231233;
	int ans = -1;
	for(int i=0;i<n;i++)
	{
		double temp;
		cin>>temp;
		double temper = t - (temp*0.006);
		// cout<<temp<<" "<<temper<<" "<<avg_t<<endl;
		if( max(temper,a)-min(temper,a) < avg_t )
		{
			ans = i+1;
			avg_t = max(temper,a)-min(temper,a);
		}
	}
	cout<<ans;
	return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll n, m, i, j, k, l;
    n=3;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    swap(a[0],a[1]);
    swap(a[0],a[2]);
    for(i=0; i<n; i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}


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

int main() {
    int n, k;
    while (cin >> n >> k) {
        if (n == 0 && k == 0) break;
        int a[n]; rep(i, n) cin >> a[i];
        int sum[n + 1]; sum[0] = 0;
        rep(i, n) sum[i + 1] = sum[i] + a[i];
        int ans = -inf;
        rep(i, n) {
            int left = i;
            int right = min(i + k, n);
            if (i + k >= n) break;
            chmax(ans, sum[right] - sum[left]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define vii vector<ii>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

	ll arr[N], brr[N];
int main()
{
	assem99;

	int n; cin >> n;
	f(i, 0, n + 1) cin >> arr[i];
	f(i, 0, n ) cin >> brr[i];
	ll ans = 0;
	f(i, 0, n)
	{
		int tmp = min(arr[i], brr[i]);
		ans += tmp;
		brr[i] -= tmp;
		arr[i] -= tmp;

		tmp = min(brr[i], arr[i + 1]);
		ans += tmp;
		arr[i + 1] -= tmp;
		brr[i] -= tmp;
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int main()
{
	int n; cin >> n;
	vector<vector<int>> F(n, vector<int>(10));
	vector<vector<ll>> P(n, vector<ll>(11));
	rep(i, 0, n - 1)rep(j, 0, 9)cin >> F[i][j];
	rep(i, 0, n - 1)rep(j, 0, 10)cin >> P[i][j];
	ll ans =  -1LL<<60;
	for (int i = 1; i < pow(2, 10); ++i)
	{
		vector<int> count(n, 0);
		for (int j = 0; j < 10; ++j)
		{
			if (i >> j & 1 == 1)
			{
				for (int k = 0; k < n; ++k)
				{
					if(F[k][j])++count[k];
				}
			}
		}
		ll temp = 0;
		for (int j = 0; j < n; ++j)
		{
			temp += P[j][count[j]];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* 最小公倍数 */
ll lcm(ll a, ll b)
{
	ll gcdRes = gcd(a, b);
	return (a * (b / gcdRes));
}

int main()
{
	ll N, M;
	string S, T;
	cin >> N >> M >> S >> T;

	ll lcmVal = lcm(N, M);
	ll sInc = lcmVal / N;
	ll tInc = lcmVal / M;
	ll checPos = lcm(sInc, tInc);
	ll ans = lcmVal;
	for (ll i = 0; i < lcmVal; i+=checPos) {
		if (S[i / sInc] != T[i / tInc]) {
			ans = -1;
			break;
		}		
	}

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


Measured memory_bytes: 512
#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>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1,-1);
    int c = 0, l = 0;

    int v = 1;
    while (ord[v] == -1) {
        ord[v] = s.size();
        s.push_back(v);
        v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];

    if (k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5852
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<int> adj[100001];
bool vis[100001];
void dfs (int cur) {
  vis[cur] = true;
  for (int i : adj[cur]) if (!vis[i]) dfs(i);
}
int main() {
  int n,m,cnt=0;
  scanf ("%d %d",&n,&m);
  while (m--) {
    int a,b,c;
    scanf ("%d %d %d",&a,&b,&c);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int x = 1; x <= n; x++) if(!vis[x]) {
    cnt++;
    dfs(x);
  }
  printf ("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

bool isOk(ll K, long long N, long long A, long long B,
          std::vector<long long> &h) {
  vl hcopy(N);
  rep(n, 0, N) { hcopy[n] = h[n] - K * B; }

  ll cnt = 0;
  rep(n, 0, N) {
    if (hcopy[n] > 0) {
      cnt += ceil((double)hcopy[n] / (A - B));
    }
  }

  return cnt <= K;
}

void solve(long long N, long long A, long long B, std::vector<long long> h) {
  ll kl = 0;
  ll kr = 1e9;
  ll km = (kl + kr) / 2;
  ll ok = -1;
  while (kl <= kr) {
    if (isOk(km, N, A, B, h)) {
      ok = km;
      kr = km - 1;
    } else {
      kl = km + 1;
    }
    km = (kl + kr) / 2;
  }
  print(ok);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, A, B, std::move(h));
  return 0;
}


Measured memory_bytes: 1904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int N = Integer.parseInt(scan.nextLine() );

		String InStr = scan.nextLine();
		String[] sV = InStr.split(" ");

		InStr = scan.nextLine();
		String[] sC = InStr.split(" ");

		int cost = 0;
		int V;
		int C;

		for (int i = 0; i < N; i++) {

			V = Integer.parseInt(sV[i]);
			C = Integer.parseInt(sC[i]);

			if( V - C > 0) {
				cost = cost + (V - C);
			}

		}
		System.out.println(cost);

		scan.close();
	}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head
int q,m,n,k,res,tmp,tmp2,tmp3,h,w;
int a[100001] = {};
//int b[100010] = {};
int r[100001][25];
deque<PII> que;
string s;
map<int,VPII> kukan;
//vector<pair<int,PII>> g;
//int dp[200000];
int flag;
//VPII g2[200000];


signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	cin>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    cin>>m;
    rep(i,0,n){
        r[i][0] = lower_bound(a+i,a+n,a[i]+m+1)-a-1;
    }
    rep(i,1,20){
        rep(j,0,n){
            r[j][i] = r[r[j][i-1]][i-1];
        }
    }
    cin>>q;
    int x,y;
    rep(i,0,q){
        cin>>x>>y;
        x-=1;y-=1;
        if(x>y) swap(x,y);
        int z = 0;
        per(j,0,20){
            if(r[x][j]<y){x=r[x][j];z+=1<<j;}
        }
        cout<<z+1<<endl;
    }
}

Measured memory_bytes: 21120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        long cnt = k;
        cnt *= Math.pow(k-1, n-1);

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  string ans;
  ans = "";
  //アルファベットは26文字なので数字を26進数で考えればいい。開始が1であることに注意。
  while (N > 0) {
    N--;
    ans = (char)('a' + N % 26)+ ans;
    N /= 26;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll t=1,s=0;
	while(t<=n){
		t*=2;
		s++;
	}
	t=1;
	s--;
	while(s--){
		t=t*2+1;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N, K, L;

const int MAX_UF = MAX_N;

class UnionFind {
private:
  int par[MAX_UF];
  int rank[MAX_UF];
  
public:
  int find(int x);
  void init(int n);
  void unite(int x, int y);
  bool same (int x, int y);
};

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

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

void UnionFind::unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) {
    return;
  } else {
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) ++rank[y];
    }
  }
}

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

vector<int> group[MAX_N];

int main() {
  cin >> N >> K >> L;

  UnionFind road_uinion;
  UnionFind rail_uinion;
  road_uinion.init(N);
  rail_uinion.init(N);
  for (int i = 0; i < K; ++i) {
    int p, q;
    cin >> p >> q;
    road_uinion.unite(--p, --q);
  }
  for (int i = 0; i < L; ++i) {
    int r, s;
    cin >> r >> s;
    rail_uinion.unite(--r,--s);
  }

  map<pii, int> duplicate;
  for (int i = 0; i < N; ++i) {
    group[road_uinion.find(i)].push_back(rail_uinion.find(i));
  }

  for (int i = 0; i < N; ++i) {
    sort(all(group[i]));
  }

  for (int i = 0; i < N; ++i) {
    cout << upper_bound(all(group[road_uinion.find(i)]), rail_uinion.find(i)) - lower_bound(all(group[road_uinion.find(i)]), rail_uinion.find(i)) << endl;
  }

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define INF INT_MAX/2

using namespace std;

int N, K;

int main() {
    cin >> N >> K;
 
    queue<int> que1;
    que1.push(1);
 
    rep(i, N) {
        queue<int> que0;
 
        while (!que1.empty()) {
            que0.push(que1.front() * 2);
            que0.push(que1.front() + K);
			que1.pop();
        }
        swap(que1, que0); 
    }
 
    int ans = INF;
    while (!que1.empty()) {
        ans = min(ans, que1.front());
		que1.pop();
    }
    cout << ans << endl;
}

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

int main() 
{
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	int N, M, X, Y, x[105], y[105];		cin >> N >> M >> X >> Y;
    	for(int i = 0; i < N; i++)	cin >> x[i];
    	for(int i = 0; i < M; i++)	cin >> y[i];
    	sort(x, x + N);
    	sort(y, y + M);
    	for(int i = -100; i <= 100; i++)
    	{
    		if(i > X && i <= Y && i > x[N - 1] && i <= y[0])
    			return cout << "No War", 0; 
    	}
    	cout << "War";
    	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int  ll;
#define pb push_back
#define mp make_pair
#define N 200005


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);

	ll x;
	cin>>x;
	ll p  = (x/500)*1000 +  ((x%500)/5)*5;
	cout<<p<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long
 
	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'
 
 
	// Debug //
 
	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
 
	using namespace std;
 	
	int main()
	{
 
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);cout.tie(NULL);
		

	 	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	ll i,j;
	ll ans=0;
	ll c=0;
	rep(i,0,n-1){
		if(s[i]==s[i+1]){
			ans++;
		}else
		c++;
	}
	ans+=min(c,k*2);
	cout<<ans;
		return 0;
		}
	 	


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int gcd(int p, int q){
        if(p %q == 0)return q;
        return gcd(q, p%q);
}
int main(int argc, char *argv[]){
        int K;
        long s = 0;
        scanf("%d", &K);
        for(int i = 1; i <= K; i++){
                for(int j = 1; j <= K; j++){
                        for(int k = 1; k <= K; k++){
                                s += gcd(gcd(i, j), k);
                        }
                }
        }
        printf("%ld\n", s);
        return 0;
}

Measured memory_bytes: 1732
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, q]: number[] = tmp[0].split(" ").map(Number);
    const s: string = tmp[1];
    const acCountList: number[] = [];
    let prevA: boolean = false;
    let count: number = 0;
    for (let i = 0; i < n; i++) {
      const t: string = s.charAt(i);
      if (t == "A") {
        prevA = true;
      } else if (prevA) {
        if (t == "C") {
          ++count;
        }
        prevA = false;
      }
      acCountList.push(count);
    }
    const result: number[] = []
    for (let i = 2, len = q + 2; i < len; i++) {
      const [l, r]: number[] = tmp[i].split(" ").map(Number);
      result.push(acCountList[r - 1] - acCountList[l - 1]);
    }
    return `${result.join("\n")}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 34724
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

signed main() {
	int N;
	cin >> N;

	vector<int> a(3 * N);
	rep(i, 3 * N) cin >> a[i];

	int sum1 = 0, sum2 = 0;
	priority_queue<int> q1, q2;
	unordered_map<int, int> m1, m2;
	rep(i, N) {
		sum1 += a[i];
		q1.push(-a[i]);
	}
	REP(i, 2 * N, 3 * N - 1) {
		sum2 += a[i];
		q2.push(a[i]);
	}
	m1[0] = sum1;
	m2[N] = sum2;
	//cerr << "m1[0] = " << sum1 << endl;
	//cerr << "m2[" << N << "] = " << sum2 << endl;

	rep(i, N) {
		sum1 += a[i + N];
		q1.push(-a[i + N]);
		sum1 -= -q1.top();
		q1.pop();
		m1[i + 1] = sum1;

		sum2 += a[2 * N - i - 1];
		q2.push(a[2 * N - i - 1]);
		sum2 -= q2.top();
		q2.pop();
		m2[N - i - 1] = sum2;
		//cerr << "m1[" << i + 1 << "] = " << sum1 << endl;
		//cerr << "m2[" << N - i - 1 << "] = " << sum2 << endl;
	}

	int ret = LLONG_MIN;
	rep(i, N + 1) {
		ret = max(ret, m1[i] - m2[i]);
	}

	cout << ret << endl;
}


Measured memory_bytes: 12404
n = int(input())
a = list(map(int, input().split()))

ans = 1000

KAI = -1
URI = 1
phase = KAI

kabu_min = a[0]
kabu_max = -1

for i in range(1, n):
  if phase == KAI and a[i] <= kabu_min:
    kabu_min = a[i]
  elif phase == KAI:
    kabu_max = a[i]
    phase = URI
  elif phase == URI and a[i] >= kabu_max:
    kabu_max = a[i]
  elif phase == URI:
    ans = (ans % kabu_min) + (ans // kabu_min) * kabu_max
    kabu_min = a[i]
    kabu_max = -1
    phase = KAI

if phase == URI and kabu_max > kabu_min:
  ans = (ans % kabu_min) + (ans // kabu_min) * kabu_max

print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   string s;cin>>s;
   if(s.back()=='s'){
      cout<<s<<"es"<<endl;
   }
   else cout<<s<<"s"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for(int i=s; i < (int)(n); i++)
#define ll long long
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}

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

int stamina(int x, int p){
  return (x-p)*(x-p);
}

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

  vector<int> vec(n);
  rep(i,n){
    cin >> vec[i];
  }

  int ans = INF;
  rep(i,100){
    int sum = 0;
    rep(j,n){
      sum += stamina(vec[j],i);
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int n, m;
vvi to, cost;
set<pi> walked;

void dfs(int cur, int g) {
    rep(k, n) {
        if (k == cur || to[cur][k]+cost[k][g] != cost[cur][g])
            continue;
        walked.insert({min(cur, k), max(cur, k)});
        dfs(k, g);
    }
}

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

    std::cin >> n >> m;
    to.resize(n, vi(n, inf));
    rep(i, n) to[i][i] = 0;
    rep(i, m) {
        int a, b, c; std::cin >> a >> b >> c;
        --a, --b;
        to[a][b] = to[b][a] = c;
    }
    cost = to;
    rep(k, n) rep(i, n) rep(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]);
    rep(i, n) srep(j, i+1, n) {
        dfs(i, j);
    }
    std::cout << m-(int)walked.size() << "\n";
}


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


int main(){
	int n,a,b,sum=0;
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++){
		int x=i,y=0;
		while(1){
			if(x<=0) break;
			y+=x%10;
			x/=10;
		}
		if(a<=y&&y<=b){
			sum+=i;
		}
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h=0,k=0,w=0;
	cin>>h>>w>>k;
	vector<vector<int>>v;
	for(int i=0;i<h;i++)
	{
		vector<int>temp;
		for(int j=0;j<w;j++)
		{
			char a;
			cin>>a;
			if(a=='.')
			temp.push_back(0);
			else temp.push_back(1);
		}
		v.push_back(temp);
	}
	int ans=0;
	for(int mask1=0;mask1<(1<<h);mask1++)
	{
		for(int mask2=0;mask2<(1<<w);mask2++)
		{
			int p=0;
			for(int i=0;i<h;i++)
			{
				for(int j=0;j<w;j++)
				{
					if((mask1&(1<<i))==0&&(mask2&(1<<j))==0&&v[i][j]==1)
					p++;
				}
			}
			if(p==k)
			ans++;			
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
use proconio::{fastout, input};

#[fastout]
#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        N: usize,
        A: [usize; N],
    }

    let mut ans = 0;
    let mut height = A[0];

    for i in 1..N {
        ans += height - std::cmp::min(A[i], height);
        height = std::cmp::max(A[i], height);
    }

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


Measured memory_bytes: 5472
n = int(input())
s = input()
rs = [0]*n
gs = [0]*n
bs = [0]*n
for i in reversed(range(n)):
    if s[i] == 'R':
        rs[i] += 1
    elif s[i] == 'G':
        gs[i] += 1
    else:
        bs[i] += 1
for i in reversed(range(n-1)):
    rs[i] += rs[i+1]
    gs[i] += gs[i+1]
    bs[i] += bs[i+1]
res = 0
for i in range(n):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            continue
        if s[i]!='B' and s[j]!='B':
            res += bs[j+1]
            if j-i+j < n:
                if s[j-i+j] == 'B':
                    res -=1
        elif s[i]!='G' and s[j]!='G':
            res += gs[j+1]
            if j - i + j < n:
                if s[j-i+j] == 'G':
                    res -=1
        else:
            res += rs[j+1]
            if j - i + j < n:
                if s[j-i+j] == 'R':
                    res -= 1
print(res)

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


int main(){
  long long N,a;
  cin >> N;
  vector<long long> A(N);
  long long sum=0;
  int sign=1;
  for (int i=0;i<N;++i){
    cin >> a;
    A[i]=a;
    sum+=sign*(a);
    sign*=-1;
  }

  cout << sum << " ";
  for(auto itr=A.begin()+1;itr<A.end();++itr){
    sum=*(itr-1)*2-sum;
    cout << sum << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2048
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var n = t.ReadInputOneLine();
            var input = t.ParseIntList(t.ReadInput());
            bool ans = false;
            for(var i = input[0]; i<=input[1]; i++)
            {
                if(i % n == 0)
                {
                    ans = true;
                    break;
                }
            }
            if (ans)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("NG");
            }
        }


        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 17876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		int x = i;
		int start = 0;

		while (i <= n) {
			if (start == 0) {
				x = i;
				if (x % 3 == 0) {
					System.out.print(" " + i);
					start = 2;
				}
			}
			if (start <= 1) {
				if (x % 10 == 3) {
					System.out.print(" " + i);
					start = 2;
				}
				if (start <= 1) {
					x /= 10;
					if (0 < x) {
						start = 1;
						continue;
					}
				}
			}
			i++;
			start = 0;
		}

		System.out.println();
	}
}

Measured memory_bytes: 28580
import sys
readline = sys.stdin.readline
n = int(readline())
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
for _ in [0] * n:
    line_axis = tuple(map(int, readline().split()))
    p0, p1, p2, p3 = (complex(x, y) for x, y in zip(line_axis[::2], line_axis[1::2]))
    if dot(p1 - p0, p3 - p2) == 0:
        print('1')
    elif cross(p1 - p0, p3 - p2) == 0:
        print('2')
    else:
        print('0')

Measured memory_bytes: 7976
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 5e4 + 7;
int c[27], dp[MAXN];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
    	scanf("%d", &c[i]);
	}
    memset(dp, 0x7f, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
    	for (int j = c[i]; j <= n; j++) {
    		dp[j] = min(dp[j], dp[j - c[i]] + 1);
		}
	}
	printf("%d\n", dp[n]);
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

void insertionSort(int *A, int N, int g, int *cnt)
{
    FOR(i, g, N)
    {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v)
        {
            A[j + g] = A[j];
            j = j - g;
            *cnt += 1;
        }
        A[j + g] = v;
    }
}

void shellSort(int *A, int N)
{
    int cnt = 0;
    int m = 0, s = 1;
    int G[1000];
    while (s <= N)
    {
        G[m] = s;
        s = 3*s + 1;
        m++;
    }

    REP(i, m/2)
    {
        swap(G[i], G[m - 1 - i]);
    }

    REP(i, m)
    {
        insertionSort(A, N, G[i], &cnt);
    }

    cout << m << endl;
    REP(i, m)
    {
        cout << G[i];
        if (i != m-1)
            cout << " ";
    }
    cout << endl << cnt << endl;

    REP(i, N)
    {
        cout << A[i] << endl;
    }
}



int main()
{
    int N, A[1000000];
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    shellSort(A, N);

}


Measured memory_bytes: 7000
#include<stdio.h>
#include<string.h>
int main()
{
      char s[100],p[100],c,k[100];

      scanf("%s%c%s",s,&c,p);
      int a,b;
      scanf("%d%d",&a,&b);
      scanf("%s",k);
      if(strcmp(s,k)==0)
            printf("%d %d\n",a-1,b);
      else if(strcmp(p,k)==0)
            printf("%d %d\n",a,b-1);
      return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i], &c[i])
	}

	dp := make([][3]int, n + 10)
	dp[0][0] = a[0]
	dp[0][1] = b[0]
	dp[0][2] = c[0]
	for i := 1; i < n; i++ {
		dp[i][0] = max(dp[i-1][1] +a[i], dp[i-1][2] + a[i])
		dp[i][1] = max(dp[i-1][0] +b[i], dp[i-1][2] + b[i])
		dp[i][2] = max(dp[i-1][0] +c[i], dp[i-1][1] + c[i])
	}

	fmt.Println(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 9372
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int main(){

  priority_queue <int> a;
  int tmp1;
  char tmp2[10];

  while(scanf("%s",tmp2),tmp2[2]!='d'){
    if(tmp2[0]=='i'){
      scanf("%d",&tmp1);
      a.push(tmp1);
    }
    else{
      printf("%d\n",a.top());
      a.pop();
    }
  }
  return 0;

}


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

using namespace std;

int main() {
	string s1;
	string s2;

	cin >> s1 >> s2;

	int length = s1.length();

	for (int i = 0; i < length; i++) {
		int ret = true;
		for (int j = 0; j < length; j++) {
			if (s1.at((i + j) % length) != s2.at(j % length)) {
				ret = false;
				break;
			}
		}
		if (ret == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

const int mod=1000000007;

int dp[310][310],dp2[310][310];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	dp[1][1]=1;
	for (int i=1;i<=m;i++)
	{
		for (int j=1;j<=n;j++)
			for (int k=1;k<=j;k++)
			{
				dp2[j][k]=dp[j][k];dp[j][k]=0;
			}
		for (int j=1;j<=n;j++)
			for (int k=1;k<=j;k++)
			{
				dp[j+1][k]=(ll(dp2[j][k])*(n-j)+dp[j+1][k])%mod;
				dp[j][k]=(ll(dp2[j][k])*(j-k)+dp[j][k])%mod;
				dp[j][j]=(ll(dp2[j][k])*k+dp[j][j])%mod;
			}
	}
	printf("%d\n",dp[n][n]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

int main(){
  int n,m;
  while(cin >> n >> m){
    vector<LLI> a(n); cin >> a;

    priority_queue<LLI> pq;
    REP(i,n){
      pq.push(a[i]);
    }

    REP(i,m){
      auto t = pq.top(); pq.pop();
      t /= 2;
      pq.push(t);
    }

    LLI ans = 0;
    while(pq.size()){
      ans += pq.top();
      pq.pop();
    }

    cout << ans << endl;

    
  }

  return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[8] = { 0,0,1,-1, 1,1,-1,-1 };// 前４つで４近傍
const int c_Dy[8] = { 1,-1,0,0 ,1,-1,1,-1};// 全部で８近傍
const int c_div = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846;


int main() {

	int N, L[10000], R[19999];

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &L[i], &R[i]);
	}


	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += R[i] - L[i] + 1;


	}

	printf("%d", ans);

}







Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int ans[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    rep(i, N) {
        if(i % 2 == 0) ans[0] += A[i];
        else ans[0] -= A[i];
    }
    REP(i, 1, N - 1) ans[i] = 2 * A[i - 1] - ans[i - 1];
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}
// 2A[0] = ans[0] + ans[1];
// 2A[1] = ans[1] + ans[2];
// 2A[2] = ans[2] + ans[0];

// ans[0] = 2A[0] - ans[1]
//        = 2A[0] - (2A[1] - ans[2])
//        = 2A[0] - (2A[1] - (2A[2] - ans[0]))
//        = 2A[0] - 2A[1] + 2A[2] - ans[0];
// ans[0] = A[0] - A[1] + A[2]


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M, C; cin >> N >> M >> C;
    vector<int> b(M);
    vector<vector<int>> a(N, vector<int>(M, 0));
    for(int i=0; i<M; i++) cin >> b[i];
    for(int i=0; i<N; i++) for(int j=0; j<M; j++) cin >> a[i][j];

    int ans = 0;
    for(int i=0; i<N; i++){
        int score = 0;
        for(int j=0; j<M; j++) score += a[i][j]*b[j];
        if(score + C > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h,n,b,v,k;

        cin>>b>>v;
        h=b;
        for(int i=1;i<=v;i++){
            cin>>k;
            h=h-k;
        }
        if(h<=0){
            cout<<"Yes";}
        else{cout<<"No";}
        return 0;
    return 0;
}


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

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

vector<long> divisors(long n, bool sort_mode = false){
    vector<long> result;
    for(long i = 1; i < ceil(sqrt((long double)n)); i++){
        if(n % i == 0){
            result.push_back(i);{
                if (i != n / i){
                    result.push_back(n/i);
                }
            }
        }
    }
    if(sort_mode == true){
        sort(result.begin(), result.end());
    }
    return result;
}

vector<long> sieve(long N){
    vector<long> search_list(N-1);
    vector<long> prime_list;
    long prime_number;

    //2 ~ Nの整数を昇順で格納
    for(long i=0; i<N-1; i++){
        search_list[i] = i + 2;
    }

    //sqrt(N)まで実行
    for(long i=0; i<sqrt(N)+1; i++){
        //素数リストに探索リストの先頭の数を追加
        //なぜ! = 1としたかは後述
        if(search_list[i] != 1){
            prime_number = search_list[i];
            prime_list.push_back(prime_number);
        }        
        //その倍数を探索リストから篩い落とす
        for(long j=0; j<search_list.size(); j++){
            if(search_list[j] % prime_number == 0){
                //.eraseはO(N)なので1を代入することで代用
                search_list[j] = 1;
            }
        }
    }

    //探索リストに残った数を素数リストに追加
    for(long i=0; i<search_list.size(); i++){
        if(search_list[i] != 1){
            prime_list.push_back(search_list[i]);
        }
    }

    return prime_list;
}
 
int main(){

    long A, B;
    cin >> A;
    cin >> B;

    long prime = 0;
    long g = gcd(A, B);
    vector<long> search_list = divisors(g, true);
    vector<long> prime_list;

    for(long i=1; i<search_list.size(); i++){
        if(search_list[i] != 1){
            prime = search_list[i];
            prime_list.push_back(prime);
        }

        for(long j=0; j<search_list.size(); j++){
            if(search_list[j] % prime == 0){
                search_list[j] = 1;
            }
        }
    }

    for(long i=0; i<search_list.size(); i++){
        if(search_list[i] != 1){
            prime_list.push_back(search_list[i]);
        }
    }

    cout << prime_list.size() + 1 << endl;

    return 0;
}

Measured memory_bytes: 384
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	int N, L, i = 0, max = 30000, a[200], b/*保存用*/, ans/*味*/ = 0;
	scanf("%d%d", &N, &L);
	for (i = 1; i <= N; i++) {
		a[i] = L + i - 1;
		b = a[i];
		if (a[i] < 0) {
			a[i] = -a[i];
		}
		if (a[i - 1] > a[i]) {
			max = b;
		}
		if (max > a[i]) {
			max = b;
		}
		if (a[i] == 0) {
			max = 0;
		}
		ans += b;
	}
	printf("%d", ans-max);
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;
const int INF = (int)1e8;

signed main(){
	int n; cin >> n;
	vector<int> p(4), t(4);
	for(auto &&e : p)cin >> e;
	for(auto &&e : t) cin >> e;
	
	vector<int> dp(n+1, INF);
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 4; j++){
			if( i - t[j] < 0){
				dp[i] = min(dp[i], dp[0] + p[j]);
			}
			else{
				dp[i] = min(dp[i], dp[i-t[j]] + p[j]);
			}
		}
	}
	cout << dp.back() << endl;

	return 0;
}




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


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

    ll n;
    cin>>n;
    pair<ll,ll> p[n];
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        p[i] = make_pair(a,-i);
    }
    sort(p,p+n,greater<pair<ll,ll>>());
    ll ans[n]={};
    ll ind = -1e9;
    ll cnt = 0;
    for(ll i=0;i<n;){
        ll a = p[i].first;
        while(i<n && a==p[i].first){
            cnt++;
            ind = max(ind,p[i].second);
            i++;
        }
        if(i<n) ans[-ind] += cnt * (a-p[i].first);
        else ans[-ind] += cnt*a;
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }


    
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int gt[9], jk[9], n, s, t, u, v;
	
	while(cin>>n && n){
		while(n--){
			s = t = 0;
			for(int i = 0; i < 9; i++){
				cin >> gt[i];
			}
			for(int j = 0; j < 9; j++){
				cin >> jk[j];
			}
			sort(gt, gt+9);
			sort(jk, jk+9);
			do{
				u = v = 0;
				for(int i = 0; i < 9; i++){
					if(jk[i] > gt[i]){
						u += (jk[i]+gt[i]);
					} else {
						v += (jk[i]+gt[i]);
					}
				}
				if(u > v){
					s++;
				} else {
					t++;
				}
			} while(next_permutation(jk, jk+9));
			
			printf("%.5f %.5f\n", (double)t/(double)(s+t), (double)s/(double)(s+t));
		}
	}
	
	return 0;
}

Measured memory_bytes: 904
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]

odd = []
for (x, y) in P:
    dist = abs(x) + abs(y)
    odd.append(dist % 2 != 0)

valid = True
even = False
if all(odd):
    pass
elif not any(odd):
    even = True
else:
    valid =False

if valid:

    M = 31
    if even:
        print(M+1)
        print(*([1 << m for m in range(M)] + [1]))
    else:
        print(M)
        print(*[1 << m for m in range(M)])

    for (x, y) in P:
        u = x + y
        v = x - y
        if even:
            u += 1
            v += 1
        if u >= 0 and v >= 0:
            A = 'R'
            B = 'U'
            C = 'D'
            D = 'L'
        elif u >= 0 and v < 0:
            v *= -1
            A = 'U'
            B = 'R'
            C = 'L'
            D = 'D'
        elif u < 0 and v >= 0:
            u *= -1
            A = 'D'
            B = 'L'
            C = 'R'
            D = 'U'
        elif u < 0 and v < 0:
            u *= -1
            v *= -1
            A = 'L'
            B = 'D'
            C = 'U'
            D = 'R'

        ans = ''
        wa = ((1 << M) - 1 - u) // 2
        sa = ((1 << M) - 1 - v) // 2
        for i in range(M):
            check = str(wa >> i & 1) + str(sa >> i & 1)
            if check == '00':
                ans += A
            elif check == '01':
                ans += B
            elif check == '10':
                ans += C
            elif check == '11':
                ans += D
        if even:
            ans += 'L'
        print(ans)
else:
    print(-1)


Measured memory_bytes: 3192
#include <stdio.h>

main(){
  char data[20];
  int i, c=0, p;

  while(1){
    for(i=0;;){
      scanf("%c", &data[i]);
      if(data[0]==' ' || data[0]==',' || data[0]=='.'){
	i=0;
	continue;
      }
      else if(data[0]!='\n' && i==0 && c==1){
	p=1;
      }
      if(data[i]=='\n'){
	printf("\n");
	return 0;
      }
      if(data[i]==' ' || data[i]==',' || data[i]=='.'){
        data[i]='\0';
        break;
      }
      i++;
    }

    if(i<=2 || i>=7){
      continue;
    }
    else if(p==1){
      printf(" ");
      p=0;
    }
    printf("%s", data);
    c=1;
  }
  return 0;
}

Measured memory_bytes: 0