akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            break;
        }
        long[] id;
        long[] v;
        foreach(i; iota(n)) {
            auto l = readInts();
            id ~= l[0];
            v ~= (int[] p){
                int ans;
                foreach(j; iota(9)) {
                    if(p[0] == 10) {
                        ans += p[0] + p[1] + p[2];
                        p = p[1..$];
                    } else if(p[0] + p[1] == 10) {
                        ans += p[0] + p[1] + p[2];
                        p = p[2..$];
                    } else {
                        ans += p[0] + p[1];
                        p = p[2..$];
                    }
                }
                ans += p.sum(0);
                return ans;
            }(l[1..$]);
        }
        zip(v, id).sort!((a, b) => a[0] > b[0] || a[0] == b[0] && a[1] < b[1]);
        foreach(i; iota(n)) {
            writeln(id[i], " ", v[i]);
        }
    }
}

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

vector<int>v[100005];

int get_sg(int u,int pre){
    int ret=0;
    for(int i=0;i<v[u].size();i++){
        if(v[u][i]!=pre)
            ret^=(1+get_sg(v[u][i],u));
    }
    return ret;
}
int main(){
    int t,n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        v[i].clear();
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    if(get_sg(1,-1))
        puts("Alice");
    else
        puts("Bob");
    return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>
int main(){
    int n,m,c,a,b[1000],ans,count=0,d,i,j;
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&c);

    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        ans=0;
        for(j=0;j<m;j++){
            scanf("%d",&a);
            d=a*b[j];
            ans+=d;
        }
        if((ans+c)>0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

bool isSameAry(VI &a, VI &b) {
    REP(i,0,a.size()) if (a[i] != b[i]) return false;
    return true;
}
bool isSmallAry(VI &a, VI &b) {
    REP(i,0,a.size()) if (a[i] > b[i]) return true;
    return false;    
}

void solve() {
    int n;
    cin >> n;
    VLL a(n), b(n);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) cin >> b[i];
    LL cnt = 0;
    priority_queue<PLL> q;
    REP(i,0,n) q.emplace(b[i],i);
    LL ok = 0;
    LL cont = 0;
    REP(i,0,n) if (a[i] > b[i]) {
        cout << -1 << endl;
        return;
    }
    while (ok < n) {
        auto p = q.top();
        q.pop();
        LL index = p.second, v = p.first;
        LL diff = b[(index-1+n)%n] + b[(index+1)%n];
        LL maxc = max({b[(index-1+n)%n], b[(index+1)%n]});
        //LL times = min((v - maxc) / diff, (v - a[index]) / diff);
        LL times = (v - a[index]) / diff;
        
        if (times == 0) {
            ++cont;
            if (cont == n) {
                cout << -1 << endl;
                return;
            }
        } else {
            cont = 0;
        }
        
        b[index] -= (b[(index-1+n)%n] + b[(index+1)%n]) * times;
        //dump(times);
        //dump(diff);
        //dump(maxc);
        //dump(v - a[index]);
        //dump(v);
        //dump(nextv);
        cnt += times;
        if (b[index] < a[index]) {
            cout << -1 << endl;
            return;
        }
        if (b[index] == a[index]) {
            ++ok;
            continue;
        }
        //REP(i,0,n) cout << b[i] << " ";
        //cout << endl;
        q.emplace(b[index], index);
    }
    REP(i,0,n) if (a[i] != b[i]) {
        cout << -1 << endl;
        return;
    }
    cout << cnt << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 9456
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int poly_bits=18;
const int poly_max=262144;//poly_max=2^poly_bits
const int mod=998244353;//a prime in the form of k*poly_max+1
const int root=3;//a primitive root of mod

int power(int x,int y){int ret=1;do{if(y&1)ret=1ll*ret*x%mod;x=1ll*x*x%mod;}while(y>>=1);return ret;}

void ntt(int a[],int n,int f)
{
	for(int i=0,j=0;i<n;i++)
	{
		if(i<j)swap(a[i],a[j]);
		for(int t=n>>1;(j^=t)<t;t>>=1);
	}
	for(int l=1;l<n;l<<=1)
	{
		int l2=l<<1;
		int wn=power(root,(mod-1)/l2),w;
		if(f==-1)wn=power(wn,mod-2);
		for(int i=0;i<n;i+=l2)
		{
			w=1;
			for(int j=0;j<l;j++)
			{
				int tmp=1ll*a[i+l+j]*w%mod;
				a[i+l+j]=(a[i+j]-tmp+mod)%mod;
				a[i+j]=(a[i+j]+tmp)%mod;
				w=1ll*w*wn%mod;
			}
		}
	}
	if(f==-1)
	{
		int rev=power(n,mod-2);
		for(int i=0;i<n;i++)a[i]=1ll*a[i]*rev%mod;
	}
}

void poly_mult(int a[],int b[],int c[],int n,int m)
{
	static int ta[1<<20],tb[1<<20];
	int l=1;while(l<n+m)l<<=1;
	for(int i=0;i<l;i++)ta[i]=(i<n?a[i]:0),tb[i]=(i<m?b[i]:0);
	ntt(ta,l,1);ntt(tb,l,1);
	for(int i=0;i<l;i++)ta[i]=1ll*ta[i]*tb[i]%mod;
	ntt(ta,l,-1);
	for(int i=0;i<n+m;i++)c[i]=ta[i];
}

int n,m,f[20111],invf[20111],ret[20111],now[20111];
char s[10111],t[10111];
int main()
{
	f[0]=1;invf[0]=1;
	for(int i=1;i<20111;i++)
	{
		f[i]=1ll*i*f[i-1]%mod;
		invf[i]=power(f[i],mod-2);
	}
		
	scanf("%s%s",s+1,t+1);
	for(int i=1;s[i];i++)if(s[i]=='1')
	{
		if(t[i]=='1')m++;
		else n++;
	}
	
	for(int i=0;i<=m;i++)now[i]=invf[i+1];
	ret[0]=1;
	int tmp=n,ans=0;
	while(tmp)
	{
		if(tmp&1)poly_mult(ret,now,ret,m+1,m+1);
		poly_mult(now,now,now,m+1,m+1);
		tmp>>=1;
	}
	for(int i=0;i<=m;i++)ans=(ans+ret[i])%mod;
	ans=1ll*ans*f[n]%mod*f[m]%mod*f[n+m]%mod;
	
	printf("%d\n",ans);
	return 0;
}

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

int even_count(int an)
{
   int count;
  
  count = 0;
  while (an > 0)
  {
    if (an % 2 == 0)
    {
      an /= 2;
      count++;
    }
    else 
      break;
  }
  return (count);
}

int main()
{
  int n;
  int i;
  int an;
  int min;
  
  cin >> n;
  cin >> an;
  min = even_count(an);
  i = 1;
  while (i < n)
  {
    cin >> an;
    if (min >= even_count(an))
      min = even_count(an);
    i++;
  }
  cout << min << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i=0;i<N;i++) cin >> P[i];
    for(int i=0;i<N;i++) cin >> Q[i];
    int a = 0, b = 0;
    vector<int> A(N);
    iota(A.begin(), A.end(), 1);
    int id = 0;
    do {
        bool p = true;
        for(int i=0;i<N;i++) p &= P[i] == A[i];
        if (p) a = id;
        bool q = true;
        for(int i=0;i<N;i++) q &= Q[i] == A[i];
        if(q) b = id;
        id++;
    }while(next_permutation(A.begin(), A.end()));
    cout << abs(a-b) << endl;
}

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

int main()
{
  int n;
  cin>>n;
  
  vector<string> v;
  
  while(n--)
  {
    string s;
    cin>>s;
    v.push_back(s);
  }
  
  unordered_set<string> s;
  int distinct =0;
  for(int i=0;i<v.size();i++)
  {
    if(s.find(v[i])==s.end())
    {
      s.insert(v[i]);
      distinct++;
    }
  }
  cout<<distinct<<endl;
}
  
  




Measured memory_bytes: 23996
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };



