akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,a,b,c;
  	cin>>x>>y>>a>>b>>c;
  	priority_queue<int>r;
  	priority_queue<int>g;
  	priority_queue<int>C;
  	for(int i=0;i<a;i++)
    {
      int X;
      cin>>X;
      r.push(X);
    }
  	for(int i=0;i<b;i++)
    {
      int X;
      cin>>X;
      g.push(X);
    }
  	for(int i=0;i<c;i++)
    {
      int X;
      cin>>X;
      C.push(X);
    }
  	//cout<<r.size()<<endl;
  	priority_queue<int,vector<int>,greater<int>>A;
  	while(x--)
    {
      A.push(r.top());
      r.pop();
    }
  	while(y--)
    {
      A.push(g.top());
      g.pop();
    }
  	while(A.top()<=C.top())
    {
      A.pop();
      A.push(C.top());
      C.pop();
      if(C.empty())break;
    }
  	long long ans=0;
  	
  	while(!A.empty())
    {
      ans+=A.top();
      A.pop();
    }
  	cout<<ans<<endl;
	return 0;
}
  

Measured memory_bytes: 5444
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, C[10][10];
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b)
        swap(a, b);
    for (int i = 0; i < b; i ++)
        printf("%d", a);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;

signed main() {
    double A,B,X;
    cin >> A >> B >> X;
    double C = X / A;
    if(C > A * B / 2) {
        X = X * 2 / (A * A) - B;
        B = B - X;
        double D = atan(B / A);
        cout << fixed;
        cout << setprecision(10) << 180 / (PI / D) << endl;
    }
    else {
        C = C * 2 / B;
        double D = atan(B / C);
        cout << fixed;
        cout << setprecision(10) << 180 / (PI / D) << endl;
    }
}

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

