akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// why am I so weak

int n, a, b, c, d;

int main() {
	cin >> n >> a >> b >> c >> d;

	for (int i = 0; i < n; i++) {
		int left = n - i - 1;

		long long nub = -1ll * c * i, nlb = -1ll * d * i;
		long long pub = 1ll * d * left, plb = 1ll * c * left;

		long long lb = 1ll * a + nlb + plb;
		long long ub = 1ll * a + nub + pub;

		if (lb <= 1ll * b && 1ll * b <= ub) {
			puts("YES");
			return 0;
		}
	}

	puts("NO");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	string s, t;
	cin >> s >> t;
	string ans = "No";
	for (int i = 0;i < s.size();i++) {
		if (s.substr(i, s.size() - i) + s.substr(0, i) == t)ans = "Yes";
	}
	cout << ans << endl;
}

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

using namespace std;

int n;
int d, x;
int a;
int answer = 0;

int main() {    
	cin >> n;
    cin >> d >> x;
    for (int i = 0; i < n; i++) {
        cin >> a;
        int day = (d - 1) / a;
        answer += day + 1;
    }
    cout << answer + x;
    return 0;
}


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

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

  set<int> s;
  rep(i, n) { s.insert(a[i]); }

  if (n == s.size()) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = n, hozon;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      if(v[i] == v[j]){
        hozon++;
        v[j] = 100 + j + i;
      }
    }
  }
  cout << ans - hozon << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
for _ in range(N):
    t = list(map(int,input().split()))
    if t[1] != 0:
        edge[t[0]-1] = list(map(lambda x:int(x)-1, t[2:]))

dist = [-1]*N
dist[0] = 0
        
q = deque([0])
while q:
    now = q.popleft()
    for nxt in edge[now]:
        if dist[nxt] == -1:
            dist[nxt] = dist[now] + 1
            q.append(nxt)
        else:
            dist[nxt] = min(dist[nxt], dist[now] + 1)

for i,d in enumerate(dist):
    print(i+1, d)


Measured memory_bytes: 6036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

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

signed main() {
    int H,W; cin >> H >> W;
    int cnt = 0;
    char s[H][W]; 
    rep(i,H) rep(j,W) {cin >> s[i][j]; if(s[i][j]=='#') cnt++;}
    int dis[H][W];
    rep(i,H) rep(j,W) dis[i][j] = INF;
    dis[0][0] = 1;
    queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int a = que.front().first;
        int b = que.front().second;
        que.pop();
        rep(i,4){
            if(dis[a+dx[i]][b+dy[i]] == INF && s[a+dx[i]][b+dy[i]] != '#' &&
            a+dx[i] >=0 && a+dx[i] < H && b+dy[i] >=0 && b+dy[i] < W ){
                dis[a+dx[i]][b+dy[i]] = dis[a][b] + 1;
                que.push(make_pair(a+dx[i],b+dy[i]));
            }
        }
    }
    if(dis[H-1][W-1]==INF) cout << -1 << endl;
    else {
        cout << H*W-dis[H-1][W-1]-cnt << endl;
    }
}

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


class Solver {
public:
    void solve();
    long long sumXORTo(long long x);
    bool isOdd(long long x);
};

bool Solver::isOdd(long long x) {
    return x % 2 != 0;
}

long long Solver::sumXORTo(long long x) {
    if (x % 2 != 0) {
        long long half = (x + 1) / 2;
        int ret = isOdd(half);
        return ret;
    }
    else {
        long long half = (x + 1) / 2;
        int ret = isOdd(half);
        return ret ^ x;
    }
}


void Solver::solve() {
    using namespace std;
    long long a, b;
    cin >> a >> b;

    long long a1 = sumXORTo(a - 1);
    long long b1 = sumXORTo(b);
    long long result = a1 ^ b1;
    cout << result << endl;
    


}



int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

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

