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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int n;cin>>n;
 	vector<int>L(n+1),R(n+1);
 	rep(i,1,n+1){
 		cin>>L[i]>>R[i];
 	}
 	set<pair<pii,int>>st1,st2;
 	rep3(n+1){
 		st1.insert({{L[i],R[i]},i});
 		st2.insert({{R[i],L[i]},i});
 	}
 	int ans=0;
 	int t=0;
 	while(st1.size()>1 && st2.size()>1){
 		auto itr=st1.rbegin();
 		t+=2*itr->x.x;
 		st2.erase({{itr->x.y,itr->x.x},itr->y});
 		st1.erase({{itr->x.x,itr->x.y},itr->y});
 		auto itr2=st2.begin();
 		t-=2*itr2->x.x;
 		st1.erase({{itr2->x.y,itr2->x.x},itr2->y});
 		st2.erase({{itr2->x.x,itr2->x.y},itr2->y});
 		maxs(ans,t);
 	}
 	cout<<ans<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 17168
//arc_097_c.cpp
//Wed Jun  6 21:48:14 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	string s;
	int k;
	cin >> s >> k;

	int slength = s.length();
	string substrings[25000];
	int num = 0;

	for (int i=0;i<slength;i++){
		int subnum = 0;
		if (slength-i>=5){
			subnum = 5;
		}else {
			subnum = slength-i;
		}

		for (int j=1;j<=subnum;j++){
			substrings[num] = s.substr(i,j);
			num++;
		}
	}

	sort (substrings,substrings+num);
	string prevstring = "1";

	for (int i=0;i<num+1;i++){
		if (prevstring != ""){
			if (prevstring == "1" || prevstring != substrings[i]){
				k--;
				if (k==0){
					cout << substrings[i] << endl;
					break;
				}
				prevstring = substrings[i];
			}
		}
	}


}