int main()
{
    ll a,b;
    cin>>a>>b;
    if(a==0||b==0||(a<0&&b>0)||(b<0&&a>0))
    {
        cout<<"Zero";
    }
    else if(a>0&&b>0)
    {
        cout<<"Positive";
    }
    else
    {
        ll t=a-b;
        if(t%2)
        {
            cout<<"Positive";
        }
        else
        {
            cout<<"Negative";
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys

N,Y=map(int,input().split())
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    if k >= 0:
      y = 10000*i + 5000*j + 1000*k
      if Y == y:
        print(i,j,k)
        sys.exit()
        
print(-1,-1,-1)


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

//最大公約数
ll gcd(ll a,ll b){
  if(b == 0)return a;
  return gcd(b,a%b);
}

//最小公倍数を　a*b = gcd(a,b)*lcm(a,b)を使って求める
ll lcm(ll a, ll b){
  ll g = gcd(a,b);
  return a / g * b;
}
 
int main(void){
  int n;cin >> n;
  ll ans = 1;
  rep(i,n){
    ll t;cin >> t;
    ans = lcm(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int n,a=0,b=0,c=0,d=0;
            cin>>n;
            string p;
            REP(i,0,n-1){cin>>p;
              if(p=="AC") a++;
              if(p=="TLE") b++;
              if(p=="WA") c++;
              if(p=="RE") d++;}  
            cout<<"AC x "<<a<<"\n";
            cout<<"WA x "<<c<<"\n";
            cout<<"TLE x "<<b<<"\n";
            cout<<"RE x "<<d<<"\n";


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll N;
	string S;
	cin >> N;
	cin >> S;
	string subStr;
	ll count = 0;
	rep(i, N - 2) {
		subStr = S.substr(i, 3);
		if ( subStr == "ABC") count++;
	}
	cout << count << endl;
}

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

const int N = 3000+5;

int n;
int a[N];
bool vis[N][N];
long long memo[N][N];

long long DP(int l, int r){
	if(r < l) return 0LL;
	if(vis[l][r]) return memo[l][r];
	int turn = (n - (r - l + 1)) & 1;
	long long ans;
	if(turn == 0){
		ans = max(a[l] + DP(l + 1, r), a[r] + DP(l, r - 1));
	}
	else{
		ans = min(-a[l] + DP(l + 1, r), -a[r] + DP(l, r - 1));
	}
	vis[l][r] = true;
	return memo[l][r] = ans;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	printf("%lld\n", DP(0, n - 1));
	return 0;
}


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

using namespace std;

int main()
{
  string base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?";
  int N, M, Q;
  while(cin >> N >> M >> Q, N || M || Q){
    long long bulb[1024]; //memset(bulb, -1LL, sizeof(bulb));
    for(int i = 0; i < M; i++) bulb[i] = (1LL << N) - 1LL;
    long long swch = 0LL;
    for(int i = 0; i < Q; i++){
      string S, B;
      cin >> S >> B;
      long long s = 0LL, b = 0LL;
      for(int j = 0; j < N; j++) if(S[j] == '1') s |= (1LL << j);
      for(int j = 0; j < M; j++) if(B[j] == '1') b |= (1LL << j);
      swch ^= s;
      for(int j = 0; j < M; j++){
	//if((b >> j) & 1LL) bulb[j] &= swch;
	if(B[j] == '1') bulb[j] &= swch;
	else bulb[j] &= ~swch;
      }
    }
    for(int i = 0; i < M; i++){
      int ctrl = -1;
      int cnt = 0;
      for(int j = 0; j < N; j++){
	//if((bulb[i] >> j) & 1LL) cnt++, ctrl = j;
	if(bulb[i] == (1LL << j)) cnt++, ctrl = j;
      }
      if(cnt == 1) cout << base36[ctrl];
      else cout << "?";
    }
    cout << endl;
  }
  return 0;
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 100011;


int main() {
    string s;
    cin>>s;
    int cnt = 0;
    string t = "YAKI";
    for(int i = 0; i < SZ(s); ++i) {
        if(s[i] == t[i]) cnt++;
        else break;
    }
    if(cnt == SZ(t)) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
def dist2(a, b):
    return sum([(i - j)**2 for i, j in zip(a, b)])


def check(num):
    return sum([True if i**2 == num else False for i in range(1, 202)]) > 0


n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
print(sum([check(dist2(i, j)) for i, j in combinations(x, 2)]))

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;

            Write(s.First());
            Write(s.Length - 2);
            Write(s.Last());
            Write("\n");

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Bottom Up Approach
int frog2(vector<int>h, int n, int k) {
	vector<int>dp(n + 1);
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = INT_MAX;
		for (int j = i - 1; j >= 1 && (i - j) <= k; j--)
			dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
	}
	return dp[n];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int>h(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	cout << frog2(h, n, k) << endl;


	return 0;
}


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

int main(){
    
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2));
    for(int i=1; i<h+1; i++){
        for(int j=1; j<w+1; j++){
            cin >> s.at(i).at(j);
        }
    }

    string ans="Yes";
    for(int i=1; i<h+1; i++){
        for(int j=1; j<w+1; j++){
            if(s.at(i).at(j)=='#'){
                if(s.at(i-1).at(j)=='.'&&s.at(i+1).at(j)=='.'&&s.at(i).at(j-1)=='.'&&s.at(i).at(j+1)=='.'){
                    ans="No";
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

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

vector<vector<double>> dp;
double find(int i,vector<double> &v,int rem){
    double ans=0;
    if(dp[i][rem]!=-1)return dp[i][rem];
    if(i==v.size()-1){
        ans+=v[i];
        if(rem>0){
            ans+=(double)1-v[i];
        }
        return dp[i][rem]=ans;
    }
    ans+=find(i+1,v,rem)*v[i];
    if(rem>0)
    ans+=find(i+1,v,rem-1)*((double)1-v[i]);
    return dp[i][rem]=ans;
}

int main(){
    
    int n;
    cin>>n;
    dp.clear();
    dp.resize(n+1,vector<double>(n-(n/2),-1));
    vector<double> v(n,-1);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    //cout<<find(0,v,n-(n/2)-1)<<endl;
    double ans=find(0,v,n-(n/2)-1);
    // printf("%lf\n",ans);
    std::cout << std::fixed;
    std::cout << std::setprecision(10);
    std::cout << ans<<endl;
    
    return 0;
}

Measured memory_bytes: 38932
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N=sc.next();
        if(N.charAt(0)==N.charAt(2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;

typedef long long ll;

int main(){
  int n, left, right;
  bool fg = true;
  cin >> n;
  cin >> left;
  for(int i = 0; i < n-1; i++){
    cin >> right;
    if(right<left-1){
      fg = false;
      break;
    }
    else if(right==left-1){
      right++;
      left = right;
    }
    else left = right;

    if(fg == false) break;
  }
  if(fg) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////
void solve(){
  ini(sx,sy,tx,ty);
  int dx = abs(sx-tx) , dy = abs(sy-ty);
  string ans;
  rep(i,dy) ans.pb('U');
  rep(u,dx) ans.pb('R');
  rep(i,dy) ans.pb('D');
  rep(u,dx) ans.pb('L');
  ans.pb('L');
  rep(i,dy+1) ans.pb('U');
  rep(u,dx+1) ans.pb('R');
  ans.pb('D');
  ans.pb('R');
  rep(i,dy+1) ans.pb('D');
  rep(u,dx+1) ans.pb('L');
  ans.pb('U');
  out(ans); 
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    // https://atcoder.jp/contests/abc170/tasks/abc170_a
    class A_FiveVariables_170
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int result = 0;

            for ( int i = 0;i < inputLongArray.Length;i++ )
            {
                if ( inputLongArray[i] == 0 )
                {
                    result = i + 1;
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28124
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=2005,maxe=maxn<<1;
int n,K,u[maxn],v[maxn],ans,Q[maxn],dst[maxn];
int e,lnk[maxn],nxt[maxe],son[maxe];
bool vis[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
void BFS(int x,int y){
	memset(vis,0,sizeof vis);
	int hed=0,til=0;
	if(x) vis[x]=1,Q[++til]=x,dst[x]=0;
	if(y) vis[y]=1,Q[++til]=y,dst[y]=0;
	while(hed^til)
	for (int i=lnk[Q[++hed]];i;i=nxt[i])
	if(!vis[son[i]])
	vis[son[i]]=1,Q[++til]=son[i],dst[son[i]]=dst[Q[hed]]+1;
	int now=0;
	for (int i=1;i<=n;i++) if(dst[i]<=K) now++;
	if(now>ans) ans=now;
}
inline void add_e(int x,int y){son[++e]=y;nxt[e]=lnk[x];lnk[x]=e;}
int main(){
	n=read(),K=read();
	for (int i=1;i<n;i++){
		u[i]=read(),v[i]=read();
		add_e(u[i],v[i]),add_e(v[i],u[i]);
	}
	if(K&1){
		K>>=1;
		for (int i=1;i<n;i++) BFS(u[i],v[i]);
	}else{
		K>>=1;
		for (int i=1;i<=n;i++) BFS(i,0);
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int m;
    cin>>m;
    ll d[m],c[m];
    ll dig=0,sum=0;
    for(int i=0;i<m;i++){
        cin>>d[i]>>c[i];
        dig+=c[i];
        sum+=d[i]*c[i];
    }
    cout<<(dig-1)+(sum-1)/9<<endl;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int	main()
{
	int	N, M;
	cin >> N >> M;
	Graph	graph(N);
	int	A, B;
	for (int i = 0; i < M; ++i) {
		cin >> A >> B;
		--A; --B;
		graph.at(A).push_back(B);
		graph.at(B).push_back(A);
	}
	queue<int>		que;
	vector<int>	prev_vec(N, -1);
	que.push(0);	
	while (!que.empty()) {
		int	u = que.front();
		que.pop();
		for (int v : graph.at(u)) {
			if (prev_vec.at(v) != -1) continue;
			prev_vec.at(v) = u;
			que.push(v);
		}
	}
	bool	feasible = true;
	for (int i = 1; i < N; ++i) {
		if (prev_vec.at(i) == -1) {
			feasible = false;
			break;
		}
	}
	if (!feasible) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;;
	for (int i = 1; i < N; ++i) {
		cout << prev_vec.at(i) + 1 << endl;
	}
}

			



Measured memory_bytes: 10160
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt=0;
vector<int> a,b;
vector<bool> visit;
vector<vector<bool>> ab;
void dfs(int t){
  visit[t]=true;
  for(int i=0;i<n;i++){
    if(ab[t][i]&&visit[i]!=true){
      dfs(i);
    }
  }
  int f=0;
  for(int i=0;i<n;i++){
    if(visit[i]){
      f++;
    }
  }
  if(f==n){
    cnt++;
  }
  visit[t]=false;
}
int main(){
  cin>>n>>m;
  a.resize(m);
  b.resize(m);
  visit.resize(n);
  ab.resize(n);
  for(int i=0;i<n;i++){
    ab[i].resize(n);
    for(int j=0;j<n;j++){
      ab[i][j]=false;
    }
  }
  for(int i=0;i<m;i++){
    int aa,bb;
    cin>>aa>>bb;
    a.at(i)=--aa;
    b.at(i)=--bb;
    ab[a[i]][b[i]]=true;
    ab[b[i]][a[i]]=true;
  }
  dfs(0);
  cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	string str;
	cin >> str;
	if (str == "SUN")
		cout << 7 << endl;
	else if (str == "MON")
		cout << 6 << endl;
	else if (str == "TUE")
		cout << 5 << endl;
	else if (str == "WED")
		cout << 4 << endl;
	else if (str == "THU")
		cout << 3 << endl;
	else if (str == "FRI")
		cout << 2 << endl;
	else if (str == "SAT")
		cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 2e5 + 1;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b; cin >> a >> b;
    if (a > 0) cout << "Positive";
    else if (a * b <= 0) cout << "Zero";
    else cout << ((b - a + 1) % 2 ? "Negative" : "Positive");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  char op;
  int answer = 0;
  cin >> A >> op >> B;
  if (op == '+'){
    answer += A + B;
  }
  else{
    answer += A - B;
  }
  cout << answer << endl;
}

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

int main(void)
{
	int n, *d;
	cin >> n;
	d = new int[n];

	for (int i = 0; i < n; i++)
		cin >> d[i];

	sort(d, d + n);

	cout << d[n / 2] - d[n / 2 - 1];

	delete d;

	return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: usize = read();

    let v = vec![1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

    println!("{}", v[k-1]);
}


Measured memory_bytes: 4352
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
W = lines.shift().split(' ')

s1 = 0
sum = 0
for (i=0; i < N; i++) {
    sum += W[i] * 1
}

abs = 100 * 100
for (i=0; i < N; i++) {
    s1 += W[i] * 1
    diff = Math.abs(s1 - (sum - s1))
    if (abs > diff) {
        abs = diff
    } 
}

console.log(abs)


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

typedef long long ll ;
#define f(i,s,n) for(int i=s;i<n;i++)

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    ll N ;cin>>N ;
    map<int,char> mp ;
    f(i,1,26) mp[i] = 'a'+(i-1) ;
    mp[0] = 'z' ;
    string ans = "" ;
    while(N)
    {
        ans+=mp[N%26] ; 
        if(N%26==0) N-=26 ;
        N/=26 ;
    }
    for(int i=ans.length()-1;i>=0;i--) cout<<ans[i];
    cout<<endl ;
}

Measured memory_bytes: 3652
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

struct Node {
    int key;
    Node* parent;
    Node* left;
    Node* right;
    Node(int k) : key(k) {}
};

void bintree_insert(Node*& root, int key)
{
    Node* node = new Node(key);
    if(!root) {
        root = node;
        return;
    }

    Node* parent = root;
    for(;;) {
        Node*& child = key < parent->key ? parent->left : parent->right;
        if(!child) {
            node->parent = parent;
            child = node;
            break;
        }
        parent = child;
    }
}

bool bintree_find(const Node* root, int key)
{
    const Node* node = root;
    for(;;) {
        if(!node) return false;

        if(node->key == key) return true;

        node = key < node->key ? node->left : node->right;
    }
}

void bintree_print_inorder(Node* node)
{
    if(!node) return;

    bintree_print_inorder(node->left);
    printf(" %d", node->key);
    bintree_print_inorder(node->right);
}

void bintree_print_preorder(Node* node)
{
    if(!node) return;

    printf(" %d", node->key);
    bintree_print_preorder(node->left);
    bintree_print_preorder(node->right);
}

void bintree_print(Node* root)
{
    bintree_print_inorder(root);
    puts("");

    bintree_print_preorder(root);
    puts("");
}

void interpret()
{
    int n;
    scanf("%d\n", &n);

    Node* root = nullptr;

    char buf[256];
    REP(_, n) {
        scanf("%s", buf);
        if(strcmp(buf, "insert") == 0) {
            //puts("insert");
            int key;
            scanf("%d", &key);
            bintree_insert(root, key);
        }
        else if(strcmp(buf, "find") == 0) {
            //puts("find");
            int key;
            scanf("%d", &key);
            bool found = bintree_find(root, key);
            puts(found ? "yes" : "no");
        }
        else if(strcmp(buf, "print") == 0) {
            //puts("print");
            bintree_print(root);
        }
    }
}

int main()
{
    interpret();

    return 0;
}

Measured memory_bytes: 21344
#include<stdio.h>

int kin(int n, int m, int k)
{
    return((n%m==0)?(n/m*k):((n/m+1)*k));
}

int main(int rgc, char *argv[])
{
    int a, b, c, d, n, set1, set2;
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    set1 = kin(n, a, b);
    set2 = kin(n, c, d);
    printf("%d\n", (set1 <= set2)?(set1):(set2));
    return 0;
}


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

int main(){
  int N, M, L, R;
  cin >> N >> M;
  L=1; R=N;
  for(int i=0; i<M; i++){
    int l, r;
    cin >> l >> r;
    if(L<l) L=l;
    if(r<R) R=r;
  }
  if(R>=L) cout << R-L+1 << endl;
  else cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];
		for(int i = 0 ; i < N ; i++) {
			A[i] = sc.next();
		}
		for(int i = 0 ; i < M ; i++) {
			B[i] = sc.next();
		}
		for(int i = 0 ; i <= N - M ; i++) {
			for(int j = 0 ; j <= N - M ; j++) {
				if(check(i, j, A, B, M)) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}

	public static boolean check(int x, int y, String[] A, String[] B, int M) {
		for(int i = 0 ; i < M ; i++) {
			for(int j = 0 ; j < M ; j++) {
				if(A[x + i].charAt(y + j) != B[i].charAt(j)) {
					return false;
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 22100
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MAX_N 100005

vector<vector<int> > g;
vector<int> color;
int n;
vector<int> p;
bool dfs(int id){
    if(color[id]==3){
        return true;
    }
    if(color[id]==2){
        color[id]=3;
    }
    int c = 0;
    vector<int> ori(n);
    bool f = 0;
    int b =-1;
    for(auto x:g[id]){
        if(color[x]==5){
            c++;
            continue;
        }
        if(color[x]==3){
            f = 1;
            b = x;
            continue;
        }
        ori[x] = color[x];
        color[x] = 1;
    }
    if(c>=1)return false;
    if(f){
        for(auto x:g[id]){
            color[x] = ori[x];
        }
        p.push_back(b);
        return true;
    }
    for(auto x:g[id]){
        if(ori[x]==1)continue;
        color[x] = 5;
        if(dfs(x)){
            p.push_back(x);
            return true;
        }
        color[x] = 1;
    }
    for(auto x:g[id]){
        color[x] = ori[x];
    }
    return false;
}
int main(){
    int m;
    cin >> n >> m;
    g.resize(n);
    color.resize(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
    }
    rep(i,n){
        rep(j,n){
            color[j] = 0;
        }
        color[i] = 2;
        if(dfs(i)){
            cout << p.size() << endl;
            for(auto x:p){
                cout << x+1 << endl;
            }

            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, Q;
  map<int, int> mp;
  cin >> N;
  vi A(N);

  REP(i, N) {
    int tmp;
    cin >> tmp;
    if (mp.count(tmp))
      mp[tmp]++;
    else
      mp[tmp] = 1;
  }
  ll ans = 0;
  for (auto a : mp) {
    ans += a.first * a.second;
  }

  cin >> Q;
  REP(i, Q) {
    int B, C;
    cin >> B >> C;
    if (mp.count(B)) {
      ans += (C * mp[B]) - (B * mp[B]);
      if (!mp.count(C))
        mp[C] = mp.at(B);
      else
        mp.at(C) += mp.at(B);
      mp.erase(B);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 6476
import numpy as np
import heapq
N,M=map(int,input().split())
a_list=[int(x) for x in input().split()]

A=list([-1*x for x in a_list])
heapq.heapify(A)

for m in range(M):
    max_a=heapq.heappop(A)
    half=max_a/2
    heapq.heappush(A,half)

result=sum([-1*int(x) for x in A])
print(result)

Measured memory_bytes: 23888
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
vector<ll>specialist[500005];
ll sum[100005];
ll point[100005];
int main() {
    fastread;
    ll n,m;
    cin>>n>>m;
    if(m>=n)
        cout<<"unsafe";
    else
        cout<<"safe";
}

Measured memory_bytes: 15376
N, A, B, C = map(int, input().split())
TotalLength = A + B + C
L = [int(input()) for _ in range(N)]
Ans = 1000000000000
for i in range(1, 4**N):
    X, fourN = i, []
    while X > 0:
        fourN.append(X % 4)
        X //= 4
    Length = [0, 0, 0]
    connect = 0
    for j in range(len(fourN)):
        if fourN[j] > 0:
            if Length[fourN[j]-1] > 0: connect += 1
            Length[fourN[j]-1] += L[j]
        if 0 not in Length: Ans = min(Ans, abs(Length[0]-A) + abs(Length[1]-B) + abs(Length[2]-C) + connect * 10)
print(Ans)

    

Measured memory_bytes: 49644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 100000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define pi atan(1)*4
#define ALL(x) x.begin(),x.end()
#define int ll

int n;
int a[10000005];
int dp[10000005];

main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		dp[i]=1e15;
	}
	dp[1]=0;
	dp[2]=min(dp[2],abs(a[1]-a[2]));
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 3072
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == "#" and s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] == ".":
          r = "No"
print(r)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

signed main(){
	cin >> n;
	int ret = 0;
	for(int i=1; i<=n; i++){
		if(i % 2 == 0) continue;
		int tmp = 0;
		for(int j=1; j<=n; j++){
			if(i % j == 0) tmp++;
		}
		if(tmp == 8) ret++;
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    n -= 1
    k -= 1
    print((n + k - 1) // k)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52652
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = (a); i <= (b); ++i)

short a[550][550];
int b[550];
char buff;
array<short, 1 << 22> dp, nxt;
main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    while(1) {
        int n, m;
        cin >> n >> m;
        if(!n) return 0;
        rep(i, n) rep(j, m) {
            cin >> buff;
            a[i][j] = buff - '0';
        }
        if(n < m) {
            int ans = 0;
            rep(mask, 1 << n) {
                if(ans > __builtin_popcount(mask)) continue;
                rep(i, m) b[i] = 0;
                rep(i, n) {
                    if(1 << i & mask) { rep(j, m) b[j] ^= a[i][j]; }
                }
                rep(i, m) {
                    if(b[i]) break;
                    if(i == m - 1) ans = max(ans, (int)__builtin_popcount(mask));
                }
            }
            cout << ans << '\n';
        } else {
            rep(i, 1 << m) dp[i] = -1000;
            dp[0] = 0;
            rep(i, n) {
                int k = 0;
                rep(j, m) k ^= (1 << j) * a[i][j];
                rep(j, 1 << m) nxt[j] = dp[j];
                rep(mask, 1 << m) {
                    if(dp[mask] < 0) continue;
                    nxt[k ^ mask] = max<short>(nxt[k ^ mask], dp[mask] + 1);
                }
                swap(dp, nxt);
            }
            cout << dp[0] << '\n';
        }
    }
}



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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
#define INF 1000000000000
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100, MAXK = 25;
const ll MOD = 1e9+7;

bool dp[MAXN];
int a[MAXN];

int main()
{
    FAST_IO;

    int n, k; cin >> n >> k;
    FOR(i, 1, n) cin >> a[i];

    FOR(i, 0, k) {
        if (dp[i]) continue;
        FOR(j, 1, n)
            if (a[j]+i <= k)
                dp[i+a[j]] = true;
    }

    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main()
{
	int N;
  cin >> N;
  vector<lint> A(N);
  cin >> A;
  sort(A.rbegin(), A.rend());
  lint r1 = 0, r2 = 0;
  for (auto x : A) {
    r1 += x;
    swap(r1, r2);
  }
  cout << abs(r1 - r2) << endl;
}



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

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

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cout <<"NO" <<endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  

  return 0;

}

Measured memory_bytes: 5128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<bool> getPrimeTable(const int& max)
{
	vector<bool> table(max + 1);
	//fill(table.begin(), table.end(), false);
    
	table[2] = true;
    
	int i, j;
	for(i = 3; i <= max; i += 2)
	{
		table[i] = i % 2 == 1;
		for(j = 3; j*j <= i; j += 2)
		{
			if(!(i % j))
			{
				table[i] = false;
				break;
			}
		}
	}
    
	return table;
}


int main()
{
	int a, d, n;

	vector<bool> prime = getPrimeTable(1000000);

	while(cin >> a >> d >> n && n)
	{
		do
		{
			if(prime[a])
				n--;
			if(!n)
			{
				cout << a << endl;
				break;
			}
		}
		while(a += d);
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N=105;

int main()
{
	int n,k;
	cin>>n>>k;
	int c=0,x;
	for(int i=0;i<n;i++) 
	{
		cin>>x;
		if(x>=k) c++;
	}
	cout<<c;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	string S; cin >> S;
	string x = "A";
	int cnt = 0;
	int ans = 0;
	while (true) {
		string key = "";
		for (int i = cnt; i < S.size(); ++i) {
			key += S[i];
			if (key != x) {
				x = key;
				ans++;
				cnt = i + 1;
				break;
			}
			else {
				cnt++;
			}
			if (cnt >= S.size()) {
				break;
			}
		}
		if (cnt >= S.size())break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)

int main() {
    long long A, B, N;
    cin >> A >> B >> N;
    if(N >= B-1) cout << A*(B-1)/B << endl;
    else{
         cout << A*(N % B)/B << endl;
    }

}

Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, tot=0;
	cin >> n;
	string s[n+1];
	map <string, int> l;
	map <string, bool> vis;
	for (int i=1; i<=n; i++){
		cin >> s[i];
		l[s[i]]++;
		vis[s[i]]=false;
	}
	for (int i=1; i<=n; i++)
		if (!vis[s[i]]){
			vis[s[i]]=true;
			tot+=(l[s[i]]-1);
		}
	cout << n-tot << endl;
	return 0;
} 

Measured memory_bytes: 41104
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int k,a,b;
      cin >> k >> a >> b;
      int count = 0;
      if(a%k ==0 ) count = b/k - a/k + 1;
      else count = b/k -a/k;
      if(count > 0) cout << "OK\n";
      else cout << "NG\n";
    }

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct lca {
    int n;
    vector<vector<int>> anc;
    vector<int> depth;
    vector<ll> dist;

    void dfs(vector<vector<P>>& G,int i,int p = -1) {
        for (P& e : G[i]) if (e.first != p) {
            anc[e.first].push_back(i);
            depth[e.first] = depth[i]+1;
            dist[e.first] = dist[i]+e.second;
            dfs(G,e.first,i);
        }
    }

    lca(vector<vector<P>>& G,int k) {
        n = G.size();
        anc.resize(n);
        depth.resize(n);
        dist.resize(n);
        depth[k] = 0;
        dist[k] = 0;
        dfs(G,k);
        int n = anc.size();
        for (int i = 0;i < 20;++i) {
            for (int j = 0;j < n;++j) {
                if (anc[j].size() < i+1 || anc[anc[j][i]].size() < i+1) continue;
                anc[j].push_back(anc[anc[j][i]][i]);
            }
        }
    }

    int getlca(int i,int j) {
        if (depth[i] > depth[j]) swap(i,j);
        while (depth[i] < depth[j]) {
            for (int k = anc[j].size()-1;k >= 0;--k) if (depth[anc[j][k]] >= depth[i]) {
                j = anc[j][k];
                break;
            }
        }
        while (i != j) {
            for (int k = anc[i].size()-1;k >= 0;--k) {
                if (anc[i][k] != anc[j][k]) {
                    i = anc[i][k];
                    j = anc[j][k];
                    break;
                } else if (k == 0) {
                    i = j = anc[i][0];
                }
            }
        }
        return i;
    }

    ll calc_dist(int i,int j) {
        return dist[i]+dist[j]-dist[getlca(i,j)]*2;
    }
};

int m;
vector<vector<P>> edges(50);
vector<P> a(20);
vector<ll> dp(1<<20,0);

void dfs(int i,int p,lca& l) {
    for (P b : edges[i]) if (b.first != p) {
        int s = 0;
        for (int j = 0;j < m;++j) if (l.calc_dist(a[j].first,a[j].second) == l.calc_dist(i,a[j].first)+l.calc_dist(i,a[j].second) && l.calc_dist(a[j].first,a[j].second) == l.calc_dist(b.first,a[j].first)+l.calc_dist(b.first,a[j].second)) s += (1<<j);
        for (int j = (1<<m)-1;j >= 0;--j) {
            dp[j|s] += dp[j];
        }
        dfs(b.first,i,l);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(P(v,1));
        edges[v].push_back(P(u,1));
    }
    lca l(edges,0);
    cin >> m;
    for (int i = 0;i < m;++i) cin >> a[i].first >> a[i].second,a[i].first--,a[i].second--;
    dp[0] = 1;
    dfs(0,-1,l);
    // p_ary(dp,0,1<<m);
    cout << dp[(1<<m)-1] << endl;
}

Measured memory_bytes: 8448
x=require('fs').readFileSync('/dev/stdin','utf8').trim().split(/\s/);

for(i=0;i<x.length-2;i+=2){
    count=0;
    y=x[i];
    if(i!=0||i==x.length-1)console.log("");
    if(y+x[i+1]==0)break;
    arr=[];
    for(;y<=x[i+1];y++){
        if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)){
            //console.log(y);
            arr.push(y);
            count++;
        }
    }

    if(count==0){
        console.log("NA");
    }else{
        arr.forEach(function(v){console.log(v);});
    }
    
}

Measured memory_bytes: 18000
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	rep(i, s.size()) {
		s[i] += n;
		if (s[i] > 'Z')s[i] -= 26;
		cout << s[i];
	}cout << endl;
}

Measured memory_bytes: 256