akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
signed main() {
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
}

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

    int digit(int N){
        int count = 0;
        while(N > 0){
            N/=10;
            count++;
        }
        return count;
    }

    int main() {
        int N;

        cin >> N;

        int count = 0;
        for(int i = 1; i <= N; i++){
            if((digit(i) % 2) == 1)
                count += 1;
        }

        cout << count << endl;
    }

Measured memory_bytes: 256
n = int(input())
data = [c for c in input()]
stack = []
ans = ''
for c in data:
    if c == '(':
        stack.append(c)
        ans += '('
    else:
        if len(stack) == 0 or stack.pop() != '(':
            ans = '(' + ans + c
        else:
            ans += ')'
ans += ')'*len(stack)

print(ans)

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int na=0;
  int nb=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='a'){
      if(na+nb<A+B){
        cout << "Yes" << endl;
        na++;
      }else{
        cout << "No" << endl;
      }
    }else if(S.at(i)=='b'){
      if((na+nb<A+B)&&(nb+1<=B)){
        cout << "Yes" << endl;
        nb++;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll a,b;
  cin>>a>>b;
  if(b<a){
    op(a-1);
  }else op(a);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#define F first
#define S second
#define INF 1<<21
using namespace std;
typedef pair<int,int>P;
int bfs();
int d[1111][1111];
int sx,sy;
int h,w,n;
char num;
char s[1111][1111];
int main(){
  int ans=0;
  cin >> h >> w >> n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
      if(s[i][j]=='S'){
	sx=j,sy=i;
      }
    }
  }
  for(num='1';num<'1'+n;num++){
    ans+=bfs();
  }
  cout << ans << endl;
}

int bfs(){
  queue <P>q;
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  int nx,ny;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=INF;
    }
  }
  
  q.push(P(sy,sx));
  d[sy][sx]=0;
  while(q.size()){
    P p=q.front();
    q.pop();
    if(s[p.F][p.S]==num){
      sy=p.F;
      sx=p.S;
      return d[p.F][p.S];
    }    
    for(int i=0;i<4;i++){
      nx=p.S+dx[i],ny=p.F+dy[i];
      if(s[ny][nx]!='X' && nx<w && nx>=0 && ny<h && ny>=0 && d[ny][nx]==INF){
	q.push(P(ny,nx));
	d[ny][nx]=d[p.F][p.S]+1;
      }
    }
  }
}

Measured memory_bytes: 6648
n=input()
arr=map(int, raw_input().split())
sums=[0]*n
sums[0]=arr[0]
for i in xrange(1, n):
  sums[i]=sums[i-1]+arr[i];
mod=10**9+7
ans=0
for i in xrange(n):
  ans=(ans%mod+arr[i]*(sums[-1]-sums[i])%mod)%mod
print ans