int main() {
	int n;
	cin >> n;
	map<int,int> m;
	int p=0,q=0,r=0,s=0,t=0;
	int ans;
	
	for(int i=2;i<n+1;i++){
		int x=i;

		for(int j=2;j*j<n+1;j++){
			while(x%j==0){
				//素因数jの数をカウント
				m[j]++; 
				x /= j;
			}
		}

		//nが小さいときの数え漏れ防止
		if( x!= 1) m[x]++;

	}

	for(int i=2;i<n+1;i++){
		//p^74
		if(m[i]>=74) p++;
		//p^24
		if(m[i]>=24) q++;
		//p^14
		if(m[i]>=14) r++;
		//p^4
		if(m[i]>=4) s++;
		//p^2
		if(m[i]>=2) t++;
	}

	//(p^74の数)+(p^24*q^2の数)+(p^14*q^4の数)+(p^4*q^4*r^2の数)
	//自身を選んだり、(p,q),(q,p)を別のものと数えないようにする
	//((pの数)*(p以外のqの数)*t)/2(pとqを入れ替えたもの重複分)-((pの数)*(p以外のqの数)分p,qからtを選んでしまった分)
	ans = p + (q*t-q) + (r*s-r) + (s*(s-1)*t-2*s*(s-1))/2;
	cout<<ans<<endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func remove(a []int, n int) (b []int) {
	count := 0
	for _, v := range a {
		if v == n && count == 0 {
			count++
		} else {
			b = append(b, v)
		}
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	for i := range x {
		fmt.Scan(&x[i])
	}

	sortedX := make([]int, n)
	copy(sortedX, x)
	sort.Ints(sortedX)
	m1 := sortedX[n/2-1]
	m2 := sortedX[n/2]

	for _, v := range x {
		if v <= m1 {
			fmt.Println(m2)
		} else {
			fmt.Println(m1)
		}
	}
}


Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, K;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
  int a,b;
  cin>>a>>b;
  string str;
  cin>>str;
  if(str[a]!='-')
    {
        cout<<"No";
        return 0;
    }
  for(int i=0;i<str.length();i++)
  {
    if(i!=a)
    if(str[i]<48 || str[i]>57)
    {
        cout<<"No";
        return 0;
    }

  }
  cout<<"Yes";



 return 0;
}








Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    //  cout << x << " ";
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}
int fac[100001];
int inv[100001];
int comb(int a, int b)
{
    if (a < b)
        return 0;
    return ((fac[a] * inv[b]) % mod * inv[a - b] % mod);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;
    while (tc--)
    {
        int a, b,sum=0;
        cin >> a;
        int k = 1;
        while(a!=1){
            a = a / 2;

            int v = pow(2, k);
            sum += v;
            k++;
        }
        sum++;
        cout << sum << endl;
    }

    return 0;
}

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

