akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"


//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 100 + 2;
const int INF = 2e9;

int tre[4 * MAXN];
int a[] = {1, 2, 3, 4, 5};
int f[4 * MAXN];

void build(int v, int l, int r){
	if(l == r){
		tre[v] = a[l];
	}
	else{
		int m = (l + r) / 2;
		build(2 * v, l, m);
		build(2 * v + 1, m + 1, r);
		tre[v] = tre[v * 2] + tre[v * 2 + 1];
	}
}
void push(int v, int l, int m, int r){
	f[2 * v] += f[v];
	f[2 * v + 1] += f[v];
	tre[2 * v] += (m - l + 1) * f[v];
	tre[2 * v + 1] += (r - m) * f[v];
	f[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, int val) {
	if (l > r)
		return;
	if (l == tl && r == tr) {
		tre[v] += val * (r - l + 1);
		f[v] += val;
		return;
	}

	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);

	update(v * 2, tl, tm, l, min(r, tm), val);
	update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);

	tre[v] = tre[2 * v] + tre[2 * v + 1];
}


int sum(int v, int tl, int tr, int l, int r) {
	if (l > r)
		return 0;
	if (l == tl && r == tr) {;
		return tre[v];
	}
	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);
	return sum(v * 2, tl, tm, l, min(r, tm))
		   + sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}


