akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n; cin >> n;
    VL a(n); cin >> a;
    rSORT(a);
    priority_queue<tuple<ll, ll, ll>> p;
    p.emplace(a[1], a[0], a[1]);
    p.emplace(a[1], a[0], a[1]);
    ll ans = a[0];
    FOR(i, 2, n) {
        auto [v, x, y] = p.top();
        p.pop();
        ans += v;
        p.emplace(min(x, a[i]), x, a[i]);
        p.emplace(min(y, a[i]), y, a[i]);
    }

    print(ans);

    return 0;
}

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

int main ()
{
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.length();i++)
    {
        s[i]=(s[i]+n-'A')%26 +'A';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
def dot(a, b):
  return a.real * b.real + a.imag * b.imag

def cross(a, b):
  return a.real * b.imag - a.imag * b.real

def cross_point(p0,p1,p2,p3):
  base=p3-p2
  d1=abs(cross(base,p0-p2))
  d2=abs(cross(base,p1-p2))
  t=d1/(d1+d2)
  ans= p0+(p1-p0)*t
  return ans.real,ans.imag

n = int(input())
for i in range(n):
  x0,y0,x1,y1,x2,y2,x3,y3 = map(int,input().split())
  p0=complex(x0,y0)
  p1=complex(x1,y1)
  p2=complex(x2,y2)
  p3=complex(x3,y3)
  print(*cross_point(p0,p1,p2,p3))


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

const int MAX = 1000000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

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

    COMinit();
    sort(a.begin(), a.end(), greater<ll>());
    ll ansn = a[0];
    ll diff = INF;
    ll ansr = 0;
    for (ll i = 1; i < n; i++) {
        if (abs(a[i] * 2 - ansn) < diff) {
            diff = abs(a[i] * 2 - ansn);
            ansr = a[i];
        }
    }
    cout << ansn << " " << ansr << endl;

    return 0;
}


Measured memory_bytes: 24448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
int main(void)
{
  int H=IN(),W=IN(),M=IN(),row[H]={0},col[W]={0},bombY[M],bombX[M],
  destroy=0,idh=0,idw=0,hmax=0,wmax=0,obj=0;
  rep(i,M)
  {
    bombY[i]=IN()-1,bombX[i]=IN()-1;
    row[bombY[i]]++;col[bombX[i]]++;
    hmax=Max(hmax,row[bombY[i]]);wmax=Max(wmax,col[bombX[i]]);
  }
  rep(i,H){if(hmax==row[i]){idh++;}}rep(j,W){if(wmax==col[j]){idw++;}}
  destroy=hmax+wmax;
  rep(i,M){if(row[bombY[i]]==hmax&&col[bombX[i]]==wmax){obj++;}}
  return OUT(1l*obj==1l*idh*idw?destroy-1:destroy),0;
}

Measured memory_bytes: 6220
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, q;
    while (cin >> k >> q && k) {
        vector<pair<pair<string, int>, int> > v;
        rep(i, k) {
            string a; int b, c;
            cin >> a >> b >> c;
            v.push_back({{a, b}, c});
        }
        using psii = pair<pair<string, int>, int>;
        sort(v.begin(), v.end(), [](const psii& x, const psii& y){return x.second < y.second;});
        rep(i, q) {
            int a; cin >> a;
            
            rep(j, v.size()) {
                if (a <= v[j].second) {
                    
                    int b = v[j].second - a;
                    if (v[j].first.second - b > 0) {
                        cout << v[j].first.first << " " << v[j].first.second - b << endl;
                    } else {
                        cout << "Unknown" << endl;
                    }
                    break;
                }
                if (j == v.size() - 1) {
                    cout << "Unknown" << endl;
                }
            }
            
        }
    }
}







Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] musics =new String[N];
		int[] m =new int[N];
		int piv =0;
		int ans =0;
		String target;

		for (int i = 0; i < N; i++) {
			musics[i] = sc.next();
			m[i] = sc.nextInt();
		}

		target = sc.next();

		for (int i = 0; i < N; i++) {
			if (musics[i].equals(target)) {
				piv = i + 1;
			}
		}

		for (int i = piv; i < N; i++) {
			ans += m[i];
		}

		System.out.println(ans);

	}
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {


    int N;
    cin >> N;
    vector<int> h(N);
    int max_ = 0;

    REP(i, N){
        cin >> h[i];
        max_ = max(max_, h[i]);
    }
    int ans = 0;
    REP(i, max_){
        int res = 0;
        int j = 0;
        while(j<N){
            if(h[j]==0){
                j++;
            }
            else{
                res++;
                while(j < N && h[j]>0){
                    ++j;
                }
            }
            // cout << "a"<<endl;
        }
        ans += res;
        REP(j, N){
            if(h[j]>0)
            h[j]--;
        }
    }

    cout << ans << endl;



}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 256
#include<iostream>

