akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{ it.toInt() }

    val frontgcd = IntArray(n)
    frontgcd[0] = a[0]
    for(i in 1..n-1){
        frontgcd[i]=gcd(a[i],frontgcd[i-1])
    }

    val backgcd = IntArray(n)
    backgcd[n-1] = a[n-1]
    for(i in n-2 downTo 0){
        backgcd[i]=gcd(a[i],backgcd[i+1])
    }

    (0..n-1).map { when(it){
        0 -> backgcd[1]
        n-1 -> frontgcd[n-2]
        else -> gcd(frontgcd[it-1],backgcd[it+1])
    } }.max().let { println(it) }
}

fun gcd(a: Int, b: Int): Int = if(b==0) a else gcd(b,a%b)

Measured memory_bytes: 59392
from itertools import product

N = int(input())

ans = [0] * (N + 1)
for x, y, z in product(range(1, 101), repeat=3):
    f = x**2 + y**2 + z**2 + x * y + y * z + z * x
    if f <= N:
        ans[f] += 1

print(*ans[1:], sep='\n')


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t < k) {
      a.push_back(t);
    }
  }
  n = a.size();
  sort(a.begin(), a.end());
  int l = -1, r = n;
  while (r - l > 1) {
    int m = (r + l + 1) / 2;
    bool need = false;
    vector<bool> dp(k);
    dp.at(0) = true;
    for (int i = 0; i < n; i++) {
      if (i == m) continue;
      for (int j = k - 1; j >= a.at(i); j--) {
        dp.at(j) = dp.at(j) or dp.at(j - a.at(i));
        if (dp.at(j) and j >= k - a.at(m)) {
          need = true;
          break;
        }
      }
      if (need) break;
    }
    if (need) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vint b(m);
  rep(i, m) cin >> b[i];
  vint res;
  set_difference(all(a), all(b), inserter(res, res.end()));
  for(int x : res) cout << x << endl;

  return 0;
}



Measured memory_bytes: 8116
/* Dynamic Programming implementation of LCS problem */
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X,string Y, int m, int n )
{
int L[m+1][n+1];

/* Following steps build L[m+1][n+1] in bottom up fashion. Note
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++)
{
	for (int j=0; j<=n; j++)
	{
	if (i == 0 || j == 0)
		L[i][j] = 0;
	else if (X[i-1] == Y[j-1])
		L[i][j] = L[i-1][j-1] + 1;
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]);
	}
}

// Following code is used to print LCS
int index = L[m][n];

// Create a character array to store the lcs string
char lcs[index+1];
lcs[index] = '\0'; // Set the terminating character

// Start from the right-most-bottom-most corner and
// one by one store characters in lcs[]
int i = m, j = n;
while (i > 0 && j > 0)
{
	// If current character in X[] and Y are same, then
	// current character is part of LCS
	if (X[i-1] == Y[j-1])
	{
		lcs[index-1] = X[i-1]; // Put current character in result
		i--; j--; index--;	 // reduce values of i, j and index
	}

	// If not same, then find the larger of two and
	// go in the direction of larger value
	else if (L[i-1][j] > L[i][j-1])
		i--;
	else
		j--;
}

// Print the lcs
cout<<lcs;
}

/* Driver program to test above function */
int main()
{
  string X,Y;
  cin>>X>>Y;
int m = X.length();
int n = Y.length();
lcs(X, Y, m, n);
return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
    int n,m;
    string S;
    int dice[6];
    for(int i=0;i<6;i++){
        cin>>dice[i];
    }
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='N'){
            m=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=m;
        }
        else if(S[i]=='S'){
            m=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=m;
        }
        else if(S[i]=='W'){
            m=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=m;
        }
        else if(S[i]=='E'){
            m=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=m;
        }
        m=0;
    }
    cout<<dice[0]<<endl;
return 0;
}


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

using namespace std;

