akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  cin >> N;
  double x[N];
  string u[N];
  rep(i,N) cin >> x[i] >> u[i];
  double ans = 0.0;
  rep(i,N)
  {
    ans += (u[i] == "JPY")? x[i] : x[i] * 380000;
  }
  printf("%.6f",ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
int dx,dy;
int ddx,ddy;
int main()
{
    scanf("%d%d%d%d",&dx,&dy,&ddx,&ddy);
    if(dx>ddx) swap(dx,ddx),swap(dy,ddy);
    if(ddx>dy) printf("0");
    else if(ddx<=dy&&ddy<=dy) printf("%d",ddy-ddx);
    else printf("%d",dy-ddx);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    int n=s.size()-2,ans=0;
    for(int i=n-1;i>=0;i-=2){
        bool check=true;
        for(int j=i;j>=(i+1)/2;j--){
            if(s[j]!=s[j-(i+1)/2]){
                check=false;
                break;
            }
        }
        if(check){
            ans=i+1;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//B優先でかたづければいいのでは？そんな簡単じゃない気がする
//5 10
//2 5
//4 6
int main(){
  ll N; cin>>N;
  vector<vector<ll>> T(N, vector<ll>(2.0));
  for(int i=0; i<N; i++){
    ll A,B; cin>>A>>B; T[i][0]=A, T[i][1]=B;
  }
  sort(T.begin(), T.end(), [](auto x, auto y){return x[1]<y[1];});
  ll time=0;
  for(int i=0; i<N; i++){
    time+=T[i][0];
    if(time>T[i][1]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

int main() {
	int x,y,s;
	int p[14][14]={};
	while(~scanf("%d,%d,%d",&x,&y,&s))
	{
		x+=2;y+=2;
		p[x][y]++;
		p[x-1][y]++;
		p[x+1][y]++;
		p[x][y-1]++;
		p[x][y+1]++;
		if(s!=1)
		{
			p[x-1][y-1]++;
			p[x-1][y+1]++;
			p[x+1][y-1]++;
			p[x+1][y+1]++;
		}
		if(s==3)
		{
			p[x-2][y]++;
			p[x+2][y]++;
			p[x][y-2]++;
			p[x][y+2]++;
		}
	}
	int white=0,max=0;
	for(int i=2;i<12;i++)
	{
		for(int j=2;j<12;j++)
		{
			if(p[i][j]==0)white++;
			else max=max<p[i][j]?p[i][j]:max;
		}
	}
	cout<<white<<endl<<max<<endl;
	return 0;
}

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

int main() {
	bool cups[3] = {true, false, false};
	char c[2];
	char d;
	while (cin >> c[0] >> d >> c[1]) {
		swap(cups[c[0] - 'A'],cups[c[1] - 'A']);
	}
	for (int i = 0; i < 3; ++i) {
		if (cups[i]) {
			cout << char('A' + i) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

void solve() {
  int x,n;  cin>>x>>n;
  set<int> a;
  for(int i=-100; i<=200; i++) {
    a.insert(i);
  }
  int z;
  rep(i,n) {
    cin>>z;
    a.erase(z);
  }
  int a1 = *(a.lower_bound(x));
  auto it = (a.lower_bound(x));it--;
  int a2 = *it;
  if((x-a2)<=(a1-x))  cout<<a2;
  else  cout<<a1;
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  ll t = 1;
//  cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n,y,b,t,r;
	while(cin>>n,n){
		cin>>y;
		priority_queue<pair<double,int> > data;
		int money =1000;
		rep(i, n){
			cin>>b>>r>>t;
			double sum = 0;
			if(t==1){
				sum =money*(1+y*((double)r/100));
			}else{
				sum =money*pow((1+(double)r/100),y);
			}
			data.push(mp(sum,b));
		}
		cout <<data.top().second<<endl;
	}
	return 0;
}

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

int main() {
  vector<int> vec(3);
  for (int i = 0; i < 3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  cout << vec.at(2) * 10 + vec.at(0) + vec.at(1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll cnt = 0;
	string s;
	in(s);
	rep(i, 0, s.size()) {
		if (s[i] == 'g') {
			cnt++;
		}
		else {
			cnt--;
		}
	}


	outn(cnt/2);
	return 0;

}


Measured memory_bytes: 512
#if TEST
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
#endif

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_156_c
    {
        
#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int N = ReadInt();
            int []ar = ReadIntArray();

            int maxAR = ar.Max();
            int minAR = ar.Min();

            int minDiff = CalcSum(ar, minAR);
            for(int p = minAR + 1; p <= maxAR; p++)
            {
                int diff = CalcSum(ar, p);
                if (diff < minDiff)
                {
                    minDiff = diff;
                }
            }

            Console.WriteLine(minDiff.ToString());
        }

        private static int CalcSum(int[] ar, int p)
        {
            int s = 0;
            for(int i = 0;i<ar.Length;i++)
            {
                s += (ar[i] - p) * (ar[i] - p);
            }

            return s;
        }

        static int Solve(int H, int A)
        {
            int d = H / A;
            int m = H % A;
            if (m > 0)
            {
                d++;
            }

            return d;
        }


        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }

#if TEST
#else
    }
}
#endif

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double sa = 2 * M_PI * h / 12.0;
    double sb = 2 * M_PI * m / 60.0;
    sa += M_PI / 6.0 * m / 60.0;
    //cerr << sa << " " << sb << endl;
    //cerr << sa - sb << endl;
    //cerr << cos( M_PI - M_PI/2) << endl;
    //cerr << 2 * M_PI * 80.0 / 360.0 << endl;
    //cerr << sqrt(a * a + b * b - 2 * a * b * cos(2 * M_PI * 80.0 / 360.0)) << endl;
        double x = sqrt(a * a + b * b - 2 * a * b * cos(sa - sb));
        printf("%.16f\n", x);
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll N;
  cin>>N;
  FOR(h,1,3501)FOR(n,1,3501){
    double a = 4.0/N - 1.0/h - 1.0/n;
    if(a==0)continue;
    int w = round(1.0/a);
    if(w<=0)continue;
    if(4ll*h*n*w == N*n*w + N*h*w + N*h*n){
      printf("%d %d %d\n",h,n,w);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.awt.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        ArrayList<String> arr=new ArrayList<>();
        for(int i=0;i<n;i++){
            char[] c=sc.nextLine().toCharArray();
//            long x=1;
//            for(int j=0;j<10;j++){
//                x=x*s.charAt(j);
//            }
//            arr.add(x);
            Arrays.sort(c);
            StringBuilder sb=new StringBuilder();
            for(int j=0;j<10;j++){
                sb.append(c[j]);
            }
            arr.add(sb.toString());
        }
        Collections.sort(arr);
        long z=0;
        long temp=0;
        for(int i=0;i<arr.size()-1;i++){
            if(arr.get(i).equals(arr.get(i+1))){
                temp++;
            }
            else{
                z=z+temp*(temp+1)/2;
                temp=0;
            }
        }
        z=z+temp*(temp+1)/2;
        System.out.println(z);

    }
}

Measured memory_bytes: 111892
#include <stdio.h>
#include <string.h>

int main(void){
   char str[101];
   int i,n,result=0;
   scanf("%s",str);

   n=strlen(str);

   for(i=0;i<n;i++){
      if((str[i]=='R') || (str[i])=='L'){
         if(i%2==0){
             if(str[i]!='R'){result=1;break;}
         } else {
             if(str[i]!='L'){result=1;break;}
         }
      }
   }
   if(result==0) printf("Yes\n");
   else printf("No\n");
   return 0;
}

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

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

    int n;
    int k, ans = 0;
    cin >> n >> k;
    while (n) {
        ans++;
        n /= k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int c = a+b;

    if(c%2 == 0) {
        cout << "Alice";
    }
    else {
        cout << "Borys";
    }
    
    cout << endl;
    return 0;
}

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

const ll mod=1e9+7;

ll modpow(ll a,ll n){
    if(n==0) return 1;
    else if(n==1) return a;
    else if(n%2) return a*modpow(a*a%mod,(n-1)/2)%mod;
    else return modpow(a*a%mod,n/2);
}

int main(){
    ll n;
    cin>>n;
    ll ans=modpow(10,n)-2*modpow(9,n)+modpow(8,n);
    while(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;

const int mod = 1e9 + 7;

template <int M> class Combination {
public:
  int n;
  vector<int> fac, finv;

  Combination(int n_) : n(n_), fac(n_), finv(n_) {
    fac[0] = 1;
    for (int i = 1; i < n; i++)
      fac[i] = fac[i - 1] * i % M;
    finv[n - 1] = pow(fac[n - 1], M - 2);
    for (int i = n - 1; i > 0; i--)
      finv[i - 1] = finv[i] * i % M;
  }

  int pow(int a, int b) {
    if (b == 0)
      return 1;
    return pow(a * a % M, b / 2) * (b % 2 ? a : 1) % M;
  }

  int C(int a, int b) {
    if (b < 0 or a < b)
      return 0;
    return fac[a] * finv[a - b] % M * finv[b] % M;
  }

  int P(int a, int b) {
    if (b < 0 or a < b)
      return 0;
    return fac[a] * finv[a - b] % M;
  }

  int H(int a, int b) {
    if (a == 0 and b == 0)
      return 1;
    return C(a + b - 1, b);
  }
};

signed main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  Combination<mod> comb(2000010);
  int ans = 0;
  rep(r, r1, r2 + 1) {
    int tmp1 = comb.fac[r+c2+1]*comb.finv[r+1]%mod*comb.finv[c2]%mod;
    int tmp2 = comb.fac[r+c1]*comb.finv[r+1]%mod*comb.finv[c1-1]%mod;
    ans += (tmp1-tmp2+mod)%mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
	int n,k,a,c=0;
	cin>>n>>k;
	rep(i,n){
		cin>>a;
		if(a>=k)c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
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; }
int N,T,i;
long ans,last,t;

inline void solve(){
  IN2(N,T);
  REP(i,N){
    IN(t);
    if(t<last){
      ans+=T-(last-t);
      last=t+T;
    }else{
      ans+=T;
      last=t+T;
    }
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll dp[110][110][410] = {0};
int main(){
  int N,W;
  cin>>N>>W;
  vector<ll> w(N),v(N);
  ll kizyun;
  for(int i(0);i<N;i++){
    cin>>w[i]>>v[i];
    if(i == 0) kizyun = w[i];
    w[i] -= kizyun;
  }
  for(int i(0);i<N;i++){
    for(int j(0);j<=i;j++){
      for(int k(0);k<=3*i;k++){
        dp[i+1][j+1][k+w[i]] = max(dp[i+1][j+1][k+w[i]],dp[i][j][k] + v[i]);
        dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
      }
    }
  }
  ll ans(0);
  for(int i(0);i<=N;i++){
    for(int j(0);j<=3*N;j++){
      if(kizyun*i + j <= W){
        ans = max(ans,dp[N][i][j]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 35072
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cerr << #x << " = " << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define vv vector<vector<ll>>

ll n,k,x,t,l;

ll add(ll& a,ll b)
{
	a+=b;
	if(a > MOD)
		a -= (a/MOD) * MOD;
}

vv d(55,vector<ll>(55,0));
vv id(55,vector<ll>(55,0));
vv matmul(vv& a,vv& b)
{
	vv c(55,vector<ll>(55,0));
	for(int i = 0; i < 50; ++i)
		for(int j = 0; j < 50; ++j)
			for(int k = 0; k < 50; ++k)
				add(c[i][j], a[i][k] * b[k][j]);
	return c;
}
vv exp(vv a,ll n)
{
	if(n==0) return id;
	if(n==1) return a;

	vv tmp;
	tmp = exp(a,n>>1);
	tmp = matmul(tmp,tmp);
	if((n&1) == 1)
		return matmul(tmp,a) ;
	else
		return tmp;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

	for (int i = 0; i < 55; ++i)
		id[i][i] = 1;
	cin >> n >> k;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> d[i][j];

	vv res;
	res = exp(d,k);
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			add(ans,res[i][j]);

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


Measured memory_bytes: 1920
H, W = map(int, input().split())
S = [0]*(H+2)
S[0] = ''.join(['#']*(W+2))
S[-1] = ''.join(['#']*(W+2))
for i in range(1,H+1):
  S[i] = '#'+input()+'#'

maxd = 0
import queue
dy = [1,0,-1,0]
dx = [0,1,0,-1]
for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]=='.':
      visited = [[False]*(W+2) for _ in range(H+2)]
      q = queue.Queue()
      visited[h][w] = True
      q.put([h,w,0])
      while not q.empty():
        a,b,c = q.get()
        #print(a,b,c)
        for i in range(4):
          y,x = a+dy[i], b+dx[i]
          if S[y][x]=='.' and visited[y][x]==False:
            q.put([y,x,c+1])
            visited[y][x]=True
      maxd = max(maxd,c)
print(maxd)


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

LL a, b, c;

void init(){
	LL ar[12345];

	sll3(a, b, c);
	for (int i = 1; i <= b; ++i)
	{
		ar[i] = a * i; 
		//printf("%d\n", ar[i]);
	}
	LL sum[1234];

	for (int i = 1; i <= b; ++i)
	{
		if(((a * i) % b) == c) {
			printf("YES\n");
			return;
		}
	}
	printf("NO\n");

}

int main(){
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	init();
	return 0;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    s = input()
    flag = False
    count = 0
    
    for i in range(len(s)):
        if s[i].isupper():
            count += 1

    if count > 2:
        print("WA")
        sys.exit()
    count = 0
    for i in range(len(s)):
        if (i == 0 and s[i] == "A"):
            flag = True
        
        if (2 <= i < len(s)-1):
            if (s[i] == "C"):
                count += 1


    if count != 1:
        flag = False

    if flag:
        print("AC")
    else:
        print("WA")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9492
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int,int> > S2;
  char ch;
  int sum=0;
  for(int i=0;cin>>ch;i++){
    if(ch=='\\')S1.push(i);
    else if(ch=='/' && S1.size()>0){
      int j=S1.top(); S1.pop();
      sum+=i-j;
      int a=i-j;
      while(S2.size()>0 && S2.top().first>j){
	a+=S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  vector<int> ans;
  while(S2.size()>0){ ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(),ans.end());
  cout<<sum<<endl;
  cout<<ans.size();
  for(int i=0;i<ans.size();i++){
    cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;

  return 0;
}
  
	
      
      



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

int main() {
    int K, X;
    cin >> K >> X;

    for (int i=X-K+1; i<=X+K-1; ++i) cout << i << " ";
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int p,q,r;
  cin>>p>>q>>r;
  if(p<q){
	if(r<q){
cout<<p+r<<endl;
    }else{
cout<<p+q<<endl;
    }
  }else{
if(r<p){
  cout<<r+q<<endl;
  }else{
cout<<q+p<<endl;
}
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << 1 << endl;
    } else if (a == b || b == c || c == a) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const long long INF = 1LL << 60;

//入力
int N;
long long h[100010];

//DPテーブル
long long dp[100010];

int main()
{
    //初期条件
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> h[i];
    //初期化（最小化問題なので、INFに初期化する)
    for (int i = 0; i < 100010; ++i)
        dp[i] = INF;
    //初期条件
    dp[0] = 0;

    //ループ
    for (int i = 0; i < N; ++i)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    //答え
    cout << dp[N - 1] << endl;
}

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

int N, x;
int a[100];
int sum = 0;
int t=0;

int main(){
	cin >> N >> x;
	for(int i=0; i<N; ++i){
		cin >> a[i];
		sum += a[i];
	}
	sort(a,a+N);
	
	for(int i=0; i<N; ++i){
		if(x>=a[i]){
			x -= a[i];
			++t;
		}
	}
	
	if(t == N && x!=0){
		--t;
	}
	
	cout << t;

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  char tempc = '0';
  int count = 0;
  int length = S.length();
  for(int i = 0; i < length; i++) {
    if(tempc == S[i]) {
      if((i + 1) < length) {
        tempc = '0';
        i++;
        count++;
      }
    } else {
      tempc = S[i];
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3480
import sys
sys.setrecursionlimit(10**9)

N, u, v = map(int, input().split())
u, v = u-1, v-1
edge = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)

taka = [0] * N
aoki = [0] * N

def dfs(v, pre, cost, i):
    for e in edge[v]:
        if e == pre:
            continue
        cost = dfs(e, v, cost, i+1)
    cost[v] = i
    return cost

taka = dfs(u, -1, [0] * N, 0)
aoki = dfs(v, -1, [0] * N, 0)

m = 0
for i in range(N):
    if taka[i] < aoki[i]:
        m = max(m, aoki[i])

print(m-1)


Measured memory_bytes: 102420
#include<iostream>
#include<cmath>
#include<set>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, D;
  cin >> N >> D;

  int X[N][D];
  rep(i,0,N-1) {
    rep(j,0,D-1) {
      cin >> X[i][j];
    }
  }

  set<int> p;
  rep(i,1,500) p.insert(i*i);

  int ans = 0;
  rep(i,0,N-1) {
    rep(j,i+1,N-1) {
      int x = 0;
      rep(k,0,D-1) {
        x += pow(X[j][k] - X[i][k], 2);
      }
      if (p.count(x) != 0) ans++;
    }
  }

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


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 l = sc.nextInt();
        int cnt = 0;

        while(n > 0){
            cnt++;
            n=(n/l);
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
N;a;b;c;z;x;y;char s[9];main(){for(;scanf("%d",&N),N;printf("%d\n",z))for(a=z=1,b=2,c=3;N--;z+=a){scanf("%s",s);x=a;y=b;*s==78?a=b,b=7-x:*s==69?a=7-c,c=x:*s==87?a=c,c=7-x:*s==83?a=7-b,b=x:*s==82?b=c,c=7-y:*s==76?b=7-c,c=y:0;}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define LL long long

const int mo=1e9+7;

int n,m,LINE,ROW,cnt,con;
bool g[1010][1010];
LL k;

struct matrix{
	int a,b,d;
	matrix() {}
	matrix(int a,int b,int d):a(a),b(b),d(d) {}
	matrix operator * (const matrix &m) const
	{
		matrix Ans;
		Ans.a=(LL)a*m.a%mo;
		Ans.b=((LL)a*m.b%mo+(LL)b*m.d%mo)%mo;
		Ans.d=(LL)d*m.d%mo;
		return Ans;
	}
};

int power(int x,LL k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

matrix power(matrix x,LL k)
{
	matrix res=matrix(1,0,1);
	for (;k;x=x*x,k>>=1)
		if (k&1) res=res*x;
	return res;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	char c;
	scanf("%d%d%lld",&n,&m,&k);
	if (k==0||k==1) {puts("1"); return 0;}
	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
	{
		c=getchar();
		while (c!='.'&&c!='#') c=getchar();
		cnt+=g[i][j]=c=='#';
	}

	for (i=1;i<=n;i++)
		ROW+=g[i][1]&&g[i][m];

	for (i=1;i<=m;i++)
		LINE+=g[1][i]&&g[n][i];

	if (ROW&&LINE) {puts("1"); return 0;}
	if (!ROW&&!LINE)
	{
		printf("%d\n",power(cnt,k-1));
		return 0;
	}
	if (ROW)
	{
		for (i=1;i<=n;i++)
		for (j=1;j<m;j++)
			con+=g[i][j]&&g[i][j+1];
		matrix mat=power(matrix(cnt,con,ROW),k-1);
		printf("%d\n",(mat.a+mo-mat.b)%mo);
	}
	else
	{
		for (i=1;i<n;i++)
		for (j=1;j<=m;j++)
			con+=g[i][j]&&g[i+1][j];
		matrix mat=power(matrix(cnt,con,LINE),k-1);
		printf("%d\n",(mat.a+mo-mat.b)%mo);
	}
}


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

using namespace std;

struct edge {
  int to, cap, rev;
};

vector<vector<edge>> G(101);
vector<bool> used(1001);

void add_edge(int from, int to, int cap) {
  G[from].push_back((edge){to, cap, (int)G[to].size()});
  G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
  if (v == t) return f;
  used[v] = true;
  for (size_t i = 0; i < G[v].size(); i++) {
    edge &e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    fill(used.begin(), used.end(), false);
    int f = dfs(s, t, numeric_limits<int>::max());
    if (f == 0) return flow;
    flow += f;
  }
}

int main() {
  int V, E;
  cin >> V >> E;
  vector<int> c(E);
  for (int i = 0; i < E; ++i) {
    int from, to, cap;
    cin >> from >> to >> cap;
    add_edge(from, to, cap);
  }
  cout << max_flow(0, V - 1) << endl;
}


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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void vin(std::vector<T> &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void vout(std::vector<T> &a){
  for(auto x: a)
    cout << x << " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n; cin >> n;
  std::vector<ll> p(n);
  vin(p);
  std::vector<ll> inv(n+1);
  for(int i=0; i<n; i++)
    inv[p[i]]=i;
  ll r=0;
  set<ll> s{-1, inv[n], n};
  for(ll i=n-1; i>0; i--){
    ll a=-3, b, c, d, e=-3;
    c=inv[i];
    auto it=s.upper_bound(c);
    d=*it;
    it++;
    if(it!=s.end())
      e=*it;
    it--; it--;
    b=*it;
    if(it!=s.begin()){
      it--;
      a=*it;
    }

    // cerr<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<"\n";
    if(a!=-3)
      r+=i*(b-a)*(d-c);
    if(e!=-3)
      r+=i*(c-b)*(e-d);

    // cerr << r <<"\n";
    s.insert(inv[i]);
  }
  cout << r << "\n";
}


Measured memory_bytes: 6528
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
    ll n;
    cin >> n;
    ll a, ans=0;
    for(ll i=0; i<n; i++) {
        cin >> a;
        while(a%2==0) {
            a/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0; 
}


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

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

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> ac(n);
    ac[0] = 0;
    for(int i=1; i < n; i++){
        if(s[i-1] == 'A' and s[i] == 'C'){
            ac[i] = ac[i-1] + 1;
        }else{
            ac[i] = ac[i-1];
        }
    }
    int l, r;
    for(int i=0; i < q; i++){
        cin >> l >> r;
        cout << ac[r-1] - ac[l-1] << endl;
    }
}


Measured memory_bytes: 1488
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define L(__) (__ << 1)
#define R(__) (L(__)|1) 
#define LL long long
#define oo (1<<30)
#define N 300005
using namespace std;
int st1[N],top1,st2[N],top2;
int n,w,h,m,z[N],ans,A[4*N],add[4*N];
struct dot{
	int x,y;
	dot(int _x=0,int _y=0){ x=_x,y=_y;}
}a[N],b[N];
bool cmp(const dot &p,const dot &q){ return p.x<q.x||(p.x==q.x&&p.y<q.y);}
int map(int x){ return lower_bound(z+1,z+m+1,x)-z;}
void update(int t){ A[t]=max(A[L(t)],A[R(t)]);}
void build(int t,int l,int r)
{
	int mid=(l+r)>>1; add[t]=0;
	if(l==r){ A[t]=-z[l]; return ;}
	build(L(t),l,mid);
	build(R(t),mid+1,r);
	update(t);
}
void Add(int t,int d){ add[t]+=d,A[t]+=d;}
void push(int t)
{
	if(add[t]==0) return ;
	Add(L(t),add[t]);
	Add(R(t),add[t]);
	add[t]=0;
}
void modify(int t,int l,int r,int l1,int r1,int d)
{
	int mid=(l+r)>>1;
	if(l>r1||r<l1||l1>r1) return ;
	if(l>=l1&&r<=r1) return Add(t,d);
	push(t);
	modify(L(t),l,mid,l1,r1,d);
	modify(R(t),mid+1,r,l1,r1,d);
	update(t);
}
void solve(int n)
{
	int i,mi=(h>>1);
	for(i=1;i<=n;i++) a[i]=b[i];
	sort(a+1,a+n+1,cmp);
	if(a[n].x<w)
		a[++n]=dot(w,0);
	top1=top2=0;
	for(i=1;i<=n;i++) z[i]=a[i].x;
	m=n,z[++m]=0,z[++m]=w;
	sort(z+1,z+m+1);
	m=unique(z+1,z+m+1)-z-1;
	for(i=1;i<=n;i++)
		a[i].x=map(a[i].x);
	build(1,1,m);
	if(a[1].x>1)
		modify(1,1,m,1,1,h);
	a[0].x=1;
	for(i=1;i<=n;i++){
		if(a[i].y<=mi){
			modify(1,1,m,a[i].x,a[i].x,h);
			ans=max(ans,A[1]+z[a[i].x]);
			modify(1,1,m,a[st1[top1]].x,a[i].x-1,-a[i].y);
			while(top1&&a[st1[top1]].y<=a[i].y){
				modify(1,1,m,a[st1[top1-1]].x,a[st1[top1]].x-1,a[st1[top1]].y-a[i].y);
				top1--;
			  }
			st1[++top1]=i;
		  }
		else{
			modify(1,1,m,a[i].x,a[i].x,h);
			ans=max(ans,A[1]+z[a[i].x]);
			modify(1,1,m,a[st2[top2]].x,a[i].x-1,a[i].y-h);
			while(top2&&a[st2[top2]].y>=a[i].y){
				modify(1,1,m,a[st2[top2-1]].x,a[st2[top2]].x-1,a[i].y-a[st2[top2]].y);
				top2--;
			  }
			st2[++top2]=i;
		  }
	  }
}
int main()
{
	int i;
	scanf("%d %d %d",&w,&h,&n);
	for(i=1;i<=n;i++)
		scanf("%d %d",&b[i].x,&b[i].y);
	solve(n);
	for(i=1;i<=n;i++) swap(b[i].x,b[i].y);
	swap(w,h);
	solve(n);
	cout<<ans*2;
	return 0;
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  long n;
  cin >> n;
  long l[n], r[n];
   for(int i=0; i<n; i++){
  cin >> l[i] >> r[i];
   }
  long sum=0;
  for(int i=0; i<n; i++){
  	sum= sum+(r[i]-l[i]+1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n], b: [usize; n]);

    if let Some(ans) = solve(n, &a, &b) {
        println!("Yes");
        println!("{}", ans.iter().map(|&v| v.to_string()).join(" "))
    } else {
        println!("No")
    }
}

fn solve(n: usize, a: &[usize], b: &[usize]) -> Option<Vec<usize>> {
    let mut d = 0;
    let b = [b; 2].concat();
    while (0..n).any(|i| a[i] == b[i + d]) {
        for i in (0..n).rev() {
            while a[i] == b[i + d] {
                d += 1;
                if d >= n {
                    return None;
                }
            }
        }
    }
    Some((&b[d..d + n]).into())
}


Measured memory_bytes: 12568
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, m;
  cin >> n >> m;
  int kotae[10] = {};
  int ok = 1;
  for (int i = 0; i < 10; i++){
    kotae[i] = -1;
  }
  ll s, c;
  for (int i = 0; i < m; i++){
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0 && n != 1){
      ok = 0;
    }
    else if (s >= n){
      ok = 0;
    }
    else if (kotae[s] == -1){
      kotae[s] = c;
    }
    else if (kotae[s] > 0 && kotae[s] != c){
      kotae[s] = -2;
      ok = 0;
    }
 }

  if (ok){
    if (n == 1 && m == 0)
      cout << 0;
    else if (kotae[0] == -1){
      cout << "1";
    }
    else {
      cout << kotae[0];
    }
    for (int i = 1; i < n; i++){
      if (kotae[i] == -1)
        cout << "0";
      else 
        cout << kotae[i];
    }
    cout << endl;
  }
  else 
    cout << -1 << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> w >> h;
    if (h == 1 || w == 1) cout << 1 << '\n';
    else if (w & 1) {
        cout << w * (h / 2) + (h & 1 ? (w + 1) / 2 : 0) << '\n';
    } else {
        cout << w / 2 * h << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, k;
  scanf("%lld %lld", &n, &k);

  if(k == 0){
    printf("%lld\n", n * n);
    return 0;
  }

  llong ans = 0;
  FOR(i,k+1,n+1){
    llong count = (n - k) / i;
    llong num = i - k;
    ans += num;
    if(count >= 2){
      ans += num * (count - 1);
    }
    //cout << count << " " << ans << endl;
    if(count >= 1){
    if(n % i >= k){
      ans += (n % i) - k + 1;
    }else{
      ans += num;
    }
    //cout << ans << endl;
  }
  }
  printf("%lld\n", ans);
  return 0;
}



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

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a[5];
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a + 3);
	if ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[1] != a[0]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<math.h>
#include<vector>
using namespace std;

double ManhattanDistance(vector<int> x, vector<int> y){
	int n = x.size();
	double d = 0;
	for(int i = 0; i < n; i++) d += abs( x[i] - y[i] );
	return d;
}

double EuclidDistance(vector<int> x, vector<int> y){
	int n = x.size();
	double D = 0;
	for(int i = 0; i < n; i++) D += (x[i] - y[i]) * (x[i] - y[i]);
	return sqrt(D);
}

double CubeRootDistance(vector<int> x, vector<int> y){
	int n = x.size();
	double D = 0;
	for(int i = 0; i < n; i++) D += abs( (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]) );
	return pow(D, 1.0 / 3.0);
}

double ChebyshevDistance(vector<int> x, vector<int> y){
	int n = x.size();
	double d = abs( x[0] - y[0] );
	for(int i = 1; i < n; i++) if( abs( x[i] - y[i] ) > d ) d = abs( x[i] - y[i] );
	return d;
}

vector<int> Enter(int n){
	vector<int> z;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		z.push_back(a);
	}
	return z;
}

int main(){
	int n;
	cin >> n;
	vector<int> x = Enter(n);
	vector<int> y = Enter(n);
	cout << fixed << setprecision(6)
		 << ManhattanDistance(x, y) << endl
		 << EuclidDistance(x, y) << endl
		 << CubeRootDistance(x, y) << endl
		 << ChebyshevDistance(x, y) << endl;
	return 0;
}

Measured memory_bytes: 1336
#include <stdio.h>
#include <stdlib.h>
#include<math.h>

int main()
{
     long long i, j, X, Y;
     scanf("%lld %lld",&X,&Y);
     j = 1;
     if(X%Y==0)
        printf("-1");
     else
     {
         for(i=X;i<=pow(10,18);i=X*j)
         {
             j++;
             if(i>X&&i%Y!=0)
             {
                 printf("%lld",i);
                 break;
             }

         }
         if(i>pow(10,18))
            printf("-1");
     }
     return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

int N, W;
vector<int> w, v;

// [k, ..., N-1]番目の品物で重さp以下に抑えるときの価値の最大値を求める
vector<vector<LLI>> dp(100, vector<LLI>(100001, -1));

LLI f(int k, int p)
{
    if (k == N)
    {
        return 0;
    }

    if (dp[k][p] >= 0)
    {
        return dp[k][p];
    }

    if (w[k] > p)
    {
        dp[k][p] = f(k + 1, p);
    }
    else
    {
        dp[k][p] = max(f(k + 1, p), f(k + 1, p - w[k]) + v[k]);
    }

    return dp[k][p];
};

int main(int argc, char *argv[])
{

    cin >> N >> W;

    for (int i = 0; i < N; i++)
    {
        int ww, vv;
        cin >> ww >> vv;
        w.emplace_back(ww);
        v.emplace_back(vv);
    }

    LLI a = f(0, W);
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 79488
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		long[][] x = new long[N][2];
		for (int i=0;i<N;i++) {
			for (int j=0;j<2;j++) {
				x[i][j]=sc.nextLong();
			}
		}
		Arrays.sort(x,Comparator.comparingLong(o -> o[0]));
		int num=0;
		Long cost=(long)0;
		while (M>0) {
			if (M>=x[num][1]) {
				M=M-x[num][1];
				cost=cost+x[num][0]*x[num][1];
				num++;
			}else {
				break;
			}
		}
		if (M>0) {
			cost=cost+x[num][0]*M;
		}
		System.out.println(cost);
	}
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	int A, B;
	cin >> A >> B;
	if ((A+B) % 2 != 0) {
		puts("IMPOSSIBLE");
		return 0;
	}
	cout << (A + B) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256