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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=5e5+5,MOD=998244353;
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
int n,m,fac[MAXN],invf[MAXN];
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
inline int comb(int n,int k){return n<k?0:(ll)fac[n]*invf[k]%MOD*invf[n-k]%MOD;}
int main() {
	n=read(),m=read();if(n>m)swap(n,m);
	fac[0]=1;for(int i=1;i<=m;++i)fac[i]=(ll)fac[i-1]*i%MOD;
	invf[m]=pow_mod(fac[m],MOD-2);
	for(int i=m-1;i>=0;--i)invf[i]=(ll)invf[i+1]*(i+1)%MOD;assert(invf[0]==1);
	int ans=0;
	for(int i=0;i<=n;++i){
		int tmp=(ll)comb(n,i)*comb(m,i)%MOD*pow_mod(n+1,m-i)%MOD*pow_mod(m+1,n-i)%MOD*fac[i]%MOD;
		if(i&1)ans=mod2(ans-tmp);
		else ans=mod1(ans+tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)



Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1e5+5;
typedef long long ll;
ll dp[N];
int h[N];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",h+i);
    dp[1]=0;dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++){
        dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
        dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n];
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int N, W;
    cin >> N >> W;
    vector <vector <ll>> dp(N, vector <ll>(W+1, 0));
    vector <int> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    for (int j = 0; j <= W; j++) {
      if (j >= w[0]) {
        dp[0][j] = v[0];
      }
    }
    for (int i = 1; i < N; i++) {
      for (int j = 0; j <= W; j++) {
        if (j >= w[i]) {
          dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
        } else {
          dp[i][j] = dp[i-1][j];
        }
      }
    }
    cout << dp[N-1][W] << endl;
}


Measured memory_bytes: 79488
#include<cstdio>
#include<cstring>
 
char s[200000];
int main(void) {
    scanf("%s",s+2);
    int n = strlen(s+2);
    for(int i=2; i<n+2; i++) {
        if(s[i-2] == s[i]) {
            printf("%d %d\n", i-3, i-1);
            return 0;
        }
        if(s[i-1] == s[i]) {
            printf("%d %d\n", i-2, i-1);
            return 0;
        }
    }
    puts("-1 -1");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
}

using namespace atcoder;

