akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

string str;

string t[8][4]={
  {"black","00","00","00"},
  {"blue","00","00","ff"},
  {"lime","00","ff","00"},
  {"aqua","00","ff","ff"},
  {"red","ff","00","00"},
  {"fuchsia","ff","00","ff"},
  {"yellow","ff","ff","00"},
  {"white","ff","ff","ff"}
};



int c2i(char ch){
  if('0'<=ch&&ch<='9')return ch-'0';
  return 10+ch-'a';
}

int cc2i(char ch,char ch2){
  return c2i(ch)*16+c2i(ch2);
}

int s2i(string str){
  return cc2i(str[0],str[1]);
}

int pow(int x){
  return x*x;
}

int main(){
  int a,mini,mini_no;
  while(cin>>str){
    if(str=="0")break;
    mini=9999999;
    for(int i=0;i<8;i++){
      a=pow( cc2i(str[1],str[2]) - s2i(t[i][1]) ); 
      a+=pow(cc2i(str[3],str[4]) - s2i(t[i][2]) );
      a+=pow(cc2i(str[5],str[6]) - s2i(t[i][3]) ); 
      if(a<mini){
	mini=a;
	mini_no=i;
      }
    }
    cout<<t[mini_no][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
abcd = input()

plmi = ['+', '-']
ABCD = []
for s in abcd:
    ABCD.append(int(s))
# print(ABCD)

ans = 0
ans_l = ''
def dfs(buff, i, buff2):
    global ans
    global ans_l

    if buff == 7 and i == 4:
        ans += 1
        ans_l = buff2

    if i == 4:
        return

    dfs(buff+ABCD[i],i+1, buff2+'+')
    dfs(buff-ABCD[i],i+1, buff2+'-')


buff_l = []
dfs(ABCD[0], 1, '')
# print(ans_l)
# print(ans)
ans = ''
ans_l = list(ans_l)
for i in range(4):
    ans += str(ABCD[i])
    if i < 3:
        ans += str(ans_l[i])


print(ans+'=7')

Measured memory_bytes: 38384
from sys import stdin
from math import floor

def make_b(b_str):
    if '.' in b_str:
        b_split = b_str.split('.')
        b_int = int(b_split[0])
        b_float = int(b_split[1])
    else:
        b_int = int(b_str)
        b_float = 0
    return b_int * 100 + b_float

def main():
    for line in stdin:
        factors_str = line.split()
        break

    a = int(factors_str[0])
    b = make_b(factors_str[1])

    prod = a * b // 100
    print(prod)

main()

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    map<string, int> m;
    REP(i, N) {
        string s; cin >> s;
        m[s] += 1;
    }
    int max_c = -1;
    vector<string> ans;
    for(auto x : m) {
        string s = x.first;
        int c = x.second;
        if (c > max_c) {
            max_c = c;
            ans.clear();
            ans.push_back(s);
        } else if (c == max_c) {
            ans.push_back(s);
        }
    }
    for(auto x : ans) {
        cout << x << "\n";
    }
}

Measured memory_bytes: 27212
import java.util.Scanner;

public class Main {

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

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

		for (; n != 0 || x != 0;) {
			int result = 0;
			for (int i = 1; i <= n - 2; i++) {
				for (int j = i + 1; j <= n - 1; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) {
							result++;
						}
					}
				}
			}
			System.out.println(result);

			n = sc.nextInt();
			x = sc.nextInt();
		}

		sc.close();
	}
}

Measured memory_bytes: 19752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
#define REP(i, n) for(int i = 0; i < n; i++)

int par[100010];

