akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
int flag = 0;
int flag2 = 0;

Node treeMinimum(Node x){
  while(x->left != NULL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NULL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){

  if(u == NULL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left, k);
  }else {
    return treeSearch(u->right, k);
  }

}

Node treeSuccessor(Node x){

  Node y;
  if(x->right != NULL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NULL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else {
    y->right = z;
  }
}

void inorder(Node u){
  if(u != NULL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  
}
void preorder(Node u){
  if(u != NULL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
  

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int y,n,i,j,t,k,cnt,ans;
        cin>>n;
        int a[n+2];
        for(j=0;j<n;j++){
            cin>>a[j];
        }
        cnt=0;
        ans=0;
        int m=0;
        sort(a,a+n);
        for(j=0;j<n;j++){
            for(k=j+1;k<n-1;k++){
                    cnt=a[j]+a[k];
                ans=lower_bound(a,a+n,cnt)-a;
                m+=ans-k-1;
            }
        }
    cout<<m<<endl;
    }


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int tu[100002];
bool kaku[100002];

int main(){
  int n,l,t;
  priority_queue<pair<int,int> > pq;

  scanf("%d%d",&n,&l);

  kaku[0]=kaku[n+1]=true;

  for(int i=1;i<=n;i++)
    scanf("%d",&tu[i]);

  for(int i=1;i<=n;i++)
    if(tu[i-1]<tu[i] && tu[i]>tu[i+1]){
      pq.push(make_pair(tu[i],i));
      kaku[i] = true;
    }

  while(!pq.empty()){
    pair<int,int> p=pq.top();
    pq.pop();
    
    t=l-p.first;
    tu[p.second]=0;

    if(!kaku[p.second-1])
      if(tu[p.second-2]<tu[p.second-1]){
	pq.push(make_pair(tu[p.second-1]-t,p.second-1));
	kaku[p.second-1]=true;
      }
    if(!kaku[p.second+1])
      if(tu[p.second+2]<tu[p.second+1]){
	pq.push(make_pair(tu[p.second+1]-t,p.second+1));
	kaku[p.second+1]=true;
      }
  }

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

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second


long n,m,x[2000],y[2000],z[2000],p[2000];

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

	for(int i = 0;i < n;i++) cin >> x[i] >> y[i] >> z[i];

	ll ans = 0;
	for(int i = -1;i < 2;i+=2){
		for(int j = -1;j < 2 ;j+=2) {
			for(int k = -1;k < 2;k+=2) {
				ll sum = 0;
				REP(l,n)p[l] = x[l] * i + y[l] * j + z[l] * k; 
				sort(p,p+n);

				REP(l,m) {
					sum += p[n-l-1];
				}
				ans = max(ans,sum);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for t in T:
    id = bisect_left(S, t)
    if S[id] == t:
        cnt += 1

print(cnt)


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int getKetasum(int a){
    int ret = 0;
    while(a>0){
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

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

    int ans = inf;
    for(int i=1;i<=N/2+1;i++){
        chmin(ans,getKetasum(i)+getKetasum(N-i));
//        cout << i << " " << getKetasum(i)+getKetasum(N-i) << endl;
    }
    pl(ans)

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
 
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;
 
typedef long long ll;
 
int main()
{
	int N;
	cin >> N;
 
	if (N >= 1000)
	{
		cout << "ABD";
	}
	else
	{
		cout << "ABC";
	}
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int lenS = (int)s.size(), lenT = (int)t.size();

    vector<vector<int>> s_index(26);
    for (int i = 0; i < lenS; i++) {
        int c = s.at(i) - 'a';
        s_index.at(c).push_back(i);
    }
    for (int i = 0; i < lenS; i++) {
        int c = s.at(i) - 'a';
        s_index.at(c).push_back(i + lenS);
    }

    long long ans = 0;
    int p = 0;
    for (int i = 0; i < lenT; i++) {
        int c = t.at(i) - 'a';
        if (s_index.at(c).size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(s_index.at(c).begin(), s_index.at(c).end(), p) + 1;
        if (p >= lenS) {
            p -= lenS;
            ans += lenS;
        }
    }
    ans += p;
    cout << ans << endl;
}            

Measured memory_bytes: 1724
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
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;


struct Info{
	Info(int arg_start,int arg_end){
		start = arg_start;
		end = arg_end;
	}
	int start,end;
};

ll dp[5001][5001],work[16000];


int main(){

	int N,M,K,Q;

	scanf("%d %d %d %d",&N,&M,&K,&Q);

	int LIMIT = 0;
	while(LIMIT < N)LIMIT += 2*K;

	vector<Info> V;

	for(int day = 0; day <= M; day++){
		for(int num = 0; num <= N-1; num++)dp[day][num] = 0;
	}

	dp[0][0] = 1;

	for(int day = 0; day <= M-1; day++){

		for(int i = 0; i < 2*N; i++)work[i] = 0;

		for(int num = 0; num <= N-1; num++){

			if(dp[day][num] == 0)continue;

			work[num] += dp[day][num];
			work[num+K] -= dp[day][num];
			if(num+LIMIT < 2*N)work[num+LIMIT] -= dp[day][num];
			if(num+LIMIT+K < 2*N)work[num+LIMIT+K] += dp[day][num];
		}

		for(int i = 1; i < 2*N; i++){
			work[i] += work[i-1];
		}

		for(int i = 0; i < 2*N; i++){
			if(i+2*K < 2*N){
				work[i+2*K] += work[i];
			}else{
				break;
			}
		}

		for(int i = 0; i < N; i++){
			dp[day+1][i] = (work[i]+work[i+N])%MOD;
		}
	}

	int a,b,c;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d",&a,&b,&c);

		c = (c-a+N)%N;

		printf("%lld\n",dp[b][c]%MOD);
	}

	return 0;
}



Measured memory_bytes: 198680
import sys
v=[0]*101
for e in sys.stdin:
 a,b=map(int,e.split())
 if a==0:
  print(['NG','OK'][1&v[1]and 1&v[2]and sum(x&1 for x in v[3:])==0])
  v=[0]*101
 v[a]+=1;v[b]+=1


Measured memory_bytes: 5612
a,b = map(int, input().split())

a_min = a/0.08
a_max = (a+1)/0.08
b_min = b/0.1
b_max = (b+1)/0.1


if a_min <= b_min:
    if b_min < a_max:
        if int(b_min) == b_min:
            print(int(b_min))
        else:
            print(int(b_min+1))
    else:
        print('-1')
else:
    if a_min < b_max:
        if int(a_min) == a_min:
            print(int(a_min))
        else:
            print(int(a_min+1))
    else:
        print('-1')

Measured memory_bytes: 3064
s = input()

for i, s_i in enumerate(s):
    index = i + 1
    if index % 2 == 0:
        if s_i in 'LUD':
            continue
        else:
            print('No')
            break
    else:
        if s_i in 'RUD':
            continue
        else:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 2940
#include <iostream>
#define N1 35
using namespace std;
void Dice(int,int,int,int);
pair<int,int> data[N1][N1];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dice[6][4]={{2,3,5,4},{1,4,6,3},{1,2,6,5},{1,5,6,2},{1,3,6,4},{2,4,5,3}};
int main(){
  int n,t,f,d,i,j,cnt[6];
  d=N1/2;
  while(1){
    for(i=0;i<N1;i++){
      for(j=0;j<N1;j++){
	data[i][j].first=data[i][j].second=0;
      }
    }
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> t >> f;
      Dice(t,f,d,d);
    }
    for(i=0;i<6;i++) cnt[i]=0;
    for(i=0;i<N1;i++){
      for(j=0;j<N1;j++){
	if(data[i][j].first!=0) cnt[data[i][j].first-1]++;
      }
    }
    for(i=0;i<6;i++){
      if(i!=5) cout << cnt[i] << ' ';
      else cout << cnt[i];
    }
    cout << endl;
  }
}
void Dice(int t,int f,int y,int x){
  int s,max=3,a,r;
  for(int i=0;i<4;i++){
    if(dice[t-1][i]==f) s=i;
  }
  for(int i=0;i<4;i++){
    if(max<dice[t-1][(s+i)%4]&&data[y][x].second>data[y+dy[i]][x+dx[i]].second){
      max=dice[t-1][(s+i)%4];
      r=i;
    }
  }
  if(max!=3){
    if(r==1||r==3) a=f;
    else if(r==2) a=7-t;
    else a=t;
    Dice(7-max,a,y+dy[r],x+dx[r]);
  }else{
    data[y][x].first=t;
    data[y][x].second++;
  }
}/*
   void Dice(int t,int f,int y,int x){
   int s,cp,max=0,max2=0,cnt=2,flag,j;
   while(cnt){
   for(int i=0;i<4;i++){
   if(dice[t-1][i]==f) cp=s=i;
   }
   for(int i=0;i<4;i++){
   cout << "cnt=" << cnt << "max=" << max << " max2=" << max2 << endl;
   if(cnt==2&&max<dice[t-1][s]){
   max=dice[t-1][s];
   j=i;
   }
   else if(cnt==1&&max2<dice[t-1][s]&&max2<max){
   cout << "ioewdsifidjfiodsi" << endl;
   max2=dice[t-1][s];
   j=i;
   }
   s++;
   if(s==4) s=0;
   }
   cout << "j= " << j << endl;
   flag=0;
   if(j==0&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(7-f,t,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==1&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   cout << data[y][x].second << ' ' <<  data[y+dy[j]][x+dx[j]].second << endl;
   Dice(7-dice[t-1][(cp+j)%4],f,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==2&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(f,7-t,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==3&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(7-dice[t-1][cp+j],f,y+dy[j],x+dx[j]),flag=1;
   }
   if(flag==0&&flag2==0){
   //      cout << y << ' ' << x << endl;
   data[y][x].second++;
   data[y][x].first=t;
   flag2=1;
   }
   cout << flag2 << endl;
   if(flag2==1) cnt--;
   cnt--;
   }
   }
 */

Measured memory_bytes: 1168
#include <stdio.h>
int n,A[50];
int solve(int i, int j);
int main(){
    int q,r,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&r);
        if(solve(0,r)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}
int solve(int i, int j){
if(j==0)return 1;
    if(i>=n)return 0;
    int c=solve(i+1,j) || solve(i+1,j-A[i]);
    return c;
    }


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = a; b; a = a * a , b >>= 1){
        if (b & 1) res = res * a;
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    int bigg = to_string(N).size();
    queue<int> as;
    as.push(3);
    as.push(5);
    as.push(7);
    int answer = 0;
    REP(i,bigg){
        REP(l,modpow(3,i)){
            if(i != 0){
                int a = as.front()+3*modpow(10,i);
                int b = as.front()+5*modpow(10,i);
                int c = as.front()+7*modpow(10,i);
                bool th = 0,fi = 0,se = 0;
                REP(q,to_string(a).size()){
                    if(to_string(a)[q] == '3')th = 1;
                    if(to_string(a)[q] == '5')fi = 1;
                    if(to_string(a)[q] == '7')se = 1;
                }
                if(th&&fi&&se&&a<=N)answer++;
                th = 0,fi = 0,se = 0;
                REP(q,to_string(b).size()){
                    if(to_string(b)[q] == '3')th = 1;
                    if(to_string(b)[q] == '5')fi = 1;
                    if(to_string(b)[q] == '7')se = 1;
                }
                if(th&&fi&&se&&b<=N)answer++;
                th = 0,fi = 0,se = 0;
                REP(q,to_string(c).size()){
                    if(to_string(c)[q] == '3')th = 1;
                    if(to_string(c)[q] == '5')fi = 1;
                    if(to_string(c)[q] == '7')se = 1;
                }
                if(th&&fi&&se&&c<=N)answer++;
                as.pop();
                as.push(a);
                as.push(b);
                as.push(c);
            }
        }
    }
    cout << answer << "\n";
}

Measured memory_bytes: 384
# coding: utf-8
def is_easy(steps):
    for i, step in enumerate(steps):
        if i % 2 == 0 and step == 'L':
            return 'No'
        elif i % 2 == 1 and step == 'R':
            return 'No'
    return 'Yes'
  
steps = input()
print(is_easy(steps))

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    int m[1050];
    int c = b - a;
    int d = 0;
    for(int i = 1; i < c; i++){
        d = d + i;
    }
    int e = d - a;
    cout << e <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
string s;
ll ans=0;
void do_magic(ll now,ll to, ll from)
{
	if(now==s.size())
	{
		ans+=to+from;
		return ;
	}
	do_magic(now+1,to+from,s[now]-'0');
	do_magic(now+1,to,from*10+s[now]-'0');
}
int main(){

cin>>s;
do_magic(1,0,s[0]-'0');
cout<<ans;
}

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

typedef long long ll;

const int MAXN = 410;
const ll INF = 1e14;

ll dp[MAXN][MAXN],V[MAXN],pref[MAXN];
int N;

ll calc(ll a,ll b){
	if(a > b) return INF;
	return pref[b] - pref[a-1];
}

ll solve(int ini,int fim){
	if(dp[ini][fim] != -1) return dp[ini][fim];
	if(ini == fim) return dp[ini][fim] = 0;
	if(ini + 1 == fim) return dp[ini][fim] = V[ini] + V[fim];
	ll best = INF;
	for(int i = ini;i<fim;i++){
		ll cand = solve(ini,i) + solve(i+1,fim) + calc(ini,fim);
		best = min(best,cand);
	}
	return dp[ini][fim] = best;

}

int main()
{
	memset(dp,-1,sizeof(dp));
	cin >> N;
	for(int i = 1;i<=N;i++) cin >> V[i];
	for(int i = 1;i<=N;i++) pref[i] = pref[i-1] + V[i];
	cout << solve(1,N) << endl;
	return 0;
}

Measured memory_bytes: 4924
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{

  ios_base::sync_with_stdio(false);	
  cin.tie(NULL);
  cout.tie(NULL);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int first=max(a*c,a*d);
  int second=max(b*c,b*d);
  int res=max(first,second);
  cout<<res;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

bool f(int x)
{
        string s=to_string(x);
        int n=s.size();
        bool res=true;
        rep(i,n/2)
        {
                if(s[i]!=s[n-1-i])res=false;
        }
        return res;
}

main()
{
        int a,b; cin>>a>>b;
        int cnt=0;
        FOR(i,a,b)cnt+=f(i);
        cout<<cnt<<endl;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  val Array(n, q, l, r) = readLine.trim.split(' ').map(_.toLong)
  val number = readLine.trim.split(' ').map(_.toLong)
  val queries = Array.fill(q.toInt){
    val Array(q, x, s, t ) = readLine.trim.split(' ').map(_.toLong)
    Query(q, x, s, t)
  }
  var lower = BigInt(l)
  var upper = BigInt(r)
  var range: Range = queries.foldRight(Section(l, r): Range){case (q, r) ⇒ r.reverse(q)}
  println(number.count(range.contains))
  case class Query(q: Long, x: Long, s: Long, t: Long)
  sealed trait Range {
    def contains(value: Long): Boolean
    def contains(value: BigInt): Boolean
    def split(value: BigInt): (Range, Range)
    def takeUntil(value: BigInt): Range
    def takeTo(value: BigInt): Range
    def dropUntil(value: BigInt): Range
    def dropTo(value: BigInt): Range
    def +(that: Range): Range
    def reverse(query: Query): Range
  }
  case object Empty extends Range {
    override def contains(value: Long): Boolean = false
    override def contains(value: BigInt): Boolean = false
    override def split(value: BigInt): (Range, Range) = (Empty, Empty)
    override def takeUntil(value: BigInt): Range = Empty
    override def takeTo(value: BigInt): Range = Empty
    override def dropUntil(value: BigInt): Range = Empty
    override def dropTo(value: BigInt): Range = Empty
    override def +(that: Range): Range = that
    override def reverse(query: Query): Range = Empty
  }
  case class Section(from: BigInt, to: BigInt) extends Range {
    override def contains(value: Long): Boolean = from <= value && value <= to
    override def contains(value: BigInt): Boolean = from <= value && value <= to
    override def split(value: BigInt): (Range, Range) = if (contains(value)) (Section(from, value), Section(value, to)) else if (value < from) (Empty, this) else (this, Empty)
    override def takeUntil(value: BigInt): Range = if (value < from) Empty else Section(from, min(to, value - 1))
    override def takeTo(value: BigInt): Range = if (value < from) Empty else Section(from, min(to, value))
    override def dropUntil(value: BigInt): Range = if (to < value) Empty else Section(max(from, value), to)
    override def dropTo(value: BigInt): Range = if (to < value) Empty else Section(max(from, value + 1), to)
    override def +(that: Range): Range = that match {
      case Empty ⇒ this
      case Section(fromT, toT) ⇒Section(min(fromT, from), max(toT, to))
    }
    override def reverse(query: Query): Range = query match {
      case Query(1, x, s, t) ⇒ takeUntil(x) + Section((from + t - 1) / t - s, to / t - s).dropUntil(x)
      case Query(2, x, s, t) if to < 0 ⇒ Section(from * t + s + 1 - t, to * t + s).takeTo(x) + dropTo(x)
      case Query(2, x, s, t) if contains(0) ⇒ Section(from * t + s + 1 - t, to * t + s + t - 1).takeTo(x) + dropTo(x)
      case Query(2, x, s, t) ⇒ Section(from * t + s, to * t + s + t - 1).takeTo(x) + dropTo(x)
      case _ ⇒ ???
    }
  }
  def min[T: Ordering](a: T, b: T): T = if (implicitly[Ordering[T]].compare(a, b) <= 0) a else b
  def max[T: Ordering](a: T, b: T): T = if (implicitly[Ordering[T]].compare(a, b) >= 0) a else b
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

bool isOk(vec<ll>& D, int diff){
    int lTop = 0;
    int rTop = 0;
    for(auto d: D){
        int lGap = d - lTop;
        int rGap = d - rTop;
        if(lGap < diff && rGap < diff){
            // impossible
            return false;
        }else if(lGap >= diff && rGap >= diff){
            // できるだけ後半をのこしておく。すすんでいる方をつぶす
            if(lTop >= rTop){
                // 左におく
                lTop = d;
            }else{
                rTop = d;
            }
        }else if(lGap >= diff){
            // 左におくしかない
            lTop = d;
        }else{
            // 右におくしかない
            rTop = d;
        }
        // 末尾が大丈夫か確認する
        int finalGap = 24 - lTop - rTop;
        if(finalGap < diff){
            // だめだった
            return false;
        }
    }
    return true;
}

void solve(long long N, std::vector<long long> D){
    sort(D.begin(), D.end());
    for(int i=12; i >= 0; i--){
        if(isOk(D, i)){
            cout << i << endl;
            break;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define USE 2

using namespace std;

bool Find;
vector<int> check,vl,cu;
vector< vector<int> > el;

void dfs(int nov) {
	if (!Find) {
		int ind = 0;
		int v = vl[nov-1];
		check[v] = 1;
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == 1) {
				cu[el[v][i]] = -v;
			}
			else if (cu[el[v][i]] == USE) {
				for (int j = ind; j < nov; ++j) {
					if (vl[j] == el[v][i]) {
						ind = j;
						Find = true;
					}
				}
			}
		}
		if (Find) {
			cout << nov-ind << endl;
			for (int i = ind; i < nov; ++i) {
				cout << vl[i]+1 << endl;
			}
			return;
		}
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = USE;
				vl[nov] = el[v][i];
				dfs(nov+1);
				cu[el[v][i]] = -v;
			}
		}
		for (int i = 0; i < el[v].size(); ++i) {
			if (cu[el[v][i]] == -v) {
				cu[el[v][i]] = 1;
			}
		}
	}
	return;
}

int main(void) {
	int u,v,N,M;
	scanf("%d %d",&N,&M);
	el = vector< vector<int> >(N);
	for (int i = 0; i < M; ++i) {
		scanf("%d %d",&u,&v);
		el[u-1].push_back(v-1);
	}
	int s = 0;
	check = vector<int>(N,0);
	cu = vector<int>(N,1);
	vl = vector<int>(N);
	Find = false;
	while (!Find && s < N) {
		if (check[s] == 0) {
			vl[0] = s;
			cu[s] = USE;
			dfs(1);
			cu[s] = 1;
		}
		++s;
	}
	if (!Find) {
		cout << -1 << endl;
	}
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//最大公約数 複数個
int gcd(const vector<int> &v) {
    int ret = v[0];
    for (int i = 1; i < v.size(); i++)
        ret = gcd(ret, v[i]);
    return ret;
}
//最小公倍数 複数個
int lcm(const vector<int> &v) {
    int ret = v[0];
    for (int i = 1; i < v.size(); i++)
        ret = lcm(ret, v[i]);
    return ret;
}

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

    int2(n, m);
    string yui, kyoko;
    cin >> yui >> kyoko;

    int targ = gcd(n, m);
//    cout << targ << endl;

    int ptr1 = n / targ, ptr2 = m / targ;
    int i = 0;
    while (1) {
        if (ptr1 * i >= n || ptr2 * i >= m) {
            break;
        }
        if (yui[ptr1 * i] != kyoko[ptr2 * i]) {
            cout << -1 << endl;
            return 0;
        }
        i++;
    }

    cout << lcm(n, m) << endl;

    return 0;
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


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



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

int N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> a(N), v(N);
    REP(i, 0, N){
        cin >> a[i];
        v[i] = a[i];
    }
    sort(v.begin(), v.end());
    REP(i, 0, N){
        if(a[i] == v[N-1]) cout << v[N-2] << '\n';
        else cout << v[N-1] << '\n';
    }


}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

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

int main(void) {
	int n, a, ans = 0;
	cin >> n >> a;
	ans = n / a;
	n %= a;
	if (n > 0)
		ans++;
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int n;
    string s;

    cin >> n >> s;

    int count = 0;
    for(int i = 0; i < n - 2; i++) {
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define p push_back
#define endl "\n"
#define l long long int
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    l n,d,ans=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        int b,c;
        cin>>b>>c;
        if(ceil(sqrt(pow(b,2)+pow(c,2)))<=d)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3692
io = STDIN
n,$k=io.gets.split.map(&:to_i)
ar = io.gets.split.map(&:to_i)
plus =ar.select{|x|x>=0}
minus =ar.select{|x|x<0}.map{|x|-x}.reverse
def calc2(pct,mct,plus,minus)
  min=[plus[pct-1],minus[mct-1]].min
  max=[plus[pct-1],minus[mct-1]].max
  min*2 + max
end
def calc(ar,plus,minus)
  ans=Float::INFINITY
  (0..plus.size).each do |pct|
    mct=$k-pct
    if mct <= minus.size
      ans=[ans,calc2(pct,mct,plus,minus)].min
    end
  end
  ans
end
if plus ==[]
  puts minus[$k-1]
elsif minus ==[]
  puts plus[$k-1]
else
  puts calc(ar,plus,minus)
end


Measured memory_bytes: 12804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ans = true;
    while(true)
    {
        c -= b;
        if(c <= 0)
        {
            ans = true;
            break;
        }
        a -= d;
        if(a <= 0)
        {
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  map <ll, ll> score;
  rep(i, n) {
    ll a;
    cin >> a;
    for (ll i = -1; i <= 1; i++) {
      if (score.count(a+i)) score.at(a+i)++;
      else score[a+i] = 1;
    }
  }
  ll res = 0;
  for (auto p : score) res = max(res, p.second);
  cout << res << endl;
}

Measured memory_bytes: 6144
N=int(input())
A=[int(x) for x in input().split()]
i=0
flag=True
count=0
while flag:
    flag=False
    for j in range(N-1,i,-1):
        if A[j]<A[j-1]:#ソート必須
            A[j],A[j-1]=A[j-1],A[j]
            count+=1
            flag=True


    i += 1
for i in range(N):print(A[i],end=' \n'[i+1==N])
print(count)


Measured memory_bytes: 5620
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin>>s;
    int n = s.size();
    int sum[n+1]={};
    for(int i=0;i<n;i++){
        if(s[i] == '1')sum[i+1]++;
        else sum[i+1]--;
        sum[i+1] += sum[i];
    }
    int ma[n+1]={};
    int mi[n+1]={};
    mi[n]=1e9, ma[n]=-1e9;
    for(int i=n-1;i>=0;i--){
        ma[i] = max(ma[i+1],sum[i+1]);
        mi[i] = min(mi[i+1],sum[i+1]);
    }
    int ans = max(0,ma[0])-min(0,mi[0]);
    int mx = max(0,ma[0]);
    for(int t=0;t<2;t++){
        int now = 0,cnt=0;
        int mini = 0;
        for(int i=0;i<n;i++){
            if(s[i]=='0')now--;
            else if(s[i] == '1')now++;
            else{
                if(max(now+1,ma[i]+cnt+2) <= mx){
                    now++;
                    cnt+=2;
                }
                else now--;
            }
            chmin(mini,now);
        }
        chmin(ans,mx-mini);
        cerr << mx << " " << mini << endl;
        mx++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 16120
from collections import deque

s = deque(input())
q = int(input())

direction = 0
for _ in range(q):
    a = input()
    if a[0]=='1':
        direction+=1
    else:
        t,f,c = a.split()
        if f=='1':
            if direction%2==0:
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if direction%2==0:
                s.append(c)
            else:
                s.appendleft(c)

if direction%2==1:
    s.reverse()
print(''.join(s))




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

int main(){
  string A,B;
  cin >> A >> B;
  if(A.length()>B.length()) cout << "GREATER";
  else if(A.length()<B.length())cout << "LESS";
  else if(A==B)cout << "EQUAL";
  else{
    for(int i=0;true;i++){
      if(A[i]>B[i]){
        cout << "GREATER";
        break;
      }
      else if(A[i]<B[i]){
        cout << "LESS";
        break;
      }
    }
  }
}



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

using namespace std;
using ll = long long;

#define endl '\n'
#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);

int main() {
    FIO();

    string s; cin >> s;
    if (s.back() == 's') s += "es";
    else s += 's';

    cout << s << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

map<int, int> prime_factor(int n) {
  map<int, int> ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  map<int, int> lc;
  REP(i,n){
    auto mp = prime_factor(a[i]);
    for(auto p: mp){
      if(lc[p.first]<p.second) lc[p.first] = p.second;
    }
  }
  
  mint lc_mod = 1;
  for(auto p: lc){
    lc_mod *= mint(p.first).pow(p.second);
  }
  
  mint ans = 0;
  REP(i,n) ans += lc_mod / mint(a[i]);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4116
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int b =N;
	int count =0;
	for(int i=0;i<8;i++) {
		count+=b%10;
		b=b/10;
	}
	if(N%count==0){
		System.out.println("Yes");
	}
	else{
		System.out.println("No");
	}
	}
	}



Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;









int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if (i%3!=0 && i%5!=0) ans+=i;
    }
    cout << ans;
    rn 0;
}

















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

int main() {
  int N,A;
  cin >> N;
  int Xmin = 100;
  for(int i = 0;i < N;i++){
    int X = 0;
    cin >> A;
    while(A % 2 == 0){
      A /= 2;
      X += 1;
    }
    Xmin = min(X,Xmin);
  }
  cout << Xmin << endl;
}


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

int main(){

  int n,max=-1000000,min=1000000,a[N];
  long long sum=0;
  cin>>n;
  for(int i=0;i<n;i++){

    cin>>a[i];
    if(max<a[i]) max=a[i];
    if(min>a[i]) min=a[i];
    sum+=a[i];

  }

  cout<<min<<" "<<max<<" "<<sum<<endl;

  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int n,k;
    std::string s;

    std::cin >> n;
    std::cin >> s;
    std::cin >> k;

    for(int i=0; i<n; i++){
        if(s[k-1]!=s[i])
            s[i] = '*';
    }

    std::cout << s << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int Q = scanner.nextInt();
        int[] A = new int[N];

        for(int i = 0; i < Q; i++) {
            int j = scanner.nextInt();
            A[j-1]++;
        }

        for(int i = 0; i < N; i++) {
            if(A[i] + K > Q) {
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }

    }
}


Measured memory_bytes: 60912
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

int n, m;
string s, p;

int main(){
    cin >> s >> p;
    n = s.size();
    m = p.size();
    s += s;
    rep(i, n){
        if(p == string(s, i, m)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
 
int main(){
  int a,b,i,kai=0;
  
  scanf("%d %d",&a,&b);
  
  for(i=0;i<2;i++){
    if(a>=b){
      kai+=a;
      a--;
    }
    else{
      kai+=b;
      b--;
    }
  }
  printf("%d",kai);
  return 0;
}

Measured memory_bytes: 128
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0;
std::cin >> x;
for(;;){
  if(x-7>0){
    x-=7;
  }else{
    break;
  }
}
 if(x==1)std::cout << "fri" << '\n';
else if(x==2)std::cout << "sat" << '\n';
else if(x==3)std::cout << "sun" << '\n';
else if(x==4)std::cout << "mon" << '\n';
else if(x==5)std::cout << "tue" << '\n';
else if(x==6)std::cout << "wed" << '\n';
else if(x==7)std::cout << "thu" << '\n';
else if(x==8)std::cout << "fri" << '\n';
else std::cout << "sat" << '\n';
}



Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long answer = Long.MAX_VALUE;
        for (int i = 0; i <= N; i++) {
            long current = 1;
            int j = N - i;
            for (int k = 0; k < i; k++) {
                current = current * 2;
            }
            current += K * j;
            answer = Math.min(answer, current);
        }
        System.out.println(answer);
    }
}


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

int main(){
    int N,K;
    int H[111111];
    int i;
    cin >> N;
    cin >> K;
    for(i=0;i<=N-1;i++)
        cin >> H[i];
    sort(H,H+N);
    int S[111111];
    for(i=0;i<=N-K;i++)
        S[i] = H[i+K-1] - H[i];
    int min = S[0];
    for(i=0;i<=N-K;i++)
        if(min > S[i]) min = S[i];
    cout << min << endl;
}

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

int main() {
	int N;
	cin >> N;
	priority_queue<double, vector<double>, greater<double> > que;
	for (int n = 0; n < N; ++n) {
		double m;
		cin >> m;
		que.push(m);
	}
	while (1 != que.size()) {
		double d1 = que.top();
		que.pop();
		double d2 = que.top();
		que.pop();
		que.push((d1 + d2) / 2.0);
	}
	double dans = que.top();
	printf("%.10f\n", dans);
	return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>

int main(){
  int x,y,tmp,i,res;

  scanf("%d %d", &x, &y);
  if(y>x){ // x>=y にする
    tmp=x;
    x=y;
    y=tmp;
  }
  x= x%y;
  res= y;
  //x(x&y)とyの最大公約数を求める
  for(i=x; i>0; i--) if(x%i==0 && y%i==0){
      res=i;
      break;
    }
  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 592
from fractions import gcd

def solve():
    a, b, c, d = map(int, input().split(' '))
    if a < b or d < b: return False
    if c >= b: return True
    
    a = a % b
    d = d % b
    x = gcd(b, d)
    k = (b - a) // x
    if (b - a) % x == 0: k -= 1
    return not (c < a + k * x < b)
    
def main():
    t = int(input())
    ans = []
    for _ in range(t):
        ans.append(['No','Yes'][solve()])
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
		
	int nr = 0;
	int p = 0;
	
	for(int i = 0; i < s.size(); i++)
		if(s[i] == 'A')
			p++;
		else
		{
			if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C')
			{
				nr += p;
				i++;
			}
			else
				p = 0;
		}
	
	cout << nr;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;
bool check=false;

int main(void){
    long N,M;
    cin>>N>>M;
    struct edge {long to,cost,index;};
    vector<vector<edge>> e(N,vector<edge>());
    
    for(int i=0;i<M;i++){
        long a,b,c;
        cin>>a>>b>>c;
        e.at(a-1).push_back({b-1,c,i});
        e.at(b-1).push_back({a-1,c,i});
    }
    
    vector<bool> unused(M+1,true);//Mはダミー
    typedef pair<pair<long,long>,long> P;//first.first 距離　//firt.second 頂点名　//second 直前の辺
    for(int s=0;s<N;s++){
        if(check) cout<<s<<"からの辺 start------------------------------------------------------------"<<endl;
        priority_queue<P,vector<P>,greater<P>> que;
        vector<long> d(N,INF),done(N,false);
        que.push(make_pair(make_pair(0,s),M));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            
            long vert=p.first.second,dist=p.first.first,inde=p.second;
            if(check) cout<<"  頂点"<<vert<<"へ辺"<<inde<<"を通ってコスト"<<dist<<"で来れます-------------------"<<endl;
            //cout<<dist<<"<="<<d.at(vert)<<endl;
            if(dist>d.at(vert)) {
                if(check) cout<<"->頂点"<<vert<<"への新距離"<<dist<<"はもはや最短ではないです"<<endl;
                continue;
            }
            if(check) cout<<"->頂点"<<vert<<"への新距離"<<dist<<"は最短です"<<endl;
            unused.at(inde)=false;
            if(done.at(vert)) continue;
            done.at(s)=true;
            d.at(vert)=dist;
            if(check) cout<<"->頂点"<<vert<<"は未使用です。d.at("<<vert<<")を"<<dist<<"に更新します"<<endl;
            for(int i=0;i<e.at(vert).size();i++){
                edge ed=e.at(vert).at(i);
                if(check) cout<<"   ->頂点"<<ed.to<<"へ辺"<<ed.index<<"で進むと暫定最短タイですか？"<<endl;
                if(d.at(ed.to)>=d.at(vert)+ed.cost){
                    if(check) cout<<"       YES"<<endl;
                    que.push(make_pair(make_pair(d.at(vert)+ed.cost,ed.to),ed.index));
                }else if(check) cout<<"       NO"<<endl;
            }
        }
    }
    
    cout<<accumulate(unused.begin(),unused.end(),0)<<endl;
}

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

int main(){
  int i,n,t=0,h=0;
  char ct[100],ch[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %s",ct,ch);
    if(strcmp(ct,ch)==0){
      t++;
      h++;
    }
    else if(strcmp(ct,ch)>0)t += 3;
    else h += 3;
  }

  printf("%d %d\n",t,h);
  return 0;
}

Measured memory_bytes: 604