akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef pair<string, int> P;

string sed(string a, string cmd[2])
{
  int pos = 0;
  while(pos = a.find(cmd[0], pos), pos != string::npos){
    a.replace(pos, cmd[0].size(), cmd[1]);
    pos += cmd[1].size();
  }
  return a;
}

int bfs(string from, string to, int n, string cmd[10][2])
{
  queue<P> que;
  que.push(P(from, 0));
  while(!que.empty()){
    P p = que.front(); que.pop();
    if(p.first == to) return p.second;
    for(int i = 0; i < n; i++){
      string next = sed(p.first, cmd[i]);
      if(next == p.first || next.size() > to.size()) continue;
      que.push(P(next, p.second + 1));
    }
  }
  return -1;
}

int main()
{
  int n;
  while(cin >> n, n){
    string cmd[10][2];
    string from, to;
    for(int i = 0; i < n; i++) cin >> cmd[i][0] >> cmd[i][1];
    cin >> from >> to;
    cout << bfs(from, to, n, cmd) << endl;
  }
  return 0;
}

Measured memory_bytes: 1492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << a*a -b << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  int n;
  cin >> n;
  vector<int>a(n+1);
  a[0]=0;
  rep(i,n) cin >> a[i+1];
  int m=0;
  int ans=0;
  rep(i,n){
    if(a[i]<=a[i+1])continue;
    ans+=a[i]-m;
    m=a[i+1];
  }
  ans+=a[n]-m;
  cout << ans << endl;
  
}


Measured memory_bytes: 12160
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MOD ((int64_t)998244353)

// BIT
typedef int BIT_T;
//BIT_T* bit;
BIT_T bit[210002];
int bitN;
void BITinit(int n)
{
   bitN = n;
//   bit = (BIT_T*)malloc( (bitN+1)*sizeof(BIT_T));
}

void BITadd(int i,BIT_T val)
{
    for(;i<=bitN;i+=i&-i) bit[i]+=val;
}

BIT_T BITget(int i)
{
    BIT_T val = 0;
    for(;i;i-=i&-i) val += bit[i];
    return val;
}

void BITreset(void)
{
    for(int i=0;i<=bitN;i++) bit[i] = 0;
}

typedef struct 
{
    int x;
    int y;
}P;

int acsY(const void *a, const void *b){return ((P*)a)->y - ((P*)b)->y;} /* 1,2,3,4.. */
int acsX(const void *a, const void *b){return ((P*)a)->x - ((P*)b)->x;} /* 1,2,3,4.. */

int64_t c2[210001];
void setC(void)
{
    int64_t c = 1;
    c2[0] = 0;
    for(int i=1;i<=210000;i++)
    {
        c = (c*2) % MOD;
        c2[i] = (c + MOD -1) % MOD;
    }
}

P ps[210000];
int a[210000]={0};
int b[210000]={0};
int c[210000]={0};
int d[210000]={0};

int main(void)
{
    int n;
    scanf("%d",&n);
// n=200000;    
    for(int i=0;i<n;i++)scanf("%d %d", &(ps[i].x), &(ps[i].y));
    qsort(ps, n, sizeof(P), acsY);
    for(int i=0;i<n;i++) ps[i].y = i+1;
    qsort(ps, n, sizeof(P), acsX);
//  printf("sort\n");       
    //BA
    //CD
    BITinit(n);
    for(int i=0;i<n;i++)
    {
        int g = BITget(ps[i].y);
        b[i] += g;
        c[i] += i-g;
        BITadd(ps[i].y,1);
    }
    BITreset();
    for(int i=n-1;i>=0;i--)
    {
        int g = BITget(ps[i].y);
        a[i] += g;
        d[i] += (n-1-i)-g;
        BITadd(ps[i].y,1);
    }
// printf("BIT\n");  
    setC();
// printf("C2\n");      
    int64_t t;
    t = 0;
    for(int i=0;i<n;i++)
    {
        // ABCD
        // ABC
        // AB D
        // A CD
        //  BCD
        //  B D
        // A C
        int64_t ca = c2[a[i]];
        int64_t cb = c2[b[i]];
        int64_t cc = c2[c[i]];
        int64_t cd = c2[d[i]];
        t += (((((ca * cb)%MOD)*cc)%MOD)*cd)%MOD;
        t %= MOD;
        t += ((((ca * cb)%MOD)*cc)%MOD);
        t %= MOD;
        t += ((((ca * cb)%MOD)*cd)%MOD);
        t %= MOD;
        t += ((((ca * cc)%MOD)*cd)%MOD);
        t %= MOD;
        t += ((((cb * cc)%MOD)*cd)%MOD);
        t %= MOD;
        t += (cb * cd)%MOD;
        t %= MOD;
        t += (ca * cc)%MOD;
        t %= MOD;
        //自分を含む組み合わせ
        t += c2[n-1]+1;
        t %= MOD;
    }
    printf("%ld\n", t);
    
    return 0;
}