int main(){
    int a, b;
    char op;
    while(op!='?'){
    if(op=='+') cout<<(a+b)<<endl;
    if(op=='-') cout<<(a-b)<<endl;
    if(op=='*') cout<<(a*b)<<endl;
    if(op=='/') cout<<(a/b)<<endl;
    cin>>a>>op>>b;
    }
    return 0;
}


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

using namespace std;

int main() {
  int S;
  int W;
  cin>>S;
  cin>>W;
  if(W>=S){//なぜか半数以上だと思っていた
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
  
}


Measured memory_bytes: 3636
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    string ans="No";
    long mod4[4]={0};
    cin >> N ;
    vector<long long>a(N);

    rep(i,N){
        cin >> a[i];
        mod4[a[i]%4]++;
    }
    if(mod4[0]>mod4[1]+mod4[3]) {
        ans = "Yes";
    }else{
        if(mod4[0] == mod4[1]+mod4[3]) {
            ans = "Yes";
        }
        if(mod4[0] == mod4[1]+mod4[3]-1) {
            if (mod4[2] == 0)
                ans = "Yes";
        }
    }

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



Measured memory_bytes: 1024
s = int(input())
a = [s]
count = 1
while True:
    count += 1
    i = a[-1]
    f = (i//2)*((i+1)%2) + (3*i+1)*(i%2)
    if f in a:
        break
    else:
        a.append(f)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e6 + 6;
 
int main() {
	int n;
	cin >> n;
	
	multiset<int> tails;
	
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		auto it = tails.lower_bound(a);
		if (it == tails.begin()) {
			tails.insert(a);
		} else {
			it--;
			if (*it < a) {
				tails.erase(it);
				tails.insert(a);
			} else
				tails.insert(a);
		}
	}
	cout << tails.size();
}
 

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	cout << (A + B + 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N, M, T;
		int a1, a2, delta = 0;
		N = scn.nextInt();
		M = scn.nextInt();
		T = scn.nextInt();
		a1 = scn.nextInt();
		for (int i = 1; i < N; i++) {
			a2 = scn.nextInt();
			delta += 2 * M > a2 - a1 ? 2 * M + a1 - a2 : 0;
			a1 = a2;
		}
		a2 = T+M;
		delta += 2 * M > a2 - a1 ? 2 * M + a1 - a2 : 0;
		scn.close();
		System.out.println(T + delta - 2*M*N);
	}
}



Measured memory_bytes: 26436
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	double a,b,p,q,r;
	cin>>a>>b>>p>>q>>r;
	c((b*p-(b-a)*q)/(q+r)+b)
}



Measured memory_bytes: 3292
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  if(a==b){
    if(b!=c){
      printf("Yes");
    }else{
      printf("No");
    }
  }else{
    if((a-c)*(b-c)==0){
      printf("Yes");
    }else{
      printf("No");
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
q = int(input())

r = set([])

g = {}

n = {}

for i in range(q):
    s,p = input().split()
    if s not in r:
        r.add(s)
        g[s] = [int(p)]
        n[int(p)] = i+1
    else:
        g[s].append(int(p))
        n[int(p)] = i+1
        
r = list(r)

r.sort()

for i in r:
    x = g[i]
    x.sort(reverse = True)
    for t in x:
        print(n[t])

Measured memory_bytes: 9104
#include<stdio.h>
#include<stdbool.h>
#define FREE -1
#define NOTFREE 1
#define N 8
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=col[i]=FREE;
    //col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=dneg[i]=FREE;
    //dneg[i]=FREE;
  }
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
       if(X[i][j]){
         if(row[i]!=j)return;
       }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%c",((row[i]==j)?'Q':'.'));
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if((NOTFREE==col[j])||(NOTFREE==dpos[i+j])||(NOTFREE==dneg[i-j+N-1]))
    continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOTFREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}
int main(){
  int i,j,k,r,c;
  initialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=false;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=true;
  }
  recursive(0);
  return 0;
}



