akhauriyash/Code-Regression huggingface dataset:
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int a[1010][1010];
    int ai[1010];
    cin >> n;
    rep(i, n) rep(j, n - 1) cin >> a[i][j];
    rep(i, n) rep(j, n - 1) a[i][j] -= 1;
    rep(i, n) ai[i] = 0;

    int ans = 0;
    bool updated = true;

    while (updated) {
        updated = false;
        bool c[1010];
        memset(c, false, 1010);
        rep(i, n) if (!c[i] && ai[i] < n - 1) {
            int t = a[i][ai[i]];
            if (c[t] || ai[t] >= n - 1) continue;
            if (a[t][ai[t]] == i) {
                ai[t] += 1;
                ai[i] += 1;
                c[t] = true;
                c[i] = true;
                updated = true;
            }
        }
        ans++;
    }

    int completed = true;
    rep(i, n) completed = completed && ai[i] == n - 1;
    if (completed)
        print(ans - 1);
    else
        print(-1);

    return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

int main(int argc, const char *argv[])
{
  int n;

  ll d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> monsters(n);
  for (auto &m : monsters) {
    cin >> m.first >> m.second;
  }

  sort(monsters.begin(), monsters.end());
  ll ans = 0;
  ll c_damage = 0;
  vector<ll> expire(n, 0);
  for (int i = 0; i < monsters.size(); i++) {
    c_damage -= expire[i];
    monsters[i].second = max(monsters[i].second - c_damage, 0ll);

    // どこまでダメージが及ぶか
    auto right_it = upper_bound(monsters.begin(), monsters.end(),
        monsters[i].first + 2 * d,
        [](int r, auto &monster) { return monster.first > r; });
    int right_idx = distance(monsters.begin(), right_it);
    
    // 右まで来たら期限切れ
    ll use_times = (monsters[i].second + a - 1) / a;
    ll damage = use_times * a;
    c_damage += damage;
    ans += use_times;
    if (right_it != monsters.end()) {
      expire[right_idx] += damage;
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		cout << (n + (n * n) + (n * n * n)) << endl;
		// ll arr[n];
		// for (ll i = 0; i < n; i++) cin >> arr[i];

	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int H,W;
    cin>>H>>W;
    vector<string> a(H);
    REP(i,H) cin>>a[i];
    REP(i,W+2) cout<<'#'; cout<<endl;
    REP(i,H) cout<<'#'<<a[i]<<'#'<<endl;
    REP(i,W+2) cout<<'#'; cout<<endl;
    return 0;
}


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

int main(){
    int H, W;
    
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                
                if( (i+j) % 2 ==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
                
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static int N;
    static int D;
    static void input()
    {
        int[] ND = ReadLineParseIntArray();
        N = ND[0];
        D = ND[1];
    }
    static void solve()
    {
        input();
        int ans = N / (2 * D + 1);
        if (N % (2 * D + 1) != 0)
            ans++;

        WriteLine(ans);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13268
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(b>a&&b<c){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































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

#define M (1 << 20)
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch) {
    if(ch == 'A')
        return 1;
    else if(ch == 'C')
        return 2;
    else if(ch == 'G')
        return 3;
    else if(ch == 'T')
        return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]) {
    long long sum = 0, p = 1;
    for(long long i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + key % (M - 1); }

int find(char str[]) {
    long long key, h;
    key = getKey(str);
    for(long long i = 0; i < M; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0)
            return 1;
        else if(strlen(H[h]) == 0)
            return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, h;
    key = getKey(str);
    for(long long i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        ;
        if(strcmp(H[h], str) == 0)
            return 1;
        else if(strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
}

int main() {
    int n, h;
    char str[L], com[9];
    for(int i = 0; i < M; i++) H[i][0] = '\0';

    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 17488
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
x1, x2, x3 = 0, 0, 0
for k, v in c.items():
    if v >= 4:
        if k > x1:
            x1 = k
    if v >= 2:
        if k > x2:
            x2, x3 = k, x2
        elif k > x3:
            x3 = k
print(max(x1*x1, x2*x3))

Measured memory_bytes: 18600
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\n'



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
 //     int t;
 //     cin >> t;
 //     while(t--){




 // }

int n;
cin >> n;
int arr[n];
fo(i,0,n)cin >> arr[i];
sort(arr,arr+n);
int count = 0;
fo(i,0,n){
	fo(j,i+1,n){
		fo(k,j+1,n){
			if(arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k] && arr[i]+arr[j] > arr[k])count++;
		}
	}
}
cout << count << endl;



return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>

int main(){

  int a,b,c,i=0,count=0;
  scanf("%d%d%d",&a,&b,&c);

  for(i=a;i<b+1;++i){
    if(c%i==0) ++count;
  }
  printf("%d\n",count);


  return 0;
}




Measured memory_bytes: 2752
import math

A, B = map(int, input().split())

def gcd(a,b):
	if b == 0:
		return a

	return gcd(b, a%b)


G = gcd(A,B)


def sosuhantei(n):
	d = math.floor(n**(1/2))
	cond = True
	for i in range(2,d+1):
		if n % i == 0:
			cond = False
			break
	return cond 


sosu = []
g = math.ceil(G**(1/2)) 

yaku = []

for i in range(1,g+1):
	if G % i == 0:
		yaku.append(i)
		yaku.append(G//i)

yaku = list(set(yaku))

cnt = 0
for i in range(len(yaku)):
	if sosuhantei(yaku[i]):
		cnt += 1

print(cnt)

Measured memory_bytes: 41308
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 1000007;

int A[MAXN], DPX[MAXN], DPY[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, z, w, ans;
	cin >> n >> z >> w;
	REP(i, n) cin >> A[i];
	ans = abs(w - A[n - 1]);
	if (n > 1) ans = max(ans, abs(A[n - 2] - A[n - 1]));
	cout << ans;
	return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

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

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a[5]={};
    
    rep(i,5){
        int xi;
        cin>>xi;

        if(xi!=0)a[xi-1] = 1;
    }

    rep(i,5){
        if(a[i] == 0)ans = i+1;
    }


    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
  char c[1301];
  int i=0,j;
  while(1){
    scanf("%c",&c[i]);
    if(c[i]=='\n'){
      break;
    }
    i++;
  }
  for(j=0; j<i; j++){
    if(c[j]>='A'&&c[j]<='Z')c[j]+=32;
    else if(c[j]>='a'&&c[j]<='z')c[j]-=32;
    printf("%c",c[j]);
    if(j==i-1)printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
def examB():
    N, M = LI()
    A = [S() for _ in range(N)]
    B = [S() for _ in range(M)]
    loop = N-M+1
    ans = "No"
    for i in range(loop):
        for j in range(loop):
            cur = int(0)
            for k1 in range(M):
                for k2 in range(M):
                    if A[i+k1][j+k2]==B[k1][k2]:
                        cur +=1
            if cur==M**2:
                ans = "Yes"
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> c;
vector<vector<int>> t;
vector<bool> check;

void f(int p) {
	for (int i = 0; i < t[p].size(); i++) {
		if (check[t[p][i]]) {
			continue;
		}
		check[t[p][i]] = true;
		c[t[p][i]] += c[p];
		f(t[p][i]);
	}

}

int main()
{
	int n, q;
	cin >> n >> q;

	c.resize(n + 1);
	t.resize(n + 1);
	check.resize(n + 1);

	for (int i = 0; i < c.size(); i++) {
		c[i] = 0;
		check[i] = false;
	}

	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		t[a].push_back(b);
		t[b].push_back(a);
	}

	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		c[p] += x;
	}

	check[1] = true;
	f(1);

	for (int i = 1; i < n + 1; i++) {
		if (i != 1) {
			cout << " ";
		}
		cout << c[i];
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int n,m;
cin>>n>>m;
 
vector<int>vc;
int sum=0;
for (int i = 0; i < n; ++i)
{
 
int a;
cin>>a;
vc.push_back(a);
sum+=a;
}
 
int ct=0;
for (int i = 0; i < n; ++i)
{
 
if(vc[i]*4*m>=sum)
{
	ct++;
}
	/* code */
}
 
if(ct>=m)
{
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}
 
 
 
 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    string s;
    cin >> n >> s;
    n = n%26;
    REP(i,s.length()){
        s[i] += n;
        if(s[i] > 90)
        s[i]-=26;
    }
    cout << s << endl;
    return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;

const int maxn = 15;
int n, m;
int dist[maxn][maxn];
int dp[1<<maxn][maxn];

int dfs(int s, int v){

    if(dp[s][v] >= 0){
        return dp[s][v];
    }

    if(s == (1<<n)-1 && v == 0){
        return dp[s][v] = 0;
    }

    int ans = inf;
    rep(u,0,n){
        if(!(s >> u & 1)){
            ans = min(ans, dfs(s | 1 << u, u) + dist[v][u]);
        }
    }

    dp[s][v] = ans;
    return ans;


}

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

    
    cin >> n >> m;

    memset(dp,-1,sizeof(dp));
    fill(dist[0],dist[0]+maxn*maxn,inf);

    

    
    rep(i,0,m){
        int f, t, c;
        cin >> f >> t >> c;
        dist[f][t] = c;
    }
    int ans = dfs(0,0);
    cout << (ans == inf ? -1 : ans) << endl;

}


Measured memory_bytes: 7052
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int n,m,q;
vector<vector<int>> a;
int ans = 0;


void dfs(vector<int> t){
    if(t.size()==n+1){
        int x = 0;
        rep(i,0,a.size()){
            int y = t[a[i][1]] - t[a[i][0]];
            if(y==a[i][2]){
                x += a[i][3];
            }
        }
        chmax(ans,x);
        return;
    }
    t.push_back(t.back());
    while(t.back()<=m){
        dfs(t);
        t[t.size()-1]++;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> n >> m >> q;
    a.resize(q);
    rep(i,0,q){
        a[i].resize(4);
        rep(j,0,4){
            cin >> a[i][j];
        }
    }
    vector<int> x = {1};
    dfs(x);
    cout << ans << endl;
}

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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)


/*A-Calc*/
void Solve()
{
	int a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a)<<"\n";
}

int main()
{
	fast
	Solve();
	return 0;
}

Measured memory_bytes: 3684
#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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,k;
vector<int> d;

void input(){
    cin >> n >> k;
    d.resize(k);
    for(int i=0;i<k;i++) cin >> d[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<int> num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector<int> canuse;
    set_difference(num.begin(), num.end(), d.begin(), d.end(), back_inserter(canuse));
    sort(canuse.begin(), canuse.end());
    // for(auto e:canuse) cout << e << endl;
    string ans = "a";
    for(int i=n;i<=10*n;i++){
        string tmp = to_string(i);
        int cnt = 0;
        for(auto s:tmp){
            for(auto e:canuse){
                if(int(s-'0') == e){
                    cnt++;
                    break;
                }
            }
        }
        if(cnt == tmp.size()){
            ans = tmp;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read() 	        freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n) 	        scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n) 	        scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%ull",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps 	        1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod 1000000007
#define var    int i,j,k,n,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int main()
{
    ll var;
    sfl(n);sfl(m);sfl(k);sfl(x);
    z=abs(n-m);
    if(x%2==0)
    {
        if(n>=m && z<=1000000000000000000LL)
        {
            cout<<z<<endl;
        }
        else if(n<m && z<=1000000000000000000LL)
        {
            cout<<-z<<endl;
        }
        else cout<<"Unfair"<<endl;
    }
    else
    {
        if(n>=m && z<=1000000000000000000LL)
        {
            cout<<-z<<endl;
        }
        else if(n<m && z<=1000000000000000000LL)
        {
            cout<<z<<endl;
        }
        else cout<<"Unfair"<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll L[90];

int main(){

	int N;

	scanf("%d",&N);

	L[0]=2ll;
	L[1]=1ll;

	int i;

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

	printf("%lld\n",L[N]);

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 400200;
int dp[maxn], arr[maxn], cnt[maxn];
int M(){
    int n, m;
    if(!~scanf("%d %d", &n, &m)) return 0;
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    for(int e = 0; e < n; e++) scanf("%d", arr + e);
    for(int e = 0; e < n; e++) cnt[arr[e]]++;
    for(int e = 1; e <= n; e++){
        dp[e - cnt[e] + 1 + maxn/2]++;
        dp[e + 1 + maxn/2] --;
    }
    for(int e = 1; e < maxn; e++)
        dp[e] += dp[e-1];
    int ans = 0;
    for(int e = maxn/2 + 1; e <= maxn/2 + n; e++)
        ans += dp[e] == 0;
    // printf("init %d\n", ans);
    for(int e = 0; e < m; e++){
        int from, to;
        scanf("%d %d", &from, &to);
        from--;
        if(dp[arr[from] - cnt[arr[from]] + 1 + maxn/2] == 1 &&
            arr[from] - cnt[arr[from]] >= 0) ans++;
        dp[arr[from] - cnt[arr[from]] + 1 + maxn/2]--;
        cnt[arr[from]]--;
        // printf("%d\n", ans);
        arr[from] = to;
        cnt[arr[from]]++;
        if(dp[arr[from] - cnt[arr[from]] + 1 + maxn/2] == 0 &&
            arr[from] - cnt[arr[from]] >= 0) ans--;
        dp[arr[from] - cnt[arr[from]] + 1 + maxn/2]++;
        printf("%d\n", ans);
    }
    // printf("end\n");
    return 1;
}
int main(){
    while(M());
    return 0;
}


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

int main() {
    while (true) {
        int t;
        cin >> t;
        if (t == 0) break;

        int n;
        cin >> n;
        int sum = 0;
        rep(i, n) {
            int s, f;
            cin >> s >> f;
            sum += f-s;
        }
        if (t <= sum) cout << "OK" << endl;
        else cout << t-sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3028
#include <stdio.h>

int main(void){
  int x[5], i;
  scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
  for(i=0; i<5; i++){
    if(x[i]==0){
      printf("%d", i+1);
    }
  }
  return 0;
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n;cin>>n;
  string s;cin>>s;
  if(n%2 !=0)
  {
    cout<<"No\n"; return 0;
  }
  else 
  {
    int  j=s.size()/2;
    int i=0;
    while(j<s.size())
    {
      if(s[i]!=s[j]) break;
      i++;j++;
    }
    if(i==s.size()/2) cout<<"Yes";
    else cout<<"No";
  }
return 0;
}

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

long long a = 0; 
int main() {
	cin >> a;
	long long ans = 1e18; 
	for (long long i = 1; i*i <= a; i++)
		if (a%i == 0) {
			long long t = a/i;
			ans = min(ans, i+t-2);
		}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define MAXN 100000

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int x[MAXN];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  ll ans = 0;
  for (int i = 0; i < n-1; i++) {
    ll walk = 1LL * (x[i+1] - x[i]) * a;
    ans += (walk < b ? walk : b);
  }
  cout << ans << endl;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans;
  
  if (n * a == b) ans = b;
  else if (n * a > b) ans = b;
  else if (n * a < b) ans = n * a;
  else {
   return 0; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key){
  int i = 0;
  A[n] = key;

  while (A[i] != key) i++;

  return i != n;
}

int main(){
  int n, q, i, key, A[10000+1], sum = 0;

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

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }

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

  return 0;
}



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

#define inf 99999999
typedef pair<int,int> pii ;

int h ,w ,n ,minute ;
char maze[1000][1000] ;
queue<pii> q ;
int data[1000][1000] ;

int bfs( int N )
{
    int y[4] = { -1, 0, 1,  0 } ;
    int x[4] = {  0, 1, 0, -1 } ;
    pii Pcmp ;
    int PcmpY = 0 ;
    int PcmpX = 0 ;

    for ( int i = 0 ; i < h ; i++ )
    {
        for ( int j = 0 ; j < w ; j++ )
        {
            if ( ( N == 0 && maze[i][j] == 'S' ) || ( N != 0 && maze[i][j] == '0'+N ) )
            {
                data[i][j] = 0 ;
                q.push( pii(i,j) ) ;
            }
            else data[i][j] = inf ;
        }
    }

    while ( q.size() )
    {
        Pcmp = q.front() ;
        q.pop() ;
        if ( maze[Pcmp.first][Pcmp.second] == '0'+N+1 ) break ;

        for ( int i = 0 ; i < 4 ; i++ )
        {
            PcmpY = Pcmp.first + y[i] ;
            PcmpX = Pcmp.second + x[i] ;
            if ( PcmpY >= 0 && PcmpY <= h-1 && PcmpX >= 0 && PcmpX <= w-1 )
            {
                if ( maze[PcmpY][PcmpX] != 'X' && data[PcmpY][PcmpX] == inf )
                {
                    q.push( pii( PcmpY,PcmpX ) ) ;
                    data[PcmpY][PcmpX] = data[Pcmp.first][Pcmp.second] + 1 ;
                }
            }
        }
        /* [debug]
        for ( int i = 0 ; i < h ; i++ )
        {
            printf("[debug]%3d:",i);
            for ( int j = 0 ; j < w ; j++ )
            {
                printf("%8d,",data[i][j]);
            }
            printf("\n");
        }
        printf("\n");
        */
    }

    while ( q.size() ) q.pop() ;
    return data[Pcmp.first][Pcmp.second] ;
}

int main()
{
    cin >> h >> w >> n ;
    for ( int i = 0 ; i < h ; i++ )
    {
        cin >> maze[i] ;
    }
    for ( int i = 0 ; i < n ; i++ )
    {
        minute += bfs(i) ;
    }
    printf("%d\n",minute) ;
    return 0 ;
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;

//positionbit目が立っているか判定
bool contain(int mask, int position){ //数字maskのi番目にフラグが立ってるか
    if((mask & (1 << position)) != 0) return true;
    else return false;
}

int main(){
   //全部調べて、足す
   //全部の記録配列を作る
  string s; cin>>s;
  int n=s.size()-1;
  ll sum=0;

    for(int mask = 0; mask < (1 << n); ++mask){// (1 << n)はn=3で00001000=8
    //つまり0000,0001,0010,0011,...0111までをモウラできる
   //これで文字の間に＋を入れる入れ方をモウラできる
   
    int l = 0;//左端
        ll tmp = 0;
        int r;//右端
        for (r = 0; r < n; ++r){ //右端が動くときの
            if(contain(mask, r)){//maskのr番目がフラグ立ってるなら,そこが仕切り
                string t = s.substr(l, r - l + 1); //そこまでの文字列を抜き出す
                 tmp += stoll(t);
                l = r + 1; //仕切りの右から文字列をよみとる
            }
         }//最後の＋の左までの和は加えた
        
        string t = s.substr(l, r - l + 1);//右端の数字を加える
        tmp += stoll(t);
        sum += tmp;
     // cout<<"tmp="<<tmp<<" sum="<<sum<<endl;//sumが総和、tmpが今回の数式の答え
  }

  cout<<sum<<endl;
} 

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

using LL = long long;

const int MAXN = 1e5 + 5;

std::priority_queue<int, std::vector<int>, std::greater<int>> weights[MAXN], heap;

int fa[MAXN];

int Find(int x) {
	return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

int main() {
	int n, m;
	
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		static int a;
		scanf("%d", &a);
		
		weights[i].push(a);
		fa[i] = i;
	}
	
	for (int i = 1; i <= m; ++i) {
		static int u, v;
		scanf("%d%d", &u, &v);
		++u; ++v;
		
		u = Find(u); v = Find(v);
		
		if (u != v) {
			if (weights[u].size() < weights[v].size()) {
				while (!weights[u].empty()) {
					weights[v].push(weights[u].top()); weights[u].pop();
				}
				fa[u] = v;
			} else {
				while (!weights[v].empty()) {
					weights[u].push(weights[v].top()); weights[v].pop();
				}
				fa[v] = u;
			}
		}
	}
	
	if (m == n - 1) {
		puts("0"); exit(0);
	}
	
	LL ans = 0;
	int part = 0;
	
	for (int i = 1; i <= n; ++i) if (Find(i) == i) {
		++part;
		
		ans += weights[i].top(); weights[i].pop();
		
		while (!weights[i].empty()) {
			heap.push(weights[i].top()); weights[i].pop();
		}
	}
	
	if ((part - 1) * 2 > n) {
		puts("Impossible"); exit(0);
	}
	
	for (int i = 1; i <= (part - 1) * 2 - part; ++i) {
		ans += heap.top(); heap.pop();
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
    
  sort(A.begin(),A.end());
  cout << A.at(N - 1) - A.at(0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i, k, m, n = 0;
    int h[100], w[100];
    while(1) {
        scanf("%d %d", &h[n], &w[n]);
        if(h[n] == 0 && w[n] == 0) break;
        n++;
    }
    for(i = 0; i < n; i++) {
        for(k = 0; k < h[i]; k++) {
            for(m = 0; m < w[i]; m++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main(void){
    vector<string> po;
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        string unko;
        cin >> unko;
        po.push_back(unko);
        for(int j=0;j<i;j++)if(po[i]==po[j]){printf("No");return 0;}
        if(i!=0&&po[i-1][po[i-1].size()-1]!=po[i][0]){printf("No");return 0;}
    }
    printf("Yes");
    
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
h = list(map(int, readline().split()))
ab = [list(map(int, readline().split())) for _ in range(m)]
memo = [True] * n
for a, b in ab:
    if h[a - 1] > h[b - 1]:
        memo[b - 1] = False
    elif h[a - 1] < h[b - 1]:
        memo[a - 1] = False
    else:
        memo[a - 1] = False
        memo[b - 1] = False
print(memo.count(True))


Measured memory_bytes: 90084
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
long long a[300000];
void dfs(int x,int y,long long num,int last)
{
	if (x>y) {if (num<=3234566667) a[++cnt]=num;return;}
	for (int i=last-1;i<=last+1;++i)
	 if (i<=9&&i>=0)
	 dfs(x+1,y,num*10+i,i);
}
int main()
{
	 int n;
	for (int i=1;i<=10;++i) 
	 {
	  for (int j=1;j<=9;++j)
	  dfs(2,i,j,j);
     }
    sort(a+1,a+1+cnt);
    cin>>n;
    cout<<a[n];
}

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

int main(){
	int N;
	cin >> N;
	vector<char> c(N, 0);
	int countR = 0, countW = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> c[i];
		if (c[i] == 'R') countR++;
		else countW++;
	}

	int ans_all_red = countW;
	int ans_all_white = countR;
	int ans_all_arrange = 0;
	
	for (int i = 0; i < countR; i++)
	{
		if (c[i] == 'W')
		{
			ans_all_arrange++;
		}
	}
	
	int ans = min(ans_all_red, ans_all_white);
	ans = min(ans, ans_all_arrange);
	cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define MAX INT_MAX
#define MIN INT_MIN
#define ss second
#define ff first
const int mod = 1e9+7;
//map<int, int> m;
int minm(vector<int> &wt, vector<int> &val, int w, int item){
	int sum = 0;
	int n = wt.size();
	for(auto i:val)
		sum += i;

	vector<int> dp(sum+1, MAX);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = sum; j >= val[i]; j--){
			dp[j] = min(dp[j], dp[j-val[i]] + wt[i]);
		}
	}
	int ans = 0;
	for(int i = sum; i >= 0; i--){
		if(dp[i] <= w)
			ans = max(ans, i);
	}
	return ans;
}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for(int i = 0; i < n; i++)
		cin >> weight[i] >> value[i];
	cout << minm(weight, value, w, 0) << endl;
	return 0;
}


Measured memory_bytes: 1024
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

set<ll> st[M];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(ll i=0; i<n; i++){
        st[s[i]-'a'].insert(i);
    }
    ll q;
    cin >> q;
    ll ans=0;
    while (q--){
        ll x;
        cin >> x;
        if(x==1){
            ll y;
            cin >> y;
            y--;
            char ch;
            cin >> ch;
            st[s[y]-'a'].erase(y);
            s[y]=ch;
            st[s[y]-'a'].insert(y);
        }
        else{
            ll ans=0;
            ll l,r;
            cin >> l >> r;
            l--;r--;
            for(ll i=0; i<26; i++){
                auto it=st[i].lower_bound(l);
                if(it==st[i].end()) continue;
                ll x=*it;
                if(x<=r) ans++;
            }
            cout << ans <<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 33692
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

void solve() {
	int N, K; cin >> N >> K;
	K = min(N-1, K);
	COMinit();
	ll ans = 0;
	if (K > 1)ans++;
	FOR(k, 1, K+1) {
		ll res = COM(N, k);
		ll m = N - k;
		ll tmp = mult(fac[k + m - 1], finv[k]);
		tmp = mult(tmp, finv[m - 1]);
		res = mult(res, tmp);
		ans = add(ans, res);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, x;
    cin >> n >> x;
    long ans = 0;
    long a, b;
    cin >> a;
    if (a > x) {
        ans += (a - x);
        a = a - (a - x);
    }
    REP(i,n-1) {
        cin >> b;
        if (a + b > x) {
            ans += (a + b - x);
            a = b - (a + b - x);
        } else {
            a = b;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#line 1 "C.cpp"
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

#line 1 "~/git/library/utility/literals.cpp"



/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#include <cstddef>
#line 11 "~/git/library/utility/literals.cpp"

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }


#line 1 "~/git/library/utility/make/vector.cpp"
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */

#ifndef H_make_vector
#define H_make_vector

#line 10 "~/git/library/utility/make/vector.cpp"
#include <type_traits>
#line 12 "~/git/library/utility/make/vector.cpp"

namespace detail {
  template <typename Tp, size_t Nb>
  auto make_vector(std::vector<size_t>& sizes, Tp const& x) {
    if constexpr (Nb == 1) {
      return std::vector(sizes[0], x);
    } else {
      size_t size = sizes[Nb-1];
      sizes.pop_back();
      return std::vector(size, make_vector<Tp, Nb-1>(sizes, x));
    }
  }
}  // detail::

template <typename Tp, size_t Nb>
auto make_vector(size_t const(&sizes)[Nb], Tp const& x = Tp()) {
  std::vector<size_t> s(Nb);
  for (size_t i = 0; i < Nb; ++i) s[i] = sizes[Nb-i-1];
  return detail::make_vector<Tp, Nb>(s, x);
}

#endif  /* !defined(H_make_vector) */
#line 9 "C.cpp"

int main() {
  size_t n, m;
  int x;
  scanf("%zu %zu %d", &n, &m, &x);

  std::vector<int> c(n);
  auto a = make_vector<int>({n, m});
  for (size_t i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    for (size_t j = 0; j < m; ++j)
      scanf("%d", &a[i][j]);
  }

  int const inf = 1e9;
  int res = inf;
  for (size_t i = 0; i < (1_zu << n); ++i) {
    std::vector<int> b(m, 0);
    int cost = 0;
    for (size_t j = 0; j < n; ++j) {
      if (~i >> j & 1) continue;
      for (size_t k = 0; k < m; ++k) {
        b[k] += a[j][k];
      }
      cost += c[j];
    }
    bool ok = true;
    for (size_t j = 0; j < m; ++j)
      ok &= (b[j] >= x);

    if (ok) res = std::min(res, cost);
  }

  if (res == inf) return puts("-1"), 0;
  printf("%d\n", res);
}


Measured memory_bytes: 3232
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  cin>>n;
  ll ans=n;
  if(n%111)ans=n+111-n%111;
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256