akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

void sieve(vector<int> &divs) {
	for (int i = 2; i <= divs.size() / 2; ++i) {
		for (int j = 2 * i; j < divs.size(); j += i) {
			++divs[j];
		}
	}
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	long long sum = 0;
	vector<int> divs(n + 100, 2);
	divs[1] = 1;
	sieve(divs);
	for (int i = 1; i <= n; ++i) {
		sum += (long long) i * divs[i];
	}

	cout << sum << "\n";

	return 0;

}

Measured memory_bytes: 42228
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0,b[1000000]={0};
        string c;
        string s;
       long long int n,m,o=0,l,d=0,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>s;
    if(s[0]=='C')
    cout<<"Rainy";
    else if(s[0]=='S')
    {
        cout<<"Cloudy";
    }
    else
    cout<<"Sunny";
    
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define pb push_back
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;--i)
#define _rrep2(i,n) for(lint i=n-1;i>=0;--i)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)
#define fi i.first
#define se i.second
#define YES(c) cout<<((c)?"YES\n":"NO\n")
#define Yes(c) cout<<((c)?"Yes\n":"No\n")

int main(){
	lin(n);
	lint ans=1;
	rep(i,2,n){
		lint cur=i;
		while(cur<=n)cur*=i;
		cur/=i;
		if(cur!=i)ans=max(ans,cur);
	}cout<<ans<<endl;
}