int main(void){
    int n;
    cin >> n;
    vector<int > A(n);
    int l=0,stk;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    l = A[n-1];
    int tr = A[n-1]/2;
    int atr = 1000000000;
    int aaa;
    for(int i=0;i<n-1;i++){
        stk = abs(tr-A[i]);
        if(stk<=atr){
            atr = stk;
            aaa = A[i];
        }else{
            break;
        }
    }
    
    cout << l << " " << aaa << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int N;
	cin >> N;
	int L[2*N];
	FOR(i,0,2*N) cin >> L[i];
	sort(L,L+2*N);
	int ans = 0;
	FOR(i,0,N){
		ans += L[2*i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
void fo (){fflush(stdout);}
using namespace std;
ll fact (int x ){return (x <= 1 ? 1 : 1LL * x * fact (x-1));}
int main ()
{
  int n , m  ;
  cin >> n >> m ;
  for (int i =0  ;i <= n ; i++)
  {
    for (int j =0 ; j <= n ;j++)
    {
      if (n - i - j < 0 )continue ;
      // cast not ness 
      ll cur = 1LL * 10000 * i + 1LL * 5000 * j + 1LL * (n - i - j) * 1000;
      if (cur == m )
      {
        cout << i <<" " << j <<" " << n-i-j <<"\n";
        return 0;
      }
    }
  }
  cout <<"-1 -1 -1\n";
//cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000
int main(){
  char a[MAX]={1,1};
  int i,j,n,x;

  for(i=2;i<MAX;i++){
    for(j=2;i*j<MAX;j++)if(!a[i])a[i*j]=1;
  }
  while(scanf("%d",&n)!=EOF){
    x=0;
    for(i=0;i<=n;i++)if(!a[i])x++;
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  ll ans=1;
  REP(i,1,n) {
    if(s[i-1]!=s[i]) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int h, m ,s;
  int S;
  scanf("%d", &S);
  h = S / 3600;
  int r1,r2;
  r1 = S % 3600;
  m = r1 / 60;
  r2 = r1 % 60;
  s = r2;
  printf ("%d:%d:%d\n",h,m,s);
  return 0;
} 


Measured memory_bytes: 2116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define repi(i,n) for(int i=0; i<(n); i++)
#define repd(i,n) for(int i = n; i >= 0; i--)

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> fruits(N,0);

  repi(i,N) {
    cin >> fruits.at(i);
  }
  sort(fruits.begin(), fruits.end());

  int sum = 0;
  repi(i,K) sum += fruits.at(i);
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n==1){
        if(m>2){
            cout<<m-2<<endl;
        }
        if(m==1){
            cout<<1<<endl;
        }
        if(m==2){
            cout<<0<<endl;
        }
        return 0;
    }
    if(m==1){
        if(n>2){
            cout<<n-2<<endl;
        }
        if(n==1){
            cout<<1<<endl;
        }
        if(n==2){
            cout<<0<<endl;
        }
        return 0;
    }
    ans=(m-2)*(n-2);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
void swap(int *a, int *b){

  int v = *a;
  
  *a = *b;

  *b = v;
}

int bubblesort(int *A, int N){

  int count = 0;
  int i,j;
  for(j = 1; j < N; j++){
    for(i = N-1; i >= j ;i--){
      if(A[i] < A[i-1]){
	swap(&A[i],&A[i-1]);
	count++;
      }
    }
  }
  return count;
}


int main(void){

  int N;
  int i;
  int c;

  while(~scanf("%d",&N)){
    
    int *A = new int[N];
    
    for(i=0;i < N;i++) scanf("%d", &A[i]);
    
    c = bubblesort(A, N);
    
    std::cout << A[0];
    for(i=1;i < N;i++){
      std::cout << " " << A[i]; 
    }
    std::cout << std::endl;
    std::cout << c << std::endl;
    
    delete []A;

  }
  
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M; cin >> N >> M;
  if(2*N == M){
    cout << N << endl;
    return 0;
  }else if(2*N > M){
    cout << M/2 << endl;
    return 0;
  }else{
    cout << N + (M - 2*N)/4 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    B = list(map(int, input().split()))
    ans = [0] * N
    ans[0] = B[0]

    for i in range(N-1):
        ans[i] = min(ans[i], B[i])
        ans[i+1] = B[i]

    print(sum(ans))


main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

#define endl "\n"
#define PRIME 1000000007

#define ll long long

#define f(i,a,n) for(int i = a; i < n; i++)
#define fs(i,a,n,k) for(int i = a; i < n; i+=k)

#define fr(i,a,n) for(int i = n; i > a; i--)
#define frs(i,a,n,k) for(int i=n; i>a; i-=k)

#define out1(a) cout << a << endl
#define out2(a,b) cout << a << " " << b << endl
#define out3(a,b,c) cout << a << " " << b << " " << c << endl


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

    //enable fast I/O
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s, t;
    cin >> s >> t;

    int ans = 0;

    f(i, 0, s.length()){
        if(s[i] != t[i]){
            ans++;
        }
    }

    out1(ans);

    return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#define ll long long
#include<cstring>
using namespace std;
const long long INF=1e18L+5;
#define ll long long
int main(){
    ll n,W,a,b;
    cin>>n>>W;
    vector<ll> w(n),val(n);
    for(ll i=0;i<n;i++) cin>>w[i]>>val[i];
    ll sum=0;
    for(ll i=0;i<n;i++)
        sum+=val[i];

    vector<ll> dp(sum+1,INF);// minima possible till this value
   dp[0]=0;// this is like 
    for(ll j=0;j<n;++j){
        for(ll i=sum;i>=val[j];i--)
          dp[i]=min(dp[i],dp[i-val[j]]+w[j]);
    }

    ll ans=0;
    for(ll i=0;i<=sum;i++)
      if(dp[i]<=W)
         ans=max(ans,i);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <utility>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, ans = 0, now = 0;
  scanf("%lld%lld", &n, &m);
  pair<ll, ll> d[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &d[i].first, &d[i].second);
  sort(d, d + n);
  for(i = 0; now < m; ++i) {
    if(now + d[i].second < m) now += d[i].second, ans += d[i].first * d[i].second;
    else ans += d[i].first * (m - now), now = m;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007;
int main(){
    int N, M, tmp;
    long long ans=0;
    cin >> N >> M;
    bool a[N]={};
    long long b[N] = {};
    rep(i, M) {
        cin >> tmp;
        a[tmp-1] = 1;
    }
    if (N==1) {
        if(M==0)ans = 1;
    }
    else{
        bool flag = true;
        rep(i, N-1){
            if(a[i+1] == 1 && a[i]==1) flag=false;
        }
        if(flag){
            if(a[0] == 0) b[0] = 1;
            else b[0] = 0;
            if(a[1] == 0) b[1] = b[0] + 1;
            else{
                b[1] = 0;
            }
            for (int i = 2; i<N; i++){
                if(a[i]==0) b[i] = b[i-1] + b[i-2];
                else b[i] == 0;
                b[i] = b[i] % LargeNum;
            }
        }
        ans = b[N-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

vector<vector<ll>> dp((1ll<<18),vector<ll>(19,-1));
vector<ll> p(1ll<<18);
string s;
int N;

int battle(int x, int y){
  if(y<x)swap(x,y);

  if(s[y-x-1]=='0'){
    return x;
  }else{
    return y;
  }
}

int dfs(int i, int m){
  if(dp[i][m]!=-1){
    return dp[i][m];
  }
  if(m==1){
    return battle(p[i],p[(i+1)%(1<<N)]);
  }else{
    dp[i][m] = battle(dfs(i,m-1), dfs((i+(1<<(m-1)))%(1<<N), m-1));
    return dp[i][m];
  }
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin>>N>>s;
  REP(i,1<<N){
    cin>>p[i];
    p[i]--;
  }
  REP(i,1<<N){
    cout<<(dfs(i,N)+1)<<endl;
  }
}



Measured memory_bytes: 52740
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int ans;
    cin>>ans;
    while(1){
        char x;
        int y;
        cin>>x;
        if(x=='=')break;
        cin>>y;
        
        if(x=='+')ans+=y;
        else if(x=='-')ans-=y;
        else if(x=='*')ans*=y;
        else if(x=='/')ans/=y;
    }
    cout<<ans<<endl;
    
    

    
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;


int eval(int x,int y,int z){
    return (x*x + y*y + z*z + x*y + x*z + y*z);
}

main(){
    int n;cin>>n;
    int res;
    int count[n+1] = {0};
    for(int i=1;i<100;i++){
        for(int j=1;j<100;j++){
            for(int k=1;k<100;k++){
                res = eval(i,j,k);
                if(res<=n) count[res]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<count[i]<<"\n";
}

Measured memory_bytes: 3444
#include <cstdio>
#define LOOP(index,times) for(int index=0;index<times;index++)
using namespace std;

int main(){

int w,n,a,b,temp;
int* num;

scanf("%d\n%d",&w,&n);

num=new int[w];

LOOP(i,w)
	num[i]=i+1;

LOOP(i,n){
	scanf("%d,%d",&a,&b);
	temp=num[a-1];
	num[a-1]=num[b-1];
	num[b-1]=temp;
}

LOOP(i,w)
	printf("%d\n",num[i]);

delete [] num;
return 0;		
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,x,sum=0;
    	bitset<3000002> bs(1);
    	for(cin>>n;n--&&cin>>x;sum+=x) bs|=bs<<x;
    	for(int i=sum+1>>1;i<=sum;++i)
    		if(bs[i]) return cout<<i,0;
    }

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> v(h);
    rep(i,h)cin>>v[i];
    
    vector<string> red(h,string(w,'.'));
    vector<string> blue(h,string(w,'.'));
    
    rep(i,h){
        rep(j,w){
            if(0<j && j<w-1){
                if(i%2==0)  red[i][j] = '#';
                else        blue[i][j] = '#';
            }else{
                if(j==0)red[i][j] = '#';
                if(j==w-1)blue[i][j] = '#';
            }
        }
    }
    
    rep(i,h){
        rep(j,w){
            if(v[i][j]=='#')red[i][j] = blue[i][j] = '#';
        }
    }
    
    rep(i,h)cout<<red[i]<<endl;
    cout<<endl;
    rep(i,h)cout<<blue[i]<<endl;
    
}

Measured memory_bytes: 1536
#include<iostream>

bool is_prime_number(int a){
    if(a == 1) return false;
    for(int j = 2; j * j <= a; j++){
        if(a % j == 0){
            return false;
        }
    }
    
    return true;
}

int main(){
    int n;
    std::cin >> n;
    
    int count = 0;
    
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        
        if(is_prime_number(a)) count++;
    }
    
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<char> p(1e5, 1);
    p[0] = p[1] = 0;
    int i = 2;
    while(i < 1e5){
        for(int j = i*2; j < 1e5; j += i){
            p[j] = 0;
        }
        while(p[++i] == 0);
    }
    vector<int> sim2017(1e5, 0);
    for(int i = 3; i < 1e5; i+=2){
        sim2017[i] += sim2017[i-2] + (p[i] && p[(i+1)/2]);
    }

    int q, l, r;
    cin >> q;
    for(int i = 0; i < q; i++){
        scanf("%d%d", &l, &r);
        cout << sim2017[r] - sim2017[l] + (p[l] && p[(l+1)/2]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void)
{
	int a,b,c,t;
	scanf("%d %d %d", &a, &b, &c);
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	if(b>c)
	{
		t=b;
		b=c;
		c=t;
	}
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	printf("%d\n", 10*c+b+a);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

//#define ELEMENTC 2000001
//#define ELEMENT 10000 

int n,k = 10000;
int a[2000001], b[2000001], c[10000];

int main(void)
{
    int i, j;
    
    scanf("%d", &n);
    for(i = 0 ; i < n ; i++) {
        scanf("%d", &a[i + 1]);
    }
    
    for(i = 0 ; i <= k ; i++) {
        c[i] = 0;
    }
    for(i = 0 ; i < n ; i++) {
        c[a[i + 1]]++;
    }
    for(i = 1 ; i <= k ; i++) {
        c[i] =  c[i] + c[i-1];
    }
    for( j = 1 ; j <= n ; j++) {
        b[c[a[j]]] = a[j];
        c[a[j]]--;
    }
    
    for(i = 1 ; i <= n ; i++) {
        printf("%d",b[i]);
        if(i == n) {
            printf("\n");
        }
        else {
            printf(" ");
        }
    }
    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int n, m;
  cin >> n >> m;
  if (n == m) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  return;
}

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: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
 
int main(){
    int N;
    scanf("%d",&N);
    int S[N];
    for(int i = 0; i < N; i++)scanf("%d",&S[i]);
 
    int M;
    scanf("%d",&M);
 
    int Q[M];
    for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
    sort(Q,Q+M);
 
    int left = 0,right,m,count = 0;
 
    for(int i = 0; i < M; i++){
        right = N-1;
        m = (left+right)/2;
 
        while(left <= right){
            if(S[m] == Q[i]){
                count++;
                left= m+1;
                break;
            }else if(S[m] > Q[i]){
                right = m-1;
            }else{ //S[m] < Q[i]
                left = m+1;
            }
            m = (left+right)/2;
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 3676
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str[] = new String[3];
    for(int i=0;i<3;i++){
      str[i] = sc.next();
    }
    
    str[1] = str[1].substring(0,1);
    
    System.out.println("A" + str[1] + "C");
    
  }
}

Measured memory_bytes: 21716
L,R = list(map(int, input().split()))

if R-L >= 2018:
  print(0)
  exit(0)
  
L = L%2019
R = R%2019

if L > R:
  print(0)
  exit(0)
  
ans = 3000
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans = min(ans,i * j % 2019)
    if ans == 0:
      print(0)
      exit(0)
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

string s;

int main () {
  cin >> s;
  int n = s.size();

  int r = 0;
  int l = 0;

  r = 1;

  int left = 0;
  int right = 0;

  rep(i, n-1) {
    char tmp = s[i];

    if (tmp == 'R') {
      if (r > 0) {
        r++;
      } else {
        if (l % 2 == 0) {
          left += l / 2;
          right += l / 2;
        } else {
          left += (l - 1) / 2;
          right += (l + 1) / 2;          
        }
        cout << left << " ";
        cout << right << " ";
        Rep(i, l-1) cout << "0 ";
        r = 1;
        l = 0;
        left = right = 0;
      }
    } else {
      if (l > 0) {
        l++;
      } else {
        if (r % 2 == 0) {
          left += r / 2;
          right += r / 2;
        } else {
          left += (r + 1) / 2;
          right += (r - 1) / 2;
        }
        Rep(i, r-1) cout << "0 ";
        r = 0;
        l = 1;
      }
    }
  }

  if (l % 2 == 0) {
    left += l / 2;
    right += l / 2;
  } else {
    left += (l - 1) / 2;
    right += (l + 1) / 2;          
  }
  cout << left << " ";
  cout << right;
  Rep(i, l-1) cout << " 0\n";
}

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
}

Measured memory_bytes: 256
//SPFA
#include<bits/stdc++.h>
#define ll long long
#define INF 1e18
#define MAXN 100005

ll min(ll x,ll y){if(x<y) return x;return y;}
	
	int n,m,s,t,u,v;
	ll a,b,f=1e15,ans[MAXN];
	
struct Graph
{
	int cnt,head[MAXN],vis[MAXN];
	ll dis[MAXN];
	
	struct Edge{int next,to;ll dis;}edge[MAXN*2];
	
	std::queue<int> q;
	
	void addedge(int from,int to,ll dis)
	{
		edge[++cnt].next=head[from];
		edge[cnt].to=to;
		edge[cnt].dis=dis;
		head[from]=cnt;
	}
	void spfa(int s)
	{
		for(int i=1;i<=n;i++) dis[i]=INF;
		memset(vis,0,sizeof(vis));
		q.push(s);vis[s]=1;dis[s]=0;
		while(!q.empty())
		{
			int x=q.front();q.pop();
			vis[x]=0;
			for(int i=head[x];i;i=edge[i].next)
			{
				int to=edge[i].to;
				if(dis[to]>dis[x]+edge[i].dis)
				{
					dis[to]=dis[x]+edge[i].dis;
					if(!vis[to]) q.push(to),vis[to]=1;
				}
			}
		}
	}
}g1,g2;

int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%lld%lld",&u,&v,&a,&b);
		g1.addedge(u,v,a);g1.addedge(v,u,a);
		g2.addedge(v,u,b);g2.addedge(u,v,b);
	}
	g1.spfa(s);g2.spfa(t);
	ans[n+1]=INF;
	for(int i=n;i>=1;i--) ans[i]=min(ans[i+1],g1.dis[i]+g2.dis[i]);
	for(int i=1;i<=n;i++) printf("%lld\n",f-ans[i]);
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    vi A(N); REP(i, N) cin >> A[i];
    int sum = 0;
    int c = 0;
    REP(i, N) sum += A[i];
    REP(i, N)
    {
        if(A[i]*4*M >= sum) c++;
    }
    if(c >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t="Yes";
  cin >>s;
  rep(i,s.size())if(count(s.begin(), s.end(), s[i])!=2)t="No";
  cout <<t;
}

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

int main()
{
    int n, a, b, c, d;

    cin >> n;

    int m[n][n];
    for( int i = 0; i < n * ( n - 1 ) / 2; i++ )
    {
        cin >> a >> b >> c >> d;
        if( c > d )
        {
            m[a-1][b-1] = 3;
            m[b-1][a-1] = 0;
        }
        else if( c < d )
        {
            m[a-1][b-1] = 0;
            m[b-1][a-1] = 3;
        }
        else
        {
            m[a-1][b-1] = 1;
            m[b-1][a-1] = 1;
        }
    }

    int p1[n];
    for( int i = 0; i < n; i++ )
    {
        int sum = 0;
        for( int j = 0; j < n; j++ )
        {
            if( i != j )
                sum += m[i][j];
        }
        p1[i] = sum;
    }

    for( int i = 0; i < n; i++ )
    {
        int sum = 1;
        for( int j = 0; j < n; j++ )
        {
            if( p1[i] < p1[j] && i != j )
                sum++;
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  const int cost[] = {0,2,5,5,4,5,6,3,7,6};
  vector<int> dp(n+1, -1); //丁度i本使い切ってできる最大の桁数, 初期化1(どうやっても不可能な場合を-1にしておく)
  dp[0] = 0; //初期化2
  rep(i, m) { //初期化3(配るdpをするために仮置き)
    if(cost[a[i]] <= n) {
      dp[cost[a[i]]] = 1;
    }
  }
  rep(i,n+1) {
    if(dp[i]){
      rep(j,m){
        if(i+cost[a[j]] <= n)
          chmax(dp[i+cost[a[j]]], dp[i]+1);
      }
    }
  }
  sort(a.rbegin(),a.rend());
  string ans;
  int match = n, digit = dp[n];
  while(match){
    rep(i,m){
      if(match-cost[a[i]] >= 0 && dp[match-cost[a[i]]] == digit-1){
        ans += to_string(a[i]);
        match -= cost[a[i]];
        digit--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map countMap = new HashMap<String, Integer>();
        countMap.put("AC", 0);
        countMap.put("WA", 0);
        countMap.put("TLE", 0);
        countMap.put("RE", 0);

        for (int i = 1; i <= n; i++) {
            String s = sc.next();
            if ("AC".equals(s)) {
                countMap.put("AC", Integer.parseInt(countMap.get("AC").toString()) + 1);
            } else if ("WA".equals(s)) {
                countMap.put("WA", Integer.parseInt(countMap.get("WA").toString()) + 1);
            } else if ("TLE".equals(s)) {
                countMap.put("TLE", Integer.parseInt(countMap.get("TLE").toString()) + 1);
            } else {
                countMap.put("RE", Integer.parseInt(countMap.get("RE").toString()) + 1);
            }
        }

        System.out.println("AC x " + countMap.get("AC"));
        System.out.println("WA x " + countMap.get("WA"));
        System.out.println("TLE x " + countMap.get("TLE"));
        System.out.println("RE x " + countMap.get("RE"));
    }
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    if(N>= (K-1)*2+1)cout << "YES" << "\n";
    else cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

def reverse(temp):
    out = ""
    for x in temp:
        if x == "U":
            out += "D"
        elif x == "D":
            out += "U"
        elif x == "R":
            out += "L"
        else:
            out += "R"
    return out

sx,sy,tx,ty = map(int,input().split())

A = ""
B = ""
C = ""
D = ""

# A
if sy < ty:
    A += "U" * (ty-sy)
else:
    A += "D" * (sy-ty)
if sx < tx:
    A += "R" * (tx-sx)
else:
    A += "L" * (sx-tx)
B = reverse(A)

C+=B[-1]+A[0]+A+A[-1]+B[0]
D = reverse(C)


print(A+B+C+D)


Measured memory_bytes: 3064
/*
* @Author: Samson
* @Date:   2018-04-11 16:28:56
* @Last Modified by:   Samson
* @Last Modified time: 2018-05-02 21:29:21
*/
//   @URL : 
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;

int s[MAXN],n,ans;

int main(void)
{
    int q,tmp;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i)
        scanf("%d",&s[i]);
    scanf("%d",&q);
    for(int i = 1; i <= q; ++i)
    {
        scanf("%d",&tmp);
        if(binary_search(s+1,s+n+1,tmp))
            ++ans;
    }
    printf("%d\n",ans);
}


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

int main()
{
	long long w, h, x, y; cin >> w >> h >> x >> y;	
			
	double ans;
	bool unique = true;

	ans = (double) w * h / 2;

	if (x + x == w && y + y == h) {
		unique = false;
	}
	else {		
		unique = true;
	}

	int ans_unique;
	if (unique) ans_unique = 0;
	else ans_unique = 1;

	cout << fixed << setprecision(11) << ans << " " << ans_unique <<  endl;

	return 0;
}

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;

ll powmod(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = powmod(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    ll r1c1 = 0, r2c2 = 0, r1c2 = 0, r2c1 = 0;
    vll fac(r2 + c2 + 5, 1), invf(r2 + c2 + 5, 1);
    for (ll i = 2; i < fac.size(); i++) fac[i] = fac[i - 1] * i % MOD;
    for (ll i = 2; i < invf.size(); i++) invf[i] = invf[i - 1] * powmod(i, MOD - 2) % MOD;
    ll ans = 0;
    // r2c2
    for (int i = 1; i <= r2 + 1; i++) {
        r2c2 += (fac[c2 + i] * invf[c2] % MOD) * invf[i] % MOD;
        if (r2c2 >= MOD) r2c2 -= MOD;
    }
    // r2c1
    for (int i = 1; i <= r2 + 1; i++) {
        r2c1 += (fac[c1 - 1 + i] * invf[c1 - 1] % MOD) * invf[i] % MOD;
        if (r2c1 >= MOD) r2c1 -= MOD;
    }
    // r1c2
    for (int i = 1; i <= r1; i++) {
        r1c2 += (fac[c2 + i] * invf[c2] % MOD) * invf[i] % MOD;
        if (r1c2 >= MOD) r1c2 -= MOD;
    }
    // r1c1
    for (int i = 1; i <= r1; i++) {
        r1c1 += (fac[c1 - 1 + i] * invf[c1 - 1] % MOD) * invf[i] % MOD;
        if (r1c1 >= MOD) r1c1 -= MOD;
    }
    ans = r2c2 + r1c1;
    if (ans >= MOD) ans -= MOD;
    ans -= r2c1;
    if (ans < 0) ans += MOD;
    ans -= r1c2;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int keta(int x){
  int cnt=0;
  while(x){
    cnt++;
    x/=10;
  }
  return cnt;
}
int main() {
  int K;
  cin>>K;
  vector<int64_t>start;
  for(int i=1;i<=9;i++){
    start.push_back(i);
  }
  int n=K;
  while(n--){
    if(K<=start.size()){
      cout<<start[K-1]<<endl;
      return 0;
    }
    K-=start.size();
    vector<int64_t>table;
    table.clear();
    swap(table,start);
    for(int64_t x:table){
      for(int i=-1;i<=1;i++){
        int64_t a=x%10+i;
        if(a<0||a>9){continue;}
        int64_t d=10*x+a;
        start.push_back(d);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4672
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			String k = stdIn.next();
			String tmp = "";
			
			for(int i = 0; i < k.length(); i++) {
				if(k.charAt(i) == '@') {
					int ck = Integer.parseInt(String.valueOf(k.charAt(i + 1)));
					String cl = String.valueOf(k.charAt(i+2));
					for(int j = 0; j < ck; j++) {
						tmp += cl;
					}
					i += 2;
				}
				else {
					tmp += String.valueOf(k.charAt(i));
				}
			}
			System.out.println(tmp);
		}
		

	}

}

Measured memory_bytes: 17160
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		
		for(int i = 1; i < str.length(); i++) {
			if(isEven(str.substring(0, str.length()-i))) {
				System.out.println(str.length() - i);
				break;
			}
		}
	}
	
	static boolean isEven(String str) {
		if(str.length() % 2 == 1) return false;
		else {
			for(int i = 0; i < str.length() / 2; i++) {
				if(str.charAt(i) != str.charAt(str.length() / 2 + i)) return false;
			}
			return true;
		}
	}
}


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

int palindromic(int x){
    int a[5] = {};

    int i = 0;
    while (x > 0){
        a[i] = x % 10;
        x /= 10;
        ++i;
    }

    bool check;
    if (a[0] == a[4] && a[1] == a[3]) check = true;
    else check = false;
    return check;
}

int main(){
    int A, B;
    cin >> A >> B;

    int counter = 0;
    for (int i = A; i <= B; ++i){
        if (palindromic(i)) ++counter;
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=100000;
		for(int i=0;i<n;i++){
			x=(int) (1.05*x);
			if(x%1000!=0){
				x=((x/1000)+1)*1000;
			}
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 26144
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	ll X, Y;	cin >> X >> Y;
	ll num = X * 2;
	int ans = 1;
	while (num <= Y) {
		++ans;
		num *= 2;
	}
	cout << ans << endl;
	cin >> X;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n==2){
        int t;
        cin >> t;
        cout << 2*t;
        return 0;
    }
    vector<int> v(n-1);
    for(int i=0; i<n-1; i++)
        cin >> v[i];
    long long sum = 0;
    sum += v[0] + v[n-2];
    for(int i=1; i<v.size(); i++)
        sum += min(v[i], v[i-1]);
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
fun main() = Thread(null, ::abc169b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169b() {
    readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    if (aList.contains(0)) return println(0)

    var answer = aList.first()

    for (a in aList.drop(1)) {
        try {
            answer = Math.multiplyExact(answer, a)
        } catch (e: Exception) {
            return println(-1)
        }
    }
    
    val max = 1000000000000000000L

    if (answer > max) return println(-1)

    println(answer)
}


Measured memory_bytes: 63300
import sys
input=sys.stdin.readline
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
L=[[int(j) for j in input().split()] for i in range(m)]

sortsec = lambda val : val[2]
L1=sorted(L,key=sortsec,reverse=True)
cnt=10**8
for i,j,k in L1:
    num=A[i-1]+B[j-1]-k
    cnt=min(cnt,num)
num=min(A)+min(B)
print(min(num,cnt))

Measured memory_bytes: 81372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll k, t;
   cin >> k >> t;
   vector<ll> a(t);
   for(ll i = 0;i < t;i++) {
      cin >> a[i];
   }
   ll cnt = 0;
   ll before_idx = -1;
   for(ll i = 0;i < k;i++) {
      ll m = 0;
      ll idx = -1;
      for(ll j = 0;j < t;j++) {
         if (before_idx != j) {
            if (m < a[j]) {
               m = a[j];
               idx = j;
            }
         }
      }
      if (m==0) {
         a[before_idx]--;
         cnt++;
      } else {
         a[idx]--;
         before_idx = idx;
      }
   }
   cout << cnt << endl;
}

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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string next;
    next.push_back(s1[0]);
    int a = {}, b = {}, c = {};
    while (true) {
        if (next == "a") {
            if (s1.empty()) {
                cout << "A" << "\n";
                break;
            }
            next = * s1.begin();
            s1.erase(s1.begin());
            a++;
        }
        if (next == "b") {
            if (s2.empty()) {
                cout << "B" << "\n";
                break;
            }
            next = * s2.begin();
            s2.erase(s2.begin());
            b++;
        }
        if (next == "c") {
            if (s3.empty()) {
                cout << "C" << "\n";
                break;
            }
            next = * s3.begin();
            s3.erase(s3.begin());
            c++;
        }
    }
    return 0;

}


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

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int l_, int r_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

using lint = long long;

int main() {
  const int N = scan<int>();
  std::map<lint, int> count;
  std::map<lint, bool> used;
  for (int i: frep(0, N)) {
    lint x, max;
    std::cin >> x;
    for (lint t = 1; t * t * t <= x; ++t) {
      if (x % (t * t * t) == 0) { 
        max = t;
      }
    }
    count[x / (max * max * max)]++;
  }
  int ans = 0;
  for (auto p: count) {
    if (used[p.first]) {
      continue;
    }
    if (p.first == 1) {
      ++ans;
      used[p.first] = true;
      continue;
    }
    lint max;
    for (lint t = 1; t * t * t < p.first; ++t) {
      if (p.first % (t * t) == 0) {
        max = t;
      }
    }
    lint nx = p.first / (max * max);
    if (nx <= 10000000000ll / (nx * max)) {
      lint y = nx * nx * max;
      if (count.find(y) != count.end()) {
        ans += std::max(p.second, count[y]);
        used[p.first] = true;
        used[y] = true;
      }
    }
    if (!used[p.first]) {
      ans += p.second;
      used[p.first] = true;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12800