int main(){
	double n;
	vector<double> v;
	while( cin >> n ){
		v.push_back( n );
	}
	double a = v[0];
	double b = v[0];
	for(int i=0 ; i < v.size() ; i++ ){
		a = max( a , v[i] );
		b = min( b , v[i] );
	}
	cout << (a-b) << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define P pair<int,int>
using namespace std;

P S[100000];
vector<int>r[100000];
int D[100000];
bool used[100001];
int p[100000];
void DFS(int a) {
	for (int b : r[a]) {
		if (D[b] == -1) {
			D[b] = D[a] + 1;
			p[b] = a;
			DFS(b);
		}
	}
}
signed main() {
	int n; cin >> n;
	for (int i = 1; i<n; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		r[x].push_back(y);
		r[y].push_back(x);
	}
	memset(D, -1, sizeof(D));
	used[n] = true;
	p[0] = n;
	D[0] = 0;
	DFS(0);
	for (int i = 0; i < n; i++) {  S[i] = { D[i],i }; }
	sort(S, S + n, greater<P>());
	for (int i = 0; i<n; i++) {
		if (used[S[i].second])continue;
		if (used[p[S[i].second]]) { puts("First"); return 0; }
		used[p[S[i].second]] = true;
	}
	puts("Second");
}

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

typedef long long   ll;
typedef long double ld;

using namespace std;
const ld pi=2*acos(0.0);
ll mod = 998244353;

int main() {
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
 // ios::sync_with_stdio(0);
 // cin.tie(0);
    string s(4,'#');
    for(int i = 0; i < 4; i ++)
        cin >> s[i];
    sort(s.begin(), s.end());
    puts(s == "1479"? "YES":"NO");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

sum_list = []
for i in range(2**n):
    b = '{0:0{1}b}'.format(i, n)

    temp = []
    for j in range(n):
        if b[j] == '1':
            temp.append(A[j])
    sum_list.append(sum(temp))

for k in m:
    print('yes' if k in sum_list else 'no')

Measured memory_bytes: 45124
n=int(input())
d=[int(i) for i in input().split()]
d.sort()
a=1
ans=[]

def dif(lout,lin):
    lo=[i for i in lout]
    li=[i for i in lin]
    if li:
        x=li.pop()
        if x in li:
            li.remove(x)
            lo.append(x)
            lo.append(24-x)
            dif(lo,li)
        else:
            dif(lo+[x],li)
            dif(lo+[24-x],li)
    else:
        pre=0
        rt=24
        lo=sorted(lo)+[24]
        for i in lo:
            rt=min(i-pre,rt)
            pre=i
        ans.append(abs(rt))
        return

for i in range(12+1):
    if d.count(i)>2:
        a=0
if 0 in d:
    a=0
if d.count(12)>=2:
    a=0

if a==0:
    print(0)
else:
    dif([],d)
    print(max(ans))


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

array<ll,100> L;

int main(){
    int N;
    cin >> N;
    L[0] = 2;
    L[1] = 1;

    for(int i=2;i<=N;i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,OO=0x3f3f3f3f;
typedef long long ll;
int arr[100];
int main() {
 int n,m,ans=0,sum=0; cin>>n>>m;
 for(int i=0;i<n;i++)
   cin>>arr[i],sum+=arr[i];
 sum=ceil(sum*1.0/(4*m));
 for(int i=0;i<n;i++)
     if(arr[i]>=sum)
         ans++;
    cout<<((ans>=m)?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const mxn = 5e5+10;
long long dp[mxn], h[mxn],inf =1e16;
int main(){
	int n,k=2;
	cin>>n;
	fill(dp,dp+mxn,inf);
	for (int i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	for (int i =1 ;i<n;i++){
		for (int j =1;j<=k;j++){
			if (i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+ abs(h[i]-h[i-j]) );
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[100005];

int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int h;
    cin >> h;
    v.push_back(h);
  }

  rep(i,100005) dp[i] = (ll)(1e15);
  dp[0] = 0;
  rep(i,N){
    dp[i+1] = min(dp[i+1], dp[i] + abs(v[i+1]-v[i]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(v[i+2]-v[i]));
  }

  cout << dp[N-1] << endl;
  
  return 0;
}


Measured memory_bytes: 1528
#include <cstdio>

using namespace std;
int n,i,j,k,nr,x,y,z,t,p1[604],p2[604],d1[604][604],d2[604][604],r1[604][604],r2[604][604];
long long x1,z1;
char s[604][604];
bool ok;
int main()
{
    scanf ("%d\n", &n);
    for (i=0;i<=(n-1);i++)
        scanf ("%s", &s[i]);
    for (i=n;i<=((2*n)-1);i++)
        for (j=0;j<=(n-1);j++)
            s[i][j]=s[i-n][j];
    for (i=0;i<=((2*n)-1);i++)
        for (j=n;j<=((2*n)-1);j++)
            s[i][j]=s[i][j-n];
    p1[0]=1;
    p2[0]=1;
    for (i=1;i<=((2*n)-1);i++)
    {
        p1[i]=p1[i-1]*29%100003;
        p2[i]=p2[i-1]*31%666013;
    }
    for (i=0;i<=((2*n)-1);i++)
        for (j=0;j<=((2*n)-1);j++)
        {
            if (i==0)
            {
                d1[i][j]=s[i][j]-'a';
                d2[i][j]=s[i][j]-'a';
            }
            else
            {
                d1[i][j]=(d1[i-1][j]+(s[i][j]-'a')*p1[i])%100003;
                d2[i][j]=(d2[i-1][j]+(s[i][j]-'a')*p2[i])%666013;
            }
            if (j==0)
            {
                r1[i][j]=s[i][j]-'a';
                r2[i][j]=s[i][j]-'a';
            }
            else
            {
                r1[i][j]=(r1[i][j-1]+(s[i][j]-'a')*p1[j])%100003;
                r2[i][j]=(r2[i][j-1]+(s[i][j]-'a')*p2[j])%666013;
            }
        }
    nr=0;
    for (i=0;i<=(n-1);i++)
        for (j=0;j<=(n-1);j++)
        {
            ok=true;
            for (k=0;k<=(n-2);k++)
            {
                x=d1[i+n-1][j+k]-d1[i+k][j+k];
                if (x<0)
                    x+=100003;
                y=d2[i+n-1][j+k]-d2[i+k][j+k];
                if (y<0)
                    y+=666013;
                z=r1[i+k][j+n-1]-r1[i+k][j+k];
                if (z<0)
                    z+=100003;
                t=r2[i+k][j+n-1]-r2[i+k][j+k];
                if (t<0)
                    t+=666013;
                if (i<j)
                {
                    x1=(1LL)*x*p1[j-i]%100003;
                    z1=(1LL)*y*p2[j-i]%666013;
                    if ((x1!=z) || (z1!=t))
                    {
                        ok=false;
                        break;
                    }
                }
                else if (i>j)
                {
                    x1=(1LL)*z*p1[i-j]%100003;
                    z1=(1LL)*t*p2[i-j]%666013;
                    if ((x1!=x) || (z1!=y))
                    {
                        ok=false;
                        break;
                    }
                }
                else
                {
                    if ((x!=z) || (y!=t))
                    {
                        ok=false;
                        break;
                    }
                }
            }
            if (ok==true)
                nr++;
        }
    printf ("%d\n", nr);
    return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>

int main(void){
	int n, s[100], i, max, min, maxi, mini, sum, ans;
	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		max = -1;
		min = 1001;
		maxi = 101;
		mini = 101;
		for(i = 0; i < n; i++){
			scanf("%d", &s[i]);
		}
		for(i = 0; i < n; i++){
			if(s[i] > max){
				max = s[i];
				maxi = i;
			}
			if(s[i] < min){
				min = s[i];
				mini = i;
			}
		}
		sum = 0;
		for(i = 0; i < n; i++){
			if(i == mini || i == maxi){
				continue;
			}
			sum += s[i];
		}
		ans = (double)sum / (n - 2);
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long n,m,k;
  long long tmp=0;
  long long i,j;
  long long res=0;
  
  cin>>k;
  if(k%2==0 || k%5==0){
    res=-1;
  }
  else{
    for(i=0;;i++){
      tmp=(tmp*10+7)%k;
      //cout<<tmp<<" "<<tmp%k<<endl;
      if(tmp==0){
        res=i+1;
        break;
      }
    }
  }
  
  
  cout<<res<<endl;
  return 0;
  
}

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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int d[110];
	cin >> N;
	rep(i,N) cin >> d[i];

	int num[110] = {0};
	rep(i,N) num[d[i]]++;

	int res = 0;
	for(int i=1; i<=100; i++){
		if(num[i]) res++;
	}
	cout << res << "\n";

} 



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

#define ll long long int

const int H=1e4+2,N=1e3+4;
ll dp[H][N],n,h;
vector<ll> a,b;

void pre(){
    for(int i=0;i<H;i++){
        for(int j=0;j<N;j++){
            dp[i][j] = -1;
        }
    }
}

ll recur(ll h, ll ind){
    // cout << "recuring on " << h << " and " << ind << " with " << a[ind] << " " << b[ind] << "\n";
    if(h > 0 && ind < 0)
        return 1e10;
    else if(h<=0)
        return 0;
    else if(dp[h][ind] != -1)
        return dp[h][ind];
    
    return dp[h][ind] = min(b[ind]+recur(h-a[ind],ind), recur(h,ind-1));

}
// 9 3
// 8 3
// 4 2
// 2 1
#define pi pair<ll,ll>

void solve(){
    ll n,d,a;
    cin >> n >> d >> a;
    vector<pi> v(n);
    for(auto &it:v)
        cin >> it.first >> it.second;

    sort(v.begin(),v.end());
    map<ll,ll> mp;
    ll ans=0,sum=0;
    for(auto it:v){
        // cout << it.first << " as " << mp[it.first] << '\n';
        // it.second += mp[it.first];
        // sum tells how much is already decreased
        sum += mp[it.first];
        // sum += max(0LL,it.second-sum);
        ans += ceil(max(0LL,it.second-sum)*1.0/a);
        ll val = lower_bound(v.begin(),v.end(),make_pair(it.first+2*d+1,0LL))-v.begin();
        // mp[it.first+2*d+1] -= max(0LL,it.second-sum);
        if(val < n)
            mp[v[val].first] -= a*ceil(max(0LL,it.second-sum)*1.0/a);
        // sum += max(0LL,it.second-sum);
        sum += a*ceil(max(0LL,it.second-sum)*1.0/a);
    }
    cout << ans << '\n';
}

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

    int test=1;
    // cin >> test;
    while(test--)
        solve();
    
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

bool f(string s) {
  int len = s.length();
  if (len==1) return true;
  for (int i=0; i<len/2; i++) {
    if (s[i]!=s[len-i-1]) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  if (n%2==0) {
    cout << no << endl;
    return 0;
  }
  if (!f(s)) {
    cout << no << endl;
    return 0;
  }
  if (!f(s.substr(0, n/2))) {
    cout << no << endl;
    return 0;
  }
  if (!f(s.substr(n/2+1, n/2))) {
    cout << no << endl;
    return 0;
  }
  cout << yes << endl;

  return 0;
}


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

int par[101010];
int diff[101010];

int find(int x) {
    if (par[x] == x) return x;
    int r = find(par[x]);
    diff[x] += diff[par[x]];
    return par[x] = r;
}

int weight(int x) {
    find(x);
    return diff[x];
}

void unite(int x, int y, int w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    par[y] = x;
    diff[y] = w;
}

int main() {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        par[i] = i;
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int x, y, w;
            cin >> x >> y >> w;
            unite(x, y, w);
        } else {
            int x, y;
            cin >> x >> y;
            if (find(x) == find(y)) {
                cout << weight(y) - weight(x) << endl;
            } else {
                cout << "?" << endl;
            }
        }
    }
}


Measured memory_bytes: 3872
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    N,K = map(int,input().split())
    count = [0]*N
    
    for i in range(K):
      d = int(input())
      A = list(map(int,input().split()))

      for s in range(d):
        a = A[s]
        count[a-1] += 1

    print(count.count(0))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}

int p[500010],c[500010];
signed main(){
  int n,m;cin>>n>>m;
  for(int i=0;i<=n;i++){
    if(i==0)p[0]=1,c[0]=1;
    else{
      p[i]=prod(p[i-1],m-n+i);
      c[i]=prod(c[i-1],prod(n+1-i,inv(i)));
      //cout<<p[i]<<" "<<c[i]<<endl;
    }
  }
  int ans=0;
  rep(i,n+1){
    int po=prod(c[i],p[n-i]);
    if(i%2==1)po=(MOD-po)%MOD;
    (ans+=po)%=MOD;
  }
  ans=prod(ans,p[n]);
  cout<<ans<<endl;
    
  return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    cout << (char) (s.front() + 1) << '\n';

    return 0;
}


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

bool iscat(const string& S_) {
    map<string, int> vis;
    function<bool(const string&)> dfs = [&](const string& S) {
        if (S.empty()) return true;
        if (S[0] != 'm' || S.back() != 'w') return false;
        if (vis.count(S)) return vis[S] == 1;
        rep(i, S.size()) if (S[i] == 'e') {
            if (dfs(S.substr(1, i - 1)) &&
                dfs(S.substr(i + 1, S.size() - i - 2))) {
                vis[S] = 1;
                return true;
            }
        }
        vis[S] = 0;
        return false;
    };
    return dfs(S_);
}

int main() {
    string S; cin >> S;
    cout << (iscat(S) ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 7416
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  while (true) {
    ll m, f, r;
    cin >> m >> f >> r;
    if (m == -1 and f == -1 and  r == -1) return;
    if (m == -1 or f == -1) cout << "F" << endl;
    else if (m + f >= 80) cout << "A" << endl;
    else if (m + f >= 65) cout << "B" << endl;
    else if (m + f >= 50) cout << "C" << endl;
    else if (m + f >= 30 and r >= 50) cout << "C" << endl;
    else if (m + f >= 30) cout << "D" << endl;
    else cout << "F" << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, x);
    Cins(int, n, a);
    
    ll ans = 1e18;
    vc<int> amin(n, 2e9);
    For(c, n){
        ll sum = (ll)c*x;
        For(i, n){
            Mini(amin[i], a[(i+n-c)%n]);
            sum += amin[i];
        }
        Mini(ans, sum);
    }
    Cout(ans);
}




Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n;
	long long L;
	cin >> n >> L;
	vector<long long> l(n + 2);
	l[0] = 0; l[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> l[i];
	}
	vector<long long>t(n+ 2, 0);
	for (int i = 1; i <= n; i++) {
		if (l[i] > max(l[i - 1], l[i + 1])) {
			t[i] = L - l[i];
			int ch = i - 2;
			l[i] = 0;
			while (ch >= 0) {
				if (l[ch] < l[ch + 1]) {
					t[ch + 1] = max(t[ch + 2], t[ch]) + L - l[ch + 1];
					l[ch + 1] = 0;
				}
				else {
					ch = -1;
				}
				ch--;
			}
			ch = i + 2;
			while (ch <= n + 1) {
				if (l[ch - 1] > l[ch]) {
					t[ch - 1] = max(t[ch - 2], t[ch]) + L - l[ch - 1];
					l[ch - 1] = 0;
				}
				else {
					ch = n + 2;
				}
				ch++;
			}
		}
	}
	sort(t.begin(), t.end());
	cout << t[n + 1] << endl;
	return 0;
}



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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;

    ll diff_v = v - w;
    ll diff_x = abs(a - b);
    if (diff_v * t >= diff_x) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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


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

int main(){
  int  L,R,d;
  cin >> L >> R >> d;
  cout << R/d-(L-1)/d << endl;
}

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

using namespace std;

void Solve(){
    int x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    vector<int> aa(a), bb(b), cc(c);
    for(int i = 0; i < a; i++) cin>>aa[i];
    for(int i = 0; i < b; i++) cin>>bb[i];
    for(int i = 0; i < c; i++) cin>>cc[i];
    sort(aa.rbegin(), aa.rend());
    sort(bb.rbegin(), bb.rend());
    sort(cc.rbegin(), cc.rend());
    long long res = 0;
    int ia = 0, ib = 0;
    while(ia < x){
        res += aa[ia];
        ia++;
    }
    ia--;
    while(ib < y){
        res += bb[ib];
        ib++;
    }
    ib--;
    int i = 0;
    while(i < c){
        if((ia >= 0 && aa[ia] < cc[i])){
            if(ib >= 0 && bb[ib] < aa[ia]){
                res -= bb[ib];
                res += cc[i];
                ib--;
            }
            else{
                res -= aa[ia];
                res += cc[i];
                ia--;
            }
        }
        else if(ib >= 0 && bb[ib] < cc[i]){
            res -= bb[ib];
            res += cc[i];
            ib--;
        }
        i++;
    }
    cout<<res<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
        Solve();
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int result = 0;
        for (int i = 1; i <= n; i++) {
            String numStr = String.valueOf(i);
            int sum = 0;
            for (int j = 0; j < numStr.length(); j++) {
                sum += Integer.parseInt(String.valueOf(numStr.charAt(j)));
            }

            if (sum >= a && sum <= b) {
                result += i;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 25812
n = int(input())
a = [int(x) for x in input().split()]
ans = sum(a)
ans_li = []
q = int(input())

d = {}
for i in range(len(a)):
    if a[i] not in d:
        d[a[i]] = 0
    d[a[i]] += 1

for i in range(q):
    B,C = map(int,input().split())
    if B not in d:
        ans_li.append(ans)
    else:
        num = d[B]
        dis = abs(B - C)
        if B >= C:
            ans_li.append(ans - (num * dis))
            ans = ans_li[-1]
        else:
            ans_li.append(ans + (num * dis))
            ans = ans_li[-1]

        if C not in d:
            d[C] = num
            d[B] = 0
        else:
            d[C] += num
            d[B] = 0

for aa in ans_li:
    print(aa)


Measured memory_bytes: 21112
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B, C; cin >> A >> B >> C;
  if(A!=B && B==C){
    cout << A << endl;
  }
  if(A==B && B!=C){
    cout << C << endl;
  }
  if(A==C && B!=C){
    cout << B << endl;
  }
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

string s;
string ans = "No";
ll N;
int main(){
	cin >> s;
	N = s.size();
	string t = s;
	reverse(t.begin(), t.end());

	string s1 = s.substr(0, (N-1)/2);
	string t1 = s1;
	reverse(t1.begin(), t1.end());
//	p(t1);

	string s2 = s.substr(N/2+1, (N-1)/2);
	string t2 = s2;
	reverse(t2.begin(), t2.end());
//	p(t2);
	if(s1 == t1 && s2 == t2 && s == t){
		ans = "Yes";
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n; string s; cin>>n>>s;
  int m = s.size();
  ll c[n+5][n+5]; memset(c,0L,sizeof(c));

  c[0][0] = 1;
  reps(i,n){
    rep(j,n+1){
      if(j) c[i][j] += c[i-1][j-1]*2;
      c[i][j] %= MOD;
      c[i][j] += c[i-1][j+1];
      c[i][j] %= MOD;
      if(j==0) c[i][0] += c[i-1][0];
      c[i][j] %= MOD;
    }
  }
  cout << c[n][m]*mpow(mpow(2,m),MOD-2)%MOD << endl;


  return 0;
}


Measured memory_bytes: 195968
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
	  int a = sc.nextInt();
	  int b = sc.nextInt();     
      if(a<=b){
        System.out.println(a);
      }else{
        System.out.println(a-1);
      }
    }
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

template<class Abel> struct UnionFind{
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight;

  UnionFind(int n=1,Abel SUM_UNITY=0){
    init(n,SUM_UNITY);
  }

  void init(int n=1,Abel SUM_UNITY=0){
    par.resize(n);rank.resize(n);diff_weight.resize(n);
    for (int i=0;i<n;++i) par[i]=i,rank[i]=0,diff_weight[i]=SUM_UNITY;
  }

  int root(int x){
    if (par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      diff_weight[x]+=diff_weight[par[x]];
      return par[x]=r;
    }
  }

  Abel weight(int x){
    root(x);
    return diff_weight[x];
  }

  bool issame(int x,int y){
    return root(x)==root(y);
  }

  bool merge(int x,int y,Abel w){
    w+=weight(x);w-=weight(y);
    x=root(x);y=root(y);
    if (x==y) return false;
    if (rank[x]<rank[y]) swap(x,y),w=-w;
    if (rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    diff_weight[y]=w;
    return true;
  }

  Abel diff(int x,int y){
    return weight(y)-weight(x);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind<int> uf(N);
  for (int i=0;i<M;++i){
    int l,r,d;
    cin >> l >> r >> d;
    --l,--r;
    if (uf.issame(l,r)) {
      if (uf.diff(l,r)!=d) {
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      uf.merge(l,r,d);
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }

    int ans=0;
    int m=0;
    rep(i,N){
        if(m<=A[i]){
            m=max(m,A[i]);
            //cout<<m<<" ";
        }else{
            ans+=m-A[i];
            //cout << 
        }
    }
    cout<<ans<<endl;

    



}


Measured memory_bytes: 5212
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod  1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const ll maxn=10000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue
inline char nc()   //快的一批的fread快读
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
    char ch=nc();
    ll sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
bool cmp(ll a,ll b)
{
    return a>b;
}
ll pri[100003];
ll sum1[100003];
int b[maxn];
ll sum;
void so()
{
  for(ll i=2;i<=100003;i++)
  {
      if(!b[i])pri[++sum]=i;
      for(ll j=1;j<=sum;j++)
      {
          if(i*pri[j]>100000)break;
          b[i*pri[j]]=1;
           if(i%pri[j]==0)break;
      }
  }
  cout<<sum<<endl;
}
int main()
{
 int a,b;
 cin>>a>>b;
 for(int i=b-a+1;i<=b;i++)
    cout<<i<<" ";
  if(a!=1)
    for(int i=b+1;i<b+a;i++)
    cout<<i<<" ";
}



Measured memory_bytes: 256