Measured memory_bytes: 8948
#include<bits/stdc++.h>
using namespace std;
int  main()
{
  int a,b;
  cin>>a>>b;
  if(a== 1 && b==2)
    cout<<"3"<<endl;  
   else if(a== 2 && b==1)
    cout<<"3"<<endl;
  else if(a== 1 && b==3)
    cout<<"2"<<endl;
   else if(a== 3 && b==1)
    cout<<"2"<<endl;
   else if(a== 2 && b==3)
    cout<<"1"<<endl;
     else if(a== 3 && b==2)
    cout<<"1"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
  int n,m;
  cin >> n >> m;
  cout << (((n-1)*n)/2) + (((m-1)*m)/2)  << endl;
  
    
   
  

}



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

using namespace std;

int main() {
    int m, n, sum = 0;
    cin >> n >> m;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (sum <= a[i] * m * 4)
            cnt++;
    }
    if (cnt >= m)
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=(int)n; i++)
#define FF(i,n) for (int i=0; i<(int)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < int , int >
#define re(x) (int)x.size()
#define y1 u228
using namespace std;
typedef long long ll;
const int N = 2e5+228;
const int big = 2e9;
const int md = 1e9 + 7;
int n,m,a[N],ans;
bool mrk[N];
vector  < int > p[N],v1,v2;
map < int , int > mem;
void dfs(int i){
    if (mrk[i]) return;
    mrk[i]=1;
    v1.pb(i); v2.pb(a[i]);
    FF(j,re(p[i])) dfs(p[i][j]);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n>>m;
    F(i,n) cin>>a[i];
    F(i,m){
        int a,b;
        cin>>a>>b;
        p[a].pb(b);
        p[b].pb(a);
    }
    F(i,n){
        if (mrk[i]) continue;
        v1.resize(0); v2.resize(0);
        dfs(i);
        mem.clear(); FF(j,re(v2)) mem[v2[j]]=1;
        FF(j,re(v1)) ans+=mem[v1[j]];
    }
    cout<<ans<<endl;
    return 0;
}







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

int main() {
	string s, t;
	cin >> s >> t;

	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (s.length() != t.length() - 1) {
		cout << "No" << endl;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int c;cin>>c;
  vector<int>s(n),t(n);
  vector<vector<int>>id(c);
  rep(i,n)
  {
    int tc;

    cin>>s[i]>>t[i]>>tc;
    tc--;
    id[tc].push_back(i);
  }
  rep(i,c)sort(all(id[i]),[&](int a,int b){return s[a]<s[b];});
  vector<int>d(100007);
  rep(i,c)
  {
    rep(j,id[i].size()-1)
    {
      int ti=id[i][j],nti=id[i][j+1];
      if(t[ti]==s[nti]){s[nti]=s[ti];s[ti]=-1;}
    }
    for(auto ti:id[i])
    {
      if(s[ti]==-1)continue;
      d[s[ti]-1]++;
      d[t[ti]]--;
    }
  }
  rep(i,d.size()-1)
  {
    d[i+1]+=d[i];
  }
  int res=0;
  //rep(i,30)cout<<d[i];
  //cout<<endl;
  rep(i,d.size())chmax(res,d[i]);
  cout<<res<<endl;



  return 0;

}


Measured memory_bytes: 2176
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
int i,n,j,l,e,g;
while(cin>>n){
g=0;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
for(l=0;l<10;l++){
for(e=0;e<10;e++){
if(i+j+l+e==n)g++;
}
}
}
}
cout<<g<<endl;
}
return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0;i < m;i++){
    cin >> p.at(i) >> s.at(i);
  }
  
  vector<int> w(n,0);
  vector<bool> a(n,false);
  
  for (int i = 0;i < m;i++){
    if (s.at(i) == "AC"){
      a.at(p.at(i) - 1) = true;
    }
    if (a.at(p.at(i) - 1) == false && s.at(i) == "WA"){
      w.at(p.at(i) - 1)++;
    }
  }
  
  int ansa = 0;
  int ansb = 0;
  
  for (int i = 0;i < n;i++){
    if (a.at(i)){
      ansa++;
      ansb += w.at(i);
    }
  }
  cout << ansa << " " << ansb << endl;
}