Measured memory_bytes: 2108
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = INF;
    rep(i, n){
        vector<ll> tmpvec;
        vector<ll> vec;
        rep(j, n){
            if(a[j] < a[i]){
                if(tmpvec.size() < k){
                    tmpvec.clear();
                    continue;
                }
                sort(all(tmpvec), greater<ll>());
                while(tmpvec.size() >= k){
                    vec.push_back(tmpvec.back());
                    tmpvec.pop_back();
                }
                tmpvec.clear();
            } else {
                tmpvec.push_back(a[j]);
            }
        }

        if(tmpvec.size() >= k){
            sort(all(tmpvec), greater<ll>());
            while(tmpvec.size() >= k){
                vec.push_back(tmpvec.back());
                tmpvec.pop_back();
            }
        }

        if(vec.size() < q) continue;
        sort(all(vec));
        ans = min(ans, vec[q - 1] - a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}

void solve(){
    ll i,j,k,l,n,m,x,y,z,r;
	
	cin>>n>>m;
	vll a(n+11);
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	vllv v(n+11);
	for(i=1;i<=m;i++){
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	ll ans=0;
	for(i=1;i<=n;i++){
		m=0;
		for(j=0;j<v[i].sz;j++){
			m=max(m,a[v[i][j]]);
		}
		if(m<a[i])ans++;
	}
	cout<<ans<<endl;
	
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int D,N;cin>>D>>N;
    if(N==100) N++;
    int ans=1;
    REP(i,D) ans*=100;
    cout<<ans*N<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	std::map<std::string,ll> s;
	for(ll i = 0;i < n;++i)
	{
		std::string tmp;
		std::cin >> tmp;
		s[tmp]++;
	}

	ll max = 0;
	for(auto itr = s.begin();itr != s.end();++itr)
		if(max < itr->second) max = itr->second;

	for(auto itr = s.begin();itr != s.end();++itr)
		if(max == itr->second) std::cout << itr->first << std::endl;


	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

ll num[MAXN];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,t;
	cin >> n >> t;
	
	ll m = 1001001001;
	ll d = 0;
	
	FOR(i,0,n){
		cin >> num[i];
		if (i){
			d = max(d, num[i]-m);
		}
		m = min(m,num[i]);
	}
	
	ll z = 0;
	ll v = 0;
	FORD(i,n-1,0){
		if (i<n-1){
			if(z-num[i]==d) {
				num[i]++;
				v++;
			}
		}
		z = max(num[i],z);
	}
	cout << v << "\n";

}


Measured memory_bytes: 4388
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='p'&&s[s.size()-i-1]=='q') {
      continue;
    }
    else if(s[i]=='q'&&s[s.size()-i-1]=='p') {
      continue;
    }
    else if(s[i]=='b'&&s[s.size()-i-1]=='d') {
      continue;
    }
    else if(s[i]=='d'&&s[s.size()-i-1]=='b') {
      continue;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int main() {
	int n, m, sum = 0;; cin >> n >> m;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i]; sum += a[i];
	}
	sort(a.rbegin(), a.rend());
	ld f = 1.000 * sum / (4 * m);
	rep(i, m) {
		if (a[i] < f) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int count=0;
  if(N>=105){
    count++;
  }
  if(N>=165){
    count++;
  }
  if(N>=135){
    count++;
  }
  if(N>=189){
    count++;
  }
  if(N>=195){
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(int a, int b)
{
   return a < b;
}
std::priority_queue<int, std::vector<int>, std::function<bool(int, int)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[i]=1;
		}
	}
}