Measured memory_bytes: 1664
import java.util.*;
import java.io.*;

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static int nextInt() throws IOException {
		return Integer.parseInt(br.readLine());
	}

	public static int[] nextArr() throws IOException {
		String elements[] = br.readLine().split(" ");
		int arr[] = new int[elements.length];
		for (int j = 0; j < elements.length; j++)
			arr[j] = Integer.parseInt(elements[j]);
		return arr;
	}

	public static void printArr(int arr[]) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr);
	}

	public static String next() throws IOException {
		return br.readLine();
	}

	public static void main(String[] args) throws IOException {

		
			String line = next();
			if (line.charAt(2) == line.charAt(3) && line.charAt(4) == line.charAt(5))
				System.out.println("Yes");
			else
				System.out.println("No");

		
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <math.h>
#include <string> 
#include <cstdlib>/*絶対値取得*/
using namespace std;
#define MAX 200000

int main(){
    bool a[26];
    char s[101010];
    cin>>s;
    for(int i=0;i<26;++i){
        a[i]=false;
    }
    for(int i=0;s[i]!='\0';++i){
        a[s[i]-'a']=true;
    }
    for(int i=0;i<26;++i){
        if(!a[i]){
            cout<<char(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int flg = 0;
  for(int i=0;i<S.size();i++){
    if((i+1)%2==0 && S[i]=='R'){
      cout << "No" << endl;
      flg=1;
      break;
    }else if((i+1)%2==1 && S[i]=='L'){
      cout << "No" << endl;
      flg = 1;
      break;
    }else{
    }
  }
  if(flg==0){
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 00:09 on 2020-06-21.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    vl sa(a);
    sort(all(sa));
    map<ll, ll> mp;
    rep(i, n) mp[sa[i]] = i;
    ll cnt = 0;
    rep(i, n) {
        if (i % 2 != mp[a[i]] % 2) cnt++;
    }
    cout << (cnt + 2 - 1) / 2 << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 11172
r, c = map(int, input().split())

matrix = [[0 for i in range(c + 1)] for j in range(r + 1)]

for i in range(r):
    lis = list(map(int, input().split()))
    for j in range(c):
        matrix[i][j] = lis[j]

for i in range(r):
    sum = 0
    for j in range(c):
        sum += matrix[i][j]
    matrix[i][c] = sum

for i in range(c + 1):
    sum = 0
    for j in range(r):
        sum += matrix[j][i]
    matrix[r][i] = sum

for i in range(r + 1):
    for j in range(c + 1):
        if j != c:
            print("%d " % (matrix[i][j]), end="")
        else:
            print("%d" % (matrix[i][j]), end="")
    print()



Measured memory_bytes: 6300
#include <stdio.h>

int main(){
    char op;
    int a, b;
    
    while(scanf("%d %c %d", &a, &op, &b), op != '?'){
        
        switch(op){
        case '+':
            printf("%d\n", a + b);
            break;
        
        case '-':
            printf("%d\n", a - b);
            break;
        
        case '*':
            printf("%d\n", a * b);
            break;
        
        case '/':
            printf("%d\n", a / b);
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
using namespace std;
#define x1 a.first
#define y1 a.second
#define x2 b.first
#define y2 b.second
#define x3 c.first
#define y3 c.second
int main(int argc, char const *argv[])
{
	pair<int,int> a,b;
	cin>>a.first>>a.second>>b.first>>b.second;
	int tx = x2-x1 ;
	int ty = y2-y1;
	pair<int,int> c;
	c.first = x2 - ty;
	c.second = tx + y2;

	pair<int,int> d;
	d.first = x1-ty;
	d.second = tx+y1;
	printf("%d %d %d %d\n",x3,y3,d.first,d.second);
	return 0;
}

Measured memory_bytes: 256
/*
https://drken1215.hatenablog.com/entry/2020/01/12/135000
勉強させていただいた記事
*/


#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
        A[i]/=2;
    }
    while(A[0]%2==0){
        rep(i,N){
            if(A[i]%2!=0){
                cout<<0<<endl;
                return 0;
            }
            A[i]/=2;
        }
        M/=2;
    }
    rep(i,N)if(A[i]%2==0){
        cout<<0<<endl;
        return 0;
    }
    ll lcm=1;
    rep(i,N){
        lcm=LCM(lcm,A[i]);
        if(lcm>M){
            cout<<0<<endl;
            return 0;
        }
    }
    //M/lcmでLの個数を求め、それを2で割ることで奇数を取り出している
    cout<<(M/lcm+1)/2<<endl;

    return 0;
}

//a=97,z=122

/*
小数が含まれてる時は、消すことを考えよう
a[k]%2==1の場合、Xは正の整数なので、条件を見たさず0
*/

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


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	
	int n;

	cin >> n;

	int temp = n/1.08;
	int ans = 0;
	rep(i, -1, 2) {
		int t = ((temp + i) * 1.08);
		if (t == n) {
			ans = temp + i;
			break;
		}
	}

	if (ans == 0) {
		cout << ":(" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> check(N,0);
    for(ll i=0;i<K;i++){
        ll d;
        cin>>d;
        for(ll j=0;j<d;j++){
            ll t;
            cin>>t;t--;
            check[t]=1;
        ;}
    ;}
    ll ans=0;
    for(ll i=0;i<N;i++){
        if(!check[i])ans++;
    ;}cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3632
function Main(input) {
	var str = input;
	var ans = 0;
	var str = str.split("\n")[0];
	var num = str.split(" ");
	var a = Number(num[0]);	
	var b = Number(num[1]);	
	var h = Number(num[2]);
	var m = Number(num[3]);
	
	var dega = 0.5*(m+60*h);
	var degb = 6*m;
	var rada = dega * (Math.PI / 180);
	var radb = degb * (Math.PI / 180);
	
	var ax = a*Math.sin(rada);
	var ay = a*Math.cos(rada);
	var bx = b*Math.sin(radb);
	var by = b*Math.cos(radb);
	
	ans = Math.sqrt((ax-bx)*(ax-bx)+ (ay-by)*(ay-by));
	ans = Math.round(ans*(10**10))/(10**10);
	console.log(ans);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(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 sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int check(int a){
    int l=-1000;
    int h=1000;
    while(l<=h){
        int mid=(l+h)/2;
        int x=pow(mid,5);
        if(x==a){
            return mid;
        }
        else if(x>a){
            h=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    return inf;
}

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int x;
        cin >> x;
        for(int i=-1000; i<=1000; i++){
            int b=pow(i,5);
            int a=x+b;
            if(check(a)!=inf){
                cout << check(a) << ' ' << i << '\n';
                return 0; 
            }
        }
        

}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll ans = 0;
	int a[5], maxx = 0;
	for (int i = 0; i < 5; ++i) {
		int x;
		cin >> x;
		ans += x;
		if (x % 10 != 0) {
			ans += (10 -  x % 10 );
			maxx = max(maxx, (10 -  x % 10 ));
		}
	}
	cout << ans - maxx << "\n";
}



Measured memory_bytes: 256
from math import sqrt
n, d = map(int, input().split())
point = [[int(i) for i in input().split()] for j in range(n)]
count = 0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for pi, pj in zip(point[i], point[j]):
            norm += (pi - pj) ** 2
        if int(sqrt(norm)) == sqrt(norm):
            count += 1

print(count)

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


int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int ii=A; ii<=min(B, A+K-1); ii++){
    cout << ii << endl;
  }
  for(int ii=max(B-K+1, min(B, A+K-1)+1); ii<=B; ii++){
    cout << ii << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
int main() {
    int n;
    scanf("%d",&n);
    int sum=0;
    int minn=INF;
    bool flag=false;
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d",&x);
        sum+=x;
        if(x%10!=0){
            flag=true;
            minn=min(minn,x);
        }
    }
 
    if(!flag)
        printf("0\n");
    else{
        if(sum%10!=0)
            printf("%d\n",sum);
        else
            printf("%d\n",sum-minn);
    }
 
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
using namespace std;
int main(){
  string S;
  int ans=0;
  cin >> S;
  for(int i=1; i<S.length(); i++){
    if(S[i-1] == S[i]){
      ans++;
      if(S[i] == '0') S[i] = '1';
      else S[i] = '0';
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const long long MOD = 1e9 + 7;


#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)


#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define MAX                     1e9 + 9

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


int main()
{
    taratari

    string a;
    cin >> a;

    int x=0;
    int y=0;

    for(int i=0;i<a.size();i++)
    {
        if(i%2==0 && a[i]=='0')
        {
            x++;
        }
        if(i%2==1 && a[i]=='1')
        {
            x++;
        }
        if(i%2==0 && a[i]=='1')
        {
            y++;
        }
        if(i%2==1 && a[i]=='0')
        {
            y++;
        }

    }


    cout << min(x,y);

    return 0;

}



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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// dp[i][j]: キーをi回押してj文字の(何らかの)文字列を作る方法の数
// これを2^mで割ればsを作る方法の数になる

int n, m, dp[5050][5050];
string s;

signed main() {
	cin >> n >> s;
	m = s.size();
	dp[0][0] = 1;
	rep(i,n) rept(j,n) {
		(dp[i+1][j+1] += dp[i][j]*2) %= mod;
		(dp[i+1][max(j-1,0ll)] += dp[i][j]) %= mod;
	}
	cout << dp[n][m] * mop(mop(2,m),mod-2) %mod << ln;
}

Measured memory_bytes: 198912
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll cnt = 1;
    ll toggle = 0;

    vi a(n);
    rep(i, n){
        cin >> a[i];
        if(i == 0) continue;
        if(i >= 1 && toggle == 0){
            if(a[i] > a[i-1]) toggle = 1;
            else if(a[i] < a[i-1]) toggle = -1;
        }
        else{
            if(toggle == 1){
                if(a[i] < a[i-1]){
                    toggle = 0;
                    cnt++;
                }
            }
            else{
                if(a[i] > a[i-1]){
                    toggle = 0;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "1" << endl;
    }else if(a != b && b != c && c != a){
        cout << "3" << endl;
    }else{
        cout << "2" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#include <utility>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    map<int, int> p;
    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            p[a] += 1;
        }
        
    }
    int count = 0;
    for (int i = 1; i < n+1; i++)
    {
        if (p[i] == 0)
        {
            count++;
        }
        
    }
    cout << count << endl;
}

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

ans = b * 10
status = ''
for i in range(10):
  8*(ans + i)//100
  if(a == 8*(ans + i)//100):
    ans += i
    status = 'ok'
    break;

if status =='ok':
  print(ans)
  
else:
  print(-1)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	int w,h,ct,num2;
	while(cin>>w>>h){
		ct=0;
		if(w==0&&h==0) break;
		int c[w+2][h+2];
		for(int i=0;i<w+2;i++){
			for(int j=0;j<h+2;j++){
				c[i][j]=0;
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>c[j+1][i+1];
			}
		}
		for(int i=0;i<w+2;i++){
			for(int j=0;j<h+2;j++){
				if(c[i][j]==1){
					c[i][j]=2;
					do{
						num2=0;
						for(int ii=1;ii<w+1;ii++){
							for(int jj=1;jj<h+1;jj++){
								if(c[ii][jj]==2&&c[ii-1][jj-1]==1){
									c[ii-1][jj-1]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii-1][jj]==1){
									c[ii-1][jj]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii-1][jj+1]==1){
									c[ii-1][jj+1]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii][jj-1]==1){
									c[ii][jj-1]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii][jj+1]==1){
									c[ii][jj+1]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii+1][jj-1]==1){
									c[ii+1][jj-1]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii+1][jj]==1){
									c[ii+1][jj]=2;
									num2++;
								}
								if(c[ii][jj]==2&&c[ii+1][jj+1]==1){
									c[ii+1][jj+1]=2;
									num2++;
								}
							}
						}
					} while(num2>0);
					ct++;
					for(int ii=0;ii<w+2;ii++){
						for(int jj=0;jj<h+2;jj++){
							if(c[ii][jj]==2){
								c[ii][jj]=0;
							}
						}
					}
				}
			}
		}
		cout<<ct<<endl;		
	}
    return 0;
}

Measured memory_bytes: 1168
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n, m, p, x, t[100000], sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> p >> x;
		cout << (sum - t[p - 1] + x) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
 
int main(){
    //input
    int N, K;
    ll L, R;
    cin >> N >> K >> L >> R;
    ll a[N];
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
 
    int hn = N/2;
    vector< vector<ll> > sumList1(hn+1);
    vector< vector<ll> > sumList2(N-hn+1);
 
    for (int i=0;i<(1<<hn);i++){
        ll sum = 0;
        int weight = 0;
        for (int j=0;j<hn;j++){
            if ((i>>j)&1){
                sum += a[j];
                weight++;
            }
        }
        sumList1[weight].push_back(sum);
    }
 
    for (int i=0;i<(1<<(N-hn));i++){
        ll sum = 0;
        int weight = 0;
        for (int j=0;j<(N-hn);j++){
            if ((i>>j)&1){
                sum += a[hn+j];
                weight++;
            }
        }
        sumList2[weight].push_back(sum);
    }
 
    for (int i=0;i<hn;i++){
        sort(sumList1[i].begin(), sumList1[i].end());
    }
/*
    cout << endl;
    for (int i=0;i<sumList1.size();i++){
        for (int j=0;j<sumList1[i].size();j++){
            cout << sumList1[i][j] << " ";
        }
        cout << endl;
    }
 
    cout << endl;
    for (int i=0;i<sumList2.size();i++){
        for (int j=0;j<sumList2[i].size();j++){
            cout << sumList2[i][j] << " ";
        }
        cout << endl;
    }
 
    cout << endl;
*/
    ll result = 0;
    for (int i=max(0, K-hn);i<min(K,N-hn)+1;i++){
        for (int j=0;j<sumList2[i].size();j++){
            vector<ll>::iterator it1 = lower_bound(sumList1[K-i].begin(), sumList1[K-i].end(), L-sumList2[i][j]);
            vector<ll>::iterator it2 = upper_bound(sumList1[K-i].begin(), sumList1[K-i].end(), R-sumList2[i][j]);
            ll dist = (ll)distance(it1, it2);
            result += dist;
        }
    }
 
    cout << result << endl;
 
    return 0;
}


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

int main()
{
    int numa, numb;
    cin >> numa >> numb;

    string A[51];
    string B[51];

    for(int i=0;i<numa;i++){
        cin >> A[i];
    }
    for(int i=0;i<numb;i++){
        cin >> B[i];
    }

    for(int i=0;i<numa-numb+1;i++){
        for(int j=0;j<numa-numb+1;j++){
            bool judge = true;
            for(int k=0;k<numb;k++){
                if(A[i+k].compare(j,numb,B[k])!=0){
                    judge = false;
                }
            }
            if(judge){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

class AStationAndBus {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    string s;
    in >> s;
    set<char> S;
    for (char c : s) S.insert(c);

    out << (S.size() == 2 ? "Yes" : "No") << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  AStationAndBus solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

int main()
{
	fastio
	int a,b;
	cin>>a>>b;

	lld ans=a*b;

	cout<<ans<<endl;
}

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

int main(){
  double r;
  cin >> r;

  cout << 2*PI*r  << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

const int MAX_N = 1e5+1;
int par[MAX_N];
int treesize[MAX_N];

void init(int n){
    for(int i=0;i<=n;i++){
        par[i] = i;
        treesize[i] = 1;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

bool same(int x, int y){
    return find(x) == find(y);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    else {
        treesize[y] += treesize[x];
        par[x] = y;
    }
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    init(n);
    
    int a[m],b[m];
    int c[k],d[k];

    int kouho[n+1] = {};

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        unite(a[i],b[i]);
        kouho[a[i]]--;
        kouho[b[i]]--;
    }

    for(int i=0;i<=n;i++){
        kouho[i] += treesize[find(i)] - 1;
    }

    for(int i=0;i<k;i++){
        cin>>c[i]>>d[i];
        if(same(c[i],d[i])){
            kouho[c[i]]--;
            kouho[d[i]]--;
        }
    }

    for(int i=1;i<=n;i++){
        cout<<kouho[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=1e2+10;
char a[M][M];
int tail,head;
int d[M][M],n,m;
pii q[M*M];
void check(int x,int y,int nx,int ny)
{
	if(nx==0 || ny==0 || nx==n+1 || ny==m+1 || d[nx][ny] || a[nx][ny]!='.')return;
	q[head++]=mp(nx,ny);
	d[nx][ny]=d[x][y]+1;
}
main()
{
	cin>>n>>m;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='.')
			{
				cnt++;
			}
		}
	}
	tail=0,head=0;
	q[head++]=mp(1,1);
	d[1][1]=1;
	while(head>tail)
	{
		int y=q[tail].S;
		int x=q[tail++].F;
		check(x,y,x-1,y);
		check(x,y,x,y-1);
		check(x,y,x+1,y);
		check(x,y,x,y+1);
	}
	if(!d[n][m])return cout<<-1,0;
	cout<<cnt-d[n][m];
}

Measured memory_bytes: 384
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,x,s=0;
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=0;i<m;i++)
{
    cin>>x;
    s=s+x;
}
cout<<max(-1LL,n-s);
}


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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const ll mod = 1e9 + 7;

void add(ll& a, ll b)
{
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void mul(ll& a, ll b)
{
    a *= b;
    if (a >= mod) {
        a %= mod;
    }
}

void sub(ll& a, ll b)
{
    a -= b;
    if (a < 0) {
        a += mod;
    }
}

const int nmax = 5020;

ll binpow(ll a, ll n)
{
    ll ans = 1;
    while (n) {
        if (n & 1) {
            mul(ans, a);
        }
        n >>= 1;
        if (n) {
            mul(a, a);
        }
    }
    return ans;
}

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);

    vector<vector<ll> > dp(nmax, vector<ll>(nmax));
    dp[0][0] = 1;
    for (int n = 0; n + 1 < nmax; ++n) {
        for (int l = 0; l < nmax; ++l) {
            add(dp[n + 1][l + 1], dp[n][l]);
            add(dp[n + 1][l + 1], dp[n][l]);
            add(dp[n + 1][max(l - 1, 0)], dp[n][l]);
        }
    }

    int n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = dp[n][sz(s)];
    ll d = binpow(2, mod - 2);

    mul(ans, binpow(d, sz(s)));
    cout << ans << '\n';

}


Measured memory_bytes: 197376
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main(){                         fastIO
  // input_from_file
  ll x,k,d,val;cin>>x>>k>>d;bool flag=0;
  // cout<<"x="<<x<<" ,k="<<k<<" ,d="<<d<<endl;
  if(x>=0)  {
    val=x/d;
    if(val>=k)  {cout<<abs(x-d*k);flag=1;}
    else  {k=k-val;x=x-(x/d)*d;}
  }  
  else{
    val=-1*x/d;
    if(val>=k)  {cout<<abs(x+d*k);flag=1;}
    else  {k=k-val;x=x-(x/d)*d;}
    if(k>0 && flag==0) {x=x+d;k--;}
  }
  // cout<<"x="<<x<<" ,flag="<<flag<<" ,k="<<k<<endl;
  if(!flag){
    if(k%2==0) cout<<abs(x);
    else cout<<abs(x-d);
  }
  return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }




int main() {
    ll n;
    cin >> n;
    ll x[100], y[100], h[100];
    REP(i, n){
        cin >> x[i] >> y[i] >> h[i];
    }
    REP(l, n){
      if(h[l] == 0) continue;
        REP(i, 101){
            REP(j, 101){
                ll H = h[l] + abs(x[l] - i) + abs(y[l] - j);
                bool ok = true;
                REP(k, n){
                    if(max(H - abs(x[k] - i) - abs(y[k] - j), 0LL) != h[k]){
                        ok = false;
                    }
                }
                if(ok){
                    cout << i << ' ' << j << ' ' << H << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
         int k,x;
         cin>>k>>x;
         rep(i,-k+1 ,k) cout<<x+i<<" ";

         
    }   
}     

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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(int i = s;i<n;i++)

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

	int a = -1;
	int b = -1;
	int c = -1;
	rep(i, 0, 2001) {
		rep(j, 0, 2001) {
			if (9000 * i + 4000 * j == Y - 1000 * N) {
				a = i;
				b = j;
				c = N - a - b;

				if (a > 0 && b > 0 && c > 0 && a <= 2000 && b <= 2000 && c <= 2000) {
					break;
				}
			}
		}
	}

	if (a < 0 || b < 0 || c < 0) {
		a = -1; b = -1; c = -1;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    Init_On Start;
    int n; cin >> n;
    string s[n];
    rep(i , n) cin >> s[i];
    set<string> st;
    rep(i , n) st.insert(s[i]);
    cout << st.size() << endl;
}

Measured memory_bytes: 25484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ECrestedIbisVsMonster {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, N;
        const int INF = ten(9);
        in>>H>>N;
        vc<int> A(N), B(N);
        REP(i, N) in>>A[i]>>B[i];
        vc<int> dp(H+1, INF);
        dp[0] = 0;
        FOR(i, 1, H+1){
            REP(j, N){
                chmin(dp[i], dp[max(0, i-A[j])]+B[j]);
            }
        }
        out<<dp[H]<<'\n';
    }
};


int main() {
	ECrestedIbisVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, d, x;
    cin >> n >> d >> x;
    VV p(d, V(n));
    rep(k, d) rep(i, n) cin >> p[k][i];

    rep(k, d - 1) {
        V dp(x + 1, -inf);
        dp[x] = 0;
        rep(i, n) {
            for (int j = x - p[k][i]; j >= 0; j--) {
                dp[j] = max(dp[j], dp[j + p[k][i]] + p[k + 1][i]);
            }
        }
        
        int t = -1;
        rep(j, x + 1) t = max(t, j + dp[j]);
        x = t;
    }

    cout << x << endl;
}

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

int main() {
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;
	
	cin >> n;
	cin >> s;
	
	k = 0;
	for(i=0;i < n ; i++) {
		//printf("K:%d\n",k);
		if (s[i] == 'A') {
			k=1;
		} else if (k == 1) {
			if (s[i] == 'B') k++;
			else k = 0;
		} else if (k == 2) {
			if (s[i] == 'C') {
				ans++;
			}
			k = 0;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	struct Combination
	{
		Combination(int n, ll mod)
		{
			v.resize(n+1, std::vector<ll>(n + 1, 0));
			for (size_t i = 0; i < v.size(); i++) {
				v[i][0] = 1;
				v[i][i] = 1;
			}
			for (size_t j = 1; j < v.size(); j++) {
				for (size_t k = 1; k < j; k++) {
					v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
					if (v[j][k] > mod)
						v[j][k] %= mod;
				}
			}
		}
		ll Get(int n, int r)
		{
			return v[n][r];
		}
		std::vector<std::vector<ll> > v;

	};
}
void ABC132D()
{
	int N, K;
	cin >> N >> K;
	ll MOD = 1000000007;
	Combination comb(N + K, MOD);
	for (int i = 1; i <= K; ++i)
	{
		ll alpha = comb.Get(N - K + 1, i);
		ll beta = comb.Get(K - 1, i - 1);
		cout << (alpha * beta) % MOD << endl;
	}
}

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

Measured memory_bytes: 125440
#include <bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        long long int m,sum=0,k=0,c,i,d=0,j,sum1=0,x,sum2=0,sum3=0,l,kk,sum4=0,sum5=0,y,z,sum6=0,e;
                 ll a,b;
            cin>>a;
             cout<<a+a*a+a*a*a<<endl;
           }

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

using namespace std;

int main() {
    int s; cin>>s;
    map<int, int> an;
    
    int i=1;
    while (an[s] != 1) {
        an[s] += 1;
        if (s % 2 == 0) s/=2;
        else s=3*s+1;
        i++;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n;
vector<int> x;
void input(){
    cin>>n;
    scan_vector(n,x);
}
void src(){
    Yes(*max_element(x.begin(),x.end())
        < accumulate(x.begin(),x.end(),0)-*max_element(x.begin(),x.end()));
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = n % 10;
        int b = n / 10;
        if(a == 9 || b == 9) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }   
}

Measured memory_bytes: 21844
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;

  vector <set<int>> st(26);
  for (int i = 0; i < N; i++){
    int now = S[i] - 'a';
    st[now].insert(i);
  }
  vector <int> ans;
  for (int i = 0; i < Q; i++){
    int num; cin >> num;
    if (num == 1){
      int A; char B; cin >> A >> B;
      A--;
      int now = S[A] - 'a', next = B - 'a';
      st[now].erase(A);
      st[next].insert(A);
      S[A] = B;
    }else{
      int L, R; cin >> L >> R;
      L--; R--;
      int sum = 0;
      for (int j = 0; j < 26; j++){
        auto iter = st[j].lower_bound(L);
        if (iter == st[j].end()) continue;

        int now = *iter;
        if (now <= R) sum++;
      }
      ans.push_back(sum);
    }
  }
  
  for (int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  
  

  return 0;
}


Measured memory_bytes: 24452
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

     public static void hoge()
    {
        var n = long.Parse(System.Console.ReadLine());
        string s = "";
        while(n > 0)
        {
            var num = n % 26;
            num = num - 1;
            if (num == -1)
            {
                num = 25;
            }
            if(n % 26 == 0)
            {
                n = n / 26;
                n -= 1;
            }
            else
            {
                n = n / 26;
            }
            
            char c = (char)(num + (long)'a');
            s = c + s;
        }

        Console.WriteLine(s);
    }
}

Measured memory_bytes: 27412
// Problem : F - Modularness
// Contest : AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
using namespace std;
int d[5005],nd[5005];
long long ds[5005];
int main()
{
 int k,q;
 cin>>k>>q;
 for(int i=1;i<=k;i++)
  cin>>d[i];
 while(q--)
 {
  int n,x,m,cnt=0,ans;
  long long sum;
  cin>>n>>x>>m;
  ans=n-1;
  n--;
  for(int i=1;i<=k;i++)
  {
   nd[i]=d[i]%m;
   ds[i]=ds[i-1]+nd[i];
   cnt+=(nd[i]==0);
  }
  ans-=n/k*cnt;
  sum=x+n/k*ds[k]+ds[n%k];
  for(int i=1;i<=n%k;i++)
   ans-=(nd[i]==0);
  ans-=sum/m-x/m;
  cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 384
n = int(input())

l = len(str(n))
if n < 10:
    ans = n
else:
    ans1 = 9 * (l-1) + int(str(n)[0]) - 1
    ans2 = sum([int(x) for x in list(str(n))])
    ans = max(ans1, ans2)
print(ans)

Measured memory_bytes: 3060