akhauriyash/Code-Regression huggingface dataset:
K = int(input())

def gcd(i,j):
    if min(i,j) == 0:
        return(max(i,j))
    else:
        return(gcd(min(i,j),max(i,j)%min(i,j)))

pair_dic = {}

wa = 0

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            # a-b check
            sa = str(a)
            sb = str(b)
            sc = str(c)
            kab = sa+"-"+sb
            kac = sa+"-"+sc
            kbc = sb+"-"+sc
            if kab in pair_dic.keys():
                ab = pair_dic[kab]
                kab2c = str(ab) +"-"+str(c)
                if kab2c in pair_dic.keys():
                    abc = pair_dic[kab2c]
                    wa += abc
                else:
                    abc = gcd(ab,c)
                    wa += abc
                    pair_dic[str(ab)+"-"+str(c)] = abc
                    pair_dic[str(c)+"-"+str(ab)] = abc
            elif kac in pair_dic.keys():
                ac = pair_dic[kac]
                kac2b = str(ac) +"-"+str(b)
                if kac2b in pair_dic.keys():
                    abc = pair_dic[kac2b]
                    wa += abc
                else:
                    abc = gcd(ac,b)
                    wa += abc
                    pair_dic[str(ac)+"-"+str(b)] = abc
                    pair_dic[str(b)+"-"+str(ac)] = abc
            elif kbc in pair_dic.keys():
                bc = pair_dic[kbc]
                kbc2a = str(bc) +"-"+str(a)
                if kbc2a in pair_dic.keys():
                    abc = pair_dic[kab2a]
                    wa += abc
                else:
                    abc = gcd(bc,a)
                    wa += abc
                    pair_dic[str(bc)+"-"+str(a)] = abc
                    pair_dic[str(a)+"-"+str(bc)] = abc
            else:
                ab = gcd(a,b)
                abc = gcd(ab,c)
                wa += abc
                pair_dic[kab] = ab
                pair_dic[sb+"-"+sa] = ab
                pair_dic[str(ab)+"-"+sc] = abc
                pair_dic[sc+"-"+str(ab)] = abc
                
print(wa)
                
                
                


Measured memory_bytes: 83844
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <set>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	multiset<int> d;
	REP(i, n){
		int t;
		cin >> t;
		d.insert(t);
	}
	cin >> m;
	multiset<int> t;
	REP(i, m){
		int tm;
		cin >> tm;
		t.insert(tm);
	}
	while(!t.empty()){
		auto itr = t.begin();
		int a = *itr;
		if(t.count(a) > d.count(a)){
			cout << "NO\n";
			return 0;
		}
		t.erase(a);
	}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
void YES(bool anser){
    if(anser)printf("YES\n");
    else printf("NO\n");
}
void Yes(bool anser){
    if(anser)printf("Yes\n");
    else printf("No\n");
}
void yes(bool anser){
    if(anser)printf("yes\n");
    else printf("no\n");
}
ll n,k;
int main(void){
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else cout<<1<<endl;
    
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

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

const ll mod = 998244353;
const int N = 1e4 + 5, M = 1e5 + 5;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)