using namespace std;
                                                                       
int main(){
    int n, k, ans = 0; cin >> n >> k;
    string s; cin >> s;
    for(int i = 1; i < n; ++i) ans += s[i] == s[i-1];

    cout << min(n-1, ans + 2 * k);
}


Measured memory_bytes: 512
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

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

  std::string s;
  std::cin>>s;

  ll n=s.size();

  ll q;
  std::cin>>q;

  ll mode=0;

  std::deque<char> front,back;

  rep(i,0,q){
    ll t;
    std::cin>>t;
    if(t==1){
      mode^=1;
    }else{
      ll f;
      char c;
      std::cin>>f>>c;

      if(f==1){
        if(mode==0){
          front.push_front(c);
        }else{
          back.push_back(c);
        }
      }else{
        if(mode==0){
          back.push_back(c);
        }else{
          front.push_front(c);
        }
      }
    }
  }

  if(mode==0){
    while(!front.empty()){
      std::cout<<front.front();
      front.pop_front();
    }
    std::cout<<s;
    while(!back.empty()){
      std::cout<<back.front();
      back.pop_front();
    }
  }else{
    while(!back.empty()){
      std::cout<<back.back();
      back.pop_back();
    }
    std::reverse(all(s));
    std::cout<<s;
    while(!front.empty()){
      std::cout<<front.back();
      front.pop_back();
    }
  }

  std::cout<<"\n";

  return 0;
}



Measured memory_bytes: 848
#include<bits/stdc++.h>
#define FF first.first
#define FS first.second
#define  F first
#define  S second
using namespace std;
typedef pair<int,string>P;
typedef pair<P,int>PP;
typedef pair<string,int>PPP;
int main(void){
	int n;
	PP p[10001];
	PPP pp[10001];
	int  i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p[i].FS>>p[i].S;
		p[i].FF=p[i].FS.size();
		pp[i].S=0;
	}
	sort(p,p+n);
	
	int j=0;
	for(i=0;i<n;i++){
		pp[j].F=p[i].FS;
		pp[j].S+=p[i].S;
		if(p[i].FS!=p[i+1].FS){
			j++;
		}
	}
	for(i=0;i<j;i++){
		cout<<pp[i].F<<" "<<pp[i].S<<endl;
	}
	return 0;
}
	
	


Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=110000;
int d[N];

int main() {
    int i, n, m, u, v;
    scanf("%d%d", &n, &m);
    while(m--) {
        scanf("%d%d", &u, &v);
        d[u]^=1;
        d[v]^=1;
    }
    for(i=1; i<=n; i++) if(d[i]) break;
    printf(i<=n? "NO\n" : "YES\n");
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
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;
}
ll cnt[110000];
int main() {
    ll N, K; cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i > 0; i--) {
        ll x = K / i;
        cnt[i] = modpow(x, N, 1000000007);
        for (ll j = 2; j <= x; j++) {
          cnt[i] -= cnt[j * i];
          if (cnt[i] < 0)cnt[i] += 1000000007;
        }
        ans += i * cnt[i];
        ans %= 1000000007;


    }

    cout << ans << endl;
}

































































