akhauriyash/Code-Regression huggingface dataset:
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
//oh,i is a enlish men!!!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = int;
void init_io()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(18);
}
ll n,k,ans=0;
void solve_dp(const vector<ll> &a,vector<vector<bool>> &dp){
  dp[0][0] = true;
  for(int i=0;i<n;i++){
    for(int j=0;j<k;j++){
      dp[i+1][j] = dp[i+1][j] | dp[i][j];
      int x = min(k,j+a[i]);
      if(x<k){
        dp[i+1][x] = dp[i+1][x] | dp[i][j];
      }
    }
  }
}
signed main(){
  init_io();
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  const ll INF = 2e9;
  vector<vector<bool>> dp1(n+1,vector<bool>(k+1,false));
  vector<vector<bool>> dp2(n+1,vector<bool>(k+1,false));
  vector<ll> d1,d2;
  solve_dp(a,dp1);
  reverse(a.begin(),a.end());
  solve_dp(a,dp2);
  for(int i=0;i<n;i++){
    bool no_need = true;
    for(int j=0;j<k;j++){
      if(dp1[n-1-i][j]){
        d1.push_back(j);
      }
      if(dp2[i][j]){
        d2.push_back(j);
      }
    }
    d2.push_back(INF);
    for(auto j:d1){
      ll mi = max(0,k-a[i]-j);
      auto itr = lower_bound(d2.begin(),d2.end(),mi);
      if(*itr+j<k){
        no_need = false;
      }
    }
    if(no_need){
      ans++;
    }
    d1.clear();
    d2.clear();
  }
  cout << ans << endl;
}//@奆奆的蒟蒻  做


Measured memory_bytes: 7040
N, M = map(int, input().split())
H = list(map(int, input().split()))
H_ans = [1] * N

for _ in range(M):
    A, B = map(int, input().split())
    if H[A - 1] == H[B - 1]:
        H_ans[A - 1] = 0
        H_ans[B - 1] = 0
    elif H[A - 1] > H[B - 1]:
        H_ans[B - 1] = 0
    else:
        H_ans[A - 1] = 0

ans = H_ans.count(1)

print(ans)

Measured memory_bytes: 20044
def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]

  result = 0
  for i in range(1, N):
    if A[i-1] > A[i]:
      result += A[i-1] - A[i]
      A[i] = A[i-1]
  print(result)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 92924