//sub-EOF


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

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

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

    ll numminuszero = 0;
    ll sum = 0;
    ll minabsval = 10000000000;
    for (int i = 0; i < N; i++) {
        if (A[i] <= 0) {
            numminuszero++;
        }
        minabsval = min(minabsval, abs(A[i]));
        sum += abs(A[i]);
    }


    if (numminuszero % 2 == 0) {
        cout << sum << endl;
    } else {
        cout << sum - 2*minabsval << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

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

    int[] X = new int[M];
    for (int i = 0; i < M; i++) {
      X[i] = sc.nextInt();
    }

    Arrays.sort(X);
    int[] diff = new int[M-1];
    for (int i = 0; i < M-1; i++) {
      diff[i] = X[i+1] - X[i];
    }

    Arrays.sort(diff);
    int ans = 0;
    for (int i = 0; i < diff.length - (N-1); i++) {
      ans += diff[i];
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 48744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

const int N = 2e6+1;

int main() {
	fio;
	string s, t;
	cin >> s >> t;
	int ans = INT32_MAX;
	for (int i = 0;i + t.size() <= s.size();i++) {
		int c = 0;
		for (int j = i;j < i + t.size();j++)
			c += (s[j] != t[j - i]);
		ans = min(ans, c);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second


main(){
  int n;
  cin>>n;
  while(n--){
    string in,ans;
    cin>>in;
    int pos=0;
    rep(i,in.size()){
      if(isalpha(in[i])){
        ans+=in[i];
        pos=0;
      }else if(in[i]=='-')continue;
      else if(in[i]=='<'){
        i+=2;
        pos--;
        if(pos<0)ans=in[i]+ans,pos=0;
      }else{
        i++;
        pos++;
        if(pos>=ans.size())ans+=in[i];
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(1000000)


def depth_first_search(node, friend_list, color_list, color):
    color_list[node] = color
    # print(color_list)
    for friend in friend_list[node]:
        if color_list[friend] == -1:
            color_list = depth_first_search(friend, friend_list,\
                 color_list, color)
    return color_list
        

# f =  open('alds1_11_d-input3.txt', 'r')
# n_user, n_relation = list(map(int, f.readline().split()))
n_user, n_relation = list(map(int, input().split()))

friend_list = [[] for _ in range(n_user)]
for _ in range(n_relation):
    # user, friend = list(map(int, f.readline().split()))
    user, friend = list(map(int, input().split()))
    friend_list[user].append(friend)
    friend_list[friend].append(user)


color_list = [-1 for _ in range(n_user)]
color = 0
for user in range(n_user):
    if color_list[user] == -1:
        color_list = depth_first_search(user, friend_list,\
                color_list, color)
        color += 1

# n_question = int(f.readline())
n_question = int(input())
for _ in range(n_question):
    # user, friend = list(map(int, f.readline().split()))
    user, friend = list(map(int, input().split()))
    if color_list[user] == color_list[friend]:
        print('yes')
    else:
        print('no')
# f.close()
        


Measured memory_bytes: 126952
#include <stdio.h>

int main()
{
	int n[6];
	int i;
	int t[5] = {};
	int judge = 0; 
	for(i = 0;i < 6; i++)
	{
		scanf("%d", &n[i]);
	}

	for(i = 0;i < 6;i++)
	{
		if(n[i] == 1)
			t[0]++;
		else if(n[i] == 2)
			t[1]++;
		else if(n[i] == 3)
			t[2]++;
		else if(n[i] == 4)
			t[3]++;
	}

	for(i = 0;i < 4;i++)
	{
		// printf("t[%d]は%d\n", i, t[i]);
		if(t[i] == 1)
			judge++;
	}

	if(judge != 2)
		printf("NO\n");
	else
		printf("YES\n");

	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

class BinomialCoefficients{
  int max;
  int mod;
  long long *factorial;
  long long *factorial_inverse;
  long long *inverse;

public:
  int get(int n, int k){
    if(n < 0 || k < 0 || k > n) return 0;
    else return factorial[n] * (factorial_inverse[k] * factorial_inverse[n - k] % mod) % mod;
  }

  BinomialCoefficients(int max = 1000000, int mod = 1000000007) : max(max), mod(mod){
    factorial = new long long[max + 1];
    factorial_inverse = new long long[max + 1];
    inverse = new long long[max + 1];

    factorial[0] = factorial[1] = 1;
    factorial_inverse[0] = factorial_inverse[1] = 1;
    inverse[1] = 1;

    for(int k = 2; k <= max; k++){
      factorial[k] = factorial[k - 1] * k % mod;
      inverse[k] = mod - inverse[mod % k] * (mod / k) % mod;
      factorial_inverse[k] = factorial_inverse[k - 1] * inverse[k] % mod;
    }
  }

  ~BinomialCoefficients(){
    delete [] factorial;
    delete [] factorial_inverse;
    delete [] inverse;
  }
};

constexpr long long power(long long b, long long e, long long mod){
  long long ret = 1;
  while(e){
    if(e & 1){
      ret *= b;
      ret %= mod;
    }

    b *= b;
    b %= mod;
    e >>= 1;
  }

  return ret;
}

constexpr long long power(long long b, long long e){
  return power(b, e, mod);
}

int main(){
  int N, M;
  cin >> N >> M;
  
  BinomialCoefficients binom;
  
  long long fact[M + 1];
  fact[0] = 1;
  for(int i = 1; i <= M; i++) fact[i] = fact[i - 1] * i % mod;
  
  long long ans = power(binom.get(M, N) * fact[N] % mod, 2);
  
  for(int i = 1; i <= N; i++){
    ans -= (i & 1 ? 1ll : -1ll) * binom.get(N, i) % mod * binom.get(M, i) % mod * fact[i] % mod * power(binom.get(M - i, N - i) * fact[N - i] % mod, 2) % mod;
    ans %= mod;
  }
  
  cout << (ans + mod) % mod << endl;
  
  return 0;
}

Measured memory_bytes: 30476
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int main(){
  string s;
  cin>>s;
  string t1,t2;
  bool flag = false;
  bool flag2 = false;
  REP(i,s.size()){
    if(!flag){
      if(s[i]!='i')t1+=s[i];
      else flag = true;
    }else{
      if(flag2) t2 += s[i];
      else if(s[i]=='i')flag2 = true;
    }
  }
  string k1 = "({[";string k2 = ")}]";
  REP(i,t2.size()){
    REP(j,3){
      if(t2[i]==k1[j])t2[i]=k2[j];
      else if(t2[i]==k2[j])t2[i]=k1[j];
    }
  }
  reverse(t2.begin(),t2.end());
  int dp[100][100]={};
  REP(i,t1.size())REP(j,t2.size()){
    if(t1[i]==t2[j])dp[i+1][j+1] = dp[i][j] + 1;
    else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
  }
  cout<<3+dp[t1.size()][t2.size()]*2<<endl;


  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  long a[n+1];
  for(int i=1;i<=n;i++)scanf("%ld",&a[i]);
  
  long long ans=0;
  
  for(int i=2;i<=n;i++){
    if(a[i-1]>a[i]){
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  
  printf("%lld",ans);
  return 0;
  
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
  int cnt=0;
  int N;
  cin >> N;
  for(int i=0; i< N; i++){
    int n, k=1;
    cin >> n;
    for(int j=2; j*j <=n; j++){
      if (n%j==0){
        k = 0;
        break;
      }
    }
    cnt +=k;
  }
  cout <<cnt <<endl;
}


Measured memory_bytes: 3084
/*
 * @Date         : 2020-08-10 15:34:44
 * @Author       : ssyze
 * @Description  :
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 6;
int n, k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& x : a) cin >> x;
    sort(a.begin(), a.end());
    ll l = 0, r = n - 1, w = 1;
    ll ans = 1;
    if (k & 1) ans = a[r--], k--, w = (ans < 0 ? -1 : 1);
    while (k) {
        ll x = a[l] * a[l + 1], y = a[r] * a[r - 1];
        if (x * w > y * w)
            ans = (ans * (x % mod)) % mod, l += 2;
        else
            ans = (ans * (y % mod)) % mod, r -= 2;
        k -= 2;
    }
    cout << (ans % mod + mod) % mod << endl;
}

Measured memory_bytes: 4752
i = int(input())
t1=i*(i+1)/2

i3=int(i/3)
t3=i3*(i3+1)/2*3

i5=int(i/5)
t5=i5*(i5+1)/2*5

i15=int(i/15)
t15=i15*(i15+1)/2*15

ans=int(t1-t3-t5+t15)
print(ans)

Measured memory_bytes: 9192
n = int(input())
import copy

hako = []
for i in range(n):
    hako.append(int(input()))
# print(hako)#まずはinput

hakomax= max(hako)#最大値をとってきた
# print(hakomax)
hako2 = copy.deepcopy(hako)#2番目の最大値を取ってくるためのコピー

hako2max = max(hako2)
# print(hako2max)
hako2.remove(hako2max)#2番目の最大値を取ってくるための
# print(hako2)
hako2max = max(hako2)
# print(hako2max)

for i in range(n):
    if hako[i] == hakomax:
        print(hako2max)
    else:
        print(hakomax)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    c-=a;d-=b;

    string U=string(d,'U');
    string D=string(d,'D');
    string L=string(c,'L');
    string R=string(c,'R');

    cout<<U+R+D+L+"L"+U+"UR"+R+"DR"+D+"DL"+L+"U"<<endl;
    return 0;
}


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

using namespace std;

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

    int odds = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 1) odds++;
    }

    if (odds % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main(){
  double w;
  int i=0,j;
  char lank[100][100];
  while(scanf("%lf",&w)!=EOF){
    if(w<=48.00)
      strcpy(lank[i],"light fly");
    if(48.00<w && w<=51.00)
      strcpy(lank[i],"fly");   
    if(51.00<w && w<=54.00)
      strcpy(lank[i],"bantam");
    if(54.00<w && w<=57.00)
      strcpy(lank[i],"feather");
    if(57.00<w && w<=60.00)
      strcpy(lank[i],"light");
    if(60.00<w && w<=64.00)
      strcpy(lank[i],"light welter");
    if(64.00<w && w<=69.00)
      strcpy(lank[i],"welter");
    if(69.00<w && w<=75.00)
      strcpy(lank[i],"light middle");
    if(75.00<w && w<=81.00)
      strcpy(lank[i],"middle");
    if(81.00<w && w<=91.00)
      strcpy(lank[i],"light heavy");
    if(91.00<w)
      strcpy(lank[i],"heavy");
    i++;
  }

  for(j=0;j<i;j++){
    printf("%s\n",lank[j]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int N, A;
    cin >> N;
    int cnt;
    int ans=40;
    for (int i = 0; i < N;i++){
        cin >> A;
        cnt = 0;
        while (true){
            if (A%2==1)
                break;
            cnt++;
            A /= 2;
        }
        if (cnt<ans)
            ans = cnt;
    }
    cout << ans << endl;
}

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

int main() {
	int n,q;
	cin >> n >> q;
	vector<list<int> > v(n);

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int x,t;
			cin >> t >> x;
			v[t].push_back(x);
		}
		else if (c == 1) {
			int t;
			cin >> t;
			for (list<int>::iterator itr = v[t].begin(); itr != v[t].end(); itr++) {
				if(itr!=v[t].begin()) cout <<" ";
				cout << *itr;
			}
			cout << endl;
		}
		else {
			int t,s; cin >> s >> t;
			v[t].splice(v[t].end(),v[s]);
		}
	}
}
	



Measured memory_bytes: 18724
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int main() {
  FASTIO();

  ll n, k;
  cin >> n >> k;
  vector<ll> hv(n);
  for (ll i = 0; i < n; ++i) {
    cin >> hv[i];
  }
  sort(hv.begin(), hv.end());

  ll tot = 0;
  for (ll i = 0; i < n - k; ++i) {
    tot += hv[i];
  }
  cout << tot;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val H = readLine()!!.split(" ").map(String::toInt)

    var max = 0
    var cnt = 0

    for (i in 1 until N) {
        if (H[i] <= H[i-1]) {
            cnt++
        } else {
            if (max < cnt) {
                max = cnt
            }
            cnt = 0
        }
    }

    if (max < cnt) {
        max = cnt
    }

    println(max)
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  int ans=(1<<30);
  REP(i,s.size()-2){
    chmin(ans,abs(753-(s[i]-'0')*100 - (s[i+1]-'0')*10 - (s[i+2]-'0')));
  }
  cout << ans << endl;
}



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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

int N,K; ll ans;

vector<vector<int>> to;

vector<int> depth; vector<bool> visited;

void BFS( int v){
  //vを根としてdepthをつけて行く
   depth[v] = 0; visited[v] = true;
  
   queue<int> Q; Q.push(v); 
  
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    for(int i = 0; i < to[p].size(); i++){
      int j = to[p][i]; 
      if( visited[j]){ continue;}
      
      depth[j] = depth[i] + 1; visited[j] = true; Q.push(j);}}
  
  //すべてのノードの深さをつけた
}
      
void color(int v){
  //vノードを根として色を振り分けて行く
  
  for(int x = 0; x < N; x++){
    //xノードに着目
    if( x != v){ //xは根でない
      for(int y = 0; y < to[x].size() - 1; y++){
        ans *= K - 2 - y; ans%= MOD;}}
    
    else{ //xが根の時
      for(int y = 0; y < to[x].size(); y++){
        ans *= K - 1 - y; ans %= MOD;}}
  }
  }

int main(){
 cin >> N >> K;
  
  to.resize(N);
  for(int i = 0; i < N - 1; i++){
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a); //向きなし
  }
  
  depth = vector<int> (N,-1); visited = vector<bool> (N, false);

  BFS(0);
  
  ans = K;
  
  color(0);
  
  
  cout << ans << endl; return 0;}

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

int N;
int A[210];

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

      int res = 0;

      while (true) {
            bool exist_odd = false;
            for (int i = 0; i < N; ++i){
                  if (A[i] % 2 != 0) exist_odd = true;
            }

            if (exist_odd) break;

            for (int i = 0; i < N; ++i){
                  A[i] /= 2;
            }
            ++res;
      }

cout << res << endl; 
      
}

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

using namespace std;

int main()
{
    int arr_size, AC_count = 0, WA_count = 0, TLE_count = 0, RE_count = 0;
    string array[100000], in;
    cin >> arr_size;
    for (int i = 0; i < arr_size; i++)
        cin >> array[i];
    for (int i = 0; i < arr_size; i++)
    {
        if (array[i] == "AC")
            AC_count++;
        else if (array[i] == "WA")
            WA_count++;
        else if (array[i] == "TLE")
            TLE_count++;
        else if (array[i] == "RE")
            RE_count++;
    }
    cout << "AC x " << AC_count << endl << "WA x " << WA_count << endl << "TLE x " << TLE_count << endl << "RE x " << RE_count << endl;
}



Measured memory_bytes: 6732
#include <stdio.h>

int main() {
  int i, n;
  int as[100];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &as[i]);
    if (as[i] % 2 == 0 && as[i] % 3 !=0 && as[i] % 5 != 0) {
      puts("DENIED");
      return 0;
    }
  }
  puts("APPROVED");
  return 0;
}

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

int main(){
  string s,base = "abcdefghijklmnopqrstuvwxyz";
  cin>>s;
  vector<bool> flag(s.size());
  for(int i=0;i<s.size();i++){
    flag[i] = false;
  }
  int count=0;
  if(s.at(0) == 'A') flag[0] = true;
  for(int i=0;i<base.size();i++){
    if(s.at(1) == base.at(i)) flag[1] = true;
    if(s.at(s.size()-1)==base.at(i)) flag[s.size()-1]=true;
    for(int j=2;j<s.size()-1;j++){
      if(base.at(i) == s.at(j)) flag[j] = true;
      else if(s.at(j)=='C'){
        count++;
        flag[j] = true;
      }
    }
  }
  if(count!=base.size()){
    cout<<"WA"<<endl;
    return 0;
  }
  for(int i=0;i<s.size();i++){
    if(!flag[i]){
      cout<<"WA"<<endl;
      return 0;
    }
  }
  cout<<"AC"<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int k = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();
		Column c = new Column(s);
		int h = c.getHandsSize();
		if(k >= h) {
			k = h - 1;
		}
		int maxPoint = 0;
		for(int i = 0; i < h - k; i++) {
			int point = c.getPoint(i, i + k);
//			System.out.println(point);
			if(point > maxPoint) {
				maxPoint = point;
			}
		}
		System.out.println(maxPoint);
	}

}
class Column{
	ArrayList<Integer> Hands = new ArrayList<Integer>();
	ArrayList<Integer> Stands = new ArrayList<Integer>();
	Column(String s){
		StringBuilder sb = new StringBuilder(s);
		while(sb.length() != 0){
			addHandStand(sb);
		}
		if(Stands.get(Stands.size() - 1) != 0) {
			Hands.add(0);
		}
	}
	void addHandStand(StringBuilder sb) {
		int h = sb.indexOf("0");
		if(h == -1) {
			h = sb.length();
		}
		Hands.add(h);
		sb.delete(0, h);

		int s = sb.indexOf("1");
		if(s == -1) {
			s = sb.length();
		}
		Stands.add(s);
		sb.delete(0, s);
	}
	int getPoint(int i, int i2) {
		if(i2 > Hands.size() - 1) {
			i2 = Hands.size() -1;
		}
		if(i == i2) {
			return Hands.get(i);
		}else if(i > i2){
			return 0;
		}
		int point =Hands.get(i2);
		for(; i < i2; i++) {
			point += Hands.get(i) + Stands.get(i);
		}
		return point;
	}
	int getHandsSize() {
		return Hands.size();
	}
}


Measured memory_bytes: 29280
#include <bits/stdc++.h>
using namespace std;
const int SIZE=10005;

int n,a[3][SIZE],f[SIZE],b[SIZE],ans=0;

int main()
{
	cin>>n;
	for (int i=1;i<=2;i++)
		for (int j=1;j<=n;j++)
			cin>>a[i][j];
			
	for (int i=1;i<=n;i++) f[i]=f[i-1]+a[1][i];
	for (int i=n;i>=1;i--) b[i]=b[i+1]+a[2][i];
	for (int i=1;i<=n;i++) ans=max(ans,f[i]+b[i]);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
void main() {
	(arr => arr.enumerate.map!(i => i[0] == 0 ? i[1]-1 : i[1]).map!(i => [i, 1, i+1, 0][abs(i)%4]).reduce!"a^b")(readAs!(ulong[])).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){

vector<char>ans;
string A;
  cin>>A;

  for(int i=0;i<(int)A.size();++i){
  ans.push_back(A[i]);
  }

  int Q;
  cin>>Q;
  int T,F;
  char C;
  int count=0;
  for(int i=0;i<Q;i++){
  cin>>T;
  
  	if(T==1)count=(count+1)%2;
  	if(T==2){
      	cin>>F>>C;
		if((count+F)%2==0){ans.push_back(C);}
     	if((count+F)%2==1){
          ans.insert(ans.begin(),C);}
  	}
  
  }
  
  
  if(count%2==0){
  for(int i;i<ans.size();i++){
    cout<<ans[i];
  	}
  }
  
    if(count%2==1){
  for(int i;i<ans.size();i++){
    cout<<ans[ans.size()-i-1];
  	}
  }
  
}


Measured memory_bytes: 1144
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{

  int A, B, ans, ans8, ans10;

  cin >> A >> B;
  for (int i = 1; i < 100000; i++)
  {
    ans8 = i * 0.08;
    ans10 = i * 0.10;
    if (ans8 == A && ans10 == B)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

using namespace std;

long long score[8][1000]; // score[0] : (+, +, +), socre[1] : (+, +, -), ...

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		long long temp[3];
		for (int j = 0; j < 3; j++)
			cin >> temp[j];
		for (int j = 0; j < 8; j++) {
			long long s = 0;
			for (int k = 0; k < 3; k++) {
				if (j & (1 << k))
					s -= temp[k];
				else
					s += temp[k];
			}
			score[j][i] = s;
		}
	}
	long long smax = 0;
	for (int i = 0; i < 8; i++) {
		sort(score[i], score[i] + n, [](long long a, long long b){return a > b;});
		long long s = 0;
		for (int j = 0; j < m; j++) {
			s += score[i][j];
		}
		smax = max(smax, s);
	}
	cout << smax << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<ctype.h>
#include<cstdio>

using namespace std;

int main()
{
    int n;int k;
    int sum=1;
    while(cin>>n>>k)
    {
       while(n--)
          {
        if(sum<k)
           {sum=sum*2;
           //cout<<sum<<endl;
           }

           else
            sum=sum+k;
           // cout<<sum<<endl;
           // cout<<n<<endl;;
          }
          cout<<sum<<endl;

    }
}


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

const int maxy = 7368791;

 int m, n;
 char a[maxy+1];

int main(){
  while(cin >> m >> n && m && n){

    for(long long int i = 1; i <= maxy; ++i){
      a[i] = 0;
    }

    for(int i = 0; i < n; ++i){
      for(int i = 1; m*i<=maxy; ++i){
        a[m*i]=1;
      }
      while(a[m])m++;
    }


    cout << m << endl;

  }
  return 0;
}

Measured memory_bytes: 10268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

namespace Solver {

    vector<bool> isPrime;
    inline void PreCompute() {
        int MAX = 1000000;
        isPrime.resize(MAX, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i * i <= MAX; ++i) {
            if (isPrime[i]) {
                for (int j = i * 2; j < MAX; j += i)
                    isPrime[j] = false;
            }
        }
    }

    int a, d, n;
    inline bool Read() {
        cin >> a >> d >> n;
        return a != 0;
    }

    inline void Work() {
        for (int i = 0, cnt = 0;; i++) {
            if (isPrime[a + d * i]) {
                cnt++;
                if (cnt == n) {
                    cout << a + d * i << endl;
                    break;
                }
            }
        }
    }

    inline void Solve() {
        PreCompute();
        while(Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1320
n = int(input())
p = [[0, 0, 0]]
for i in range(n):
    p.append([int(_) for _ in input().split()])

p.sort()

flag = True
for i in range(n):
    dt = abs(p[i+1][0]-p[i][0])
    dxy = abs(p[i+1][1]-p[i][1])+abs(p[i+1][2]-p[i][2])
    if dt >= dxy and (dt-dxy)%2==0:
        pass
    else:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21156
n = int(input())
lr_cnt = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
    str_i = str(i)
    start = int(str_i[0])
    end = int(str_i[-1])
    lr_cnt[start][end] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += lr_cnt[i][j] * lr_cnt[j][i]
print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int N,M; cin>>N>>M;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];
    sort(a.begin(),a.end());

    priority_queue<pair<int,int> > Q;
    for(int i=0;i<M;i++){
        int b,c; cin>>b>>c;
        Q.push(make_pair(c,b));
    }

    int i=0;
    while(!Q.empty()){
        int num=Q.top().first;
        int cnt=Q.top().second;
        Q.pop();
        if(i==N) continue;
        while(cnt>0 and a[i]<num){
            a[i++]=num;
            cnt--;
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353
//#defint mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll fact[2*N];

void getfact(){
	for(ll i = 0;i<2*N;i++){
		if(i==0){
			fact[i] = 1;
		}else{
			fact[i] = (fact[i-1]*i)%mod;
		}
	}
}

ll combination(ll n,ll k){
	ll ans = (fact[n]*((inv(fact[k])*inv(fact[n-k]))%mod))%mod;
	return ans;
}

int main(){
	boost;
	ll n,m,t;
	cin>>n>>m>>t;
	getfact();
	ll sum = 0;
	for(int k = 0;k<=t;k++){
		ll ans = power(m-1,n-k-1)%mod;
		ans = (m*((ans*combination(n-1,k))%mod))%mod;
		sum = (sum + ans)%mod;
	}
	cout<<sum;
}

//Total solved problems:- 13



Measured memory_bytes: 5196
import java.util.*;

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

        int[] cs = new int[N-1];
        int[] ss = new int[N-1];
        int[] fs = new int[N-1];

        for (int i = 0; i < N-1; i++) {
            cs[i] = sc.nextInt();
            ss[i] = sc.nextInt();
            fs[i] = sc.nextInt();
        }

        for (int i = 0; i < N - 1; i++) {
            int t = 0;
            for (int j = i; j < N - 1; j++) {
                if (i == j) {
                    t = cs[j] + ss[j];
                } else {
                    if (t > ss[j]) {
                        int k = ((t - ss[j]) + fs[j] - 1) / fs[j];
                        t = ss[j] + fs[j] * k + cs[j];
                    } else {
                        t = ss[j] + cs[j];
                    }
                }
            }
            System.out.println(t);
        }
        System.out.println("0");
    }
}

Measured memory_bytes: 26580
#include<bits/stdc++.h>
using namespace std;
int H,n,sum,x;
int main()
{
	cin>>H>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>=H)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main(){
  long long N, s = 0;
  cin >> N;
  for(int i = 1; i <= N; i++){
    if(!(i % 3 ==0 || i % 5 == 0)){
      s += i;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3600
import math

def a():
    n = int(input())

    print((10000-n)%1000)


def b():
    n = int(input())
    # s = []
    count = [0]*4
    for i in range(n):
        s = input()
        if s == 'AC':
            count[0] += 1
        elif s == 'WA':
            count[1] += 1
        elif s == 'TLE':
            count[2] += 1
        else:
            count[3] += 1
    
    

    print('AC x',count[0])
    print('WA x',count[1])
    print('TLE x',count[2])
    print('RE x',count[3])



def c():
    print('')



def d():
    print('')


b()

Measured memory_bytes: 9228
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
int n,m;
string a,b;
int dp[3005][3005];
int solve(int i,int j)
{
	if(i==n||j==m)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	int ans=0;
	if(a[i]==b[j])
		ans=1+solve(i+1,j+1);
	else
		ans=max(solve(i+1,j),solve(i,j+1));
	dp[i][j]=ans;
	return ans;
}
void print(int i,int j,int l)
{
	if(l==0)
		return;
	if(i==n||j==m)
		return ;
	if(a[i]==b[j]&&solve(i,j)==l)
	{
		cout<<a[i];
		print(i+1,j+1,l-1);
		return ;
	}
	if(solve(i+1,j)==l)
	{
		print(i+1,j,l);
	}
	else
	{
		print(i,j+1,l);
	}
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   cin>>a>>b;
   n=a.size();
   m=b.size();
   memset(dp,-1,sizeof(dp));
   int l=solve(0,0);
   if(l==0)
   {
   	return 0;
   }
   print(0,0,l);
}                       

Measured memory_bytes: 71168
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[100000];
int w[100000];

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

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


	int s = 0;
	rep(i, n ) {
		if (i & 1)s -= a[i];
		else s += a[i];
	}

	w[0] = s;
	for (int i = 0; i < n - 1; i++) {
		w[i + 1] = (a[i] - w[i] / 2) * 2;
	}


	cout << w[0];
	rep(i, n - 1)cout << ' ' << w[i + 1];
	cout << endl;




	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<limits.h>

int main(){
  int n;
  int i;
  long max = LONG_MIN;
  long min = LONG_MAX;
  long sum = 0;
  int num;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &num);

    if(num < min){
      min = num;
    }

    if(num > max){
      max = num;
    }

    sum += num;
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;
int x;
 
int get_pow(int k){
	return (int) pow(k,5);
}
 
bool check(int k){
	int y = (int) pow((ld) k, 0.2);
	int z = pow(y,5);
	// cout<<y<<" "<<z<<" "<<k<<"\n";
	return k==z;
}
signed main(){
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 
 
 
	cin>>x;

	for(int i=0;i<=3000;i++){
		int b = get_pow(i);
		if (check(x+b)){
			cout<<(int) pow((ld) x+b ,0.2)<<" "<<i<<"\n";
			return 0;
		}
		if (check(x-b)){
			cout<<(int) pow((ld) x-b ,0.2)<<" "<<-i<<"\n";
			return 0;
		}
	}
 
	return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
const int N = -1;
const long long INF = 1e9 + 19;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


void ret(bool flag) {
    if (flag) 
        puts("YES");
    else
        puts("NO");
    exit(0);
}

void read() {
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    ll sum = 0;
    for (auto x: a)
        sum += x;
    ll step = (n + 1) * 1ll * n / 2;
    if (sum % step != 0) {
        ret(0);
    }
    ll k = sum / step;
    vector<ll> diff(n);
    for (int i = 0; i < n; i++)
        diff[i] = (a[(i + 1) % n] - a[i]) - k;

    
    ll ss = 0;
    for (int i = 0; i < n; i++)  {
        if (diff[i] % n != 0 || diff[i] > 0)
            ret(0);
        ss += diff[i] / n;
    }
    if (ss != -k)
        ret(0);
    assert(ss == -k);
     
    ret(1);
}

void solve() {

}

void stress() {

}

int main(){
#ifdef HOME 
    freopen("in", "r", stdin);
#endif
    if (1) {
        read();
        solve();
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
inline int power(int a, int b) {
    long long res = a, ans = 1;
    for (; b; b >>= 1, res = res * res % mod) if (b & 1) ans = ans * res % mod;
    return ans;
}
struct edge {
    int v, nxt;
} e[10010];
int head[5010], tot;
inline void addedge(int u, int v) {
    e[++tot] = edge{v, head[u]};
    head[u] = tot;
}
int cnt[5010];
int dp[5010][5010], sze[5010], tmp[5010];
inline void dfs(int now, int fa) {
    sze[now] = 1;
    dp[now][1] = 1;
    for (int i = head[now]; i; i = e[i].nxt) {
        if (e[i].v == fa) continue;
        dfs(e[i].v, now);
        memset(tmp, 0, sizeof(int[sze[now] + sze[e[i].v] + 1]));
        for (int j = sze[now] & 1; j <= sze[now]; j += 2)
            for (int k = sze[e[i].v] & 1; k <= sze[e[i].v]; k += 2) tmp[j + k] = (tmp[j + k] + 1ll * dp[now][j] * dp[e[i].v][k]) % mod;
        sze[now] += sze[e[i].v];
        for (int j = 0; j <= sze[now]; j++) dp[now][j] = tmp[j];
    }
    if (sze[now] % 2 == 0) {
        for (int i = 2; i <= sze[now]; i += 2) dp[now][0] = (dp[now][0] - 1ll * cnt[i] * dp[now][i] % mod + mod) % mod;
    }
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        addedge(u, v);
        addedge(v, u);
    }
    cnt[0] = 1;
    for (int i = 2; i <= n; i += 2) {
        cnt[i] = 1ll * cnt[i - 2] * (i - 1) % mod;
    }
    dfs(1, 0);
    return cout << (mod - dp[1][0]) % mod << endl, 0;
}

Measured memory_bytes: 97024