Measured memory_bytes: 4372
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
    int R[MAX], n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << "\n";
    
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1
#define rgi register int
#define ll long long
#define pii pair<int,int>
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
const int maxn=200005;
int n,m,a[maxn],b[maxn];
struct sgt
{
	int p,l,r;
	ll val,add;
}t[maxn<<2];
void build(int p,int l,int r)
{
	t[p].l=l,t[p].r=r;
	if(l==r)
	{
		t[p].val=a[l];
		return;
	}
	int mid=(l+r)>>1;
	build(ls,l,mid);
	build(rs,mid+1,r);
	t[p].val=t[ls].val+t[rs].val;
}
inline void spread(int p)
{
	if(t[p].add)
	{
		t[ls].val+=t[p].add*(t[ls].r-t[ls].l+1);
		t[rs].val+=t[p].add*(t[rs].r-t[rs].l+1);
		t[ls].add+=t[p].add;
		t[rs].add+=t[p].add;
		t[p].add=0;
	}
}
void change(int p,int l,int r,ll x)
{
	if(l<=t[p].l&&t[p].r<=r)
	{
		t[p].add+=x;
		t[p].val+=x*(t[p].r-t[p].l+1);
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(mid>=l)
		change(ls,l,r,x);
	if(mid<r)
		change(rs,l,r,x);
	t[p].val=t[ls].val+t[rs].val;
}
ll sum(int p,int l,int r)
{
	if(l<=t[p].l&&t[p].r<=r)
		return t[p].val;
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	ll ret=0;
	if(mid>=l)
		ret+=sum(ls,l,r);
	if(mid<r)
		ret+=sum(rs,l,r);
	return ret;
}
bool check()
{
    for(int i=1;i<=n;++i)
        if(b[i]!=n)
            return 0;
    return 1;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
        cin>>a[i];
    build(1,1,n);
    memset(a,0,sizeof(a));
    for(int i=1;i<=m;++i)
    {
        for(int i=1;i<=n;++i)
            b[i]=sum(1,i,i);
        if(check())
            break;
        build(1,1,n);
        for(int i=1;i<=n;++i)
        {
            int l=max(i-b[i],1),r=min(i+b[i],n);
            change(1,l,r,1);
        }
    }
    for(int i=1;i<=n;++i)
        cout<<sum(1,i,i)<<" ";
    cout<<endl;
	return 0;
}

Measured memory_bytes: 21596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,k;
  while(cin >> n >> k, n+k) {
    vector<int> v;
    bool zero = 0;
    REP(i,k) {
      int a;
      cin >> a;
      if (a == 0 ) zero = 1;
      else v.push_back(a);
    }
    int m = v.size();
    sort(ALL(v));
    int hoge[2] = {1,1};
    int res[2] = {0,0};
    REP(i,m-1) {
      REP(j,2) {
        if (v[i] + 1 == v[i+1])
          hoge[j]++;
        else if (j==0 && v[i] + 2 == v[i+1])
          hoge[0] = hoge[1] + 2;
        else hoge[j] = 1;
        res[j] = max(res[j], hoge[j]);
      }
    }
    if (!zero)
      cout << res[1] << endl;
    else {
      if (res[1] == res[0] && k != n) res[0]++;
      cout << res[0] << endl;
    }
  }
}

Measured memory_bytes: 1352
//
// Created on 2020/01/10.
//

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

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

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

int main() {
    ll A;
    ll B;
    ll ans;
    cin>>A;
    cin>>B;

    ans = lcm(A,B);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;
int t;

int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();i++) if(i%t==0) cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=1001;
int n, cnt, dd[N*N], k, ans, c[N*N], mark[N*N];
long long b[N*N], a[N];
vector <int > v[45];

bool cmp(int i, int j) {
    return dd[i]>dd[j];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> k;
    rep(i, 1, n) { cin >> a[i]; a[i]+=a[i-1]; }
    rep(i, 1, n)
        rep(j, i, n) {
            b[++cnt]=a[j]-a[i-1];
        }
    rep(i, 0, 39) {
        rep(j, 1, cnt) {
            if((b[j]>>i)&1ll) v[i].push_back(j);
        }
    }

    int fl=0;
    bool ok=0;
    for(int i=39 ; i>=0 ; --i) {
        if(v[i].size()<k) continue;
        ok=1;
        int dem=0;
        for(int x:v[i]) if(mark[x]==fl) ++dem;
        if(dem<k) continue;
        for(int x:v[i]) if(mark[x]==fl) {
                mark[x]=fl+1;
                ++dd[x];
        }
        ++fl;
    }
    if(ok==false) return cout << 0, 0;
    rep(i, 1, cnt) c[i]=i;
    sort(c+1, c+cnt+1, cmp);
    long long ans=b[c[1]];
    rep(i, 2, k) ans&=b[c[i]];
    cout << ans;
    return 0;
}


Measured memory_bytes: 54260
import math
A, B, H, M = (int(x) for x in input().split())