int g[MAXN][MAXN];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	ll l, r;
	cin >> l >> r;

	if((r - l - 1) / 2019 > 0) {finish(0);}

	ll mn = 1e18;

	for(ll i = l; i <= r; i++){
		for(ll j = i + 1; j <= r; j++){
			mn = min(mn, (i * j) % 2019);
		}
	}

	cout << mn;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string s;
    while(true){
        cin>>s;
        if(s=="0") break;
        int sum=0;
        for(int i=0;i<s.length();i++){
            int a=s[i]-'0';
            sum+=a;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

static const int N=1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=m;i++)
        c[i][0]=0;
  for(int j=0;j<=n;j++)
       c[0][j]=0;

  for(int i=1;i<=m;i++){
    for(int j=1;j<= n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s1,s2;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
}





Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int gcd(int a,int b){
  if(a % b == 0) return b;
  return gcd(b, a%b);
}

int lcm(int a,int b){
  return a * b / gcd(a,b);
}

int main(){
  int k,x;
  cin >> k >> x;
  int n = k-1;
  for(int i = x-n; i <= x+n; i++){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)

template<typename F> double bsearch(double ok, double ng, ll loop, F f) {
	REP(i, loop) {
		double middle = (ok + ng) / 2;
		(f(middle) ? ok : ng) = middle;
	}
	return ok;
}
int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	
	while (true) {
		ll r, n; cin >> r >> n;
		if (r == 0)break;
		vector<ll> hl(30, 0), hr(30, 0);
		const int D = 30;
		REP(i, n) {
			ll xl, xr, h; cin >> xl >> xr >> h;
			FOR(x, xl, min(xr, 0ll)) hl[abs(x) - 1] = max(hl[abs(x) - 1], h);
			FOR(x, max(0ll, xl), xr) hr[x] = max(hr[x], h);
		}
		cout << bsearch(0, 100000, 1000, [&](double t) {
			FOR(i, -r + 1, r) {
				if (i <= 0) if (sqrt(r*r - i*i) + t - r > hl[abs(i)]) return false;
				if (i >= 0) if (sqrt(r*r - i*i) + t - r > hr[i]) return false;
			}
			return true;
		}) << endl;
	}

	return 0;
}

Measured memory_bytes: 3152
from datetime import datetime
r=[]
while 1:
    l=list(map(int,input().split()))
    if not l[0] and not l[1]:break
    r.extend([datetime(year=2004,month=l[0],day=l[1]).weekday()])
for i in r:
    if i==0:print("Monday")
    elif i==1:print("Tuesday")
    elif i==2:print("Wednesday")
    elif i==3:print("Thursday")
    elif i==4:print("Friday")
    elif i==5:print("Saturday")
    elif i==6:print("Sunday")



Measured memory_bytes: 6040
from collections import *

N = int(input())
A = list(map(int, input().split()))
ans = sum(A)
cnt = Counter(A)

for i in range(int(input())):
    B, C = list(map(int, input().split()))
    ans -= B * cnt[B]
    ans += C * cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(ans)

Measured memory_bytes: 24148
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def check(A, M, V, P, idx):
  # print(f'i={idx}, A={A}, M={M}, V={V}, P={P}')
  v = A[idx] + M

  if v < A[P]:
    # print(f'v={v}, False')
    return False

  n = M * (V - P - (len(A) - idx))

  if n <= 0:
    # print(f'v={v}, n={n}, True')
    return True

  r = sum(v - x for x in A[P:idx])

  # print(f'v={v}, n={n}, r={r}, {r >= n}')
  return r >= n


def main():
  _, M, V, P = map(int, input().split())
  A = sorted(list(map(int, input().split())), reverse=True)
  P -= 1

  if check(A, M, V, P, len(A) - 1):
    print(len(A))
    return

  low = P
  high = len(A) - 1

  while (high - low) > 1:
    idx = (low + high) // 2
    ret = check(A, M, V, P, idx)

    if ret:
      low = idx
    else:
      high = idx

  print(high)


if __name__ == '__main__':
  main()


Measured memory_bytes: 66072
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 100005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll wt[mx], val[mx], n, dp[mx][105];

ll knap(ll w, ll i){

	if(i == n)
	return 0;

	if(!w)
	return 0;

	if(dp[w][i] != -1)
	return dp[w][i];

	if(w < wt[i])
	return dp[w][i] = knap(w, i+1);

	return dp[w][i] = max(val[i] + knap(w - wt[i], i+1), knap(w, i+1));
}

void bta_de_yarr(){

	ll  i, j, fl=0, ans, m;
	// ll a[mx];
	cin>>n;
	cin>>m;

	rep(i, 0, n){

		cin>>wt[i]>>val[i];
	}

	rep(i, 0, m+1){

		rep(j, 0, n+1)
		dp[i][j]= -1;
	}

	ans= knap(m, 0);
	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 82304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int a,b,c;
    scanf("%d%d",&a,&b);

    char a2[8],b2[8];
    sprintf(a2,"%d",a);
    sprintf(b2,"%d",b);

    c=atoi(strcat(a2,b2));
    int flag=0;
    for(int i=1;i*i<=c;i++){
        if(i*i==c){
            printf("Yes"); 
            flag=1;
        }
    }
    if(flag==0)printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;
	int ans=0;
	for(int i=0;i<N-1;i++){
		if(S[i]==S[i+1]){
			ans++;
		}

	}
	cout<<min(ans+2*K,N-1)<<endl;
}

Measured memory_bytes: 512
using System;
class Mainclass 
{
    static void Main()
    {
        var input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        Console.WriteLine(input[0] % 3 * input[1] % 3 * (input[0] + input[1]) % 3 == 0 ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 27404
// #define _DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#else
#define dump(x)
#endif
#ifdef _DEBUG
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#else
#define dump2(x, y)
#endif

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void getAnswer(ll &answer, ll w1, ll w2, ll w3, ll h1, ll h2, ll h3) {
  ll smax = max(w1 * h1, max(w2 * h2, w3 * h3));
  ll smin = min(w1 * h1, min(w2 * h2, w3 * h3));
  answer = smax - smin;
  dump2(w1, h1);
  dump2(w2, h2);
  dump2(w3, h3);
  dump(smax);
  dump(smin);
  dump(answer);
}

void solve(ll H, ll W) {
  ll w1, w2, w3;
  ll h1, h2, h3;

  // 1. 縦割り
  switch (W % 3) {
  case 2:
    w1 = w2 = W / 3 + 1;
    w3 = W / 3;
    break;
  case 1:
    w1 = W / 3 + 1;
    w2 = w3 = W / 3;
    break;
  case 0:
    w1 = w2 = w3 = W / 3;
    break;
  }
  h1 = h2 = h3 = H;
  ll answer1;
  getAnswer(answer1, w1, w2, w3, h1, h2, h3);

  // 2. 横割り
  switch (H % 3) {
  case 2:
    h1 = h2 = H / 3 + 1;
    h3 = H / 3;
    break;
  case 1:
    h1 = H / 3 + 1;
    h2 = h3 = H / 3;
    break;
  case 0:
    h1 = h2 = h3 = H / 3;
    break;
  }
  w1 = w2 = w3 = W;
  ll answer2;
  getAnswer(answer2, w1, w2, w3, h1, h2, h3);

  // 3.縦大
  h1 = H;
  switch (H % 2) {
  case 1:
    h2 = H / 2 + 1;
    h3 = H / 2;
    break;
  case 0:
    h2 = h3 = H / 2;
    break;
  }
  w2 = w3 = (W / 3) * 2 + 1;
  w1 = W - w2;
  ll answer3;
  getAnswer(answer3, w1, w2, w3, h1, h2, h3);

  // 4.横大
  w1 = W;
  switch (W % 2) {
  case 1:
    w2 = W / 2 + 1;
    w3 = W / 2;
    break;
  case 0:
    w2 = w3 = W / 2;
    break;
  }
  h2 = h3 = (H / 3) * 2 + 1;
  h1 = H - h2;
  ll answer4;
  getAnswer(answer4, w1, w2, w3, h1, h2, h3);

  dump(answer1);
  dump(answer2);
  dump(answer3);
  dump(answer4);

  ll answer = min(answer1, min(answer2, min(answer3, answer4)));
  cout << answer << endl;
}

// Generated by 1.1.6 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() {
  ll H;
  scanf("%lld", &H);
  ll W;
  scanf("%lld", &W);
  solve(H, W);
  return 0;
}


Measured memory_bytes: 256
#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;

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

}

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

}

Node treeSearch(Node u, int k){
  if(u==NIL || 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!=NIL){
    return treeMaximum(x->right);
  }
  y=x->parent;
  while(y!=NIL && 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
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
  


}

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!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }




}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    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: 20452
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);
 
