akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

void warshall_floyd(vector< vector<int> >& d)
{
   int N = d.size();
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
         }
      }
   }
}

signed main()
{
   V<int> a(3), b(3);
   REP(i, 3) {
      cin >> a[i] >> b[i];
      a[i]--; b[i]--;
   }

   V<V<int>> d(4, V<int>(4,INF));
   REP(i, 3) {
      d[a[i]][b[i]] = 1;
      d[b[i]][a[i]] = 1;
   }

   warshall_floyd(d);
   FOR(i, 0, 4) {
      FOR(j, i+1, 4) {
         if (d[i][j] == 3) {
            cout << "YES" << endl;
            return 0;
         }
      }
   }
   cout << "NO" << endl;

   return 0;
}


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

int main()
{
    int X;
    cin >> X;
    while (true)
    {
        bool flag = true;
        for (int i = 2; i * i <= X; i++)
        {
            if (X % i == 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << X << endl;
            break;
        }
        else
        {
            X++;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main (){
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  if ((x-r)<0 || (x+r)>w)
    std::cout << "No" << std::endl;
  else if ((y-r)<0 || (y+r)>h)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
}



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

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.2")

#define all(x) (x).begin(),(x).end()

long long inp(){
    long long x;
    cin >> x;
    return x;
}

void opting(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
}

const int maxn = 1e5 + 69, maxk = 100 + 5, maxp = 100 + 5, inf = 1e9 + 420;

vector<int> A;
void input(){
    string s;
    cin >> s;
    for(auto c : s)
        A.push_back(c - '0');
}

int dec_sum = 0;

inline void add_(int y){
    A[0] += y;
    dec_sum += y;
    int i = 0;
    while(A[i] > 9){
        int r = A[i] % 10;
        int j = (A[i] - r) / 10;

        dec_sum -= (j * 9);

        A[i + 1] += j;
        A[i] = r;
        i++;
    }
}

void solve(){
    reverse(all(A));


    int n = A.size();
    A.push_back(0);
    A.push_back(0);
    A.push_back(0);


    for(int i = 0; i < n; i++)
        A[i] *= 9;

    for(int i = 0; i < n; i++){
        if(A[i] > 9){
            A[i + 1] += (A[i] / 10);
            A[i] %= 10;
        }
        dec_sum += A[i];
    }

    int ans = 1;
    add_(9);

    while(dec_sum > 9 * ans)
        ans++, add_(9);

    cout << ans;


}

int main(){
    opting();
    //while(1){
        A.clear();
        input();
        solve();
    //}
}


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        int a;
        cin >> a;
        sum[i + 1] = (sum[i] + a) % m;
    }
    ll ans = 0;
    map<ll, ll> mp;
    rep(i, 0, n + 1) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
N=int(input())
kouholist=[]
worddict=dict()
maxvalue=0
for i in range(N):
    S=input()
    if S in worddict.keys():
        worddict[S]+=1
    else:
        worddict[S]=1
    maxvalue=max(maxvalue,worddict[S])
#print("ここから")
#print(worddict)
for k in worddict.keys():
    if worddict[k]==maxvalue:
        kouholist.append(k)
kouholist=sorted(kouholist)
for h in range(len(kouholist)):
    print(kouholist[h])

Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
    int n;cin>>n;
    vector<P> v(n);
    vi ans(n*n);
    rep(i,n)cin>>v[i].first;
    rep(i,n)v[i].first--;
    rep(i,n)v[i].second=i+1;
    vector<bool> used(n*n,false);
    sort(all(v));
  int l=0;
    rep(i,n){
        rep(j,v[i].second-1){
            while(used[l])l++;
            if(l>=v[i].first){
                cout<<"No"<<endl;
                return 0;
            }
            ans[l]=v[i].second;
            l++;
        }
        used[v[i].first]=true;
        ans[v[i].first]=v[i].second;
    }
    rep(i,n){
        rep(j,n-v[i].second){
            while(used[l])l++;
            if(l<v[i].first){
                cout<<"No"<<endl;
                return 0;
            }
            ans[l]=v[i].second;
            l++;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n*n){
        if(i)cout<<' ';
        cout<<ans[i];
    }
}


Measured memory_bytes: 3200
def gcd(a,b)
    return a if b == 0
    gcd(b,a%b)
end

def lcm(a,b)
    a * b / gcd(a,b)
end

ans = 1
n = gets.to_i
n.times do
    t = gets.to_i
    ans = lcm(ans,t)
end
puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int a, b;
    cin >> a >> b;
    string s1, s2, s;
    REP(i, b) s1 += to_string(a);
    REP(i, a) s2 += to_string(b);
    if(s1 < s2) cout << s1 << endl;
    else cout << s2 << endl;
}


Measured memory_bytes: 256
from sys import stdin
A=int(stdin.readline().rstrip())
B=int(stdin.readline().rstrip())
C=int(stdin.readline().rstrip())
X=int(stdin.readline().rstrip())
ans=0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
print(ans)

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  VI xs(N);
  REP(i,N) cin >> xs[i];

  VI is(N+1), ds(N+1);
  is[N-1] = ds[N-1] = N;
  for(int i=N-2;i>=0;--i){
	if(xs[i] < xs[i+1]){
	  is[i] = is[i+1];
	  ds[i] = i+1;
	}
	else if(xs[i] > xs[i+1]){
	  is[i] = i+1;
	  ds[i] = ds[i+1];
	}
	else{
	  is[i] = is[i+1];
	  ds[i] = ds[i+1];
	}
  }

  int ans = 0;
  for(int i=0;i<N;){
	++ans;
	i = max(is[i], ds[i]);
  }
  cout << ans << endl;
  
  return 0;
}


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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

class CGoodSequence {
public:
    int N;
    map<int, int> m;

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) {
            int num;
            in >> num;
            if (!m.count(num)) {
                m[num] = 1;
            } else {
                m[num]++;
            }
        }

        ll ans = 0;

        FOREACH(e, m) {
            e.second < e.first ? ans += e.second : ans += e.second - e.first;
        }

        OUT(ans);
    }
};


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