Measured memory_bytes: 7120
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
  cin>>s;
  for(auto &c: s) if(c==',') c = ' ';
  cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        a[i] *= n;
    }
    for (int i = 0; i < n; i++) {
        sum+=a[i];
    }
    int av = sum/n;
    int min = 1 << 29;
    int ans = 1 << 10;
    for (int i = 0; i < n; i++) {
        int x = abs(av - a[i]);
        if (x < min) {
            min = x;
            ans = i;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 42;
int N;
int X, Y, Z;

const int S = 1 << 17;
num dp[MAXN][S];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> X >> Y >> Z;

	int good = ((1 << (X+Y+Z)) + (1 << (Y+Z)) + (1 << Z)) >> 1;
	dp[0][0] = 1;
	num ans = 0;
	for (int i = 0; i < N; i++) {
		for (int m = 0; m < S; m++) {
			for (int x = 1; x <= 10; x++) {
				int m1 = ((m << x) | (1 << (x-1))) & (S-1);
				dp[i+1][m1] += dp[i][m];
			}
		}
		
		num ways = 1;
		for (int j = 0; j < N-(i+1); j++) ways *= 10;
		for (int m = 0; m < S; m++) {
			if ((m & good) == good) {
				ans += ways * dp[i+1][m];
				dp[i+1][m] = 0;
			}
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 21888
sx,sy,X,Y = map(int,input().split())

ans = ""
ans += "U"*(Y-sy)
ans += "R"*(X-sx)
ans += "D"*(Y-sy)
ans += "L"*(X-sx)

ans += "L"+"U"*(Y-sy+1)
ans += "R"*(X-sx+1)+"D"
ans += "R" + "D"*(Y-sy+1)
ans += "L"*(X-sx+1)+"U"

print(ans)

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

int main()
{
    int n;
    cin >> n;
    ll res = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0)
        {
            //
        }
        else if (i % 5 == 0)
        {
            //
        }
        else
        {
            res += i;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main{
    static int n;
    static Scanner sc = new Scanner(System.in);
    static int[] Adj;
    static int[][] V;
    static StringBuilder sb = new StringBuilder();
    static String crlf = System.getProperty("line.separator");


    public static void main(String[] args){
        n = sc.nextInt();
        Adj = new int[n];
        V = new int[n][n];
        int m;
        for(int i=0; i<n; i++){
            Adj[i] = sc.nextInt();
            m = sc.nextInt();
            for(int j=0; j<m; j++){
                V[Adj[i]-1][sc.nextInt()-1] = 1;
            }
            for(int j=0; j<n; j++){
                sb.append(V[Adj[i]-1][j]);
                if(j!=n-1){
                    sb.append(" ");
                }
            }
            sb.append(crlf);
        }
        System.out.print(sb.toString());

    }
}


Measured memory_bytes: 28816
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
#include <cmath>
#include <stack>
#include <bitset>
#include <queue>

using namespace std;

#define int long long
#define MAX 1000000000000000000

signed main() {
    int n; 
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = 0; i < n; i++) {
        if(a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 1;
    for(int i = 0; i < n; i++) {
        if(a[i] > MAX / ans) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int main() {
	int n;cin >> n;
	cout << n <<":";
	while(n%2==0)
	{
		cout <<" "<< 2;
		n/=2;
	}
	for(int i = 3; i*i<=n;i+=2)
	{
		while(n % i== 0)
		{
			cout<<" "<<i;
			n/=i;
		}
	}
	if(n !=1)cout<<" "<<n;
	cout <<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;


int main(){
    char s,p;
    cin>>s;
    p=s+1;
    cout<<p;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;
void Main()
{
    ll n, D;
    cin >> n >> D;

    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    
    two_sat ts(n);
    for (ll i = 0; i < n - 1; i++) {
        for (ll j = i + 1; j < n; j++) {
            if (abs(x[i] - x[j]) < D) {
                ts.add_clause(i, false, j, false);
            }
            if (abs(y[i] - y[j]) < D) {
                ts.add_clause(i, true, j, true);
            }
            if (abs(x[i] - y[j]) < D) {
                ts.add_clause(i, false, j, true);
            }
            if (abs(y[i] - x[j]) < D) {
                ts.add_clause(i, true, j, false);
            }
        }
    }

    if (!ts.satisfiable()) {
        put("No");
        return;
    }

    put("Yes");
    rep(i, n) {
        if (ts.answer()[i]) {
            put(x[i]);
        }
        else {
            put(y[i]);
        }
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 3784
import collections

H,W = map(int,input().split())
L = [input() for i in range(H)]

dxy = [(1,0),(0,1)]

cnt_list = [[float("inf") for x in range(W)] for y in range(H)]
cnt_list[0][0] = 1

q = collections.deque([(0,0)])

while q :
    y,x = q.popleft()
    for dy,dx in dxy :
        ny = y + dy
        nx = x + dx
        
        if (ny < 0) or (ny >= H) or (nx < 0) or (nx >= W) :
            continue
        if L[ny][nx] == "#" :
            continue
        if cnt_list[ny][nx] < float("inf") :
            cnt_list[ny][nx] += cnt_list[y][x]
        else :
            cnt_list[ny][nx] = cnt_list[y][x]
            q.append((ny,nx))
ans = cnt_list[-1][-1]
if ans < float("inf") :
    ans %= 10**9+7
else :
    ans = 0

print(ans)


Measured memory_bytes: 227588
#include <string>
#include <sstream>
#include <iterator>
#include <iostream>
#include <vector>


using namespace std;

int main()  {
  int a, b, c, d, e;
  int count;
  count = 0;
  // 空白文字で区切られた数字を 3 つ取得
  std::cin >> a >> b >> c;
  //std::vector<int> v(2);
  for (int i = 0; i < a; i++) {
    std::cin >> d >> e;
    if(d >= b && e >=c){
		count++;
	}
  }
  printf("%d\n",count);
  
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M,K;
LL A[200000];
LL B[200000];

LL ans = 0;

void solve(){
	LL sum = 0;
	//例えばAを0~i-1番目まで取るならば
	//A_index = iとする
	//1つも取らないなら0
	LL A_index = 0;//どこまでとったか
	for(int i=0;i<N;i++){
		if(sum+A[i]>K){
			A_index = i;
			break;
		}
		sum += A[i];
		if(i==N-1) A_index = i+1;
	}
	ans = A_index;

	for(int i=0;i<M;i++){
		sum += B[i];
		while(1){
			if(sum<=K || A_index==0) break;
			sum -= A[A_index-1];
			A_index--;
		}
		if(sum>K) break;
		ans = max(ans,A_index+i+1);
	}
}

int main(){
	cin >> N >> M >> K;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<M;i++) cin >> B[i];

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
string pre[11], aft[11];
string s, g;

string change(string s, string t, string r){
    string res = s;
    size_t pos = res.find(t);    
    while(pos != string::npos){
        res.replace(pos, t.size(), r);
        pos = res.find(t, pos + r.size());
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n, n){
        rep(i, 0, n){
            cin >> pre[i] >> aft[i];
        }
        cin >> s >> g;
        queue<string> q;
        map<string, int> mp;
        q.push(s);
        mp[s] = 1;
        while(!q.empty()){
            string now = q.front(); q.pop();
            rep(i, 0, n){
                string tmp = change(now, pre[i], aft[i]);
                if(tmp.size() > g.size()) continue;
                if(mp.count(tmp)) continue;
                mp[tmp] = mp[now] + 1;
                q.push(tmp);
            }
        }
        cout << mp[g] - 1 << endl;
    }
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int W[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> W[i + 1];
		W[i + 1] += W[i];
	}
	int res = inf;
	rep(i, 1, N) {
		MIN(res, abs(W[i] - W[0] - (W[N] - W[i])));
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    S = input()

    # 1の個数と0の個数を交互に記録
    nums = []
    if S[0] == "0":
        nums.append(0)
    i = 0
    while i < n:
        j = i
        while j < n and S[j] == S[i]:
            j += 1
        nums.append(j - i)
        i = j
    nums.append(0) if S[-1] == "0" else None

    # 累積和
    sums = [0] * (len(nums) + 1)
    for i in range(len(nums)):
        sums[i + 1] = sums[i] + nums[i]

    res = 0
    for left in range(0, len(sums), 2):
        right = left + k * 2 + 1
        if right >= len(sums):
            right = len(sums) - 1
        res = max(res, sums[right] - sums[left])

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 8012
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    int l = k, t = 0;
    while (l && t < n) {
        l /= 2;
        ans *= 2;
        ++t;
    }
    cout << ans + k * max(0, n - t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MOD = 1e9 + 7;
#define INF ((1<<30)-1)
#define LINF (1LL<<30)

ll dp[110][110000];
ll dp_sum[110][110000];
ll a[110];

int main() {
    int n,k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)cin >> a[i];
    dp[0][0] = 1;
    for(int j = 0; j <= k; j++)dp_sum[0][j] = 1;

    for(int i = 1;i <= n; i++){
        for(int j = 0; j <= k;j++){
            dp[i][j] = dp_sum[i-1][j];
            if (j-a[i]-1 >= 0) dp[i][j] -= dp_sum[i-1][j-a[i]-1];
            
            if(j-1 >= 0)dp_sum[i][j] = dp_sum[i][j-1] + dp[i][j];
            else dp_sum[i][j] = dp[i][j];
            dp[i][j] %= MOD;
            dp_sum[i][j] %= MOD;
        }
    }
    if(dp[n][k] < 0) dp[n][k] += MOD;
    cout << dp[n][k] << endl;
}

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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=8&&b<=8){
    cout << "Yay!" << endl;
  }
  else{
  cout << ":(" << endl;
  }
}

Measured memory_bytes: 3528
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> v(n);
    for(auto &x:v)cin>>x;
    bool f = 0;
	for(ll i=0;i<n;i++)
	{
		if(v[i]%2==0 && v[i]%3!=0 && v[i]%5!=0)
		{
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
    return 0;
}


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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  char b; cin>>b;
  if(b=='A') printf("T");
  else if(b=='T') printf("A");
  else if(b=='G') printf("C");
  else if(b=='C') printf("G");
  return 0;
}

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

const int kx[2][4] = { {1,0,-1,0}, {0,-1,0,1} };
const int ky[2][4] = { {1,0,-1,0}, {0,1,0,-1} };

int main(){
  int n;
  int m[55],x[55][15],y[55][15];

  while(cin >> n,n){
    for(int i=0;i<=n;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++)cin >> x[i][j] >> y[i][j];
    }

    for(int i=1;i<=n;i++){
      if(m[i] != m[0])continue;

      bool exist = false;

      for(int d=0;d<4;d++){
	bool f = true;
	for(int j=1;j<m[i];j++){
	  if(x[0][j]-x[0][0] != kx[0][d]*(x[i][j]-x[i][0]) + ky[1][d]*(y[i][j]-y[i][0]) ||
	     y[0][j]-y[0][0] != ky[0][d]*(y[i][j]-y[i][0]) + kx[1][d]*(x[i][j]-x[i][0])){
	    f = false; break;
	  }
	}
	exist |= f;
      }

      for(int d=0;d<4;d++){
	bool f = true;
	for(int j=1;j<m[i];j++){
	  if(x[0][m[i]-1-j]-x[0][m[i]-1] != kx[0][d]*(x[i][j]-x[i][0]) + ky[1][d]*(y[i][j]-y[i][0]) ||
	     y[0][m[i]-1-j]-y[0][m[i]-1] != ky[0][d]*(y[i][j]-y[i][0]) + kx[1][d]*(x[i][j]-x[i][0]) ){
	    f = false; break;
	  }
	}
	exist |= f;
      }
      if(exist)cout << i << endl;
    }
    cout << "+++++" << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
bool a[300001];
using namespace std;
int main(){
  int b,w,x,p=0,i;
  cin>>w>>b;
  for(i=0;i<w;i++){
    scanf("%d",&x);
    p=max(p,x);
    a[x]++;
  }
  while(b--){
    for(cin>>x,i=1;i<x;i++)
      for(int j=x-i;j<=p;j+=x)
        if(a[j])goto L;
    L:printf("%d\n",x-i);
  }
}

Measured memory_bytes: 3356
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = 0;
    
    for(int i=0;i<2;i++){
      if(a>=b){
        ans+=a;
        a--;
      }else{
        ans+=b;
        b--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
string s;
int ans=700;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='o')
		ans+=100;
	}
	cout<<ans;
	//system("pause");
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn=1e3+6;
const int mod=1e9+7;
int g[maxn][maxn];
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}    
int gcd(int a,int b){ return b==0?a:gcd(b,a%b); } 
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	     g[i][j]=gcd(i,j);
	LL ans=0;
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	     for(int k=1;k<=n;k++)
		    ans+=g[g[i][j]][k]; 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int64_t> v(K);
	for (int i = 1; i <= N; i++) {
		v.at(i % K)++;
	}

	if (K % 2) {
		int64_t n = v.at(0) * v.at(0) * v.at(0);
		cout << n << endl;
	}
	else {
		int64_t n = v.at(0) * v.at(0) * v.at(0);
		int64_t m = v.at(K / 2) * v.at(K / 2) * v.at(K / 2);
		cout << n + m << endl;
	}
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,q,S[10000],T[500],i,j,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    S[n]=T[i];
    j=0;
    while(S[j]!=T[i]){
      j++;
    }
    if(j!=n) c++;
  }
  printf("%d\n",c);
  return 0;
}
      



Measured memory_bytes: 2108
N,D,A = map(int,input().split())

XH = sorted(tuple(map(int,input().split())) for _ in range(N))

X = [x for x,h in XH]
H = [h for x,h in XH]

dH = [0]*(N+1)

cnt = 0
acc = 0

cnt = 0
i = 0
j = 0
while i < N:
    while j < N and X[j] <= X[i]+2*D:
        j += 1

    acc -= dH[i]
    H[i] -= acc
    if H[i] > 0:
        c = (H[i]-1)//A + 1
        acc += c*A
        dH[j] += c*A
        cnt += c
    i += 1

print(cnt)

Measured memory_bytes: 134612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CTravelingSalesmanAroundLake {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int mx = Math.abs(a[0] + k - a[n - 1]);
            for (int i = 1; i < n; i++) {
                mx = Math.max(mx, a[i] - a[i - 1]);
            }
            out.println(k - mx);
        }

    }
}



Measured memory_bytes: 83260
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var _N = long.Parse(Console.ReadLine());
        var _Atopbottom = new List<int[]>();
        var _Bbottomtop = new List<int[]>();
        for (var i = 0; i <= 9; i++)
        {
            _Atopbottom.Add(new int[10]);
            _Bbottomtop.Add(new int[10]);
        }
        for(var i = 1; i <= _N; i++)
        {
            var tmp = 1;
            for(var j = 1; j <= 6;j++)
            {
                tmp *= 10;
                if (i < tmp)
                {
                    var tmp2 = tmp / 10;
                    var top = i / tmp2;
                    var bottom = i % 10;
                    (_Atopbottom[top])[bottom]++;
                    (_Bbottomtop[bottom])[top]++;
                    break;
                }
            }
        }
        long ans = 0;
        for (var i = 0; i <= 9; i++)
        {
            for (var j = 0; j <= 9; j++)
            {
                ans += ((_Atopbottom[i])[j]) * ((_Bbottomtop[i])[j]);
            }
        }
        Console.WriteLine(ans);
#if DEBUG
        Console.ReadKey();
#endif
    }
}

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

int main(){
    string s;
    cin >> s;
    int n;
    if (s == "SUN")n = 7;
    if (s == "MON")n = 6;
    if (s == "TUE")n = 5;
    if (s == "WED")n = 4;
    if (s == "THU")n = 3;
    if (s == "FRI")n = 2;
    if (s == "SAT")n = 1;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>

int main(){
 int a, b, h, m, s;

 scanf("%d", &a);

 h = a / 3600;
 b = a % 3600;
 m = b / 60;
 s = a % 60;

 printf("%d:%d:%d\n", h, m, s);

 return 0;
}

Measured memory_bytes: 592
use std::vec::Vec;
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (x, y) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    let mut group_1 = HashSet::new();
    for i in vec![1, 3, 5, 7, 8, 10, 12] {
        group_1.insert(i);
    }

    let mut group_2 = HashSet::new();
    for i in vec![4, 6, 9, 11] {
        group_2.insert(i);
    }

    let mut group_3 = HashSet::new();
    for i in vec![2] {
        group_3.insert(i);
    }

    if group_1.contains(&x) && group_1.contains(&y) {
       println!("Yes");
       return
    }

    if group_2.contains(&x) && group_2.contains(&y) {
       println!("Yes");
       return
    }

    if group_3.contains(&x) && group_3.contains(&y) {
       println!("Yes");
       return
    }

    println!("No");

}


Measured memory_bytes: 4352
#include<stdio.h>
int main() {
	int a=0, b=0, c=0, i;
	while (scanf("%d", &i) == 1) {
		if (a < i) {
			if (a != 0) {	
				if (0 != b)
					c = b;
				b = a;
			}
			a = i;
		}
		else if (b < i) {
			if (b != 0) 
				c = b;
			b = i;
		}
		else if (c < i)
			c = i;
	}
	printf("%d\n%d\n%d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int>
 
int32_t main(){
    string s;
    cin>>s;
    int n=s.length();
    char ch=s[0];
    int flag=0;
    for(int i=1;i<n;i++){
        if(ch!=s[i]) {
            flag=1;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
typedef long long ll;

ll num_of_triplets(string s, int N) {
    ll r = 0, g = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    return r*g*b;
}

ll arth_triplets(string s, int N) {
    ll count = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = 2*j - i;
            if (k < 0 || k >= N || k == i || k == j)
                continue;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) count++;
        }
    }
    return count;
}

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;

    ll total = num_of_triplets(S, N);
    ll arth = arth_triplets(S, N);
    cout << total - arth << endl;
}

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

int main() {
  int64_t x, k, d;
  cin >> x >> k >> d;
  int64_t xx;
  if (x <= 0){
    xx = (-1) * x;
  }
  else {
    xx = x;
  }
  int64_t a = xx / d;
  int64_t ans;
  if (k <= a){
      ans = xx - k * d;
    }
  else {
      ans = xx - a * d;
      if((k - a) % 2 == 1){
        ans = (d - ans);
      }
  }
  cout << ans;
}



Measured memory_bytes: 3604
n, x, y = list(map(int, input().split()))

count = [0]*n

for i in range(1, n):
  for j in range(i+1, n+1):
    if i<=x and j>=y:   # out,out
      d = (x-i)+(j-y)+1
    elif i<=x and j<y:  # out, in
      if (y-j)<(j-x):
        d = (x-i)+(y-j)+1
      else:
        d = (x-i)+(j-x)
    elif i>x and j>=y:  # in, out
      if (y-i)>(i-x):
        d = (i-x)+(j-y)+1
      else:
        d = (y-i)+(j-y)
    else:               # in, in
      if (j-i)>((i-x)+(y-j)):
        d = (i-x)+(y-j)+1
      else:
        d = j-i
    #print(i, j, d)
    count[d] += 1

for i in range(1, n):
  print(count[i])

Measured memory_bytes: 3444
while True:
    try:
        a,da, b = [], [], []
        m = int(raw_input())
        for i in range(m):
            a.append(map(int, raw_input().split()))
        a = sorted(a)
        dax = []
        for i in range(m):
            dax.append(a[i][0]-a[0][0])
        n = int(raw_input())
        for i in range(n):
            b.append(map(int, raw_input().split()))
        b = sorted(b)
        bx = []
        for i in b:
            bx.append(i[0])
        for i in range(n-m+1):
            for j in range(m):
                if bx.count(bx[i]+dax[j]) == 0:
                    break
            else:
                print b[i][0]-a[0][0],b[i][1]-a[0][1]
                break
    except:
        break

Measured memory_bytes: 4424
import sys

def input_number():
    for i in range(n):
        adding=map(int,raw_input().split())
        A.append(adding)
    for i in range(m):
        adding=input()
        b.append(adding)

if __name__ == '__main__':
    n,m=map(int,raw_input().split())
    A=[]
    b=[]
    ans=[0 for i in range(n)]
    input_number()
    for i in range(n):
        for j in range(m):
            ans[i] += A[i][j] * b[j]
    for i in range(n):
        print ans[i]

Measured memory_bytes: 6628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        List<Character> diff = new ArrayList<Character>(Arrays.asList('A', 'C', 'G', 'T'));

        int count = 0;
        int maxCount = 0;
        for (int i = 0; i < c.length; i++) {
            for (int j = i; j < c.length; j++) {
                if (diff.contains(c[j])) {
                    count++;
                    if (maxCount < count) {
                        maxCount = count;
                    }
                } else {
                    break;
                }
            }
            count = 0;
        }

        System.out.println(maxCount);
        sc.close();
    }
}

Measured memory_bytes: 35724