C = 0.5 * (60 * H + M) #A(時針の角度)
D = 6 * M #B(分針の角度)
E = math.radians(D - C) #E(2針の角度の差(ラジアンに直した))

F = (A * A) + (B * B) - (2 * A * B * math.cos(E))

print(math.sqrt(F))

Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
   for (int i = 0; i < N; i++) {
     cin >> vec.at(i);
   }
  
  int a = vec.at(0); // ボタン1の番号
  int x = 1; // ボタンを押す回数
  
   for (int i = 0; i < N; i++) {
     if (vec.at(0) == 2){
       break;
     }
     else if (vec.at(a-1) == 2){
       x ++;
       break;
     }
     else if(x == N){
       x = -1;
       break;
     }
     else{
       x ++;
       a = vec.at(a-1);
     }
   }
  cout << x << endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

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

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  int H, W, N; cin >> H >> W >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  vector<vector<int>> res(H, vector<int>(W, 0));
  int cnt = 0;
  rep(i, 0, H){
    rep(j, 0, W){
      int k;
      if(i % 2) k = W - j - 1;
      else k = j;
      res[i][k] = cnt + 1;
      A[cnt]--;
      if(A[cnt] == 0) cnt++;
    }
  }
  rep(i, 0, H){
    rep(j, 0, W){
      cout << res[i][j];
      if(j != W - 1) cout << " ";
      else cout << endl;
    }
  }
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        if(a+b >= 10){
            System.out.println("error");
        }else{
            System.out.println(a+b);
        }
    }
}


Measured memory_bytes: 21332
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

p=set()
q=set()
r=[1]*N
r[0]=0
for j in range(N-2):
  i=j+1
  r[i+1]=r[i]*(i+1)
pnum=0
qnum=0
for i in range(N):
  k=0
  for j in range(P[i]):
    if {j+1}<=p:
      k=k
    else:
      k+=1
  pnum+=r[N-1-i]*(k-1)
  p.add(P[i])
  
  k=0
  for j in range(Q[i]):
    if {j+1}<=q:
      k=k
    else:
      k+=1
  qnum+=r[N-1-i]*(k-1)
  q.add(Q[i])
  