Measured memory_bytes: 4736
#include<stdio.h>

int main(void){
	int N,M,n[5],i,a,b,total[5],d=0;
	for(i=1;i<4;i++){total[i]=0;n[i]=0;}
	n[1]=1;
	scanf("%d",&N);
	scanf("%d",&M);
	for(i=0;i<M;i++){
		scanf("%d",&a);
		scanf("%d",&b);
		if(a==1&&b==0&&N!=1)d++;
		if(total[a]==0){
			n[a]=b;
			total[a]++;
		}
		else{
			if(n[a]!=b)d++;
		}
	}
	if(M==0&&N==1)n[1]=0;
	if(d!=0)printf("-1");
	else {
		for(i=1;i<=N;i++)printf("%d",n[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;

ll n,m,q,T;

bool M[501][501] = {0};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    int c1,c2,c3,c4,c5;
    ll a,b,c,d;
    ll x,y;

    cin >> n;
    string s;
    for(c1 = 0; c1 < n; c1++){
        cin >> s;
        for(c2 = 0; c2 < n; c2++){
            if(s[c2] == '.'){
                M[c2][c1] = 0;
            }
            else{
                M[c2][c1] = 1;
            }
        }
    }

    ll ans = -1;

    b = 0;

    for(c1 = 0; c1 < n; c1++){
        bool ny = 1;
        for(c2 = 0; c2 < n; c2++){
            ny &= M[c1][c2];
        }
        b += ny;
    }

    for(c1 = 0; c1 < n; c1++){
        ll w = 0;
        for(c2 = 0; c2 < n; c2++){
            w += !M[c2][c1];
        }
        bool fr = 0;
        for(c2 = 0; c2 < n; c2++){
            fr |= M[c1][c2];
        }
        ll ext = 0;
        if(w != n && fr == 0){
            fr = 1;
            ext = 1;
        }

        //if(w == 1 && ext == 1)ext = 0;

        ll temp = fr*(n-b+w+ext);


        if(fr != 0){
            if(ans == -1)ans = temp;
            ans = min(ans , temp);
        }

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

    return 0;
}


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

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

int main(){
	int w, h, k;
	string s;
	
	while( cin >> w >> h , w || h ){
		int x=0 , y=0, dir=0;
		while( cin >> s , s != "STOP" ){
			if( s == "RIGHT" ){
				dir = (dir+1) % 4;
			}else if( s == "LEFT" ){
				dir = (dir+3) % 4;
			}else if( s == "FORWARD" ){
				cin >> k;
				for(int i=k ; i > 0 ; i-- ){
					int mx = x + dx[dir];
					int my = y + dy[dir];
					if( mx >= 0 && mx < w && my >= 0 && my < h ){
						x = mx;
						y = my;
					} 
				}
			}else if( s == "BACKWARD" ){
				cin >> k;
				for(int i=k ; i > 0 ; i-- ){
					int mx = x - dx[dir];
					int my = y - dy[dir];
					if( mx >= 0 && mx < w && my >= 0 && my < h ){
						x = mx;
						y = my;
					} 
				}
			}
		}
		cout << (x+1) << " " << (y+1) << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int maxValue = 0;
        int maxIndex = 0;
        int secondMaxValue = 0;
        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(sc.next());
            if (tmp > maxValue) {
                maxValue = tmp;
                maxIndex = i;
            } else if (tmp > secondMaxValue) {
                secondMaxValue = tmp;
            }
        }

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < N; i++) {
            if (i == maxIndex) {
                builder.append(secondMaxValue);
            } else {
                builder.append(maxValue);
            }
            builder.append("\n");
        }

        System.out.println(builder.toString());
    }
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    if(k >= n){
        cout << 0 << endl;
    }else{
        sort(ALL(h));
        cout << accumulate(h.begin(), h.begin()+n-k, 0LL) << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli mod = 1e9+7;
lli n, memo[101][4][4][4];

lli toi(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  return 3;
}

lli rec(lli i, char c, char d, char e) {
  auto& ref = memo[i][toi(c)][toi(d)][toi(e)];
  if (i == n) return 1;
  if (ref > 0) return ref;
  bool C = true, G = true;
  if ((c == 'A' || d == 'A' || e == 'A') 
      && (d == 'G' || e == 'G')) C = false;
  if (d == 'A' && e == 'C') G = false;
  lli res = 0;
  res += rec(i+1, d, e, 'A');
  if (C) res += rec(i+1, d, e, 'C');
  if (G) res += rec(i+1, d, e, 'G');
  res += rec(i+1, d, e, 'T');
  return ref = res % mod;
}

int main() {
  cin >> n;
  lli ans = rec(0, 'T', 'T', 'T');
  for (lli i=3; i<=100; ++i) {
    fill(&memo[0][0][0][0], &memo[100][3][3][3]+1, 0);
    n = i;
    // cout << i << '\t' << rec(0, 'T', 'T', 'T') << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
k,n=gsmi
a=gsmi
max=0
prev=-(k-a[-1])
n.times do |i|
  diff=a[i]-prev
  prev=a[i]
  max=diff if max<diff
end
puts k-max

Measured memory_bytes: 18716
#include<iostream>
#include<cstring>
#define pb push_back
#include<vector>
using namespace std;
int n,k;
long long int dp[20][2000];
vector<int> p;
int main(){
	vector<bool> used(1130,true);
	for(int i=2;i<=1120;i++){
		if(used[i]){
			for(int j=i*2;j<=1120;j+=i){
				used[j]=false;
			}
			p.pb(i);
		}
	}
	while(cin>>n>>k,n||k){
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<p.size()&&p[i]<=n;i++){//i番目の素数
			for(int j=k-1;j>=0;j--){//j回使った
				for(int l=0;l<=n-p[i];l++){//l
					if(dp[j][l]){
						dp[j+1][l+p[i]]+=dp[j][l];
					}
				}
			}
		}
		cout<<dp[k][n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
def isPrime(n):
    for p in primes:
        if n%p == 0:
            return False
        elif n < p*p:
            return True

primes = [2,3,5,7]
for i in range(11,10**5,2):
    if isPrime(i):
        primes.append(i)
n2017s = [0]
for p in primes[1:]:
    if (p+1)//2 in primes:
        n2017s.append(p)
n2017s.append(10**6)
        
def binary_search(n):
    l=0
    r=len(n2017s)-1
    while l+1<r:
        i = (l+r)//2
        if n2017s[i] > n:
            r = i
        else:
            l = i
    return l

Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(binary_search(r+1)-binary_search(l-1))

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

int main() {
	string s,t; cin >> s >> t;
	int n=s.size();
	rep(i,n) {
		if(s==t) {
			cout << "Yes" << endl;
			return 0;
		}
		s=s.back()+s.substr(0,n-1);
	}
	cout << "No" << endl;
}

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

int main() {
	int N;
	cin >> N;
	int tgt = 1, a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a == tgt)
			tgt++;
	}
	if (tgt == 1)
		cout << -1 << endl;
	else
		cout << N - tgt + 1 << endl;
	return 0;
}


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


signed main(){
  ll n;
  cin>>n;
  vector<ll> as(n);
  for(int i=0;i<n;i++) cin>>as[i];
  ll sum=0;
  for(int i=0;i<n;i++){
    if(!(i&1)) sum+=as[i]; //0,2,4,6
    else sum-=as[i]; //1,3,5,7,
  }
  vector<ll> bs(n);
  bs[0]=sum;
  for(int i=1;i<n;i++) bs[i]=(as[i-1]-bs[i-1]/2)*2;
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<bs[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2944
(function(stdin) {

  // Define Function
  function splitCols(line, sep) {
    return line.split(sep);
  }

  function Squire(width,height) {
    return {
      getArea: function() {
        return width * height;
      },
      getPeriphery: function() {
        return (width + height) * 2;
      }
    };
  }

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');
// Array.from ?????°???????????????????????´???????????????
//  const cols  = Array.from(inputs[0].split(' '),Number);
const cols  = splitCols(inputs[0],' ').map(Number);

  // Main Procedure
  const result = (function(a,b) {
    const squire = Squire(a,b);
    return [squire.getArea(), squire.getPeriphery()].join(' ');

  }(cols[0], cols[1]
    ));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

int main() {
	int n;
	cin >> n;
	int l[n];
	int maxi = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		sum += l[i];
		if (maxi < l[i]) {
			maxi = l[i];
		}
	}

	string judge = "No";
	sum = sum - maxi;
	if (maxi < sum) {
		judge = "Yes";
	}

	cout << judge << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, m; cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Numerics;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = BigInteger.Parse(Console.ReadLine());
            var b = BigInteger.Parse(Console.ReadLine());

            if(a > b){
                Console.WriteLine("GREATER");
            }else if(a < b){
                Console.WriteLine("LESS");
            }else{
                Console.WriteLine("EQUAL");
            }
        }
    }
}


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

using namespace std;

int main(void){
    long long X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<long long> p(A), q(B), r(C);
    for(int i = 0; i < A; i++) cin >> p[i];
    for(int i = 0; i < B; i++) cin >> q[i];
    for(int i = 0; i < C; i++) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<long long> e(A + B);
    for(int i = 0; i < X; i++) e[i] = p[i];
    for(int i = 0; i < Y; i++) e[i + A] = q[i];
    sort(e.rbegin(), e.rend());
    sort(r.rbegin(), r.rend());
    for(int i = 0; i < min(X + Y, C); i++){
        if(e[X + Y - 1 - i] < r[i]){
            e[X + Y - 1 - i] = r[i];
            //cout << i << endl;
        }
    }
    long long ans = 0;
    for(int i = 0; i < X + Y; i++){
        ans += e[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, M = map(int, input().split())
    ans = [0] * N
    for _ in range(M):
        a, b = map(lambda x: int(x)-1, input().split())
        ans[a] = 1-ans[a]
        ans[b] = 1-ans[b]
    if 1 in ans:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    main()


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    //vector<char> c(n);
    int count=0;
    /*
    for(int i=0;i<n;i++){
        c.at(i)=s.at(i);
    }
    */
    for(int i=0;i<n-1;i++){
        if(s.at(i)!=s.at(i+1)){
            count++;
        }
    }
    cout << count+1 << endl;

}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextInt();

			if (n % 10 == 9) {
				System.out.println("Yes");
			} else if(n / 10 == 9) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	int ans = 0;
	rep(i, N)
	{
		int h;
		cin >> h;

		if (h >= K)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const ll MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


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

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  
int main(){
    string str;
    cin >> str;
    N = str.size();
    ll sub = 0;
    ll p10 = 1;
    ll ans = 0;
    vector<ll> v(2019, 0);
    for(int i = N-1; i >= 0; --i){
        sub = (sub + (str[i] - '0')*p10) % 2019;
        if( str[i]- '0' != 0 )ans += v[sub];
        //cout << ans << " \n";
        if(sub == 0) ++ans; 
        if( str[i]- '0' != 0 ) ++v[sub];
        p10 = (p10 * 10) % 2019;
        //cout << sub << " ";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3732
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,w = li()
wv = []
for _ in range(n):
    wv.append(tuple(li()))
    
w0 = wv[0][0]
dic = {w0+i: [] for i in range(4)}
for k,v in wv:
    dic[k].append(v)
    
for wi in range(w0,w0+4):
    dic[wi] = [0] + sorted(dic[wi], reverse=True)
    dic[wi] = list(accumulate(dic[wi]))
    
ans = 0
for idx1, w1 in enumerate(dic[w0]):
    
    for idx2, w2 in enumerate(dic[w0+1]):
        
        for idx3, w3 in enumerate(dic[w0+2]):
            
            for idx4, w4 in enumerate(dic[w0+3]):
                
                if w0*idx1 + (w0+1)*idx2 + (w0+2)*idx3 + (w0+3)*idx4 > w:
                    continue
                
                ans = max(ans, w1+w2+w3+w4)
        
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    t=1;
    for(int x=1;x<=t;x++)
    {
        int n=5;
        int arr[5];
        int ans=0;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]==0)
                ans=i+1;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<queue>
#include<map>
using namespace std;

int main() {
	// ダイクストラで最短で1への最短距離を求める
	int H, W;
	cin>>H>>W;
	int c[10][10];
	for(int i=0;i<10;++i){
		for(int j=0;j<10;++j){
			cin>>c[i][j];
		}
	}
	int A[H][W];
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cin>>A[i][j];
		}
	}
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >que;
	que.push(make_pair(0, 1));
	pair<int, int>state;
	int ansarr[10];
	int comp = 0;
	for(int i=0;i<10;++i){
		ansarr[i] = -1;
	}

	while(comp < 10){
		state = que.top();
		//cout<<state.first<<" "<<state.second<<endl;
		que.pop();
		for(int i=0;i<10;++i){
			if(i==state.second) continue;
			que.push(make_pair(state.first + c[i][state.second], i));
		}
		if(ansarr[state.second]==-1){
			comp++;
			ansarr[state.second] = state.first;
		}
	}
	/**
	for(int i=0;i<10;++i){
		cout<<i<<" "<<ansarr[i]<<endl;
	}
	**/
	int ans = 0;
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			if(A[i][j]==-1)continue;
			ans += ansarr[A[i][j]];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void solve() {
    int q;
    cin >> q;
    Tree<pair<int, int>> t;
    long long A = 0;
    long long B = 0;
    const int INF = 0x3f3f3f3f;
    int l=-INF, r=INF;
    while (q--) {
        int op; cin >> op;
        if (op == 1) {
            int a, b;
            cin >> a >> b;
            B += b;
            if (a < l) {
                A = A+l-a;
            }
            if (a > r) {
                A = A+a-r;
            }
            t.insert(make_pair(a, q));
            int n = t.size();
            l = (n-1)/2;
            r = (n&1)? l : l+1;
            l = t.find_by_order(l)->first;
            r = t.find_by_order(r)->first;
        } else {
            cout << l << ' ' << A+B << '\n';
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 12800
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut ans = vec![0, 0, 0, 0];
    for i in 0 .. n {
        match &s[i][..] {
            "AC" => { ans[0] += 1 },
            "WA" => { ans[1] += 1 },
            "TLE" => { ans[2] += 1 },
            "RE" => { ans[3] += 1 },
            _ => {},
        }
    }

    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);

}


Measured memory_bytes: 7888
import sys
from io import StringIO
import unittest
import math


def resolve():
    N = int(input())
    A = 1
    B = 1

    center = math.ceil(math.sqrt(N))
    for i in range(1, center + 1)[::-1]:
        if N % i == 0:
            A = i
            B = int(N / i)
            break
        else:
            continue

    result = A - 1 + B - 1
    print(result)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """50"""
        output = """13"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000000019"""
        output = """10000000018"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 6484
//Author:: Pham Ngoc Minh- Chuyen Thai Binh
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int const maxn=2*1e5+5;
pair<long long,long long> a[maxn];
bool cmp(pair<long long,long long> a,pair<long long,long long> b){
    if(a.s==b.s) return a.f<b.f;
    else return a.s<b.s;
}
int n;
int sum=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].f>>a[i].s;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        sum+=a[i].f;
        if(sum>a[i].s){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}
// I love Chuyen Thai Binh Verry much ! Now, you alaways in my code of me <3
// Chuyen Thai Binh La Nha :>>


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

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

//素数を求める
vector<int> prime_factor(int num){
    vector<int> vec;
    int a = 2;
    while(num >= a*a){
        if(num%a==0){
            vec.push_back(a);
            num /= a;
        }else{
            a++;
        }
    }
    vec.push_back(num);
    return vec;
}

int main() {
    cin >> N;
    while(true){
        vector<int> vec = prime_factor(N);
        if(vec.size() == 1) break; 
        N++;
    }
    cout << N;
}


Measured memory_bytes: 256
// Problem : B - String Palindrome
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " | ";
	err(++it, args...);
}

const ll inf = 1e18;
const int nax = 1e5 + 5;

bool ok(string &s)
{
	ll n = s.length();
	forn(i,0,n/2)
	{
		if(s[i]!=s[n-i-1])
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		string s;
		cin>>s;
		
		ll n = s.length();
		string s1 = "", s2 = "";
		forn(i,0,(n-1)/2)
		{
			s1 += s[i];
		}
			
		forn(i,(n+3)/2-1,n)
		{
			s2 += s[i];
		}
		
		if(ok(s) && ok(s1) && ok(s2))
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
const double PI = acos(-1.0);

ll dp[200005][5];

ll cost(int i, int k, const vector<ll> &a) {
  if (k==0 || k==4) {
    return a[i];
  } else if (k==1 || k==3) {
    if (a[i]%2 == 0 && a[i]>0) return 0;
    else if (a[i] > 0) return 1;
    else return 2;
  } else {
    return (a[i]+1)%2;
  }
}

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  rep(i, 200005) {
    rep(j, 5) {
      dp[i][j] = LONG_MAX/2;
    }
  }
  dp[0][0] = 0;

  rep(i, n) {
    rep(j, 5) {
      for(int k=j; k<5; k++) {
        chmin(dp[i+1][k], dp[i][j] + cost(i, k, a));
      }
    }
  }

  ll ans = LONG_MAX;
  rep(i, 5) {
    chmin(ans, dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600
Sa = list(input())
Sb = list(input())
Sc = list(input())
next_turn = 'a'

while True:
    if next_turn == 'a':
        if len(Sa) == 0:
            print('A')
            break
        next_turn = Sa.pop(0)
    elif next_turn == 'b':
        if len(Sb) == 0:
            print('B')
            break
        next_turn = Sb.pop(0)
    else:
        if len(Sc) == 0:
            print('C')
            break
        next_turn = Sc.pop(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=50;
int k=38,n=k*(k-1)+1,a[N][N];
int main(){
    printf("%d %d\n",n,k);
    for (int i=1;i<=k;i++){
        printf("1");
        for (int j=(i-1)*(k-1)+2;j<=i*(k-1)+1;j++)printf(" %d",j),a[i][j-(i-1)*(k-1)-2]=j;
        puts("");
    }
    for (int i=0;i<k-1;i++)
        for (int j=0;j<k-1;j++){
            printf("%d",i+2);
            for (int l=2,cur=j;l<=k;l++,cur=(cur+i)%(k-1))printf(" %d",a[l][cur]);
            puts("");
        }
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int K;

    cin >> N >> K;
    int D[K];
    for (int i = 0; i < K; i++) cin >> D[i];

    int ans = N;
    while (true) {
        bool end = true;
        int tmp = ans;
        while (tmp >= 1) {
            int n = tmp % 10;
            for (int i = 0; i < K; i++) {
                if (n == D[i]) end = false;
            }
            tmp /= 10;
        }
        if (end) break;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int q;
  cin>>q;
  for(int x=0;x<q;x++){
    int n;
    cin>>n;
    int ans=0;
    while(n/10>0){
      int nn=0;
      string s=to_string(n);
      for(int i=1;i<s.size();i++){
        string a,b;
        for(int j=0;j<i;j++)a.push_back(s[j]);
        for(int j=i;j<s.size();j++)b.push_back(s[j]);
        nn=max(nn,stoi(a)*stoi(b));
        n=nn;
      }
      ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

/*
	input :
	N
	A_1 A_2 A_3 ... A_N
*/

// assign/range max
// 0-filled by default
struct SegTree {
	std::vector<int> data; // max
	int n;
	SegTree (int n_) {
		for (n = 1; n < n_; n <<= 1);
		data.resize(n << 1);
	}
	void assign(int index, int val) {
		for (data[index += n] = val; index >>= 1; ) data[index] = std::max(data[index << 1], data[index << 1 | 1]);
	}
	// [l, r)
	int max(int l, int r) {
		int res = 0;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (r & 1) res = std::max(res, data[--r]);
			if (l & 1) res = std::max(res, data[l++]);
		}
		return res;
	}
};

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	
	std::map<int, int> compress;
	for (auto i : a) compress[i] = 0;
	int cnt = 0;
	for (auto &i : compress) i.second = cnt++;
	for (auto &i : a) i = compress[i];
	
	SegTree tree(cnt);
	for (auto &i : a) tree.assign(i, tree.max(0, i) + 1);
	printf("%d\n", tree.max(0, cnt));
	return 0;
}




Measured memory_bytes: 8884
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    ll n;cin>>n;
    ll now =0;
    int ans =0;
    rep(i,10000000){
        now*=10;
        now+=7;
        now%=n;
        ans++;
        if(now==0)break;
    }
    if(ans!=10000000)cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    string s;
    cin >> s;
    size_t c = count(s.cbegin(), s.cend(), '1');
    cout << min({c, s.size() - c}) * 2 << endl;

    return 0;
}

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

#define all(x) (x).begin(),(x).end()

#define mod 1000000007;

using namespace std;

int main(){
	int n,m;
	int check=0;
	
	cin >> n >> m;
	
	int a[m];
	long long int dp[n+1];
	
	for(int i=0; i<m; i++){
		cin >> a[i];
	}
	
	for(int i=0; i<=n; i++){
		dp[i]=0;
	}
	
	for(int i=0; i<m; i++){
		dp[a[i]]=-1;
	}
	
	dp[0]=1;
	if(dp[1]!=-1)	dp[1]=1;
	for(int i=2; i<=n; i++){
		if(dp[i]!=-1){
			if(dp[i-1]!=-1)	dp[i]+=dp[i-1];
			dp[i]%=mod;
			if(dp[i-2]!=-1)	dp[i]+=dp[i-2];
			dp[i]%=mod;
			
			if(dp[i]==0){
				check=1;
				break;
			}
		}
	}
	
	if(check==1)	cout << "0" << endl;
	else	cout << dp[n] << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int n=100,a,b;
char ans[105][105];
int main(){
	scanf("%d%d",&a,&b);
	if (a==1&&b==1){
		puts("1 2\n.#");
		return 0;
	}
	if (a==1&&b==2){
		puts("1 3\n#.#");
		return 0;
	}
	if (a==2&&b==1){
		puts("1 3\n.#.");
		return 0;
	}
	if (a==1||b==1){
		int flag=b==1;
		if (b==1)
			swap(a,b);
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
				ans[i][j]='.';
		for (int i=2;i<n&&b;i+=2)
			for (int j=2;j<n&&b;j+=2)
				ans[i][j]='#',b--;
		if (flag)
			for (int i=1;i<=n;i++)
				for (int j=1;j<=n;j++)
					if (ans[i][j]=='.')
						ans[i][j]='#';
					else
						ans[i][j]='.';
		puts("100 100");
		for (int i=1;i<=n;i++,puts(""))
			for (int j=1;j<=n;j++)
				printf("%c",ans[i][j]);
		return 0;
	}
	a-=2,b-=2;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i==1)
				ans[i][j]=j<=n/2?'#':'.';
			else
				ans[i][j]=(j%2==0)?'#':'.';
	for (int i=1;i<n/2;i++)
		ans[n][i]='.';
	for (int i=n/2+2;i<n;i++)
		ans[n][i]='#';
	for (int i=2;i<n/2&&a;i+=2)
		ans[n][i]='#',a--;
	for (int i=n/2+3;i<n&&b;i+=2)
		ans[n][i]='.',b--;
	for (int i=1;i<n/2&&a;i+=2)
		for (int j=3;j<n&&a;j+=2)
			ans[j][i]='#',a--;
	for (int i=n/2+2;i<=n&&b;i+=2)
		for (int j=3;j<n&&b;j+=2)
			ans[j][i]='.',b--;
	printf("100 100\n");
	for (int i=1;i<=n;i++,puts(""))
		for (int j=1;j<=n;j++)
			printf("%c",ans[i][j]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	int a[100];
	
	cin >> n; 
	for(int i = 0; i < n ; i++){
		cin >> a[i];
	}
	
	for(int i = n - 1; i >= 0; i--){
		cout << a[i];
		if(i != 0) cout << " ";
	}
	cout << "\n";
	
	return 0;
}

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

#define ll long long 
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < s.length(); i++) {
		ans += (s[i] != t[i]);
	}
	cout << ans;
	return 0;
}	

Measured memory_bytes: 3728