akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		for(;;)
		{
			int N = sc.nextInt(), R = sc.nextInt();
			if(N==0&&R==0) break;
			
			Stack<int[]> st = new Stack<int[]>();
			for (;R-->0;) st.push(new int[] { sc.nextInt(), sc.nextInt() });
			
			int top = 1;
			for(;!st.isEmpty();)
			{
				int[] pc = st.pop();
				int p = pc[0], c = pc[1];
				if (top <= c)
				{
					top += p - 1;
				}
				else if (c < top && top <= c + p - 1)
				{
					top -= c;
				}
			}
			System.out.println(N - (top - 1));
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> A(n),B(m);
  cin>>A>>B;

  auto calc = [](vector<int> A){
    int n = A.size();
    int res = 0;
    for(int i=1;i<n;i++) {
      int len = A[i] - A[i-1];
      int l = i;
      int r = n - i;
      res = (res + len * l * r % mod) % mod;
    }
    return res;
  };

  int a = calc(A);
  int b = calc(B);
  int ans= a * b % mod;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
	long long i,j,k,n,a,b,c,d;
	cin>>a>>b>>c>>d>>n;
	k=min(a*4,min(b*2,c));
	if(k*2<=d)cout<<k*n<<endl;
	else cout<<(n%2)*k+(n/2)*d<<endl;
	return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
vector<int> num(3);
REP(i, 3) cin >> num[i]; 
sort(all(num));
// print(num[0]);
int one = num[2];
int two = num[1];
int three = num[0];

bool x = true, y = true; // true　even

if((one - two) % 2 != 0 ) x = false;
if((one - three) % 2 != 0 ) y = false;
int ans = 0;
if(x != y){
    one++;
    two++;
    ans++;
}
ans += ((one - two) + (one - three)) / 2 ;

print(ans);

}

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

int main()
{
   ll n;
   cin>>n;
   map<ll,ll> m;
   for(int i=0;i<n;i++)
   {
       ll temp ;
       cin>>temp;
       m[temp] ++;
   }
   ll ans =0;
   auto it = m.begin() ;
   for( ;it!= m.end() ;it++)
   {
       if( it->first > it->second )
       {
           ans += it->second;
       }
       else ans += (it->second - it->first );
   }
   cout<<ans;
}

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

int64_t f(int64_t n){
    return n*(n-1)/2;
}

