akhauriyash/Code-Regression huggingface dataset:
#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 ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int n, m;
vector<vector<int>> g;
vector<int> color;

bool dfs(int v, int c) {
    color[v] = c;
    for(const auto &u : g[v]) {
        if(color[u] == c) {
            return false;
        }
        if(color[u] == 0 && !dfs(u, -c)) {
            return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    g.resize(n);
    color.resize(n, 0);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    bool f = dfs(0, 1);
    if(f) {
        ll b = count(ALL(color), 1);
        ll w = n - b;
        cout << b * w - (ll)m << endl;
    } else {
        cout << (ll)n * (n - 1) / 2 - (ll)m << endl;
    }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    int N,Q;
    string S;
    cin >> N >> Q >> S;
    vector<int>l(Q);
    vector<int>r(Q);
    for (int i = 0; i < Q; ++i) {
      cin >> l[i] >> r[i];
    }

    // i文字目までのACの合計がsum[i]
    vector<int>sum(N+1);
    sum[0] = 0;
    sum[1] = 0;
    S = ' ' + S;
    for (int i = 2; i < N+1; ++i) {
        if(S[i] == 'C' && S[i-1] == 'A') {
            sum[i] = sum[i-1] + 1;
        }else{
            sum[i] = sum[i-1];
        }
    }

    int ans;
    for (int i = 0; i < Q; ++i) {
        ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2172
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO") << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

vector<int> memo;

int dp(int k, const vector<vector<int>> &g) {
  if(memo[k] != -1) return memo[k];
  if(g[k].empty()) {
    return memo[k] = 0;
  }
  vector<int> tmp;
  for(int i: g[k]) {
    tmp.push_back(dp(i, g));
  }
  sort(tmp.rbegin(), tmp.rend());
  REP(i,tmp.size()) tmp[i] += i + 1;
  int res = -1;
  REP(i,tmp.size()) res = max(res, tmp[i]);
  return memo[k] = res;
}

int main(){
  int N;
  cin >> N;
  vector<int> a(N - 1);
  REP(i,N - 1) {
    cin >> a[i]; --a[i];
  }

  vector<vector<int>> g(N);
  REP(i,N - 1) {
    g[a[i]].push_back(i + 1);
  }

  memo.assign(N, -1);
  cout << dp(0, g) << endl;
  return 0;
}



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

int main() {
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a(n,0);
    int ans = x;
    for (size_t i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    for (size_t i = 1; i <= d; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            if ((i-1)%a[j]==0) {
                ++ans;
            }
        }
        /* code */
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int M = 1e9+7;
const int N = 1e5+5;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int n; cin >> n;
	int a[n], b[n], c[n];
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	int da[n+1], db[n+1], dc[n+1];
	da[0] = db[0] = dc[0] = 0;
	rep(i, n) {
		da[i+1] = max(db[i], dc[i]) + a[i];
		db[i+1] = max(da[i], dc[i]) + b[i];
		dc[i+1] = max(da[i], db[i]) + c[i];
	}
	print(max({da[n], db[n], dc[n]}));
}


Measured memory_bytes: 4992
#include <iostream>
 
int main()
{
  long int W, H, x, y;
  std::cin >> W >> H >> x >> y;
  
  long double area = W * H * 0.5;
  std::cout << area << ' ';
  if(x * 2 == W && y * 2 == H){
    std::cout << 1;
  } else {
    std::cout << 0;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll V[1<<18],W[1<<18];
ll dp[1<<9][100001]={};
ll Dfs(ll vert,ll w){
	if(vert==0)return 0;
	if(dp[vert][w]!=-1)return dp[vert][w];

	ll ret=Dfs(vert/2,w);
	if(w>=W[vert]){
		ret=max(ret,V[vert]+Dfs(vert/2,w-W[vert]));
	}
	return dp[vert][w]=ret;
}

ll Dfs2(ll vert,ll w){
	if(vert<(1<<9))return dp[vert][w];
	ll ret=0;
	ret=max(ret,Dfs2(vert/2,w));
	if(w<W[vert])return ret;
	return max(ret,V[vert]+Dfs2(vert/2,w-W[vert]));
}
int main(){
    cin>>N;
    for(ll i=1;i<=N;i++){
        cin>>V[i]>>W[i];
    }
	for(ll i=1;i<(1ll<<9);i++) for(ll j=0;j<=100000;j++) dp[i][j]=-1;
	for(ll i=1;i<(1ll<<9);i++) for(ll j=0;j<=100000;j++) Dfs(i,j);
    ll Q;cin>>Q;
    for(ll i=0;i<Q;i++){
        ll v,L;
        cin>>v>>L;
		cout<<Dfs2(v,L)<<endl;
    }

    return 0;
}

Measured memory_bytes: 406956
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    REP(i, 2*n){
        if(i%2==0)
            cout << s[i/2];
        else
            cout << t[i/2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int, input().split()))
MOD = 10 ** 9 + 7

cumsum = [A[0]]
for i in range(1, N):
    cumsum.append(A[i] + cumsum[i - 1])

ans = 0
for i in range(N):
    ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 106908
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p = p[-x:]
q.sort()
q = q[-y:]
print(sum(sorted(p + q + r)[-x - y:]))

Measured memory_bytes: 113004
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int ans = 0;
  rep(i, N) {
    int a; in(a);
    ans += a-1;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

vll lang(100001, -1);
struct UF{
  std::vector<int> par, dep, sz;
  UF(int n){
    par.resize(n+1), dep.resize(n+1), sz.resize(n+1);
    init(n);
  }
  void init(int nu) {
    for(int iu=0;iu<=nu;iu++){
      par[iu] = iu;
      dep[iu] = 0;
      sz[iu] = 1;
    }
  }
  int find(int xu){
    if(par[xu] == xu) return xu;
    return par[xu] = find(par[xu]);
  }
  void unite(int xu, int yu){
    xu=find(xu);
    yu=find(yu);
    if(xu == yu) return;
    if(dep[xu] < dep[yu]){
      sz[yu] += sz[xu];
      par[xu] = yu;
    }else{
      par[yu] = xu;
      sz[xu] += sz[yu];
      if(dep[xu] == dep[yu]) dep[xu]++;
    }
  }
  bool same(int xu, int yu){
    return find(xu) == find(yu);
  }
};
int main(int argc, char const *argv[]) {
  ll n, m, k, t;std::cin >> n >> m;
  UF uf(n+1);
  re(i, n){
    std::cin >> k;
    re(j, k){
      std::cin >> t;
      if(lang[t]==-1) lang[t] = i+1;
      else uf.unite(i+1, lang[t]);
    }
  }
  ll c = uf.find(1);
  rep(i, 1, n+1) {
    if(uf.find(i)!=c){
      std::cout << "NO" << '\n';
      return 0;
    }
  }
  std::cout << "YES" << '\n';
  return 0;
}


Measured memory_bytes: 2176
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  string s;
  cin >> s;
  int ans = 0;
  REP(i, SZ(s) / 2) {
    if (s[i] != s[SZ(s) - i - 1]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e3;
LL t[N + 5], a[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 0;i < n;i++) cin>>t[i]>>a[i];
	LL x1 = 1, y1 = 1;
	for(int i = 0;i < n;i++) {
		LL mul = max((t[i] + x1 - 1) / t[i], (a[i] + y1 - 1) / a[i]);
		x1 = t[i] * mul;
		y1 = a[i] * mul;
//		cout<<x1<<" "<<y1<<" "<<mul<<endl;
	}
	cout<<x1+y1<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


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

	int r[3][10] = {};


	for (int i = 0; i < M; ++i) {
		int s, c;
		cin >> s >> c;

		r[s - 1][c] = 1;
	}

	for (int i = 0; i < N; ++i) {
		int c = 0;
		int j = 0;
		for (j = 0; j < 10; ++j) {
			if (r[i][j]) {
				++c;
			}
		}
		if (c >= 2) {
			printf("-1\n");
			return 0;
		}
	}

	for (int i = 0; i < N; ++i) {
		bool bFound = false;
		int j = 0;
		for (j = 0; j < 10; ++j) {
			if (r[i][j]) {
				bFound = true;
				break;
			}
		}
		if (bFound == false) {
			j = 0;
			if (i == 0) {
				j = 1;
			}
			if (N == 1) {
				j = 0;
			}
		}
		if ((i == 0 && j == 0) && N != 1) {
			printf("-1\n");
			return 0;
		}
		printf("%d", j);
	}
	printf("\n");


	return 0;
}



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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    int n;
    cin>>n;
    vl v(n),prefix,suffix;
    pan(i,n) cin>>v[i];
    ll ans=0,x=v[0],y=v[n-1];
    prefix.pb(x),suffix.pb(y);
    for(int i=1;i<n;i++){
        x=gcd(x,v[i]);
        y=gcd(y,v[n-1-i]);
        prefix.pb(x),suffix.pb(y);
    }
    pan(i,n){
        ll p;
        if(i==0)
            p=suffix[n-2];
        else if(i==n-1)
            p=prefix[n-2];
        else p=gcd(prefix[i-1],suffix[n-i-2]);
        ans=max(ans,p);
    }
    cout<<ans;
}


Measured memory_bytes: 2804
#include <stdio.h>

int main(){
int a,b,c;
scanf("%d %d %d", &a,&b,&c);
int tmp;
if (a>b){tmp=a; a=b; b=tmp;};
if (b>c){tmp=b; b=c; c=tmp;};
if (a>b){tmp=a; a=b; b=tmp;};
printf("%d %d %d\n", a, b, c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 

  
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{ll int t;

t=1;

while(t--)
{

ll int a,b,c;
cin>>a>>b>>c;
if(a==b&&b==c)
{cout<<"No"<<endl;
continue;}
if(a==b||a==c)
{
    
    cout<<"Yes"<<endl;
}
else if(b==c)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
    



}
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,q;
        cin>>n>>q;
        vvl G(n,vl(0));
        rep(i,n-1){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            G[a].pb(b);
            G[b].pb(a);
        }
        vl score(n,0);
        rep(i,q){
            ll p,x;
            cin>>p>>x;
            p--;
            score[p]+=x;
        }
        queue<ll> Q;
        Q.push(0);
        umap<ll,ll> M;
        M[0]++;
        while(!Q.empty()){
            ll now=Q.front();
            Q.pop();
            rep(i,Size(G[now])){
                ll y=G[now][i];
                if(M[y]!=0)continue;
                M[y]++;
                score[y]+=score[now];
                Q.push(y);
            }
        }
        rep(i,n)cout<<score[i]<<' ';
        cout<<endl;
    }

Measured memory_bytes: 26224
N, M = map(int, input().split())

guess = []
for _ in range(M):
  s, c = map(int, input().split())
  guess.append([s, c])

result = -1
for n in range(pow(10, N)):
  if (len(str(n)) != N):
    continue
  
  valid = True
  for s_c in guess:
    keta = s_c[0]
    index = keta - 1
    if (str(n)[index] != str(s_c[1])):
      valid = False
      break
  
  if (valid == False):
    continue
  else:
    result = n
    break

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
vi Zalgo(string S) {
    vi vec(1, S.size());
    for(int i = 1, l = -1, r = -1; i < S.size(); i++){
        if(i <= r && vec[i-l] < r-i+1) vec.emplace_back(vec[i-l]);
        else {
            l = i; r = (i > r) ? i : (r+1);
            while(r < S.size() && S[r-i] == S[r]) r++;
            vec.emplace_back((r--) - l);
        }
    }
    return vec;
}

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

    int n; cin >> n;
    string in; cin >> in;

    int res = 0;
    rep(i, n){
        string S = in.substr(i);
        auto tbl = Zalgo(S);
        rep(j, tbl.size()){
            chmax(res, min(j, tbl[j]));
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        x: [i32;n]
    }
    let a = (x.iter().sum::<i32>() as f64) / (n as f64);
    let p = a.round() as i32;
    let res = x.iter().map(|x| (x - p).pow(2)).sum::<i32>();
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4476
#include <stdio.h>

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

    while(1){
        scanf("%d %d",&x,&y);
        if(x>y) {tmp = x; x = y; y = tmp;}
        if(x == 0 && y == 0) break;
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 600
dy = [1, -1, 0, 0]
dx = [0, 0, 1, -1]

def resolve():
	h, w = map(int, input().split())
	pic = []
	for i in range(h):
		r = list(input())
		pic.append(r)
	for i in range(h):
		for j in range(w):
			if pic[i][j] == '#':
				ok = False
				for k in range(4):
					ny = i + dy[k]
					nx = j + dx[k]
					if ny >= h or nx >= w:
						continue
					if pic[ny][nx] == '#':
						ok = True
				if not ok:
					print('No')
					return
	print('Yes')
resolve()

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

string a;
vll dp;
vbl used;
vector<lli> r;
vector<char> ch;
mat m;

lli solve(lli x){
	if(used[x]) return dp[x];
	used[x] = true;
	for(char c = 'a';c <= 'z';c++){
		lli y;
		if(m[x][c] == a.size()) y = 1;
		else y = 1 + solve(m[x][c]+1);
		if(dp[x] > y){
			dp[x] = y;
			r[x] = m[x][c]+1;
			ch[x] = c;
		}
	}
	return dp[x];
}

int main(){
	cin >> a;
	m = mat(a.size()+1,vll(128,a.size()));
	for(lli i = a.size()-1;i >= 0;i--){
		for(char c = 'a';c <= 'z';c++){
			if(a[i] == c){
				m[i][c] = i;
			}else{
				m[i][c] = m[i+1][c];
			}
		}
	}
	used = vbl(a.size()+1);
	dp = vll(a.size()+1,INT_MAX);
	r = vll(a.size()+1);
	ch = vector<char>(a.size()+1);
	solve(0);
	for(lli i = 0;i < a.size();){
		cout << ch[i];
		i = r[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 211972
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long N = I.nextLong();
		long M = I.nextLong();
		long ans = 1;
		for (long i = 1; i*i<=M; i++) {
			if (M%i==0) {
				long slotsum = N*i;
				long left = M-slotsum;
				if (left>=0&&left%i==0) ans=Math.max(ans,i);
				
				slotsum = N*M/i;
				left=M-slotsum;
				if (left>=0&&left%(M/i)==0) ans=Math.max(ans, M/i);
			}
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25608
from heapq import heappush, heappop

def search(v, u):
    while v != root[v]: v = root[v]
    while u != root[u]: u = root[u]
    
    return v, u

def rebuild(v, u, r):
    while v != root[v]: v, root[v] = root[v], r
    while u != root[u]: u, root[u] = root[u], r
    return v, u

n = int(input())
root = [i for i in range(n)]
depth = [1] * n

q = []

for i in range(n):
    for j, c in enumerate(list(map(int, input().split()))):
        if c == -1: continue
        heappush(q, (c, i, j))
        
ans = 0

while q:
    c, v, u = heappop(q)
    
    v_r, u_r = search(v, u)
    if v_r == u_r: continue
    
    ans += c
    
    v_d, u_d = depth[v_r], depth[u_r]
    if v_d == u_d:
        depth[v_r] += 1
        if depth[v_r] > 10: rebuild(v, u, v_r)
        
    elif v_d < u_d: v_r, u_r = u_r, v_r
    
    root[v_r] = u_r
    
print(ans)



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

#define llint long long int

#define MAX 200001
#define NUM 1000000007

#define MULT(x,y) ( ((x)%NUM)*((y)%NUM) %NUM)
#define ADD(x,y)  ((((x)%NUM)+((y)%NUM))%NUM)

std::vector<llint>  fac(MAX);
std::vector<llint> finv(MAX);

llint pow(llint base, llint exp){
  llint res = 1;
  while(exp > 1){
    if(exp%2){
      res = MULT(res, base);
    }
    base = MULT(base, base);
    exp/=2;
  }
  return MULT(res, base);
}

void comb_init(){
  fac[0] = 1;
  for(int i=1; i<MAX; i++){
    fac[i] = MULT(fac[i-1], i);
  }
  finv[MAX-1] = pow(fac[MAX-1], NUM-2);
  for(int i=MAX-2; i>=0; i--){
    finv[i] = MULT(finv[i+1], i+1);
  }
}

llint comb(llint a, llint b){
  return MULT(MULT(fac[a], finv[a-b]), finv[b]);
}

int main(void){
  llint n, m, k;
  std::cin >> n >> m >> k;

  comb_init();

  llint total = 0;
  for(int d=1; d<n; d++){
    total = ADD(total, MULT(d*(n-d)*m*m, comb(n*m-2, k-2)));
  }

  for(int d=1; d<m; d++){
    total = ADD(total, MULT(d*(m-d)*n*n, comb(n*m-2, k-2)));
  }
  std::cout << total << std::endl;
  
  return 0;
}


Measured memory_bytes: 3328
import collections
N=int(input())
h=[int(i) for i in input().split()]

h_o_l = len(h[1::2])
h_e_l = len(h[::2])

h_o = collections.Counter(h[1::2])
h_e = collections.Counter(h[::2])

o_ = h_o.most_common()
e_ = h_e.most_common()
o_.append((0,0))
e_.append((0,0))

if o_[0][0] != e_[0][0]:
    print(N-o_[0][1]-e_[0][1])
elif o_[0][0] == e_[0][0]:
    a =min(N-o_[0][1]-e_[1][1],N-e_[0][1]-o_[1][1])
    print(a)

Measured memory_bytes: 21184
using System;
					
public class Program
{
	public static void Main()
	{
		int pages = int.Parse(Console.ReadLine());
		int answer = 0;
		if (pages%2 == 0){
			answer = pages/2;
		}
		else{
			answer = (pages+1)/2;
		}
		Console.WriteLine("{0}", answer);
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
const int sup=101;
char map[sup][sup];
int main(){
  int a,b;
  cin>>a>>b;
  int tmp_a=a;
  int tmp_b=b;
  if(a>b){
    a=tmp_b;
    b=tmp_a;
  }
  int small=a;
  small--;
  int div=small/100;
  int rest=small%100;
  char buf='.';
  rep1(i,100){
    rep1(j,100){
      if(i==sup/2)buf='#';//最初は.途中から#
      map[i][j]=buf;
      if(i==sup/2&&j%2==1)map[i][j]='.';//50段目の奇数が白
      //      cout<<map[i][j];
    }
    //    cout<<endl;
  }
  int small2=small*2;//真ん中をあれする
  for(int i=sup/2+1;i<sup/2+5+div*2;i++){
    for(int j=1;j<=100;j++){
      if((i+j)%2==1)buf='.';
      else buf='#';
      if(small2==0)goto kk;
      map[i][j]=buf;
      small2--;
    }
  }
 kk:
  //aは.でbは#
  a-=small;
  b-=small;
  a--;
  b--;
  int tmp=1;
  if(a==0){
    rep1(i,25){
      rep1(j,100){
	if(b==0)goto FINE;
	if(i%2==1&&j%2==1){
	  map[i][j]='#';
	  b--;
	}
	//	if(b==0)goto FINE;
      }
    }
  }
  if(b==0){
    for(ll i=70;i<=100;i++){
      rep1(j,25){
	if(a==0)goto FINE;
	if(i%2==1&&j%2==1){
	  map[i][j]='.';
	  a--;
	}
	//	if(a==0)goto FINE;
      }
    }
  }
 FINE:
  cout<<"100 100"<<endl;
  rep1(i,100){
    rep1(j,100){
      if(tmp_a>tmp_b){
	if(map[i][j]=='.')map[i][j]='#';
	else map[i][j]='.';
      }
      cout<<map[i][j];
    }
    cout<<endl;
  }
  //  cout<<small<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
 
int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int count=0;
  for(int i=l; i<=r; i++){
    if(i%d==0)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(int i=0;i<SZ(s);i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            cnt++;
            i+=2;
        }
    }
    cout<<cnt<<nl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
using namespace std;
int main(){
	int a[3],n,w;
	while(true){
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]==0&&a[1]==0&&a[2]==0)
		break;
	for(int i=0;i<2;i++){
        for(int j=2;j>i;j--){
	        if(a[j]<a[j-1]){
	        int tmp=a[j];
	        a[j]=a[j-1];
	        a[j-1]=tmp;
	        }
        }
    }
	double h=(double)sqrt((double)(a[0]*a[0])+(a[1]*a[1]))/2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w;
		if(h<w)
			cout<<"OK"<<endl;
		else
			cout<<"NA"<<endl;
	}
	}
    return 0;
}
 

Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>

using namespace std;

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

int main (int argc, char*argv[]) {
  int n;
  cin >> n;
  vector<int> count (100000, 0);
  int s = 0;
  for(int i=0; i<n; i++) {
    int k;
    cin >> k;
    count[k-1] ++;
    if(count[k-1] > 1) {
      s++;
    }
  }

  if(s % 2 == 1) s++;

  cout << n - s << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;
const ll mod = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this)+=a; }
  mint operator-(const mint a) const { return mint(*this)-=a; }
  mint operator*(const mint a) const { return mint(*this)*=a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this)/=a; }
  bool operator==(const mint a) const { return x == a.x; }
  bool operator!=(const mint a) const { return x != a.x; }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};

template<typename T>
struct Comb {
  vector<T> fact, finv, inv;
  Comb(int n) : fact(n, 1), finv(n, 1), inv(n, 1) { init(n); }
  void init(int n) {
    fact.assign(n, 1), finv.assign(n, 1), inv.assign(n, 1);
    for (ll i=2; i<n; i++) {
      fact[i] = fact[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod/i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }
  T nck(int n, int k) {
    if (n<k || n<0 || k<0) return 0;
    return fact[n] * (finv[k] * finv[n-k] % mod) % mod;
  }
  T nhk(int n, int k) { return nck(n+k-1, k); }
  T npk(int n, int k) {
    if (n<k || n<0 || k<0) return 0;
    return fact[n] * finv[n-k] % mod;
  }
};

int main()
{
  ll k; cin >> k;
  string s; cin >> s;
  ll n = s.size();
  Comb<ll> c(2000010);
  mint ans = 0;
  rep(i, k+1) {
    mint now = mint(25).pow(i) * c.nhk(n, i);
    now *= mint(26).pow(k-i);
    ans += now;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51196
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string str[8]={"black",
                "blue",
                "lime",
                "aqua",
                "red",
                "fuchsia",
                "yellow",
                "white"};

int change(string t){
    int res = 0;
    rep(i, 0, 2){
        if('0' <= t[i] && t[i] <= '9'){
            res += (t[i] - '0')*16*(1 - i);
        }else{
            res += ((t[i] - 'a') + 10)*16*(1 - i);
        }
    }
    return res;
}

signed main() {
    string s;
    while(cin >> s){
        if(s == "0") break;
        int r, g, b;
        r = change(s.substr(1, 2));
        g = change(s.substr(3, 2));
        b = change(s.substr(5, 2));
        int MIN = 1e9, p = -1;
        rep(i, 0, 2){
            rep(j, 0, 2){
                rep(k, 0, 2){
                    int d = (r - i*240)*(r - i*240) + (g - j*240)*(g - j*240) + (b - k*240)*(b - k*240);
                    if(d < MIN){
                        MIN = d;
                        p = i*4 + j*2 + k;
                    }
                }
            }
        }
        cout << str[p] << endl;
    }
}

Measured memory_bytes: 1188
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪func•*¨*•.¸¸♪

//•*¨*•.¸¸♪main•*¨*•.¸¸♪

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	k := scanInt()

	ans := 0

	for i := 1; i < n+1; i++ {
		ans += max((n/i)*(i-k),0)+max((n%i)-(k-1),0)
		// fmt.Println(ans)
	}
	if k == 0 {
		ans -= n
	}
	fmt.Println(ans)
}


func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}


Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

const int MAX = 510000;
const int MOD = 1000000007;

ll 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;
    }
}

// 二項係数計算
ll 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 mod(ll i, ll j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll min_s = 0;
    ll max_s = 0;
    COMinit();
    vll TMP(N);
    rep(i, N) {
        ll selected = COM(N - i - 1, K - 1);
        //ll selected = COM(N - 1, K - 1);
        min_s += (selected * A[i]) % MOD;
        min_s %= MOD;
        //seleted
    }
    sort(A.begin(), A.end(), greater<ll>());
    rep(i, N) {
        ll selected = COM(N - i - 1, K - 1);
        //ll selected = COM(N - 1, K - 1);
        max_s += (selected * A[i]) % MOD;
        max_s %= MOD;
        //seleted
    }
    ll ans = mod(max_s - min_s, MOD);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13824
#include<iostream>
using namespace std;
long long n,a,b,c=1;
int main(){
    cin>>n;
    for(a=2;a*a<=n&&c;a++)c=(n%a!=0);
    if(!c){
        c=n;
        for(a=2;a*a<=n;a++){
            if(n%a==0){
                b=n/a;
                if(a+b-2<c)c=a+b-2;
            }
        }
        cout<<c<<'\n';
    }else cout<<n-1<<'\n';
}

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

int main() {
	long long n,m,i,j,k,ans,cur,jud;
	cin >> k;
	queue<long long> q;
	
	if(k==1){
		cout << 1 << endl; return 0;
	}
	for(i=2; i<=12; i++){
		q.push(i);
	}
	for(i=2; i<k; i++){
		cur=q.front();
		q.pop();
		if(cur%10>0){
			q.push(cur*10+(cur%10)-1);
		}
		q.push(cur*10+cur%10);
		if(cur%10<9){
			q.push(cur*10+(cur%10)+1);
		}
	}
	cout << q.front() << endl;;
	return 0;
}

Measured memory_bytes: 1792
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 1000_000usize;
  let mut h = vec![0usize; nmax + 1];
  for i in 0..N {
    h[A[i]] += 1;
  }
  let mut mx = 0;
  let mut isprime = vec![true; nmax + 1];
  let mut i = 2;
  let mut j = 0;
  let mut f = 0;
  while i <= 1000 {
    if isprime[i] {
      f = 0usize;
      j = i;
      while j <= nmax {
        isprime[j] = false;
        f += h[j];
        j += i;
      }
      mx = max(mx, f);
    }
    i += 1;
  }
  for i in 1001..=nmax {
    if isprime[i] {
      f = 0usize;
      j = i;
      while j <= nmax {
        f += h[j];
        j += i;
      }
      mx = max(mx, f);
    }
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}


Measured memory_bytes: 25232
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	m := make(map[rune]string)
	ans := 0
	for i := 1; i <= n; i++ {
		count := 0
		a := s[:i]
		b := s[i:]
		for _, v := range a {
			m[v] = "a"
		}
		for _, v := range b {
			if m[v] == "a" {
				count++
				m[v] = ""
			}
		}
		if ans < count {
			ans = count
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
string s;
int n;
int main() {
		cin>>n>>s;
		if( s.length()<=n ){
			cout<<s;
		}else {
			rep(i,0,n){
				cout<<s[i];
			}
			printf("...");
		} 
} 

Measured memory_bytes: 3672
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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; }



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

  ll N,M; cin>>N>>M;
  vector<ll> A(M),B(M); rep(i,M) cin>>A[i]>>B[i];
  
  ll ans=0;
  rep(i,M){
    vector<vector<ll>> graph(N,vector<ll>(0));
    rep(j,M){
      if(i==j) continue;
      ll a=A[j],b=B[j]; a--; b--;
      graph.at(a).push_back(b);
      graph.at(b).push_back(a);
    }
    vector<int> vec(N,0);
    queue<ll> que;
    que.push(0); vec[0]=1;
    while(!que.empty()){
      ll v=que.front(); que.pop();
      for(auto nv:graph.at(v)){
        if(vec[nv]) continue;
        vec[nv]=1;
        que.push(nv);
      }
    }
    for(auto v:vec) if(!v) {ans++; break;}
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, M; cin >> N >> M;
    vector<vector<int>> s(M, vector<int>());
    rep(i_M, 0, M) {
        int k; cin >> k;
        rep(i_k, 0, k) {
            int ins; cin >> ins;
            --ins;
            s[i_M].push_back(ins);
        }
    }
    vector<int> p(M);
    rep(i, 0, M) cin >> p[i];

    int res = 0;
    rep(mask, 0, 1<<N) {
        bool ok = true;
        rep(i_M, 0, M) {
            int numOn = 0;
            rep(i_k, 0, s[i_M].size()) {
                if ((1 << s[i_M][i_k]) & mask) ++numOn;
            }

            if ((numOn & 1) != p[i_M]) {
                ok = false;
                break;
            }
        }
        if (ok) ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = [list(map(int,input().split())) for i in range(M)]

for i in range(M) :
    ans = 0
    for j in range(N) :
        if j == PX[i][0]-1 :
            ans += PX[i][1]
        else :
            ans += T[j]
    print(ans)


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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if(c-a<0) cout << "NO" <<endl;
    else if(c-a<=b) cout << "YES" << endl;
    else cout << "NO" <<endl;
    
}



Measured memory_bytes: 256