int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++)
	{
		if(i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum << endl;
	return 0;
}


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

int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
main()
{
    int n;
    cin>>n;
    map<string,int>mp;
    string s;
    rep(i,n){
        cin>>s;
        if(mp.find(s)==mp.end()){
            mp.emplace(s,1);
        }else{
            mp[s]++;
        }
    }
    int m;
    cin>>m;
    rep(i,m){
        cin>>s;
        if(mp.find(s)==mp.end()){
            mp.emplace(s,0);
        }else{
            mp[s]--;
        }
    }
    auto begin = mp.begin(), end = mp.end();
    int ans1=0;
    string ans;
    for(auto itr=begin;itr!=end;itr++){
        if(ans1<itr->second){
            ans1=itr->second;
        }
    }
    cout<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //Use common MaxNum to reduce the compuation time
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4016
#include <iostream>

using namespace std;

int main() {
    string s;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='L') { cout<<"No"; return 0; }
    }

    for(int i=1;i<s.size();i+=2){
        if(s[i]=='R') {cout<<"No"; return 0; }
    }

    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

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

int main() {

    while (true) {

        int W, H;
        cin >> W >> H;

        if (!(W | H)) break;

        vector<vector<int>> S(H, vector<int>(W));
        for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> S[i][j];

        vector<int> c(4);
        for (int i = 0; i < 4; i++) cin >> c[i];

        vector<vector<vector<int>>> dp(H, vector<vector<int>>(W, vector<int>(4, INT_MAX)));
        dp[0][0][1] = 0;
        priority_queue<tuple<int, pair<int, int>, int>, vector<tuple<int, pair<int, int>, int>>, greater<tuple<int, pair<int, int>, int>>> Q;
        Q.push(make_tuple(0, make_pair(0, 0), 1));
        while (!Q.empty()) {
            auto t = Q.top();
            Q.pop();
            int cost = get<0>(t);
            int y = get<1>(t).first;
            int x = get<1>(t).second;
            int d = get<2>(t);
            if (dp[y][x][d] < cost) continue;
            for (int i = 0; i < 4; i++) {
                int nd = (d + i) % 4;
                int ncost = cost;
                if (i != S[y][x]) ncost += c[i];
                int toY = y + dy[nd];
                int toX = x + dx[nd];
                if (toY < 0 || toY >= H || toX < 0 || toX >= W) continue;
                if (dp[toY][toX][nd] > ncost) {
                    dp[toY][toX][nd] = ncost;
                    Q.push(make_tuple(ncost, make_pair(toY, toX), nd));
                }
            }
        }

        int ans = INT_MAX;
        for (int i = 0; i < 4; i++) ans = min(dp[H - 1][W - 1][i], ans);
        cout << ans << endl;

    }

    return 0;
}












































































Measured memory_bytes: 3284
//インクルード(アルファベット順)
#ifndef TEMPLATE
#define TEMPLATE
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<ctime>
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

#endif // TEMPLATE

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


signed main() {
ll N,ans;
cin >> N;
ans = (modpow(10,N,MOD) + modpow(8,N,MOD)) % MOD - 2*modpow(9,N,MOD)%MOD;
if(ans<0){
  ans += MOD;
}
answer(ans);
return 0;
}

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

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

using namespace std;
int main() {
	string s;
	cin >> s;

	string t = s;
	reverse(s.begin(), s.end());

	if (s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define sq(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl
#define setbitj(n, j) (n |= (1 << (j)))
#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAX = 100005;
const int MOD = 1000000007;

inline bool isEq(double a, double b){return abs(a - b) < EPS;}
inline double toRad(double deg){return deg*PI/180;}
inline double toDeg(double rad){return rad*180/PI;}

inline int geti(int &_int){return scanf("%d", &_int);}
inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}
inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}

inline int getl(ll &_ll){return scanf("%lld", &_ll);}
inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}
inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}

inline int getd(double &_double){return scanf("%lf", &_double);}
inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}

inline int getstr(char *str){return scanf("%s", str);}

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

