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

class FC{
public:
	int p[31];
	int n;

	bool is_over()
	{
		return p[1]==p[2]&&p[2]==p[3]&&p[3]==p[4]&&p[4]==p[5]&&p[5]==p[6]&&p[6]==p[7]&&p[7]==p[8]&&p[8]==p[9]&&p[10]==p[11]&&p[11]==p[12]&&p[13]==p[14]&&p[14]==p[15]&&p[16]==p[17]&&p[17]==p[18]&&p[19]==p[20]&&p[20]==p[21]&&p[22]==p[23]&&p[23]==p[24]&&p[24]==p[25]&&p[25]==p[26]&&p[26]==p[27]&&p[27]==p[28]&&p[28]==p[29]&&p[29]==p[30];

	}

	void rot1(){
		swap(p[7],p[22]);
		swap(p[8],p[23]);
		swap(p[9],p[24]);
		swap(p[13],p[18]);
		swap(p[10],p[12]);
	}
	void rot2(){
		swap(p[1],p[28]);
		swap(p[2],p[29]);
		swap(p[3],p[30]);
		swap(p[15],p[16]);
		swap(p[19],p[21]);
	}
	void rot3(){
		swap(p[1],p[24]);
		swap(p[4],p[27]);
		swap(p[7],p[30]);
		swap(p[16],p[18]);
		swap(p[10],p[21]);
	}
	void rot4(){
		swap(p[3],p[22]);
		swap(p[6],p[25]);
		swap(p[9],p[28]);
		swap(p[13],p[15]);
		swap(p[19],p[12]);
	}
};
int main(){
	int N;
	cin>>N;

	for(int i=0;i<N;i++){
		FC now;
		for(int j=1;j<=30;j++){
			cin>>now.p[j];
		}
		now.n=0;

		queue<FC>que;
		que.push(now);

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

			if(now.is_over()){
				cout<<now.n<<endl;
				break;
			}
	
			FC nex1=now;nex1.rot1();nex1.n++;que.push(nex1);
			FC nex2=now;nex2.rot2();nex2.n++;que.push(nex2);
			FC nex3=now;nex3.rot3();nex3.n++;que.push(nex3);
			FC nex4=now;nex4.rot4();nex4.n++;que.push(nex4);
			}
	}
	return 0;
}

Measured memory_bytes: 12168
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N;
  cin >> N;
  P p[55];
  ll i, j, k;
  P sa[55][55]={};
  map<P, ll> mp;
  
  for(i=0; i<N; i++) {
    cin >> p[i].ft >> p[i].sc;
  }
  sort(p, p+N);
  
  ll ans=0;
  for(i=0; i<N; i++) {
    for(j=i+1; j<N; j++) {
      ll x1=p[i].ft;
      ll x2=p[j].ft;
      ll y1=p[i].sc;
      ll y2=p[j].sc;
      
      mp[P(x2-x1, y2-y1)]++;
      
    }
  }
  
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    chmax(ans, it->sc);
  }
  
  pt(N-ans);
  
  
}












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

long long r, d, x[20];

int main()
{
    cin >> r >> d >> x[0];
    for (int i = 1; i <= 10; ++i)
    {
        x[i] = x[i - 1] * r - d;
        cout << x[i] << endl;
    }
    return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  int mn=10000,mx=-1;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    mn = min(t, mn);
    mx = max(t, mx);
  }
  cout<<mx-mn<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define INF 1e9

using namespace std;

int abs(int a) {
    if(a < 0) {
        return -a;
    }
    return a;
}

void chmin(int& a, int b) {
    if(a > b) {
        a = b;
    }
    return;
}