void init(int n){
    REP(i, n+1) par[i] = i;
    return;
}

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

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

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    else{
        par[x] = y;
        return;
    }
}

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

    vector<int> p(n);
    REP(i, n) cin >> p[i];
    vector<int> x(m),y(m);
    REP(i, m){
        cin >> x[i] >> y[i];
        unite(x[i],y[i]);
    }
    
    int ans = 0;
    for(int i=0;i<n;i++){
        if(same(i+1, p[i])) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jun  9 16:08:03 2018
//
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 1e7)
	sc.Buffer(buf, 1e7)

	nextLine()
	line := nextLine()
	arr := strings.Split(line, " ")
	m := map[int]int{}
	for i := range arr {
		v, _ := strconv.Atoi(arr[i])
		m[v]++
	}

	nextLine()
	line = nextLine()
	arr = strings.Split(line, " ")
	for i := range arr {
		t, _ := strconv.Atoi(arr[i])
		if m[t] > 0 {
			m[t]--
		} else {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int co=0;
        int a=i;
        while(a>=1){
            co++;
            a/=10;
        }
        if(co%2==1)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    cin>>vec;
    int ans=0;
    FOR(i,-1,n){
        FOR(j,i,n+1){
            int sum=0;
            int t=0;
            priority_queue<int,vi,greater<int>> que;
            REP(k,i){
                sum+=vec[k];
                que.push(vec[k]);
                t++;
            }
            FOR(k,j,n){
                sum+=vec[k];
                que.push(vec[k]);
                t++;
            }
            if(t>m){
                continue;
            }
            REP(k,m-t){
                if(!que.size()||que.top()>=0){
                    break;
                }
                sum-=que.top();
                que.pop();
            }
            chmax(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
  }
};

/* 円の点包含判定 */
double isContainedCP(P c, double r, P p){
  //return abs(c-p) < r - P_eps; //円周上を含まない
  return abs(c-p) < r + P_eps; //円周上を含む
}

int solve(){
  int n;
  double x[SIZE], y[SIZE];

  scanf("%d", &n);
  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    scanf("%lf%lf", x+i, y+i);
  }

  int ans = 1;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i == j) continue;
      P vec = P(x[i]-x[j], y[i]-y[j]);

      if(abs(vec) > 2.0 + P_eps) continue;
      
      P p = P(-vec.imag(), vec.real());
      p = p / abs(p) * sqrt(1 - norm(vec) / 4);
      //debug(p);

      p += vec / 2.0 + P(x[j], y[j]); 

      int counter = 0;
      // debug(abs(p - P(x[i], y[i])));
      
      for(int k=0;k<n;k++){
        counter += isContainedCP(p, 1, P(x[k], y[k]));
      }

      ans = max(ans, counter);
    }
  }

  printf("%d\n", ans);
  return true;
}


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



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int n,m,h,u,v;
const int nax = 1e5+10;
vvi adj(nax);
vi hs(nax);
bool good;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m;
    fore(i,1,n+1)
        cin>>hs[i];

    forn(i,m){
        cin>>u>>v;
        adj[u].pb(v); adj[v].pb(u);
    } 

    int cnt = 0;
    fore(i,1,n+1){
        good = true;
        for(auto ad: adj[i]){
            if(hs[i]<=hs[ad]){
                good&=false;
            }
        }
        if(good) cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};


int main() 
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	
	ll n;
	cin>>n;
	ll ans = 0;
	loop(i,1,n){
		ans+=n/i;
		if(n%i==0)
			ans--;
	}
	cout<<ans;
}