int main(int argc, char* argv[])
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    if(s.size() == a+b+1){
        bool f = true;
        for(int i = 0; i < a+b+1; i++){
            if(i != a){
                f &= isdigit(s[i]);
            }
        }
        if( f&& s[a] == '-')
            cout << "Yes";
        else
            cout << "No";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{	
	int n, x;
	cin >> n >> x;
	vector<int> L(n);
	REP(i, n) cin >> L[i];
	vector<int> D(n+1);
	D[0] = 0;
	int ans = 1;
	for(int i = 1;i < n+1; i++){
		D[i] = D[i-1]+L[i-1];
		if(D[i] <= x) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << '\n'; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, a, b; cin >> n >> a >> b;
  if (a+b-1 > n || n > a*b) fail();

  ll s = 0;
  V ans;
  rep(i, a) {
    ll k = n + i + 1 - a - s;
    chmin(k, b);
    drep2(j, s+k, s) ans.push_back(j+1);
    s += k;
  }

  cout << ans;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

const ll MOD = 1e9+7;
int n, k;
vector<bool> visited;
vector<vector<int>> edges;
ll dfs(int q, ll k, ll k1, ll k2){
    visited[q] = true;
    ll ret = k;
    ll dk = 0;
    for(int p : edges[q]) if (!visited[p]){
        ret *= dfs(p, k+k1-dk-1, k2+dk, 1);
        ret %= MOD;
        dk++;
    }
    return ret;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    cin >> n >> k;
    edges.resize(n+1);
    visited.resize(n+1, false);
    FOR(i, n-1){
        int a,b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    ll ans = dfs(1, k, 0, 0);
    cout << ans << endl;

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    int k;
    cin>>k;
    
    int a[32]={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};
    cout<<a[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(3)

#include<bits/stdc++.h>
#define MST(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a ; i < b ; ++i)
#define per(i,a,b) for(int i = a ; i > b ; --i)
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using namespace std;
namespace fast_IO{
    const int maxbuff = 1<<17;
    char ibuff[maxbuff],obuff[maxbuff];
    inline char Getchar(){
        static char *p1=ibuff,*p2=ibuff;
        if(p1 == p2) {
            p1 = ibuff;
            p2 = ibuff+fread(ibuff,1,maxbuff,stdin);
            if(p1 == p2) return -1;
        }
        return *p1++;
    }

    int optr = 0;
    inline void Putchar(char c) {
        if(optr == maxbuff) {fwrite(obuff,1,optr,stdout);optr = 0;}
        obuff[optr++] = c;
    }

    inline void Flush() {
        fwrite(obuff,1,optr,stdout);
    }

    template<class T>
    inline int read(T &x) {
        x = 0;
        char c = Getchar();
        if(c == EOF) return -1;
        for( ; (c < '0' || c > '9') && c != EOF ; c = Getchar());
        if(c == EOF) return -1;
        for( ; c >= '0' && c <= '9' ; c = Getchar()) x = x*10+c-'0';
        return 0;
    }

    template<class T>
    inline void write(const T &x,int tag = 0) {
        if(!x) {
            if(!tag) Putchar(x+'0');
            return ;
        }
        write(x/10,1);
        Putchar(x%10+'0');
    }

    template<class T>
    inline void writeln(const T &x) {
        write(x);Putchar('\n');
    }

    template<class T>
    inline void writesp(const T &x) {
        write(x);Putchar(' ');
    }
}
template<class T> void show(T *x,int len,int s = 0) {for(int i = s ; i < s+len-1 ; ++i) cerr << x[i] << ' ';cerr << x[s+len-1] << endl;}
void debug() {cerr << endl;}
template <typename T, typename... Args> void debug(T x,Args... args) {cerr << x << ' ';debug(args...);}
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
#include <ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
typedef __gnu_pbds::priority_queue<pii,greater<>,pairing_heap_tag> heap;
typedef heap::point_iterator iter;

template<class T>
inline void cmin(T &A,const T &B) {A = (A<B?A:B);}
template<class T>
inline void cmax(T &A,const T &B) {A = (A>B?A:B);}

const int N = 1e5+19;
int n,k,s;
LL f[N];

void solve() {
    cin >> n >> k >> s;
    for(int i = 1 ; i <= k ; ++i)
        f[i] = f[i-1]+s;
    int p = 0;
    for(p = 2 ; p < N ; ++p)
        if(__gcd(p,s) == 1)
            break;
    for(int i = k+1 ; i <= n ; ++i)
        f[i] = f[i-1] + p;
    for(int i = n ; i ; --i)
        f[i] -= f[i-1];
    for(int i = 1 ; i <= n ; ++i)
        cout << f[i] << ' ';
}

signed main() {
#ifdef LOCAL
    freopen("input","r",stdin);
    //freopen("output","w",stdout);
#endif
    srand((int)time(0));
    ios::sync_with_stdio(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
using namespace std;

const long long inf = 1e10;
const long long mod = 1e9+7;

typedef vector<vector<int> > G;
G graph;

int color[100050];

bool dfs(int u, int c){
    color[u] = c;
    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if(color[v] == c){
            return false;
        }
        if(color[v] == 0 && !dfs(v, -c) ){
            return false;
        }
    }   
    return true;
}

int main(void){
    long long n, m;
    cin >> n >> m;
    graph = G(n);
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    long long B=0, W=0;
    if(dfs(0, 1)){
        for(int i=0; i<n; i++){
            if(color[i] == 1){
                B++;
            }else if(color[i] == -1){
                W++;
            }
        }
        cout << B*W - m << endl;
    }else{
        cout << ( (n*(n-1)) /2) - m << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6528
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = list(input())
    even = set(S[1::2])
    odd = set(S[0::2])
    o = {'R', 'U', 'D'}
    e = {'L', 'U', 'D'}
    res = 'Yes'
    if not(even <= e) or not(odd <= o):
        res = 'No'
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from collections import Counter

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

c = Counter(a)
s = [(k, v) for k, v in c.items() if v >= 2]

s1 = s2 = 0  # s1 >= s2
for k, v in s:
    if k > s1:
        if v >= 4:
            s1 = s2 = k
        else:
            s1, s2 = k, s1
    elif k > s2:
        s2 = k

print(s1 * s2)


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

int main()
{
    int N, M, T;
    cin >> N >> M >> T;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int sum = a[0] - M;
    for (int i = 0; i < N - 1; i++) {
        if (a[i + 1] - a[i] > 2 * M) {
            sum += a[i + 1] - a[i] - 2 * M;
        }
    }
    sum += max(0, T - a[N - 1] - M);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)<(0)?-(x):(x))

using namespace std;
using ll = long long;
const int N = 105;

int a[N];
int b[N];

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

	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> b[i];
	}
	a[1] = b[1];
	int ans = a[1];
	for(int i = 2; i < n; i++) {
		a[i] = min(b[i - 1], b[i]);
		ans += a[i];
	}
	ans += b[n - 1];
	cout << ans << endl;
	return 0;
}



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

int main()
{
    string s;
    getline (cin,s);
    int len = s.length();
    int i,j=1;
    string a;

    a = s[0];
    for(i=1; i<len; i++)
    {
        if(s[i] == 32)
        {
            a += s[++i];
        }
    }
    cout<<a;
}


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

int main(){
  int H,W;
  cin >>H >>W;
  char s[H][W];
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin>>s[i][j];
    }
  }
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if(s[i][j]=='#'){
        if((s[i-1][j]=='#')||(s[i+1][j]=='#')||(s[i][j-1]=='#')||(s[i][j+1]=='#')){
          continue;
        }
        else {
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  
  cout<<"Yes"<<endl;
   
  return 0;
}
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t m, ct=-1;
void f(int64_t n){
  if(n<=m) ct++;
  else return;
  f(10*n+3);
  f(10*n+5);
  f(10*n+7);
}
void g1(int64_t n){
  if(n<=m) ct--;
  else return;
  g1(10*n+3);
  g1(10*n+5);
}

void g2(int64_t n){
  if(n<=m) ct--;
  else return;
  g2(10*n+3);
  g2(10*n+7);
}

void g3(int64_t n){
  if(n<=m) ct--;
  else return;
  g3(10*n+5);
  g3(10*n+7);
}

void h1(int64_t n){
  if(n<=m) ct++;
  else return;
  h1(10*n+3);
}

void h2(int64_t n){
  if(n<=m) ct++;
  else return;
  h2(10*n+5);
}

void h3(int64_t n){
  if(n<=m) ct++;
  else return;
  h3(10*n+7);
}

int main() {
  cin >> m;
  f(0);
  g1(0);
  g2(0);
  g3(0);
  h1(0);
  h2(0);
  h3(0);
  cout << ct;
  return 0;
}


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

int main(){
	int64_t A, B, C, K;
	cin >> A >> B >> C >> K;
	// K <= A
	// 1 1 1 1 (K_ko)
	// A <= K <= A+B
	// 1 1 1 1 (A_ko) 0 0 (K-A_ko)
	// A+B <= K <= A+B+C
	// 1 1 1 1 (A_ko) 0 0 0 (B_ko) -1 (K-A-B_ko)
	if(K <= A){
		cout << K << endl;
	}else if(K <= A+B){
		cout << A << endl;
	}else{
		cout << A - (K-A-B) << endl;
	}
	return 0;
}

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

bool primecheck(int p) {
	if (p <= 1)return false;
	for (int i = 2; i + i <= p; i++) {
		if (p % i == 0)return false;
	}
	return true;
}
int main() {
	int N,p;
	cin >> N;
	p = N;
	while (!primecheck(p))p++;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3600
#define DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#else
#define bug(args...) 0
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    // cin >> T;
    auto inputAll = [&]()->void {
        
    };
    auto kase = [&]()->void {
        // cout << "Case " << cn << ": ";
        int x;
        cin>>x;
        cout<<8-(x-400)/200<<'\n';
    };
    auto resetAll = [&]()->void {
        
    };
    while (cn++!=T) inputAll(), kase(), resetAll();
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    A = []
    for _ in range(M):
        A.append(II())
    A.append(INF)
    dp = [0] * (N + 1)
    dp[0] = 1
    k = 0
    if A[0] == 1:
        dp[1] = 0
        k = 1
    else:
        dp[1] = dp[0]
    for i in range(2, N + 1):
        if i == A[k]:
            k += 1
            dp[i] = 0
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    ans = dp[N]
    return ans

print(main())

Measured memory_bytes: 7848
#pragma comment(linker, "/STACK:204800000,204800000");
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n,sum,l[1000000],vis[1000000],S[4000000],stage[4000000],top;
long long ans;
vector <int> g[1000000];
int DFS(int v){
	for (int i=0;i<g[v].size();i++) l[v]+=DFS(g[v][i]);
	return l[v];
}
bool cmp(int a,int b){
	return l[a]<l[b];
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		int b;
		scanf("%d%d",&l[i],&b);
		if (b!=-1){
			g[b].push_back(i);
			vis[i]=1;
		}
	}
	for (int i=0;i<n;i++) if (!vis[i]){
		S[0]=i;
		stage[0]=0;
		top=0;
		while (top!=-1){
			int cur=S[top];
			if (stage[top]==g[cur].size()){
				top--;
				if (top!=-1){
					l[S[top]]+=l[S[top+1]];
//printf("%d-%d\n",S[top],S[top+1]);
				}
			}
			else{
				S[top+1]=g[cur][stage[top]];
				stage[top]++;
				stage[++top]=0;
			}
		}
	}
	for (int i=0;i<n;i++) sort(g[i].begin(),g[i].end(),cmp);
	for (int i=0;i<n;i++){
		sum=0;
		for (int j=0;j<g[i].size();j++){
			ans+=sum;
			sum+=l[g[i][j]];
		}
	}
	//for (int i=0;i<n;i++) printf("%d ",l[i]);
	//printf("\n");
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 74304
from fractions import Fraction

def choose(n,r):
    res=1
    for i in range(r):
        res=res*(n-i)//(i+1)
    return res

n,a,b=map(int,input().split())
vs=sorted(map(int,input().split()))

average_max=Fraction(sum(vs[n-a:]),a)
print("{0:.9f}".format(float(average_max)))

res=0
for m in range(a,b+1):
    average=Fraction(sum(vs[n-m:]),m)
    if average<average_max:
        continue
    mn=min(vs[n-m:])
    res+=choose(sum(1 for x in vs if x==mn),
                sum(1 for x in vs[n-m:] if x==mn))
print(res)

Measured memory_bytes: 65516
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int x;//現在の乱数
int nx;//次の乱数
int A,B,C;//定数
int n;
int y;//条件
int step;
int ans;
int main(){
	while(cin>>n>>A>>B>>C>>x){
		if(n==0&&n==A&&A==B&&B==C&&C==x)
			break;
		step = 0;
		ans = -1;
		for(int i = 0;i <n;i++){
			cin>>y;
			while(1){
				if(step>10000){
					ans = -1;
					break;
				}
				if(x==y&&ans!=step){
					ans = step;
					break;
				}
				nx =(A*x+B)%C;
				//cout <<x<<endl;
				x= nx;
				step++;
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  ll n, K; cin >> n >> K;
  vl A(n);
  rep(i,n) cin >> A[i];

  ll ans = 0;
  vl cnt1(n,0), cnt2(n,0);
  rep(i,n) {
    REP(j,i+1,n) {
      if (A[i] > A[j]) {
        cnt1[j]++;
      }
    }
  }
  rep(i,n) {
    rep(j,n) {
      if (A[i] > A[j]) {
        cnt2[j]++;
      }
    }
  }

  rep(i,n) {
    ans += (cnt1[i] * K) % MOD;
    ans %= MOD;
  }
  if (K >= 2) {
    ll x = K * (K-1) / 2;
    x %= MOD;
    rep(i,n) {
      ans += (cnt2[i] * x) % MOD;
      ans %= MOD;
    }
  }
  // rep(i,n) cout << cnt1[i] << " \n"[i==n-1];
  // rep(i,n) cout << cnt2[i] << " \n"[i==n-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300;
int m[maxn][maxn];
int main() {
	int n;
	cin >> n;
	memset(m,0,sizeof(m));
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ 
		cin >> a[i];
		for(int j = 0; j < a[i]; ++j) m[i][j]++;
	}
	int ans = 0;
	for(int j = 0; j < maxn; ++j){
		int c = 0;
		for(int i = 0; i < maxn; ++i){
			if(m[i][j] == 0) continue;
			while(i < maxn and m[i][j] == 1) i++;
			i--;
			c++;
		}
		ans+= c;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int n,m,x;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&x);
		n-=x;
	}
	printf("%d\n",n>=0?n:-1);
	return 0;
}

Measured memory_bytes: 3820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DPL_3_B_Largest_Rectangle
{
	class Program
	{
		const int Dirty = 1;

		static void Main ( string[] args )
		{
			//input
			int[] size = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int width = size[1];
			int height = size[0];

			int[][] area = new int[height][];
			for (int lp = 0; lp < height; lp++)
			{
				area[lp] = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			}

			//process
			int[][] histgram = Histgram (area);

			int maxArea = 0;
			for (int lp = 0; lp < height; lp++)
			{
				maxArea = Math.Max (maxArea, GetLargestRectangle (width, histgram[lp]));
			}

			Console.WriteLine (maxArea);
		}

		static int[][] Histgram ( int[][] area )
		{
			int width = area[0].Length;
			int height = area.Length;
			int[][] histgram = new int[height][];

			for (int lp = 0; lp < height; lp++)
			{
				histgram[lp] = new int[width];
			}

			for (int col = 0; col < width; col++)
			{
				for (int row = 0; row < height; row++)
				{
					if (area[row][col] == Dirty)
					{
						histgram[row][col] = 0;
					}
					else
					{
						if (row == 0)
						{
							histgram[row][col] = 1;
						}
						else
						{
							histgram[row][col] = histgram[row - 1][col] + 1;
						}
					}
				}
			}

			return histgram;
		}

		static int GetLargestRectangle ( int size, int[] buffer )
		{
			Stack<Rectangle> rectangleCase = new Stack<Rectangle> (size / 2);
			int maxArea = 0;

			List<int> histgram = new List<int> (buffer);
			histgram.Add (-1);

			for (int lp = 0; lp <= size; lp++)
			{
				Rectangle rect = new Rectangle (histgram[lp], lp);

				//空だったら
				if (rectangleCase.Count == 0)
				{
					rectangleCase.Push (rect);
				}
				else
				{
					if (rectangleCase.Peek ().Height < rect.Height)
					{
						rectangleCase.Push (rect);
					}
					else if (rectangleCase.Peek ().Height > rect.Height)
					{
						Rectangle previousRect;

						do
						{
							previousRect = rectangleCase.Pop ();
							int area = previousRect.Height * (lp - previousRect.Position);
							maxArea = Math.Max (maxArea, area);
						}
						while (rectangleCase.Count != 0 && rectangleCase.Peek ().Height >= rect.Height);
						
						rect = new Rectangle (rect.Height, previousRect.Position);
						rectangleCase.Push (rect);
					}
				}
			}

			return maxArea;
		}
	}

	class Rectangle
	{
		public Rectangle ( int height, int position )
		{
			this.Height = height;
			this.Position = position;
		}

		public int Height { private set; get; }
		public int Position { private set; get; }
	}
}



Measured memory_bytes: 47216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A >= 13) {
        print(B);
    }
    else if (A <= 5) {
        print(0);
    }
    else {
        print(B/2);
    }
}

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

int main(){
	
	
	int n;
	cin >> n;
	
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
	}
	
	int cnt = 0;
	vector<int> b(3);
	for(int i = 1; i < n-1; i++){
		b[0] = p[i-1];
		b[1] = p[i];
		b[2] = p[i+1];
		sort(b.begin(),b.end());
		
		if(b[1] == p[i]) cnt++;
		
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[100005][3];
int abc[100005][3];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;;
    for(int i=0;i<n;i++)
    {
        cin>>abc[i][0]>>abc[i][1]>>abc[i][2];
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=abc[0][0];
    dp[0][1]=abc[0][1];
    dp[0][2]=abc[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+abc[i][j]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 3840
S = input()

if S == 'SUN':
    answer = 7

elif S == 'MON':
    answer = 6

elif S == 'TUE':
    answer = 5

elif S == 'WED':
    answer = 4

elif S == 'THU':
    answer = 3

elif S == 'FRI':
    answer = 2

elif S == 'SAT':
    answer = 1

print(answer)

Measured memory_bytes: 9052
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=deque()
for i in range(N):
  if i%2==0:
    l.append(A[i])
  else:
    l.appendleft(A[i])
if N%2==0:
  print(*l)
else:
  print(*list(reversed(l)))

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

int L[100000],R[100000];

void scan(int N){
    for(int i=0;i<N;i++){
        cin >> L[i] >> R[i];
    }
}



int main(){
    int a,b,c,d,i,N,M,ans;
    cin >> N >> M;
    scan(M);
  a=L[0];
  b=R[0];
  for(i=1;i<M;i++){
    if(a<L[i]) a = L[i];
  }
  for(i=1;i<M;i++){
    if(b>R[i]) b = R[i];
  }
    ans = b-a;
  
    
    if(ans<0){
        ans=-1;
    }
   ans = ans+1;
   cout << ans << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  lli A,B,C=0,D=0,E=0,F=INF,G=INF,H=-1,N,M,K,sum=0;
  string S;cin >> S;
  cin >> K;
  rep(i,0,K){
    if(S[i]=='1')H=i;
    else break;
  }
  if(H>=K-1)Out(1);
  else Out(S[H+1]);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int w,h;cin>>h>>w;
    string s[h]={""};
    rep(i,h){cin>>s[i];}
    rep(i,h){s[i].insert(0,"#");s[i].push_back('#');}
    string up="";
    rep(i,w+2)up.push_back('#');
    co(up);
    rep(i,h){
        co(s[i]);
    }
    co(up);
}

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    if (a>=k){
        cout<<k<<endl;
    }else if(a+b>=k){
        cout<<a<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: usize,
        d: [(u64,u64);n],
    }

    for i in 0..n - 2 {
        if d[i].0 == d[i].1 && d[i + 1].0 == d[i + 1].1 && d[i + 2].0 == d[i + 2].1 {
            println!("Yes");
            return;
        }
    }

    println!("No");
}


Measured memory_bytes: 2188
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [n, m] <- g
  solve n <$> f <*> replicateM m g >>= print
  where
    f = readiv B.readInt <$> B.getLine
    g = map read <$> words <$> getLine

solve :: Int -> Vector Int -> [[Int]] -> Int
solve n vh = (n -) . IS.size . foldl f IS.empty
  where
    f st [a, b] = case compare (vh ! (a - 1)) (vh ! (b - 1)) of
      GT -> IS.insert b st
      LT -> IS.insert a st
      EQ -> IS.insert a (IS.insert b st)

readiv :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


Measured memory_bytes: 87968
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int h = t / 3600;
        int m = (t % 3600) / 60;
        int s = (t % 3600) % 60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

std::string s;

int main(int argc, char const* argv[])
{
    std::cin >> s;
    char c = ' ';
    for (const auto& e : s) {
        if (e == c) {
            std::cout << "Bad" << std::endl;
            return 0;
        }
        c = e;
    }
    std::cout << "Good" << std::endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<ll> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VL s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];
  VVL dp(n+1, VL(m+1, 0LL));
  VVL sm(n+1, VL(m+1, 0LL));
  FOR(i, 1, n+1) FOR(j, 1, m+1) {
    if(s[i-1] != t[j-1]) dp[i][j] = 0LL;
    else dp[i][j] = (sm[i-1][j-1] + 1LL) % MOD;
    sm[i][j] = (sm[i-1][j] % MOD + sm[i][j-1] % MOD - sm[i-1][j-1] % MOD + dp[i][j] % MOD + MOD) % MOD;
  }
  out((sm[n][m] + 1LL) % MOD);
  return 0;
}


Measured memory_bytes: 62976
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector <int> x(N);
  for (int i = 0; i < N; i++) {
	  cin >> x[i];
	}
  vector <int> y(M);
  for (int i = 0; i < M; i++) {
	  cin >> y[i];
	}
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (max(x[N - 1], X) < min(y[0], Y)) {
	  cout << "No War" << endl;
	} else {
	  cout << "War" << endl;
	}
  return 0;
}


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

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<vector>
#include<cstdio>
#include<sstream>

using namespace std;

namespace patch
{
	template < typename T > std::string to_string(const T& n)
	{
		std::ostringstream stm;
		stm << n;
		return stm.str();
	}
}

int main() {
	while (1) {
		int l;
		string str;
		cin >> str >> l;
		if (l == 0)break;
		int size = str.size();
		if(l-size>0)for (int i = 0; i < l - size; i++)str.insert(str.begin(), '0');
		//cout << str << endl;
		typedef string Str;
		vector<Str> ai;
		ai.push_back(str);

		int n = 1;
		while (1) {
			bool bre = false;
			string tstr = ai[n - 1];
			sort(tstr.begin(), tstr.end(), greater<int>());
			int max = atoi(tstr.c_str());
			sort(tstr.begin(), tstr.end());
			int min = atoi(tstr.c_str());
			int d = max - min;
			//cout <<max<<'-'<<min<<'='<< d << endl;

			for (int i = 0; i < n; i++) {
				int comp = atoi(ai[i].c_str());
				//cout << comp << endl;
				if (d == comp) {
					cout << i << ' ' << d << ' ' << n - i << endl;
					bre = true;
					break;
				}
			}

			if (bre)break;
			else {
				string pstr = patch::to_string(d);
				int psize = pstr.size();
				if(l-psize>0)for (int i = 0; i < l - psize; i++)pstr.insert(pstr.begin(), '0');
				ai.push_back(pstr);
				n++;
			}
		}
	}
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[100002]={0};
    for (int i = 0; i < n; ++i) {
        int in;
        cin>>in;
        num[in]++;
        num[in+1]++;
        num[in+2]++;
    }
    int maxn = 0;
    for (int j : num) {
        maxn= max(maxn, j);
    }
    cout<<maxn<<endl;
    return 0;
}


Measured memory_bytes: 640