akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	char c;
	cin>>c;
	c++;
	cout<<c<<endl;
}









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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int n;
string s[10000];
LL lb=0,ra=0;

LL innercnt(string s){
  LL cnt=0;
  if(s[s.size()-1]=='A')ra++;
  if(s[0]=='B')lb++;
  REP(i,s.size()-1){
    if(s[i]=='A' && s[i+1]=='B')cnt++;
  }
  return cnt;
}

int main(){
  cin>>n;
  LL cnt=0;
  REP(i,n){
    cin>>s[i];
    cnt+=innercnt(s[i]);
  }
  if(lb==ra){
    bool flg=true;
    REP(i,n){
      flg = flg && !((s[i][0]=='B') ^ (s[i][s[i].size()-1]=='A'));
    }
    if(flg)
      cout<<cnt+max(0LL,min(lb,ra)-1LL)<<endl;
    else
      cout<<cnt+min(lb,ra)<<endl;
  }else
    cout<<cnt+min((LL)(n-1),min(lb,ra))<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[10010], b[10010], c[10010], ans[10010];
P d[10010];
vector<int> vec[10010];
int used[10010];
void dfs(int s, int p) {
	for (int i : vec[s]) {
		if (!used[i]) {
			used[i] = p + 1;
			dfs(i, p + 1);
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
	}
	rep(i, n)cin >> c[i];
	dfs(1, 0);
	REP(i, n) {
		d[i] = make_pair(used[i], i);
	}
	sort(c, c + n, greater<int>());
	sort(d + 1, d + n + 1);
	REP(i, n) {
		ans[d[i].second] = c[i - 1];
	}
	int sum = 0;
	rep(i, n) {
		sum += min(ans[a[i]], ans[b[i]]);
	}
	cout << sum << endl;
	REP(i, n - 1)cout << ans[i] << " ";
	cout << ans[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top=0,stack[100];

int pop();
void push(int);

int main(){
  int x,y,z;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x=pop();
      y=pop();
      push(x+y);

    } else if ( s[0] == '-' ){
      y=pop();
      x=pop();
      push(x-y);

    } else if ( s[0] == '*' ){
      x=pop();
      y=pop();
      push(x*y);

    } else {
      z = atoi(s);
      push(z);

    }
  }
  printf("%d\n",pop());
  return 0;
}

int pop(){
  top--;
  return stack[top];
}

void push(int a){
  stack[top]=a;
  top++;
}
  



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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt=0;
    rep(i,0,s.size()-2){
        if(s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }
    cout << cnt << endl;
}

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


int main(){
    int n,m;
    cin >> n >> m;
    multiset<ll> s;

    rep(i,n){
        ll temp;
        cin >> temp;
        s.insert(temp);
    }

    rep(i,m){
        ll temp = *s.rbegin();
        s.erase(--s.end());
        s.insert(temp/2);
    }

    ll ans = 0;
    for(auto v:s) ans += v;

    cout << ans << endl;


}

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=3e5+10, maxm=5e4+10, lg=21, mod=998244353, inf=1e18;

ll n,A,B,K,fac[maxn],inv[maxn];
ll pwm(ll a,ll b){if(b==0)return 1;if(b%2)return a*pwm(a,b-1)%mod;ll ret=pwm(a,b/2);return ret*ret%mod;}
ll C(ll n,ll r){return fac[n]*inv[r]%mod*inv[n-r]%mod;}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	fac[0]=inv[0]=1; for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod, inv[i]=pwm(fac[i],mod-2);
	cin>>n>>A>>B>>K;
	ll ans=0;
	for(int i=0;i<=n;i++)if(K-i*A>=0 && (K-i*A)%B==0){
		ll cc=(K-i*A)/B;
		if(cc>n) continue;
		ans+=C(n,i)*C(n,cc)%mod, ans%=mod;
	}
	cout<<ans;
	
	return 0;
}



 


Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <class T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

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

    ll sum = 0;
    for(char c : s){
        sum += c - '0';
    }

    if(sum % 9) puts("No");
    else
        puts("Yes");

    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, ans, tmp; cin >> n;
    vector<int> l;
    ans = tmp = 0;
    for (int i = 0; i < n; i++){
        int di;
        cin >> di; 
        l.push_back(di);
    }
    sort(l.begin(), l.end());
    for (auto itr = l.begin(); itr != l.end(); ++itr)
    {
        if (tmp < *itr)
        {
            ans++;
            tmp = *itr;
        }
    }
    cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>a(3*N);
	for (int i = 0;i < 3*N;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	ll sum = 0;
	for (int i = 0;i < 2*N;i+=2) {
		sum = sum + a[N+i];
	}
	cout<<sum<<endl;

}

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

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

  ll x2 = 0;
  rep(i, n) {
    if (i % 2)
      x2 -= a[i];
    else
      x2 += a[i];
  }
  vector<int> ans(n);
  ans[0] = x2 / 2;
  rep(i, n - 1) ans[i + 1] = a[i] - ans[i];
  rep(i, n) ans[i] *= 2;

  rep(i, n) printf("%d%c", ans[i], (i == n - 1 ? '\n' : ' '));
  return 0;
}