print(abs(pnum-qnum))

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(int i=0; i<N; i++){
        cin >> w[i] >> v[i];
    }
    vector<vector<ll> > dp(N+1, vector<ll>(W+1));
    for(int i=0; i<N; i++){
        for(int ws=0; ws<=W; ws++){
            if(ws < w[i]){
                dp[i+1][ws] = dp[i][ws];
            }else{
                dp[i+1][ws] = max(dp[i][ws], dp[i][ws-w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n;
struct Edge
{
  int to, id;
};
vector<Edge> tree[maxN];
int colors[maxN];

void solve(int u = 0, int prv = -1, int prvColor = 0)
{
  int c = 0;
  for (Edge &e: tree[u])
    if (e.to != prv)
    {
      c ++;
      if (prvColor == c) c ++;
      colors[e.id] = c;
      solve(e.to, u, c);
    }
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i ++)
      tree[i].clear();
    for (int i = 0; i < n - 1; i ++)
    {
      int u, v; scanf("%d %d", &u, &v); u --, v --;
      tree[u].push_back({v, i}), tree[v].push_back({u, i});
    }

    solve();
    int k = 1;
    for (int i = 0; i < n - 1; i ++)
      k = max(k, colors[i]);
    printf("%d\n", k);
    for (int i = 0; i < n - 1; i ++)
      printf("%d%c", colors[i], i < n - 2 ? ' ' : '\n');
  }
  return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 105;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
const int MOD = 1e9+7;


int h[N];
int Has[N]; int tot;
ll dp[N][N];

ll Pow(ll x, ll y) {
	if(y <= 0) return 1;
	ll result = 1;
	while(y) {
		if(y & 1)
			result = result * x % MOD;
		y >>= 1;
		x = x*x % MOD;
	}
	return result;
}

int main() {
	int n;
	while(~scanf("%d", &n)) {
		tot = 0;
		memset(dp, 0, sizeof(dp));
		h[0] = 0;
		dp[0][0] = 1;

		for(int i = 1; i <= n; ++i) {
			scanf("%d", &h[i]);
			Has[++tot] = h[i];
		}
		sort(Has + 1, Has + tot + 1);
		tot = unique(Has+1, Has + tot + 1) - Has - 1;
		
		for(int i = 1; i <= n; ++i) {
			h[i] = lower_bound(Has + 1, Has + tot + 1, h[i]) - Has;
		}
		
		
		for(int i = 1; i <= n; ++i) {
			dp[i][0] = dp[i-1][0] * 2 % MOD;
			for(int j = h[i] + 1; j <= h[i-1]; ++j) dp[i][0] = (dp[i][0] + dp[i-1][j] * 2 % MOD) % MOD;

			ll tmpPow = Pow(2, Has[h[i]] - Has[h[i-1]]);
			for(int j = 1; j <= h[i]; ++j) {
				dp[i][j] = dp[i-1][j] * tmpPow % MOD;
			}

			for(int j = h[i-1] + 1; j <= h[i]; ++j) {
				dp[i][j] = (dp[i][j] + j==1? ( dp[i-1][0] * ( Pow(2, Has[j]) - 2) % MOD * Pow(2, Has[h[i]] - Has[j]) % MOD ) :
											 ( dp[i-1][0] * 2 * (Pow(2, Has[j]-Has[j-1]) - 1) % MOD * Pow(2, Has[h[i]]-Has[j]) % MOD ) 
											 ) %MOD;
			}
		}


		ll result = 0;
		for(int i = 0; i <= tot; ++i) {
			result = (result + dp[n][i]) % MOD;
		}
		printf("%lld\n", result);
	}
	return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}



int main(void) {
    FAST_IO;
    
    int n, k;
    string s;
    cin >> n >> k >> s;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && s[i] == 'L' && s[i - 1] == 'L')
            ans++;
        if (i < n - 1 && s[i] == 'R' && s[i + 1] == 'R')
            ans++;
    }
    cout << min(ans + 2 * k, n - 1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long n, m, k;

	std::cin >> n >> m >> k;

	for (size_t i = 0; i <= n; i++)
	{
		for (size_t j = 0; j <= m; j++)
		{
			if (i * m + j * n - i * j * 2 == k) {
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}

	for (size_t i = 0; i <= m; i++)
	{
		for (size_t j = 0; j <= n; j++)
		{
			if (i * n + j * m - i * j * 2 == k) {
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "No" << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b,c;

main(){
  cin>>a>>b>>c;

  cout<<min(a+b,min(b+c,c+a))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if((c-a-b)*(c-a-b)>4*a*b && c-a-b >= 0) dunk("Yes");
    else dunk("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EPS (1e-15)
using namespace std;

int K,R,L;
double P,E,T,ans,cnt;

void func(int k,double l,double r,double p){
  double h=(l+r)/2;
  cnt++;
  if(l-(T+E)>EPS||T-E-r>EPS)return;
  else if(l-(T-E)>=EPS&&T+E-r>=EPS){
    ans+=p;
    return;
  }
  if(k==K&&E-abs(h-T)>=EPS){
    ans+=p;
    return;
  }
  if(k==K)return;
  if(T<=h){
    func(k+1,l,h,p*(1-P));
    func(k+1,h,r,p*P);
  }else{
    func(k+1,l,h,p*P);
    func(k+1,h,r,p*(1-P));
  }
}

int main(){
  cin>>K>>R>>L>>P>>E>>T;
  func(0,R,L,1);
  //cout<<cnt<<endl;
  printf("%.15f\n",ans);
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
//input
long long x;
long long count=0;
long long ans=0;
bool flag=false;
// long long a=0;
// long long b=0;
scanf("%lld",&x);

while(!flag){
 flag=true;
  for (int i=2; i<=sqrt(x); i++) {
    int m=x%i;
		if (m==0) {
		flag=false;
		}
  }
  if(flag==false)x++;
}

//output
	printf("%lld",x);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());
			if (n == 0)
				break;

			ArrayList<Schedule> sche = new ArrayList<>();

			for (int i = 0; i < n; i++) {
				String str[] = br.readLine().split(" ");
				String d[] = str[0].split(":");
				String a[] = str[1].split(":");
				sche.add(new Schedule(Integer.parseInt(d[0]), Integer.parseInt(d[1]), Integer.parseInt(d[2]),
						Integer.parseInt(a[0]), Integer.parseInt(a[1]), Integer.parseInt(a[2])));
			}
			Collections.sort(sche);

			int max = 0;

			for (int i = 0; i < n; i++) {
				int last = sche.get(i).e;
				int count = 1;
				for (int j = i + 1; j < n; j++) {
					if (last <= sche.get(j).e && last > sche.get(j).s) {
						count++;
					}
					max = Math.max(max, count);
				}
			}
			System.out.println(max);
		}
	}
}

class Schedule implements Comparable<Schedule> {
	int s;
	int e;

	public Schedule(int sh, int sm, int ss, int eh, int em, int es) {
		this.s = sh * 3600 + sm * 60 + ss;
		this.e = eh * 3600 + em * 60 + es;
	}

	@Override
	public int compareTo(Schedule s) {
		if (this.e != s.e)
			return this.e - s.e;
		return this.s - s.s;
	}
}


Measured memory_bytes: 69200
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >>a;
  cin >>b;

 if(a<b)
 cout <<"a < b";

 else if(a>b)
 cout<<"a > b";
 else if (a==b)
 cout<<"a == b";
 cout <<endl;

}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int sx,sy,x,y,n,sm,m,flag = 1;

int main()
{
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        cin>>m>>x>>y;
        if(x == sx && y == sy)
        {
            if((m - sm) % 2)flag = 0;
        }
        else
        {
            int d = abs(x - sx) + abs(y - sy);
            if(!((m - sm) && (m - sm) % d == 0 && ((m - sm) / d) % 2))flag = 0;
        }
        sx = x,sy = y,sm = m;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    char tmp;
    string S;
    cin >> N;

    ans = 800*N - N/15 * 200;
    
    
    // ans = max(A*B, C*D);
    
    cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  if (x == 7 || x == 5 || x == 3)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   int n,count=0;
   sc(n);
   string str;
   cin>>str;
   char a=str[0];
   for(int i=1;i<n;i++){
      if(str[i]!=a){
         count++;
         a=str[i];
      }
   }
   count++;
   pf(count);
   return 0;
}


Measured memory_bytes: 3912
s = input()
first = 'MM'
second = 'MM'

if int(s[:2]) > 12 or int(s[:2]) == 0:
	first = 'YY'
	if int(s[2:]) == 0:
		first = 'NA'

if int(s[2:]) > 12 or int(s[2:]) == 0:
	second = 'YY'
	if int(s[:2]) == 0:
		second = 'NA'

if first == 'MM' and second == 'MM':
	print('AMBIGUOUS')
elif first == 'YY' and second == 'YY':
	print('NA')
elif first == 'NA' or second == 'NA':
	print('NA')
else:
	print(first+second)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    ll a,b;
    cin >> a >> b;
    cout << a*b << "\n";

    
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>


int sum_each_digit() {
  char x[1001];
  int ans = 0;
  std::cin >> x;
  if (x[0] == '0') return -1;
  for (int i = 0; x[i] != '\0'; i ++) {
    ans += (int)x[i] - 48;
  }
  return ans;
}

int main() {
  int ans;
  while (true) {
    ans = sum_each_digit();
    if (ans == -1) break;
    std::cout << ans << std::endl;
  }

  return 0;
}



Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 2e6 + 10;
char ar[maxn], br[maxn];
int f[maxn];
bool sign[maxn];
void getFail(char *P, int *f) {
	int m = strlen(P);
	f[0] = f[1] = 0;
	for (int i = 1; i < m; ++i) {
		int j = f[i];
		while (j && P[i] != P[j]) j = f[j];
		f[i + 1] = P[i] == P[j] ? j + 1 : 0;
	}
}
void Find(char *T, char *P, int *f) {
	int n = strlen(T), m = strlen(P);
	getFail(P, f);
	int j = 0;
	for (int i = 0; i < n; ++i) {
		while (j && T[i] != P[j]) j = f[j];
		j = T[i] == P[j] ? j + 1 : 0;
		if (j == m) {
			// cout << i << endl;
			sign[i - m + 1] = 1;
		}
	}
}

vector<int> G[maxn];
int  vis[maxn];
int q[maxn];
int cnt = 0;
int dp[maxn];
void dfs(int u) {
	vis[u] = 1;
	for (auto c : G[u]) {
		if (vis[c] == 2) continue;
		if (vis[c] == 1) {
			cout << -1 << endl;
			exit(0);
		}
		dfs(c);
	}
	vis[u] = 2;
	q[++cnt] = u;
}
int main(void)
{
	cin >> ar >> br;
	int n = strlen(ar);
	int m = strlen(br);
	int nn = n;
	// cout << n << endl;
	while (n < nn + m) {
		for (int i = 0; i < nn; ++i)
			ar[n++] = ar[i];
	}
	ar[n] = '\0';
	// cout << strlen(ar) << endl;
	// cout << ar << endl;
	Find(ar, br, f);
	for (int i = 0; i < nn; ++i) {
		if (sign[i]) {
			// cout << i << " " << (i + m) % nn << endl;
			G[i].Pb((i + m) % nn);
		}
	}
	// DEBUG;
	for (int i = 0; i < nn; ++i) {
		if (!vis[i]) {
			dfs(i);
		}
	}
	assert(cnt == nn);
	int ans = 0;
	for (int i = nn; i >= 1 ; --i) {
		int t = q[i];
		for (auto c : G[t]) {
			dp[c] = max(dp[c], dp[t] + 1);
			ans = max(ans, dp[c]);
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 104192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APainting solver = new APainting();
        solver.solve(1, in, out);
        out.close();
    }

    static class APainting {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt(), m = s.nextInt(), k = s.nextInt();
            if (n > m) {
                int temp = n;
                n = m;
                m = temp;
            }
            int cost = 0, count = 0;
            for (int i = 0; i < n && count < k; i++) {
                count += m;
                cost++;
            }
            w.println(cost);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int sum(int *a, int n){
  int r = 0;
  rep(i, n){
    r += a[i];
  }
  return r;
}

bool maina(){
  int input(n);
  int input(m);
  if(n == 0 &&  m == 0) return false;
  int list_input(t, n);
  int list_input(h, m);

  rep(i, n){
    rep(j, m){
      int tmp = h[j];
      h[j] = t[i];
      t[i] = tmp;
      if(sum(h, m) == sum(t, n)){
        p("%d %d", h[j], t[i]);
        goto GOAL;
      }
      tmp = t[i];
      t[i] = h[j];
      h[j] = tmp;
    }
  }
  p("%d", -1) return true;

GOAL:
  return true;
}

int main(){
  while(maina());
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <math.h>

int main() {
	int N,D;
	scanf("%d %d",&N,&D);
	double cor[N][D];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			scanf("%lf",&cor[i][j]);
		}
	}
	double dist;
	int cnt = 0;
	for (int i = 0; i < N-1; i++) {
		for (int j = i+1; j < N; j++) {
			double tmp = 0;
			for (int k = 0; k < D; k++) {
				tmp += pow(fabs(cor[i][k]-cor[j][k]), 2);
			}
			dist = sqrt(tmp);
			if (dist == (int)dist) cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100
#define INF 1e8
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int color[MAX],d[MAX],p[MAX],min,u;
  int i,j,v;

  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  p[0] = -1;

  while(1){
    min = INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<min){
	min = d[i];
	u = i;
      }
    }

    if(min == INF) break;
    color[u] = BLACK;

    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
	if(d[u]+M[u][v] < d[v]){
	  d[v] = d[u] + M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
        }
    } 
  }

  for(i=0;i<n;i++) printf("%d %d\n",i,(d[i]==INF ? -1: d[i]));
}

int main(){
  int u,k,v,c;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++) for(j=0;j<n;j++) M[i][j]=INF;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }
  dijkstra();
  
  return 0;
}



Measured memory_bytes: 2112
import math
import sys

s = sys.stdin.readline().rstrip()
d = {'a': 0, "b": 0, "c": 0}
for si in s:
    if si in d:
        d[si] += 1
    else:
        d[si] = 1
x = (len(s)-1) // 3+1
if d['a'] <= x and d['b'] <= x and d['c'] <= x:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
	int n,d,x,ans=0,cnt=0,a;
	int number[100];
	int k[100];
	cin>>n>>d>>x;
	for(int i=0;i<n;i++)
	{
		cin>>number[i];
		int a=number[i];
		int cnt=0;
		for(int j=1;j<=d;j=j+a)
		{
			if(j<=d)
				cnt++;
			else
				break;
		}
		k[i]=cnt;
	}
	for(int i=0;i<n;i++)
	{
		ans+=k[i];
	}
	ans=ans+x;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256