int main(){
    int n;
    cin>>n;
    
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    for(int i=0; i<n; i++){
        cout << ans -f(m[a[i]]) + f(m[a[i]]-1) << endl;
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vvl a(n,vl(n));
	FOR(i,0,n) FOR(j,0,n) cin >> a[i][j];

	vl value(1 << n);
	FOR(mask,0,1 << n) {
		FOR(i,0,n) if (mask & (1 << i)) {
			FOR(j,i+1,n) if (mask & (1 << j)) {
				value[mask] += a[i][j];
			}
		}
	}
	
	vl dp(1 << n,-oo);
	dp[0] = 0;
	FOR(mask,0,1 << n) {
		for (ll smask = mask; smask > 0; smask = (smask-1) & mask) {
			dp[mask] = max(dp[mask], value[smask] + dp[mask^smask]);
		}
	}
	cout << dp.back() << endl;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,M,sum=0,cnt=0;
    cin>>N>>M;
    vi A(N);
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    M*=4;
    rep(i,N){
        A[i]*=M;
        if(A[i]>=sum)cnt++;
    }
    M/=4;
    if(cnt>=M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    string S;
    int a, b, c, d;
    a = b = c = d = 0;
    for (int i = 0; i < N; i++) {
        cin >> S;
        if (S == "AC") a++;
        if (S == "WA")b++;
        if (S == "TLE")c++;
        if (S == "RE")d++;
   }
    cout << "AC x "<< a<< endl;
    cout << "WA x "<< b << endl;
    cout << "TLE x "<< c << endl;
    cout << "RE x "<< d << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,D,X;
    cin>>N>>D>>X;
    REP(i,N){
        int a; cin>>a;
        X+=1+(D-1)/a;
    }
    cout<<X<<endl;

}


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

int main() {

	int n; cin >> n;
	string s; cin >> s;
	int ans = 1;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

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

	if (a < b and b < c) {
			cout << "Yes" << endl;
	} else {
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;




string s;
string sr;
int cnt[200000];



signed main(){
    ios::sync_with_stdio(0);


    cin >> s;

    int nu = 0;
    for(int i = 0;i < s.length();i++){
        if(s[i] != 'x'){
            sr+=s[i];
            nu++;
        }else{
        cnt[nu]++;
        }
    }

    for(int i = 0;i < sr.length()/2;i++){
        if(sr[i]!=sr[sr.length()-1-i]){
            cout<< -1<< endl;
            return 0;
        }
    }

    int ans=0;
    for(int i = 0;i < (nu+1)/2;i++){
        ans+=max(cnt[i], cnt[nu-i])-min(cnt[i], cnt[nu-i]);
    }
    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 1104
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  vi b = a;
  vi c = a;

  if (prev_permutation(all(b))) {
    for (int i = 0; i < n; ++i) {
      cout << b[i];
      if (i != n - 1) cout << " ";
    }
    cout << '\n';
  }

  for (int i = 0; i < n; ++i) {
    cout << a[i];
    if (i != n - 1) cout << " ";
  }
  cout << '\n';

  if (next_permutation(all(c))) {
    for (int i = 0; i < n; ++i) {
      cout << c[i];
      if (i != n - 1) cout << " ";
    }
    cout << '\n';
  }


  return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define M 200005
using namespace std;
int n,a[M],b[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i>=1;i--){
		int now=0;
		for(int j=i;j<=n;j+=i)now+=b[j];
		if(now%2!=a[i])b[i]=1;
		else b[i]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)if(b[i])ans++;
	printf("%d\n",ans);
	for(int i=1;i<=n;i++)if(b[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>

#define rep(p,q) for(int i = p;i < q;i++)

using namespace std;

int ruiseki[100000];

int main(void) {
	string str;
	int n,q;
	cin >> n >> q >> str;
	ruiseki[0] = 0;
	rep(1, n) {
		ruiseki[i] = ruiseki[i - 1];
		if (str.substr(i - 1, 2) == "AC")ruiseki[i]++;
	}
	rep(0, q) {
		int l, r;
		cin >> l >> r;
		cout << ruiseki[r - 1] - ruiseki[l - 1] << endl;
	}
}

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

int main() {
    string s, tmp;
    while(cin >> s){
        if (s == "-") {
            break;
        }

        int m;
        cin >> m;
        int i;
        for(i = 0; i < m; i++){
            int h;
            cin >> h;
            tmp = s.substr(0, h);
            s.erase(0, h);
            s = s + tmp;
        }
        cout << s << endl;
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
vector<vector<int>> G(100030);

int main()
{
   int n,m;
   cin >> n >> m;
   for(int i=0;i<m;++i)
   {
      int x,y;
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
   }
   int level[100030]={};
   queue<int> Q;
   Q.push(1);
   while(Q.size()){
      int v = Q.front();
      Q.pop();
      for(auto i:G[v]){
            if(level[i]==0)
            {
               Q.push(i);
               level[i]=v;
            }
         }
   }
   cout<<"Yes\n";
   for(int i=2;i<=n;++i)
      cout<<level[i]<<'\n';
}


Measured memory_bytes: 10236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define SZ(X) ((int)(X).size())

const int m = 1000000007;
int C[2001][2001];

int32_t main(){
    int n;
    cin >> n;
    int ans = 0;
    C[0][0] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= i; ++j){
            C[i][j] = C[i-1][j] + C[i-1][j-1];
            C[i][j] %= m;
        }
    }
    for(int k = 1; n-2*k-1 >= 0; ++k){
        ans = (ans + C[n-2*k-1][k-1]) % m;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 26136
N = int(input())
list = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(N):
        list[input()] += 1

print('AC x ' + str(list['AC']))
print('WA x ' + str(list['WA']))
print('TLE x ' + str(list['TLE']))
print('RE x ' + str(list['RE']))

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="RRS" || s=="SRR" )cout<<2;
    else if(s=="SSS")cout<<0;
    else if(s=="RRR")cout<<3;
    else cout<<1;

}


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

int main()
{
  string s, t;
  cin >> s >> t;
  ll r = 0;
  for (int i = 0; i < (int)s.length(); i++)
  {
    if (s[i] != t[i])
      r++;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 3912
#include <stdio.h>
int main(void){
    
    int cards[128][14];
    int i, j, n, num;
    unsigned char x;
        
    scanf("%d",&n);
    
    for(i = 1; i <=n+1; i++) {
        scanf("%c %d\n", &x, &num);
        if(x=='S') cards[1][num] = 1;
        if(x=='H') cards[2][num] = 1;
        if(x=='C') cards[3][num] = 1;
        if(x=='D') cards[4][num] = 1;
    }
    
    for(i=1;i<=4;i++){
        for(j=1;j<=13;j++){
            if(i==1&&cards[i][j]==0) printf("S %d\n",j);
            else if(i==2&&cards[i][j]==0) printf("H %d\n",j);
            else if(i==3&&cards[i][j]==0) printf("C %d\n",j);
            else if(i==4&&cards[i][j]==0) printf("D %d\n",j);
        }
    }
    return 0;
}



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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    rep(i, N) {
        int same = 0;
        rep(j, N - i) {
            if (ans == i) continue;
            if (S[j] == S[j + i]) {
                same++;
                //cout << i << j << same << ans << endl;
            } else {
                ans = max(ans, min(same, i));
                same = 0;
            }
        }
        ans = max(ans, min(same, i));
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const int MOD = 998244353;

const int MAX_N = 310;
const int SIZE = 90010;

ll dp[MAX_N][SIZE];

int main2() {
  CLR(dp, 0);
  int N; cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  const int S = accumulate(ALL(A), 0);

  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < SIZE; j++) {
      dp[i+1][j] = (j - A[i] >= 0 ? dp[i][j - A[i]] : 0) + dp[i][j] * 2;
      dp[i+1][j] %= MOD;
    }
  }

  ll ans = 0;
  for (int j = 0; j < SIZE; j++) {
    if (2 * j >= S) {
      ans += 3 * dp[N][j];
      ans %= MOD;
    }
  }

  ll three = 1;
  REP(i, N) three = (three * 3) % MOD;

  ans = (three - ans + MOD) % MOD;

  // (R, G, B) = (S/2, S/2, 0), (S/2, 0, S/2) の場合を重複して引いたので帳尻合わせ
  if (S % 2 == 0) {
    CLR(dp, 0);
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < SIZE; j++) {
        dp[i+1][j] = (j - A[i] >= 0 ? dp[i][j - A[i]] : 0) + dp[i][j];
        dp[i+1][j] %= MOD;
      }
    }
    ans = (ans + dp[N][S/2] * 3) % MOD;
  }

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 218240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N; cin >> N;
    ll sum = 0;

    vector<ll> a(N),d(N);
    for(int i=0; i<N; ++i) { cin >> a[i]; sum += a[i]; }

    if(sum%(N*(N+1)/2) != 0){
        cout << "NO" << endl;
        return 0;
    }

    ll k = sum/(N*(N+1)/2);
    for(int i=0; i<N; ++i) d[i] = a[(i+1)%N] - a[i];
    for(int i=0; i<N; ++i) d[i] -= k;

    ll cnt = 0;
    for(int i=0; i<N; ++i){
        if(d[i] > 0){
            cout << "NO" << endl;
            return 0;
        }
        else if((-d[i])%N != 0){
            cout << "NO" << endl;
            return 0;
        }
        else{
            cnt += (-d[i])/N;
        }
    }   

    if(cnt == k){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 1792
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

using namespace std;

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

	ll a, b;
	cin >> a >> b;

	string s;
	cin >> s;

	for(int i = 0; i < a; i++)
	{
		if (!('0' <= s[i] && s[i] <= '9'))
		{
			cout << "No";
			return 0;
		}
	}

	if(s[a] != '-')
	{
		cout << "No";
		return 0;
	}

	for (int i = a + 1; i < a + 1 + b; i++)
	{
		if (!('0' <= s[i] && s[i] <= '9'))
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



fn position_max<T: Ord>(slice: &[T]) -> Option<usize> {
    slice.iter().enumerate().max_by(|(_, value0), (_, value1)| value0.cmp(value1)).map(|(idx, _)| idx)
}

fn main() {
    input! {
        D: usize,
        C: [i64; 26],
        S: [[i64; 26]; D],
    }

    let score = |sol: &Vec<i64>| -> i64 {
        let mut sat: i64 = 0;
        let mut last = vec![0; 26];
        for (d, v) in sol.iter().enumerate() {
            let j: usize = (v - 1) as usize;
            last[j] = d + 1;
            for i in 0..26 {
                sat -= (d + 1 - last[i]) as i64 * C[i];
            }
            sat += S[d][j];
        }

        return sat;
    };

    let i = position_max(&C).unwrap() as i64;

    let mut ans:Vec<i64> = vec![];
    let mut last = vec![0; 26];
    for d in 0..D {
        let mut ma = 0;
        let mut mai = 0;
        for j in 0..26 {
            let a = (d + 1 - last[j]) as i64 * C[j] + S[d][j];
            if a > ma {
                ma = a;
                mai = j;
            }
        }
        last[mai] = d + 1;
        ans.push((mai+1) as i64);
    }

    for c in ans {
        println!("{}", c);
    }
    // println!("{}", score(&ans));
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define INTMAX 2147483647LL
#define PII pair<int,int>
#define MK make_pair
#define re register
using namespace std;
typedef long long ll;
const double Pi=acos(-1.0);
const int Inf=0x3f3f3f3f;
const int MAXN=1e5+10;
inline int read(){
	re int x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}
inline ll readll(){
	re ll x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}

int n; 
ll E,T;
ll a[MAXN],f[MAXN];
int main(){
	n=read();E=readll();T=readll();
	for(int i=1;i<=n;++i) a[i]=readll();
	
	f[0]=0;
	int now=0;ll mn=1e18+7;
	for(int i=1;i<=n;++i){
		while(T<=2*(a[i]-a[now+1])){
			mn=min(mn,f[now]-2*a[now+1]);++now;
		}
		f[i]=min(f[now]+T,mn+2*a[i]);
	}
	printf("%lld",E+f[n]);
	return 0;
}

Measured memory_bytes: 1792
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll m=0;
    ll n,c=0;
    str s;
    cin >> n;
    cin >> s;
    for(ll i=0;i<n;i++){
        switch(s[i]){
            case 'A':
                m=1;
                break;
            case 'B':
                if(m==1){
                    m=2;
                }else{
                    m=0;
                }
                break;
            case 'C':
                if(m==2){
                    c++;
                }
                m=0;
                break;
            default:
                m=0;
                break;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int n;
	long a[100010];
	long ans[100010] = {0};
	long num = 0;
	
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = 0; i < n; i++) {
		if (i % 2) {
			num += (a[i]*-1);
		}
		else {
			num += a[i];
		}
	}
	
	
	ans[0] = num;
	
	for (int i = 1; i < n; i++) {
		ans[i] = abs(ans[i-1] - (a[i-1]*2));
	}
	
	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2816
n, k = gets.chomp.split(" ").map(&:to_i)

sigma = 0.0
(1..n).each do |i|
    ruijo = 1
    p = 1
    while k > i * ruijo
        ruijo *= 2
        p *= 0.5
    end
    sigma += p
end
sigma = sigma.to_f / n.to_f

puts sigma

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t A, B, C; cin >> A >> B >> C;
	if(C - (A + B) < 0) {
		cout << "No" << '\n';
		return 0;
	}
	__int128_t a = A, b = B, c = C;
	cout << (4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
 int a,b;

scanf("%d%d%d",&a,&b);

if(a==1 && b==2){
 printf("3\n");
}

else if(a==1 && b==3){
printf("2\n");
}

else if(a==2 && b==1){
 printf("3\n");
}

else if(a==2 && b==3){
 printf("1\n");
}

else if(a==1 && b==3){
 printf("2\n");
}

else if(a==3 && b==1){
 printf("2\n");
}

else if(a==3 && b==2){
 printf("1\n");
}

return 0;
}


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

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

    if(s.length()==2){
        cout << s << endl;
    }else if(s.length()==3){
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}


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

// typedef
using ll = long long;

// loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

// YesNo
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

int a, b, c, k;
bool solve() {
	rep(i, k) {
		if(a >= c || b >= c) {
			c *= 2;
		} else if(a >= b) {
			b *= 2;
		}
		if(a < b && b < c) {
			return true;
		}
	}
	return false;
}
int main(void) {
	cin >> a >> b >> c;
	cin >> k;

	Yes(solve());
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <array>
#include <algorithm>

using namespace std;

int main(){
  array<char, 3> odd = {'R', 'U', 'D'};
    array<char, 3> even = {'L', 'U', 'D'};
    string s;
    cin >> s;

    int length = s.length();

    for(int i = 0; i < length; ++i) {
        if(i % 2 ? !any_of(even.cbegin(), even.cend(), [s, i](char c){return s[i] == c;})
                 : !any_of(odd.cbegin(), odd.cend(), [s, i](char c){return s[i] == c;}))
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
/* You got a dream , you gotta protect it . */
/* You got a dream , you gotta protect it . */
/* You got a dream , you gotta protect it . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const long long MOD = 1e9 + 7;
int main(){
    FAST
    ll n , a , b , cnt = 0;
    cin >> n >> a >> b;
    if((n % (a + b)) > a) cnt+=a;
    else cnt+=(n % (a + b));
    cnt+=((n / (a + b)) * a);
    cout << cnt << endl;
    return 0;
}
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


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

int main() {
  string S;
  cin >> S;
  deque<char> s;
  for(int i = 0; i < S.size(); i++) {
    s.push_back(S.at(i));
  }
  
  int Q;
  cin >> Q;
  bool judge = false;
  //vector<tuple<int, int, char>> TFC(Q, make_tuple(0, 0, '0'));
  for(int i = 0; i < Q; i++) {
    int a, b;
    char c;
    cin >> a;
    if(a == 1) {
      judge = !judge;
      //reverse(s.begin(), s.end());
    }
    
    else if(a == 2) {
      cin >> b >> c;
      if(b == 1) {
        if(judge == 0) {
          s.push_front(c);
        }
        
        else {
          s.push_back(c);
        }
        
      }
      
      else if(b == 2) {
        if(judge) {
          s.push_front(c);
        }
        
        else {
          s.push_back(c);
        }
        
      }
      
    }
  }
  if(judge) {
    reverse(s.begin(), s.end());
  }
  
  for(int i = 0; i < s.size(); i++) {
    cout << s.at(i);
  }
  
  cout << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  vector<string> S(3);
  cin >> S[0] >> S[1] >> S[2];
  int a=0,b=0,c=0;
  char now = 'a';
  while(1){
    if(now == 'a'){
      if(a == S[0].size())break;
      now = S[0][a];
      a++;
    }
    else if(now == 'b'){
      if(b == S[1].size())break;
      now = S[1][b];
      b++;
    }
    else if(now == 'c'){
      if(c == S[2].size())break;
      now = S[2][c];
      c++;
    }
  }
  if(now == 'a')cout << 'A' << endl;
  if(now == 'b')cout << 'B' << endl;
  if(now == 'c')cout << 'C' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long int
#define vll vector<long long int>
#define vpi vector<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a ; i<b ; ++i)
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main() {
    IOS;
    int n; cin>>n;
    vi v(n);
    rep(i,0,n) cin >> v[i];
    int cnt=0;
    rep(i,0,n){
        if(i%2==0 && v[i]%2!=0) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#define loop_input(fmt,...) while(~scanf(fmt,__VA_ARGS__))

int main() {
    int a, b;
    loop_input("%d%d", &a, &b) {
        if (a == 0 && b == 0) break;
        if (a > b)  a ^= b ^= a ^= b;
        printf("%d %d\n", a, b);
    }
    return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n], odd = 0, even = 0, four = 0;
    for (int i = 0; i < n; i++) 
    {
        cin >> a[i];
        if (a[i] % 2 == 1) odd++;
        else if (a[i] % 4 == 2) even++;
        else four++;
    }
    if (even == 0 && odd <= four + 1) cout << "Yes";
    else if (even > 0 && odd <= four) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans=0;
  cin >> n;
  
  if(n%2!=0&&n%n!=1){
    ans = n*2;
  }else if(n%2==0&&n%n==0){
    ans = n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int count[1000] = {};
  int n,k;cin>>n>>k;
  rep(_t, k){
    int d;cin>>d;
    rep(i,d){
      int a;cin>>a;
      a--;
      count[a]++;
    }
  }
  int ans = 0;
  rep(i,n){
    if(count[i] == 0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    int lis[4]={0};
    for(int i=0;i<N;i++){
        string S;
        cin>>S;
        if(S[0]=='A')lis[0]++;
        if(S[0]=='W')lis[1]++;
        if(S[0]=='T')lis[2]++;
        if(S[0]=='R')lis[3]++;
    }
    printf("AC x %d\n",lis[0]);
    printf("WA x %d\n",lis[1]);
    printf("TLE x %d\n",lis[2]);
    printf("RE x %d\n",lis[3]);
    return 0;
}


Measured memory_bytes: 3712
def sgn(a, b):
    return int(a*b/abs(a*b))

class Dice:
    def __init__(self, numbers):
        self.numbers_dict = {1:numbers[0], 2:numbers[1], 3:numbers[2], -3:numbers[3], -2:numbers[4], -1:numbers[5]}
        self.numbers_ver_dict = {numbers[0]:1, numbers[1]:2,numbers[2]:3,numbers[3]:-3, numbers[4]:-2,numbers[5]:-1}

    # a:top, b:front
    def show_right(self, a, b):
        var_a = self.numbers_ver_dict[a]
        var_b = self.numbers_ver_dict[b]
        if abs(var_a) == 1:
            if abs(var_b) == 2:
                return self.numbers_dict[sgn(var_a,var_b)*3]
            else:
                return self.numbers_dict[-sgn(var_a,var_b)*2]
        elif abs(var_a) == 2:
            if abs(var_b) == 1:
                return self.numbers_dict[-sgn(var_a, var_b)*3]
            else:
                return self.numbers_dict[sgn(var_a,var_b)]
        else:
            if abs(var_b) == 1:
                return self.numbers_dict[sgn(var_a, var_b)*2]
            else:
                return self.numbers_dict[-sgn(var_a,var_b)]

if __name__ == '__main__':
    examin_list = list(map(int, input().split()))
    dice1 = Dice(examin_list)
    dice2 = Dice(list(map(int, input().split())))
    yes_flag = True
    exam_tuple = ((examin_list[0], examin_list[1]), (examin_list[0], examin_list[2]), (examin_list[0], examin_list[4]),
                  (examin_list[0], examin_list[3]), (examin_list[1], examin_list[5]))
    for num in exam_tuple:
        if dice1.show_right(num[0], num[1]) != dice2.show_right(num[0], num[1]):
            print('No')
            yes_flag = False
            break
    if yes_flag:
        print('Yes')



Measured memory_bytes: 5608
use std::io;
use std::collections::HashMap;

fn main(){
  loop {
    let v = read_vu32();
    let mut x = v[0];
    let y = v[1];
    
    if x == 0 && y == 0 {break;}

    let mut hm: HashMap<u32, u32> = HashMap::new();
    let mut i:u32 = 0;

    loop {
      if x == 0 {
        println!("{} {}", i, 0);
        break;
      }

      match hm.get(&x) {
        Some(&j) =>  {
          println!("{} {}", j, i - j);
          break;
        },
        None => {
          hm.insert(x, i);
          x = x * 10 % y;
          i += 1;
        }
      }
    }
  }
}

fn read_vu32() -> Vec<u32> {
   let mut buf = String::new();
   io::stdin().read_line(&mut buf).expect("read error");
   buf.trim().split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 54224
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    int flag=1;
    for(i=n-2;i>=0;i--)
    {
        if(arr[i]>arr[i+1])
        {
            if(arr[i]-arr[i+1]==1 )arr[i]--;
            else flag=0;
        }
    }
    if(flag)cout<<"Yes";
    else cout<<"No";

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 5e5 + 1, CC = 10001;

using namespace std;

string s, t;
int n, m;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> s; n = s.size();
    int bc = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') ++bc;
        else ans += bc;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3768
N = int(input())
b = list(map(int, input().split()))

ans=[]
while b:
    for i in reversed(range(len(b))):
        if i==b[i]-1:
            b.remove(b[i])
            ans.append(i)
            break
        if i==0:
            print(-1)
            exit()
ans.reverse()
for i in ans:
    print(i+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
   while( scanf("%d%d%d",&a,&b,&c)==3)
   {

       if((a<=c&&b>=c))
       {
           printf("Yes\n");
       }
       else
       {
          printf("No\n");

       }

   }


    return 0;
}


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

int main(){
	int n;
	cin >> n;
	for (int t = 1; t <= n; t++){
		if (t % 3 == 0)cout << " " << t;
		else{
			int s = t;
			for (int i = 0;s!=0;){
				if (s % 10 == 3){
					cout << " " << t;
					i++;
				}
				s = s / 10;
				if (i == 1)break;
			}
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
// return gcd(a,b)
long long gcd(long long a, long long b) {
    // O(log min(a,b))
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

// return the answer of "ax + by = gcd(a,b)"
long long extend_gcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    } else {
        long long d = extend_gcd(b, a % b, y, x);
        y -= a / b * x;
        return d;
    }
}

map<long long, int> prime_factor(long long n) { // prime factorization
    map<long long, int> ret;
    for (long long i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    long long x, y;
    cin >> x >> y;
    ll d = gcd(x, y);
    map<ll, int> prime_fac = prime_factor(d);
    cout << prime_fac.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

void print_grid(int x, int y, std::string grid[])
{
  for (auto i = 0; i < y; ++i) {
    auto c = 0;
    for (auto j = 0; j < x; ++j) {
      if (grid[i][j] == 'n') {
        ++c;
        continue;
      }
      std::cout << grid[i][j];
    }
    if (x != c)
      std::cout << std::endl;
  }
}

int main()
{
  // input grid
  int x, y;
  std::cin >> y >> x;
  std::string in_grid[y];
  std::string out_grid[y];
  for (auto i = 0; i < y; ++i) {
    std::cin >> in_grid[i];
    out_grid[i] = in_grid[i];
  }
  // check grid row
  for (auto i = 0; i < x; ++i) {
    for (auto j = 0; j < y; ++j) {
      if ('.' != in_grid[j][i]) break;
      if (j == y-1) {
        for (auto k = 0; k < y; ++k) {
          out_grid[k][i] = 'n';
        }
      }
    }
  }
  // check grid column
  for (auto i = 0; i < y; ++i) {
    for (auto j = 0; j < x; ++j) {
      if ('.' != in_grid[i][j]) break;
      if (j == x-1) {
        for (auto k = 0; k < x; ++k)
          out_grid[i][k] = 'n';
      }
    }
  }
  print_grid(x, y, out_grid);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    cout << *max_element(a.begin(),a.end()) - *min_element(a.begin(),a.end());
}

Measured memory_bytes: 256
import sys

if __name__ == "__main__":
    (X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
    A = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))
    C = list(map(int, sys.stdin.readline().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    v = []
    for a in range(len(A)):
        for b in range(len(B)):
            if (a + 1) * (b + 1) > K:
                break
            for c in range(len(C)):
                if (a + 1) * (b + 1) * (c + 1) > K:
                    break
                v.append(A[a] + B[b] + C[c])

    v.sort(reverse=True)

    for i in range(K):
        sys.stdout.write("%d\n" % v[i])

Measured memory_bytes: 47856
<?php
// B - Digit Sums
$sum = 0;

$stdin = trim(fgets(STDIN));
$len = strlen($stdin);

for ($i=0; $i < $len; $i++) {
  $digit = substr($stdin, $i, 1);
  $sum = $sum + $digit;
}

//echo ("sum = $sum\n");

$odd = $stdin % $sum;
//echo ("odd = $odd\n");
if ($odd > 0) echo ("No\n");
else echo ("Yes\n");
?>


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

long f1(long n, int p) {
  if (n == 0) return 0;
  return n / p + f1(n / p, p);
}

long f2(long n, int p) {
  if (n % 2 == 1) {
    return f1(n, p) - f2(n - 1, p);
  }
  long res = f1(n / 2, p);
  if (p == 2) res += n / 2;
  return res;
}

int main() {
  long N;
  cin >> N;
  if (N % 2) return cout << 0 << "\n", 0;
  cout << f2(N, 5) << "\n";
}

Measured memory_bytes: 3604
import fractions
a, b = map(int, input().split())
n = fractions.gcd(a, b)
i = 1
ass = [1]
for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        ass.append(i)
        n = n//i
if n != 1:
    ass.append(n)
print(len(set(ass)))

Measured memory_bytes: 5048
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  for(int tci = 0; ; ++tci) {
    int n; scanf("%d", &n);
    if(n==0) break;
    int m0v=0, m1v=1000, sum=0;
    for(int i = 0; i < n; ++i) {
      int x; scanf("%d", &x);
      sum += x;
      m0v = max(m0v, x);
      m1v = min(m1v, x);
    }
    printf("%d\n", (sum-m0v-m1v)/(n-2));
  }
  return 0;
}

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

int main(){
	int amida[30];
	for (int i = 0; i < 30; i++){
		amida[i] = i + 1;
	}
	int n, w;
	int a, b;

	cin >> w;
	cin >> n;
	int c;
	for (int i = 0; i < n; i++){
		char c;
		cin >> a >> c >> b;
		swap(amida[a - 1], amida[b - 1]);
	}
	for (int i = 0; i < w; i++){
		cout << amida[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

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

int main()
{
    queue<P> que;
    int H,W;
    cin >> H >> W;
    int tile[H+2][W+2];
    for(int i=0; i<H+2; i++){
        fill(tile[i], tile[i]+W+2, 1);
    }
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            char tmp;
            cin >> tmp;
            if(tmp=='#'){
                tile[i][j]=1;
                que.push(P(i, j));
            }else{
                tile[i][j]=0;
            }
        }
    }

    int ans=-1;
    while(true){
        ans++;
        queue<P> tmp;
        int s=que.size();
        for(int i=0; i<s; i++){
            P p=que.front(); que.pop();
            if(tile[p.first-1][p.second]==0){
                tmp.push(P(p.first-1, p.second));
                tile[p.first-1][p.second]=1;
            }
            if(tile[p.first+1][p.second]==0){
                tmp.push(P(p.first+1, p.second));
                tile[p.first+1][p.second]=1;
            }
            if(tile[p.first][p.second-1]==0){
                tmp.push(P(p.first, p.second-1));
                tile[p.first][p.second-1]=1;
            }
            if(tile[p.first][p.second+1]==0){
                tmp.push(P(p.first, p.second+1));
                tile[p.first][p.second+1]=1;
            }
        }
        if(!tmp.size()) break;
        int s2=tmp.size();
        for(int i=0; i<s2; i++){
            P p=tmp.front(); tmp.pop();
            que.push(p);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032