Measured memory_bytes: 3668
while(1):
    a,op,b=input().split(" ")
    a=(int)(a)
    b=(int)(b)
    if(op=="?"):
        break
    elif(op=="+"):
        print(a+b)
    elif(op=="-"):
        print(a-b)
    elif(op=="*"):
        print(a*b)
    elif(op=="/"):
        print(a//b)


Measured memory_bytes: 5596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    a = max(a,c);
    b = min(b,d);
    int ans = b - a;
    if(ans < 0) ans = 0;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
const int maxn=1000010;
const ll mod=1e9+7;
int n;
ll pre=1,tmp,f[maxn];
int main() {
	read(n);
	tmp=1LL*n*(n-1)%mod;
	f[1]=n;
	f[2]=1LL*n*n%mod;
	for(int i=3;i<=n;i++) {
		f[i]=(f[i-1]+pre+tmp-(i-2))%mod;
		(pre+=f[i-2])%=mod;
	}
	writeln(f[n]%mod);
	return 0;
}

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

int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[0] == N[2]) {
    cout << "Yes" << endl;
  } else if (N[1] == N[2] && N[1] == N[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	s := sc.Text()
	n, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = nextInt(sc)
	}
	q := nextInt(sc)
	t := make([]int, q)
	for i := 0; i < q; i++ {
		t[i] = nextInt(sc)
	}

	result := 0
	for _, x := range t {
		for _, y := range s {
			if x == y {
				result++
				break
			}
		}
	}
	fmt.Println(result)
}



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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val,typename Number>
//use ll or int for gcd
Val gcd(Val a, Val b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->push_back(make_pair(count,A->at(i)));
        count = 1;
      }
    }else{
      R->push_back(make_pair(count,A->at(i)));
      count = 1;
    }
  }
}

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

int main(){
  ll X;
  cin>>X;
  ll count = 0;
  ll ans;
  llrep(i,X+1){
    count+=i;
    if(count>=X){
      ans = i;
      break;
    }

  }




  cout<<ans<<endl;




}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int ans=0;
int w,h;
char a[22][22];
bool f[22][22];
void dfs(int H,int W){
	if(W<0||W>=w||H<0||H>=h||a[H][W]=='#'||f[H][W]==true)return;
	if(a[H][W]=='.'&&f[H][W]==false){
		f[H][W]=true;
		ans++;
	}
	rep(i,0,4)dfs(H+dy[i],W+dx[i]);
	return;
}

int main(){
	while(1){
		ans=0;
		rep(i,0,22)rep(j,0,22)f[i][j]=false;
		cin>>w>>h;
		int start_x,start_y;
		if(w==0)break;
		rep(i,0,h)rep(j,0,w){
			cin>>a[i][j];
			if(a[i][j]=='@')start_y=i,start_x=j;
		}
		dfs(start_y,start_x);
		print(ans+1);
	}
	return 0;
}


Measured memory_bytes: 2976
#include <stdio.h>
#include <algorithm>

using namespace std;

int n;
int minn = 200;
int a[1002];
int i;int j;int dif;

int main(){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++) scanf("%d",&a[i]);
		minn = 1000002;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				dif = a[i]-a[j];
				if(dif<0) dif*=(-1);
				if(minn>dif) minn = dif;
			}
		}
		printf("%d\n",minn);
	}	
	return 0;
}


Measured memory_bytes: 2740
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b<<" "<<a+a+b+b<<endl;
}



Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8
ll dp[3][100007];

int main() {
  ll N,C;
  cin >> N;
  ll A[100007];
  rep(i,N){
      cin >> A[i];
  }
  dp[1][0]=A[0];
  dp[0][0]=dp[2][0]=A[1];
  rep(i,N-1){
      dp[0][i+1]=max(gcd(dp[0][i],A[i+1]),gcd(dp[2][i],A[i+1]));
      dp[1][i+1]=gcd(dp[1][i],A[i+1]); //ok
      dp[2][i+1]=dp[1][i];
  }
  cout << max(dp[0][N-1],dp[2][N-1]) << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    ll a[n],s=0,c=0;
    for (ll i=0;i<n;i++){
        cin >> a[i];
        s+=a[i];
        if (i%2)c+=a[i];
    }
    ll x=s-(2*c);
    cout << x << " ";
    for (ll i=1;i<n;i++){
        x=(2*a[i-1])-x;
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<double> pq;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    pq.push(a);
  }
  for (int i = 0; i < m; i++) {
    double x = pq.top();
    pq.pop();
    pq.push(x / 2);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (int)pq.top();
    pq.pop();
  }
  cout << ans << endl;
}


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

void push(int);
int pop(void);


int S[4];
int top = 0;

