akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double pi = 3.141592653589793238;
    double y = abs(2*60*h + 2*m - 2*12*m);
    if (y / 720 > 1) y = 2*720 - y;
    double x = a*a + b*b - 2*a*b * cos(y * pi / 720);
    cout << fixed << setprecision(15) << pow(x, 0.5) <<endl;
    return 0;
}

Measured memory_bytes: 4332
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;

template<typename T>
T Gcd(T a, T b)
{
	while (b != 0)
	{
		T next = a % b;
		a = b;
		b = next;
	}

	return a;
}

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

	vector<ll> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		A[i] /= 2;
	}

	ll lcm = A[0];
	for (int i = 0; i < n - 1; i++)
	{
		lcm = lcm * A[i + 1] / Gcd(lcm, A[i + 1]);
		//lcm = lcm * A[i] * A[i + 1] / Gcd(A[i], A[i + 1]);
		if (lcm > m + 100)
		{
			lcm = 0;
		}
	}

	if (lcm == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		if (lcm / A[i] % 2 == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	ll ans = (m - lcm) / (lcm * 2) + 1;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#
import sys
import math
import numpy as np
import itertools


# ひとつ入力
n = int(input())

if n % 2 ==0:
    print(n*(n-2)//2)
    for i in range(n):
        for j in range(i+1,n):
            if i+j+1 == n:
                pass
            else:
                print(i+1,j+1)
else:
    print((n-1)*(n-1)//2)
    for i in range(n):
        for j in range(i+1,n):
            if i+j+2 == n:
                pass
            else:
                print(i+1,j+1)


Measured memory_bytes: 18872
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int n,a[3][100010],now=0;
    long long int b[3][100010];
    scanf("%d",&n);
    for(int j=0;j<3;j++)for(int i=0;i<n;i++)scanf("%d",&a[j][i]);
    for(int i=0;i<=n;i++)b[2][i]=n-i;
    sort(a[0],a[0]+n);
    sort(a[1],a[1]+n);
    sort(a[2],a[2]+n);
    for(int i=0;i<n;i++){
        while(a[1][i]>=a[2][now]&&now<n)now++;
        b[1][i]=b[2][now];
    }
    for(int i=n-2;i>=0;i--)b[1][i]+=b[1][i+1];
    now=0;
    for(int i=0;i<n;i++){
        while(a[0][i]>=a[1][now]&&now<n)now++;
        if(i!=0)b[0][i]=b[0][i-1]+b[1][now];
        else b[0][i]=b[1][now];
    }
    printf("%lld\n",b[0][n-1]);
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define N 1000000
#define ar array
#define inf 1e18
#define mod 998244353
#define ld long double
#define pb push_back
#define f first
#define s second
typedef long long int ll;
using namespace std;
/*

ll d[N];
set<pair<ll,ll>>s;
ll par[N];
vector<pair<ll,ll>>adj[N];
void Dijkstra(ll v){
	d[v]=0;
	s.insert({d[v],v});
	par[v]=v;
	while(!s.empty()){
		ll u=s.begin()->second;
		s.erase(s.begin());
		for(auto x:adj[u]){
			if(d[x.first]>d[u]+x.second){
				s.erase({d[x.first],x.first});
				d[x.first]=d[u]+x.second;
				s.insert({d[x.first],x.first});
				par[x.first]=u;
			}
		}
	}
}*/
int main(void){
	fast;
	int n,i;
	cin>>n;
	ll ans=0;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	vector<int>v;
	if(n==1)
	cout<<0<<endl;
	else{
	v.pb(0);
	v.pb(a[0]);
	i=1;
	while(v.size()<n){
		v.pb(a[i]);
		if(v.size()>=n)
		break;
		v.pb(a[i]);
		if(v.size()>=n)
		break;
		i++;
	}
	for(auto x:v)
	ans+=x;
	cout<<ans;
	}
}


Measured memory_bytes: 4980
import sys

N = int(input())

W = []
for _ in range(N):
    W.append(input())

WW = set(W)

if len(W) != len(WW):
    print("No")
    sys.exit()
else:
    for i in range(N-1):
        a = W[i][-1]
        b = W[i+1][0]
        if a != b:
            print("No")
            sys.exit()
print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    double n;
    for(;;) {
        cin >> n;
        if(n == 0) break;
        double s[1010], all =0;
        rep(i, 1010) {
            s[i] = 0;
        }
        rep(i, n) {
            cin >> s[i];
            all += s[i];
        }
        double ave = all / n;
        double sum=0;
        rep(i, n) {
            sum += (s[i] - ave) * (s[i] - ave);
        }
        double ans = sqrt(sum / n);
        cout << fixed << setprecision(10) << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3296
// All Heil Fire Lord Zuko

#include<bits/stdc++.h>
using namespace std;

#define sz(x) (int)x.size()
#define F first
#define S second
#define PB push_back

#define debug(x) cerr << #x << " = " << x << "\n"

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, bool> pllb;

const int N = 100 * 1000 + 19;

int n;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    if (n % 2)
        return cout << n / 2, 0;
    cout << (n / 2) - 1;
    return 0;
}

/* THINGS TO CHECK */

// Runtime ->
// Overflow ->
// Time ->
// Memory ->

/* READ PROBLEM STATEMENT CAREFULLY */


Measured memory_bytes: 256
//投影
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const double EPS=1e-6;
bool is_Zero(double &a){
	return a<EPS&&a>-EPS;
}
const int INFTY=1<<29;
struct Point{
	double x,y;
	Point(double x,double y):x(x),y(y){}
	Point(){}
	Point(const Point&a){x=a.x;y=a.y;}
	Point operator+(const Point&a){
		return Point(x+a.x,y+a.y);
	}
	Point operator-(const Point&a){
		return Point(x-a.x,y-a.y);
	}
	Point operator*(double k){
		return Point(k*x,k*y);
	}
	Point operator/(double k){
		return Point(x/k,y/k);
	} 
};
typedef Point Vector;
Point operator*(double k,const Point&a){
	return Point(k*a.x,k*a.y);
}
double norm(const Point&a){
	return a.x*a.x+a.y*a.y;
}
double abs(const Point&a){
	return sqrt(norm(a));
}
double dot_product(const Point&a,const Point&b){
	return a.x*b.x+a.y*b.y;
}
double cross_product(const Point&a,const Point&b){
	return a.x*b.y-a.y*b.x;
}
Point projection_Point(Point&p1,Point&p2,Point&p){
	Vector base=p2-p1;
	double r=dot_product(base,p-p1)/norm(base);
	return p1+base*r;
}

Point reflection_Point(Point&p1,Point&p2,Point&p){
	Point temp=projection_Point(p1,p2,p);
	return 2*temp-p;
}

int main(){
	Point p1,p2;
	Point temp;
	scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lf%lf",&temp.x,&temp.y);
		Point a=reflection_Point(p1,p2,temp);
		printf("%.10lf %.10lf\n",a.x,a.y);
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,C,X,D[32][32],t[3][32]; //i+j mod 3=iの場所に色jがt[i][j]個

void solve(){
    int ans=INF;
    //C種類から3つ選ぶ組み合わせを総あたり
    for(int i=1;i<=C;i++){
        for(int j=1;j<=C;j++){
            if(i!=j){
                for(int k=1;k<=C;k++){
                    if(i!=k&&j!=k){
                        int tt=0;
                        for(int l=1;l<=C;l++) tt+=D[l][i]*t[0][l];
                        for(int l=1;l<=C;l++) tt+=D[l][j]*t[1][l];
                        for(int l=1;l<=C;l++) tt+=D[l][k]*t[2][l];
                        
                        ans=min(ans,tt);
                     }
                }
            }
        }
    }
    cout<<ans<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >>N>>C;
    for(int i=1;i<=C;i++){
        for(int j=1;j<=C;j++){
            cin>>D[i][j];
        }
    }
    
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin>>X;
            t[(i+j)%3][X]++;
        }
    }
        
    solve();
    
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int main(){ 
  ll a, b, c;
  cin >>a>>b>>c;
  if (c-a-b>0&&4*a*b<(c-a-b)*(c-a-b)){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int n;
  long int a[100000];
  int i;
  long int sum = 0;
  long int ans[100000];
  if(scanf("%d",&n)==1);
  for(i=0;i<n;i++){
    if(scanf("%ld",&a[i])==1);
    sum += a[i];
  }
  
  sum /= 2;
  for(i=1;i<n;i+=2){
    sum -= a[i];
  }
  ans[0] = sum;
  for(i=1;i<n;i++){
    ans[i] = a[i-1] - ans[i-1];
  }
  printf("%ld",2*ans[0]);
  for(i=1;i<n;i++){
    printf(" %ld",2*ans[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
struct strling {
    // vector size : n + 1
    vector<vector<mint> > S;
    strling (int MAX): S(MAX + 1, vector<mint>(MAX + 1)) {
        assert(MAX < mod);
        // n < k => 0
        S[0][0] = 1;
        // n > k => S[n][k] = S[n - 1][k - 1] + k * S[n - 1][k]
        for (int n = 1; n <= MAX; ++n) {
            for (int k = 1; k <= n; ++k) {
                S[n][k] = S[n-1][k-1] + S[n-1][k] * k;
            }
        }
    }
    mint operator()(int n, int k) {
        if (n < 0 || k < 0 || n < k) return 0;
        return S[n][k];
    }
};
/* global variables */
/* function */
/* main */
int main() {
    int n, k;
    cin >> n >> k;
    if (n < k) { cout << 0 << '\n'; return 0; }
    strling s = strling(2000);
    cout << s(n, k) << '\n';
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

ll solve(){
    int N,k;
    cin >> N>>k;
    auto f=[&](ll X)->ll{
        //1つ前はX/(k-1)グループのX%(k-1)+1番目
        return k*(X/(k-1))+(X%(k-1))+1;
    };
    auto ans=0L;
    rep(i,N-1) ans=f(ans);
    return ans;
}

int main(){
    out(solve());
}



Measured memory_bytes: 3120
// A C++ program to find bridges in a given undirected graph 
#include<iostream> 
#include <list> 
#define NIL -1 
using namespace std; 
int ans=0;
// A class that represents an undirected graph 
class Graph 
{ 
	int V; // No. of vertices 
	list<int> *adj; // A dynamic array of adjacency lists 
	void bridgeUtil(int v, bool visited[], int disc[], int low[], 
					int parent[]); 
public: 
	Graph(int V); // Constructor 
	void addEdge(int v, int w); // to add an edge to graph 
	void bridge(); // prints all bridges 
}; 

Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<int>[V]; 
} 

void Graph::addEdge(int v, int w) 
{ 
	adj[v].push_back(w); 
	adj[w].push_back(v); // Note: the graph is undirected 
} 

// A recursive function that finds and prints bridges using 
// DFS traversal 
// u --> The vertex to be visited next 
// visited[] --> keeps tract of visited vertices 
// disc[] --> Stores discovery times of visited vertices 
// parent[] --> Stores parent vertices in DFS tree 
void Graph::bridgeUtil(int u, bool visited[], int disc[], 
								int low[], int parent[]) 
{ 
	// A static variable is used for simplicity, we can 
	// avoid use of static variable by passing a pointer. 
	static int time = 0; 

	// Mark the current node as visited 
	visited[u] = true; 

	// Initialize discovery time and low value 
	disc[u] = low[u] = ++time; 

	// Go through all vertices aadjacent to this 
	list<int>::iterator i; 
	for (i = adj[u].begin(); i != adj[u].end(); ++i) 
	{ 
		int v = *i; // v is current adjacent of u 

		// If v is not visited yet, then recur for it 
		if (!visited[v]) 
		{ 
			parent[v] = u; 
			bridgeUtil(v, visited, disc, low, parent); 

			// Check if the subtree rooted with v has a 
			// connection to one of the ancestors of u 
			low[u] = min(low[u], low[v]); 

			// If the lowest vertex reachable from subtree 
			// under v is below u in DFS tree, then u-v 
			// is a bridge 
			if (low[v] > disc[u]) 
			ans++;
		} 

		// Update low value of u for parent function calls. 
		else if (v != parent[u]) 
			low[u] = min(low[u], disc[v]); 
	} 
} 

// DFS based function to find all bridges. It uses recursive 
// function bridgeUtil() 
void Graph::bridge() 
{ 
	// Mark all the vertices as not visited 
	bool *visited = new bool[V]; 
	int *disc = new int[V]; 
	int *low = new int[V]; 
	int *parent = new int[V]; 

	// Initialize parent and visited arrays 
	for (int i = 0; i < V; i++) 
	{ 
		parent[i] = NIL; 
		visited[i] = false; 
	} 

	// Call the recursive helper function to find Bridges 
	// in DFS tree rooted with vertex 'i' 
	for (int i = 0; i < V; i++) 
		if (visited[i] == false) 
			bridgeUtil(i, visited, disc, low, parent); 
} 

// Driver program to test above function 
int main() 
{ 
	// Create graphs given in above diagrams 
	int n,m;
    cin>>n>>m;
	Graph g1(n);
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        g1.addEdge(u,v);
    } 
    g1.bridge();
    cout<<ans<<endl;
	

	return 0; 
} 


Measured memory_bytes: 3648
n, m = map(int, input().split())
x=list(map(int, input().split()))
def solve(x):
    if m<=n:
        return 0
    x=sorted(x)
    l=sorted([x[i+1]-x[i] for i in range(m-1)], reverse = True)
    return x[m-1]-x[0]-sum(l[:n-1])
print(solve(x))

Measured memory_bytes: 13968
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    ll V = 1;
    for(int n = 0; n < N;n++){
        V = min(2*V,V+K);
    }
    cout << V << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n;
long long x = 0;
int main()
{
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >>n;
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= n; ++j)
    {
      int g = __gcd(i, j);
      for (int k = 1; k <= n; ++k)
      {
        x += __gcd(g, k);
      }
    }
  }
  cout <<x << '\n';
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n;
	cin >> n;
	int C[n-1], S[n-1], F[n-1];
	rep(i, n-1) {
		cin >> C[i] >> S[i] >> F[i];
	}

	for (int i=0; i<n-1; i++) {
		int res = 0;
		for (int j=i; j<n-1; j++) {
			if (j==i) {
				res += S[j] + C[j];
			}
			else {
				int w = S[j];
				while (res>w) w += F[j];
				res += w-res+C[j];
			}
		}
		cout << res << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 3592
N, Q = map(int, input().split())
S = input()
lr = [[int(i) for i in input().split()] for i in range(Q)]
check = []
num, cnt = 0, 0

for i in range(N):
    if S[i] == 'A':
        cnt = 1
    elif S[i] == 'C':
        if cnt == 1:
            cnt = 0
            num += 1
    else:
        cnt = 0
    check.append(num)

for l, r in lr:
    print(check[r - 1] - check[l - 1])

Measured memory_bytes: 69208
from collections import deque
s=list(input())
d=deque()
n=len(s)
acount=0
cnt=0
for i in range(n):
    d.append(s[i])
i=0
while i<n:
    if s[i]=="A":
        acount=acount+1
    elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
    else:
        acount=0
    i=i+1
    #print(acount,cnt)
    #input()
print(cnt)

Measured memory_bytes: 62064
ans=[]

while True:
    H,W=map(int,input().split())
    if W==H==0:
        break
    r=''
    r+='#'*W+'\n'

    for i in range(H-2):
        r+='#'+'.'*(W-2)+'#\n'

    r+='#'*W+'\n'
    ans.append(r)

print('\n'.join(ans))


Measured memory_bytes: 5704
N = int(input())
Mons = list(map(int, input().split()))
Mons = list(set(Mons))
Mons.sort()

minHP = Mons[0]

if minHP == 1 or len(Mons) == 1:
    print(minHP)
    exit()
    
minSA = minHP

for a,b in zip(Mons[:],Mons[1:]):
    sa = b % a
    if sa and sa < minSA:
        minSA = sa

ans = minSA

while 1:
    hoge = [val % ans for val in Mons if val % ans]

    if hoge:
        if ans == min(hoge):
            break
        else:
            ans = min(hoge)
    else:
        break

print(ans)

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

void swap(int &a, int &b) {
	int tmp = a;
	a = b;
	b = tmp;
}
// void bubbleSort(vector<int> &A, vector<int> &B) {
// 	bool flag = true;
// 	int i = 0;
// 	int N = A.size();
// 	while (flag) {
// 		flag = false;
// 		for (int j = N - 1; j > i; j--) {
// 			if (A[j - 1] > A[j]) {
// 				flag = true;
// 				swap(A[j - 1], A[j]);
// 				swap(B[j - 1], B[j]);
// 			}
// 		}
// 		i++;
// 	}
//
// }

int main(void) {
	int N;
	scanf("%d", &N);
	vector<int> A(N);
	vector<int> ans(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		ans[A[i] - 1] = i + 1;
	}
	for (int i = 0; i < N; i++) {
		printf("%d", ans[i]);
		if (i != N - 1) {
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define elif else if
using namespace std;
int main () {
    wolfe;
    int a;
    cin >> a;
    cout << a + (a*a) + (a*a*a) << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>

int main(){

  char tile[128][128];
  int i,j,k,l,x,y;

  while(1)
    {
  scanf("%d%d",&i,&j);
  if(i==0&j==0)break;
  else
    {
  for(k=0;k<i;k++)
    {
      scanf("%s",tile[k]);
    }
  x=0;
  y=0;
  l=0;
  while(tile[y][x] != '.')
    {
      l++;
      if(l>i*j)break;
      else if(tile[y][x]=='>')x++;
      else if(tile[y][x]=='<')x--;
      else if(tile[y][x]=='^')y--;
      if(tile[y][x]=='v')y++;
    }
  if(l>i*j)printf("LOOP\n");
else
  printf("%d %d\n",x,y);
    }
    }
  return 0;
}

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

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

    cin >> a >> b >> c;

    if (a == 1 && b == 1 && c == 0) {
        cout << "Open" << endl;
    }
    else if (a == 0 && b == 0 && c == 1) {
        cout << "Open" << endl;
    }
    else {
        cout << "Close" << endl;
    }

    return 0;
}



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

using namespace std;

int main()
{
    int i,n,AC=0,WA=0, TLE=0,RE=0;

    cin>>n;

    string s[n];
    for(i=0; i<n; i++)
    {
        cin>>s[i];
    }
    for(i=0; i<n; i++)
    {
        if(s[i]=="AC")
            AC++;
        else if(s[i]=="WA")
            WA++;
        else if(s[i]=="TLE")
            TLE++;
        else if(s[i]=="RE")
            RE++;
    }
    cout<<"AC"<<" x "<<AC<<endl;
    cout<<"WA"<<" x "<<WA<<endl;
    cout<<"TLE"<<" x "<<TLE<<endl;
    cout<<"RE"<<" x "<<RE<<endl;


    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



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

	int n;
	cin >> n;
	int a[n], p[n];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);

	int ans = 0;
	for (int i=0; i<n; i++) {
		if (i==0) p[i] = -1;
		else if (i==n-1) p[i] = 1;
		else if (a[i]<0) p[i] = -1;
		else p[i] = 1;
		ans += p[i]*a[i];
	}

	cout << ans << nl;
	for (int i=1; i<n-1; i++) {
		if (p[i]==1) {
			cout << a[0] << " " << a[i] << nl;
			a[0] -= a[i];
		}
	}
	for (int i=0; i<n-1; i++) {
		if (p[i]==-1) {
			cout << a[n-1] << " " << a[i] << nl;
			a[n-1] -= a[i];
		}
	}

	return 0;
}


Measured memory_bytes: 2688
def main():
    # 区間スケジューリングの典型問題
    # 選べる中で最小の終点を選んでいく
    N = int(input())
    sec = [[0,0] for _ in range(N)]
    for i in range(N):
        X,L = map(int, input().split())
        sec[i][0] = X+L
        sec[i][1] = X-L
    # 終点で昇順ソート
    sec = sorted(sec)
    ans = 1
    now = sec[0][0]
    for i in range(1,N):
        if sec[i][1]>=now:
            # 残す
            ans += 1
            now = sec[i][0]
    print(ans)

main()


Measured memory_bytes: 20908
#include <bits/stdc++.h>
using namespace std;
int main(){
 string S;
 cin>>S;
bool a=false;
int count=0;
 if(S.at(0)==S.at(1)){
 a=true;
 }
 else if(S.at(1)==S.at(2)){
     a=true;
 }
 else if(S.at(2)==S.at(3)){
     a=true;
 }
 if(a==true){
     cout<<"Bad"<<endl;
 }
 else
 cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn=1e6;
int fun(int n){
    int sum=0;
    while(n){
        sum+=(n%10);
        n/=10;
    }
    return sum;
}
int main()
{
    int n;
   while( cin>>n){
        int minn = inf;
        for (int i = 1; i <= n / 2; i++) {
            int sum = fun(i) + fun(n - i);
            if (minn > sum)
                minn = sum;
        }
        cout << minn << endl;
   }
    return 0;
}


Measured memory_bytes: 256
(defvar input (concatenate 'list (read-line)))

(let ((char1 '())
      (char2 '()))
  (labels ((countchar (str)
                      (if str
                          (cond ((null char1)
                                 (setf char1 (cons 1 char1))
                                 (setf char1 (cons (car str) char1))
                                 (countchar (cdr str)))
                                ((eq (car char1) (car str))
                                 (setf (cadr char1) (1+ (cadr char1)))
                                 (countchar (cdr str)))
                                ((null char2)
                                 (setf char2 (cons 1 char2))
                                 (setf char2 (cons (car str) char2))
                                 (countchar (cdr str)))
                                ((eq (car char2) (car str))
                                 (setf (cadr char2) (1+ (cadr char2)))
                                 (countchar (cdr str)))
                                (t (format t "No~%")))
                          (if (and (eq 2 (cadr char1))
                                   (eq 2 (cadr char2)))
                              (format t "Yes~%")
                              (format t "No~%")))))
          (countchar input)))

Measured memory_bytes: 11876
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication30
{
    class Program
    {
        static void Main()
        {
            List<int> R = new List<int>();
            int A = int.Parse(Console.ReadLine()), S = int.MinValue;int U = int.MinValue;
            for (int B = 0; B < A; B++)
            {
                int L = int.Parse(Console.ReadLine());
                R.Add(L);
            }
            for (int C = R.Count - 1; C > -1; C--)
            {
                    if (S >= R[C]||U>=R[C]) continue;
                    for (int D = C - 1; D > -1; D--)
                    {
                        if (R[C] - R[D] > S) { S = R[C] - R[D]; if (R[D] == 0) break;U = R[C]; }
                    }
            }
            Console.WriteLine(S);
            }
        }
    }

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

int main()
{
    int k;
    int a[4];
    int s=0;
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3, greater<int>());
    cin>>k;
    for(int i=0;i<k;i++)
    {
        a[0]=a[0]*2;
    }
    for(int i=0;i<3;i++)s+=a[i];
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m,q = [int(x) for x in input().split()]

data =[]

for _ in range(q):
    data.append([int(x) for x in input().split()])

ans = 0

def dfs(pos,prev,arr):
    global ans
    if pos == n:
        cost = 0
        for dd in data:
            a,b,c,d = dd
            if arr[b-1] - arr[a-1] == c:cost+=d
        ans = max(ans,cost)
    else:
        for i in range(prev,m+1):
            arr[pos] = i
            dfs(pos+1,arr[pos],arr)

dfs(0,1,[0]*n)

print(ans)

Measured memory_bytes: 9164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_4_C
{
    public class Program

    {
        public static void Main(string[] args)
        {

            while(true)
            {

                string[] line = ReadStAr();
                int a = int.Parse(line[0]);
                string op = line[1];
                int b = int.Parse(line[2]);

                switch (op)
                {
                    case "?": return;
                    case "+": Console.WriteLine("{0}", a + b); break;
                    case "-": Console.WriteLine("{0}", a - b); break;
                    case "*": Console.WriteLine("{0}", a * b); break;
                    case "/": Console.WriteLine("{0}", a / b); break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 15956
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define F first
#define S second
const int MAXN=1e9+7;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll x,y,ans=0;cin >> x >> y;
	while (x<=y){
		ans++;
		x*=2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int x, y;
    cin >> x >> y;
    int kame, turu;
    for (int kame = 0; kame <= 100; kame++)
    {
        for (int turu = 0; turu <= 100; turu++)
        {
            int sum = kame * 4 + turu * 2;
            if (x == kame + turu && sum == y)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

using mint = modint998244353;
const mint inv9 = mint(1) / 9;

// モノイド
struct S {
    mint x, w;
    S(mint x = 0, mint w = 1) : x(x), w(w) {}
};

S op(S a, S b) { return S(a.x * b.w + b.x, a.w * b.w); }
// モノイドの単位元
S e() { return S(); }

// 写像の中身: fffffに変換する
S mapping(int f, S a) {
    if (f == 0) return a;
    return S((a.w - 1) * inv9 * f, a.w);
}

// 関数合成
// gが先なので注意
int composition(int f, int g) {
    if (f == 0) return g;
    return f;
}

int id() { return 0; }

int main() {
    int N, Q;
    cin >> N >> Q;
    lazy_segtree<S, op, e, int, mapping, composition, id> t(N);

    // 初期化
    rep(i, N) t.set(i, S(1, 10));  //なんで10-> 10^1 = 10だから
    rep(i, Q) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        t.apply(l, r, d);
        S ans = t.all_prod();
        printf("%d\n", ans.x.val());
    }
    return 0;
}

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


typedef long long ll;
struct NT{
  vector<bool>isprime;

  ll mod_mult(ll a, ll b, ll m) {
    ll res = 0;
    ll exp = a % m;
    while (b) {
      if (b & 1) {
        res += exp;
        if (res > m) res -= m;
      }
      exp <<= 1;
      if (exp > m) exp -= m;
      b >>= 1;
    }
    return res;
  }

  ll mod_exp(ll a, ll b, ll m) {
    ll res = 1;
    ll exp = a % m;
    while (b) {
      if (b & 1) res = mod_mult(res, exp, m);
      exp = mod_mult(exp, exp, m);
      b >>= 1;
    }
    return res;
  }

  bool miller_rabin(ll n, ll times) {
    if (n < 2) return false;
    if (n == 2) return true;
    if (!(n & 1)) return false;
    ll q = n-1;
    int k = 0;
    while (q % 2 == 0) {
      k++;
      q >>= 1;
    }
    for (int i = 0; i < times; i++) {
      ll a = rand() % (n-1) + 1;
      ll x = mod_exp(a, q, n);
      if (x == 1) continue;
      bool found = false;
      for (int j = 0; j < k; j++) {
        if (x == n-1) {
          found = true;
          break;
        }
        x = mod_mult(x, x, n);
      }
      if (found) continue;
      return false;
    }
    return true;
  }

  ll pollard_rho(ll n, int c) {
    ll x = 2;
    ll y = 2;
    ll d = 1;
    while (d == 1) {
      x = mod_mult(x, x, n) + c;
      y = mod_mult(y, y, n) + c;
      y = mod_mult(y, y, n) + c;
      d = __gcd((x-y >= 0 ? x-y : y-x), n);
    }
    if (d == n) return pollard_rho(n, c+1);
    return d;
  }
};

int sum;

int main(){
  NT N;
  ll n;
  cin>>n;
  while(n--){
    ll a;
    scanf("%ld",&a);
    if(N.miller_rabin(a,10))sum++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3136
using System;

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var str = Console.ReadLine();
                if(str == null)break; 
                string temp = "this";
                for (int i = 0; i < 26; i++)
                {
                    temp = swap(str, i);
                    if (check(temp) == true)
                    {
                        Console.WriteLine(temp);
                        break;
                    }
                }
            }
            
        }
        static string swap(string str1,int n) {
            int code;
            string swap_str ="";
            char[] strs = new char[str1.Length];
            for (int i = 0; i < str1.Length; i++) {
                if (str1.Substring(i, 1) != " " && str1.Substring(i, 1) != ".")
                {
                    code = (int)str1[i] + n;
                    if (122 < code) { code -= 26; }
                    strs[i] = (char)code;
                }
                else if (str1.Substring(i, 1) == " ") strs[i] = ' ';
                else strs[i] = '.';
            }
            for (int i = 0; i < strs.Length; i++) swap_str += strs[i].ToString();
            return swap_str;
        }
        static Boolean check(string str) {
            Boolean tf = false;
            for (int i = 0; i < str.Length-2; i++) {
                if (str.Substring(i, 3) == "the") {
                    tf = true;
                    break;
                }
            }
            for (int i = 0; i < str.Length-3; i++) {
                if (str.Substring(i, 4) == "this"|| str.Substring(i, 4) == "that"){
                    tf = true;
                    break;
                }
            }
            return tf;
        }
    }
}

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

int h,w;
char a[105][105];
int ans[105][105];

int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            ans[i][j]=1e9;
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i==1&&j==1)
                if(a[i][j]=='#')ans[1][1]=1;
                else ans[1][1]=0;
            else{
                if(ans[i-1][j]<ans[i][j-1]){
                    ans[i][j]=ans[i-1][j];
                    if(a[i-1][j]!='#'&&a[i][j]=='#')ans[i][j]+=1;
                }
                else if(ans[i-1][j]>ans[i][j-1]){
                    ans[i][j]=ans[i][j-1];
                    if(a[i][j-1]!='#'&&a[i][j]=='#')ans[i][j]+=1;
                }
                else{
                    ans[i][j]=ans[i][j-1];
                    if(a[i][j-1]!='#'&&a[i-1][j]!='#'&&a[i][j]=='#')ans[i][j]+=1;
                }
            }
        }
    }

    cout<<ans[h][w];

    return 0;
}

Measured memory_bytes: 384
import java.io.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;

class Main {
   final static PrintWriter out = new PrintWriter( System.out );

   final static BufferedReader in =
         new BufferedReader( new InputStreamReader( System.in ) );

   static int lcs(char[] a, char[] b){
      final int alen = a.length;
      final int blen = b.length;
      int dp[][] = new int[alen+1][blen+1];
      int maxl = 0;

      for(int i=0; i<alen; ++i){
         for(int j=0; j<blen; ++j){

            if(a[i] == b[j])
               dp[i+1][j+1] = dp[i][j] + 1;
            else
               dp[i+1][j+1] = max( dp[i][j+1], dp[i+1][j] );

            maxl = max(maxl, dp[i+1][j+1]);
         }
      }
      return (maxl);
   }

   public static void main(String[] args) throws IOException {
      final int N = parseInt( in.readLine() );
      for(int i=0; i<N; ++i){
         char[] a = in.readLine().toCharArray();
         char[] b = in.readLine().toCharArray();
         out.println( lcs(a,b) );
      }
      out.flush();
   }
}




Measured memory_bytes: 63344
#include<bits/stdc++.h>
using namespace std;
int sum;
int main()
{
    int a,b;
    cin>>a>>b;
    int i,j;
    for(int i=0;i<=a;i++)
    for(int j=0;j<=a;j++)
    {
        if(b-i-j>=0&&(b-i-j)<=a)sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main() {
	int N, M, cnt = 0;
	string s[100], t[100], d[100];
	int p[100], ans = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		p[i] = 0;
		d[i] = "0";
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i - cnt; j++) {
			if (s[i] == d[j]) {
				p[j]++;
				cnt++;
				break;
			}
			else if (j + 1 == i - cnt + 1) {
				d[j] = s[i];
				p[j]++;
			}
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N - cnt; j++) {
			if (d[j] == t[i]) {
				p[j]--;
			}
		}
	}
	for (int i = 0; i < N - cnt;i++) {
		ans = max(ans, p[i]);
	}


	cout << ans << endl;

	

	return(0);
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Module Module1
    Sub Main()
        'let'
        Dim N As Long = CLng(Console.ReadLine())
        'var'
        Dim dic As New Dictionary(Of Long, Long)

        For i As Long = 0 To N - 1
            'let'
            Dim d As Long = CLng(Console.ReadLine())
            dic(d) = 1
        Next
        Console.WriteLine(dic.Count)
    End Sub
End Module


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll c = min(n, b - 1);
    cout << (a * c) / b << endl;
}

Measured memory_bytes: 3612
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    an=list(map(int,input().split()))
    a.append(an)

for j in range(m):
    b.append(int(input()))

ans=[]
for i in range(n):
    ai=a[i]
    ansi=0
    for j in range(m):
        ansi+=ai[j]*b[j]
    ans.append(ansi)

for i in range(len(ans)):
    print(ans[i])



Measured memory_bytes: 6020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    cin>>n;
    long long int a[n+5];
    map<long long int,long long int>mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    long long int cn=0,cnt,j,ans=0;
    for(map<long long int, long long int>::iterator it=mp.begin();it!=mp.end();it++)
        {
            cnt=1;
            if(it->second>1)
            {
                long long int l,m;
                l=it->second;
                m=l-1;
                 cnt=(l*m)/2;
                   ans+=(cnt);
            }

        }
    for(i=0;i<n;i++)
    {
        long long int r,s,ss;
        r=mp[a[i]];
        if(r>1)
        {
        r=((r-1)*r)/2;
        mp[a[i]]--;
        if(mp[a[i]]==1)
            s=ans-r;
        else
        {
            s=mp[a[i]];
            s=(s*(s-1))/2;
            s=r-s;
            s=ans-s;
        }
        }
        else
            s=ans;

        cout<<s<<endl;
        mp[a[i]]++;
    }
    return 0;
}


Measured memory_bytes: 11008
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> dam(n);
    FOR(i,0,n)cin>>dam[i];
    ll all = 0;
    FOR(i,0,n) all += dam[i];
    ll a = all/=2;
    for(ll i=1; i<(ll)n; i+=2){
      a -= dam[i];
    }
    FOR(i,0,n){
      cout<<a*2;
      if(i != n-1)cout<<" ";
      else cout<<endl;
      a = dam[i] - a;
    }

}


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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9){
		cout << a * b << endl;
	}else{
		cout << -1 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, m, a[1010];
    while(cin >> n >> m){
        int max = 0;
        if(n == 0&& m==0)    break;
        for(int i=0; i<n; i++){
            cin >> a[i];
        }
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(a[i]+a[j]<=m && max<a[i]+a[j]){
                    max = a[i]+a[j];
                }
            }
        }
        if(max == 0)    cout << "NONE" <<endl;
        else    cout << max << endl;
    }
    return 0;
}



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

ll count_dup(string s){
    ll a = 0;
    for (int i = 0,j=0; i < s.size(); i=j)
    {
        while (j < s.size() && s[i] == s[j])j++;
        a += (j-i)/2;
    }
    return a;
}

int main()
{
    string s;
    ll k;
    cin >> s >> k;

    //sが同じ文字かチェック
    bool is_same = true;
    for (int i = 1; i < s.size(); i++) if (s[0] != s[i]) is_same = false;
    if (is_same)
    {
        cout << (s.size() * k) / 2 << endl;
        return 0;
    }

    //初項を求める
    ll a = count_dup(s);
    //cout << a << endl;
    ll aa = count_dup(s+s);
    //cout << aa << endl;
    ll d = aa - a;
    cout << a + (k - 1) * d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, r;
  cin >> n >> r;
  int ans = r;
  if(n < 10) ans += 100*(10-n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  int K;
  cin >> S >> K;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'a') continue;
    if ('z' - S[i] + 1 <= K) {
      K -= 'z' - S[i] + 1;
      S[i] = 'a';
    }
  }
  if (K != 0)
    S[S.size() - 1] = (char)(((S[S.size() - 1] - 'a') + K) % 26 + 'a');
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

ll gcd(ll a, ll b) {
    while (a && b)
        if (a >= b)
            a %= b;
        else
            b %= a;
    return a + b;
}

int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    ll n, x;
    cin >> n >> x;
    ll g = gcd(n, x);
    n /= g;
    cout << (n - 1) * 3 * g << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i, n) {
		cin >> v[i];
	}
	SORT(v);
	double result = 0;
	rep(i, n) {
		if (i == 0) {
			result = v[i];
			continue;
		}
		result = (v[i] + result)/2;
	}
	cout << result << endl;

}



Measured memory_bytes: 256