int main(){
    int n, inA, ans = 0;
    cin >> n;
    int a[n];
	for(int i=0;i<n;i++){
		cin >> inA;
		a[i] = inA;
	}
    
	for(int i=0; i<n;i++){
		int a1 = a[i];
		int a2 = a[a1-1];
		ans += ((a1 < a2 || a2 < a1) && i+1 == a2 )? 1 : 0;
	}
    cout << ans/2 << endl;
}

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

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

const int MAXN = 1e5;

int N, K, H[MAXN+10], dp[MAXN+10];

int main()
{
    int i, j;

    scanf("%d%d", &N, &K);
    for(i=1; i<=N; i++) scanf("%d", &H[i]);

    for(i=2; i<=N; i++)
    {
        dp[i]=2147483647;
        for(j=max(i-K, 1); j<i; j++) dp[i]=min(dp[i], dp[j]+abs(H[i]-H[j]));
    }
    printf("%d", dp[N]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
void add_self(ll &a, ll b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
}
string k;
int d;
ll dp[100005][101][2];
ll solve(int index, int rem, int flag){
    if(index == k.size()){
        return rem == 0;
    }
    if(dp[index][rem][flag] != -1){
        return dp[index][rem][flag];
    }
    ll ans = 0;
    int num = (k[index] - '0');
    for(int i = 0; i < ((!flag) ? num : 10); i++){
        add_self(ans,solve(index+1, (rem + i)%d, 1));
    }
    if(!flag){
        add_self(ans, solve(index+1, (rem+num)%d, flag));
    }
    return dp[index][rem][flag] = ans;
}
int main() {
    IO;
    memset(dp, -1, sizeof dp);
    cin  >> k >> d;
    cout << (solve(0, 0,  0)-1+MOD)%MOD;



    return 0;
}


Measured memory_bytes: 158976
# ABC160 C

def main():
    k, n = map(int, input().split())
    A = list(map(int, input().split()))
    
    maxIndex = 0
    maxDist = 0
    
    for i in range(n):
        if i == n - 1:
            gap = A[0]+k - A[i]
        else:
            gap = A[i+1] - A[i]
        
        if gap >= maxDist:
            maxDist = gap
            maxIndex = i
    
    if maxIndex == n - 1:
        print(A[-1] - A[0])
    else:
        print((A[maxIndex]+k) - A[maxIndex+1])            

if __name__ == '__main__':
    main()

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long


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

    int n; cin >> n;
    string s; cin >> s;
    if (n & 1) {
        cout << "No"; return 0;
    }

    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[i+n/2]) {
            cout << "No"; return 0;
        }
    }
    cout << "Yes";
 
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;
int n;
int a[15];
int main()
{
	cin >> n;
	int flag = 0;
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j <= 9; j++)
			if(i*j == n)
				flag = 1;
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int N, K;
  int number = 1;
  
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    if (number * 2 < number + K) {
      number *= 2;
    } else {
      number += K;
    }
  }
  cout << number << endl;
}

