akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def main():
  h, w = map(int, input().strip().split())
  dp = [[0]*(w+1) for _ in range(h+1)]
  maze = [input().strip() for _ in range(h)]
  dp[1][0] = 1
  for i in range(1, h+1):
    for j in range(1, w+1):
      if maze[i-1][j-1] == '#':
        continue
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MAX
  print(dp[-1][-1])


if __name__=='__main__':
  main()

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll x(n),y(n),h(n);
  ll sx,sy,sh;
  rep(i,n){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0) sx=x[i],sy=y[i],sh=h[i];
  }
  
  rep(i,101){
    rep(j,101){
      ll H=sh+abs(i-sx)+abs(j-sy);
      bool ok=true;
      rep(ki,n){
        ll d=max(H-abs(i-x[ki])-abs(j-y[ki]),0LL);
        if(h[ki]!=d){
          ok=false;
          break;
        }
      }
      if(ok){
        cout<<i<<" "<<j<<" "<<H<<endl;
        return 0;
      }
    }
  }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const ll INF=123456789012;

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

    vector<int> d(n),c(m);
    rep(i,n) scanf(" %d", &d[i]);
    rep(i,m) scanf(" %d", &c[i]);

    //?????????i????????????j??\?????????
    ll dp[1001][1001];
    fill(dp[0],dp[1001],INF);

    dp[0][0]=0;
    rep(j,m)
    {
        rep(i,n)
        {
            //?¬??????????????§????
            dp[i+1][j+1]=min(dp[i+1][j],dp[i][j]+d[i]*c[j]);
            //??????
            dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
        }
    }

    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 10988
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){
    
  double W,H,x,y,ans=0;

  cin >>W>>H>>x>>y;
  
  ans = W*H /2;

  printf("%.10f",ans);

  cout << ' ';

  if(W/2==x&&H/2==y){
    cout << '1' <<endl;
  }else{
    cout << '0' <<endl;
  }

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+10;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,pw2[N],pw3[N],fac[N],inv[N],ifac[N];

int C(int n,int m) {
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main() {
	n=gi();
	pw2[0]=pw3[0]=1;
	for(int i=1;i<=n;i++) {
		pw2[i]=2ll*pw2[i-1]%mod;
		pw3[i]=3ll*pw3[i-1]%mod;
	}
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	for(int i=2;i<=n;i++) {
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	int ans=pw3[n],sum=0;
	for(int i=n/2+1;i<=n;i++)
		sum=(sum+1ll*C(n,i)*pw2[n-i])%mod;
	cout<<(ans-2ll*sum%mod+mod)%mod;
	return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

namespace IntegerMath
{
  int64_t floor_div(int64_t x, int64_t y) {
    return x / y;
  }

  int64_t ceil_div(int64_t x, int64_t y) {
    return (x / y) + min(static_cast<int64_t>(1), x % y);
  }

  int64_t sqrt(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t log2(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log2l( 
        static_cast<long double>(x)
      ) )
    );
  }    

  int64_t log10(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log10l( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t number_of_digits(int64_t x) {
    return static_cast<int64_t>(
      ::ceill( ::log10l( 
        static_cast<long double>(x + 1)
      ) )
    );
  }

  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

class Prime
{
private:
  std::set<uint64_t> _primes;

  bool _is_prmie(uint64_t n) const {
    uint64_t m = IntegerMath::sqrt(n);
    for (uint64_t d : _primes) {
      if (n % d == 0) { return false; }
      if (d > m) { break; }
    }
    return true;
  }

public:
  Prime(uint64_t n) {
    _primes.insert(2);

    for (uint64_t i = 3; i <= n; i += 2) {
      if (_is_prmie(i)) {
        _primes.insert(i);
      }
    }
  }

  std::set<uint64_t> set() const { return _primes; }
};

int main()
{
  set<uint64_t> primes = Prime(1e+5).set();
  auto is_prime = [&primes](uint64_t n) { return primes.find(n) != primes.end(); };
  vector<uint64_t> cumsum(1e+5 + 2, 0);
  for (uint64_t n = 3; n <= 1e+5; ++n) {
    uint64_t m = (n + 1) >> 1;

    cumsum[n] = cumsum[n - 1];
    
    if ((n & 1) == 0) { continue; }
    
    if (is_prime(n) && is_prime(m)) {
      ++cumsum[n];
    }
  }

  uint64_t Q;
  cin >> Q;

  N_TIMES(q, Q) {
    uint64_t l, r;
    cin >> l >> r;

    cout << (cumsum[r] - cumsum[l - 1]) << endl;
  }

  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
map<string,int> mp;
string s;
int main()
{
	s="01";
	mp[s]=1;
	s="02";
	mp[s]=1;
	s="03";
	mp[s]=1;
	s="04";
	mp[s]=1;
	s="05";
	mp[s]=1;
	s="06";
	mp[s]=1;
	s="07";
	mp[s]=1;
	s="08";
	mp[s]=1;
	s="09";
	mp[s]=1;
	s="10";
	mp[s]=1;
	s="11";
	mp[s]=1;
	s="12";
	mp[s]=1;
	cin>>s;
	string s1,s2;
	s1+=s[0];
	s1+=s[1];
	s2+=s[2];
	s2+=s[3];
	if(mp[s1]==0&&mp[s2]==0)
	{
		cout<<"NA"<<endl;
	}
	if(mp[s1]==0&&mp[s2]==1)
	{
		cout<<"YYMM"<<endl;
		
	}
	if(mp[s1]==1&&mp[s2]==0){
		cout<<"MMYY"<<endl;
	}
	if(mp[s1]==1&&mp[s2]==1)
	{
		cout<<"AMBIGUOUS"<<endl; 
	} 
	
	
	
	
	
	
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	unordered_set<char> s;
	for (int i = 0; i < n; i++)
	{
		char si;
		cin >> si;
		s.insert(si);
	}
	cout << (s.size() == 3 ? "Three" : "Four") << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var b=sc.Ia;
		long d=0;
		for(int i = 0;i<=n;i++) {d+=a[i];}
		for(int i = 0;i<n;i++) {
			if(b[i]>a[i]){
				b[i]-=a[i];
				a[i]=0;
				a[i+1]=Max(a[i+1]-b[i],0);
			}
			else{a[i]-=b[i];}
		}
		for(int i = 0;i<=n;i++) {d-=a[i];}
		Console.WriteLine("{0}",d);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 31036
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=100005;
const ll INF=0x3f3f3f3f;
const ll MOD=1000000007;
ll n,ans[MAX],pt,pt_idx=MAX;
pll a[MAX];
int main(){
    scanf(" %lld",&n);
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i].x),a[i].y=i;
    sort(a,a+n+1);
    for(ll i=n;i>=1;i--){
        pt_idx=min(pt_idx,a[i].y);
        ans[pt_idx]+=(n+1-i)*(a[i].x-a[i-1].x);
    }
    for(ll i=1;i<=n;i++) printf("%lld\n",ans[i]);
    return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        sum += a-1;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
	int n;
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		char ch[5000];
		scanf("%s",ch);
		if(ch[0]=='M')a[1]++;else
		if(ch[0]=='A')a[2]++;else
		if(ch[0]=='R')a[3]++;else
		if(ch[0]=='C')a[4]++;else
		if(ch[0]=='H')a[5]++;
	}
	long long ans=0,p=1;
	for(int i=1;i<=3;i++)
		for(int j=i+1;j<=4;j++)
			for(int k=j+1;k<=5;k++)
			{
				p=a[i]*a[j]*a[k];
				ans+=p;
			}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fast;
    ll n, mn = 10000000001;
    cin >> n;
    vector<ll> a(n), dp(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(abs(a[i-1] - a[i]) + dp[i-1], abs(a[i-2] - a[i]) + dp[i-2]); 
    }
    cout << dp[n-1];
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll N; cin>>N;
    if(N==2){
        cout<<1<<endl;
        return 0;
    }
    set<ll> F;//factor
    for(ll i = 2; i <= sqrt(N); i++){
        if(N%i==0){
            F.insert(i);
            F.insert(N/i);
        }
    }

    for(ll i = 2; i <= sqrt(N-1); i++){
        if((N-1)%i==0){
            F.insert(i);
            F.insert((N-1)/i);
        }
    }

    ll res = 2;
    for(auto i: F){
        ll n = N;
        while(n>=i){
            if(n%i==0)n = n/i;
            else{
                if(n%i==1)n = 1;
                else break;
            }
        }
        if(n==1)res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3904
#include<iostream>
#include <cstdio>
bool f[100001];
int c[100002];
int N, L, R;
int main()
{
	for (int i = 2; i <= 100000; i++) if (!f[i]) for (int j = i + i; j <= 100000; j += i)
		f[j] = true;
	for (int i = 3; i <= 100000; i += 2) if (!f[i] && !f[(i + 1) / 2]) c[i]++;
	for (int i = 3; i <= 100000; i++) c[i] += c[i - 1];
	scanf("%d", &N);
	while (N--)
	{
		scanf("%d%d", &L, &R);
		printf("%d\n", c[R] - c[L - 1]);
	}
}

Measured memory_bytes: 1152
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  long N;
  scanln(N);
  N.rep!(() => readln.chomp).sort.uniq.count.writeln;
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 9364
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh=sorted(xyh,reverse=True,key=lambda x:x[2])
#print(xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1]-cy)
        for x,y,h in xyh:
            if h!= max(H - abs(x - cx) - abs(y - cy),0):
                break

        else:
            if H>=1:
                print(cx,cy,H)
                exit()


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

int main(){
    int n; cin >> n;
    int a[2][n];
    for(int j=0;j<2;j++){
        for(int i=0;i<n;i++){
            cin >> a[j][i];
        }
    }
    int MAX=0;
    int sum;
    for(int i=0;i<n;i++){
        sum = 0;
        for(int j=0;j<i+1;j++){
            sum += a[0][j];
        }
        for(int j=i;j<n;j++){
            sum += a[1][j];
        }
        MAX = max(MAX, sum);
    }
    cout << MAX << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll answer=0;
ll N,M;
multiset<ll,greater<ll>> rem;
int main() {
    cin >> N >> M;
    vector<P> js;
    REP(i,N) {
        ll A,B;
        cin >> A>>B;
        js.pb(P(M-A,B));
    }
    sort(ALL(js), [](P p, P q){
        return p.fi==q.fi ? p.se>q.se:p.fi>q.fi;
    });
    int p=0;
    for(ll i=M-1;i>=0;--i) {
        while(p<js.size()&&js[p].fi>=i)rem.insert(js[p++].se);
        if (!rem.empty()) {
            answer+=*rem.begin();
            rem.erase(rem.begin());
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 6512
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>

int getint()
{
	int x = 0, c = getchar();
	while (c > 47 && c < 58)
	{
		x = x * 10 + c - 48;
		c = getchar();
	}
	return x;
}

const int MAX = 300001;
int res[300001 * 4];

int main()
{
	int H = getint();
	int W = getint();
	int M = getint();

	int h, w, ans;
	int mxr = 0;
	int mxc = 0;
	int ctrow = 0;
	int ctcol = 0;
	for (int i = 0; i < M; ++i)
	{
		h = getint(), w = getint();
		res[i + 2 * MAX] = h, res[i + 3 * MAX] = w;
		int x = ++res[h], y = ++res[w + MAX];

		if (x == mxr)
			++ctrow;
		else if (x > mxr)
			mxr = x, ctrow = 1;

		if (y == mxc)
			++ctcol;
		else if (y > mxc)
			mxc = y, ctcol = 1;
	}
	ans = mxr + mxc;

	long ct = ctrow;
	ct *= ctcol;
	if (ct > M)
	{
		printf("%d\n", ans);
		return 0;
	}

	for (int i = 0; i < M; ++i)
		if (res[res[i + 2 * MAX]] == mxr && res[res[i + 3 * MAX] + MAX] == mxc)
			--ct;
	if (ct <= 0)
		--ans;
	printf("%d\n", ans);
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 1e5 + 5;
	int w[111],v[111];
	ll f[102][N];
	int n,W;

    void solve(){
    	cin>>n>>W;
    	for(int i = 1;i <= n;++i){
    		cin>>w[i]>>v[i];
    	}
    	for(int i = 1;i <= n;++i){
    		for(int j = 0;j <= W;++j){
    			maximize(f[i][j],f[i - 1][j]);
    			if(j >= w[i]){
    				maximize(f[i][j],f[i - 1][j - w[i]] + 1LL*v[i]);
    			}
    		}
    	}
    	cout<<f[n][W];
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 78336
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
R,C,K=map(int, sys.stdin.readline().split())

value=defaultdict(lambda: 0)
value=[ [0 for _ in range(C+1)] for __ in range(R+1) ]
for _ in range(K):
    r,c,v=map(int, sys.stdin.readline().split())
    value[r][c]=v

dp0=[0]*(C+1)
dp1=[0]*(C+1)
dp2=[0]*(C+1)
dp3=[0]*(C+1)

#dp1[1]=value[1][1]

for r in range(1,R+1):
    for c in range(1,C+1):
        #今のマスにアイテムがある場合
        if 0<value[r][c]:
            dp3[c]=max( dp3[c-1], dp2[c-1]+value[r][c] )
            dp2[c]=max( dp2[c-1], dp1[c-1]+value[r][c] )
            dp1[c]=max( dp1[c-1], dp0[c-1]+value[r][c], dp0[c]+value[r][c] )
            dp0[c]=max( dp0[c-1], dp0[c] )
        #今のマスにアイテムがない場合
        else:
            dp0[c]=max( dp0[c-1], dp0[c] )
            dp1[c]=max( dp1[c-1], dp1[c] )
            dp2[c]=max( dp2[c-1], dp2[c] )
            dp3[c]=max( dp3[c-1], dp3[c] )

    #上の行にアイテムをコピー
    for c in range(1,C+1):
        dp0[c]=max( dp0[c], dp1[c], dp2[c], dp3[c] )
    dp1=[0]*(C+1)
    dp2=[0]*(C+1)
    dp3=[0]*(C+1)

print dp0[C]


Measured memory_bytes: 153100
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

struct monster {
    int x; // pos
    int h; // health
};

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    vector<monster> M;
    for (int i = 0; i < N; i++) {
        int x, h;
        cin >> x >> h;
        M.push_back(monster{ x, h });
    }

    long long ans = 0;
    queue<pair<long, long>> end;
    long long current = 0;

    sort(M.begin(), M.end(), [](const monster &a, const monster &b) { return a.x < b.x; });

    for (auto m: M) {
        while (!end.empty() && end.front().first < m.x) {
            current -= A * end.front().second;
            end.pop();
        }
        int remain = m.h - current;
        if (remain > 0) {
            long long num = ceil((double)remain / A);
            ans += num;
            current += num * A;
            end.push(pair<long, long>(m.x + 2 * D, num));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3440
#include <stdio.h>
int main(void)
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    long long int ans=0;
    ans+=1800*m+100*n;
    for(int p=1;p<m+1;p++)ans*=2;
    printf("%lld",ans);
}


Measured memory_bytes: 128
from collections import deque


def find_farthest(adj, start):
    distance = [float("inf")] * len(adj)
    q = deque([(start, 0)])
    while len(q):
        cur, d = q.popleft()
        if distance[cur] <= d:
            continue
        distance[cur] = d
        for nxt in adj[cur]:
            if distance[nxt] > d+1:
                q.append((nxt, d+1))
    ret = 0
    for i, d in enumerate(distance):
        if d != float("inf"):
            ret = max(ret, d)
    return ret


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    adj = [set() for _ in range(H*W)]
    start = None
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                continue
            if i >= 1 and S[i-1][j] == ".":
                adj[i*W+j].add((i-1)*W+j)
                adj[(i-1)*W+j].add(i*W+j)
            if j >= 1 and S[i][j-1] == ".":
                adj[i*W+j].add(i*W+(j-1))
                adj[i*W+(j-1)].add(i*W+j)
            start = i*W+j
    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                ans = max(ans, find_farthest(adj, i*W+j))
    print(ans)


if __name__ == "__main__":
    main()


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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  if ( S == "RRR" ) std::cout << 3 << std::endl;
  else if ( S == "RRS" ) std::cout << 2 << std::endl;
  else if ( S == "SRR" ) std::cout << 2 << std::endl;
  else if ( S == "SSS" ) std::cout << 0 << std::endl;
  else std::cout << 1 << std::endl;
  return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
#define M 1000000007
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

#define B 310

int main() {
	long N, L, Q;
	long x[100001];
	long i, j, k;
	long a, b, tmp;
	long move1day[100001];
	long moveBday[100001] = {0};
	long right;
	long ans[100001] = {0};
	
	scanf("%ld", &N);
	for(i=1;i<=N;i++) scanf("%ld", &x[i]);
	scanf("%ld", &L);
	
	right = 2;
	for(i=1;i<=N;i++) {
		for(j=right;j<=N;j++) {
			if(x[j] - x[i] > L) {
				j--;
				break;
			}
		}
		move1day[i] = j;
		right = j;
	}
	
	for(i=1;i<=N;i++) {
		k = i;
		for(j=0;j<B;j++) {
			if(k >= N) break;
			k = move1day[k];
		}
		if(j == B) moveBday[i] = k;
	}
	
	scanf("%ld", &Q);
	for(i=1;i<=Q;i++) {
		scanf("%ld %ld", &a, &b);
		
		if(a > b) { tmp = a; a = b; b = tmp; }
		
		j = a;
		while(moveBday[j] > 0 && moveBday[j] < b) {
			j = moveBday[j];
			ans[i] += B;
		}
		
		for(;j<b;) {
			j = move1day[j];
			ans[i]++;
		}
	}
	
	for(i=1;i<=Q;i++) printf("%ld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double x_p0 = scan.nextDouble();
		double y_p0 = scan.nextDouble();
		double x_p1 = scan.nextDouble();
		double y_p1 = scan.nextDouble();
		double vx = x_p1 - x_p0;
		double vy = y_p1 - y_p0;
		int q = scan.nextInt();
		for(int i = 0; i < q; i++) {
			double x = scan.nextDouble();
			double y = scan.nextDouble();
			double ux = x - x_p0;
			double uy = y - y_p0;
			double t = dot(ux, uy, vx, vy);
			double f = 0.00000001;
			if(cross(vx, vy, ux, uy) > f) {
				System.out.println("COUNTER_CLOCKWISE");
			}else if(cross(vx, vy, ux, uy) < -f){
				System.out.println("CLOCKWISE");
			}else if(dot(vx, vy, ux, uy) < -f) {
				System.out.println("ONLINE_BACK");
			}else if(norm(vx, vy) < norm(ux, uy)) {
				System.out.println("ONLINE_FRONT");
			}else {
				System.out.println("ON_SEGMENT");
			}
		}
		scan.close();

	}
	static double dot(double x1, double y1, double x2, double y2) {
		return x1 * x2 + y1 * y2;
	}
	static double norm(double x1, double y1, double x2, double y2) {
		return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	}
	static double norm(double x, double y) {
		return x * x + y * y;
	}
	static double cross(double x1, double y1, double x2, double y2) {
		return x1 * y2 - y1 * x2;
	}
}


Measured memory_bytes: 41700
import Control.Monad (unless)
main = do
        n <- readLn
        unless ( n == (-1)) $ do
            print $ thirdRoot n
            main

thirdRoot :: Double -> Double
thirdRoot q = solver (q/2)
    where solver xn = if errIsSmall
                  then xn
                  else solver (funcX q xn)
                  where
                      errIsSmall = abs (xn^3 - q) < 0.00001 * q

funcX q xn = xn - (xn^3 - q)/(3 * xn^2)



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

int	main()
{
	string	str("1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51");
	int	K;
	cin	>> K;
	if (K == 32) {
		cout << 51 << endl;
		return 0;
	}
	if (K == 1) {
		cout << 1 << endl;
		return 0;
	}
	int	bgn_idx = 0;
	int	end_idx = 0;
	for (int i = 0; i < K; ++i) {
		++end_idx;
		bgn_idx = end_idx;
		while (str.at(end_idx) != ' ')
			++end_idx;
	}
	--end_idx;
	cout << stoi(str.substr(bgn_idx, end_idx - bgn_idx)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll INF=1000000007;
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll sum=0;
  ll ans=0;
  for(ll i=0;i<N;i++) {
cin>>A[i];
    sum+=A[i];
  }
  for(ll i=0;i<N-1;i++) {
    sum-=A[i];
    ans+=A[i]*(sum%INF);
    ans%=INF;
  }
  
  cout<<ans<<endl;
}

    
    
    
    

Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int ans=0;
    for (int i = 0; i <= s.size(); i++)
    {
        for (int j = 0; j <= s.size()-i; j++)
        {
            string t=s.substr(j,i);
            bool flg=true;
            for (int k = 0; k < t.size(); k++){
                if(t[k]!='A'&&t[k]!='C'&&t[k]!='G'&&t[k]!='T'){
                    flg=false;
                    break;
                }
            }
            if(flg==true){
                if(ans<t.size())ans=t.size();
            }
            
        }
        
    }
    cout<<ans;
    return 0;
}

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

const int mod = 1000000007;
signed main(void)
{
	long long n; cin >> n;
	long long a[n];
	long long ans, sum, cnt;

	rep(i, n) cin >> a[i];
	ans = 0;
	rep(k, 60) 
	{
		cnt = sum = 0;
		rep(i, n)
		{
			if (a[i] >> k & 1)
				cnt++;
		}
		sum = cnt * (n - cnt);
		rep(i, k)
		{
			sum *= 2;
			sum %= mod;
		}
		ans += sum;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main(void)
{
	int i, j, m, n, **A, *v, c;

	scanf("%d %d", &n, &m);
	A = (int **)malloc(sizeof(int *) * n);
	for (i = 0; i < n; i++) {
		A[i] = (int *)malloc(sizeof(int) * m);
	}
	v = (int *)malloc(sizeof(int) * m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &v[i]);
	}

	for (i = 0; i < n; i++) {
		c = 0;
		for (j = 0; j < m; j++) {
			c += A[i][j] * v[j];
		}
		printf("%d\n", c);
	}

	return 0;
}



Measured memory_bytes: 2104
# ABC157b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    # print(bing)

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[1][0]+bing[2][0] == -3 or bing[0][1]+bing[1][1]+bing[2][1] == -3 or bing[0][2]+bing[1][2]+bing[2][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;
 
signed main(){
	int N,A,B;
	in(N,A,B);
	if(A<B)swap(A,B);
	if((A-B)%2==0){
		out((A-B)/2);
		return 0;
	}
	int mi = min(B,N-A+1);
	out(mi+(A-B)/2);
}

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

int gcd( int x, int y ) {
    if ( y == 0 ) return x;
    else {
	return gcd( y, x % y );
    }
}

int main()
{
    int x, y;

    scanf("%d %d", &x, &y);

    printf("%d\n", gcd( x, y ));

    return 0;
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int Q = int.Parse(str[2]);
		int[,]A = new int[Q,4];
		for(var i=0;i<Q;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			A[i,2] = int.Parse(str2[2]);
			A[i,3] = int.Parse(str2[3]);
		}
		int[]B = new int[N];
		for(var i=0;i<N;i++){
			B[i] = 1;
		}
		int t = N-1;
		int ans = 0;
		while(true){
			int ct = 0;
			for(var i=0;i<Q;i++){
				if(B[A[i,1]-1]-B[A[i,0]-1]==A[i,2]){
					ct += A[i,3];
				}
			}
			ans = Math.Max(ans,ct);
			while(B[t]==M){
              t--;
              if(t<0){
                break;
              }
            }
          	if(t<0){
              break;
            }
          	B[t]++;
			for(var x=t;x<N;x++){
				B[x] = B[t];
			}
			t = N-1;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17884
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        m: usize,
        c: i64,
        bs: [i64; m],
        ass: [[i64; m]; n],
    }
    let mut count = 0;
    for i in 0..n {
        let mut tmp = 0;
        for j in 0..m {
            tmp += ass[i][j] * bs[j];
        }
        if tmp + c > 0 {
            count += 1;
        }
    }
    println!("{}", count);
}


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

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<n;i++){
    int point = a[i];
    int num=0;
    while(a[i+num]==point) num++;
    if(num%2==1) ans++;
    i+=num-1;
  }
  cout << ans << endl;
  return 0;
}


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

int max(int a,int b){
  if(a>b) return a;
  return b;
}

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    cout << a+max(a-1,b) << endl;
  }else{
    cout << b+max(a,b-1) << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n, m, sum;
int a[100];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for(int i = n; i >= n - m + 1; i--)sum += a[i];
	printf("%d\n", sum);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		
		Scanner sc =new Scanner(System.in);
		
		int N =sc.nextInt();
		int[] ar =new int[N];
		int[] br =new int[N];
		
		for(int i=0;i<N;i++){
			ar[i] = sc.nextInt();
			br[i] = sc.nextInt();			
		}
		int min=0;
		
		int m1=br[0];
		for(int i=1;i<N;i++){
			m1 = Math.min(m1,br[i]);
		}
		
		int count=0;
		
		for(int i=1;i<N;i++){
			if(m1==br[i]) count=i;
		}
		int result=ar[count]+br[count];
				
		System.out.println(result);

		
		
	}

}


Measured memory_bytes: 64948
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[100100][3],dp[100100][3];

int main(void){
	int n,i,j,k;
	ll ans=-INFLL;
	cin >> n;
	fill(dp[0],dp[100100],-INFLL);
	for(i=0; i<n; ++i){
		for(j=0; j<3; ++j){
			cin >> a[i][j];
		}
	}
	for(j=0; j<3; ++j){
		dp[0][j] = a[0][j];
	}
	for(i=1; i<n; ++i){
		for(j=0; j<3; ++j){
			for(k=0; k<3; ++k){
				if(j==k){
					continue;
				}
				dp[i][k] = max(dp[i][k],dp[i-1][j]+a[i][k]);
			}
		}
	}
	for(j=0; j<3; ++j){
		ans = max(ans,dp[n-1][j]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        List l = new ArrayList<>();
        int max = 1;
        for(int i = 2; i <= Math.sqrt(x); i++) {
            int j = 2;
            while(true) {
                if(Math.pow(i, j) > x) break;
                if(l.contains(Math.pow(i, j)))  break;
                else {
                    if(max < Math.pow(i, j)) {
                        max = (int)Math.pow(i, j);
                    }
                }
                j++;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  int n, k;
  cin >> n >> k;
  int lim = pow(2, n);
  if (k > lim-1){
      cout << -1;
      return 0;
  }
  if (k == 0){
      for (int i=0; i<lim; i++){
          cout << i << " ";
      }
      for (int i=lim-1; i>=0; i--){
          cout << i << " ";
      }
  }else if (n == 1 && k == 1){
      cout << -1;
  }else{
      cout << "0 ";
      cout << k << " 0 ";
      for (int i=1; i<lim; i++){
          if (i == k){
              continue;
          }
          cout << i << " ";
      }
      cout << k << " ";
      for (int i=lim-1; i>=1; i--){
          if (i == k){
              continue;
          }
          cout << i << " ";
      }
  }
  return 0; 
}

Measured memory_bytes: 1792
#include <iostream>

int main(){
   int N;
   std::cin >> N;

   int X = N;
   int sum = 0;
   while(X/10>0){
      sum += X%10;
      X /= 10;
   }
   sum += X%10;

   if(N%sum==0) std::cout << "Yes" << std::endl;
   else std::cout << "No" << std::endl;

   return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
pair<ll,ll> T[202020];
const ll mo=998244353;

template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	static V const def=0;
	// static V const def=1LL<<60; min
	V comp(V l,V r){ return max(l,r);};
	
	SegTree_1(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=comp(v,val[entry]); //上書きかチェック
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};
SegTree_1<int,1<<20> st;
int nex[202020];
ll dp[202020];
ll sum[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>T[i].first>>T[i].second;
	sort(T,T+N);
	
	sum[N]=1;
	for(i=N-1;i>=0;i--) {
		x=lower_bound(T+i+1,T+N,make_pair(T[i].first+T[i].second,0LL))-T;
		nex[i]=max(i+1,st.getval(i+1,x));
		st.update(i,nex[i]);
		dp[i]=sum[nex[i]]%mo;
		sum[i]=(sum[i+1]+dp[i])%mo;
	}
	cout<<sum[0]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
// const int INF = 1e9 + 7;

void test_case() {
    int n, w;
    cin >> n >> w;
    vector<ll> dp(w + 1);
    for (int item = 0; item < n; item++) {
        int weight, value;
        cin >> weight >> value;
		vector<ll> new_dp(w+1);
		for(int i=1;i<=w;i++){
			ll chosen = (i-weight >=0) ? (value + dp[i-weight]) : 0;
			ll not_chosen = dp[i];
			new_dp[i] = max(chosen, not_chosen);
		}
		dp = new_dp;
    }
	cout<<dp[w]<<endl;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) test_case();
    return 0;
}

Measured memory_bytes: 4724
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] + list(reversed(b)) + a
for i in range(n + m):
    c[i + 1] += c[i]
r = m
ans = 0
for l in range(m + 1):
    while r <= n + m and c[r] - c[l] <= k:
        ans = max(ans, r - l)
        r += 1
print(ans)


Measured memory_bytes: 115884
def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
s = int(input())

a = [0]
for i in range(1,10**6):
    if i == 1:
        x = s
    else:
        x = func(a[i-1])
    if x in a:
        print(i)
        break
    else:
        a.append(x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;


signed main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    rep(i,0,n){
        ll h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608