void solve(){
	int n; cin>>n;
	int cnt=0;
	f(i,0,n){
		int x; cin>>x;
		while(x%2==0) {
			x/=2;
			++cnt;
		}
	}
	cout<<cnt;
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383

int main(){
   
    fast;
    int d,t,s;
    cin>>d>>t>>s;
    if((s*t) >= d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }








}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] d = Console.ReadLine().Split(' ');
            for (int i = nk[0]; ; i++)
            {
                string s = i.ToString();
                bool ok = true;
                for (int j = 0; j < d.Length; j++)
                {
                    if (s.Contains(d[j]))
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 5336
def main():
    N, W = map(int, input().split())
    # (v, w)
    item = [tuple(map(int, input().split())) for _ in range(N)]
    """
    使い回さない方
    dp = [[0]*(W+1) for _ in range(N+1)]
    for i in range(N):
        for w in range(W+1):
            if w >= item[i][1]:
                dp[i+1][w] = max(dp[i][w], dp[i][w-item[i][1]]+item[i][0])
            else:
                dp[i+1][w] = dp[i][w]
    print(max(dp[N]))
    """
    """ 使い回す方 """
    dp = [0]*(W+1)
    for i in range(N):
        for w in range(W, -1, -1):
            if item[i][1] <= w:
                dp[w] = max(dp[w], dp[w-item[i][1]]+item[i][0])
    print(max(dp))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5924
def solve(N, M, Es):
    al = {}
    for e in Es:
        al.setdefault(e[0], []).append(e[1])
        al.setdefault(e[1], []).append(e[0])

    ans = 0
    q = [(1, [1])]
    while len(q) > 0:
        current, history = q.pop()
        nexts = al[current] if current in al else []
        if len(history) == N:
            ans += 1
        for n in nexts:
            if n not in history:
                nhist = history[:]
                nhist.append(n)
                q.append((n, nhist))
    return ans


if __name__ == "__main__":
    N, M = map(int, input().split(" "))
    Es = []
    for _ in range(M):
        Es.append(tuple(map(int, input().split(" "))))
    print(solve(N, M, Es))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll A[n+1];
    ll B[n];
    for(ll i=0;i<=n;i++)
        cin>>A[i];
    for(ll i=0;i<n;i++)
        cin>>B[i];
    ll counter=0;
    int flag = 0;
    for(ll i=0;i<n;i++)
    {
        flag=0;
        //cout<<A[i]<<" "<<B[i]<<" "<<A[i+1]<<endl;
        if(A[i]<=B[i])
        {
            counter = counter+A[i];
            B[i]=B[i]-A[i];
            A[i]=0;
            flag = 1;
        }
        if(B[i]>=0 && flag==0)
        {
            counter = counter + B[i];
            B[i]=0;
        }
        else if(B[i]>=0)
        {
            if(A[i+1]<=B[i])
            {
                counter = counter+A[i+1];
                B[i] = B[i]-A[i+1];
                A[i+1]=0;

            }
            else
            {
                A[i+1] = A[i+1]-B[i];
                counter = counter+B[i];
                B[i] = 0;

            }
        }
        //cout<<A[i]<<" "<<B[i]<<" "<<A[i+1]<<endl;
    }
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n; cin>>n;
   ll count=0,num;
   for(int i=0;i<n;i++){
       cin>>num;
       while(num%2==0){
           num/=2;
           count++;
       }
   }
   cout<<count;
   return 0;
}


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



#define select(_1, _2, x, ...) x



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

#define repr(i, a, b) for (int i = (a); i < (b); i++)

#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)



#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)

#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)

#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)



#define umax(m, x) (m = max(m, x));

#define umin(m, x) (m = min(m, x));



#define rng(v) v.begin(), v.end()

#define rrng(v) v.rbegin(), v.rend()



#define debug(x) cerr << #x << " = " << x << endl



using namespace std;



using ll = long long int;



using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vb = vector<bool>;



using vvi = vector<vector<int>>;

using vvl = vector<vector<ll>>;

using vvs = vector<vector<string>>;

using vvb = vector<vector<bool>>;



const int INF = 1e9;

const ll LINF = 1e18;



inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }



struct node {

    ll num;

    string all;

};



