akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<string>
#include<string.h>
#include<map>
#include<math.h>

#define int long long
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define all(a) begin(a),end(a)
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define sz(x) ((int)x.size())
#define ins insert
#define rep(i,l,u) for(int i=l;i<=u;++i)
#define reb(i,l,u) for(int i=l;i>=u;--i)
using namespace std;
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
main(){
    int x,k,d;
    cin>>x>>k>>d;
    if(abs(x)>=abs(k*d))cout<<abs(x)-abs(k*d)<<endl;
    else{
        int left=abs(x)%d;
        int num=abs(x)/d;
        if((k-num)%2)cout<<d-left<<endl;
        else cout<<left<<endl;
    }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N, v[100010];
    cin >> N;
    for (int i=0;i<N;i++) cin >> v[i];

    vector<int> O(100010,0),E(100010,0);
    for (int i=0;i<N;i+=2) O[v[i]]++;
    for (int i=1;i<N;i+=2) E[v[i]]++;

    multimap<int,int,greater<int>> Om, Em;
    Om.emplace(0,0), Em.emplace(0,0);
    for (int i=0;i<100010;i++) {
        if (O[i]) Om.emplace(O[i],i);
        if (E[i]) Em.emplace(E[i],i);
    } // first: count, second: number
    // for (auto itr: Om) {
    //     cout << itr.first << ": " << itr.second << endl;
    // }
    // for (auto itr: Em) {
    //     cout << itr.first << ": " << itr.second << endl;
    // }
    auto oitr = Om.begin(), eitr = Em.begin();
    bool flag = false;
    while (oitr->second == eitr->second) {
        oitr++; eitr++;
        flag = true;
        if (oitr == Om.end()) break;
    }
    if (oitr == Om.end()) {
        oitr = Om.begin(), eitr = Em.begin();
        eitr++;
    } else if (flag) {
        if (oitr->first < eitr->first) {
            oitr = Om.begin(), eitr = Em.begin();
            eitr++;
        } else {
            oitr = Om.begin(), eitr = Em.begin();
            oitr++;
        }
    }
    cout << N - oitr->first - eitr->first << endl;

    return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>
#include<float.h>

int main(void){
  double a;
  double max;
  double min;

  max = 0.0;
  min = DBL_MAX;
  while(scanf("%lf ",&a)!=EOF){
    if(max < a)max = a;
    if(min > a)min = a;
  }

  printf("%.1lf\n",max - min);

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <stack>
using namespace std;
int N;
multiset <int> contain;
multiset <int> notContain;
multiset <int>::iterator it;
stack <int> newInc;
int main() {
    cin >> N;
    int a;
    for (int i=0; i<(1<<N); i++){
        scanf("%d", &a);
        notContain.insert(a);
    }
    it = notContain.end();
    it--;
    contain.insert(*it);
    notContain.erase(it);
    bool works = true;
    for (int i=0; i<N; i++){
        for (auto is: contain){
            it = notContain.lower_bound(is);
            if (it == notContain.begin()) {
                works = false;
                break;
            }
            it--;
            newInc.push(*it);
            notContain.erase(it);
        }
        if (!works){
            break;
        }
        while (!newInc.empty()){
            contain.insert(newInc.top());
            newInc.pop();
        }
    }
    if (works) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	int a,b;

	char op;

	cin>>a>>op>>b;

	if(op=='+')PRINT(a+b);
	else PRINT(a-b);

	

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

  vector<int> count (n, 0);
  for(int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    count[tmp-1] ++; // to 0-based
  }

  vector<int> group;
  for(auto elem : count) {
    if(elem != 0) {
      group.push_back(elem);
    }
  }

  int ans = 0;
  int z = group.size();
  if (!group.empty()) sort(group.begin(), group.end());
  for(int i=0; i<z-k; i++) {
    ans += group[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
n, k = map(int, input().split())
D = [0]*k
A = []
for i in range(k):
    D[i] = int(input())
    A.append(list(map(int, input().split())))

cnt = 0
ans = []
for a in A:
  for i in a:
    if i not in ans:
      ans.append(i)
print(n-len(ans))
    

Measured memory_bytes: 9184
d=[0]*13
d[0]=1
m=1
mmod=1
t=input()[::-1]
mod=10**9+7
zero=[0]*13

for c in t:
    e=zero[:]
    if c=="?":
        for i in range(10):
            for j in range(13):
                k=(i*m+j)%13
                e[k]+=d[j]
                e[k]%=mod
                
                
                
                
                
                
                
                
    else:
        for j in range(13):
            k=(int(c)*m+j)%13
            e[k]+=d[j]
            e[k]%=mod
            
            
            
            
            
            
            
            
            
    d=e
    m=10*m%13
print(d[5])



Measured memory_bytes: 43372
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
int main(){
int n,i,k=1,m=2,ans=0;
cin>>n;
int arr[n];
for(i=0;i<n;i++){
  cin>>arr[i];
}
sort(arr,arr+n);
for(i=n-1;i>=2;i--){
k=i-1; m=i-2;

while(arr[i]<arr[k]+arr[m]&&m>=0){

while(arr[i]<arr[k]+arr[m]&&m>=0){
//  cout <<i<<" "<<k<<" "<<m<<endl;
  m--; ans++;
}k--;; m=k-1;


}//no final disto ans é o número de triângulos que envolve i

}

cout << ans<<endl;






}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int gotiusa=a+b+c+d;
  cin>>a>>b>>c>>d;
  int ujimatu=a+b+c+d;
  cout<<(gotiusa>ujimatu ?gotiusa:ujimatu )<<endl;
}

Measured memory_bytes: 3072
/*
userid : rakeshpvan333
*/
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define M 1000000007
#define MXN 1000007

int main()
{
    ll n,x;
    cin>>n>>x;
    ll a,ans=0;
    for(int i=0;i<n;++i)
        cin>>a,ans = __gcd(ans,abs(a-x));
    cout<<ans<<"\n";
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> A(N);
    vector<pll> pe(M);
    vector<ll> D;
  	rep(i,N)cin >> A[i];
    rep(i,M){
        int b,c;
        cin >> b >> c;
        pe[i]=make_pair(c,b);
    }
    sort(all(A));
    sort(all(pe));
    reverse(all(pe));
    int x=0;
    while(D.size()<N){
        rep(i,pe[x].second){
            D.push_back(pe[x].first);
        }
        x++;
    }
    rep(i,N){
        if(!chmax(A[i],D[i]))break;
    }
    ll sum=0;
    rep(i,N){
        sum+=A[i];
    }
    cout << sum;
  	rep(i,D.size())cerr << D[i];
}

/*



 */



Measured memory_bytes: 11756
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 1005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;

ll c=-INF;
int cidx;
ll b[2];
vector<int> u[2];
bool ex;

int main()
{
	cin >> N;
	rep(i,0,N){
		ll a;
		cin >> a;
		if(a>0){
			b[i%2] += a;
			u[i%2].push_back(i);
			ex = true;
		}
		if(c < a){
			c = a;
			cidx = i;
		}
	}
	if(!ex){
		cout << c << endl;
		cout << N-1 << endl;
		rep(i,0,N-cidx-1){
			cout << N-i << endl;
		}
		rep(i,0,cidx){
			cout << 1 << endl;
		}
		return 0;
	}

	ll ans = max({b[0],b[1]});
	cout << ans << endl;
	int k;
	if(ans == b[0])k = 0;
	else k = 1;
	vector<int> v;

	for(int i=N;i>u[k][u[k].size()-1]+1;i--){
		v.push_back(i);
	}
	rep(i,0,u[k][0]){
		v.push_back(1);
	}
	rep(i,0,u[k].size()-1){
		int t = (u[k][i+1]-u[k][i])/2;
		rep(j,0,t-1)v.push_back(3);
		v.push_back(2);
	}
	cout << v.size() << endl;
	rep(i,0,v.size()) cout << v[i] << endl;

	return 0;
}


Measured memory_bytes: 256
//package com.company;

import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        int a = 0,b = 0;
        for(int i = 0; i<n; i++){
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        if(n%2==0) {
            for (int i = 1; i < n; i += 2) {
                a += arr[i];
            }
            for (int i = 0; i < n - 1; i += 2)
                b += arr[i];
            System.out.println(a-b);
        }
        else{
            for (int i = 0; i < n; i += 2) {
                a += arr[i];
            }
            for (int i = 1; i < n - 1; i += 2)
                b += arr[i];
            System.out.println(a-b);
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200005 ;
int main()
{
   fast ;
   ll tests=1 ;
   ///cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
      ///cout<<"Case #"<<testcase<<": " ;
      ///Read,Think ans Test Properly,then code
      ///Try to avoid using print statements debug on your own
      ll n,k ;
      cin>>k>>n ;
      vector<ll>a(n) ;
      for(ll i=0;i<n;i++)
      {
          cin>>a[i] ;
      }
      ll mx=0 ;

      for(ll i=0;i<n-1;i++)
      {
          mx=max(mx,a[i+1]-a[i]) ;
      }
      mx=max(mx,k-a[n-1]+a[0]) ;

      cout<<(k-mx) ;

   }
}
/// ans ->for answer
/// cur ->for local answer
/// level ->for depth in tree
/// v -> adjacency matrix
/// r -> array
/// s ->string



Measured memory_bytes: 1792
/*
	Writing Segment Tree is Fun !
*/
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


struct SegTree {

	vector<int> dat;
	int s;

	void init(int size)
	{
		s = 1;
		while(s < size)
			s *= 2;
		dat.resize(s * 2, 0);
	}

	void add(int pos, int x)
	{
		pos += s;

		while(pos > 0) {
			dat[pos] += x;
			pos = pos / 2;
		}
	}

	int sum(int a, int b, int k, int l, int r)
	{
		if(b <= l || a >= r)
			return 0;
		if(a <= l && r <= b)
			return dat[k];

		int mid = (l + r) / 2;
		int lv = sum(a, b, k * 2 + 0, l, mid);
		int rv = sum(a, b, k * 2 + 1, mid, r);

		return lv + rv;
	}

	int sum(int a, int b)
	{
		return sum(a, b, 1, 0, s);
	}
};


int main()
{
	while(true) {

		int n;
		vector<pair<int, int> > x;

		scanf("%d", &n);
		if(n == 0)
			break;
		x.resize(n);
		for(int i = 0; i < n; ++i) {
			int v;
			scanf("%d", &v);
			x[i] = make_pair(v, i);
		}

		SegTree st;

		st.init(n);
		sort(x.begin(), x.end());

		int ans = 0;

		for(int i = 0; i < n; ++i) {
			int p = x[i].second;
			ans += p - st.sum(0, p);
			st.add(p, 1);
		}

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

	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,k;
int a[100005],b[100005],c[100005],d[100005];
vector<int> G[100005];
int cmp[100005];
int cnt[100005];
int ans[100005];

void dfs(int v,int c){
	cmp[v]=c;
	cnt[c]++;
	for(int i=0;i<G[v].size();i++){
		if(cmp[G[v][i]]==-1){
			dfs(G[v][i],c);
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	for(int i=0;i<k;i++){
		scanf("%d%d",&c[i],&d[i]);
		c[i]--;
		d[i]--;
	}
	memset(cmp,-1,sizeof(cmp));
	int siz=0;
	for(int i=0;i<n;i++){
		if(cmp[i]==-1){
			dfs(i,siz++);
		}
	}
	for(int i=0;i<n;i++){
		ans[i]=cnt[cmp[i]]-1-G[i].size();
	}
	for(int i=0;i<k;i++){
		if(cmp[c[i]]==cmp[d[i]]){
			ans[c[i]]--;
			ans[d[i]]--;
		}
	}
	for(int i=0;i<n;i++){
		printf("%d%c",ans[i],i+1==n?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 9472
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int x[10],y[10];
int main(void)
{
    int n;
    double sum=0;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> x[i] >> y[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            sum+=sqrt((y[i]-y[j])*(y[i]-y[j])+(x[i]-x[j])*(x[i]-x[j]));
    sum/=n;
    printf("%.9f" ,sum);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int BinarySearch(int,int[]);

int q,n;

int main()
{
  int S[N],T[N],i,j,cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  
  scanf("%d",&q);

  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
    }

   for(i=0;i<q;i++)
    {
      if(BinarySearch(T[i],S) == 1)cnt++;
    }

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

  
  return 0;
}

int BinarySearch(int key,int S[])
{
  int left=0,right=n,mid;
  while( left < right)
  { 
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    
    else if (key < S[mid]) right = mid;
    
    else left = mid + 1;
  }
  return 0;
}



Measured memory_bytes: 2276
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll a,b,c;
    cin >> a >> b >> c;

    ll l = 4*a*b;
    ll r = (c-a-b)*(c-a-b);
    if (l<r && (c-a-b)>=0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int D[][] = new int[C][C];
		int c[][] = new int[N][N];
		for(int i = 0; i < C; i++) {
			for(int j = 0; j < C; j++) {
				D[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				c[i][j] = sc.nextInt() - 1;
			}
		}
		
		int num0[] = new int[C];
		int num1[] = new int[C];
		int num2[] = new int[C];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				switch((i + j) % 3) {
				case 0:
					num0[c[i][j]]++;
					break;
				case 1:
					num1[c[i][j]]++;
					break;
				case 2:
					num2[c[i][j]]++;
					break;
				}
			}
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < C; i++) {
			int temp0 = 0;
			for(int color = 0; color < C; color++) {
				temp0 += D[color][i] * num0[color];
			}
			for(int j = 0; j < C; j++) {
				if(j == i) continue;
				int temp1 = 0;
				for(int color = 0; color < C; color++) {
					temp1 += D[color][j] * num1[color];
				}
				for(int k = 0; k < C; k++) {
					if(k == i || k == j) continue;
					int temp2 = 0;
					for(int color = 0; color < C; color++) {
						temp2 += D[color][k] * num2[color];
					}
					ans = Math.min(ans, temp0 + temp1 + temp2);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 90740
#include<bits/stdc++.h>
using namespace std;
string s;
int c;
int main(){
	cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]=='C') c=1;
		if (c==1&&s[i]=='F'){
			cout<<"Yes";
			return 0;	
		}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
            if (m == -1 && f == -1 && r == -1) break;

            if(m == -1 || f == -1) {
                System.out.println("F");
            } else if (m+f>=80) {
                System.out.println("A");
            } else if (m+f>=65 && m+f<80) {
                System.out.println("B");
            } else if (m+f>=50 && m+f<65) {
                System.out.println("C");
            } else if (m+f>=30 && m+f<50) {
                if (r>=50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else if (m+f<30) {
                System.out.println("F");
            }
        }
    }
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n+10);
    for(int i=0;i<n;++i) cin >> a[i];
    int cnt = 0;
    for(int i=0;i<n;++i){
        while(a[i]%2==0){
            a[i] /= 2;
            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
count = int(input())
for i in range(count):
    x = list(map(float ,input().split()))
    x1=x[2]-x[0]
    y1=x[3]-x[1]
    x2=x[6]-x[4]
    y2=x[7]-x[5]
    if abs(x1*y2-x2*y1)<=1e-10:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 5604
import sys
import math
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

def check_t(num):
    t = math.log(num,2)
    return 2**(int(t)+1)



from collections import defaultdict
n = getN()
nums = getlist()
numhash = defaultdict(int)
for i in nums:
    numhash[i] += 1
ans = 0
for num in sorted(numhash.keys(), key=lambda x: -x):
    while(numhash[num] != 0):
        target = (check_t(num)) - num
        if numhash[target]:

            if target == num:
                if numhash[target] >= 2:
                    ans += 1
                    numhash[target] -= 2
                else:
                    numhash[num] = 0
            else:
                if numhash[target] >= 1:
                    ans += 1
                    numhash[target] -= 1
                    numhash[num] -= 1
                else:
                    numhash[num] = 0
        else:
            numhash[num] = 0


print(ans)


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

int main() {
  ll x;
  cin >> x;

  if (x <= 6) {
    puts("1");
    return 0;
  }

  ll cnt = x / (6 + 5) * 2;
  x -= cnt * (6 + 5) / 2;
  if (x == 0) {
    //
  } else if (x > 6 || x == 5) {
    cnt += 2;
  } else {
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String odd = sc.nextLine(),
               even = sc.nextLine();
        int length = odd.length()+even.length();
        for(int i=1;i<=length;i++){
        	if(i%2==0)System.out.print(even.charAt(i/2-1));
        	else System.out.print(odd.charAt(i/2));
        }
        System.out.println();
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/


ll n,m,v,p;
vector<ll> a;

bool check(ll mid){
  ll cnt=0;
  rep(i,n){
    if(i==mid-1){
      cnt+=m;
      continue;
    }if(i<p-1||i>mid-1){
      cnt+=m;
    }else{
      if(a[mid-1]+m<a[i]){
        return false;
      }
      cnt+=a[mid-1]+m-a[i];
    }
  }
  if(cnt>=m*v){
    return true;
  }else{
    return false;
  }
}

ll serch(ll ok,ll ng) {
	while (abs(ok-ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(){
  cin>>n>>m>>v>>p;
  a.resize(n);
  rep(i,n){
    cin>>a[i];
  }
  SORTR(a);
  cout<<serch(p,n+1)<<endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
# define llt  int
using namespace std;


int main(){

    int n;
    cin>>n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;

    string a;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        if(a=="AC")
            ac++;
        else    
        if(a=="WA")
            wa++;
        else
            if(a=="TLE")
                tle++;
        else
            if(a=="RE") 
                re++;           

    }
    cout<<"AC"<<" x "<<ac<<endl; 
    cout<<"WA"<<" x "<<wa<<endl; 
    cout<<"TLE"<<" x "<<tle<<endl; 
    cout<<"RE"<<" x "<<re<<endl; 


    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
main(){
int w,h,i,j,z;
for( ;scanf("%d%d",&h,&w); ){
if (h == 0 && w==0) {break;}
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
printf("#");}
printf("\n");}
printf("\n");}
return 0; 
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    set<int> s;
    for (int i = 0; i < 3; ++i) {
        int x;
        cin >> x;
        s.insert(x);
    }
    cout << (s.size() == 2 ? "Yes" : "No") << endl;
    return 0;
}

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

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

    int cnt = 0;
    rep(i, n) {
        int x, y;
        cin >> x >> y;

        double tmp = sqrt(pow(x, 2) + pow(y, 2));
        //cout << tmp << endl;
        if (tmp <= d)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int rx, ty, n;
  cin >> rx >> ty >> n;
  int lx = 0, uy = 0;
  REP(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      lx = max(lx, x);
    } else if (a == 2) {
      rx = min(rx, x);
    } else if (a == 3) {
      uy = max(uy, y);
    } else if (a == 4) {
      ty = min(ty, y);
    }
  }
  if (rx - lx <= 0 || ty - uy <= 0) {
    cout << 0 << endl;
  } else {
    cout << (rx - lx) * (ty - uy) << endl;
  }
}


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

int main() {
    string s;
    cin >> s;
    int front_a = s.size(), back_z = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') front_a = min(front_a, i);
        if (s[i] == 'Z') back_z = max(back_z, i);
    }
    cout << back_z - front_a + 1 << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#define ll long long
using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, ll> mp;
	for(int i=0; i<N; ++i){
	    string S;
	    cin >> S;
	    sort(S.begin(), S.end());
	    ++mp[S];
	}
	ll ans=0;
	for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
	    ll p=itr->second;
	    ans += p*(p-1)/2;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);
 
mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}
 
int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
  int nk = (p==-1) ? k : k-2;
  int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ans *= f(nk,c);
}
 
int main() {
  int n;
  cin >> n >> k;
  for(int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

const int N = 310;
const int MOD = 998244353;

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

char s[N];
int n, k;
vector <int> v;

int dp[N][N][N];
int dp2[N][N][N];

int main() {
	scanf ("%s%d", s + 1, &k);
	n = strlen(s + 1);
	k = min(k, n);
	int ones = 0;
	rep(i, 1, n) {
		if (s[i] == '1') ones++;
		if (s[i] == '0') {
			v.pb(ones);
			ones = 0;
		}
	}
	v.pb(ones);
	dp[0][0][0] = 1;
	rep(j, 0, k)
		rep(g, 0, k) {
			dp2[0][j][g] = dp[0][j][g];
			if (j && g) add(dp2[0][j][g], dp2[0][j - 1][g - 1]);
		}
	
	int M = ss(v);
	rep(i, 1, M) {
		ones = v[i - 1];
		rep(j, 0, k) {
			rep(g, 0, k) {
				rep(pomoc, 0, ones) {
					if (g + pomoc > k) continue;
					add(dp[i][j][g], dp[i - 1][j][g + pomoc]);
				}
				if (j >= 1 && g >= 1) {
					add(dp[i][j][g], dp2[i - 1][j - 1][g - 1]);
				}
				add(dp2[i][j][g], dp[i][j][g]);
				if (j && g)
					add(dp2[i][j][g], dp2[i][j - 1][g - 1]);
				//printf ("%d %d %d %d\n", i, j, g, dp[i][j][g]);
			}
		}	
	}
	int ans = 0;
	rep(i, 0, k)
		add(ans, dp[M][i][0]);
	printf ("%d\n", ans);
	
	return 0;
}	


Measured memory_bytes: 114912
#pragma GCC optimize(3)
#include <bits/stdc++.h>

using namespace std;

int n, num, ans = 1;

int main()
{
	cin>>n;
	for(int i = 0; i < n; i ++)
	{
		cin>>num;
		if(num == ans) ans ++;
	}
	if(ans == 1) cout<<-1;
	else cout<<n - ans + 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    char x;
    cin >>A>>x>>B;
    if(x=='+') cout << A+B << endl;
    else cout <<A-B<<endl;



}


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

typedef long long ll;

int n;
ll a[100005];
__int128_t ans;

int main(){

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

    cin>>n;
    ans=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        ans*=a[i];
        if(ans>1000000000000000000ll){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<(ll)ans<<endl;

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    rep(i, (s.size() - 1)/2 + 1) {
        cout << s[2*i];
    }
    return 0;
}

Measured memory_bytes: 512
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	string s; cin >> s;
	int cnt[30]; memset(cnt,0,sizeof cnt);
	for(auto&to:s) ++cnt[to-'a'+1];
	rep(i,1,26) if(cnt[i]&1)
		return cout << "No", 0;
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;


pair<int, int> get_key(int a, int b) {
  if(a > b)
    return make_pair(b, a);
  return make_pair(a, b);
}

vector<int> coloring_edges_on_tree(int n, vector<int> a, vector<int> b) {
  vector<vector<int>> graph(n);
  for(int i=0;i<a.size();i++) {    
    int vertex_a = a[i] - 1;
    int vertex_b = b[i] - 1;
    graph[vertex_a].emplace_back(vertex_b);
    graph[vertex_b].emplace_back(vertex_a);
  }
  
  int color_num = 0;  
  queue<int> que;
  map<pair<int, int>, int> mp;

  int used[100000] = {};
  que.push(0);
  vector<int> ans;  
  while(!que.empty()) {
    int vertex = que.front();
    que.pop();    
    vector<int> vertex_vec = graph[vertex];
    int degree = vertex_vec.size();
    color_num = color_num > degree ? color_num : degree;
    set<int> colors;
    int color_index = 1;
    for(int j=0;j<vertex_vec.size();j++) {
      int vertex2 = vertex_vec[j];
      if(used[vertex2] == 1)
	colors.insert(mp[get_key(vertex, vertex2)]);
    }
    for(int i=0;i<vertex_vec.size();i++) {
      int vertex2 = vertex_vec[i];
      if(used[vertex2] == 1)
	continue;

      que.push(vertex2);
      
      pair<int, int> key = get_key(vertex, vertex2);

      while(true) {
	if(colors.count(color_index) == 1) {
	  color_index++;
	  continue;
	} else {
	  break;
	}
      }
      mp[key] = color_index++; 
    }
    used[vertex] = 1;
  }
  ans.push_back(color_num);
  for(int i = 0; i< a.size();i++) {
    ans.push_back(mp[get_key(a[i]-1, b[i]-1)]);
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  for(int i=0;i<n-1;i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
    cin >> temp;
    b.push_back(temp);
  }
  vector<int> ans = coloring_edges_on_tree(n, a, b);
  for(int i=0;i<ans.size();i++) {
    cout << ans[i];
    if(ans.size() - 1 != i)
      cout << endl;
  }
}

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

int main(){
  long long n, sum = 0, ans = 1LL << 60, tot = 0;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  for(int i = 0; i < n; i++){
    if(abs((a[i] * n) - sum) < ans ){
      tot = (i);
      ans = abs((a[i] * n) - sum);
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    ll N;
    cin >> N;
    vec<ll> A(N);
    const int ma = 1000000;
    vec<mint> a(ma+1,0),a2(ma+1,0),val(ma+1,0);
    for(int i=0;i<N;i++){
        cin >> A[i];
        a[A[i]] += A[i];
        a2[A[i]] += A[i]*A[i];
    }
    mint two = 2,inv2 = two.inv();
    mint ans = 0;
    for(int i=ma;i>=1;i--){
        mint v1 = 0,v2 = 0;
        for(int j=1;i*j<=ma;j++){
            v1 += a[i*j];
            v2 += a2[i*j];
        }
        val[i] = (v1*v1-v2)*inv2;
        for(int j=2;i*j<=ma;j++) val[i] -= val[i*j];
        mint g = i;
        ans += val[i]*g.inv();
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
   int n, k;
   cin >> n >> k;
   int ans = 1;
   for(int i = 0 ; i < n; i++){
       if(ans *2 >= ans + k){
           ans += k;
       }else {
           ans *= 2;
       }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, n;
      cin >> A >> B;
      n = 0;
      for(int i = 1; i < 10; i++){
        int S1;
        S1 = 10001 * i;
        // cout << "f" << S1 << endl;
        for(int j = 0; j < 10; j++){
          int S2;
          S2 = S1 + 1010 * j;
          // cout << "s" << S2 << endl;
          if(S2 > B)
            break;
          for(int k = 0; k < 10; k++){
            int S3;
            S3 = S2 + 100 * k;
            // cout << "t" << S3 << endl;
            if(S3 > A - 1 && S3 < B + 1){
              n++;
              // cout << S3 << endl;
            }
          }
        }
      }
      cout << n << endl;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N+1];
     
        for(int i=1; i<=N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int count = 0;
        for(int i=1; i<=N; i++) {
            if(p[i] == i) {
                if(i == N) {
                    int w = p[i];
                    p[i] = p[i-1];
                    p[i-1] = w;
                    count++;
                }else {
                    int w = p[i];
                    p[i] = p[i+1];
                    p[i+1] = w;
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 49308
def dijkstra_heap(n,s,edge,k):
    # 始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n  # True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heappush(edgelist, [e[k],e[2]])
    while edgelist:
        minedge = heappop(edgelist)
        # まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[2]]:
                heappush(edgelist, [e[k] + d[v], e[2]])
    return d

def examD():
    N, M, s, t = LI()
    edge = defaultdict(list)
#    edge2 = defaultdict(list)
    # edge2 メモリ無駄
    for i in range(M):
        x, y, z1, z2 = map(int, input().split())
        x -=1; y -=1
        edge[x].append((z1,z2,y))
        edge[y].append((z1,z2,x))
    start1 = s-1
    start2 = t-1
    res1 = dijkstra_heap(N,start1, edge,0)
    res2 = dijkstra_heap(N,start2, edge,1)
    ans = []
    snuke = 10**15
    cur = res1[N-1] + res2[N-1]
    ans.append(snuke-cur)
    for i in range(N-2,-1,-1):
        if res1[i] + res2[i]<cur:
            cur = res1[i] + res2[i]
            ans.append(snuke-cur)
        else:
            ans.append(snuke-cur)
    for v in ans[::-1]:
        print(v)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 121944
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int cnt = 0;
    while (A > 0 && C > 0) {
        if (cnt % 2) {
            A -= D;
        }
        else {
            C -= B;
        }
        cnt++;
    }

    cout << (cnt % 2 ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    ll q, h, s, d;
    ll n;

    cin >> q >> h >> s >> d;
    cin >> n;

    ll lcost = min(min(4*q, 2*h), s);
    ll rcost = min(2*lcost, d);

    ll res = (n/2)*rcost;

    if (n&1)
    {
        res += lcost;
    }

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;

    int a[n]; 
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans;
    ans=*max_element(a,a+n)-*min_element(a,a+n);

	
    cout<<ans<<endl;

	return 0;
}


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


int findMin(int h[], int n) {
	int cost[n];
	cost[0] = 0;
	cost[1] = abs(h[0] - h[1]);

	for(int i=2; i<n; i++)
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]),
			cost[i-2] + abs(h[i] - h[i-2]));

	return cost[n-1];
}

int main() {
	int n;
	int h[100000];
	cin>>n;
	for(int i=0;i <n; i++)
		cin>>h[i];


	cout<<findMin(h, n)<<endl;
}

Measured memory_bytes: 1024
def dp1(n,a):
    dp=[0]*(n+1)
    dp[0]=1
    ok=[True]*(n+1)
    for x in a:
        ok[x]=False
    if 1 not in a:
        dp[1]=1
    if n==1:
        return dp[1]
    else:
        for i in range(2,n+1):
            if ok[i]:
                dp[i]=(dp[i-1]+dp[i-2])%1000000007 
    return dp[n]

def main():
    n, m= map(int, input().split())
    a = [int(input()) for _ in range(m)]    
    print(dp1(n,a))

main()

Measured memory_bytes: 8616
#include <iostream>
#include <cstdlib>

using namespace std;

int min(int a,int b){
    if(a < b)return a;
    else return b;
}

int main(void){
    char trueSN,trueEW,falseSN,falseEW;
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1-x2<0){
        trueEW='R';
        falseEW='L';
    }else{
       trueEW='L';
       falseEW='R'; 
    }
    if(y1-y2<0){
        trueSN='U';
        falseSN='D';
    }else{
        trueSN='U';
        falseSN='D';
    }
    int deltaEW = abs(x1-x2);
    int deltaSN = abs(y1-y2);
    for(int i=0;i<deltaEW;i++){
        cout << trueEW;
    }
    for(int i=0;i<deltaSN;i++){
        cout << trueSN;
    }
    for(int i=0;i<deltaEW;i++){
        cout << falseEW;
    }
    for(int i=0;i<deltaSN;i++){
        cout << falseSN;
    }
    cout << falseSN;
    for(int i=0;i<=deltaEW;i++){
        cout << trueEW;
    }
    for(int i=0;i<=deltaSN;i++){
        cout << trueSN;
    }
    cout << falseEW << trueSN;
    for(int i=0;i<=deltaEW;i++){
        cout << falseEW;
    }
    for(int i=0;i<=deltaSN;i++){
        cout << falseSN;
    }
    cout << trueEW << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
bool used[(1<<18)+1];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<ll> a(n);
ll mi=inf,ma=-inf;
bool m=false,p=false;
for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>0)p=true;
    if(a[i]<0)m=true;
}
if(!p&&!m){
    cout<<0<<endl;
    return 0;
}
if(p&&!m){
    cout<<n-1<<endl;
     for(int i=0;i<n-1;i++){
         cout<<i+1<<" "<<i+2<<endl;
     }
}
else if(!p&&m){
    cout<<n-1<<endl;
    for(int i=n-2;i>=0;i--){
         cout<<i+2<<" "<<i+1<<endl;
     }
}
else{
    int nowma,nowmi;
    cout<<2*n-1<<endl;
    for(int i=0;i<n;i++){
        if(ma<a[i]){
            ma=a[i];
            nowma=i;
        }
        if(mi>a[i]){
            mi=a[i];
            nowmi=i;
        }
    }
    if(abs(ma)<abs(mi)){
        for(int i=0;i<n;i++){
            a[i]+=mi;
            cout<<nowmi+1<<" "<<i+1<<endl;
        }
         for(int i=n-2;i>=0;i--){
         cout<<i+2<<" "<<i+1<<endl;
     }
    }
    else{
        for(int i=0;i<n;i++){
            a[i]+=ma;
            cout<<nowma+1<<" "<<i+1<<endl;
        }
        for(int i=0;i<n-1;i++){
         cout<<i+1<<" "<<i+2<<endl;
     }
    }
}
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
def bubble_sort(A):
    cnt = 0
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in range(len(A)-1,i,-1):
            if A[j] < A[j-1]:
                [A[j],A[j-1]] = [A[j-1],A[j]]
                cnt += 1
                flag = 1
        i += 1
    print(*A)
    print(cnt)
    return A

bubble_sort(A)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main(){
    int s;cin>>s;
    set<int>num;
    num.insert(s);
    int tmp=s;
    int ans=1;
    while(1){
        tmp=func(tmp);
        if(num.count(tmp)){
            ans++;
            break;
        }else{
            num.insert(tmp);
            ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,c=1;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
    if(vec[i]!=vec[i+1]){
      c++;
    }
  }
  cout<<c<<endl;
  }


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

using namespace std;

using ll = long long;
const ll MOD = 1e9+7;
string ans="";


void push(vector<int> &s){
    for(int i=0; i<s.size(); i++){
        if(s[i]==1){
            ans+='U';
        }else if(s[i]==-1){
            ans+='D';
        }else if(s[i]==2){
            ans+='R';
        }else{
            ans+='L';
        }
    }
    for(int i=0; i<s.size(); i++){
        s[i]*=-1;
    }
}
int main(){
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    int dy=ty-sy; int dx=tx-sx;
    vector<int> round1;
    vector<int> round2;
    if(dx>0) round2.push_back(-2);
    else round2.push_back(2);
    
    if(dy>0){
        for(int i=0; i<dy; i++){
            round1.push_back(1);
            round2.push_back(1);
        }
        round2.push_back(1);
    }else{
        for(int i=0; i<dy; i++){
            round1.push_back(-1);
            round2.push_back(-1);
        }
        round2.push_back(-1);
    }

    if(dx>0){
        for(int i=0; i<dx; i++){
            round1.push_back(2);
            round2.push_back(2);
        }
        round2.push_back(2);
    }else{
        for(int i=0; i<dx; i++){
            round1.push_back(-2);
            round2.push_back(-2);
        }
        round2.push_back(-2);
    }

    if(dy>0) round2.push_back(-1);
    else round2.push_back(1);
    
    push(round1);
    push(round1);
    push(round2);
    push(round2);

    cout<<ans<<endl;

}

Measured memory_bytes: 384