int main() {
    int N;
    cin >> N;
    int h[N];
    for(int i = 0; i< N; i++) cin >> h[i];
    int dp[N];
    dp[0] = 0;
    for(int i = 1; i < N; i++) dp[i] = INF;

    for(int i = 1; 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;

    return 0;
}

Measured memory_bytes: 1024
H,W=map(int,input().split())
S=[input() for _ in range(H)]

padded = []
for i in range(H+2):
  if i == 0 or i == H+1:
    padded.append('.'*(W+2))
  else:
    padded.append('.'+S[i-1]+'.')
    
def calc(row,col):
  out=0
  for i in range(3):
    for j in range(3):
      if padded[row-1+i][col-1+j]=='#':out+=1
  return out

ans=[[] for _ in range(H)]
for i in range(1,H+1):
  for j in range(1,W+1):
    if padded[i][j]=='#':
      ans[i-1].append('#')
      continue
    tmp = calc(i,j)
    ans[i-1].append(str(tmp))
  ans[i-1] = ''.join(ans[i-1])

for i in range(H):
  print(ans[i])

Measured memory_bytes: 9208
#include<stdio.h>
main(){
  int i,x,y;
  for(i=0;;i++){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0)break;
    if(x>y){
      printf("%d %d\n",y,x);
    }
    else{
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
cin>>a>>b;
int t=((b-a-1)*(b-a-1)+b-a-1-2*a)/2;
cout<<t;
return 0;
}

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

using namespace std;

int main() {
    int i,j,n,p,q,temp;
    int t=0;
    int flag=0;
    string s;
int k;
    cin>>n>>k;
    cin>>s;
    if(s[k-1]=='A')s[k-1]='a';
    else if(s[k-1]=='B')s[k-1]='b';
    else{s[k-1]='c';}
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<bool> m(b, false);
  int now = a;
  now %= b;
  while(1){
    if(m.at(now) == false){
      m.at(now) = true;
      now += a;
      now %= b;
    }else break;
  }
  if(m.at(c) == true) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  string s;
  cin>>s;
  int kk=s.size();
  int i;
  vector<char> a(kk);
  vector<char> d(kk);
  LOOP(i,s.size()){
    if(i%2==1){
      a[i]='0';
      d[i]='1';
    }
    else{
      a[i]='1';
      
      d[i]='0';
    }
  }

  
  int ans=0;
  int z=0;
  int x=0;
  LOOP(i,s.size()){
    if(s[i]!=a[i]) z++;
    else if(s[i]!=d[i]) x++;
  }
  ans=min(z,x);
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    for(int i=1;i<=k-1;i++)
    {
        cout<<(n-k+i)<<" ";
    }
    cout<<n<<" ";
    for(int i=1;i<=k-1;i++)
    {
        cout<<(n+i)<<" ";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int n;
int tmps[43][43];

int main(int argc,char const* argv[])
{
  cin >> n;
  cout << n/3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define RMAX 4294967295
#define equals(a,b)(fabs((a)-(b))<EPS)

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef complex<double> comp;
typedef vector<complex<double>> vcomp;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef string::const_iterator State;
class ParseError {};
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



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

	int N;
	cin >> N;
	vi num(100011, 0);
	rep(i, N) {
		int a;
		cin >> a;
		num[a]++;
	}
	int ans = 0;
	repl(i, 1, 100000) {
		ans = max(ans, num[i - 1] + num[i] + num[i + 1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int m,d;
	int i,j;
	int cnt;
	int x,y,z;
	cin>>m>>d;
	cnt=0;
	for(i=1;i<=m;i++){
		for(j=1;j<=d;j++){
			z=j;
			y=z%10;
			z/=10;
			x=z%10;
			if(x>=2){
				if(y>=2){
					if(x*y==i){
						//cout<<i<<" "<<j<<" "<<i<<" "<<y<<x<<endl;
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  int n;
  cin >> n;
  VI v(n);
  REP(i, n) {
    cin >> v[i];
  }

  SORT(v);
  REVERSE(v);

  ll ans = 0;
  int idx = 0;
  int cnt = 0;
  // 最初
  ans = v[0];
  idx = 1;
  cnt = 1;

  while (cnt < n - 1) {
    ans += v[idx] * 2;
    idx++;
    cnt += 2;
    // ANS(ans);
  }
  if(n%2==1){
    ans -= v[idx - 1];
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3fll
using namespace std;
int n,x,sum=0;
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		sum+=x-1;
	}
	printf("%d\n",sum);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int N, T, A; cin >> N >> T >> A;
    vector<int> H(N); REP(i, N) cin >> H[i];

    double res = 10000007.0;
    int result = 0;
    REP(i, N) {
        double cnt = abs(A - (T - H[i] * 0.006));
        if(res > cnt) {
            res = cnt;
            result = i + 1;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	ll ans=0;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N);
	for(int i=0;i<N-1;i++) cin>>B[i];
	A[0]=B[0];
	A[N-1]=B[N-2];
	for(int i=1;i<N-1;i++){
		A[i]=min(B[i],B[i-1]);
	}
	for(int i=0;i<N;i++){
		ans+=A[i];
		//cout<<A[i]<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A1,A2,A3;
  cin>>A1>>A2>>A3;
  int sum=A1+A2+A3;
  if(sum>=22){
    cout<<"bust"<<endl;}
   else {
    cout<<"win"<<endl;}
  return 0;
}


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

int zettaichi(int a,int b){
  int ans;
  ans = max(a-b,b-a);
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  vector<int> dp(n);
  dp[0] = 0;
  dp[1]=zettaichi(h.at(1),h.at(0));
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+zettaichi(h.at(i),h.at(i-1)),dp[i-2]+zettaichi(h.at(i),h.at(i-2)));
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

  


Measured memory_bytes: 1024
#include<stdio.h>
int J[10001][10001],O[10001][10001],I[10001][10001];
int a[100001],b[100001],c[100001],d[100001];
char joi[10001][10001];
int main(void)
{
	int M,N,K,i,j,sumJ,sumO,sumI;
	scanf("%d%d%d",&M,&N,&K);
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			scanf(" %c",&joi[i][j]);
		}
	}
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			J[i][j]=0;
			O[i][j]=0;
			I[i][j]=0;
		}
	}
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			if(joi[i][j]=='J'){
				J[i][j]++;
			}
			if(joi[i][j]=='O'){
				O[i][j]++;
			}
			if(joi[i][j]=='I'){
				I[i][j]++;
			}
			J[i][j+1]+=J[i][j];
			O[i][j+1]+=O[i][j];
			I[i][j+1]+=I[i][j];
		}
	}
	for(i=1;i<=N;i++){
		for(j=1;j<M;j++){
			J[j+1][i]+=J[j][i];
			O[j+1][i]+=O[j][i];
			I[j+1][i]+=I[j][i];
		}
	}
	for(i=1;i<=K;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	for(i=1;i<=K;i++){
		sumJ=0;
			sumJ+=J[c[i]][d[i]];
			sumJ-=J[a[i]-1][d[i]];
			sumJ-=J[c[i]][b[i]-1];
			sumJ+=J[a[i]-1][b[i]-1];
		sumO=0;
			sumO+=O[c[i]][d[i]];
			sumO-=O[a[i]-1][d[i]];
			sumO-=O[c[i]][b[i]-1];
			sumO+=O[a[i]-1][b[i]-1];
		sumI=0;
			sumI+=I[c[i]][d[i]];
			sumI-=I[a[i]-1][d[i]];
			sumI-=I[c[i]][b[i]-1];
			sumI+=I[a[i]-1][b[i]-1];
		printf("%d %d %d\n",sumJ,sumO,sumI);
	}
	return 0;
}

Measured memory_bytes: 32624
#include <stdio.h>
#define MAX (int)1e5+1

void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; }

int partition(int A[], int p, int r) {
    int i, j;
    i = p - 1;
    for (j = p; j <= r; j++) {
        if (A[j] <= A[r]) {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    return i;
}

int main() {
    int A[MAX];
    int i, q, n;

    scanf("%d", &n);

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

    q = partition(A, 0, n - 1);

    for (i = 0; i < n; i++) {
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
        printf( (i == n - 1) ? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 2080
using System;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion
        var arr = ReadLib.ReadAsIntArray();
        var n = arr[0];
        var c = arr[1];
        var k = arr[2];

        var ts = ReadLib.ReadNTimesAsInt(n).OrderByDescending(i => i);
        var nBus = 0;
        var nCurrentCustomers = 0;

        var maxT = ts.First();

        foreach (var t in ts) {
            var allowCurrentSubmit = t + k;
            if (maxT > allowCurrentSubmit || nCurrentCustomers >= c) {
                nBus++;
                nCurrentCustomers = 0;
                maxT = t;
            }

            nCurrentCustomers++;

        }

        if (nCurrentCustomers > 0) {
            nBus++;
        }

        Console.WriteLine(nBus);

        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion
    }
}


static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

Measured memory_bytes: 19164
# coding: utf-8
# Your code here!
s=list(input())
K=int(input())

dp=[[[[[0]*27 for i in range(27)] for i in range(27)] for i in range(27)] for i in range(27)]

for i in range(len(s)):
    for j in range(5):
        temp=list(map(lambda x:ord(x)-96,s[i:i+j+1]))+[0,0,0,0,0]
        #print(temp)
        dp[temp[0]][temp[1]][temp[2]][temp[3]][temp[4]]=1
        
    

for a in range(len(dp)):
    for b in range(len(dp[a])):
        for c in range(len(dp[a][b])):
            for d in range(len(dp[a][b][c])):
                for e in range(len(dp[a][b][c][d])):
                    if dp[a][b][c][d][e]==1:
                        if K==1:
                            print(chr(a+96 if a!=0 else 0)+(chr(b+96) if b!=0 else "")+(chr(c+96) if c!=0 else "")+(chr(d+96) if d!=0 else "")+(chr(e+96) if e!=0 else ""))
                            exit()
                        else:
                            K-=1




Measured memory_bytes: 188000
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
using P=pair<pair<int,int>,pair<int,int>>;
signed main(){
  int N;
  cin>>N;
  map<int,int> mp,mp1,mp2;
  vector<int> A(N),B(N);
  for(int &i:A){
    cin>>i;
    mp[i]++;
    mp1[i]++;
  }
  for(int &i:B){
    cin>>i;
    mp[i]++;
    mp2[i]++;
  }
  vector<P> C;
  for(pair<int,int> p:mp)C.push_back({{p.s,p.f},{mp1[p.f],mp2[p.f]}});
  sort(C.rbegin(),C.rend());
  if(C[0].f.f>N){
    puts("No");
    return 0;
  }
  puts("Yes");
  vector<pair<int,int>> D(N);
  for(int i=0;i<N;i++)D[i].f=D[i].s=-1;
  int n=0;
  for(P &p:C){
    for(int i=0;i<p.s.f;i++){
      if(i+n==N){
        p.s.f-=i;
        goto home;
      }
      D[n+i].f=p.f.s;
    }
    n+=p.s.f;
    p.s.f=0;
    for(int i=0;i<p.s.s;i++){
      if(i+n==N){
        p.s.s-=i;
        goto home;
      }
      D[n+i].s=p.f.s;
    }
    n+=p.s.s;
    p.s.s=0;
  }
  home:;
  n=0;
  for(P p:C){
    int m=0;
    for(;m<p.s.f && n<N;n++){
      if(D[n].f==-1)D[n].f=p.f.s,m++;
    }
  }
  n=0;
  for(P p:C){
    int m=0;
    for(;m<p.s.s && n<N;n++){
      if(D[n].s==-1)D[n].s=p.f.s,m++;
    }
  }
  sort(D.begin(),D.end());
  for(int i=0;i<N;i++)cout<<D[i].s<<(i==N-1?'\n':' ');
}

Measured memory_bytes: 53164
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int X,a;
bool expo[1001]={};

int main(){
    cin>>X;
    expo[1]=1;
    // rep(i,1001){
    //     expo[i]=0;
    // }
    repi(i,2,50){
        a=i*i;
        while(a<=X){
            expo[a]=1;
            a*=i;
        }
    }
    // out(expo[1000]);
    for(int i=X;;i--){
        if(expo[i]){
            out(i);
            return 0;
        }
    }
}


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

int main(){

    vector<int> data(3);
    cin >> data[0] >> data[1] >> data[2];

    sort(data.begin(), data.end());

    if(data[0] + data[1] == data[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

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

  int t[110000];
  int x[110000];
  int y[110000];
  t[0] = x[0] = y[0] = 0;

  for(int i = 0; i < N; ++i) {
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  string ans = "Yes";
  for (int i = 0; i < N; ++i) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(dt < dist) {
      ans = "No";
      break;
    }
    if(dt % 2 != dist % 2) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

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

typedef pair<P, P> PP;

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

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

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x, y;
    cin >> x >> y;
    cout << x + y + 1 - gcd(x, y) << endl;
	return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1 << 18;

#define pii pair<int, int>

int n, k;
int a[N], L[N], R[N];
vector<pii> G[N]; 

int main() {
	scanf("%d", &k);
	n = 1 << k;
	for (int i = 0; i < n; i++) {
		L[i] = 0, R[i] = n - 1;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		--a[i];
		if (~a[i]) {
			L[i] = R[i] = a[i];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < k; j++) {
			if (!((i >> j) & 1)) {
				L[i | (1 << j)] = max(L[i | (1 << j)], L[i] + 1);
			}
		}
	}
	for (int i = n; i--; ) {
		for (int j = 0; j < k; j++) {
			if ((i >> j) & 1) {
				R[i ^ (1 << j)] = min(R[i ^ (1 << j)], R[i] - 1);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (L[i] > R[i]) {
			puts("NO");
			return 0;
		}
		G[L[i]].emplace_back(R[i], i);
	}
	priority_queue<pii, vector<pii>, greater<pii>> Q;
	for (int i = 0; i < n; i++) {
		for (auto x : G[i]) {
			Q.push(x);
		}
		if (Q.empty()) {
			puts("NO");
			return 0;
		}
		pii x = Q.top();
		Q.pop();
		if (x.first < i) {
			puts("NO");
			return 0;
		}
		a[x.second] = i;
	}
	for (int i = 1, j = n >> 1, k; i < n - 1; i++, j += k) {
		if (i < j)
			swap(a[i], a[j]);
		for (k = n >> 1; j >= k; j -= k, k >>= 1);
	}
	puts("YES");
	for (int i = 0; i < n; i++) {
		printf("%d ", a[i] + 1);
	}
	return 0;
}


Measured memory_bytes: 19200
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
 
namespace adaptor = boost::adaptors;
using namespace std;
using ll = long long;
using lll = int64_t;
 
void Main()
{
  int N, M;
  cin >> N >> M;
  vector<lll> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    std::cin >> A[i] >> B[i];
  }
 
  vector<size_t> indices(N);
  iota(indices.begin(), indices.end(), 0);
 
  sort(indices.begin(), indices.end(), [&A](size_t i1, size_t i2) {
    return A[i1] < A[i2];
  });
 
  int d = M;
  lll money = 0;
  for (auto i : indices)
  {
    if ( B[i]>=d ){
      money += A[i]*d;
      break;
    }
    money += A[i]*B[i];
    d -= B[i];
  }
  cout << money << endl;
}
 
int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main(){
    int shot;
    int total;
    int eachshot;
    int loop;
    while(1){
        cin>>shot;
        if(shot==0) break;
        loop = shot/4;
        total = 0;
        for(int i=0;i<loop;i++){
            cin>>eachshot;
            total+=eachshot;
        }
        cout<<total<<endl;
    }
  return 0;
}


Measured memory_bytes: 2984
a,b=input().split()
#a=10
#b=9.99
from decimal import*
A=Decimal(str(a))
AA=A.quantize(Decimal('0'),rounding=ROUND_FLOOR)
B=Decimal(str(b))
BB=B.quantize(Decimal('0.01'),rounding=ROUND_FLOOR)
#print(AA)
#print(BB)
K=AA*BB
KK=K.quantize(Decimal('0'),rounding=ROUND_FLOOR)
print(KK)

#a='10'
#b='9.99'
#aa=int(a)
#bb=float(b)
#print(int(aa*bb))

Measured memory_bytes: 9940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W,D,Q;
    cin >> H >> W >> D;
    vector<vector<ll>> A(H,vector<ll>(W));
    map<ll,Pll> mp;
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
            mp[A[i][j]] = Pll(i,j);
        }
    }
    cin >> Q;
    vector<ll> dp(H*W+10);
    rep(i,H*W){
        if(i<D)continue;
        dp[i+1] = dp[i+1-D] + abs(mp[i+1].first - mp[i+1-D].first) + abs(mp[i+1].second - mp[i+1-D].second);
    }
    ll L,R;
    vector<ll> v;
    rep(i,Q){
        cin >> L >> R;
        v.push_back(dp[R]-dp[L]);
    }
    rep(i,Q){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 9080
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	cout<<n*n*n;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
      int n;
        cin>>n;
        vector<int>v(n);
        for(int i=0; i<n; i++)
          cin>>v[i];
      
        int ans=1,mn=v[0];
        for(int i=1 ;i <n; i++){
            if(mn>=v[i]){
               ans+=1;
               mn=v[i];
            }
          }
         cout<<ans<<endl;
    }
//aaaaa


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

//dp[i][j] i前の桁で繰り上がってる？ j j番目
lli dp[2][1000100];

void func(string &N){

    reverse(N.begin(),N.end());

    dp[0][0]=0;
    dp[1][0]=INF;

    REP(i,0,N.size()){
        //今回繰り上がらない

        lli num = N[i]-'0';
        dp[0][i+1] = min(dp[0][i]+num,dp[1][i]+num+1);

        //今回繰り上がる
        dp[1][i+1] = min(dp[0][i]+10-num,dp[1][i]+10-num-1);
    }

    REP(i,0,N.size()+1){
        LOG3(i,dp[0][i],dp[1][i]);
    }

    cout<<min(dp[0][N.size()],dp[1][N.size()]+1)<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    string N;
    cin>>N;
    func(N);
    return 0;
}


Measured memory_bytes: 17028
#include <iostream>
#include <vector>

void solve() {
    int a, b, c, d, e;
    std::cin >> a >> b >> c >> d >> e;

    int ans = 0;
    while (a < b) {
        if (a < 0) {
            ans += c;
        } else {
            ans += e;
            if (a == 0) {
                ans += d;
            }
        }
        ++a;
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>k>>n;
    int f;
    cin>>f;
    int prv=f;
    FOR(i,1,n){
        int x;
        cin>>x;
        ans=max(ans,x-prv);
        prv=x;
    }
    ans=max(ans,f+k-prv);
    cout<<k-ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#knapsack1
n,w=map(int,input().split())
data=[]
for i in range(n):
    u,v=map(int,input().split())
    data.append((u,v))
can_pack=[[0 for i in range(w+1)] for j in range(n+1)]
#can_pack[i][k]=i番目までの荷物を使って重さをkにしようとしたときに、もしそれが可能ならばその時の価値の最大値、不可能なら0

for   i in range(n):
    a,b=data[i][0],data[i][1]
    #aが重さ、bが価値　。
    for j in range(1,w+1):
        if    j>=a:
            can_pack[i+1][j]=max(can_pack[i][j-a]+b,can_pack[i][j])
        else:
            can_pack[i+1][j]=can_pack[i][j]
ans=0
for i in range(w+1):
    ans=max(ans,can_pack[n][i])
print(ans)

Measured memory_bytes: 171784
LARGE = 1000000007


def solve(n, a_list):

    x = -1
    y = -1
    z = -1
    res = 1

    for i in range(n):
        c = 0
        a = a_list[i]
        if x == a - 1:
            c += 1
        if y == a - 1:
            c += 1
        if z == a - 1:
            c += 1
        if x == a - 1:
            x += 1
        elif y == a - 1:
            y += 1
        else:
            z += 1
        res *= c
        res %= LARGE
    return res


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(6, [0, 1, 2, 3, 4, 5]) == 3
    assert solve(3, [0, 0, 0]) == 6


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 14396
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    if(str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5)){
      pl("Yes");
    }else{
      pl("No");
    }
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	int a, b, k;
	cin >> a >> b >> k;
	if (b - a > 2*k - 2) {
		for (int i = 0; i < k; i++) cout << a + i << endl;
		for (int i = b-k+1; i <= b; i++) cout << i << endl;
	}
	else {
		for (int i = a; i <= b; i++)
		{
			cout << i << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int H, W;
char a[200][200];

int main()
{
    cin >> H >> W;
    repe(i, 1, H)
    {
        repe(j, 1, W)
        {
            cin >> a[i][j];
        }
    }

    repe(i, 1, H)
    {
        bool flag = true;
        repe(j, 1, W)
        {
            if (a[i][j] == '#')
            {
                flag = false;
            }
        }
        if (flag)
        {
            repe(j, 1, W)
            {
                a[i][j] = '*';
            }
        }
    }

    repe(j, 1, W)
    {
        bool flag = true;
        repe(i, 1, H)
        {
            if (a[i][j] == '#')
            {
                flag = false;
            }
        }
        if (flag)
        {
            repe(i, 1, H)
            {
                a[i][j] = '*';
            }
        }
    }
    repe(i, 1, H)
    {
        bool flag = false;
        repe(j, 1, W)
        {
            if (a[i][j] != '*')
            {
                flag = true;
                cout << a[i][j];
            }
        }
        if (flag)
        {
            cout << endl;
        }
    }
}


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

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

    ll a, b;
    cin >> a >> b;
    int s = a + b;
    if(s % 2 == 0) {
        cout << s / 2;
    } else {
        cout << "IMPOSSIBLE";
    }
    return 0;
}


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

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

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

  int Q;
  cin >> Q;

  vector<vector<char>> process(Q, vector<char>(3)); 
  rep(i,Q){
    char a; 
    cin >> a;
    process.at(i).at(0) = a;
    if(a=='2'){
      char b, c;
      cin >> b >> c;
      process.at(i).at(1) = b;
      process.at(i).at(2) = c;
    }
  }

  bool reverse = false;
  string ans = S;

  vector<char> first;
  vector<char> end;
  
  rep(i, Q){
    if(process.at(i).at(0) == '1') reverse = !reverse;
    else if(process.at(i).at(1)=='1'){
      if(!reverse){
        first.push_back(process.at(i).at(2));
      }else{
        end.push_back(process.at(i).at(2));
      }
    }else{
      if(!reverse){
        end.push_back(process.at(i).at(2));
      }else{
        first.push_back(process.at(i).at(2));
      }
    }
  }
  
  int l = ans.size();
  int fl = first.size();
  int el = end.size();
  
  if(reverse){
    for(int i=el-1; i>=0; i--){
      cout << end.at(i);
    }
    for(int i=l-1; i>=0; i--){
      cout << ans.at(i);
    }
    for(int i=0; i<fl; i++){
      cout << first.at(i);
    }
  }else{
    for(int i=fl-1; i>=0; i--){
      cout << first.at(i);
    }
    for(int i=0; i<l; i++){
      cout << ans.at(i);
    }
    for(int i=0; i<el; i++){
      cout << end.at(i);
    }
}
}
  

Measured memory_bytes: 11968
#include<bits/stdc++.h>
using namespace std;
#define SYNC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define ll long long int
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(j,c,d) for(int j=c;j>d;j--)
#define mod 1000000007
#define mo 998244353
ll dp[1001][1001];
int main()
{
    SYNC
    int n,m,i,j;
    char c;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    f(i,0,n) f(j,0,m)
    {
        cin>>c;
        if(c=='#')
            dp[i][j]=0;
    }
    if(dp[0][1]!=0)dp[0][1]=1;
    if(dp[1][0]!=0)dp[1][0]=1;
    f(i,0,n)
    {
        f(j,0,m)
        {
            if((i==0&&j==0)||(i==0&&j==1)||(i==1&&j==0)) continue;
            else if(i==0&&j>1&&dp[i][j]!=0)dp[i][j]=dp[i][j-1];
            else if(j==0&&i>1&&dp[i][j]!=0)dp[i][j]=dp[i-1][j];
            else if(dp[i][j]!=0) dp[i][j]=((dp[i-1][j])%mod+(dp[i][j-1])%mod)%mod;
        }
    }
    cout<<dp[n-1][m-1];
    return 0;
}




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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b || (n == 1 && a != b)){
    cout << 0 << endl;
    return 0;
  }else if(a==b){
    cout << 1 << endl;
    return 0;
  }

  ll res = a + b;
  cout << res + b * (n-2) - (res + a * (n-2)) + 1 << endl;

}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

"""
H Wの後に
#.#.
###.
みたいな文字列を受け取る
"""
H,W = map(int,input().split(' '))
MAP = [['#']*(W+1)] + [None]*H

for i in range(1,H+1):
    MAP[i] = ['#'] + list(map(str,input()))
import queue
q = queue.Queue()


MAP[H][W] = 'G'
visited = [None]*(H+1)
for i in range(H+1):
    visited[i] = [False]*(W+1)

d_num = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if MAP[i][j]=='#':
            d_num += 1

def is_okay(x,y):
    if not (0<x<W+1) or not (0<y<H+1):
        return False
    if visited[y][x] or MAP[y][x]=='#':
        return False
    return True

n = 0
q.put([1,1,n])
ans = 10**7 + 7
delta = [[1,0],[-1,0],[0,1],[0,-1]]
while not q.empty():
    x,y,n = q.get()
    k = MAP[y][x]

    n += 1
    if k=='G':
        ans = min(ans,n)
        break
    for d in delta:
        dx = x+d[0]
        dy = y+d[1]
        if is_okay(dx,dy):
            q.put([dx,dy,n])
            visited[dy][dx] = True

if not ans==10**7 + 7:
    ANS = H*W - ans - d_num
else:
    ANS = -1

print(ANS)

Measured memory_bytes: 4720
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

    iRet = 0
    iRet += iCZero
    iCZero += 1 #0の場合を追加

    iSumPlus = sum(aPlus)
    iSumMinus = sum(aMinus)
    iUlim = min(iSumPlus , iSumMinus)
    iOlim = max(iSumPlus , iSumMinus)
    if 0 < iUlim:
        dp1 = [[0]*(iOlim +1) for _ in range(iLenPlus)]
        dp1[0][0] = 1
        dp1[0][aPlus[0]]=1
        for j in range(1,iLenPlus):
            for k in range(iUlim + 1):
                if k < aPlus[j] :
                    dp1[j][k] = dp1[j-1][k]
                else:
                    dp1[j][k] = dp1[j-1][k] + dp1[j-1][k-aPlus[j]]

        dp2 = [[0]*(iOlim +1) for _ in range(iLenMinus)]
        dp2[0][0] = 1
        dp2[0][aMinus[0]]=1
        for j in range(1,iLenMinus):
            for k in range(iUlim + 1):
                if k < aMinus[j] :
                    dp2[j][k] = dp2[j-1][k]
                else:
                    dp2[j][k] = dp2[j-1][k] + dp2[j-1][k-aMinus[j]]
        for i in range(1,iUlim+1):
            iRet += iCZero * dp1[-1][i] * dp2[-1][i]

    print(iRet)
解()


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var a = Console.ReadLine();
    var b = Console.ReadLine();
    
    if(a.Length > b.Length) Console.Write("GREATER");
    else if(a.Length < b.Length) Console.Write("LESS");
    else{
      bool eq = true;
      for(int i=0; i<a.Length; i++){
        if(int.Parse(a[i].ToString()) > int.Parse(b[i].ToString())){
          Console.Write("GREATER");
          eq = false;
          break;
        }
        else if(int.Parse(a[i].ToString()) < int.Parse(b[i].ToString())){
          Console.Write("LESS");
          eq = false;
          break;
        }
      }
      if(eq) Console.Write("EQUAL");
    }
  }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main () {
	int n;
	cin >> n;
	int cost[n][3];
	for (int i=0; i<n; i++) {
		for (int j=0; j<3; j++) {
			cin >> cost[i][j];
		}
	}
	int dp[n][3];
	dp[0][0] = cost[0][0];
	dp[0][1] = cost[0][1];
	dp[0][2] = cost[0][2];
	for (int i=1; i<n; i++) {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+cost[i][0];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2])+cost[i][1];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1])+cost[i][2];
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  ll sum_a=0, sum_b=0;
  rep(i, n) {
    scanf("%d", &a[i]);
    sum_a+=a[i];
  }
  rep(i, n) {
    scanf("%d", &b[i]);
    sum_b+=b[i];
  }
  if (sum_a>sum_b) {
    puts("No");
    return 0;
  }
  ll ops=sum_b-sum_a;
  ll need=0;
  rep(i, n) {
    if (a[i]<b[i]) {
      ll diff=b[i]-a[i];
      need+=(diff+1)/2;
    }
  }
  if (need<=ops) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using namespace std;
// cout << fixed << setprecision(10）<<  << endl;

const ll MOD = 998244353;

struct BIT{
    int n;
    vector<ll> bit;

    BIT(int n_){
        bit.resize(n_+1,0ll); n = n_;
    }
    ll sum(ll i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i & -i; // 上のnodeへの遷移
        }
        return s;
    } // i番目(1-index)までの和
    void add(int i, ll x){
        while(i<=n){
            bit[i] += x;
            i += i & -i; // 上のnodeへの遷移
        }
    } // i番目にxを加える
};

int main() {
    int n, k; cin >> n >> k;
    BIT dp(n);
    dp.add(1,1ll);
    vector<pair<int,int>> data(k);
    rep(i,k) cin >> data[i].first >> data[i].second;
    for(int i = 2; i <= n; i++) {
        ll count = 0;
        rep(j,k) {
            count += dp.sum(max(0,i-data[j].first)) - dp.sum(max(0,i-data[j].second-1));
            count %= MOD;
        }
        dp.add(i,count);
        if (i == n) cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

using Number = long long;
using NumberSet = std::vector<Number>;
using NumberCount = std::unordered_map<Number, size_t>;
using Top2Count = std::pair<size_t, size_t>;

struct Count {
    Number number;
    size_t size;
};

void findTop2(const NumberCount& occurence, NumberSet& topNumbers, Top2Count& top2Count) {
    std::vector<Count> counts;
    for (const auto& element : occurence) {
        counts.push_back(Count{element.first, element.second});
    }

    std::sort(counts.begin(), counts.end(),
              [](const auto& lhs, const auto& rhs) { return lhs.size > rhs.size; });

    auto size = counts.at(0).size;
    topNumbers.clear();
    top2Count = Top2Count{0, 0};

    size_t index = 0;
    for(const auto& count : counts) {
        if (index == 0) {
            if (size == count.size) {
                topNumbers.push_back(count.number);
                top2Count.first = size;
            } else {
                index = 1;
                size = count.size;
            }
        }

        if (index >= 1) {
            if (count.size == size) {
                top2Count.second = size;
            } else {
                break;
            }
        }
    }

    return;
}

int main(int argc, char* argv[]) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    size_t size = 0;
    std::string paramLine;
    std::getline(std::cin, paramLine);
    std::istringstream isp(paramLine);
    isp >> size;

    std::string numLine;
    std::getline(std::cin, numLine);
    std::istringstream is(numLine);

    NumberCount occurenceA;
    NumberCount occurenceB;
    size_t i = 0;
    while(i < size) {
        Number n = 0;
        is >> n;
        occurenceA[n] += 1;
        ++i;
        is >> n;
        occurenceB[n] += 1;
        ++i;
    }

    NumberSet topNumbersA;
    NumberSet topNumbersB;
    Top2Count top2CountA;
    Top2Count top2CountB;
    findTop2(occurenceA, topNumbersA, top2CountA);
    findTop2(occurenceB, topNumbersB, top2CountB);

    size_t answer = 0;
    if ((topNumbersA.size() > 1) || (topNumbersB.size() > 1) ||
        (topNumbersA.at(0) != topNumbersB.at(0))) {
        answer = size - top2CountA.first - top2CountB.first;
    } else {
        answer = size - top2CountA.first - std::max(top2CountA.second, top2CountB.second);
    }

    std::cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 7696
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    R, C, K = NMI()
    grid = make_grid_int(R, C, 0)
    for i in range(K):
        r, c, v = NMI()
        grid[r-1][c-1] = v

    dp0 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp1 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp2 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp3 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]

    for r in range(R+1):
        for c in range(C+1):
            now0 = dp0[r][c]
            now1 = dp1[r][c]
            now2 = dp2[r][c]
            now3 = dp3[r][c]
            try:
                val = grid[r][c]
            except:
                val = 0

            dp0[r+1][c] = max(now3, dp0[r+1][c])

            # 取って下
            dp0[r+1][c] = max(now0 + val, now1 + val, now2 + val, dp0[r+1][c])
            # 取らずに下
            dp0[r+1][c] = max(now0, now1, now2, now3, dp0[r+1][c])
            # 取って横
            dp1[r][c+1] = max(now0 + val, dp1[r][c+1])
            dp2[r][c+1] = max(now1 + val, dp2[r][c+1])
            dp3[r][c+1] = max(now2 + val, dp3[r][c+1])

            # 取らずに横
            dp1[r][c+1] = max(now1, dp1[r][c+1])
            dp2[r][c+1] = max(now2, dp2[r][c+1])
            dp0[r][c+1] = max(now0, dp0[r][c+1])

    print(max(dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C]))


if __name__ == "__main__":
    main()


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

int main()
{
  long long a,v,b,w;
  cin >> a >> v >> b >> w;
  long long t;
  cin >> t;

  long long dis = abs(b - a);
  long long rel = v - w;
  if(rel > 0)
  {
    bool ans = ((dis - 1) / rel < t);
    cout << (ans ? "YES" : "NO") << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,r=0; cin>>n;
    string s; cin>>s;
    rep(i,n)if(s[i]=='R') r++;
    if(r>n-r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3600