Measured memory_bytes: 95388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a=input(q);
  vector<int> point(n);
  rep(i,n){
    point[i]=k-q;
  }
  rep(i,q){
    point[a[i]-1]++;
  }
  rep(i,n){
    sayYes(point[i]>0);
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;

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

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[1005];
ll B[1005];

//! Nを置ける場所が何通りあるか
ll T[1000005];
//! 場所が決まっている
bool S[1000005];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, M)
    {
        cin >> B[i];
    }

    //! A/Bに同じ数字が書かれている場合には0を出力
    bool same = false;
    REP(i, N)
    {
        FOR(j, N, i + 1)
        {
            if (A[i] == A[j])
                same = true;
        }
    }
    REP(i, M)
    {
        FOR(j, M, i + 1)
        {
            if (B[i] == B[j])
                same = true;
        }
    }
    if (same)
    {
        cout << 0 << endl;
        return 0;
    }

    REP(h, N)
    {
        REP(w, M)
        {
            int t = std::min(A[h], B[w]);
            T[t]++;
            if (A[h] == B[w])
                S[t] = true;
        }
    }

    ll ans = 1;
    ll next = 0;
    for (int i = N * M; i > 0; --i)
    {
        if (T[i] == 0)
        {
            T[i] += next;
            next = 0;
        }
        if (!S[i])
            ans = (ans * T[i]) % MOD;
        next += T[i] - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define INF 100000

int n,m;
string str;

void SetA(int num){
  for(int i=0;i<n;i++){
    if(str[i] == '#'){
      if(num == 1) str[i] = 'A';
      else if(num == 2) str[i] = 'B';
      else str[i] = 'D';
      return;
    }
  }
}

void SetB(){
  for(int i=n-1;i>=0;i--){
    if(str[i] == '#' && str[i-1] != 'A' && str[i+1] != 'A'){
      str[i] = 'B';
      return;
    }
  }
  SetA(2);
}

void SetC(int c){
  if(c == 0) {
    str[(n%2==1 ? (n+1)/2 : (n/2+1)) -1] = 'C';
    return;
  }
  for(int i=0;i<n;i++){
    if(str[i] != '#'){
      if(str[i+1] == '#') {
	str[i+1] = 'C';
	return;
      }
      if(str[i-1] == '#') {
	str[i-1] = 'C';
	return;
      }
    }
  } 
}

void SetD(int c){
  if(c == 0){
    str[0] = 'D';
    return;
  }
  int MAX=0,j,m,MAXi;
  for(int i=0;i<n;i++){
    if(str[i]=='#'){
      for(j=i-1;j>=0;j--) if(str[j]!='#') break;
      for(m=i+1;m<n;m++) if(str[m]!='#') break;
      if(j==-1) j = INF;
      if(m==n) m = INF;
      if(j==INF){
	if(c-i > MAX) MAX = m-i,MAXi=i,MAXi=i;
      } else if(m==INF){
	if(i-j > MAX) MAX = i-j,MAXi=i;
      } else{
	if(min(m-i,i-j) > MAX) MAX=min(m-i,i-j),MAXi=i;
      }
    }
  }
  if(MAX == 0) SetA(3);
  else str[MAXi] = 'D';
}
  
int main(){
  while(cin >> n >> m , n || m){
    str = "";
    for(int i=0;i<n;i++) str += '#';
    for(int c=0;c<m;c++){
      char h; cin >> h;
      if(h == 'A') SetA(1);
      else if(h == 'B') SetB();
      else if(h == 'C') SetC((c==0 ? 0 : 1));
      else SetD((c==0 ? 0 : 1));
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

int n; 
vector<int> w;
vector<vector<int>> dp;

int rec(int l = 0, int r = n){
    //[l,r)をみる
    if((r - l) <= 1) return 0;
    if((r - l) == 2){
        if(abs(w[l] - w[l+1])<=1) return 2;
        else return 0;
    }
    int &res = dp[l][r];
    if(res != -1) return res;
    if(abs(w[l] - w[r-1]) <= 1 && rec(l+1, r-1) == r - l - 2) chmax(res, r - l);//全部取り除ける時
    for(int i = l+1; i <= r-1; i++){
        chmax(res, rec(l,i) + rec(i, r));
    }
    return res;
}

int main(){
    vector<int> ans;
    while(true){
        cin >> n;
        if(n == 0) break;
        w.resize(n);
        for(int i = 0; i < n; i++){
            cin >> w[i];
        }
        dp.assign(n+1,vector<int>(n+1, -1));
        ans.push_back(rec());
    }
    for(auto i : ans) cout << i << endl;
    return 0;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n; cin>>n;

  for (int i=1; i<n; i++) {
    ll t = i*(i+1)/2;
    if (t >= n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define mp make_pair
#define fi first
#define se second

int main()
{
    int n;cin >> n;
    vector<pair<int,int>> matrix(n);
    int a,b;
    for (int i=0;i<n;i++)
    {
        cin >> a >> b;
        matrix[i]=mp(a,b);
    }
    vector<vector<pair<int,pair<int,int>>>> dp(n,vector<pair<int,pair<int,int>>> (n,mp(INF,mp(-1,-1))));
    for (int i=0;i<n;i++)
    {
        dp[i][i].fi=0;
        dp[i][i].se.fi=matrix[i].fi;
        dp[i][i].se.se=matrix[i].se;
    }
    for (int len=1;len<n;len++)
    {
        for (int l=0;l<n-len;l++)
        {
            int r=l+len;
            //cout << l << r << endl;
            for (int m=l;m<r;m++)
            {
                if (dp[l][r].fi>dp[l][m].fi+dp[m+1][r].fi+dp[l][m].se.fi*dp[l][m].se.se*dp[m+1][r].se.se)
                {
                    //cout << l <<" " << r << ":" ;
                    dp[l][r].fi=dp[l][m].fi+dp[m+1][r].fi+dp[l][m].se.fi*dp[l][m].se.se*dp[m+1][r].se.se;
                    dp[l][r].se.fi=dp[l][m].se.fi;
                    dp[l][r].se.se=dp[m+1][r].se.se;
                    //cout << dp[l][r].fi<< endl;
                }
            }
        }
    }
    cout << dp[0][n-1].fi << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  bool ok = true;
  int prev_t = 0, prev_x = 0, prev_y = 0;
  while (n--) {
    int t, x, y;
    cin >> t >> x >> y;
    int dif_t = t - prev_t, dif_x = abs(x - prev_x), dif_y = abs(y - prev_y);
    ok &= ( (dif_t >= dif_x + dif_y) && (dif_t % 2 == (dif_x + dif_y) % 2));
  }
  cout << (ok ? "Yes" : "No") << 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 long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  int ans = 0;
  rep(i,n) for (int j = i+1; j < n; ++j) {
    ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
#define N 200000

int main() {
  ll n, m; cin >> n >> m;
  vector<pair<int, int> >pairs[N];
  int b[N], c[N];
  for(ll i = 0; i < m; i++) {
    int p, y; cin >> p >> y;
    pairs[p-1].push_back(make_pair(y, i));
  }
  for(ll i = 0; i < n; i++) {
    sort(pairs[i].begin(), pairs[i].end());
    for(ll j = 0; j < pairs[i].size(); j++) {
      b[pairs[i][j].second] = i+1;
      c[pairs[i][j].second] = j+1;
    }
  }
  for(ll i = 0; i < m; i++) {
    printf("%06d%06d\n", b[i], c[i]);
  }

  return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
//=================================================
int H, W;
vector<string> S;
//=================================================
void input()
{
    cin >> H >> W;
    S = vector<string>(H);
    rep(i, H)
    {
        cin >> S[i];
    }
}
//=================================================
int ms[51][51] = {};

bool visited[51][51] = {};

void dfs(int c, int h, int w)
{
    //cout << "dfs" << c << "," << h << "," << w << endl;
    if (h < 0 || h >= H || w < 0 || w >= W)
        return;
    if (ms[h][w] == 0)
        return;
    //if (ms[h][w] >= 3) return;
    //if (visited[h][w]) return;

    // if (c == 0) {

    if (c == 0)
    {
        dfs(c + 1, h - 1, w);
        dfs(c + 1, h, w - 1);
        dfs(c + 1, h + 1, w);
        dfs(c + 1, h, w + 1);
    }
    //    }
    //    else {
    if (c != 0)
    {
        //        visited[h][w] = true;
        ms[h][w]++;
        debug(ms[h][w]);
    }
    //}
}

void solve()
{
    rep(i, H)
    {
        rep(j, W)
        {
            if (S[i][j] == '#')
                ms[i][j] = 1;
            else
                ms[i][j] = 0;
        }
    }

    rep(i, H)
    {
        rep(j, W)
        {
            if (ms[i][j] >= 1)
                dfs(0, i, j);
        }
    }

    bool ans = true;
    rep(i, H)
    {
        rep(j, W)
        {
            if (ms[i][j] == 1)
            {
                ans = false;
                break;
            }
        }
    }

    cout << (ans ? ("Yes") : ("No")) << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
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 c = sc.nextInt();
         int ans = 0;

         for(int x = a; x <= b; x++){
            if(c % x == 0)
                ans++;
        }

         System.out.println(ans);
}
}


Measured memory_bytes: 26344
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
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;

// AOJ1057(UAPC2010G) Ég¦éÀ.Q½ÊÅTCR]ª·Æ«g¦»¤.
// TCRÍi¯¶TCRÈçj×Ú·éQÊÌlðè·êÎü«ªÜé©çAdi.t*7+di.sÅêÓÉèÜé.
int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};
struct dice{
	int t,b,n,s,e,w;              // top bottom north south east west
	int y,x;
  int i;
  
	void roll(int d)
	{
		int tmp;
		y+=dy[d],x+=dx[d];
		
		if(d==0) {
			tmp=t; t=s; s=b; b=n; n=tmp;
		}else if(d==1) {
			tmp=t; t=e; e=b; b=w; w=tmp;
		}else if(d==2) {
			tmp=t; t=n; n=b; b=s; s=tmp;
		}else {
			tmp=t; t=w; w=b; b=e; e=tmp;
		}
	}
};

string route;
int dis[6][6][30][30][6];

int w,h;
map<char, int> mp;

char ba[30][30];

int solve(dice di) {
  queue<dice> Q;
  Q.push(di);
  memset(dis,-1,sizeof(dis));

  dis[di.t][di.s][di.y][di.x][0] = 0;
  
  while(!Q.empty()) {
    dice now = Q.front();
    Q.pop();
    // if (dis[now]) continue;
    //dis[now] = 1;
    //cout << now.i << endl;
    //cout << now.x << " " << now.y << " " << now.t << endl;
    // cout << dis[now.t][now.s][now.y][now.x]  << endl;
    if (now.i == 6) {
      //cout << dis[now.t][now.s][now.y][now.x][now.i] << endl;
      return dis[now.t][now.s][now.y][now.x][now.i];
    }
    if (ba[now.y][now.x] == route[now.i]) {
      dis[now.t][now.s][now.y][now.x][now.i+1] = dis[now.t][now.s][now.y][now.x][now.i];
      now.i++;
      Q.push(now);
      continue;
    }
    
    REP(d, 4) {
      dice tmp = now;
      tmp.roll(d);

      if (tmp.x<0||tmp.x>=w||tmp.y<0||tmp.y>=h) continue;
      if (!(ba[tmp.y][tmp.x] == route[now.i] && tmp.t == mp[route[now.i]]))
        if (ba[tmp.y][tmp.x] != 'w') continue;
//      cout << tmp.x << " " << tmp.y << endl;
      if (dis[tmp.t][tmp.s][tmp.y][tmp.x][tmp.i]!=-1) continue;
//      cout << "ok" << endl;
      
      dis[tmp.t][tmp.s][tmp.y][tmp.x][tmp.i] = dis[now.t][now.s][now.y][now.x][now.i] + 1;
      Q.push(tmp);
    }
  }
  return -1;
}

int main() {
  string s = "rcgmby";
  REP(i, 6) mp[s[i]] = i;
  while(cin >> w >> h, w||h) {
    int sx,sy;
    int colorx[6], colory[6];
    REP(i, h) {
      REP(j, w) {
        cin >> ba[i][j];
        if (ba[i][j] == '#') {
          sy = i;
          sx = j;
          ba[i][j] = 'w';
        }
        if (mp.count(ba[i][j])) {
          colory[mp[ba[i][j]]] = i;
          colorx[mp[ba[i][j]]] = j;
        }
      }
    }
    cin >> route;
    int res = 0;
    dice di;
    di.t = 0;
    di.b = 1;
    di.n = 2;
    di.s = 3;
    di.e = 4;
    di.w = 5;
    di.x = sx;
    di.y = sy;
    di.i = 0;
    int tmp = solve(di);
    if (tmp == -1)
      cout << "unreachable" << endl;
    else
      cout << tmp << endl;
  }
}

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

int main() {
  int N,A,C, sum,c1,c2,c3,c4,c5,LA;
  string B;
  cin >>A>>B>>C;
  sum =1;
  //N = A.size();
  if(B=="+"){
  cout<<A+C<<endl;
  }
  else
    cout<<A-C<<endl;
  
 //cout<<"A"<<B.at(0)<<"C"<<endl;
/*  	if(A=="a"||A=="e"||A=="i"||A=="o"||A=="u"){
    cout<<"vowel"<<endl;
    }
    else{
    cout<<"consonant"<<endl;
    }
 
*/

}

Measured memory_bytes: 256
num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

print(count)


Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int n, m;
vector<vector<int>> g;

vector<int> dp;

int rec(int v) {
    if(dp[v] != -1) return dp[v];
    int res = 0;
    for(int nv: g[v]) {
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res;
} 

void solve() {
	cin >> n >> m;
    g.assign(n, vector<int>());
    rep(i, m) {
        int x, y; cin >> x >> y; -- x, -- y;
        g[x].push_back(y);
    }
    dp.assign(n, -1);
    int ans = 0;
    rep(i, n) {
        chmax(ans, rec(i));
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-10;

#define INF (1<<29)
#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

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

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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


int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int r;
  int n;
  while (cin >> r >> n) {
    if (r == 0 && n == 0) break;
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    map<int, map<int, double>> height;
    int lx, rx, h;
    int l_end = INF;
    int r_end = -INF;
    rep(i, n) {
      cin >> lx >> rx >> h;
      l_end = min(l_end, lx);
      r_end = max(r_end, rx);
      REP(j, lx, rx) {
        height[j][j+1] = max<double>(h, height[j][j+1]);
      }
    }
    l_end = min(-r, l_end);
    r_end = max(r, r_end);

    // simulation
    double center = -r;
    double step = 0.0001;
    double ans = -step;
    while (true) {
      bool judge = true;
      REP(i, l_end, r_end) {
        int lx = i;
        int rx = i + 1;
        double h = height[lx][rx];
        double dl = sqrt(fabs(h - center) * fabs(h - center) + abs(lx) * abs(lx));
        double dr = sqrt(fabs(h - center) * fabs(h - center) + abs(rx) * abs(rx));
        if (dl < r || dr < r) {
          judge = false;
          break;
        }
      }
      if (!judge) break;
      center += step;
      ans += step;
    }
    cout << fixed << setprecision(4) << ans << endl;
  }
  return 0; 
}

Measured memory_bytes: 3224
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int total = 0;
  if(a >= b ){
    total += a;
    a -= 1;
  }else{
    total += b;
    b -= 1;
  }
  if(a >= b ){
    total += a;
    a -= 1;
  }else{
    total += b;
    b -= 1;
  }
  cout << total << endl;
}
  

Measured memory_bytes: 256
import math
import sys
from collections import deque
a=input()
for i in range(8):
  c=int(a[0])
  l=[a[0]]
  for j in range(3):
    if i>>j & 1:
      c+=int(a[j+1])
      l+=["+",a[j+1]]
    else:
      c-=int(a[j+1])
      l+=["-",a[j+1]]
  if c==7:
    for i in l:
      print(i,end="")
    print("=7")
    sys.exit()

Measured memory_bytes: 3316
def main():
    N, X, Y = map(int, input().split())
    tree = [[float('inf')] * N for _ in range(N)]
    ans = [0] * (N + 1)
    X -= 1
    Y -= 1
    for i in range(N):
        for j in range(i,N):
            dist = min(j - i, abs(X - i) + 1 + abs(Y - j))
            ans[dist] += 1

    for i in range(1,N):
        print(ans[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 76380
n=int(input())
xyh=[]
for i in range(n):
  x,y,h=map(int,input().split())
  xyh.append([h,x,y])
xyh.sort(reverse=True)
ans=0

for cx in range(101):
  for cy in range(101):
    for N in range(n):
      if abs(xyh[0][1]-cx)+abs(xyh[0][2]-cy)+xyh[0][0]>0:
        H=abs(xyh[0][1]-cx)+abs(xyh[0][2]-cy)+xyh[0][0]
      else:
        break
      if xyh[N][0]!=max(H-abs(xyh[N][1]-cx)-abs(xyh[N][2]-cy),0):
        break
      if N == n-1:
        ans=[cx,cy,H]
print(*ans)

Measured memory_bytes: 9240
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private long N, A, B, C, D;
    private long S;

    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        A = int.Parse(line[1]);
        B = int.Parse(line[2]);
        C = int.Parse(line[3]);
        D = int.Parse(line[4]);
    }

    bool Bo(int n)//n回+
    {
        long a = C * n;
        long b = D * n;

        long c = C * (N - 1 - n);
        long d = D * (N - 1 - n);

        long aa = b - c;
        long bb = a - c;
        if (bb <= S && S <= aa)
        {
            return true;
        }

        long cc = b - d;
        long dd = a - d;

        if (dd <= S && S <= cc)
        {
            return true;
        }
        return false;
    }


    public void Solve()
    {
        Scan();
        S = Math.Abs(A - B);
        for (int i = 0; i < N; i++)
        {
            if (Bo(i))
            {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>

using namespace std;
int main()
{
  int n;
  cin >> n;
  int sum{0};
  for(int i=0; i<n; ++i){
    int l, r;
    cin >> l;
    cin >> r;
    sum += r-l+1;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
#define N 400600
map<int,int> tp1;
set<int> tp3;
struct sth{int l,r,lb,rb;friend bool operator <(sth a,sth b){return a.l<b.l;}};
vector<sth> v[N];
int su[N][2],vl[N][2],tp[N][2],ct,n,k,s[N],cnt;
long long as;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
		tp3.insert(s[i]);if(!tp1[s[i]])tp1[s[i]]=++cnt;
		v[tp1[s[i]]].push_back((sth){i,i,1,1});
	}
	int lb=*tp3.lower_bound(1);
	while(1)
	{
		int st=tp1[lb];
		sort(v[st].begin(),v[st].end());
		int sz=v[st].size(),las=v[st][0].l;
		for(int i=0;i<sz;i++)
		{
			if(ct&&v[st][i].l!=v[st][i-1].r+1)
			{
				su[ct+1][0]=su[ct+1][1]=0;
				int s1=ct/k;
				if(s1)
				{
					for(int j=1;j<=ct;j++){int r1=j+k-1;if(r1<=ct)as+=1ll*vl[j][1]*(su[ct][0]-su[r1-1][0]);}
					for(int j=1;j<s1;j++)tp[j][0]=su[(j+1)*k-1][0]-su[j*k-1][0];
					tp[s1][0]=su[ct][0]-su[s1*k-1][0];
					for(int j=1;j<s1;j++)tp[s1-j+1][1]=-su[ct-(j+1)*k+1][1]+su[ct-j*k+1][1];
					tp[1][1]=su[ct-s1*k+1][1];
					if(!tp1[lb+1])tp1[lb+1]=++cnt,tp3.insert(lb+1);
					for(int j=1;j<=s1;j++)v[tp1[lb+1]].push_back((sth){las+j-1,j==s1?v[st][i-1].r:las+j-1,tp[j][0],tp[j][1]});
					for(int j=1;j<=s1;j++)vl[j][0]=tp[j][0],vl[j][1]=tp[j][1],su[j][0]=su[j-1][0]+vl[j][0];
					for(int j=1;j<=s1;j++){int r1=j+k-1;if(r1<=s1)as-=1ll*vl[j][1]*(su[s1][0]-su[r1-1][0]);}
				}
				ct=0;las=v[st][i].l;
			}
			vl[++ct][0]=v[st][i].lb;vl[ct][1]=v[st][i].rb;
			su[ct][0]=su[ct-1][0]+vl[ct][0];su[ct][1]=su[ct-1][1]+vl[ct][1];
		}
		su[ct+1][0]=su[ct+1][1]=0;
		int s1=ct/k;
		if(s1)
		{
			for(int j=1;j<=ct;j++){int r1=j+k-1;if(r1<=ct)as+=1ll*vl[j][1]*(su[ct][0]-su[r1-1][0]);}
			for(int j=1;j<s1;j++)tp[j][0]=su[(j+1)*k-1][0]-su[j*k-1][0];
			tp[s1][0]=su[ct][0]-su[s1*k-1][0];
			for(int j=1;j<s1;j++)tp[s1-j+1][1]=-su[ct-(j+1)*k+1][1]+su[ct-j*k+1][1];
			tp[1][1]=su[ct-s1*k+1][1];
			if(!tp1[lb+1])tp1[lb+1]=++cnt,tp3.insert(lb+1);
			for(int j=1;j<=s1;j++)v[tp1[lb+1]].push_back((sth){las+j-1,j==s1?v[st][sz-1].r:las+j-1,tp[j][0],tp[j][1]});
			for(int j=1;j<=s1;j++)vl[j][0]=tp[j][0],vl[j][1]=tp[j][1],su[j][0]=su[j-1][0]+vl[j][0];
			for(int j=1;j<=s1;j++){int r1=j+k-1;if(r1<=s1)as-=1ll*vl[j][1]*(su[s1][0]-su[r1-1][0]);}
		}
		ct=0;
		set<int>::iterator it=tp3.lower_bound(lb+1);
		if(it==tp3.end())break;
		lb=*it;
	}
	printf("%lld\n",as+n);
}

Measured memory_bytes: 26216
local s = io.read("*l")

local count = 0
count = count + ((s:sub(1, 1) == "1") and 1 or 0)
count = count + ((s:sub(2, 2) == "1") and 1 or 0)
count = count + ((s:sub(3, 3) == "1") and 1 or 0)
print(count)

Measured memory_bytes: 256
import java.util.Scanner;

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

        long ans = Long.MAX_VALUE;
        for(long a=1; a*a<=n; a++) {
            if(n % a == 0) {
                long b = n / a;
                int digits = Math.max(String.valueOf(a).length(), String.valueOf(b).length());
                ans = Math.min(ans,digits);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	long long a; scanf ("%lld", &a);
	int now = 26, sum = 26, p = 1;
	while (sum < a) now *= 26, sum += now, ++p;
	if (sum == a) {		
		for (int i = 1; i <= p; ++i) putchar ('z');
		return 0;
	} //676 //1000000000000001
	a -= (sum - now);
//	printf ("%lld %lld\n", sum , a);
	for (int i = p; i >= 1; --i) {
		int now = pow (26, i - 1);
		int k = a / now, q = a % now;
	//	if (i == 4) printf ("666 %lld %lld\n", k, q);
		if (!q) --k, q = now;
		
		putchar ('a' + k); a = q;	
	} return 0;
}

Measured memory_bytes: 4080
import sys

s=list(str(input()))
t=list(str(input()))

start=[-1 for _ in range(26)]
goal=[-1 for _ in range(26)]

for i in range(len(s)):
  a=int(ord(s[i]))-97
  b=int(ord(t[i]))-97

  if start[a]!=-1 or goal[b]!=-1:
    if start[a]!=b or goal[b]!=a:
      print('No')
      sys.exit()
  start[a]=b
  goal[b]=a

print('Yes')

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> L, R;
    rep(i, M) {
        int l, r; cin >> l >> r;
        L.push_back(l);
        R.push_back(r);
    }
    int left = L[0];
    int right = R[0];
    for (int i = 1; i < M; i++) {
        if (R[i] < left || right < L[i]) {
            cout << 0 << endl;
            return 0;
        }
        if (left < L[i]) left = L[i];
        if (R[i] < right) right = R[i];
    }
    cout << right - left + 1 << endl;
    return 0;
}

Measured memory_bytes: 1276
def main():
    h, w = map(int, input().split())

    px = [[0 for j in range(w)] for i in range(h)]
    px_stretch = [[0 for j in range(w)] for i in range(2 * h)]

    for row in range(h):
        px[row] = list(input())

    for row in range(2 * h):
        px_stretch[row] = [px[row // 2][i] for i in range(w)]
        print(''.join(px_stretch[row]))


if __name__ == "__main__":

    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::vector<std::string> w { "Sunny", "Cloudy", "Rainy", "Sunny" };
    std::string s;
    std::cin >> s;
    auto it = std::find(w.begin(), w.end(), s);
    std::cout << *++it << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int N;
cin>>N;
vector<long long> a(N);

rep(i,N)cin>>a[i];

sort(a.begin(),a.end());

long long Max=a[N-1];

multimap<long long,long long >diff;
long long  center;
if(a[N-1]%2==0){
    center=a[N-1]/2;
    rep(i,N-1){
    diff.insert(make_pair(abs(center-a[i]),i));
    }
}
else{
    center=a[N-1]/2;
    long long center2=center+1;
    rep(i,N-1){
        diff.insert(make_pair(min(abs(center-a[i]),abs(center2-a[i])),i));
    }
}
auto it=diff.begin();

long long m=a[it->second];

cout<<Max<<" "<<m<<endl;




 return 0;
}
/*
5
6 9 4 2 11

11 6


2
100 0

100 0
*/

Measured memory_bytes: 7296
#include <stdio.h>
#define MAX 100
int main(){
  int num[MAX],a,i,j,k,m,n=0;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&num[i]);
    }
    for(j=1;j<a;j++){
        i=j;
        for(k=j-1;k>=0;k--){
            if(num[k]>num[i]){
                m=num[k];
                num[k]=num[i];
                num[i]=m;
                i--;
                n++;
            }
        }
    }
       for(i=0;i<a;i++){
       printf("%d",num[i]);
       if(i !=a-1){
           printf(" ");
       }
       }
    printf("\n%d\n",n);
    return 0;
}



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

using namespace std;

#define sp << " " <<

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int d[4]={0};
    int a;
    for(int i=0;i<6;i++)
    {
        cin >> a;
        d[a-1]++;
    }
    sort(d,d+4);
    if(d[0]==1&&d[1]==1&&d[2]==2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
  	cin >> N;
    string S;
    string T;
    cin >> S >> T;

    for (int i=0; i < N; i++) {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n;
		int ans;
		
		while(scan.hasNextInt()){
			n = scan.nextInt();
			
			ans = 1;
			for(int i = 1; i <= n; i++){
				ans += i;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 25944
n, x = list(map(int, input().split()))
ls1 = list(map(int, input().split()))

ls2 = []
ls2.append(0)
for i in range(n):
  ls2.append(ls1[i]+ls2[i])
  
ct=0
for j in range(n+1):
  if ls2[j]<=x:
    ct += 1
print(ct)

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


struct Edge {
    int from;
    int to;
    int cost;
};

const long long inf = 1e18;
long long n, m; 

bool has_neg_loop(long long n, const vector<Edge> &edges) {
    bool f = false;
    vector<long long> dist(n,0);
    for (int i=0; i<n; i++) {
        for (auto e: edges) {
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i==n-1 && e.to == n-1) f |= true;
            }
        }
    }
    return f;    
}

vector<long long> 
bellman_ford(vector<long long> &dist, const vector<Edge> &edges) {
    for (int i=0; i<n; i++) {
        for (auto e: edges) {
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }
    return dist;    
}

int main () {
    cin >> n >> m;
    vector<Edge> edges(m);
    for (auto &e: edges) {
        int f, t, c; cin >> f >> t >> c;
        e = {f-1, t-1, -c};
    }
    vector<long long> distance(n, inf);
    distance[0] = 0;

    distance = bellman_ford(distance, edges);
    if (has_neg_loop(n, edges)) {
        cout << "inf" << endl;
    } else {
        cout << -1*distance[n-1] << endl;
    }
}



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

const int INF = (int)1.01e9;

bool solve(string s) {
    if (s.length() == 1) return 1;

    vector<int> cnt(3);
    for (char c : s) cnt[c - 'a']++;

    int n = s.length();
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) if (i != j) {
                if (cnt[i] == (n + 2) / 3 && cnt[j] == (n + 1) / 3 && cnt[0+1+2-i-j] == n / 3) {
                    return 1;
                }
            }
    }
    return 0;
}
int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s;
    while (cin >> s) {
        puts(solve(s) ? "YES" : "NO");
    }


#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int n; 
set<int> s;
int main() {
  	cin >> n;
    for (int i=0;i<n;i++) {
        int a;
      	cin >> a;
        s.insert(a);
    }
    if (s.size()==n)
        cout << "YES" << endl;
    else
        cout <<  "NO" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string a, b;
	string ans = "";
	cin >> a >> b;
	for(int i = 0; i < n; ++i) {
		ans += a[i];
		ans += b[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	int n, t, a;
	cin >> n >> t >> a;
	vector<int>h(n);
	for (int i = 0; i < n; i++)cin >> h[i];
	vector<double>T(n);
	vector<double>diff(n);
	vector<double>count(n);
	for (int i = 0; i < n; i++) {
		T[i] = t - h[i] * 0.006;
		diff[i] = abs(T[i] - a);
		count[i] = diff[i];
	}
	int ans;
	sort(diff.begin(), diff.end());
	for (int i = 0; i < n; i++) {
		if (diff[0] == count[i]) {
			ans = i + 1;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
string c[4] = {"AC","WA","TLE","RE"};
int a[4];

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        for(int j=0; j<4; j++){
            if(s==c[j]){
                a[j]++;
                break;
            }
        }
    }
    for(int i=0; i<4; i++){
        cout << c[i] << " x " << a[i] << endl;
    }
}


Measured memory_bytes: 3564
/* 北さん参考 */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    int n, ans = 0;
    cin >> n;    
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    REP(i, n) {
        if(p[i] == i+1) {
            ans++;
            swap(p[i], p[(i+1)%n]);
        }
    } 

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
//-----------------------------B-I-Y------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll M = 1000000007;

void solve(){
	ll n , m , i, j;
	cin >> n >> m;
	ll a[m];
	ll sum = 0;
	for( i = 0 ; i < m ; i++ ){
		cin >> a[i];
		sum += a[i];
	}
	ll ans ;
	if( n - sum >= 0 ){
		ans = n-sum;
		cout << ans << endl;
	}else{
		ans = -1;
		cout << ans << endl;
	}

}

signed main(){
    fast;
    ll t=1;
    // cin >> t;
    while( t-- )
        solve();
    return 0;
}
//-----------------------------B-I-Y------------------------------------------------

Measured memory_bytes: 3692
program main
    implicit none
    integer(4):: a,b
    character(10):: s,t,u
    read*, s,t
    read*, a,b
    read*, u

    if (u == s) then
        a=a-1
    else
        b=b-1
    end if

    print"(i0,1x,i0)",a,b
end program main

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 3e3 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

int arr[N];
ll mem[N][N][2];

ll solve(int start, int end, int player) {
  if(start > end)
    return 0;
  ll& ret = mem[start][end][player];
  if(~ret)
    return ret;
  if(player)
    ret = inf;
  else
    ret = -inf;
  ll c1 = solve(start + 1, end, player ^ 1) + arr[start] * (player ? -1ll : 1ll);
  ll c2 = solve(start, end - 1, player ^ 1) + arr[end] * (player ? -1ll : 1ll);
  if(player)
    return ret = min(c1, c2);
  else
    return ret = max(c1, c2);
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  memset(mem, -1, sizeof mem);
  cout << solve(0, n-1, 0);
  return 0;
}


Measured memory_bytes: 141952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nums = br.readLine().split(" ");
        br.close();
        int a = Integer.parseInt(nums[0]);
        int b = Integer.parseInt(nums[1]);

        if( a > 9 || b > 9) System.out.println(-1);
        else System.out.println(a*b);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    if (n==m)cout << "Yes"  << endl;
    else cout << "No" << endl;

    return 0; 
}


Measured memory_bytes: 3636