Measured memory_bytes: 256
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
S = input()

ANS = []*n
for i in range(len(S)):
    x = A.index(S[i])
    ANS.append(A[n+x])
for i in range(len(ANS)):
    print(ANS[i], end = "")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a>b)
		cout << "a > b" << endl;
	else if(a<b)
		cout << "a < b" << endl;
	else 
		cout << "a == b" << endl;
}


Measured memory_bytes: 3088
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    a += b
    c += d
    ans = ["Left", "Right"]
    if a == c:
        print("Balanced")
        return
    print(ans[a < c])
    return

#B
def B():
    n, a, b = LI()
    ans = 0
    for i in range(1, n + 1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
           ans += i
    print(ans) 
    
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 43116
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

void cmin(int &lhs,int rhs){
    lhs=min(lhs,rhs);
}
const int INF=1e9;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];

    vector<vector<int>> dp(1<<n,vector<int>(n,INF));
    dp[0][0]=0;

    auto build=[&](int cnt,int id){
        if(cnt<0) return 0;
        else if((cnt-id)%2) return b[id];
        else return a[id];
    };
    
    for(int bit=0;bit<((1<<n)-1);bit++){
        int pc=__builtin_popcount(bit);
        
        for(int i=0;i<n;i++){
            int x=build(pc-1,i);
            int piyo=pc;
            for(int j=0;j<n;j++){
                if((bit>>j)&1){
                    piyo--;
                    continue;
                }
                int y=build(pc,j);
                if(x<=y){
                    int nexBit=bit|(1<<j);
                    cmin(dp[nexBit][j],dp[bit][i]+piyo);
                }
            }
        }
    }
    int ans=*min_element(dp[(1<<n)-1].begin(),dp[(1<<n)-1].end());
    if(ans==INF){
        cout<<-1<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 26880
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]

N = int(input())
L = [None]*N
for i in range(N):
    *L[i], = map(int, input().split())

p = (0, 0, 0, 1, 1, 2, 2, 3)
ok = 1
for i in range(N):
    Li = L[i]
    for j in range(i+1, N):
        Lj = L[j]
        for k in range(24):
            if Li == Lj:
                ok = 0
            Lj[:] = (Lj[e] for e in D[p[k%8]])
print("Yes" if ok else "No")


Measured memory_bytes: 5608
#include <cstdio>

int main(int argc, char const* argv[])
{
	int n;
	scanf("%d", &n);
	char **a = new char*[n];
	for(int i = 0; i < n; i++){
			a[i] = new char[n];
			scanf("%s", a[i]);
	}
	int count = 0;
	for(int k = 0; k < n; k++){
			int flag = 0;
			for(int i = 0; i < n; i++){
					if(flag == 1)break;
					for(int j = 0; j < n; j++){
							if(a[i][j] != a[(j+k) % n][(i - k + n) % n]){
									flag = 1;
									break;
							}
					}
					if(i == n - 1)count++;
			}
	}
	printf("%d\n", count*n);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;
typedef pair<int, int> P;

const int mod = 998244353;

const int DEPTH = 18;
const int INF = 1e+12;

struct SegMax {
	int val[1 << (DEPTH + 1)];
	SegMax() { int i; rep(i, (1 << (DEPTH + 1))) val[i] = -INF; }
	int getMax(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return -INF;
		if (l <= a && b <= r) { return val[id]; }
		int res1 = getMax(l, r, a, (a + b) / 2, id * 2 + 1);
		int res2 = getMax(l, r, (a + b) / 2, b, id * 2 + 2);
		return max(res1, res2);
	}
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		val[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			val[pos] = max(val[pos * 2 + 1], val[pos * 2 + 2]);
		}
	}
};

