akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N;
int P[200005];
int C[200005];
int Stack[200005];
bool Use[200005], Forest[200005];
vector <int> G[200005], Cycle,GG[200005];
bool ok, V[200005], cyc;
int Pos[200005], top;
int X[200005][2];
int DP[200005];
map <int, int> M[200005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        cin >> P[i];
        G[P[i]].push_back(i);
        GG[i].push_back(P[i]);
        GG[P[i]].push_back(i);
        M[P[i]][i]++;

        if(M[P[i]][i] == 1 && M[i].find(P[i]) != M[i].end())
        {
            Cycle.push_back(i);
            Cycle.push_back(P[i]);
            cyc = 1;
            Forest[i] = Forest[P[i]] = 1;
        }
    }

}

void DFS(int node, int father)
{
    Use[node] = 1;
    Stack[++top] = node;
    Pos[node] = top;
    for(int i = 0; i < GG[node].size(); i++)
    {
        int neighb = GG[node][i];
        if(neighb == father)
            continue;
        if(Use[neighb] == 0)
        {
            DFS(neighb, node);
        }
        else
        {
            if(Cycle.size() == 0)
            for(int j = Pos[neighb]; j <= top; j++)
                Cycle.push_back(Stack[j]), Forest[Stack[j]] = 1;
        }
    }
    --top;
}

void DFS2(int node)
{

    for(int i = 0;i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(Forest[neighb] == 1)
            continue;
        DFS2(neighb);

    }
    for(int i = 0; i < G[node].size() + 2; i++)
        V[i] = 0;
    for(int i = 0; i < G[node].size(); i++)
        if(Forest[G[node][i]] == 0)
            V[DP[G[node][i]]] = 1;
    int cnt = -1;
    for(int i = 0; i < G[node].size() + 2 && cnt < 1; i++)
        if(V[i] == 0)
            X[node][++cnt] = i;
    DP[node] = X[node][0];
}

void DFS3(int val, int node)
{
    int x = P[node];
    DP[node] = val;
    while(x != node)
    {
        for(int i = 0; i < G[x].size() + 2; i++)
        V[i] = 0;
    for(int i = 0; i < G[x].size() ; i++)
        V[DP[G[x][i]]] = 1;
    int cnt = -1;
    for(int i = 0; i < G[x].size() + 2; i++)
        if(V[i] == 0)
        {
            DP[x] = i;
            break;
        }
    x = P[x];
    }
}