Measured memory_bytes: 3988
#include <iostream>

using namespace std;

int n;
string s;
int dp[1000][1000];

int main() {

    while (cin >> n) {
        if (n == 0) break;

        for (int i = 0; i < n; i++) {
            cin >> s;
            for (int j = 0; j < n; j++) {
                dp[i][j] = s[j] == '.' ? 1 : 0;
            }
        }

        int ans = 0;

        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                if (dp[i][j]) {
                    dp[i][j] = min(dp[i - 1][j], min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
                    ans = max(ans, dp[i][j]);
                }
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 7000
import java.util.*;
public class Main{

 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double ans = 1;
    for(int i = 1; i <= n; i++){
      ans = (ans * i) % 1000000007;
    }
 
    System.out.println((int)ans);
  }
}

Measured memory_bytes: 21584
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);


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

  ll n;
  cin >> n;
  string s;
  cin >> s;

  vector<ll> rs(n, 0), gs(n, 0), bs(n, 0);
  if (s[0] == 'R') rs[0]++;
  else if (s[0] == 'G') gs[0]++;
  else bs[0]++;

  for (int i = 1; i < n; i++) {
    rs[i] = rs[i-1];
    gs[i] = gs[i-1];
    bs[i] = bs[i-1];
    if (s[i] == 'R') rs[i]++;
    else if (s[i] == 'G') gs[i]++;
    else bs[i]++;
  }

  ll ans = 0;
  rep(i, n-3) {
    char x = s[i];
    for (int j = i+1; j < n-1; j++) {
      char y = s[j];
      if (x == y) continue;
      int ng = j + (j-i);  // ng >= n に注意
      if (x != 'R' && y != 'R') {
        ans += rs[n-1] - rs[j];
        if (ng < n && s[ng] == 'R') ans--;
      } else if (x != 'G' && y != 'G') {
        ans += gs[n-1] - gs[j];
        if (ng < n && s[ng] == 'G') ans--;
      } else if (x != 'B' && y != 'B') {
        ans += bs[n-1] - bs[j];
        if (ng < n && s[ng] == 'B') ans--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 2019;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

void solve(){
   string s;

   cin >> s;
   int n = (int)(s.size());

   map<int, int> freq;
   int ans = 0;

   reverse(s.begin(), s.end());
   freq[0]++;

   int pw = 1;
   for (int i = 0; i < n; ++i)
   {
      ans = (s[i] - '0') * pw + ans % mod;
      ans %= mod;
      pw *= 10;
      pw %= mod;
      freq[ans]++;
   }

   ans = 0;
   for(auto it: freq){
      ans += (it.second * (it.second - 1)) / 2;
   }

   cout<<ans;
}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    string s;
    while(cin>>s)
    {
        int i,len,a[100005];
        len=s.length();
        fill(a,a+len,0);
        int j,k;
        for(i=0; i<len; i++)
        {
            if(s[i]=='R')
            {
                if(i-1>0&&s[i-1]=='R')
                    ;
                else
                {
                    j=i;
                    while(s[j]!='L')
                        j++;
                }
                if((j-i)%2)
                    a[j-1]++;
                else
                    a[j]++;
            }
            else
            {
                if(s[i-1]=='L')
                    ;
                else
                {
                    k=i;
                    while(s[k]!='R')
                        k--;
                }
                if((i-k)%2)
                    a[k+1]++;
                else
                    a[k]++;
            }
        }
        for(i=0; i<len; i++)
            cout<<a[i]<<' ';
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int number;
	char str[2];
	int a = 0;
	int b = 0;
	int ab = 0;
	int o = 0;
	while(scanf("%d,",&number) != EOF){
		scanf("%s",str);
		if(str[0] == 'A'){
			if(str[1] == 'B'){
				ab++;
			}
			else{
				a++;
			}
		}
		if(str[0] == 'B'){
			b++;
		}
		if(str[0] == 'O'){
			o++;
		}
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 


int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c = 0;
    int i = 0;
    while(i<n)
    {
        if(s[i]=='W')
        {
            c++;
        }
        i++;
    }
    int c1 = 0;
    i = 0;
    while(i<n-c)
    {
        if(s[i]=='W')
        {
            c1++;
        }
        i++;
    }
    cout<<c1<<"\n";
    
    
    return 0;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);

}

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

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m = 0, count = 0, sum = 0;
	llint k, a, b;
	bool check = false;
	string ss;
	vector<llint> array;
	vector<char> ch;
	cin >> a>>b>>n;
	if (b <= n) ans = max((a * n / b) - a * (n / b), (a * (b - 1) / b) - a * ((b - 1) / b)); 
	else ans = (a * n / b) - a * (n / b);
	cout << ans << endl;

	please AC;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
long long x[100002],n,a,b,ans;
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	sort(x+1,x+n+1);
	for(int i=2;i<=n;i++){
		if((x[i]-x[i-1])*a>b)ans+=b;
		else ans+=(x[i]-x[i-1])*a;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
v=list(map(int,input().split()))
lim=min(n,k)
V=len(v)
ans=-1*float("inf")
for a in range(0,lim+1):
    for b in range(0,lim+1):
        x=[]
        m=k-a-b
        if a+b>lim:
            break
        for i in range(a):
            x.append(v[i])
        for i in range(V-1,V-b-1,-1):
            x.append(v[i])
        x.sort()
        for i in range(m):
            if x:
                if x[0]<0:
                    X=x.pop(0)
        ans=max(ans,sum(x))
print(ans)


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

ans = []

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

for a in reversed(ans):
    print(a)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll dp[2050][2050];
ll c[2050];
ll w[2050];
bool cmp(ll a, ll b) {
    return a > b;
}
ll sum1[N],sum2[N],sum3[N], sum4[N];
void solve(){
    ll n,s;
    cin >> n >> s; 
    for(int i = 1; i <= n; ++i)
        cin >> w[i] >> c[i];
    ll mn = *min_element(w + 1, w + n + 1); 
    vector <ll> v1, v2,v3 ,v4;
    for(int i = 1; i <= n; ++i) {
        if(w[i] == mn) {
            v1.pb(c[i]);
        }
        else if(w[i] == mn + 1) {
            v2.pb(c[i]);
        }
        else if(w[i] == mn+ 2){
            v3.pb(c[i]);
        }
        else {
            v4.pb(c[i]);
        }
    }
    sort(rall(v1));
    sort(rall(v2));
    sort(rall(v3));
    sort(rall(v4));
    v1.insert(v1.begin(), 0);
    v2.insert(v2.begin(), 0);
    v3.insert(v3.begin(), 0);
    v4.insert(v4.begin(), 0);
    for(int i = 1; i < v1.size(); ++i) {
        sum1[i] = sum1[i - 1] + v1[i];
    }
    for(int i = 1; i < v2.size(); ++i) {
        sum2[i] = sum2[i - 1] + v2[i];
    }
    for(int i = 1; i < v3.size(); ++i) {
        sum3[i] = sum3[i - 1] + v3[i];
    }
    for(int i = 1; i < v4.size(); ++i) {
        sum4[i] = sum4[i - 1] + v4[i];
    }
    ll mx = 0;
    for(ll i = 0; i < v1.size(); ++i) {
        for(ll j = 0; j < v2.size(); ++j) {
            for(ll k = 0; k < v3.size(); ++k) {
                if(i * mn + j * (mn + 1) + k * (mn + 2) > s)
                    continue;
                ll m4 = (s - (i * mn + j * (mn + 1) + k * (mn + 2)) )/ (mn + 3);
                ll tot = sum1[i] + sum2[j] + sum3[k] + sum4[m4]; 
                mx = max(mx, tot);
            }
        }
    }
    cout << mx;
}
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
using namespace std;
constexpr auto MOD = 1000000007;

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

	int N, M;
	cin >> N >> M;
	vector<long long> dp(100010, 0);
	vector<int> broken(100010, 0);
	for (int i = 0; i < M; ++i) {
		int tmp; cin >> tmp;
		broken[tmp] = 1;
	}
	dp[0] = 1;
	for (int i = 1; i <= N; ++i) {
		if (broken[i]) continue;
		if (i == 1) dp[1] = 1;
		else dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7)
    {
        cout<<"YES"<<endl;
    }
    else if(a==5&&b==7&&c==5)
    {
        cout<<"YES"<<endl;
    }
    else if(a==7&&b==5&&c==5)
    {
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N,X;
        N = scan.nextInt();
        X = scan.nextInt();
        int [] L = new int [N];
        for(int i=0;i<N;i++){
            L[i] = scan.nextInt();
        }
        int [] D = new int [N+1];
        D[0] = 0;
        for(int i=1;i<=N;i++){
            D[i] = D[i-1] +L[i-1];
        }
        int count = 0;
        for(int i=0;i<=N;i++){
            if(D[i]<=X){
                count++;
            }
        }
        System.out.println(count);
    }
}

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

int main() {
    string S;
    cin >> S;
    sort(S.begin(), S.end());

    if(S=="abc"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3608
program prob1
    implicit none
    character(len=3)::S,T
    integer::l
    read(*,*) S
    l = len_trim(S)
    if(l == 2) then
        write(*,'(a)') trim(S)
    else
        T(1:1) = S(3:3)
        T(2:2) = S(2:2)
        T(3:3) = S(1:1)
        write(*,'(a)') trim(T)
    end if
    stop
end program

Measured memory_bytes: 2924
//code by 27.
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<cassert>
#include<climits>
#include<cmath>
#include<memory.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(((a+b)%3==0)||(a%3==0)||(b%3==0))cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
n-=1
ans=0
for i in range(1<<n):
    tmp=0
    for j in range(n):
        if (i>>j)&1:
            ans+=int(s[tmp:j+1])
            tmp=j+1
    ans+=int(s[tmp:])
print(ans)


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

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n, a, b;

vector <int> edges[N_MAX];

int parent[N_MAX];

int depth[N_MAX];

int mxd[N_MAX];

void dfs (int node)
{
    mxd[node] = 0;
    for(int u : edges[node])
        if(u != parent[node])
        {
            parent[u] = node;
            depth[u] = depth[node] + 1;
            dfs(u);
            mxd[node] = max(mxd[node], mxd[u] + 1);
        }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    for(int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    depth[b] = 1;
    dfs(b);
    int ans = 0;
    for(int i = a; i != n; i = parent[i])
    {
        int dista, distb;
        dista = depth[a] - depth[i];
        distb = depth[i] - depth[b];
        if(distb <= dista)
            break;
        int lg = 0;
        lg += mxd[i];
        lg += dista;
        lg += depth[a] - depth[b] - dista * 2;
        lg--;
        ans = max(ans, lg);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10752
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder();
        int num = readInt(builder);
        int count = 0;
        for (int i = 0; i < num; i++) {
            if (i % 2 == 0) {
                if (readInt(builder) % 2 == 1) count++;
            } else {
                skip();
            }
        }

        System.out.print(count);
    }

    private static int readInt(StringBuilder builder) {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }

        return Integer.parseInt(builder.toString());
    }


    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }
}


Measured memory_bytes: 32292
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String s=sc.next(); //入力された文字列
		String test="CODEFESTIVAL2016";
		int num=0;	//書き換えるかい回数
		
		//1文字ずつ一致しているか確認
		for(int i=0;i<s.length();i++)
		{
			char s_c=s.charAt(i);
			if(!(s_c==test.charAt(i))) num++;
		}

		//一致していない回数(=書き換える回数)を出力
		System.out.println(num);
	}
} 

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 998244353;
const int M = 100+50;
int main(){
	int n,m,h;
	cin>>n>>m>>h;
	int a[25][105],b[105];
	for(int i=0;i<m;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
	    for(int j=0;j<m;j++)
	        cin>>a[i][j];
	int ans=0;
	for(int i=0;i<n;i++){
		int sum=0;
		for(int j=0;j<m;j++)
			sum+=a[i][j]*b[j];
		if(sum+h>0)
			ans++;
	}
	cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

drinks = []

for _ in range(n):
    a, b = map(int, input().split())
    drinks += [[a, b]]

drinks.sort()

ans = 0

for drink in drinks:
    if m <= 0:
        break

    ans += min(m, drink[1]) * drink[0]
    m -= drink[1]

print(ans)

Measured memory_bytes: 20000
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>
#define N 12
using namespace std;

int c[N], a[N][N];
int v[N];

int main(void)
{
    int n, m, k;
    int i, j, s, o;

    cin >> n >> m >> k;
    for(i = 0; i < n; i ++)
    {
        cin >> c[i];
        for(j = 0; j < m; j ++)
            cin >> a[i][j];
    }

    for(s = 0, o = INT_MAX; s < (1 << n); s ++)
    {
        for(i = 0; i < m; i ++)
            v[i] = 0;
        for(i = 0; i < n; i ++)
            if(s >> i & 1)
                for(j = 0; j < m; j ++)
                    v[j] += a[i][j];
        for(i = 0; i < m; i ++)
            if(v[i] < k)
                break;
        if(i == m)
        {
            for(i = j = 0; i < n; i ++)
                if(s >> i & 1)
                    j += c[i];
            o = min(o, j);
        }
    }
    cout << (o == INT_MAX ? -1 : o) << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int n;
int flag[10] = {0};
string s;
int ans = 0;

bool check(){
    bool ret = true;
    rep(i, 3)   if(!flag[3+i*2]) ret = false;
    return ret;
}

void dfs(){
    if(s.size() != 0){
        if(stol(s) > n) return;
    }
    if(check()) ans++;
    for(int i = 3; i <= 7; i+=2){
        s += to_string(i);
        flag[i]++;
        dfs();
        flag[i]--;
        s.pop_back();
    }
}

int main(){
    cin>>n;
    dfs();
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define inf 1e18
#define rep(x, s, t) for(int (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(int (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<int, int> P;

int n;
string s;
int beki[15];
int carry[200005];
int dest[600005], ndest[600005];
bitset<600005> bs[3];
int pt[3];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	
	beki[0] = 1;
	for(int i = 1; i < 15; i++) beki[i] = beki[i-1] * 3;
	
	for(int i = 0; i < 3; i++){
		int p = i;
		for(int j = 0; j < s.size(); j++){
			if(s[j] == 'R'){
				if(p == 2) carry[j] = i;
				p = (p+1) % 3;
			}
			else p = (3-p)%3;
		}
		dest[i] = p;
	}
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < beki[i+1]; k++) bs[j][k] = false;
			for(int k = 0; k < beki[i]; k++) bs[j][j*beki[i]+k] = true;
		}
		for(int j = 0; j < 3; j++) pt[j] = j;
		for(int j = 0; j < s.size(); j++){
			if(s[j] == 'S') swap(pt[1], pt[2]);
			else{
				int tmp[3];
				for(int k = 0; k < 3; k++){
					for(int l = 0; l < 3; l++){
						int x = l*beki[i]+carry[j];
						if(bs[pt[k]][x]){
							tmp[k] = x;
							if(k == 2) carry[j] = x;
							break;
						}
					}
				}
				for(int k = 0; k < 3; k++){
					bs[pt[k]][tmp[k]] = false;
					bs[pt[(k+1)%3]][tmp[k]] = true;
				}
			}
		}
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < beki[i+1]; k++){
				if(bs[pt[j]][k]) ndest[k] = dest[k%beki[i]] + j*beki[i];
			}
		}
		for(int j = 0; j < beki[i+1]; j++) dest[j] = ndest[j];
	}
	
	for(int i = 0; i < beki[n]; i++) cout << dest[i] << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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 main() {
    ll n, m, c;
    cin >> n >> m >> c;
    vector<ll> b(m);
    rep(i, 0, m) cin >> b[i];

    ll ans = 0;
    rep(i, 0, n) {
        ll tmp = c;
        rep(j, 0, m) {
            ll a;
            cin >> a;
            tmp += a * b[j];
        }
        if (tmp > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(int i=0; i<n;i++)
#define fr1(i, n) for(int i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define nl "\n"
 
void file(){
	readf("in.txt");
    writef("out.txt");
}
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;

 
int main()
{
	//file();
 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
	int n, ans = 0, x, a[100005], dp[100005];

	cin>>n;

	fr(i,n)
		cin>>a[i];
    
    dp[0] = 0;

    dp[1] = abs(a[1]-a[0]);
 	for(int 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]<<nl;

    return 0;
 
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
ansl = 0
ansr = 10**5
for i in range(m):
  l,r = map(int,input().split())
  if l > ansr or r < ansl:
    print(0)
    break
  if ansl < l:
    ansl = l
  if ansr > r:
    ansr = r
else:
  if ansr < ansl:
    print(0)
  elif ansr >= ansl:
    print(ansr-ansl+1)

Measured memory_bytes: 43496
w=int(raw_input())
n=int(raw_input())

ret=range(1,w+1)

for i in range(0,n):
    ab = map(int,raw_input().split(","))
    tmp = ret[ab[0]-1]
    ret[ab[0]-1] = ret[ab[1]-1]
    ret[ab[1]-1] = tmp

for i in ret:
    print i

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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 4e5+5;
const ll mod = 1e9+7;




int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    string s, s1, s2;

    cin >> p >> n;
    for1(i, n) {
        scl1(x);
        sum += x;
    }

    if(sum >= p) puts("Yes");
    else puts("No");

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <deque>
#include <numeric>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::deque<int> V(N);
  for (auto& vi: V) scanf("%d", &vi);

  std::vector<std::vector<int>> left(N+1), right(N+1);
  // O(N^2 log N)
  for (size_t i = 1; i <= N; ++i) {
    left[i] = left[i-1];
    left[i].push_back(V[i-1]);
    std::sort(left[i].begin(), left[i].end());
  }
  for (size_t i = 1; i <= N; ++i) {
    right[i] = right[i-1];
    right[i].push_back(V[N-i]);
    std::sort(right[i].begin(), right[i].end());
  }

  int res = 0;
  for (size_t i = 0; i <= N; ++i)
    for (size_t j = 0; j <= N; ++j) {
      if (i + j > K) break;
      if (i + j > N) break;
      std::vector<int> cur = left[i];
      cur.insert(cur.end(), right[j].begin(), right[j].end());
      std::sort(cur.rbegin(), cur.rend());
      size_t k = K - (i+j);
      int cur_v = std::accumulate(cur.begin(), cur.end(), 0);
      for (size_t i = 0; i < k; ++i) {
        if (cur.empty()) break;
        if (cur.back() >= 0) break;
        cur_v -= cur.back();
        cur.pop_back();
      }
      res = std::max(res, cur_v);
    }
  printf("%d\n", res);
}


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

int n;
vector<int> adjl[105];
vector<pair<int,int> > edgelist;
int dist[105];

pair<int,int> furthest(int node, int parent){
    pair<int,int> ans = {0,node};
    for (int x : adjl[node]){
        if (x==parent) continue;
        auto thing = furthest(x,node);
        ans = max(ans,{thing.first+1,thing.second});
    }
    return ans;
}

void dfs(int node, int parent){
    for (int x : adjl[node]){
        if (x==parent) continue;
        if (dist[x]==-1 || dist[x]>dist[node]+1){
            dist[x] = dist[node]+1;
            dfs(x,node);
        }

    }
}

int main(){
    scanf("%d",&n);
    for (int x = 0; x<n-1; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjl[a].push_back(b);
        adjl[b].push_back(a);
        edgelist.push_back({a,b});
    }

    int far = furthest(1,-1).second;
    auto diam = furthest(far,-1);

    printf("%d ",diam.first/2+1);


    long long ans = LLONG_MAX;
    for (int x = 1; x<=n; x++){
        auto res = furthest(x,-1);
        if (res.first<=diam.first/2){
            for (int y = 1; y<=n; y++){
                dist[y] = -1;
            }
            dist[x] = 0;
            dfs(x,-1);


            long long cur = 1;
            for (int y = diam.first/2-1; y>0; y--){
                int mult = 0;
                for (int z = 1; z<=n; z++){
                    if (dist[z]==y){
                        mult = max(mult,(int)adjl[z].size()-1);
                    }
                }
                long long temp = cur*mult;
                if (temp/cur!=mult){
                    cur = LLONG_MAX;
                    break;
                }
                cur = temp;
            }
            if (cur==LLONG_MAX) continue;
            cur *= adjl[x].size();
            ans = min(ans,cur);
        }
    }

    for (auto x : edgelist){
        auto dist1 = furthest(x.first,-1);
        auto dist2 = furthest(x.second,-1);
        if (dist1.first<=diam.first/2+1 && dist2.first<=diam.first/2+1){
            for (int y = 1; y<=n; y++){
                dist[y] = -1;
            }
            dist[x.first] = 0;
            dist[x.second] = 0;
            dfs(x.first,-1);
            dfs(x.second,-1);


            long long cur = 1;
            for (int y = diam.first/2; y>=0; y--){
                int mult = 1;
                for (int z = 1; z<=n; z++){
                    if (dist[z]==y){
                        mult = max(mult,(int)adjl[z].size()-1);
                    }
                }
                long long temp = cur*mult;
                if (temp/cur!=mult){
                    cur = LLONG_MAX;
                    break;
                }
                cur = temp;

            }
            if (cur==LLONG_MAX) continue;
            cur *= 2;
            ans = min(ans,cur);
        }
    }

    printf("%lld",ans);
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let t: String = sc.read();
    let mut t = to_chars(t);
    t[3] = '8';
    for c in t {
        print!("{}", c);
    }
    println!("");
}

Measured memory_bytes: 4352
#include<stdio.h>
int d1,d2,n,f[2001][2001],a=0,now=0;

void color(int x){
	if(x%2==1){
		for(int i=0;i<n<<1;++i){
			for(int j=0;j<n<<1;++j){
				if(((i>>now)+(j>>now))%2)f[i][j]=1;
			}
		}
	}else if(x%4==2){
		for(int i=0;i<n<<1;++i){
			for(int j=0;j<n<<1;++j){
				if((i>>now)%2)f[i][j]=1;
			}
		}
	}else{ 
		++now;
		color(x/4);
	}
}

int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	color(d1);
	now=0;
	color(d2);
	for(int i=0;i<n<<1;++i){
		for(int j=0;j<n<<1;++j){
			if(f[i][j]==0){
				printf("%d %d\n",i,j);
				if(++a==n*n)return 0;
			}
		}
	}
}


Measured memory_bytes: 6528
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b, x;
    cin >> a >> b >> x;
    cout << (x >= a and x <= a+b ? "YES" : "NO") << "\n";
    
    return 0;
}

Measured memory_bytes: 256