int main() {

    ll k;

    cin >> k;



    if (k <= 9) {

        cout << k << endl;

        return 0;

    }



    queue<struct node> q;

    rep(i, 1, 10) {

        struct node temp = {i, to_string(i)};

        q.push(temp);

    }



    ll cnt = 0;



    struct node t;

    while (cnt < k) {

        t = q.front(); q.pop();

        rep(i, t.num - 1, t.num + 2) {

            if (i < 0 || i > 9) continue;

            struct node temp = {i, t.all + to_string(i)};

            q.push(temp);

        }

        cnt++;

    }



    cout << t.all << endl;



    return 0;

}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
struct edge{ int to,cost; };
vector<edge> nex[301]; // to, cost
int dist[301][301];
int ndis[301][301];
signed main(){
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		nex[x].pb((edge){y,z});
		nex[y].pb((edge){x,z});
		dist[x][y] = z;
		dist[y][x] = z;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if( i == j ){
				dist[i][j] = 0;
			}
			else if( dist[i][j] == 0 ){
				dist[i][j] = inf;
			}
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if( dist[i][j] > dist[i][k] + dist[k][j] ){
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if( i == j ){
				ndis[i][j] = 0;
			}
			else if( dist[i][j] <= l ){
				ndis[i][j] = 1;
			}
			else{
				ndis[i][j] = inf;
			}
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if( ndis[i][j] > ndis[i][k] + ndis[k][j] ){
					ndis[i][j] = ndis[i][k] + ndis[k][j];
				}
			}
		}
	}
	int q; cin>>q;
	for(int i=0;i<q;i++){
		int s,t;
		cin>>s>>t;
		if( ndis[s][t] == inf)cout<<-1<<endl;
		else cout<<ndis[s][t]-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> w(n+1, 0);
    rep(i, n){
        if(s[i] == '#') w[i+1]++;
    }
    rep(i, n) w[i+1] += w[i];

    int ans = INF;
    rep(i, n+1){
        ans = min(ans, w[i] + (n-i)-(w[n]-w[i]));
        // cout << w[i] << " " << n-i-w[n]+w[i] << endl;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1412
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

vector<vector<long> > tt;
vector<long> par;
vector<long> child;

void bfs( long root )
{
    queue<long> que;
    que.push( root );

    while( !que.empty() ) {
        long curr = que.front();
        que.pop();

        long nSize=(long)tt[curr].size();
        long i;
        for(i=0; i<nSize; i++) {
            long next = tt[curr][i];
            par[next]=curr;

            child[next]--;
            if(child[next]==0) {
                que.push(next);
            }
        }
    }

    return;
}


int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    tt.resize(n);
    child.resize(n);

    long i;
    for(i=0; i<n+m-1; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        tt[a-1].push_back(b-1);
        child[b-1]++;
    }

    long root=-1;
    for(i=0; i<n; i++) {
        if(child[i]==0) {
            root=i; break;
        }
    }
    
    par.resize(n);
    for(i=0; i<n; i++) {
        par[i]=-1;
    }

    bfs( root );

    for(i=0; i<n; i++) {
        printf("%ld\n", par[i]+1);
    }
 
    return 0;
}


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

long long int gcd(long long int x, long long int y)
{
	if (x < y)
	{
		x ^= y;
		y ^= x;
		x ^= y;
	}
	
	return y ? gcd(y, x % y) : x;
}

long long int lcm(long long int x, long long int y)
{
	return x * y / gcd(x, y);
}

int main()
{
	long long int a, b;
	cin >> a >> b;
	
	cout << lcm(a, b) << endl;
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0, a;
  rep(i, 5) {
    cin >> a;
    if (a == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3560
n,c,k = map(int, input().split())
t = []

for i in range(n):
    x = int(input())
    t.append([x,x+k])

t.sort()

ans = 0
while t:
    x = t[-1][0]
    ans += 1
    for i in range(c):
        if t:
            if t[-1][0] <= x <= t[-1][1]:
                t.pop()
            else:
                break

print(ans)



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main() {
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  vll count(1000001, 0);
  sort(all(a));
  ll ans = 0;
  rep(i, 0, n){
    if(count.at(a.at(i)) == 1) continue;
    ll copy = a.at(i);
    while(copy < 1000001){
      count.at(copy) = 1;
      copy += a.at(i);
    }
    if(i < n - 1) if(a.at(i) == a.at(i + 1)) continue;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12760
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    int n, x[100], y[100];
    double d1 = 0.0, d2 = 0.0, d3 = 0.0, d4 = 0.0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }

    for (int i = 0; i < n; i++) {
        d1 += abs(x[i] - y[i]);
        d2 += pow(abs(x[i] - y[i]), 2.0);
        d3 += pow(abs(x[i] - y[i]), 3.0);
        if (abs(x[i] - y[i]) > d4) {
            d4 = abs(x[i] - y[i]);
        }
    }
    d2 = pow(d2, 1.0 / 2.0);
    d3 = pow(d3, 1.0 / 3.0);

    cout << fixed << setprecision(6) << d1 << endl;
    cout << fixed << setprecision(6) << d2 << endl;
    cout << fixed << setprecision(6) << d3 << endl;
    cout << fixed << setprecision(6) << d4 << endl;

    return 0;
}

Measured memory_bytes: 1304
n,m = map(int, input().split())
load_info = {i:[] for i in range(1, n+1)}

for _ in range(m):
  a,b = map(int, input().split())
  load_info[a].append(b)
  load_info[b].append(a)

for n_i in range(1, n+1):
  print(len(load_info[n_i]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll mod = 1000000007;
template< int mod >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
using modint = ModInt< mod >;

int pl[65];
int pr[65];
modint memo[65][2][2][2];
bool ok[65][2][2][2];

modint f(int pos, bool flagX, bool flagY, bool flagZ) {
    if (pos == -1) return modint(1);
    if (ok[pos][flagX][flagY][flagZ]) return memo[pos][flagX][flagY][flagZ];
    modint ret;
    //x=0, y=0
    if (flagX || pl[pos] == 0) {
        ret += f(pos-1, flagX, (pr[pos] == 1? 1: flagY), flagZ);
    }
    //x=0, y=1
    if ((flagX || pl[pos] == 0) && (flagY || pr[pos] == 1) && flagZ) {
        ret += f(pos-1, flagX, flagY, flagZ);
    }
    //x=1, y=1
    if (flagY || pr[pos] == 1) {
        ret += f(pos-1, (pl[pos] == 0? 1: flagX), flagY, 1); 
    }
    memo[pos][flagX][flagY][flagZ] = ret;
    ok[pos][flagX][flagY][flagZ] = 1;
    return ret;
}

int main() {
    ll L, R;
    cin >> L >> R;
    for (int i = 0; i < 60; i++) {
        pl[i] = L & 1;
        pr[i] = R & 1;
        L >>= 1;
        R >>= 1;
    }

    cout << f(59,0,0,0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double 
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,bool> PP;

const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

vector<PP> convex_hull(vector<PP> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<PP> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

bool isIntersect(L s1, L s2){
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

bool check(vector<PP> v,P s,P g){
  bool res=0;
  int n=v.size();
  for(int i=0;i<n;i++)res|=isIntersect(L(v[i%n].first,v[(i+1)%n].first),L(s,g));
  return res;
}

double ref(P a,P b,P s,P g){
  double l=0,r=abs(a-b);
  int cnt=100;
  b-=a,s-=a,g-=a,b/=abs(b);
  while(cnt--){
    double m=(l+r)/2;
    P p1=m*b,p2=(m+EPS)*b;
    if(abs(s-p1)+abs(g-p1)<abs(s-p2)+abs(g-p2))r=m;
    else l=m;
  }
  b*=l;
  return abs(b-s)+abs(b-g);
}

int main(){
  double x,y;
  P s,g;
  cin>>x>>y;
  s=P(x,y);
  cin>>x>>y;
  g=P(x,y);
  int n;
  cin>>n;
  vector<PP> v;
  for(int i=0;i<n;i++)cin>>x>>y,v.push_back(PP(P(x,y),0));
  double ans=1e9;
  if(check(v,s,g)){
    v.push_back(PP(s,1));
    v.push_back(PP(g,1));
    v=convex_hull(v);
    int n=v.size();
    double sum=1e9;
    for(int i=0;i<2*n;i++){
      if(v[i%n].second)ans=min(ans,sum),sum=0;
      sum+=abs(v[i%n].first-v[(i+1)%n].first);
    }
  }
  else{
    for(int i=0;i<n;i++)
      ans=min(ans,ref(v[i].first,v[(i+1)%n].first,s,g));
  }
  printf("%.8Lf\n",ans);
  return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(){
  ll A,B,C,K; cin >>A >>B >>C >>K;
  // 1 time : B+C,  C+A,  A+B
  // 1 time : -A,   -B,   -C
  // 2 times: -B-C, -C-A, -A-B
  // 2 times: A,    B,    C
  // K times: A(-1)^K, B(-1)^K, C(-1)^K
  // ans : (A-B)(-1)^K
  ll co = K%2==0 ? 1 : -1;
  ll res = (A-B)*co;
  cout <<res <<endl;
}

int main() {
  solve();
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
ll k;
int n,m,t;
int gt[MAXN];
ll a[MAXN],pre[MAXN],ans[MAXN];
vector<int> num;
bool vis[MAXN];
void got(int x){
	vis[x]=1;
	if(num.size()>=1&&x==num[0])
		return ;
	num.push_back(x);
	got(gt[x]);
}
int main(){
	SF("%d",&n);	
	for(int i=1;i<=n;i++)
		SF("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		pre[i]=a[i]-a[i-1];
	SF("%d%lld",&m,&k);
	for(int i=1;i<=n;i++)
		gt[i]=i;
	for(int i=1;i<=m;i++){
		SF("%d",&t);	
		swap(gt[t],gt[t+1]);
	}
	for(int i=1;i<=n;i++){
		if(vis[i]!=0)
			continue;
		got(i);
		int len=num.size();
		ll k1=k%len;
		for(int j=0;j<len;j++)
			ans[num[j]]=pre[num[(j+k1)%len]];
		num.clear();
	}
	ll sum=0;
	for(int i=1;i<=n;i++){
		sum+=ans[i];
		PF("%lld.0\n",sum);
	}
}
//

Measured memory_bytes: 7928
import sys
from heapq import*
r=sys.stdin.readline
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=[*map(int,r().split())]
  if f[0]:
   c,d,e=f[1:]
   E[c]+=[(e,d)]
   E[d]+=[(e,c)]
  else:
   print(g(*f[1:]))


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

int main() {
  string S ; 
  cin >> S ; 
  int N ; 
  N = S.size() ; 

  
  for(int i = 0 ; i < N ; i++){
    
    
    if( (i+1) % 2 == 0 ){ //偶数
      if( (S.at(i) != 'L') &&  (S.at(i) != 'U' ) && (S.at(i) != 'D')  ){
        cout << "No" << endl ; 
        return 0 ; 
      }
    }
    
    else if( (i+1)  % 2 == 1){ // 奇数
      if( (S.at(i) != 'R') && (S.at(i) !='U') && (S.at(i) !='D')  ){
        cout << "No" << endl ; 
        return 0 ; 
      }      
    }

    
  }
  
  cout << "Yes" << endl ;

  
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

vector<string> three = {
    "a..",
    "a..",
    ".bb"
};
vector<string> four = {
    "ahff",
    "ahgg",
    "bbde",
    "ccde"
};
vector<string> five = {
    "ahhgg",
    "ai..f",
    "bi..f",
    "b.jje",
    "ccdde"
};
vector<string> six = {
    "aa..hi",
    "bb..hi",
    "cc..jk",
    "..ddjk",
    "..eelm",
    "..fflm"
};
vector<string> seven = {
    "ahhii..",
    "aj..mm.",
    "bjk....",
    "b.k..oo",
    "c..l..p",
    "c..l..p",
    ".ddeeff"
};

int main() {
    int n = 0;
    cin >> n;
    if (n == 2) {
        cout << -1 << endl;
    } else if (n == 3) {
        for (auto s : three) {
            cout << s << endl;
        }
    } else {
        vector<string> ans(n);
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                ans.at(i).push_back('.');
            }
        }
        int mod = n%4;
        if (mod == 0) {
            for (int i=0; i<4; i++) {
                for (int j=0; j<4; j++) {
                    ans.at(i).at(j) = four.at(i).at(j);
                }
            }
        } else if (mod == 1) {
            for (int i=0; i<5; i++) {
                for (int j=0; j<5; j++) {
                    ans.at(i).at(j) = five.at(i).at(j);
                }
            }
        } else if (mod == 2) {
            for (int i=0; i<6; i++) {
                for (int j=0; j<6; j++) {
                    ans.at(i).at(j) = six.at(i).at(j);
                }
            }
        } else if (mod == 3) {
            for (int i=0; i<7; i++) {
                for (int j=0; j<7; j++) {
                    ans.at(i).at(j) = seven.at(i).at(j);
                }
            }
        }
        int cur = 4 + mod;
        while (cur + 4 <= n) {
            for (int i=0; i<4; i++) {
                for (int j=0; j<4; j++) {
                    ans.at(cur+i).at(cur+j) = four.at(i).at(j);
                }
            }
            cur += 4;
        }
        for (auto s : ans) {
            cout << s << endl;
        }
    }
    return 0;
}


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

int main(){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    cout << a << " " << b <<" "<< c << endl;
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int N;
V<V<int>> DP;
V<int> S;

int f(int i, int v) {
	if (i == N)
		return v == 0;
	if (v < 0)
		return 0;
	if (DP[i][v] != -1)
		return DP[i][v];
	return DP[i][v] = f(i+1, v) || f(i+1, v-S[i]);
}

int main() {
	cin >> N;
	S = V<int>(N);
	READALL(S);
	DP = V<V<int>>(N, V<int>(10001, -1));
	int ans = 0;
	REP(v, 10001) {
		if (v%10 == 0 || !f(0, v))
			continue;
		ans = max(ans, v);
	}
	cout << ans << endl;
}

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

static int cnt;

static void
print_array(int A[], size_t len)
{
        for (int i = 0; i < len; i++) {
                if (i)
                        printf(" ");
                printf("%d", A[i]);
        }
        printf("\n");
}

static void
merge(int A[], int left, int mid, int right)
{
        int n1 = mid - left;
        int n2 = right - mid;
        int *L = malloc(sizeof(int) * (n1 + 1));
        int *R = malloc(sizeof(int) * (n2 + 1));

        memcpy(L, &A[left], sizeof(int) * n1);
        memcpy(R, &A[mid], sizeof(int) * n2);

        L[n1] = INT_MAX;
        R[n2] = INT_MAX;

        for (int i = 0, j = 0, k = left; k < right; k++) {
                if (L[i] <= R[j]) {
                        A[k] = L[i];
                        i++;
                } else {
                        A[k] = R[j];
                        j++;
                }
                cnt++;
        }

        free(L);
        free(R);
}

static void
merge_sort(int A[], int left, int right)
{
        if ((left + 1 ) < right) {
                int mid = (left + right) / 2;
                merge_sort(A, left, mid);
                merge_sort(A, mid, right);
                merge(A, left, mid, right);
        }
}

int
main(void)
{
        int n;

        scanf("%d", &n);
        int *S = malloc(sizeof(int) * n);
        for (int i = 0; i < n; i++)
                scanf("%d", &S[i]);

        merge_sort(S, 0, n);

        print_array(S, n);
        printf("%d\n", cnt);

        free(S);

        return 0;
}



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

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

int main() {
    int H,W,N,x=1;
    cin >> H >> W >> N;
    vector<int> a(N);
    vector<vector<int>> r(H, vector<int>(W));
    rep(i,N)
        cin >> a.at(i);
    
    rep(i,H)
        rep(j,W) {
            if(i%2 == 0)
                r.at(i).at(j) = x;
            else
                r.at(i).at(W-1-j) = x;
            a.at(x-1)--;
            if(a.at(x-1) == 0)
                x++;
        }

    rep(i,H) {
        rep(j,W)
            cout << r.at(i).at(j) << " ";
        cout << endl;
    }
}

Measured memory_bytes: 384