int main()
{
  int p, q;
  while(cin >> p >> q, p || q) {
    string master[11], beginner[11];
    for(int i = 0; i < p; i++) cin >> master[i];
    for(int i = 0; i < q; i++) cin >> beginner[i];

    int well[11] = {0};
    for(int i = 0; i < p; i++) {
      for(int j = 0; j < master[i].size(); j++) {
	if(master[i][j] != '.') break;
	well[i]++;
      }
    }
    int ans[11]; fill(ans, ans + 11, -2);
    for(int R = 1; R <= 20; R++) {
      for(int C = 1; C <= 20; C++) {
	for(int S = 1; S <= 20; S++) {
	  int r = 0, c = 0, s = 0; bool cor = true;
	  for(int i = 0; i < p; i++) {
	    if(R*r + C*c + S*s != well[i]) { cor = false; break; }
	    for(int j = 0; j < master[i].size(); j++) {
	      switch(master[i][j]) {
	      case '(': r++; break; case ')': r--; break;
	      case '{': c++; break; case '}': c--; break;
	      case '[': s++; break; case ']': s--; break;
	      }
	    }
	  }
	  if(cor == false) continue;
	  r = 0, c = 0, s = 0;
	  for(int i = 0; i < q; i++) {
	    if(ans[i] == -2) ans[i] = R*r + C*c + S*s;
	    else if(ans[i] != R*r + C*c + S*s) ans[i] = -1;
	    for(int j = 0; j < beginner[i].size(); j++) {
	      switch(beginner[i][j]) {
	      case '(': r++; break; case ')': r--; break;
	      case '{': c++; break; case '}': c--; break;
	      case '[': s++; break; case ']': s--; break;
	      }
	    }
	  }
	}
      }
    }
    for(int i = 0; i < q; i++) cout << ans[i] << (i==q-1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 1216
n, m = list(map(int, input().split()))
lr = [list(map(int, input().split())) for i in range(m)]
lr.sort()
r_min = 100000
l_max = 0
lr_min = 100000

for i in range(m):
    l_max = max(lr[i][0], l_max)
    r_min = min(lr[i][1], r_min)

lr_min = [r_min - l_max + 1 if l_max <= r_min else 0]
print(lr_min[0])


Measured memory_bytes: 27772
#include <iostream>
#include <vector>
#include <utility>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;

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

vector<pair<ll,int> > factorize(ll n){
  vector<pair<ll,int> > res;
  for(ll i = 2; i*i <= n; i++){
    if(n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1);
  return res;
}

int main(){
  ll a,b;
  cin >> a >> b;
  ll m = gcd(a,b);
  
  auto vp = factorize(m);
  cout << vp.size() +1 << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int num[10]={111,222,333,444,555,666,777,888,999,1111};
int main()
{
	int n;
    cin>>n;
    for(int i=0; i<10 ; i++)
    {
    	if(num[i]>=n) {
    	cout<<num[i];return 0;
        }
    }
     return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace ::std;
 
#define all(x)  x.begin(),x.end()
#define Unique(x) x.erase(unique(x.begin(), x.end()), x.end())

template< class T > T SQR(T N) {return (T) N * N;}
template< class T > double DIST(T a, T b) {return 1.0 * sqrt(SQR(double(a)) + SQR(double(b)));}
template< class T > bool CROSS(pair< T,T > a, pair< T,T > b, pair< T,T > c) {return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);}
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int,int > pi;
 
int px[] = {0, 1, -1, 0, -1, -1, 1};
int py[] = {1, 0, 0, -1, -1, 0, -1, -1};

const double eps = 1e-9;
 
inline ll power(ll a, ll p, ll mod)
{
    ll x = a, res = 1;
 
    while(p)
    {
        if(p&1) res = (res * x)%mod;
        p /= 2, x = (x * x)%mod;
    }
    return res;
}

int main()
{
    int n, m, c, d, a, b, k;
 
    int test;
 
    // scanf("%d", &test);
    // while(test--)
    // {
        scanf("%d", &n);

        m = ceil(n/1000.0);

        printf("%d\n", m * 1000 - n);
    //}
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;

ll ans=0;

void plu(string s){
  string n="";
  rep(i,s.size()){
    if(s[i]=='+'){
      ans+=stoll(n);
      n="";
    }else{
      n+=s[i];
    }
  }
  ans+=stoll(n);
}

void bfs(int c,string s){
  if(c==0){
    plu(s);
    return;
  }
  bfs(c-1,s);
  if(c>0){
    s.insert(c,"+");
    bfs(c-1,s);
  }
}

int main() {
  string s;
  cin >>s;
  bfs(s.size()-1,s);
  cout <<ans<<endl;
}

Measured memory_bytes: 3628
#datetimeモジュールをインポートする
import datetime

#aとbが0になるまで処理を繰り返す
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:break

    #detetimeモジュールを使い、youbiに代入し、"strftime"を使い、曜日を取得する
    youbi = datetime.datetime(2004,a,b)
    print(youbi.strftime("%A"))


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

int main(){
  int i,j,n,be,af;
  string a[10],ans;
  a[0] = "0111111";
  a[1] = "0000110";
  a[2] = "1011011";
  a[3] = "1001111";
  a[4] = "1100110";
  a[5] = "1101101";
  a[6] = "1111101";
  a[7] = "0100111";
  a[8] = "1111111";
  a[9] = "1101111";
  while(1){
    cin >> n;
    if(n == -1) break;
    for(i=0;i<n;i++){
      cin >> af;
      if(i == 0){
	ans = a[af];
      }
      else{
	for(j=0;j<7;j++){
	  if(a[af][j] == a[be][j]) ans[j] = '0';
	  else ans[j] = '1';
	}
      }
      cout << ans << endl;
      be = af;
    }
  }
  return 0;
}

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

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

    string s;
    cin >> s;

    int n = s.length();

    char last = s[0];

    int count = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] != last) {
            ++count;
            last = s[i];
        }
    }

    cout << count - 1 << endl;

    return 0;
}


Measured memory_bytes: 512
def main():
	A, B =  map(int, input().split())

	ans = 0

	for n in range(A,B+1):
		dic = {}
		count = 0
		n = str(n)

		if n[0] == n[4]:
			if n[1] == n[3]:
				ans += 1

	print (ans)

"""			
			if a not in dic.keys():
				dic.update({a:1})
			else:
				val = dic.get(a)
				val += 1
				dic.update({a:val})
				count += 1

		if count ==3:
			ans += 1

		if (len(dic.keys())) == 3 and count ==2:
			ans += 1

		if n == 11111:
			print (count)
"""

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


Measured memory_bytes: 3060
S = input().strip()
K = 1
s = S[0]
cnt = 0
for i in range(1,len(S)):
    if S[i]==s and cnt==0:
        cnt += 1
    elif cnt==1:
        s = S[i-1]+S[i]
        cnt = 0
        K += 1
    elif S[i]!=s:
        cnt = 0
        s = S[i]
        K +=1
print(K)

Measured memory_bytes: 3500
#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 getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

map<int,int> num;

int main(void){
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	rep(i,n) num[x[i]]++;

	int ans = 0;
	for(auto &it:num){
		if(it.second < it.first)
			ans += it.second;
		else
			ans += it.second - it.first; 
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	long long int n;
	cin>>n;
	string s="";
	while(n!=0){
		long long int r=n%26;
		n=n/26;
		if(r!=0){
			s=(char)('a'+(r-1))+s;
		}
		else{
			s='z'+s;
			n=n-1;
		}
	}
	cout<<s<<endl;
	return 0;

}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

int n, a, b, c;
int sta, stb, stc;
vector<char> ans;
vector<string> q;
bool ok = false;

void rec(int i) {
    //cout << "abc: " << a << ' ' << b << ' ' << c << ' ' << i << endl;
    if (a < 0 || b < 0 || c < 0) return;
    if (i == n) {
        ok = true;
        cout << "Yes\n";
        for (auto shit : ans) {
            cout << shit << "\n";
        }
        return;
    }
    if (q[i] == "AB") {
       if (a >= b) {
            --a; ++b;
            ans[i] = 'B';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'A';
            a += 2;
            b -= 2;
            rec(i + 1);
            a--; b++;
            return;
       } else {
            --b; ++a;
            ans[i] = 'A';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'B';
            a -= 2;
            b += 2;
            rec(i + 1);
            b--; a++;
            return;
       }
    }
    if (q[i] == "AC") {
        if (a >= c) {
            --a; ++c;
            ans[i] = 'C';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'A';
            a += 2;
            c -= 2;
            rec(i + 1);
            --a; ++c;
            return;
       } else {
            --c; ++a;
            ans[i] = 'A';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'C';
            a -= 2;
            c += 2;
            rec(i + 1);
            --c; ++a;
            return;
       }
    }
    if (q[i] == "BC") {
       if (b >= c) {
            --b; ++c;
            ans[i] = 'C';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'B';
            b += 2;
            c -= 2;
            rec(i + 1);
            --b; ++c;
            return;
       } else {
            --c; ++b;
            ans[i] = 'B';
            rec(i + 1);
            if (ok) return;
            ans[i] = 'C';
            b -= 2;
            c += 2;
            rec(i + 1);
            --c; ++b;
            return;
       }
    }
}

void solve() {  
    cin >> n >> a >> b >> c;
    sta = a; stb = b; stc = c;
    ans.resize(n);
    q.resize(n);
    for (int i = 0; i < n; ++i) cin >> q[i];
    rec(0);
    if (!ok) {
        cout << "No\n";
        //assert(false);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 12700
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    map<ll, map<ll, int>> m;
    rep(i, n) rep(j, n) {
            if (i == j) continue;
            P a = v[i];
            P b = v[j];

            ll h = a.first - b.first;
            ll w = a.second - b.second;

            m[h][w]++;

        }

    int ma = 0;
    for (auto &e : m) {
        for (auto &f : e.second) {
            cmax(ma, f.second);
        }
    }
    cout << n - ma << endl;
}


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

int main(){
    int n, x, min, max;
    long int sum = 0; 
    min = 1000001;
    max = -1000001;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> x;
        
        if(x < min) min = x;
        if(x > max) max = x;
        
        sum += x;
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    vec h(n);
    rep(i, n) cin >> h[i];

    sort(all(h));

    int res = INF;

    for (int i = 0; i + k - 1 < n; i++) {
        res = min(res, h[i+k-1] - h[i]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[3010][3010];
ll mod = 998244353;
  
int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    dp[0][0] = 1;
    reps(i, 1, D - B + 1){
        (dp[0][i] = dp[0][i - 1] * A) %= mod;
        //fprintf(stderr, "k,l =(%d, %d), %d\n", 0, i, dp[0][i]);
    }
    reps(i, 1, C - A + 1){
        (dp[i][0] = dp[i - 1][0] * B) %= mod;
        //fprintf(stderr, "k,l =(%d, %d), %d\n", i, 0, dp[i][0]);
    }
    reps(k, 1, C - A + 1){
        reps(l, 1, D - B + 1){
            ll tmp1 = dp[k][l - 1] * (k + A) %mod;
            ll tmp2 = dp[k - 1][l] * (l + B) %mod;
            ll tmp3 = dp[k - 1][l - 1] * (k + A - 1) % mod;
            (tmp3 *= (l + B - 1)) %= mod;
            
            (dp[k][l] = tmp1 + tmp2) %= mod;
            (dp[k][l] += mod - tmp3) %= mod;
            
            
            //dp[k][l] = dp[k][l - 1] * (k + A) + dp[k - 1][l] * (l + B) - dp[k - 1][l - 1] * (k + A - 1) * (l + B - 1); //(k - 1)(l - 1);
            //fprintf(stderr, "k,l =(%d, %d), %d = %d * %d + %d * %d - %d * %d * %d\n", 
            //    k, l, dp[k][l], dp[k][l - 1], (A + 1), dp[k - 1][l], (B + 1), dp[k - 1][l - 1], (k + A - 1), (l + B - 1));
        }
    }
    cout << dp[C - A][D - B];
}



Measured memory_bytes: 74128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{  // freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
    iso;
  	 int n;
  	 cin>>n;
  	 cout<<(n-2)*180;

}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int X, A;
    cin >> X >> A;
    if(X < A){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		char[] a = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

		for (int i = 0; i < h; i++) {

			for(int j = 0; j < w; j++ ){
			String s = sc.next();


			if(s.equals("snuke")){
				System.out.print(a[j]);
				System.out.println(i+1);
			}
			}

		}


	System.out.println("");

		sc.close();
	}


}


Measured memory_bytes: 10248
#ABC079C - Train Ticket
import sys
S = list(input())
def dfs(i,f,s):
    if i == len(S)-1:
        if s == 7:
            print(f+"=7")
            sys.exit()
    else:
        return dfs(i+1, f+"+"+S[i+1], s+int(S[i+1])), dfs(i+1, f+"-"+S[i+1], s-int(S[i+1]))
dfs(0,S[0],int(S[0]))

Measured memory_bytes: 3064
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

  cin>>n>>m; V(int)w0,w1,w2,w3;
	rep(i,n){
		cin>>x>>y;
		if(!i){q=x; w0.eb(y); continue;}
		if(x==q)w0.eb(y);
		else if(x==q+1)w1.eb(y);
		else if(x==q+2)w2.eb(y);
		else w3.eb(y);
	}
	int s0=w0.size(),s1=w1.size(),s2=w2.size(),s3=w3.size();
	Int val,ans=0;
	sort(ALL(w0)); reverse(ALL(w0));
	sort(ALL(w1)); reverse(ALL(w1));
	sort(ALL(w2)); reverse(ALL(w2));
	sort(ALL(w3)); reverse(ALL(w3));
	rep(i,s0+1)rep(j,s1+1)rep(k,s2+1)rep(l,s3+1){
		if(i*q+j*(q+1)+k*(q+2)+l*(q+3)>m)continue;
		val=0;
		rep(i0,i)val+=w0[i0];
		rep(i0,j)val+=w1[i0];
		rep(i0,k)val+=w2[i0];
		rep(i0,l)val+=w3[i0];
		cmax(ans,val);
	}
	END
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N = int(input())
    Xs = [int(item) for item in input().split()]

    sorted_xs = sorted(Xs)

    for item in Xs:
        if item <= sorted_xs[(N-1)//2]:
            print(sorted_xs[N//2])
        else:
            print(sorted_xs[(N-1)//2])

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 30792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[100005];
int main()
{
	cin>>s;
	int len=strlen(s);
	int ans=0;
	for(int i=0;i<len-1;++i){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
from collections import deque

# BFSで通す
N, Q = map(int, input().split())  # N頂点, Q個の命令

G = [[] for _ in range(N)]
count = [0]*N
for i in range(N-1):  # 辺はN-1本
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)

for i in range(Q):  # Q個の操作について
    p, x = map(int, input().split())
    count[p-1] += x

q = deque([0])
flag = [False]*N

while len(q):
    v = q.pop()
    flag[v] = True
    for e in G[v]:  # vを親にもつノードについてループを回す
        if flag[e]:  # 頂点eに到達済みであれば
            continue
        count[e] += count[v]  # それぞれの子たちに親の値を伝播させる
        q.append(e)

print(*count)


Measured memory_bytes: 56168
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <string.h>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

struct node
{
	string s;
	int dist;

	node(string s , int dist)
	{
		this -> s = s;
		this -> dist = dist;
	}
};

int input[10];
map<string , int> m;
queue<node> q;

string swap(string s , int index1 , int index2)
{
	string ans = "";
	for (int i = 0;i < s.length();i ++)
	{
		if (i == index1)
			ans = ans + s[index2];
		else if (i == index2)
			ans = ans + s[index1];
		else
			ans = ans + s[i];
	}
	return ans;
}

void bfs()
{
	q.push(node("01234567" , 0));
	m["01234567"] = 0;

	int count = 0;
	while (!q.empty())
	{
		node no = q.front();
		q.pop();
		count ++;

		int i;
		for (i = 0;i < 8;i ++)
		{
			if (no.s[i] == '0')
				break;
		}
		// ?????¢i + 1 , i + 4
		if (i + 1 < 8 && (i + 1) % 4 != 0)
		{	
			string newStr = swap(no.s , i , i + 1);

			if (m.find(newStr) == m.end())
			{
				m[newStr] = no.dist + 1;
				q.push(node(newStr , no.dist + 1));
			}
		}

		if (i - 1 >= 0 && (i % 4 != 0))
		{
			string newStr = swap(no.s , i , i - 1);

			if (m.find(newStr) == m.end())
			{
				m[newStr] = no.dist + 1;
				q.push(node(newStr , no.dist + 1));
			}
		}

		if (i + 4 < 8)
		{
			string newStr = swap(no.s , i , i + 4);

			if (m.find(newStr) == m.end())
			{
				m[newStr] = no.dist + 1;
				q.push(node(newStr , no.dist + 1));
			}
		}

		if (i - 4 >= 0)
		{
			string newStr = swap(no.s , i , i - 4);

			if (m.find(newStr) == m.end())
			{
				m[newStr] = no.dist + 1;
				q.push(node(newStr , no.dist + 1));
			}
		}
	}
}

char toChar(int number)
{
	return (char) (number + '0');
}

int main()
{
	bfs();
	int i , j;
	while (scanf("%d" , &input[0]) != EOF)
	{
		string s;
		for (i = 1;i < 8;i ++)
			scanf("%d" , &input[i]);
		for (i = 0;i < 8;i ++)
			s = s + toChar(input[i]);

		printf("%d\n" , m[s]);
	}
	return 0;
}

Measured memory_bytes: 3484
#include <stdio.h>

int main(){
	int i, a, b, c;
	scanf("%d %d",&a,&b);
	c = 0;
	
	if(a>b){
		
			for(i=0;i<a;i++){
			b = b * 10;
			c = c + b;
			}
	}else {
		for(i=0;i<b;i++){
			a = a * 10;
			c = c + a;
		}
	}
	printf("%d",c/10);
}


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

#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 10e9+7

using namespace std;

int main(){
int P,Q,R;
cin >> P >> Q >> R;
cout << (P < Q ? (Q < R ? P + Q : P + R):(P < R ? P + Q : Q + R))<< endl;
return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#define pb push_back
int fa[200005], dep[200005], ans;
std::vector<int> adj_b[200005], adj_r[200005];
void init(int u, int f = -1)
{
	fa[u] = f;
	for (int v : adj_b[u])
	{
		if (v != f)
		{
			dep[v] = dep[u] + 1;
			init(v, u);
		}
	}
}
inline bool chk(int u, int v)
{
	int rem = 2;
	while (u != v && rem--)
	{
		int &x = dep[u] < dep[v] ? v : u;
		x = fa[x];
	}
	return u == v;
}
void dfs(int u, int len = 0, int f = -1)
{
	if (dep[u] > ans)
		ans = dep[u];
	if (dep[u] <= len)
		return;
	for (int v : adj_r[u])
	{
		if (v != f)
		{
			if (!chk(u, v))
			{
				puts("-1");
				throw false;
			}
			dfs(v, len + 1, u);
		}
	}
}
int main()
try
{
	// freopen("AGC005-E.in", "r", stdin);
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj_r[--u].pb(--v);
		adj_r[v].pb(u);
	}
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj_b[--u].pb(--v);
		adj_b[v].pb(u);
	}
	init(--b);
	dfs(--a);
	printf("%d\n", ans << 1);
	return 0;
}
catch (...)
{
	return 0;
}


Measured memory_bytes: 33536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  //白い石の累積和
  vector<ll> sumW(N + 1, 0);
  //黒い石の累積和
  vector<ll> sumB(N + 1, 0);
  sumW[0] = 0;
  sumB[0] = 0;
  for (ll i = 0; i < N; i++) {
    if (S[i] == '.') {
      sumW[i + 1] = sumW[i] + 1;
    } else {
      sumW[i + 1] = sumW[i];
    }
    if (S[i] == '#') {
      sumB[i + 1] = sumB[i] + 1;
    } else {
      sumB[i + 1] = sumB[i];
    }
  }

  ll ans = 100000;
  // 条件を満たす状態は以下の状態しかない
  // ↑黒黒黒黒黒黒黒
  // 白↑黒黒黒黒黒黒
  // 白白↑黒黒黒黒黒
  // ...
  // 白白白白白白白白↑
  for (ll i = 0; i <= N; i++) {
    //区間[0, i)にある黒を白にする
    //区間[i, N)にある白を黒にする
    ans = min(ans, sumB[i] + sumW[N] - sumW[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const long D = 1000000007;

int main()
{
  string a, b;
  cin >> a >> b;
  if (a.length() < b.length())
  {
    cout << "LESS" << endl;
  }
  else if (a.length() > b.length())
  {
    cout << "GREATER" << endl;
  }
  else
  {
    cout << (a > b ? "GREATER" : a == b ? "EQUAL" : "LESS") << endl;
  }
  return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int N, A, B;
cin >> N >> A >> B;

int ans = min(N * A, B);

print(ans);


 }

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

int n, k;
int a;
vector<int> g[100001];

int ans = 0;

int dfs(int v = 0, int t = 0)
{
  int d = 0;
  for (int i = 0; i < g[v].size(); i++){
    d = max(d, dfs(g[v][i], v) + 1);
  }

  if (d == k - 1 && t != 0){
    d = -1;
    ans++;
  }

  return d;
}

int main()
{
  cin >> n >> k;
  cin >> a;

  for (int i = 1; i < n; i++){
    int v;
    cin >> v;
    g[v - 1].push_back(i);
  }

  dfs();
  cout << (a != 1) + ans << endl;
}



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

typedef struct {
	char value[3];
	int key;
} card;

void bubbleSort(card *, int);
void selectionSort(card *, int);
void swap(char *, char *);
int isStable(card *, int);

int main() {
	int n, i;
	scanf("%d", &n);
	card *a = (card *)malloc(n * sizeof(card));
	card *b = (card *)malloc(n * sizeof(card));

	for (i = 0; i < n; i++) {
		scanf("%s", a[i].value);
		strcpy(b[i].value, a[i].value);
		a[i].key = i;
		b[i].key = i;
	}
	bubbleSort(a, n);
	for (i = 0; i < n - 1; i++) printf("%s ", a[i].value);
	printf("%s\n", a[i].value);
	(isStable(a, n)) ? printf("Stable\n") : printf("Not stable\n");

	selectionSort(b, n);
	for (i = 0; i < n - 1; i++) printf("%s ", b[i].value);
	printf("%s\n", b[i].value);
	(isStable(b, n)) ? printf("Stable\n") : printf("Not stable\n");

}

void bubbleSort(card *a, int max) {
	int i, j;
	for (i = 0; i < max; i++) {
		for (j = max - 1; j > i; j--) {
			if (a[j].value[1] < a[j - 1].value[1]) {
				swap(a[j].value, a[j - 1].value);
			}
		}
	}
}

void selectionSort(card *a, int max) {
	int needSwap = 0, minIx = 0;
	int i, j;
	for (i = 0; i < max; i++) {
		minIx = i;
		for (j = i; j < max; j++) {
			if (a[j].value[1] < a[minIx].value[1]) {
				minIx = j;
				needSwap = 1;
			}
		}
		if (needSwap) {
			swap(a[i].value, a[minIx].value);
			needSwap = 0;
		}
	}
}

void swap(char *p1st, char *p2nd) {
	for (int curByte = 0; curByte < sizeof(card); curByte++) {
		char byteCopy = p1st[curByte];
		p1st[curByte] = p2nd[curByte];
		p2nd[curByte] = byteCopy;
	}
}

int isStable(card *check, int max) {
	int i;
	for (i = 1; i < max; i++) {
		if (check[i-1].value[1] == check[i].value[1] && check[i - 1].key > check[i].key) return 0;
	}
	return 1;
}


Measured memory_bytes: 2052
from collections import Counter,defaultdict,deque
def main():
    N=int(input())
    edge = [[]for _ in range(N)]
    for i in range(N-1):
        u,v,w = map(int,input().split())
        u,v = u-1,v-1
        edge[u].append((v,w))
        edge[v].append((u,w))
    color = [-1]*N
    color[0]=0
    queue = deque([(0,0)])
    while queue:
        v,col = queue.popleft()
        for to,dist in edge[v]:
            if color[to]!=-1:
                continue
            c = (col+dist)%2  # 色
            color[to] = c
            queue.append((to,c))
    print(*color,sep="\n")
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 71840
// glory be to the sky
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


ll arr[200005];

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	ll t;
	cin >> n >> t;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	ll curr = arr[0] + t, ans = t;
	for (int i = 2; i <= n; i++) {
		if (arr[i] - arr[i - 1] < t) {
			ans -= t;
			ans += arr[i] - arr[i - 1];
			curr = curr - t + arr[i] - arr[i - 1] + t;
			ans += t;
		}
		else { 
			curr += (arr[i] - (arr[i - 1] + t));
			ans += t;
		}
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
 
int main() {
	std::string s;
	std::cin >> s;
	int nSum = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'C') {
			for (int j = i + 1;j < s.size();j++) {
				if (s[j] == 'F') {
					nSum += 1;
				}
			}
		}
	}
	if (nSum == 0) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,i,j;
	cin>>a;
	for(i=1;i<=9;i++)
		for(j=i;j<=9;j++)
		{
			if(i*j==a)
			{
				cout<<"Yes";
				exit(0);
			}
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B;
    
    int ans = 0;
    
    ans = max(A + A - 1, ans);
    ans = max(B + B - 1, ans);
    ans = max(A + B, ans);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

minus_cnt_is_even = True
has_zero = False
min_a = 1000000000
sum_a = 0
for item in a:
    if item < 0:
        item = -item
        minus_cnt_is_even = not minus_cnt_is_even
    elif item == 0:
        has_zero = True
    min_a = min(min_a, item)
    sum_a += item
if has_zero or minus_cnt_is_even:
    print(sum_a)
else:
    print(sum_a - min_a*2)

Measured memory_bytes: 15180
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int l[n];
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
	}
	int d;
	d=0;
	for(int i=1;i<n+1;i++)
	{
		d+=l[i-1];
		if(d>k) 
		{
		cout<<i;
	    return 0;
		}
	}
	if(d<=k) cout<<n+1;
	

}

Measured memory_bytes: 256
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int 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; }
    const int MAX =3001;
const int MOD =998244353;
int 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;
    }
}

// 二項係数計算
int 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;
}
  
  
signed main(){
  COMinit();
int n,x;
cin>>n>>x;
int dp[x][n+1];
for(int i=0;i<x;i++)for(int j=0;j<=n;j++){
  if(j==0)dp[i][j]=(i==0);
  else dp[i][j]=dp[i][j-1];
  if(i>=1&&j>=1)dp[i][j]=(dp[i][j]+dp[i-1][j-1])%MOD;
  if(i>=2&&j>=1)dp[i][j]=(dp[i][j]+dp[i-2][j-1])%MOD;
}
int ans=0;
for(int i=0;i<x;i++)ans=(ans+dp[i][n])%MOD;
for(int i=2;i<=x-1;i+=2)for(int j=0;j+i<=n;j++)ans=(ans+COM(j+i-1,j)*dp[x-1-i][n-i-j]%MOD)%MOD;
if(x%2)for(int i=x;i<=n;i++)ans=(ans+COM(n,i))%MOD;
cout<<ans<<endl;


}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n], b[n];
    vector<ll> plus;
    ll minus = 0;
    ll suma = 0, sumb = 0;
    ll cnt = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        suma += a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
        sumb += b[i];
    }
    if(suma < sumb){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        ll diff = a[i] - b[i];
        if(diff > 0){
            plus.push_back(diff);
        }else if(diff < 0){
            minus += (-1) * diff;
            cnt++;
        }
    }
    sort(plus.rbegin(), plus.rend());
    int idx = 0;
    while(minus > 0){
        minus -= plus[idx];
        idx++;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main(){
    int n;
    cin >> n;
    if(n == 1)
    {
        cout << 0 << "\n";
        return 0;
    }
    ll a = 1, b = 1, c = 1;
    for (int i = 1; i <= n; i++){
        a = (a * 10) % MOD;
        b = (b * 9) % MOD;
        c = (c * 8) % MOD;
    }
    cout << (a - 2 * b + c + MOD * 2) % MOD  << "\n";
}

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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B;
    int R = C + D;
    if (L > R)
    {
        cout << "Left" << endl;
    }
    if (L == R)
    {
        cout << "Balanced" << endl;
    }
    if (L < R)
    {
        cout << "Right" << endl;
    }
}


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

int mod = 1'000'000'007;

long long modpow(long long a, long long b, int p){
    if (b == 0) return 1;
    if (b % 2) return a * modpow(a, b - 1, p) % p;
    return modpow(a, b / 2, p) * modpow(a, b / 2, p) % p;
}

int main(){
    string s;
    cin >> s;
    int k = s.size();
    vector<long long> dp(13, 0);
    dp[0] = 1;
    for (int i = 0; i < k; i++){
        vector<long long> next_dp(13, 0);
        long long tmp = modpow(10, k - i - 1, 13);
        if (s[i] == '?'){
            for (int j = 0; j < 13; j++) {
                for (int z = 0; z < 10; z++){
                    next_dp[(tmp * z % 13 + j) % 13] += dp[j];
                    next_dp[(tmp * z % 13 + j) % 13] %= mod;
                }
            }
        }
        else {
            for (int j = 0; j < 13; j++){
                next_dp[(tmp * (s[i] - '0') % 13 + j) % 13] += dp[j];
                next_dp[(tmp * (s[i] - '0') % 13 + j) % 13] %= mod;
            }
        }
        dp = next_dp;
    }
    cout << dp[5] % mod << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>imos(100001);
  vector<pair<ll,pair<ll,ll>>> a(n);
  for(i=0;i<n;i++){
    cin>>a[i].second.first>>a[i].second.second>>a[i].first;
  }
  sort(ALL(a));
  j=0;
  buf=INF;
  for(i=1;i<=k&&j<n;i++){
    for(;a[j].first==i&&j<n;j++){
      if(buf==a[j].second.first)a[j].second.first++;
      buf=a[j].second.second;
    }
    buf=INF;
  }


  for(i=0;i<n;i++){
    imos[a[i].second.first-1]++;
    imos[a[i].second.second]--;
  } 
  buf=0;
  for(i=0;i<=100000;i++){
    buf+=imos[i];
    chmax(result,buf);
    //cout<<buf<<endl;
  }
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 3456
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

int f[303][303];
bool vis[303];
int t[303],r[303];

int main() {
    int n,m,i,j;
    scanf("%d%d",&n,&m);
    for(i = 1; i <= n; i++) {
        r[i] = 1;
        for(j = 1; j <= m; j++) scanf("%d",&f[i][j]);
    }
    int ans = n;
    while(1) {
        memset(t,0,sizeof(t));
        for(i = 1; i <= n; i++) {
            while(r[i] <= m) {
                if(!vis[f[i][r[i]]]) {
                    t[f[i][r[i]]]++;
                    break;
                }
                r[i]++;
            }
            if(r[i] > m) {
                printf("%d\n",ans);
                return 0;
            }
        }
        int d = 0;
        for(i = 1;i <= m; i++) {
                d = max(d,t[i]);
                //cout<<t[i]<<" ";
        }
        //cout<<endl;
        ans = min(d,ans);
        for(i = 1;i <= m; i++) {
            if(t[i] == d) break;
        }
        vis[i] = 1;
        //cout<<i<<" "<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n),x[n],y[n];
  vector<bool> people(n,false);
  for(int i=0;i<n;i++){
    cin >> a[i];
    for(int j=0;j<a[i];j++){
      ll tx,ty;
      cin >> tx >> ty;
      tx--;
      x[i].push_back(tx);
      y[i].push_back(ty);
    }
  }
  for(ll i=0;i<(1ll<<n);i++){
    ll cnt = 0;
    bool can=true;
    fill(people.begin(),people.end(),false);
    for(ll j=0;j<n;j++){
      if(i&(1ll<<j)){
        people[j]=true;
        cnt++;
      }
    }
    for(ll j=0;j<n;j++){
      if(people[j]){
        for(int k=0;k<a[j];k++){
          if(people[x[j][k]]!=y[j][k]){
            can = false;
          }
        }
      }
    }
    if(can){
      ans = max(ans,cnt);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define show(x) cerr << #x << x << endl

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

int n, k;
int a[100001];
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("C:\\Users\\naruse\\CLionProjects\\competitive\\cmake-build-debug\\in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = INT_INF;
    for (int i = 0; i <= n - k; i++) {
        int b = a[i + k - 1] - a[i];
        chmin(ans, b);
    }
    cout << ans << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
long long int gcd(long long int x,long long int  y){
   if(y==0)return x;
   return gcd(y,x%y);
}
long long exp(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = exp(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int prime(long long x){
if(x%2==0)

    return 0;
else{
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)
            return 0;
    }
}
return 1;
}
//main
int main() {
IOS;
int k=0;
string s,a="R",b="RR",c="RRR";
cin>>s;
if(s.find(a)>=0&&s.find(a)<3)
k=1;
if(s.find(b)>=0&&s.find(b)<3)
    k=2;
if(s.find(c)>=0&&s.find(c)<3)k=3;
cout<<k<<"\n";
return 0;
}


Measured memory_bytes: 3636