int n;
P pa[200000];
int x[200000], d[200000];
SegMax segMax;
int R[200000];
int dp[200001];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> pa[i].first >> pa[i].second;
	sort(pa, pa + n);
	rep(i, n) { x[i] = pa[i].first; d[i] = pa[i].second; }
	
	rep(i, n) { segMax.update(i, i); }
	rrep(i, n) {
		int iter = lower_bound(x, x + n, x[i] + d[i]) - x;
		int val = segMax.getMax(i, iter);	//[i, iter)
		R[i] = val;
		segMax.update(i, val);
	}
	
	dp[0] = 1;
	rep(i, n) {
		dp[i + 1] += dp[i];
		dp[i + 1] %= mod;
		dp[R[i] + 1] += dp[i];
		dp[R[i] + 1] %= mod;
	}
	
	cout << dp[n] << endl;
	return 0;
}

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

const ll INF = 1e15;

void worshallFloyd(vector<vector <ll>> &d) {
  int V = d.size();
  for(int k = 0; k < V; k++) {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        if(d[i][k] != INF && d[k][j] != INF)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int H, W;

int main () {
  cin >> H >> W;

  vector<vector<ll>> G(10, vector<ll>(10));
  rep(i,10)rep(j,10) cin >> G[i][j];

  worshallFloyd(G);

  ll ans = 0;
  rep(i,H)rep(j,W) {
    int A;
    cin >> A;
    if(A == -1) continue;
    ans += G[A][1];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
ll t,n,m,i,j,k,l,x,y,z=1,xx;
vector<ll>v,v1;
int main()
{
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&m);
        if(m>0)
            v.push_back(m);
        else if(m<0)
            v1.push_back(-m);
        else
            xx++;
        z=(z*m)%mod;
        if(z<0)
            z+=mod;
    }
    m=0;
    if(n==k)
    {
        if(z<0)
            z+=mod;
        printf("%lld\n",z);
        return 0;
    }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    reverse(v.begin(),v.end());
    reverse(v1.begin(),v1.end());
    for(i=0;i<v.size() && i<k;i++)
        {

        }
    j=(k-i)%2;
    if(j==1 && v.size()>0)
     i--;
    x=i;
    y=k-i;
    if(y>v1.size() || (y%2==1 && xx>0))
    {
        printf("0\n");
        return 0;
    }
    if(y%2==1)
    {
        z=1;
        reverse(v1.begin(),v1.end());
        for(i=0;i<y;i++)
            z=(z*(-v1[i]))%mod;
        if(z<0)
            z+=mod;
        printf("%lld\n",z%mod);
        return 0;
    }
    for(i=y;i+1<v1.size() && x>1;i+=2)
    {
        l=v[x-1]*v[x-2];
        z=v1[i+1]*v1[i];
        if(l>=z)
            break;
        x-=2;
    }
    y=i;
    z=1;
    for(i=0;i<x;i++)
        z=(z*v[i])%mod;
    for(i=0;i<y;i++)
        z=(z*v1[i])%mod;
   printf("%lld\n",z);
    return 0;
}



Measured memory_bytes: 5580
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String b1,b2;

		try {
			while (true) {
				b1 = br.readLine();
				b2 = br.readLine();
				if (b1.equals("0")&&b2.equals("0")) break;
				double x = Double.parseDouble(b1);
				double h = Double.parseDouble(b2);
				double S = Math.pow(x,2)+(2*x*Math.sqrt(Math.pow(h,2)+Math.pow((x/2),2)));
				System.out.println(S);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17040
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= H && A[r] > A[largest] ) largest = r;

  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}


Measured memory_bytes: 6600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll smax=-INF, smin=INF, dmax=-INF, dmin=INF;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        smax = max(smax, x+y);
        smin = min(smin, x+y);
        dmax = max(dmax, x-y);
        dmin = min(dmin, x-y);
    }
    cout << max(smax-smin, dmax-dmin) << endl;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>kachi(N);
  vector<int>cost(N);
  for(int i=0;i<N;i++){
    cin >> kachi.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> cost.at(i);
  }
  int answar=0;
  for(int i=0;i<N;i++){
    if(kachi.at(i)>cost.at(i)){
      answar+=kachi.at(i)-cost.at(i);
    }
  }
  cout << answar;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
string s,s1,s2;
string s3="keyence";
int main(){std::ios::sync_with_stdio(false);
cin>>s;
for(int i=0;i<(int)s.size();i++){
	for(int j=i+1;j<(int)s.size();j++){
		s1=s.substr(0,i+1);
		s2=s.substr(j,(int)s.size());
		s1+=s2;
//		cout<<s1<<endl;
		if(s1==s3){
			cout<<"YES"<<endl;
			return 0;
		}
	}
}
cout<<"NO"<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //System.out.print("入力してください > ");
        int    n = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();
        
        if(n % 2 == 1 || n == 0){
            System.out.println("No");
            return;
        }
        String s1 = s.substring(0  , n/2);
        String s2 = s.substring(n/2, n);
        
        if(s1.startsWith(s2)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        
        // Scannerクラスのインスタンスをクローズ
        scanner.close();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,cntW=0,cntR=0,ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++)
		if(s[i]=='W')
			cntW++;
	for(ll i=n-1;i>=n-cntW;i--)
		if(s[i]=='R')
			ans++;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3740
n,m,x,y = map(int,input().split())
xx = list(map(int,input().split()))
yy = list(map(int,input().split()))

z = x+1
check = True
while z <= y and check:
    tempcheck = True

    for i in range(n):
        if xx[i] >= z:
            tempcheck = False
    for i in range(m):
        if yy[i] < z:
            tempcheck = False
    
    if tempcheck:
        print('No War')
        check = False
    z += 1
if check:
    print("War")

Measured memory_bytes: 3064
using System;
using System.Linq;
 
class Program
{
    static void Main()
    {
        var xs = Console.In.ReadToEnd().Trim('\n')
            .Split()
            .Select(n => int.Parse(n))
            .ToArray();
        
        int k = xs[xs.Length - 1];
        int min = xs[0];
        int max = xs[xs.Length - 2];
        
        Console.WriteLine(max - min <= k ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 

inline void init(vector<int>& uf) {
    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {
    if (uf[x] == x) {
        return x;
    } else {
        return uf[x] = root(uf, uf[x]);
    }
}
inline bool same(vector<int>& uf, int x, int y) {
    return root(uf, x) == root(uf, y);
}
inline void unite(vector<int>& uf, int x, int y)
{
    x = root(uf, x);
    y = root(uf, y);
    if (x == y) return;
    uf[x] = y;
}

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

    vector<int> uf(N+M);
    init(uf);
    rep(i, N) {
        int K; cin >> K;
        vi L(K); cin >> L;
        rep(j, K) {
            unite(uf, i, N+L[j]-1);
        }
    }
    int r = root(uf, 0);
    bool f = all_of(uf.begin(), uf.begin()+N, [&](int x) { return root(uf, x)==r; });
    // cout_h(uf);

    cout << (f?"YES":"NO") << endl;
}


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

int main() {
  int N;
  cin >> N;
  int pt = 0, px = 0, py = 0, t, x, y;
  string ans = "Yes";
  for (int i = 0; i < N; i++) {
    cin >> t >> x >> y;
    if ((t + x + y) % 2 or t - pt < abs(x - px) + abs(y - py)) {
      ans = "No";
    }
    pt = t; px = x; py = y;
  }
  cout << ans << endl;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define EPS 1e-12

#define DEBUG_PRINT 1
#define idp if (DEBUG_PRINT)
#define p2(a, b) idp cout << a << "\t" << b << endl
#define p3(a, b, c) idp cout << a << "\t" << b << "\t" << c << endl
#define p4(a, b, c, d) idp cout << a << "\t" << b << "\t" << c << "\t" << d << endl
#define p5(a, b, c, d, e) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << endl
#define p6(a, b, c, d, e, f) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << endl
#define p7(a, b, c, d, e, f, g) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << endl
#define p8(a, b, c, d, e, f, g, h) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << endl
#define p9(a, b, c, d, e, f, g, h, i) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << "\t" << i << endl
#define p10(a, b, c, d, e, f, g, h, i, j) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << "\t" << i << "\t" << j << endl


typedef pair<li, li> PI;

li p[20010];
li a[20010];
li b[20010];
li n;

int main(void)
{
    cin >> n;
    rep(i, n) {
        cin >> p[i];
        p[i]--;
        a[i] = 30000 * i + 1;
        b[i] = 30000 * (n - i) + 1;
    }
    rep(i, n) {
        b[p[i]] += i;
    }

    rep(i, n) {
        cout << a[i];
        if (i < n - 1)cout << " ";
    } cout << endl;
    rep(i, n) {
        cout << b[i];
        if (i < n - 1)cout << " ";
    } cout << endl;


    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
 
int main(void)
{
  char num[100000],risou[100000];
  int a=0,i;
  scanf("%s",num);
  if(num[0]=='1')
    for(i=0;i<100000;i++){
      if(num[i]=='\0')
        break;
      
      if(i%2==0)
        risou[i]='1';
      else
        risou[i]='0';
    }
  else
   for(i=0;i<100000;i++){
      if(num[i]=='\0')
        break;
     
      if(i%2==0)
        risou[i]='0';
      else
        risou[i]='1';
   }
  
for(i=0;i<100000;i++){
  if(num[i]=='\0')
   break;
  if(num[i]!=risou[i])
    a++;
}
  printf("%d",a);
 return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
ll greedy1(int n, vector<int>& x, vector<int>& y) {
    vector<int> I(n);
    iota(I.begin(), I.end(), 0);
    int b1 = *min_element(I.begin(), I.end(), [&](int i, int j) {
        return make_pair(x[i], -y[i]) < make_pair(x[j], -y[j]);
    }), B_min = x[b1], R_min = y[b1];
    int b2 = *min_element(I.begin(), I.end(), [&](int i, int j) {
        return make_pair(y[i], -x[i]) > make_pair(y[j], -x[j]);
    }), B_max = x[b2], R_max = y[b2];
    for(int i : I) {
        if(i != b1 and i != b2) {
            B_max = max(B_max, x[i]);
            R_min = min(R_min, y[i]);
        }
    }
    return ll(R_max - R_min) * (B_max - B_min);
}
ll greedy2(int n, vector<int>& x, vector<int>& y) {
    int R_min = *min_element(x.begin(), x.end()), R_max = *max_element(y.begin(), y.end());
    vector<int> I, perm_B;
    for(int i = 0; i < n; i++) {
        if(x[i] == R_min) perm_B.push_back(y[i]);
        if(y[i] == R_max) perm_B.push_back(x[i]);
        if(x[i] != R_min and y[i] != R_max) {
            I.push_back(i);
        }
    }
    int perm_B_min = *min_element(perm_B.begin(), perm_B.end()), perm_B_max = *max_element(perm_B.begin(), perm_B.end());
    int y_min = lim<int>::max(), y_max = lim<int>::min();
    ll ans = lim<ll>::max();
    sort(I.begin(), I.end(), [&](int i, int j) { return make_pair(x[i], y[i]) < make_pair(x[j], y[j]); });
    for(int i = 0; i < I.size(); i++) {
        int B_min = min({y_min, x[I[i]], perm_B_min});
        int B_max = max({y_max, x[I.back()], perm_B_max});
        ans = min(ans, ll(R_max - R_min) * (B_max - B_min));
        y_min = min(y_min, y[I[i]]), y_max = max(y_max, y[I[i]]);
    }
    ans = min(ans, ll(R_max - R_min) * (max(y_max, perm_B_max) - min(y_min, perm_B_min)));
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if(x[i] > y[i]) {
            swap(x[i], y[i]);
        }
    }
    cout << min(greedy1(n, x, y), greedy2(n, x, y)) << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	vector<long long> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	long long ans = 0;
	for (int i = 1; i < n; i++) {
		if (a * (x[i] - x[i - 1]) - b > 0) {
			ans += b;
		} else {
			ans += a * (x[i] - x[i - 1]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int M = 2e5 + 10;
 
int main() {
	map<int,int>mp;
	ll ans=0;
	int n,p,p1=0,p2=1;
	string s;
	cin>>n>>p;	
	cin>>s;
	if(p==2)
	{
		for(int i=0;i<n;i++){
			if((s[i]-'0')%2==0) ans+=i+1;
		}
		cout<<ans;
		return 0;
	}
	if(p==5)
	{
		for(int i=0;i<n;i++){	
			if((s[i]-'0')%5==0) ans+=i+1;
		}
		cout<<ans;
		return 0;
	}
	mp[0]++;
	for(int i=n-1;i>=0;i--){
		p1=(p1+(s[i]-'0')*p2)%p;
		ans+=mp[p1];
		mp[p1]++;
		p2=(p2*10)%p;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int N, K;
vector<pair<int, int>> ans;

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

  int cnt = (N - 1) * (N - 2) / 2;

  if (cnt < K) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 2; i <= N; i++) {
    ans.push_back({1, i});
  }

  int c = cnt - K;
  for (int i = 2; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (c <= 0) continue;
      ans.push_back({i, j});
      c--;
    }
  }

  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x.first << " " << x.second << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>

using namespace std;

main(){
  char bef,af;
  char Ball = 'A';
  //int n=0;
  while(scanf("%c,%c\n",&bef,&af) != EOF){// \nツづーツ忘ツづェツづ按つ「ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！ツ！
    
    if(Ball == bef)Ball = af;
    else if(Ball == af)Ball = bef;
    //n++;
    // cout << n<<" "<<  Ball << endl<< endl;
  }
  
  cout << Ball << endl;

  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <complex>
#include <assert.h>

using namespace std;

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

static const double EPS = 1e-12;

static const int tx[] = {+0,+1,+0,-1};
static const int ty[] = {-1,+0,+1,+0};

int dp[101][101];

int main(){
  int num_of_tests;
  while(~scanf("%d",&num_of_tests)){
    for(int test_i = 0; test_i < num_of_tests; test_i++){
      int num_of_cards;
      scanf("%d",&num_of_cards);
      vector<int> cards;
      for(int card_i = 0; card_i < num_of_cards; card_i++){
        int card;
        scanf("%d",&card);
        cards.push_back(card);
      }

      memset(dp,0,sizeof(dp));
      for(int len = 1; len <= cards.size(); len++){
        for(int pos = 0; pos < cards.size(); pos++){
          for(int mid = 0; mid < len; mid++){
            dp[pos][len] = max(dp[pos][len],
                               dp[pos][mid]
                               + dp[(pos + mid) % cards.size()][len - mid]
                               + abs(cards[pos] - cards[(pos + mid) % cards.size()]));
          }
        }
      }

      int res = 0;
      for(int pos = 0; pos < cards.size(); pos++){
        res = max(dp[pos][cards.size()],res);
      }
      printf("%d\n",res);
    }
  }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
int dp[100001][2], arr[101], n, k;
int solve(int K, int cur){
    if (K<arr[0])
        return 0;
    if (dp[K][cur]!=-1)
        return dp[K][cur];
    bool ret = false;
    for (int i=0; i<n; i++)
        if (arr[i]<=K){
            if (!solve(K-arr[i], 1-cur)){
                ret = true;
                break;
            }
        }
        else break;
    return dp[K][cur] = ret;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >>n >> k;
    for (int i=0; i<n; i++)
        cin >> arr[i];
    sort(arr, arr+n);
    memset(dp, -1, sizeof(dp));
    cout << (solve(k, 0)? "First\n": "Second\n");
}

Measured memory_bytes: 9056
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//以g为间隔的插入排序
void insertSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;

	}
}

void shellSort(int A[], int n) {
	for (int h = 1;;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int i = G.size() - 1; i >= 0; i--) {
		insertSort(A, n, G[i]);

	}
}

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

	shellSort(A, n);
	cout << G.size() <<endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) printf("%d\n", A[i]);
	return 0;
}


Measured memory_bytes: 7128
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
using namespace std;
#define REP(i,n) for(int i=0;i < n; i++)
#define RREP(i,n) for(int i=n-1;i >=0; i--)
#define p(a) (a) * (a)
#define p2(a,b) p((a) - (b)) 

#define MAX 100002

int main() {
	int x = 0, n,m =0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		m = max(m, x);
	}
	cout << m << endl;
	return 0;
}

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

int main(void) {
    int a[3], b[3];
    int cnt[5] {0, 0, 0, 0, 0};
    int flag = 0;

    for (int i = 0; i < 3; i++) {
        cin >> a[i] >> b[i];
        cnt[a[i]] += 1;
        cnt[b[i]] += 1;
    }

    int max = 0;
    for (int i = 1; i <= 4; i++) {
        if (cnt[i] == 0){
            flag = 1;
        }
        if (max <= cnt[i]) {
            max = cnt[i];
        }
    }
    if (max >= 3)
        flag = 1;

    if (flag == 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256