int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop()+pop();
      push(x);
    } else if ( s[0] == '-' ){

      a = pop();
      b = pop();
      x = b-a;
      push(x);
    } else if ( s[0] == '*' ){
      x = pop()*pop();
        push(x);
    } else {
      x = atoi(s);
      push(x);

    }
  }

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

  return 0;
}

void push(int x){
  top++;
  S[top] = x;
}

int pop(void){
  top--;
  return S[top+1];
}




Measured memory_bytes: 2108
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in range(n):
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 29372
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MX=1e18;

int main(){
  int s,w;
  cin>>s>>w;
  if(s>w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::string s, t;
    std::cin>>s>>t;

    std::string ans = "NO";
    if((s[0] == t[2]) && (s[1] == t[1]) && (s[2] == t[0])){
        ans = "YES";
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

ll mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      return 0;
    }
    a -= d;
  }
  cout << "No";

  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
 
 
 
 int bin(multiset<int>&s)
 {

	 
	 int l=0,r=s.size()-1,mid,ans=1;
	 while(l<=r)
	 {
		 mid=(l+r)/2;
		 auto k =s.begin();
	   	advance(k,mid);
		 if(*k>=s.size()-mid)
		 { 
			 ans=s.size()-mid; r=mid-1;
		 }
		 else l=mid+1;
	 }
	 return ans;
 }
 
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 

 

int n ;cin>>n;
string s;
cin>>s;
int cnt=0;

for(int i=0;i<n;)
{
	cnt++;
	if(i!=n-1 && s[i]==s[i+1])
	{
        int j=i+1;
		while(j<n && s[j]==s[i])j++;
		i=j;
	}
	else i++;
}

cout<<cnt<<"\n";
 
 
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 #define  inf 1e9+5;
int main()
{
	int n;
  cin>>n;
int v[n];
  for(int i=0;i<n;i++)
	 cin>>v[i];
	
	ll dp[n];
	for(int i=1;i<n;i++)
	    dp[i]=inf;
	dp[0]=0;
	
	for(int i=0;i<n;i++)
	{
		int c=0;
		int j=i+1;	
	while(c<2 && j<n)	{
	
		

	
      dp[j]=min(dp[j], (dp[i]+abs(v[j]-v[i])));				
		//cout<<dp[j]<<"\n";
      c++;
j++;
}
		
	}

  //cout<<n;
  ll res=dp[n-1];
	cout<<res<<"\n";
	return 0;
}


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

typedef long long ll;
const int N = 1000010;
int n, mx;
int a[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	ll ans = 1ll, cnt = 0;
	for(int i = n; i; i--) {
		if(a[i] == a[i - 1]) ans *= a[i], ++cnt, --i;
		if(cnt == 2) break; 
	}
	if(cnt == 2) printf("%lld\n", ans);
	else printf("0");
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,k; cin >> n >> k;
	ll d = n/k;
	ll ans = d*d*d;
	if(k%2==0){
		ll e = n/(k/2)-d;
		ans += e*e*e;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
import math
import itertools
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K = int(input())

sums = 0
# for a, b, c in itertools.permutations(range(1, K+1), 3):
for a, b, c in itertools.product(range(1, K+1), repeat=3):
    sums += gcd(a, b, c)
# for a in range(1, K+1):
#     for b in range(1, K+1):
#         for c in range(1, K+1):
#             sums += gcd(a, b, c)

print(sums)

Measured memory_bytes: 69272
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,m;cin>>n>>m;
    ll a[m],b[m];
    vector<pair<ll,ll>> p,q;
    bool bo[m];
    rep(i,0,m-1){
        cin>>a[i]>>b[i];
        bo[i]=false;
        p.push_back(make_pair(b[i],i));
        q.push_back(make_pair(a[i],i));
    }
    q.push_back(make_pair(inf,0));
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    ll y[m];
    rep(i,0,m-1){
        y[p[i].second]=i;
    }
    
    ll ans;ans=0;
    ll c=0;
    rep(i,0,m-1){
        if(bo[i]==false){
            ans++;
            while(q[c].first<p[i].first){
                bo[y[q[c].second]]=1;
                c++;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 5988
import java.util.Scanner;

class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int a = scan.nextInt();
    	int b = scan.nextInt();
    	int d = a / b;
    	int r = a % b;
    	double f = (double)a / (double)b;
    	
    	System.out.println(d + " " + r + " " + String.format("%.8f", f));
    	
     }
}

Measured memory_bytes: 26256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int main (){
	int d,nn;
	cin >>d >>nn;
	if(nn == 100 && d ==0){
			cout << "101" << endl;
			return 0;
	}
	if(nn == 100 && d ==1){
			cout << "10100" << endl;
			return 0;
	}
	if(nn == 100 && d ==2){
			cout << "1010000" << endl;
			return 0;
	}
	cout << nn;
	rep(i,d){
		cout << "00";
	}
	cout <<endl;
	return 0;
}


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


void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F){

    std::sort(A.begin(), A.end());
    std::sort(F.begin(), F.end(), std::greater<long long>());
    long long first = 0;
    long long last = 1e12;
    while(first < last)
    {
        long long mid = (first + last) / 2;
        // すべてのA[i]F[i]をmid以下にできるか？
        long long need = 0; //必要な時間 (Kと比較)
        for(long long i = 0; i < N; i++)
        {
            need += std::max(0ll, A[i] - mid / F[i]);
        }

        if(need <= K)
        {
            last = mid;
        } else {
            first = mid + 1;
        }
    }
    printf("%lld\n", first);
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }
    solve(N, K, std::move(A), std::move(F));
    return 0;
}


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


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

    int ans = 0;
    int cnt = 0;
    rep(i, S.size()) {
        if (S[i] == 'S') {
            cnt = 0;
        } else {
            ++cnt;
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		string t;
		
		while( "0 0" != (t= Console.ReadLine()) ) {
			var u = t.Split(' ');
			var n = int.Parse(u[0]);
			var s = int.Parse(u[1]);
			
			var cnt = 0;
			my.DFS(n, 0, 0, s, ref cnt);
			
			Console.WriteLine(cnt);
		}
	}
	
	private static void DFS(int depth, int num, int sum, int s, ref int cnt) 
	{
		if(depth == 0 && sum == s) {
			cnt++;
			return;
		}
		
		if(num == 10 || depth == 0) {
			return;
		}
		
		DFS(depth, num+1, sum, s, ref cnt);
		DFS(depth-1, num+1, sum + num, s, ref cnt);
	}
	
	private static void Swap(int[] A, int i, int j)
	{
		int tmp = A[i];
		A[i] = A[j];
		A[j] = tmp;
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}
	
	private static int[] GetIntArray(int n, string t)
	{
		var A = new int[n];
		var s = t.Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(char c, string s)
	{
		return Array.ConvertAll(s.Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(string s)
	{
		return Array.ConvertAll(s.Split(' '), int.Parse);
	}
	
	private static double[] GetDoubleArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteVector(Vector v)
	{
		Console.WriteLine(string.Format("{0:f8} {1:f8}", v.X, v.Y));
	}
}

public struct Vector
{
	public double X,Y;
}

Measured memory_bytes: 9028
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int N, W;
    cin >> N >> W;
    long long dp[100001] = {0};
    long long ans = 0;
    for (int i = 0; i < N; i++){
        int weight, value;
        cin >> weight >> value;
        for (int j = W - weight; j >= 0; j--){
            dp[j + weight] = max(dp[j + weight], dp[j] + value);
            //cout << dp[j + weight] << " " << j + weight << endl; 
        }
    }
    for (int j = 0; j <= W; j++){
        ans = max(ans, dp[j]);
    }
    cout << ans;
    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var H = new HashSet<int>();
		foreach(var n in A) H.Add(n);
		
		if(H.Count > 2){
			Console.WriteLine("No");
			return;
		}
		
		int ma = A.Max();
		int mi = A.Min();
		if(ma - mi > 1){
			Console.WriteLine("No");
			return;
		}
		
		
		var ar = new List<int>();
		if(ma == mi){
			ar.Add(mi);
			ar.Add(mi + 1);
		} else {
			ar.Add(ma);
		}
		
		foreach(var n in ar){
			var ret = check(n);
			if(ret){
				Console.WriteLine("Yes");
				return;
			}
		}
		
		Console.WriteLine("No");
		
	}
	
	bool check(int n){
		
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(A[i] == n - 1) cnt++;
		}
		
		int rest = n - cnt;
		if(rest == 0){
			return N - cnt == 0;
		}
		if(rest < 0 ){
			return false;
		}
		return N - cnt >= 2 * rest;
		
	}
	
	
	
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<string, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

string r[25000];
P p[5000];
map<string, int> mp;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int k;
    cin >> s >> k;
    rep(i, s.size()) {
        p[i].first = s[i];
        p[i].second = i;
    }
    int cnt = 0;
    rep(i, s.size()) {
        string temp = "";
        rep(j, 5) {
            if(p[i].second + j < s.size()) {
                temp += s[p[i].second + j];
                if(mp[temp] != 1) {
                    mp[temp] = 1;
                    r[cnt++] = temp;
                }
            }
        }
    }
    sort(r, r + cnt);
    cout << r[k - 1] << endl;
    return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;
const int M = 1e5;
int ar[M][3];
ll sum[M][3];

vector<int> others(int i) {
    vector<int> ar(2);
    if(i == 0) ar[0]=1,ar[1]=2;
    else if(i == 1)ar[0]=0,ar[1]=2;
    else ar[0]=0,ar[1]=1;
    return ar;
}

ll dp(int i, int lc){
    if(i == 0){
        if(lc == 0) return ar[0][0];
        else if(lc == 1) return ar[0][1];
        else return ar[0][2];
    }
    if(sum[i][lc] != -1) return sum[i][lc];
    sum[i][lc] = ar[i][lc] + max(dp(i-1,others(lc)[0]), dp(i-1,others(lc)[1]));
    return sum[i][lc];
}

int main() {FIN;
    int n;
    cin >> n;
    fore(i,n,M) {ar[i][0]=0 ; ar[i][1]=0; ar[i][2]=0;}
    fore(i,0,M) {sum[i][0]=-1 ; sum[i][1]=-1; sum[i][2]=-1;}
    fore(i,0,n) cin >> ar[i][0] >> ar[i][1] >> ar[i][2];
    sum[0][0]=ar[0][0],sum[0][1]=ar[0][1],sum[0][2]=ar[0][2];
    dp(n-1,0);
    dp(n-1,1);
    dp(n-1,2);
    int m = max(sum[n-1][0], max(sum[n-1][1], sum[n-1][2]));
    cout << m;
    return 0;
}



Measured memory_bytes: 19456
#include<stdio.h>

void solve(void);

int main(void){
  int T;
  scanf("%d",&T);
  while(T--) solve();
  return 0;
}

void solve(void){
  int N,D,x,y,sum=0,i;
  scanf("%d%d",&N,&D);
  x=D;
  for(i=0;i<N-1;i++){
    y=x^127;
    sum+=x^y;
    x=y;
  }
  printf("%d\n",sum+x);
}


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

using ll = long long;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<ll> sum;
    ll all_or = 0;
    rep(i, N) {
        ll s = 0;
        for (int j = i; j < N; j++) {
            s += A[j];
            sum.push_back(s);
            all_or |= s;
        }
    }

    vector<int> idx(sum.size());
    iota(idx.begin(), idx.end(), 0);

    ll ans = 0;
    for (ll b = (1LL << 41); b > 0; b >>= 1) {
        if (!(all_or & b)) continue;
        vector<int> on;
        for (const int& i : idx) {
            if (sum[i] & b) {
                on.push_back(i);
            }
        }
        if (on.size() >= K) {
            ans |= b;
            idx = on;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7148
#include "bits/stdc++.h"
using namespace std;
#define ll long long;
// Start Time: 11:41
int main(){
	std::ios::sync_with_stdio(false);
	int N;
	vector<int> A;
	cin >> N;
	for(int x = 0; x<N;x++){
		int i;
		cin >> i;
		A.push_back(i);
	}
	vector<int> X = A;
	sort(X.begin(), X.end());
	for(int p : A){
		if (X[N-1] == p){
			cout << X[N-2] << endl;
		}
		else{
			cout << X[N-1] << endl;
		}
	}
}

 


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
void solve()
{
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
    {
        cout<<"safe";
    }
    
}
int32_t main()
{
    _FAST

    int t;
    t=1;
    while (t--)
    {
        solve();
        //lb:;
    }

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  while(str[0]!='0'){
    int i,o=0;
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define fo(i, k, n) for (int i = k; i <= n; ++ i)
#define fod(i, k, n) for (int i = k; i >= n; -- i)
template <typename T, typename U>
static inline void maxx (T &x, U y) {
  if (x < y) {
    x = y;
  }
}
template <typename T, typename U>
static inline void minn (T &x, U y) {
  if (x > y) {
    x = y;
  }
}
template<typename T>
void read (T &x) {
  x = 0;
  T neg = 1;
  register T c = getchar ();
  if (c == '-') {
    neg = -1;
  }
  while (c < 48 || c > 57) {
    c = getchar ();
  }
  for (; c < 48 || c > 57; c = getchar ());
  for (; c <= 57 && c >= 48; c = getchar ()) {
    x = (x << 3) + (x << 1) + (c & 15);
  }
  x *= neg;
}
template<typename T>
void write (T x) {
  bool neg = 0;
  if (x < 0) {
    x *= -1;
    neg = 1;
  }
  char snum[65];
  int i = 0;
  do {
    snum[++ i] = x % 10 + '0';
    x /= 10;
  }
  while (x);
  //-- i;
  if (neg) {
    putchar ('-');
  }
  while (i > 0) {
    putchar (snum[i --]);
  }
}
///declare
int n, b[101], a[101], res = 0;
int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
//  else {
//    freopen(".inp", "r", stdin);
//    freopen(".out", "w", stdout);
//  }
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  read (n);
  fo (i, 1, n - 1) {
    read (b[i]);
  }
  a[1] = b[1];
  a[n] = b[n - 1];
  fo (i, 2, n - 1) {
    a[i] = min (b[i], b[i - 1]);
  }
  fo (i, 1, n) {
    res += a[i];
  }
  write (res);
}


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

int main() {
	long long int N,A,B;
  	cin>> N >> A >> B;
  	long long int j,k=0;
  	long long int sum=0;
  	
  	j=N/(A+B)*A;
  	k=N/(A+B)*B;
  	sum+=j;
  	
  	if(A<=N-j-k && N-j-k<=A+B){
     	sum+=A; 
    }
  	else{
      	sum+=N-j-k; 
    }
      
     
  
  	
  	cout<<sum<<endl;
}


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

int main(){
    int sx, sy, tx, ty;
    std::cin >> sx >> sy >> tx >> ty;
    
    int dx = tx - sx;
    int ax = dx >= 0 ? dx : -1 * dx;
    int dy = ty - sy;
    int ay = dy >= 0 ? dy : -1 * dy;
    std::string ans;
    std::string tmp;
    
    for(int i=0; i<ay; i++){
        if(dy >= 0){
            ans = ans + "U";
            tmp = tmp + "D";
        }else{
            ans = ans + "D";
            tmp = tmp + "U";
        }
    }
    for(int i=0; i<ax; i++){
        if(dx >= 0){
            ans = ans + "R";
            tmp = tmp + "L";
        }else{
            ans = ans + "L";
            tmp = tmp + "R";
        }
    }
    ans = ans + tmp;
    tmp = "";
    if(dx >= 0){
        ans = ans + "L";
        tmp = tmp + "R";
    }else{
        ans = ans + "R";
        tmp = tmp + "L";
    }
    for(int i=0; i<ay+1; i++){
        if(dy >= 0){
            ans = ans + "U";
            tmp = tmp + "D";
        }else{
            ans = ans + "D";
            tmp = tmp + "U";
        }
    }
    for(int i=0; i<ax+1; i++){
        if(dx >= 0){
            ans = ans + "R";
            tmp = tmp + "L";
        }else{
            ans = ans + "L";
            tmp = tmp + "R";
        }
    }
    if(dy >= 0){
        ans = ans + "D";
        tmp = tmp + "U";
    }else{
        ans = ans + "U";
        tmp = tmp + "D";
    }
    ans = ans + tmp;
    
    
    std::cout << ans << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int a, b, c;
    int m, sum = 0;

    cin >> a >> b >> c;

    m = a;
    if(m < b) m = b;
    if(m < c) m = c;

    if(m==a){
        sum = 10*a + b + c;
    }
    if(m==b){
        sum = 10*b + a + c;
    }
    if(m==c){
        sum = 10*c + a + b;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,num,card[4][14];
  int i,j;
  char s;
  for(i=0;i<=13;i++){
    card[0][i]=1;
    card[1][i]=1;
    card[2][i]=1;
    card[3][i]=1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&s,&num);
         if(s=='S')card[0][num]=0;
    else if(s=='H')card[1][num]=0;
    else if(s=='C')card[2][num]=0;
    else if(s=='D')card[3][num]=0;
  }
  for(i=0;i<4;i++){
    for(j=1;j<=13;j++){
      if(card[i][j]!=0){
	if(i==0)s='S';
	else if(i==1)s='H';
	else if(i==2)s='C';
	else if(i==3)s='D';
	printf("%c %d\n",s,j);
      }
    }
  }
  return(0);
}

Measured memory_bytes: 596
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {  
		Scanner input = new Scanner(System.in);
		double W = input.nextDouble();
		double H = input.nextDouble();
		double x = input.nextDouble();
		double y = input.nextDouble();
		double A = W*H;
		A/=2; //It's always possible to split rectangle into 2 equal pieces
		//when divider can have any slope and start point
		x%=W;
		y%=H; //Easier to check if point is on edge
		int ways = 0;
		boolean Vert = false;
		boolean Hor = false;
		if (x==W/2) Vert=true;
		if (y==H/2) Hor=true;
		if (Vert&&Hor) ways++;
		
		System.out.println(A+" "+ways);
	}
}

Measured memory_bytes: 23252
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static int A,B,AB,O;

	static void solve() {
		String[] s = in.next().split(",");
		if (s[1].equals("A")) {
			A++;
		} else if (s[1].equals("B")) {
			B++;
		} else if (s[1].equals("AB")) {
			AB++;
		} else if (s[1].equals("O")) {
			O++;
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(in.hasNext()) solve();

		out.println(A);
		out.println(B);
		out.println(AB);
		out.println(O);

		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int dp[3005][3005];

int main(){
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> pr(N);
  REP(i, N){
    int A, B;
    cin >> A >> B;
    pr[i] = {A, B};
  }
  sort(pr.begin(), pr.end());
  REP(i, N){
    auto [A, B] = pr[i];
    REP(j, T){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(j+A > T) continue;
      dp[i+1][j+A] = max(dp[i+1][j+A], dp[i][j] + B);
    }
  }
  int ans = 0;
  REP(i, N){
    ans = max(ans, dp[i][T-1]+pr[i].second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x);
int pop();


int main(void)
{
	int a,b;
	top=0;
	char s[100];
	
	while(scanf("%s", s) != EOF){
		if(s[0] == '+'){
			a=pop();
			b=pop();
			push(a + b);
		}
		else if(s[0] == '-'){
			b=pop();
			a=pop();
			push(a - b);
		}
		else if(s[0] == '*'){
			a=pop();
			b=pop();
			push(a * b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	
	return 0;
}

void push(int x)
{
	S[++top] = x;
}

int pop()
{
	top--;
	return S[top+1];
}



Measured memory_bytes: 2092