bool check()
{
    for(int node = 1; node <= N; node++)
    {
        for(int i = 0; i < G[node].size() + 2; i++)
        V[i] = 0;
    for(int i = 0; i < G[node].size(); i++)
        V[DP[G[node][i]]] = 1;
    int cnt = -1;
    for(int i = 0; i < G[node].size() + 2; i++)
        if(V[i] == 0)
        {
            if(i < DP[node])
                return 0;
        }
    if(V[DP[node]] == 1)
        return 0;
    }
    return 1;
}
int main()
{
    Read();
    if(N == 2)
    {
        cout << "POSSIBLE\n";
        return 0;
    }
    if(cyc == 0)
    DFS(1, 0);
    for(int i = 0; i < Cycle.size(); i++)
        DFS2(Cycle[i]);
    DFS3(X[Cycle[0]][0], Cycle[0]);
    int ans = check();
    DFS3(X[Cycle[0]][1], Cycle[0]);
    ans = max(ans, (int)check());
    if(ans == 1)
        cout << "POSSIBLE\n";
    else
        cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 59772
#include <stdio.h>

#define MAX (999999)

int main(void)
{
	int i, j;
	int p[MAX] = {0};
	// ツェツ素ツ青板表ツ催ャツ青ャツづ可使ツづつスツェ
	int n, ans;
	
	// ツつアツづつゥツづァツ素ツ青板表ツ催ャツ青ャ
	p[0] = 1;
	for (i = 2; i <= (MAX / 2); i++){
		for (j = 2; (i * j) <= MAX; j++){
			if (p[(i * j) - 1] == 0){
				p[(i * j) - 1] = 1;
			}
		}
	}
	// ツつアツつアツづ慊づ！
	
	// ツ本ツ氾板つ「ツづつュツづヲツー
	while (scanf("%d", &n) != EOF){
		ans = 0;
		for (i = 0; i < n; i++){
			if (p[i] == 0){
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 4320
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

for Ai in A:
    ans += 1/Ai

ans = 1 / ans

print(ans)




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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

int main()
{
    long long H;
    cin >> H;
    long long sum = 0;
    long long now = 1;
    for (int i = 1;; i++)
    {
        sum += now;
        now *= 2;
        if(now>H){
           // sum = i;
            break;
        }
    }
    cout << sum<< endl;

}


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

ll gcd(ll a,ll b){return a%b==0?b:gcd(b,a%b);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	string s,t;cin >> s >> t;
	ll g=gcd(n,m),l=n/g*m;
	ll N=n/g,M=m/g;
	rep(i,g){
		if(s[i*N]!=t[i*M]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d));

	return 0;
}

Measured memory_bytes: 3636
//Volume0-0086
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


public class Main {

	private static TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();

	public static void main(String[] args) {

		//declare
		Iterator<Map.Entry<Integer, Integer>> I;
		String[] s;
		String   result;
		boolean flg;
		int i,v;

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	map.clear();
        	out:while(true){
        		s = sc.nextLine().split("\\s");
        		for(i=0;i<2;i++){
        			v = Integer.parseInt(s[i]);

        	    	//calculate
        			if(v == 0){break out;}
        			if   (map.containsKey(v)){ map.put(v,map.get(v)+1);}
        			else                     { map.put(v,1);           }
        		}
        	}

        	map.put(1,map.get(1)+1);
        	map.put(2,map.get(2)+1);

        	flg = true;
        	I = map.entrySet().iterator();
        	while(I.hasNext()){
       			if (I.next().getValue()%2 != 0){
       				flg = false;
       				break;
       			}
   			}
        	if   (flg){result = "OK";}
        	else      {result = "NG";}

        	//output
        	System.out.println(result);
        }
	}
}

Measured memory_bytes: 23048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;


//?????????????????????????????????????????????????????????????\¨??°
int calc(string _input)
{
 //   cout << _input << endl;


    if(_input[0] != '[')
    {
      //  cout << stoi(_input) / 2 + 1 << endl;
        return stoi(_input) / 2 + 1;
    }

    auto in_size = _input.size();
    vector< int > vote_num(0);

    auto count = 0;
    auto start_index = 0;

    for(int i = 0; i < in_size; i++)
    {
        if(_input[i] == '[')
        {
            count++;
        }
        if(_input[i] == ']')
        {
            count--;
        }

        if(count == 0)
        {
            vote_num.push_back( calc(_input.substr(start_index + 1, i - start_index - 1) ) );
            start_index = i + 1;
        }
    }

    sort(vote_num.begin(), vote_num.end());

    int ans = 0;
    for(int i = 0; i < vote_num.size() / 2 + 1; i++)
        ans += vote_num[i];

    return ans;
}

int main()
{
    auto n = 0;
    cin >> n;

    string input;

    for(int i = 0; i < n; i++)
    {
        cin >> input;
        cout << calc(input) << endl;
    }

    return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B;
	scanf("%d%d", &A, &B);

	bool can = false;

	for (int i = 1; i <= 3; i++) {
		if (A*B*i % 2 == 1) {
			can = true;
		}
	}
	if (can) {
		printf("Yes");

	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 128
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-19 17:03:27
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
  #define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int64> a(n); cin >> a;

  // -+-+-+-+...
  // +-+-+-+-...

  int64 ans1 = 0, ans2 = 0;
  int64 sum1 = 0, sum2 = 0;

  for (int i = 0; i < n; ++i) {
    if (i & 1 && sum1 + a[i] <= 0) {
      ans1 += abs(sum1 + a[i]) + 1;
      sum1 = 1;
    } else if (!(i & 1) && sum1 + a[i] >= 0) {
      ans1 += abs(sum1 + a[i]) + 1;
      sum1 = -1;
    } else {
      sum1 += a[i];
    }
  }

  for (int i = 0; i < n; ++i) {
    if (!(i & 1) && sum2 + a[i] <= 0) {
      ans2 += abs(sum2 + a[i]) + 1;
      sum2 = 1;
    } else if (i & 1 && sum2 + a[i] >= 0) {
      ans2 += abs(sum2 + a[i]) + 1;
      sum2 = -1;
    } else {
      sum2 += a[i];
    }
  }

  debug(ans1, ans2);
  cout << min(ans1, ans2) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    deque<char> st;
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='B'&&!st.empty()){
            st.pop_back();
        }
        else if(s[i]=='B')continue;
        else{
            st.push_back(s[i]);
        }
    }
    while(!st.empty()){
        cout<< st.front();
        st.pop_front();
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n;i++)cin >> b[i];
    for(int i = 0;i < n;i++)cin >> c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<ll> cnt_ba(n); 
    cnt_ba[0] = (ll)(lower_bound(a.begin(),a.end(),b[0]) - a.begin());
    for(int i = 1;i < n;i++){
        cnt_ba[i] = cnt_ba[i-1] + (ll)(lower_bound(a.begin(),a.end(),b[i]) - a.begin());
    }    

    ll ans = 0;
    for(int i = 0;i < n;i++){
        int index = lower_bound(b.begin(),b.end(),c[i]) - b.begin();
        index--;
        if(index >= 0)ans += cnt_ba[index];
    }

    cout << ans << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String q = sc.next();
        int count = 0;
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(i) == q.charAt(i)) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll a,b,c;
    std::cin >> a>>b>>c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    ll n[3] = {a,b,c};
    sort(n,n+3);

    
    std::cout << n[0]*n[1] << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int N;
int ans = 0;

void dfs(ll k){
    if(k>N) return;
    int a = 0;
    int b = 0;
    int c = 0;
    ll t = k;
    while(t){
        if(t%10==3) a++;
        else if(t%10==5) b++;
        else if(t%10==7) c++;
        t/=10;
    }
    
    if(a>=1 && b>=1 && c>=1) ans++;
    
    dfs(10*k+3);
    dfs(10*k+5);
    dfs(10*k+7);
}


int main() {
    cin >> N;
    dfs(0);
    
    cout << ans << endl;
    return 0;
    
}





Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int main(){

	int N,upper_Pal,down_Pal,length,tmp,work;
	queue<int> Q;

	scanf("%d",&N);

	for(int num = N; num >= 0; num--){
		tmp = num;
		for(length = 0; tmp > 0; length++){
			Q.push(tmp%10);
			tmp /= 10;
		}

		work = 0;
		for(int k = 1; k <= length; k++){
			work += Q.front()*pow(10,length-k);
			Q.pop();
		}

		if(work == num){
			down_Pal = num;
			break;
		}
	}

	for(int num = N+1; num <= 10001; num++){
		tmp = num;
		for(length = 0; tmp > 0; length++){
			Q.push(tmp%10);
			tmp /= 10;
		}

		work = 0;
		for(int k = 1; k <= length; k++){
			work += Q.front()*pow(10,length-k);
			Q.pop();
		}

		if(work == num){
			upper_Pal = num;
			break;
		}
	}

	if(abs(upper_Pal - N) < abs(down_Pal-N)){
		printf("%d\n",upper_Pal);
	}else{
		printf("%d\n",down_Pal);
	}

	return 0;
}

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

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

    return 0;
}


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

int main()
{
  string s;
  cin >> s;
    
  int min_diff = 1000;
  for(int i = 0; i < s.length() - 2; i++)
  {
    int three_num = std::stoi(s.substr(i, 3));
    int diff = abs(three_num - 753);
    if( diff < min_diff)
      min_diff = diff;
  }
    
  cout << min_diff;
  return 0;
}


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

int main() {
  ll n;
  string s;
  cin >> n >> s;

  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
  for (ll i = n - 1; i >= 0; i--) {
    for (ll j = n - 1; j >= 0; j--) {
      if (s[i] == s[j]) {
        dp[i][j] = dp[i+1][j+1] + 1;
      } else {
        dp[i][j] = 0;
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      if (dp[i][j] <= abs(i - j)) {
        ans = max(ans, dp[i][j]);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 195840
import sys

N, M, C = map(int, input().split())
b_list = list(map(int, input().split()))
a_list = [ list(map(int, input().split())) for i in range(N) ]

#print(N, M, C, b_list, a_list)

ans = 0

for i in range(len(a_list)):
    tmp = 0
    for j in range(len(a_list[i])):
        tmp += a_list[i][j] * b_list[j]
    if tmp + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3064
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
n=int(input())
prev=0
l=[]
for i in range(n):
	l.append(list(map(int,input().split())))
z=[[0,0,0] for i in range(n)]
z[0]=l[0]
for i in range(1,n):
	z[i][0]=l[i][0]+max(z[i-1][1],z[i-1][2])
	z[i][2]=l[i][2]+max(z[i-1][1],z[i-1][0])
	z[i][1]=l[i][1]+max(z[i-1][0],z[i-1][2])
print(max(z[-1]))

Measured memory_bytes: 98216
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, a[N], ans, sum, res[N], pref[N];
map <int, int> cnt;
main() {
    file("stars");
    ios;
    cin >> n >> k;
    ++cnt[0];
    fo(i, 1, n, 1) {
        cin >> a[i];
        --a[i];
        pref[i] = pref[i - 1] + a[i];
        pref[i] %= k;
        if (i >= k) --cnt[pref[i - k]];
        ans += cnt[pref[i]]++;
    }
    cout << ans;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**
0 1 1 2 3

pref[r] - pref[l - 1] % k == r - l % k
pref[r] - r == pref[l - 1] - l;
*/


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

#define ff first
#define ss second
#define pb push_back

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

const int N = 100005;

int main() {
	int n, r;
	scanf("%d %d", &n, &r);
	if(n >= 10){
		printf("%d\n", r);
	}
	else{
		printf("%d\n", 100 * (10 - n) + r);
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,N,A[100010],P[100010];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    P[A[i]-1]=i+1;
  }
  for(i=0;i<N;i++){
    printf("%d ",P[i]);
  }
  printf("\n");  
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	cout<<setprecision(10);
	ll i,j,k,m,n,t;
	long double x;
	cin>>x;
	x/=3.0;
	x=x*x*x;
	cout<<x;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 2000;
const int INF = (1<<30);
struct edge{
    int to; edge *nxt;
}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt=&edges[0];
void addedge(int u, int v) {
    edge *p = (++ecnt);
    p->to = v, p->nxt = adj[u], adj[u] = p;
    p = (++ecnt);
    p->to = u, p->nxt = adj[v], adj[v] = p;
}
int a[MAXN + 5], N;
int f[MAXN + 5], s[MAXN + 5];
void dfs(int x, int fa) {
    s[x] = a[x], f[x] = 0;
    for(edge *p=adj[x];p;p=p->nxt) {
        if( p->to == fa ) continue;
        dfs(p->to, x), s[x] += s[p->to];
        f[x] += f[p->to] + s[p->to];
    }
}
int get(int x, int fa) {
    int mx = 0;
    for(edge *p=adj[x];p;p=p->nxt) {
        if( p->to == fa ) continue;
        if( mx == 0 || f[p->to] > f[mx] ) mx = p->to;
    }
    if( mx == 0 ) return 0;
    int k = get(mx, x) + s[mx];
    if( f[x] - f[mx] - s[mx] >= k ) return f[x] & 1;
    else return k - (f[x] - f[mx] - s[mx]);
}
char S[MAXN + 5];
int main() {
    scanf("%d%s", &N, S + 1);
    for(int i=1;i<=N;i++) a[i] = S[i] - '0';
    for(int i=1;i<N;i++) {
        int u, v; scanf("%d%d", &u, &v);
        addedge(u, v);
    }
    int ans = INF;
    for(int j=1;j<=N;j++) {
        dfs(j, 0);
        if( get(j, 0) == 0 )
            ans = min(ans, f[j]/2);
    }
    if( ans == INF ) printf("-1\n");
    else printf("%d\n", ans);
}

Measured memory_bytes: 504
//連想配列 ARC_081_Cの解答 //ABC073でも復習できます。
/*
int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin>>a.at(i);
  map<ll,ll>mp;
  rep(i,n){
    mp[a.at(i)]++;
  }
  ll one  = 0;
  ll two = 0;
  for(auto p:mp){
//    cout << p.first << " " << p.second << endl;
    if(p.second >= 2){
      if(one <= p.first){
        two = one;
        one = p.first;
      }
    }
    if(p.second >= 4){
      if(one <= p.first){
        two = p.first;
        one = p.first;
      }
    }
  }
//  cout << one << endl;
//  cout << two << endl;
//  cout << endl;
  cout << one * two << endl;
}
*/

//#define pi 3.14159265359
//桁数を指定して出力する方法
//#include <iomanip>//これをincludeしておかないといけない
//cout << fixed << setprecision(20)<< ans << endl;

//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//getline(cin, s); //空白文字を含むものをまとめて入力できる。
//s配列に格納した単語を、辞書順にソートする
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列を格納できる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s; cin >> s;
  int n; cin >> n;
  vector<int>a(n); vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//10のi乗pow(10, i);//ただしdouble型のため注意
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}

int keta(int n){
  int wa = 1;
  while(n>0){
    wa *=10;
    n--;
  }
  return wa;
}

int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin>>a.at(i);
  map<ll,ll>mp;
  rep(i,n){
    mp[a.at(i)]++;
  }
  ll one  = 0;
  ll two = 0;
  for(auto p:mp){
//    cout << p.first << " " << p.second << endl;
    if(p.second >= 2){
      if(one <= p.first){
        two = one;
        one = p.first;
      }
    }
    if(p.second >= 4){
      if(one <= p.first){
        two = p.first;
        one = p.first;
      }
    }
  }
//  cout << one << endl;
//  cout << two << endl;
//  cout << endl;
  cout << one * two << endl;
}

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

int main() {
	int num,count;
	string n;
	num = count = 0;


	cin >> n;
	while (n.length() != count) {
		num += (int)(n[count]-'0');
		count++;
	}

	if (num % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <random>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    random_device seed_gen;
    mt19937 rand(seed_gen());
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e3;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


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

int main(void){
    int n,k,sum=0;
    cin >> n >> k;
    int h[n];
    for(int i=0; i <n; i++) cin >> h[i];

    for(int i=0; i <n; i++){
        if(h[i] >= k) sum++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<stack>
#include<set>
using namespace std;
long long a, b, c;
int main()
{
	scanf("%lld%lld.%lld",&a,&b,&c);
	b=b*100+c;
	c=a*b/100;
	printf("%lld",c);
	return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"



signed main()
{
    FAST;
    int t;
    t=1;
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        int a[n];
        
        for(i=0;i<n;i++)
        {
            
            cin>>a[i];
            
            ans = (ans^a[i]);
        }
        
        for(i=0;i<n;i++)
        {
            cout<<(ans^a[i])<<" ";
        }
        cout<<endl;
        
        
        
        
    }
        
    
    
    
    
}

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

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

int main(){
    ll n,weight;
    ll v[105],w[105],m[105];
    cin>>n>>weight;
    REP(i,n){
        cin>>v[i]>>w[i]>>m[i];
    }
    ll dp[10005]={};
    REP(i,n){
        for(int k=0; m[i]>0; k++){
            ll key = std::min(m[i], (ll)1<<k);
            m[i] -= key;
            for(int j=weight; j>=key*w[i]; j--){
                dp[j] = std::max(dp[j], dp[j-key*w[i]] + key*v[i]);
            }
        }
    }
    ll ans=0;
    REP(i,weight+1) ans = std::max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[][] charTable = new int[n][26];
		StringBuilder res = new StringBuilder();
		
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			
			for (char c: s.toCharArray()) {
				charTable[i][c - 'a']++;
			}
		}
		
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 26; j++) {
				charTable[0][j] = Math.min(charTable[0][j], charTable[i][j]);
			}
		}
		
		for (int i = 0; i <= 25; i++) {
			if (charTable[0][i] != 0) {
				for (int j = 0; j < charTable[0][i]; j++) {
					res.append((char)('a' + i));
				}
			}
		}
		System.out.println(res.toString());
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        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());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22996
#include <stdio.h>

int main() {
	int Xz;
    long long int Zx[100004], ent = 1;
    scanf("%lld", &Xz);
    for (int i = 0; i < Xz; i++) {
        scanf("%lld", &Zx[i]);
    }
    for (int i = 0; i < Xz; i++) {
        if (Zx[i] == 0) {
            printf("0");
            return 0;
        }
    }
    for (int i = 0; i < Xz; i++) {
        if (Zx[i] <= (1000000000000000000 / ent)) {
            ent *= Zx[i];
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", ent);
    
}


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

long long GCD (long long a, long long b)
{
    long long t;
    if (a>b) swap(a,b);
    while (1)
    {
        t=b%a;
        if (t==0) break;
        b=a;
        a=t;
    }
    return a;
}

int main()
{
    long long a,b,gcd[50],lcm[50],c=0;
    while (cin>>a>>b)
    {
        gcd[c]=GCD(a,b);
        lcm[c]=a*b/gcd[c];
        c++;
    }
    for (int i=0; i<c; i++) cout<<gcd[i]<<" "<<lcm[i]<<'\n';
    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
long long n,k,tmp,h[10000000],F[10000000];
int main()
{
    //freopen("FROG2.INP","r",stdin);
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>h[i];
    for (int i=2;i<=n;i++)
    {
        F[i]=10E15;
        for (int j=1;j<=k;j++)
            if (i-j>0) F[i]=min(F[i-j]+abs(h[i]-h[i-j]),F[i]);
    }
    cout<<F[n]<<endl;
    return 0;
}



Measured memory_bytes: 3072
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1,s2;

	//IntStack yStack;
	//charStack Stack;

	cin >> a;
	cin >> s;
	cin >> s1;
	cin >> s2;
	for (int i = 0; i < a; i++)
	{
		if (s[i]==s1[i]&&s1[i]==s2[i])
		{

		}
		else if(s[i]!=s1[i]&&s1[i]!=s2[i]&&s2[i]!=s[i])
		{
			ans+=2;
		}
		else
		{
			ans++;
		}
	}
	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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


int main() {
	int N, M;
	cin >> N >> M;
	int minimum = 0;
	int maximum = N - 1;
	for(int i = 0; i < M; i++){
		int L, R;
		cin >> L >> R;
		L--;
		R--;
		minimum = max(minimum, L);
		maximum = min(maximum, R);
	}
	cout << max(maximum - minimum + 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  bool y = false;
  cin >> s;
  
  for(int i=0; i<3; i++){
    if(s.at(i)=='7') y = true;
  }

  if(y) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

long long n;
vector<long long> a;

int main()
{
    cin >> n;
    a.resize(n);
    for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long sus = 0;
    long long ans = 0;
    for (long long i = n - 1; i >= 0; i--)
    {
        if (a[i] > sus)
        {
            sus = a[i];
            ans += a[i];
        }
        sus--;
        sus = sus > 0 ? sus : 0;

        if (i < n-1 && a[i] < a[i+1]-1)
        {
            cout << "-1\n";
            return 0;
        }
    }
    if (sus > 0 || a[0] > 0)
        ans = -1;
    cout << ans << "\n";
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter cout = new PrintWriter(System.out);

        int n = cin.nextInt();
        cin.nextLine();
        String s = cin.nextLine();

        int cnt = 1;
        char last = s.charAt(0);
        for(int i=1;i<n;i++) {
            char cur = s.charAt(i);
            if(last == cur) continue;
            else cnt++;
            last = cur;
        }

        cout.println(cnt);
        cout.close();
    }
}

Measured memory_bytes: 26300
l = int(input())
a = input()
b = input()

if len(a) > len(b):
    k = b
    b = a
    a = k

mina = None
maxa = None
"""
f = [None] * (l + 1)

f[0] = ''
#print(f)
for i in range(l):
    tmpa = None
    tmpb = None
    if i + 1 >= len(a) and f[i + 1 - len(a)] is not None:
        tmpa = a + f[i + 1 - len(a)]
    if i + 1 >= len(b) and f[i + 1 - len(b)] is not None:
        tmpb = b + f[i + 1 - len(b)]
    if tmpa is None and tmpb is None:
        continue
    if tmpa is None and tmpb is not None:
        f[i+1] = tmpb
        continue
    if tmpb is None and tmpa is not None:
        f[i+1] = tmpa
        continue
    if tmpa < tmpb:
        f[i+1] = tmpa
    else:
        f[i+1] = tmpb
print(f[l])

def less(a, b):
    if a < b:
        if not b.startswith(a):
            return True
        else:
            c = b
            while c.startswith(a):
                c = c[len(a):]
            if a < c:
                return True
            else:
                return False

"""
for i in range(l+ 1) :
    if i * len(a) > l:
        break
    if (l - i * len(a)) % len(b) == 0:
        if mina is None:
            mina = i
            maxb = (l - i * len(a)) // len(b)
        maxa = i
        minb = (l - i * len(a)) // len(b)


ans1 = a * maxa + b * minb
ans2 = b * maxb + a * mina

if ans1 < ans2:
    print(ans1)
else:
    print(ans2)


Measured memory_bytes: 4212
n=input()
data=list(map(int,input().split()))
a=[i for i in data if i%4==0]
b=[i for i in data if i%4!=0]
c=[i for i in b if i%2==0]
x=len(a)+len(c)//2
y=len(b)-len(c)//2
if y<=x+1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
def call(n: int) -> list:
    ret = []
    for i in range(1, n+1):
        if i%3 == 0:
            ret.append(i)
            continue

        x = i
        while x:
            if x%10 == 3:
                ret.append(i)
                break

            x //= 10

    return ret

n = int(input())
print(" ", end="")
print(*call(n))


Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<vector<bool>>A(N,vector<bool>(N,0));
  for(int i=0;i<M;i++){
    int a,b;cin>>a>>b;A[a-1][b-1]=1;A[b-1][a-1]=1;
  }
  vector<int>v(N-1);for(int i=1;i<N;i++)v[i-1]=i;
  int ans=0;
  do{
    int s=0;
    for(int n:v){
      if(!A[s][n])break;
      s=n;
    }
    if(s==v[v.size()-1])ans++;
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
using namespace std;
using namespace boost;
using Graph = adjacency_list<listS, vecS, undirectedS, no_property, property<edge_weight_t, int>>;
using Edge = pair<int, int>;
using Vertex = graph_traits<Graph>::vertex_descriptor;
int main() {
  int N, u, v, w;
  cin >> N;
  vector<Edge> edge;
  vector<int> weight;
  for (int i = 0; i < N - 1; i++) {
    cin >> u >> v >> w;
    u--; v--;
    edge.push_back(Edge(u, v));
    weight.push_back(w);
  }
  Graph graph(edge.begin(), edge.end(), weight.begin(), N);
  vector<size_t> distance(num_vertices(graph));
  dijkstra_shortest_paths(graph, 0, distance_map(&distance[0]));
  for (int i = 0; i < N; i++) cout << (distance[i] % 2) << endl;
}

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    if((B - A + 1) > 2 * K){
        for(int i = A; i < A + K; i++){
            cout << i << endl;
        }
        for(int i = B - K + 1; i <= B; i++){
            cout << i << endl;
        }
    }
    else{
        for(int i = A; i <=B; i++){
            cout << i << endl;
        }
    }

    return 0;
}

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

int main(){
    vector<vector<long long>> dp(100010, vector<long long>(13));
    dp[0][0] = 1;
    string S; cin >> S;
    long long n = S.length();
    long long MOD = 1000000007;
    for(int i=0; i < n; i++){
        for(int j=0; j < 13; j++){
            dp[i][j] %= MOD;
            if(S[i] == '?'){
                for(int k=0; k < 10; k++){
                    dp[i+1][(j*10 + k) % 13] += dp[i][j];
                }
            } else {
                int k = S[i] - '0';
                dp[i+1][(j*10 + k) % 13] += dp[i][j];
            }
        }
    }
    cout << dp[n][5] % MOD << endl;    
}

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

#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++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        int a[n];
        rep(i, n) cin >> a[i];
        int m = a[0], sum = a[0];
        for (int i = 1; i < n; i++)
        {
            sum = max(sum + a[i], a[i]);
            if (sum > m)
                m = sum;
        }

        OP(m)
    }

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n,m,L;
int dp[111][111];
main()
{
	while(cin>>n>>m>>L,n)
	{
		for(int i=1;i<=n;i++)for(int j=0;j<=L;j++)dp[i][j]=1e9;
		vector<pair<int,pair<int,int> > >G[111];
		for(int i=0;i<m;i++)
		{
			int a,b,d,e;cin>>a>>b>>d>>e;
			G[a].push_back({b,{d,e}});
			G[b].push_back({a,{d,e}});
		}
		priority_queue<pair<pair<int,int>,int> >P;
		P.push({{0,L},1});
		dp[1][L]=0;
		while(!P.empty())
		{
			int sum=-P.top().first.first;
			int le=P.top().first.second;
			int u=P.top().second;
			P.pop();
			if(dp[u][le]<sum)continue;
			for(int i=0;i<G[u].size();i++)
			{
				int v=G[u][i].first;
				int dis=G[u][i].second.first;
				int com=G[u][i].second.second;
				if(le>=dis)
				{
					if(dp[v][le-dis]>sum)
					{
						dp[v][le-dis]=sum;
						P.push({{-sum,le-dis},v});
					}
				}
				if(dp[v][le]>sum+com)
				{
					dp[v][le]=sum+com;
					P.push({{-sum-com,le},v});
				}
			}
		}
		int ans=1e9;
		for(int i=0;i<=L;i++)if(ans>dp[n][i])ans=dp[n][i];
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3520
package main
import (
  "fmt"
  )
func main(){
    var s int
    fmt.Scanf("%d", &s)
    a := s / 100
    b := s % 100
    if 0 < a && a <= 12 && 0 < b && b <= 12 {
      fmt.Println("AMBIGUOUS")
    } else if 0 < b && b <= 12 {
      fmt.Println("YYMM")
    } else if 0 < a && a <= 12 {
      fmt.Println("MMYY")
    } else {
      fmt.Println("NA")
    }
}

Measured memory_bytes: 512
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t A, B;
    std::cin >> A >> B;

    // std::string S;
    // std::cin >> S;


    std::cout << (A-1)*(B-1) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int cnt[(int)1e5 + 5], N, m, total = 0;

int main(){
  FAST_IO
  cin >> N >> m;
  for(int rep = 0, l, r; rep < m; ++rep){
    cin >> l >> r;
    cnt[l]++;
    cnt[r + 1]--;
  }

  for(int pos = 1; pos <= N; ++pos){
    cnt[pos] += cnt[pos - 1];
    if(cnt[pos] == m) total++;
  }

  cout << total << '\n';
  return 0;
}



Measured memory_bytes: 4020