/*
* @Author: dnhirapara
* @Date: 2020-04-25 23:49
* @Name: dp_d
*/
//see this : https://github.com/Errichto/youtube/blob/master/atcoder-dp/d.cpp --> O(n) space code
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, w, x, y;
    cin>>n>>w;
    ll dp[n+2][w+2]={0};
    memset(dp,0,sizeof(dp));
    std::vector< pair<ll,ll> > a(n+2);
    a[0]=  make_pair(0,0);
    for(ll i=1;i<=n;i++){
        cin>>x>>y;
        a[i]=make_pair(x,y);
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(a[i].first<=j){
                dp[i][j] = max(dp[i-1][j-a[i].first]+a[i].second,dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
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; }
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n;
cin >> n;
vector<int>c(n);
vector<pair<double,double>>a(n);
int zzz = 1;
for(int i=0;i<n;i++){
    c.at(i)=i;
    double z,zz;
    zzz*=i+1;
    cin >> z >> zz;
    a.at(i)=make_pair(z,zz);
}
double ans = 0;
for(int i=0;i<zzz;i++){
    for(int j=1;j<n;j++){
        double z = pow((a.at(c.at(j-1)).first-a.at(c.at(j)).first),2);
        double dd = pow((a.at(c.at(j-1)).second-a.at(c.at(j)).second),2);
        double che = pow((z+dd),0.5);
        ans+=che;
    }
   next_permutation(c.begin(), c.end());
}
ans/=double(zzz);
cout << fixed << setprecision(10);
cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#define mx 1002
char ar[mx][mx];
ll P = 7+1e9;
ll dp[mx][mx];
ll r,c;
ll dx[] = {1,0};
ll dy[] = {0,1};

bool check(ll x,ll y){
    if(x<0 || x==r || y<0 || y==c)  return false;
    if(ar[x][y]=='#')   return false;
    return true;
}

ll fn(ll x,ll y){
    if(x==r-1 && y==c-1)    return 1;

    ll &ans = dp[x][y];
    if(ans!=-1) return ans;
    ans = 0;
    for(ll i = 0; i<2; i++){
        ll nx = x+dx[i],   ny = dy[i]+y;
        if(!check(nx,ny))   continue;
        ans=(ans+fn(nx,ny))%P;
    }
    return ans;
}

int main(){
int t,tc = 0;
scanf("%lld%lld",&r,&c);

for(ll i = 0; i<r; i++) for(ll j = 0; j<c; j++)     scanf(" %c",&ar[i][j]);

memset(dp,-1,sizeof dp);
ll ans = fn(0,0);
printf("%lld\n",ans);

return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 
 
signed main() {
	fio();
	ll a, b, c;
	cin >> a >> b >> c;
	
	if (a + b - c >= 0) {
		cout << "No" << endl;
		return 0;
	}
	if ((c - a - b) * (c - a - b) > 4 * a * b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL solve(LL P, int N) {
	LL res = 0;
	for (LL i = 0; i < N; ++i) {
		if (((P & (1LL << (N - 1 - i))) > 0) ^ (res % 2 > 0)) {
			res = (1LL << (i + 1)) - 1 - res;
		}
	}
	return res;
}

int main() {
	LL N, A, B;
	while (cin >> N >> A >> B, N) {
		LL P = solve((1LL << N) - A , N);
		LL Q = B - 1;
		LL R = P ^ Q;
		string str;
		for (LL i = 0; i < N; ++i) {
			if (R & (1LL << i)) {
				str.push_back('L');
			}
			else {
				str.push_back('R');
			}
		}
		reverse(str.begin(), str.end());
		cout << str << endl;
	}
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> H(N+1);
  H[0] = 0;
  for( int i = 1; i <= N; ++i){
    cin >> H[i];
  }
  

  for( int i = 1; i < N; ++i){
    if( H[i-1] != H[i] ){
      --H[i];
    }
    if( H[i] > H[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    int x; cin >> x;

    if (x < 600) {
        cout << 8 << endl;
    }
    else if (x < 800) {
        cout << 7 << endl;
    }

    else if (x < 1000) {
        cout << 6 << endl;
    }

    else if (x < 1200) {
        cout << 5 << endl;
    }

    else if (x < 1400) {
        cout << 4 << endl;
    }

    else if (x < 1600) {
        cout << 3 << endl;
    }

    else if (x < 1800) {
        cout << 2 << endl;
    }

    else if (x < 2000) {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main()
{	
	int n;
	cin >> n;
	V<int> a(n);

	RNG(i, 1, n + 1) {
		int k = 2 * i;
		int p = 0;
		int z = 1;
		while (k - z * z > 0) {
			int c = k - z * z;
			int y = 1;
			while (c - y * y > 0) {
				int b = c - y * y;
				int x = sqrt(b) - 1;
				REP(j, 3) {
					if (x * x == b && x>0) {
						int x2 = x - y + z;
						int y2 = x + y - z;
						int z2 = -x + y + z;
						if (x2 % 2 || y2 % 2 || z2 % 2) continue;
						x2 /= 2;
						y2 /= 2;
						z2 /= 2;
						if (x2 < 1 || y2 < 1 || z2 < 1) continue;

						p += 1;
						break;
					}
					x++;
				}
				y++;
			}
			z++;
		}
		col(p);
	}

	return 0;
}


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


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

  vector<int> x(N);
  vector<int> y(M);

  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  int hantei;
  for(int i = 0; i < M; i++){
    cin >> y[i];
  }
for(int i = X + 1; i <= Y; i++){
  hantei = 1;
  for(int j = 0; j < N; j++){
    if(x[j] >= i){ hantei = 0; break;}
  }
    for(int k = 0; k < M; k++){
      if(y[k] < i){ hantei = 0; break; }
    }
   
    if(hantei == 1){ cout << "No War" << endl; return 0; }
  
}

cout << "War" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{   string s;
int  i,l,max=0,c=0;
cin>>s;
l=s.length();
for(i=0;i<l;i++){
    if(s[i]=='R')
        c++;
    else if(c>max){
        max=c;
        c=0;
    }
}
if(c>max)
    max=c;
cout<<max;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if a >= b {
		fmt.Println("delicious")
		return
	}
	if b-a <= x {
		fmt.Println("safe")
		return
	}
	fmt.Println("dangerous")
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>

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

using namespace std;


int main() {
    ll n, k;
    cin >> n >> k;
    ll count = 0;
    ll tmp1 = n / k;
    count += tmp1 * tmp1 * tmp1;
    if(k % 2 == 0) {
        ll tmp2 = (n + k / 2)/ k;
        count += tmp2 * tmp2 * tmp2;
    }
    cout << count<< endl;
    return 0;
}



Measured memory_bytes: 256
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>
# include <map>
# include <set>


#define ll long long

using namespace std;


long long modular(long long base, long long exp, int mod) {
    if(mod==1) return 0;
    long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    int N;
    string x;
    cin >> N;
    cin >> x;
    int ct = 0;
    
    
    
    for(int i = 0; i < N; i++){
        ct += (x[i]=='1');
    }
    
    ll int ansmin = 0;

    if(ct!=1){
        for(int i = 0; i < N; i++){
            ansmin += (x[i] == '1') * modular(2, N-1-i, ct-1);
            ansmin %= ct-1;
        }
        
        
    }
    
    ll int ansmax = 0;
    for(int i = 0; i < N; i++){
        ansmax += (x[i] == '1') * modular(2, N-1-i, ct+1);
        ansmax %= ct + 1;
    }
    
    //cout << ansmin << ansmax << endl;

    
    for(int i = 0; i < N; i++){
        long long int next;
        //string s = x;
        if(x[i] == '1'){
            if(ct==1){
                cout << "0\n";
                continue;
            }
            next = (ansmin - modular(2, N-1-i, ct-1)+ct-1)%(ct-1);
            //s[i] = '0';
        }
        else{
            next = (ansmax + modular(2, N-1-i, ct+1)+ct+1)%(ct+1);

            //s[i] = '1';
        }
        int ct = 1;
        while(next){
            ct++;
            next = next % __builtin_popcount(next);
        }
        
        cout << ct << "\n";
        
        
        
        
        
        
    }
   
    
    
    
    
    
    
    
    
    
    
}


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

using namespace std;

int main() {
    int W, H, x, y;
    
    scanf("%d%d%d%d", &W, &H, &x, &y);
    printf("%lf %d\n", double(W)*double(H) / 2, x + x == W && y + y == H);
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}
trait Monoid {
    fn unit() -> Self;
    fn add(lhs: Self, rhs: Self) -> Self;
}

struct SegTree<T: Monoid + Clone> {
    dat: Vec<T>,
    n: usize,
}

impl<T: Monoid + Copy> SegTree<T> {
    pub fn new(n: usize) -> Self {
        let dat = vec![T::unit(); n << 1];
        SegTree { dat: dat, n: n }
    }
    pub fn update(&mut self, k: usize, v: T) {
        let mut k = k + self.n;
        self.dat[k] = v;
        while {
            k >>= 1;
            k > 0
        } {
            self.dat[k] = T::add(self.dat[k << 1], self.dat[k << 1 | 1]);
        }
    }
    pub fn get(&self, a: usize, b: usize) -> T {
        let mut a = a + self.n;
        let mut b = b + self.n;
        let mut va = T::unit();
        let mut vb = T::unit();
        while a < b {
            if a & 1 != 0 {
                va = T::add(va, self.dat[a]);
                a += 1;
            }
            if b & 1 != 0 {
                vb = T::add(self.dat[b - 1], vb);
            }
            a >>= 1;
            b >>= 1;
        }
        T::add(va, vb)
    }
}

impl Monoid for usize {
    fn unit() -> Self {
        Default::default()
    }
    fn add(lhs: Self, rhs: Self) -> Self {
        std::cmp::max(lhs, rhs)
    }
}

const MOD: usize = 998244353;

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let mut xd: Vec<(i64, i64)> = (0..n).map(|_| parse!(it, 2)).collect();
    xd.sort();
    let mut rv = vec![0; n];
    let mut seg = SegTree::<usize>::new(n);
    for i in (0..n).rev() {
        let r = xd
            .binary_search_by_key(&(xd[i].0 + xd[i].1), |x| x.0)
            .unwrap_or_else(|x| x);
        let v = seg.get(i, r);
        let v = std::cmp::max(i, v);
        rv[i] = v;
        seg.update(i, v)
    }

    let mut dp0 = vec![0; n + 1];
    let mut dp1 = vec![0; n + 1];
    dp0[n] = 1;
    for i in (0..n).rev() {
        dp0[i] = (dp0[i + 1] + dp1[i + 1]) % MOD;
        let j = rv[i];
        dp1[i] = if i == j { dp0[i] } else { dp1[j] };
        dp1[i] %= MOD;
    }
    println!("{}", (dp0[0] + dp1[0]) % MOD);
}


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

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

		for(int i=0 ; i < n ; i++ ){
			cin >> a;
			if( m.count(a) ){
				m[a] += 1;
			}else{
				m[a] = 1;
			}
		}

		int ans=-1;
		for(map<int,int>::iterator it = m.begin() ; it != m.end() ; ++it ){
			if( it->second > n/2 ){
				ans = it->first;
			}
		}
		if( ans == -1 ){
			cout << "NO COLOR" << endl;
		}else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	for(auto& p: mp) {
		if(p.se&1) {
			cout <<"NO" <<endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


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

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

#define MAXN 100001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FAIL {printf("-1\n"); return 0;}

int N, M;
LL A[MAXN];

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);

    scanf("%d %d", &N, &M);
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &A[i]);
        A[i] += A[i - 1];
    }

    map<int, int> cnt;
    cnt[0] = 1;
    LL ans = 0;
    for (int i = 1; i <= N; i++) {
        int r = A[i] % M;
        ans += cnt[r];
        cnt[r]++;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    string S,T;
    cin >> N >> S >> T;
    int ans = 0;
    REP(i,N){
        if(S[i] == T[0]){
            string s = S.substr(i,N-i);
            string t = T.substr(0,N-i);
            if(s == t){
                chmax(ans,N-i);
            }
        }
    }
    cout << (2*N-ans) << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,int> PDI;
typedef pair<LL,LL> PLL;
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const LL inf=1e18;
const double pi=acos(-1.0);
const int mod=123456789;
const int N=1e6;
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//template <class T> inline bool scan_d(T &ret) { char c; int sgn; if(c=getchar(),c==EOF) return 0; while(c!='-'&&(c<'0'||c>'9')) c=getchar();    sgn=(c=='-')?-1:1;    ret=(c=='-')?0:(c-'0');    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; }
//void ADD(LL &a,LL b) {a=(a+b)%mod;}

int main()
{
//    freopen("3.in", "r", stdin);
//    freopen("WA.txt", "w", stdout);
    string s,t="FESTIVAL";
    cin>>s;
    int n=SZ(s);
    cout<<s.substr(0,n-8)<<endl;
    return 0;
}
/*
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  double p=n/2+n%2;
  pd(p/n);
}

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


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    h,w = LI()
    a = [sys.stdin.readline() for i in range(h)]
    s = 0
    p = [None for i in range(w*h)]
    q = [None for j in range(w*h)]
    l = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                p[s] = (i,j)
                s += 1
            else:
                q[l] = (i,j)
                l += 1
    if s == h*w:
        print(0)
        quit()
    ans = 0
    M = w*h
    for i,j in q[:h*w-s]:
        m = M
        for x,y in p[:s]:
            if abs(i-x)+abs(j-y) < m:
                m = abs(i-x)+abs(j-y)
        if m > ans:
            ans = m
    print(ans)
    return

#B
def B():
    h,w,n = LI()
    sy,sx = LI()
    sy -= 1
    sx -= 1
    s = S()
    t = S()
    ks = list("LRUD")
    kt = list("RLDU")
    ds = [[0,-1],[0,1],[-1,0],[1,0]]
    dt = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in range(4):
        y,x = [sy,sx]
        for j in range(n):
            if s[j] == ks[i]:
                y+=ds[i][0]
                x+=ds[i][1]
                if y < 0 or y >= h or x < 0 or x >= w:
                    print("NO")
                    quit()
            if t[j] == kt[i]:
                y += dt[i][0]
                x += dt[i][1]
                if y < 0:y = 0
                elif y >= h:y = h-1
                elif x < 0:x=0
                elif x >= w:x=w-1
    print("YES")
    return

#C
def C():
    n = I()
    return

#D
def D():
    n = I()
    return

#E
def E():
    n = I()
    return

#F
def F():
    n = I()
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 73044
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <map>
using namespace std;

struct Edge {
    int src,dst,cost;
    Edge(int s,int d,int c) : src(s), dst(d), cost(c) {;}
};
bool operator<(const Edge &e,const Edge &f) {
    return e.cost != f.cost ? e.cost > f.cost : e.src < f.src;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int dijkstra(const Graph &g,int s,int d) {
    const int n = g.size();
    vector<int> dist(n,-1);
    priority_queue<Edge> q;
    q.push(Edge(-2,s,0));

    while(!q.empty()) {
        Edge e = q.top(); q.pop();
        if(dist[e.dst] != -1) continue;
        dist[e.dst] = e.cost;

        for(int i=0; i<g[e.dst].size(); ++i) {
            if(dist[g[e.dst][i].dst] == -1) {
                q.push(Edge(e.dst,g[e.dst][i].dst,e.cost+g[e.dst][i].cost));
            }
        }
    }
    return dist[d];
}

int main() {
    int n,m,d,t;
    string s,p,g,a,b;
    while(cin>>n>>m, n|m) {
        map<string,int> idx;
        cin>>s>>p>>g;
        idx[s] = 0; idx[p] = 1; idx[g] = 2;
        int cnt = 3;

        Graph g(n);
        for(int i=0; i<m; ++i) {
            cin>>a>>b>>d>>t;
            if(idx.find(a) == idx.end()) idx[a] = cnt++;
            if(idx.find(b) == idx.end()) idx[b] = cnt++;
            g[idx[a]].push_back(Edge(idx[a],idx[b],d/40+t));
            g[idx[b]].push_back(Edge(idx[b],idx[a],d/40+t));
        }

        int ans = dijkstra(g,0,1) + dijkstra(g,1,2);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
  ll a;string s;
  cin>>a>>s;
  if(a<3200)
    cout<<"red";
  else
    cout<<s;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 301000
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	if (flag)	x = -x;
}
using namespace std;
int n, Rt;
int cnt[N];
int fa1[N], fa2[N];
struct edge{
	int nxt, to;
}e[N << 1];
int head[N], ecnt = 1;
inline void addedge(int from, int to) {
//	printf("%d -> %d\n", from, to);
	e[++ecnt] = (edge){head[from], to};
	head[from] = ecnt;
}

int blong[N];
bool evis[N << 1], etype[N << 1];
void dfs(int cur) {
	for (int &i = head[cur]; i; i = e[i].nxt) {
		if (evis[i])	continue;
		evis[i] = evis[i ^ 1] = true;
		etype[i] = true;
		int to = e[i].to; dfs(to);
	}
}

int main() {
	read(n); Rt = n + n + 1;
//	printf("Rt = %d\n", Rt);
	for (int i = 1; i <= n; ++i) {
		read(fa1[i]);
		if (fa1[i] == -1)	fa1[i] = Rt;//, printf("Attention!!! : fa1[%d] = %d\n", i, fa1[i]);
		addedge(fa1[i], i); addedge(i, fa1[i]);
		++cnt[fa1[i]];
//		printf("fa1[%d] = %d\n", i, fa1[i]);
	}
	for (int i = 1; i <= n; ++i) {
		read(fa2[i]);
		if (fa2[i] == -1)	fa2[i] = Rt;
		else	fa2[i] += n;
		addedge(fa2[i], i + n); addedge(i + n, fa2[i]);
		++cnt[fa2[i]];
//		printf("fa2[%d] = %d\n", i, fa2[i]);
	}
	for (int i = 1; i <= n; ++i) {
		if ((cnt[i] & 1) != (cnt[i + n] & 1)) {
			puts("IMPOSSIBLE");
			return 0;
		}
		if (!(cnt[i] & 1))
			addedge(i, i + n), blong[i] = ecnt, addedge(i + n, i);
	}
	puts("POSSIBLE");
	dfs(1);
	for (int i = 1; i <= n; ++i) {
		if (cnt[i] & 1)	printf("0 ");
		else	printf("%d ", etype[blong[i]] ? 1 : -1);
//		printf("(cnt[%d] = %d)\n", i, cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 16020
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<vector<int> > book(2, vector<int>(m));
    for(int i=0; i<m; ++i)
        cin >> book[0][i] >> book[1][i];
    for(int i=1; i<m; ++i){
        book[0][i] += book[0][i-1];
        book[1][i] += book[1][i-1];
    }

    vector<vector<int> > shelf(2, vector<int>(n));
    for(int i=0; i<n; ++i)
        cin >> shelf[0][i] >> shelf[1][i];

    vector<int> dp(1<<n, 0);
    for(int i=0; i<(1<<n); ++i){
        bitset<15> bs(i);
        for(int j=0; j<n; ++j){
            if(bs[j])
                continue;
            bs[j] = true;

            int next = m;
            for(int k=0; k<2; ++k){
                int base = 0;
                if(dp[i] > 0)
                    base = book[k][dp[i]-1];
                int tmp = upper_bound(book[k].begin(), book[k].end(), base + shelf[k][j]) - book[k].begin();
                next = min(next, tmp);
            }
            dp[bs.to_ulong()] = max(dp[bs.to_ulong()], next);

            bs[j] = false;
        }
    }
    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 5148
#include<stdio.h>

int main(void)
{
	int g = 0, c = 0, p = 0, n, i, a[5];
	while (scanf("%d", &n))
	{
		if (n == 0)
		{
			break;
		}
		a[0] = n;
		if (n == 1)
		{
			g++;
		}
		if (n == 2)
		{
			c++;
		}
		if (n == 3)
		{
			p++;
		}
		for (i = 1;i < 5;i++)
		{
			scanf("%d", &n);
			a[i] = n;
			if (n == 1)
			{
				g++;
			}
			if (n == 2)
			{
				c++;
			}
			if (n == 3)
			{
				p++;
			}
		}

		if (g == 5 || c == 5 || p == 5)
		{
			for (i = 0;i < 5;i++)
			{
				a[i] = 3;
				printf("%d\n",a[i]);
			}
		}
		else if(g == 0 || c == 0 || p == 0)
		{
			if (g > 0 && c > 0)
			{
				for (i = 0;i < 5;i++)
				{
					printf("%d\n", a[i]);
				}
			}
			else if (c > 0 && p > 0)
			{
				for (i = 0;i < 5;i++)
				{
					if (a[i] == 2)
					{
						printf("1\n");
					}
					else
					{
						printf("2\n");
					}
				}
			}
			else if (p > 0 && g > 0)
			{
				for (i = 0;i < 5;i++)
				{
					if (a[i] == 3)
					{
						printf("1\n");
					}
					else
					{
						printf("2\n");
					}
				}
			}
		}
		else
		{
			for (i = 0;i < 5;i++)
			{
				a[i] = 3;
				printf("%d\n", a[i]);
			}
		}
		g = 0;c = 0;p = 0;
	}
}

Measured memory_bytes: 612
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
string s;
int n;
int main(){
	cin>>s;
	n=s.size();
	if(n%2==1)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<n-1;i+=2)
		if(s[i]!='h'||s[i+1]!='i')
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp2
{
    class Program {
        static void Main(string[] Args) {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            dictionary.Add("A", "T");
            dictionary.Add("T", "A");
            dictionary.Add("C", "G");
            dictionary.Add("G", "C");

            WriteLine(dictionary[ReadLine()]);

            ReadLine();
        }
    }
}


Measured memory_bytes: 13152
#include<iostream>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
    int N; cin >> N;
    rep(i, 3){
        int a = N%10;
        N /= 10;
        if(a == 7){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll n,x,d;
ll ans=0,f[N],sum[N];
int main()
{
    scanf("%lld%lld%lld",&n,&x,&d);
    if(x==0&&d==0)
    {
        cout<<1<<endl;return 0;
    }
    if(x<0&&d<0)
        x*=-1,d*=-1;
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+i-1;
    ll k=__gcd(x,d),xx=x/k,dd=d/k;
    if(xx>=0&&dd>=0)
    {
        for(int i=0;i<=n;i++)
        {
            ll l=sum[i],r=sum[n]-sum[n-i];
            if(l>r) swap(l,r);
            ans+=r-l+1;
            if(i+dd<=n)
            {
                ans-=max(0ll,r-sum[i+dd]-xx+1);
            }
        }
    }
    else
    {
        if(xx<0) xx*=-1;
        if(dd<0) dd*=-1;
        for(int i=0;i<=n;i++)
        {
            ll l=sum[i],r=sum[n]-sum[n-i];
            if(l>r) swap(l,r);
            ans+=r-l+1;
            if(i+dd<=n)
            {
                r=min(r,sum[n]-sum[n-i-dd]-xx);
                l=max(l,sum[i+dd]-xx);
                ans-=max(0ll,r-l+1);
            }
        }
    }
    printf("%lld\n",ans);
}


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

int main(){
  int n;
int a,b,c,d;
  cin >>n;
      d=n%10;
  n=n/10;
  c=n%10;
  n=n/10;
  b=n%10;
  n=n/10;
  a=n;
  int ans=0;
while(1){
  int ans1=a+b+c+d;
   int ans2=a+b+c-d;
   int ans3=a+b-c+d;
   int ans4=a-b+c+d;
   int ans5=a+b-c-d;
   int ans6=a-b+c-d;
   int ans7=a-b-c+d; 
  int ans8=a-b-c-d;
if(ans1==7){
cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
  break;
}
  if(ans2==7){
cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
  break;
}
  if(ans3==7){
cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
  break;
}
  if(ans4==7){
cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
  break;
}
  if(ans5==7){
cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
  break;
}
  if(ans6==7){
cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
  break;
}
  if(ans7==7){
cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
  break;
}
  if(ans8==7){
cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
  break;
}

break;
}
  

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#pragma warning (disable: 4996)
 
int N, A[1 << 18], C[3];
long long sum = 1;
 
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
 
	for (int i = 1; i <= N; i++) {
		long long cnt = 0, id = -1;
		if (A[i] == C[0]) { cnt++; id = 0; }
		if (A[i] == C[1]) { cnt++; id = 1; }
		if (A[i] == C[2]) { cnt++; id = 2; }
		if (id == -1) {
			cout << "0" << endl;
			return 0;
		}
		sum *= cnt; C[id]++;
		sum %= 1000000007;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
import os
import math

# adjacent list
M = []
for i in range(105):
    M.append([])

def solve(M):
    odd_num = 0
    even_num = 0

    for m in M:
        if len(m) % 2 == 0:
            even_num += 1
        else:
            odd_num += 1

    # semi-Eulerlian graph
    if odd_num == 2 and len(M[0]) % 2 == 1 and len(M[1]) % 2 == 1:
        print('OK')
    else:
        print('NG')

for s in sys.stdin:
    a, b = map(int, s.split())
    if a == b == 0:
        solve(M)

        # reset
        M = []
        for i in range(105):
            M.append([])
    else:
        a -= 1
        b -= 1
        M[a].append(b)
        M[b].append(a)

Measured memory_bytes: 7728
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++) {
	  cin >> A[i];
	}
  vector <int> ans(N);
  ans[0] = A[0];
  for (int i = 1; i < N; i++) {
	  if (i % 2 == 1) {
		  ans[0] -= A[i];
		}
	  else {
		  ans[0] += A[i];
		}
	}
  for (int i = 1; i < N; i++) {
	  ans[i] =  2 * A[i - 1] - ans[i - 1];
	}
  for (int i = 0; i < N - 1; i++) {
	  cout << ans[i] << " ";
	}
  cout << ans[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 int a[N];
  
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  
  int now, c,x=0;
  now=1, c=0;
  
  for (int i=0; i<N; i++)
  {
    now = a[x];
    x=now-1;
    c++;
    
    if (now==2)
    {
      cout << c << endl;
      break;
     }
  }
  
  
  if (now!=2)
  {
    cout << -1 << endl;
  }

}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int n;
    cin >> n;
    int a[n];
    double sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=1.0/a[i];
    }
    double ans=1.0/sum;
    cout << ans;
       
    

return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int count[N]={0};
	for (int i=0; i<K; i++){
	    int D;
	    cin >> D;
	    int A[D];
	    for (int i=0; i<D; i++){
	        cin >> A[i];
	        count[A[i]-1]++;
	    }
	}
	int ans=0;
	for (int i=0; i<N; i++){
	    if (count[i]==0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<char, int>> RLE;
    if (s[0] == '0') RLE.emplace_back('1', 0);
    RLE.emplace_back(s[0], 1);
    srep(i, s.length(), 1) {
        if (RLE.back().fi != s[i]) RLE.emplace_back(s[i], 1);
        else RLE.back().se++;
    }
    if (RLE.back().fi == '0') RLE.emplace_back('1', 0);

    int sz = RLE.size();
    vint sum(sz);
    sum[0] = RLE[0].se;
    srep(i, sz, 1) {
        sum[i] = sum[i-1] + RLE[i].se;
    }
    int ans = 0;
    if (sz/2 < k) {
        cout << sum[sz-1] << endl;
        return 0;
    } 
    for (int i = 0; i+(k*2) < sz; i+=2) {
        if (i-1 < 0) ans = max(ans, sum[i+(k*2)]);
        else ans = max(ans, sum[i+(k*2)] - sum[i-1]);
    }

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

Measured memory_bytes: 1652
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

vector<int> g[200005];
ll val[200005];

void dfs(int p, int c, ll sum){
  val[c]+=sum;
  for(auto i : g[c]){
      if(i!=p){
      dfs(c,i,val[c]);
    }
  }
}


int main(){
  int n,q;
  cin>>n>>q;
  for(int i = 0;i < n-1; i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i = 0; i < q; i++){
    int p,x;
    cin>>p>>x;
    p--;
    val[p]+=x;
  }
  dfs(-1,0,0);

  for(int i = 0; i < n; i++){
    cout<<val[i]<<" ";
  }
  cout<<endl;
  return 0;
}

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

using namespace std;

const int MOD = int(1e9) + 7;

using lint = long long;

const int N_ = 3050;

int N, Q;
int A[N_];
int X[N_], Y[N_];

int ways[N_][N_];
int lazy[N_];

lint P2 = 1, PINV2 = 1;

void set_ways(int i, int j, long long v) {
  ways[i][j] = v * PINV2 % MOD;
}

lint get_ways (int i, int j) {
  return ways[i][j] * P2 % MOD;
}

int main() {
#ifdef IN_MY_COMPUTER
  freopen("example.in", "r", stdin);
#endif

  //for(int i = 1; i < N_; i++) assert(1L * pow2[i] * pow2[-i] % MOD == 1);

  scanf("%d%d", &N, &Q);
  for(int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  for(int q = 1; q <= Q; q++) {
    int x, y; scanf("%d%d", &x, &y);
    if(x > y) swap(x, y);
    X[q] = x; Y[q] = y;
  }

  for(int i = 1; i <= N; i++) {
    for(int j = 1; j < i; j++) {
      ways[i][j] = 1;
    }
  }

  for(int q = Q; q > 0; q--) {
    int x = X[q], y = Y[q];
    vector<tuple<int, int, long long>> updates;
    for(int i = 1; i <= N; i++) {
      lint cur = get_ways(i, x) + get_ways(i, y);
      updates.emplace_back(i, x, cur);
      updates.emplace_back(i, y, cur);
    }
    for(int j = 1; j <= N; j++) {
      lint cur = get_ways(x, j) + get_ways(y, j);
      updates.emplace_back(x, j, cur);
      updates.emplace_back(y, j, cur);
    }
    {
      lint cur = get_ways(x, y) + get_ways(y, x);
      updates.emplace_back(x, y, cur);
      updates.emplace_back(y, x, cur);
    }

    P2 = P2 * 2L % MOD;
    PINV2 = PINV2 * 500000004L % MOD;

    for(auto it : updates) {
      int i, j; lint v;
      tie(i, j, v) = it;
      set_ways(i, j, v % MOD);
    }
  }

  lint ans = 0;
  for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
    if(A[i] < A[j]) (ans += get_ways(i, j)) %= MOD;
  }

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

Measured memory_bytes: 36544
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int x,y,a,b,c;
int q[N],p[N],r[N];
priority_queue<int,vector<int>,greater<int> >A,B;
bool cmp(int X,int Y) {
	return X>Y;
}
int main()
{
	//cwk;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;i++) scanf("%d",&p[i]);
	for(int i=1;i<=b;i++) scanf("%d",&q[i]);
	for(int i=1;i<=c;i++) scanf("%d",&r[i]);
	sort(p+1,p+a+1,cmp);
	sort(q+1,q+b+1,cmp);
	sort(r+1,r+c+1,cmp);
	ll ans=0;
	for(int i=1;i<=x;i++) A.push(p[i]),ans+=p[i];
	for(int i=1;i<=y;i++) B.push(q[i]),ans+=q[i];
	for(int i=1;i<=c;i++) {
		int v1=A.top(),v2=B.top();
		if(r[i]<=v1&&r[i]<=v2) {
			break;
		}
		if(v1<=v2) {
			ans-=v1;
			A.pop();
			A.push(r[i]);
			ans+=r[i];
		}else {
			ans-=v2;
			B.pop();
			B.push(r[i]);
			ans+=r[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

  int ans = 0;
  int cnt;
  for (int i = 1; i <= n; i+=2)
  {
    cnt = 0;
    for (int j = 1; j <= i; j++)
    {
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        char[] S = scan.next().toCharArray();
        char[] T = scan.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i] != T[i]) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 42236