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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	ll p[a], q[b], r[c];
	pair<ll, ll> z[a + b + c];
	for (ll i = 0; i < a; i++) {
	    cin >> p[i];
	    z[i] = mp(p[i], 0);
	}
	sort(p, p + a, greater<ll>());
	for (ll i = 0; i < b; i++) {
	    cin >> q[i];
	    z[i + a] = mp(q[i], 1);
	}
	sort(q, q + b, greater<ll>());
	for (ll i = 0; i < c; i++) {
	    cin >> r[i];
	    z[i + a + b] = mp(r[i], 2);
	}
	sort(r, r + c, greater<ll>());
	ll s1[a] = {0}, s2[b] = {0}, s3[c] = {0};
	for (ll i = 0; i < a; i++) {
	    s1[i] = (i == 0 ? p[i] : s1[i - 1] + p[i]);
	}
	for (ll i = 0; i < b; i++) {
	    s2[i] = (i == 0 ? q[i] : s2[i - 1] + q[i]);
	}
	for (ll i = 0; i < c; i++) {
	    s3[i] = (i == 0 ? r[i] : s3[i - 1] + r[i]);
	}
	sort(z, z + a + b + c, greater<pair<ll, ll>>());
	ll cnt[3] = {0};
	for (ll i = 0; i < a + b + c; i++) {
	    cnt[z[i].se]++;
	    if (min(x, cnt[0]) + min(y, cnt[1]) + cnt[2] == x + y) break;
	}
	ll mx = 0;
	for (ll i = 0; i <= cnt[2]; i++) {
		if (cnt[2] == 0) {
			mx = s1[x - 1] + s2[y - 1];
			break;
		}
		ll g, h;
	    if (x - i - 1 < -1 || x - i - 1 > a - 1) continue;
		else if (x == i) g = 0;
		else g = s1[x - i - 1];
	    if (y - cnt[2] + i - 1 < -1 || y - cnt[2] + i - 1 > b - 1) continue;
		else if (y - cnt[2] + i - 1 == -1) h = 0;
		else h = s2[y - cnt[2] + i - 1];
	    ll temp = g + h + s3[cnt[2] - 1]; 
	    mx = max(mx, temp);
	}
	cout << mx << "\n";
 	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("take.in","r",stdin);
    //    freopen("give.out","w",stdout);
    //#endif
    ios_base::sync_with_stdio(false);
    int r,c,n;
    cin>>r>>c>>n;
    //vector<pair<int,pair<int,int>>>a;
    vector<pair<pair<int,int>,int>>a0,bn,na,b0;
    for(int i=1;i<=n;i++)
    {
        int x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        if(((x1==0 or x1==r) or (y1==0 or y1==c)) and ((x2==0 or x2==r) or (y2==0 or y2==c)))
        {
            //a.push_back(make_pair(i,make_pair(x1,y1)));
            //a.push_back(make_pair(i,make_pair(x2,y2)));
            if(x1==0)
            {
                //cout<<1;
                a0.push_back(make_pair(make_pair(x1,y1),i));
            }
            else if(y1==c)
            {
                //cout<<2;
                bn.push_back(make_pair(make_pair(x1,y1),i));
            }
            else if(x1==r)
            {
                //cout<<3;
                na.push_back(make_pair(make_pair(x1,y1),i));
            }
            else if(y1==0)
            {
                //cout<<4;
                b0.push_back(make_pair(make_pair(x1,y1),i));
            }

            //yoyo
            //cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;

            if(x2==0)
            {
                //cout<<1;
                a0.push_back(make_pair(make_pair(x2,y2),i));
            }
            else if(y2==c)
            {
                //cout<<2;
                bn.push_back(make_pair(make_pair(x2,y2),i));
            }
            else if(x2==r)
            {
                //cout<<3;
                na.push_back(make_pair(make_pair(x2,y2),i));
            }
            else if(y2==0)
            {
                //cout<<4;
                b0.push_back(make_pair(make_pair(x2,y2),i));
            }
        }
    }
    sort(a0.begin(),a0.end());
    sort(na.begin(),na.end());
    sort(bn.begin(),bn.end());
    sort(b0.begin(),b0.end());
    vector<int>a;
    for(int i=0;i<a0.size();i++)
    {
        a.push_back(a0[i].second);
    }
    for(int i=0;i<bn.size();i++)
    {
        a.push_back(bn[i].second);
    }
    for(int i=na.size()-1;i>=0;i--)
    {
        a.push_back(na[i].second);
    }
    for(int i=b0.size()-1;i>=0;i--)
    {
        a.push_back(b0[i].second);
    }


    stack<int>s;
    for(int i=0;i<a.size();i++)
    {
        if(!s.empty() and s.top()==a[i])
        {
            s.pop();
        }
        else
        {
            s.push(a[i]);
        }
    }

    if(s.empty()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 4712
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vi A(N), B(N);
  cin >> A;
  int X = 0;
  rep(i, 0, N) X ^= A[i];
  rep(i, 0, N / 2) {
    int x = i * 2;
    int y = i * 2 + 1;
    B[x] = A[x] ^ X;
    B[y] = A[x] ^ A[y] ^ B[x];
  }
  {
    int Y = 0;
    rep(i, 0, N) Y ^= B[i];
    assert(X == Y);
    rep(i, 0, N) { assert(A[i] == X ^ B[i]); }
  }
  cout << B << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 6336
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<set>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define mp make_pair
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
void outn(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(10);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
//const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll quickpow(ll x, ll k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}

const int maxn = 1e5 + 5;
int par[maxn], r[maxn];
int findp(int x)
{
    if (par[x] < 0) return x;
    else{
        int fx = findp(par[x]);
        r[x] = (r[x] + r[par[x]]) % 2;
        par[x] = fx;
    }
}
void unite(int x, int y)
{
    int fx = findp(x), fy = findp(y);
    if (fx != fy){
        r[x] = (r[x] - r[y] + 1) % 2;
        par[fy] = fx;
    }
}
bool same(int x, int y){return findp(x) == findp(y);}

int main()
{
    int x;
    cin >> x;
    cout << x * (x + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A1 = [int(i) for i in input().split(" ")]
A2 = [int(i) for i in input().split(" ")]
ans = [0 for i in range(N)]         
for i in range(N):
  ans[i] += sum(A1[0:i+1])
  ans[i] += sum(A2[i:N+1])
print(max(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair 
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll sum = 0;
int md(int n){
	if(n>0)return n;
	else return -n;
}
string str,str2;
void solve(){
	ll n;cin>>n;
	cin>>str;
	ll ans=0;int k=n-1;
	fori(n){
		if(str[i]=='R')continue;
		int j;
		for(j=k;j>=i;j--){
			if(str[j]=='R')break;
		}
		if(j<=i)break;
		else ans++;
		k=j-1;
	}
	cout<<ans;
}


int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
     cin.tie(0);
    ios::sync_with_stdio(false);
   
	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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



int main() {
	ll N, M, X;
	cin >> N >> M >> X;
	vector<ll> C(N);
	vector<vector<ll>> A(N, vector<ll>(M + 1, 0));

	rep(i, N) {
		cin >> C[i];
		repn(j, M) cin >> A[i][j];
	}

	ll ans = INF;
	rep(k, 1 << N) {
		ll cost = 0;
		vector<ll> rikai(M + 1, 0);
		
		rep(i, N) {
			if ((k >> i) % 2 == 0) { continue; }
			cost += C[i];
			repn(j, M) rikai[j] += A[i][j];
		}

		ll b = 1;
		repn(j, M) if (rikai[j] < X) { b = 0; }

		if (b == 1) { ans = min(ans, cost); }
	}

	if (ans == INF) { ans = -1; }
	cout << ans << endl;

	system("PAUSE");

}

Measured memory_bytes: 3640
l=int(input())
for i in range(21):
  if 2 ** i > l:
    n = i
    break

m = (n - 1) * 2
  
s = l -  2 ** (n - 1)
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(n - 1):
  if s >= 2 ** (n - 2 - i) :
    s -= 2 ** (n - 2 - i)
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)
  
#print(path_add)
#print(path_add_value)
#print(s)  
  
print(n, m + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  
for i in range(n - 1):
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i]) 
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int i=1;
  while(i*i<=n) i++;
  cout<<(i-1)*(i-1)<<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
) 

func main() {
  var d, n int
  fmt.Scan(&d, &n)
  
  result := 1
  for i := 0; i < d; i++ {
    result *= 100
  }
  if n==100{
    n++
  }
  fmt.Println(result * n)
}

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

int main(){
    int n;
    cin >> n;
    if(n<=104){
        cout << "0";
    }else if(105<=n&&n<=134){
        cout << "1";
    }else if(135<=n&&n<=164){
        cout << "2";
    }else if(165<=n&&n<=188){
        cout << "3";
    }else if(189<=n&&n<=194){
        cout << "4";
    }else if(195<=n&&n<=200){
        cout << "5";
    }
}

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

a_L.append(-99)
tmp_num = -1
result_L = []
counter = 0

for val in range(len(a_L)):
    #print(tmp_num,a_L[val])

    if tmp_num == a_L[val]:
        counter += 1
    if tmp_num != a_L[val] and counter != 0:
        counter +=1
        result_L.append(counter)
        #print("a",tmp_num,a_L[val],counter)
        counter = 0

    tmp_num = a_L[val]


result_L = [i//2 for i in result_L]


print(sum(result_L))


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){

  vector<int> x,y;
  int n;
  int temp;
  double p1 = 0;
  double p2 = 0;
  double p3 = 0;
  double p4 = 0;

  cin >> n;
  for( int i = 0; i < n; ++i){
    cin >> temp;
    x.push_back(temp);
  }
  for( int i = 0; i < n; ++i){
    cin >> temp;
    y.push_back(temp);
  }
    
  for( int i = 0; i < n; ++i){
    p1 += abs(x[i]-y[i]);
    p2 += (x[i]-y[i])*(x[i]-y[i]);
    p3 += fabs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
    if( p4 < abs(x[i]-y[i]) ){
      p4 = abs(x[i]-y[i]);
    }
  }

  p2 = sqrt(p2);
  p3 = cbrt(p3);

  cout << fixed << setprecision(5) << p1 << endl << p2 << endl << p3 << endl << p4 << endl;
  return 0;
  
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<vector<int>>xy(n,vector<int>(15,-1));

    rep(i,n){
        int a;
        cin>>a;

        rep(j,a){
            int x,y;
            cin>>x>>y;

            x--;

            xy[i][x]=y;
        }
    }

    int ans=0;

    rep(bit,1<<n){
        bool jdg=true;
        int cnt=0;

        rep(i,n){
            if(bit&(1<<i)){
                cnt++;
                rep(j,xy[i].size()){
                    if(xy[i][j]==1){
                        if(!(bit&(1<<j))){
                            jdg=false;
                        }
                    }
                    else if(xy[i][j]==0){
                        if(bit&(1<<j)){
                            jdg=false;
                        }
                    }
                }
            }
        }

        if(jdg)ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main() {
  int h,w;
  cin >> h >> w;
  int ch,cw;
  cin >> ch >> cw;
  ch--;cw--;
  int dh, dw;
  cin >> dh >> dw;
  dh--;dw--;
  char s[h][w];
  rep(i,h){
    rep(j,w)cin >> s[i][j];
  }

  int ans = -1;
  int visited[h][w];
  memset(visited, -1, sizeof(visited));

  queue<int> qh;
  queue<int> qw;
  queue<int> cost;


  qh.push(ch);
  qw.push(cw);
  cost.push(0);

  queue<int> qh2;
  queue<int> qw2;
  queue<int> cost2;

  while(!qh.empty()){
    while(!qh.empty()){
      int nowh = qh.front();
      qh.pop();
      int noww = qw.front();
      qw.pop();
      int nowc = cost.front();
      cost.pop();
      
      if(nowh == dh and noww == dw){
        ans = nowc;
        cout << ans << endl;
        return 0;
      }
      if(visited[nowh][noww] != -1)continue;

      qh2.push(nowh);
      qw2.push(noww);
      cost2.push(nowc);

      for(int i = -1;i <=1;i++){
        for(int j= -1;j <= 1;j++){
          if((i == 0 or j == 0) and (0 <= nowh + i and nowh + i < h) and (0 <= noww + j and noww + j < w)){
            if(s[nowh+i][noww+j] == '.'){
              qh.push(nowh+i);
              qw.push(noww+j);
              cost.push(nowc);
            }
          }
        }
      }
      visited[nowh][noww] = nowc;
    }


    while(!qh2.empty()){
      int nowh = qh2.front();
      qh2.pop();
      int noww = qw2.front();
      qw2.pop();
      int nowc = cost2.front();
      cost2.pop();

      for(int i = -2;i <=2;i++){
        for(int j= -2;j <=2;j++){
          if((0 <= nowh + i and nowh + i < h) and (0 <= noww + j and noww + j < w)){
            if(s[nowh+i][noww+j] == '.' and visited[nowh+i][noww+j] == -1){
              qh.push(nowh+i);
              qw.push(noww+j);
              cost.push(nowc+1);
            }
          }
        }
      }      
    } 
  }
  cout << ans << endl;
} 

Measured memory_bytes: 8668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n, k;
  cin >> n >> k;
  cout << (n%k == 0 ? 0 : 1) << endl;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [tuple(map(int, input().split())) for i in range(M)]

l = 1
r = N
for i in range(M):
    l = max(l, LR[i][0])
    r = min(r, LR[i][1])

ans = max(0, r - l + 1)
print(ans)


Measured memory_bytes: 16620
import java.util.Scanner;
import java.io.PrintWriter;

class Main {
    static int cheaper(int n, int a, int b) {
        int train = n * a;
        if ( train < b ) {
            return train;
        }
        return b;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        out.println(cheaper(n, a, b));
        out.flush();
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,a,n) for(int i=a;i<n;i++)

int main(){
	int n,a=0,b=0;
	char s[110],t[110];
	scanf("%d",&n);
	rep(i,0,n){
		scanf("%s %s",s,t);
		if(strcmp(s,t)>0) a+=3;
		else if(strcmp(s,t)<0) b+=3;
		else{
			a++; b++;
		}
	}
	printf("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 1032
# -*- coding: utf-8 -*-
#input number
num = int(input())
str = input()
#change to list distinguished by space
str_list = str.split()
#change list all item to "int"
list_up = list( map((lambda x:int(x)),str_list))

#arrange number from high number to low number
list_up.sort(reverse=True)
sum = 0
for (i, v) in enumerate(list_up):
  if(i % 2 == 0):
    sum += int(v)
  elif(i % 2 == 1):
    sum -= int(v)
print(sum)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
void init(int n){
   par.resize(n);
   depth.resize(n,0);
   rep(i,n) par[i]=i;
}

int find(int n){
   if(par[n]==n) return n;
   return par[n]=find(par[n]);
}

void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(par[x]==par[y]) return;
   if(depth[x]<depth[y]) par[x]=par[y];
   else{
      par[y]=par[x];
   if(depth[x]==depth[y]) depth[x] ++;
   }
}

bool same(int x,int y){
   return find(x)==find(y);
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k,l;
    cin>>n>>k>>l;
    init(n);
    int p,q;
    rep(i,k){
       cin>>p>>q;
       p --;
       q --;
       unite(p,q);
    }
    vector<P> x(n);
    rep(i,n) x[i].first=find(i);
    init(n);
    rep(i,l){
       cin>>p>>q;
       p --;
       q --;
       unite(p,q);
    }
    rep(i,n) x[i].second=find(i);
    map<P,int> z;
    rep(i,n){
      if(!z.count(x[i])) z[x[i]]=1;
      else z[x[i]] ++;
    }
    rep(i,n) cout<<z[x[i]]<<" ";

}

Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
const int MAX_H = 101;

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  set<int> water, sugar;
  for(int i = 0; i <= 30; ++i) {
    for(int j = 0; j <= 30; ++j) {
      int amount = 100 * a * i + 100 * b * j;
      if(amount <= f) water.insert(amount);
    }
  }

  for (int i = 0; i <= 3000; ++i) {
    for(int j = 0; j <= 3000; ++j) {
      int amount = i * c + j * d;
      if(amount <= f) sugar.insert(amount);
    }
  }
  pair<int, int> ans;
  ans.first = a * 100;
  double maxper = 0;
  for (int w : water) {
    for (int s : sugar) {
      int sw = w + s;
      if(0 < sw && sw <= f) {
        if(s > (w / 100) * e) continue;
        double per = double(s) / sw;
        if(per > maxper) {
          maxper = per;
          ans.first = sw;
          ans.second = s;
        }
      }
    }
  }

  cout << ans.first << " " << ans.second << endl;;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {    
  public static void main(String[] args) {
   
      Scanner sc = new Scanner(System.in);      
     
      String s = sc.next();
      
      for(int i = 0;i < s.length();i+=2){
          System.out.print(s.charAt(i));
      }     
      
      System.out.println();
      
  }                
}

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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    vector<int> p(n), q(n);
    vector<int> orig(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        orig[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }

    int a, b;
    int i = 0;

    do {
        if (orig == p) {
            a = i;
        }
        if (orig == q) {
            b = i;
        }
        i++;
    } while (next_permutation(orig.begin(), orig.end()));

    cout << abs(a - b) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
	string s;cin>>s;
	for(int i = a - 1; i < max(d,c) - 1; i++) {
		if(s[i - 1] == '#' && s[i] == '#'){
			cout << "No" << endl;
			return 0;
		}
	}
	if (c > d){
		bool flag = false;
	for(int i = b - 1; i < d; i++) {
		if(s[i] == '.' && s[i] == s[i + 1] && s[i] == s[i - 1]){
			flag = true;
		}
	}
	if(!flag){
		cout << "No" << endl;
		return 0;
	}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;



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

            String s;
            int a , b ,temp;
            int r = 0;
            while((s = br.readLine())!=null)
            {
            StringTokenizer st = new StringTokenizer(s," ");
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
        
            	if(a<b)
            	{
            		temp = a;
            		a = b;
            		b = temp;
            	}
            
            	while(b!=0)
            	{
            		r = a%b;
            		a = b;
            		b = r;
            		
            	}
            	System.out.println(a);
            	
            }
    	}catch (Exception e) {
            e.printStackTrace();
        }
       
    }
   

}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  int64_t ans = 0;
  for (int i = k; i < n; ++i) ans += h[i];
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll L[87];
    int n;
    cin >> n;
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= n; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    cout << (a % k == 0 or b % k == 0 or (b / k) - (a / k) >= 1 ? "OK" : "NG") << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a = n%10;
    if(a == 3){
        cout << "bon" << endl;
    }
    else if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i< N; i++) cin >> a.at(i);
  
  int ave = 0;

  for(int i = 0; i< N; i++){
    ave += a.at(i); 
  }
  
  int ans = 0;
  int minv = abs(a.at(0)*N - ave);
  for(int i = 1; i< N; i++){
    if (minv > abs(a.at(i)*N - ave)){
      minv = abs(a.at(i)*N - ave);
      ans = i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1	 : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]

NNN = (10**6)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
N, K = map(int, input().split())

r = 0
for i in range(K, N+2):
    s = ((i-1) * i) //2
    s %= mod
    e = N*(N+1)//2
    e -= ((N-i)*(N-i+1)) //2
    e %= mod
    r = (r + e-s+1) % mod
print(r)



Measured memory_bytes: 168064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c-a-b;

    ATYN(d > 0 && d*d - 4*a*b > 0)
    return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  int a[100005];
  for (int i=0; i<n; i++) {
    scanf("%d",a+i);
  }
  for (int i=0; i<n; i++) {
    if (a[i]==k) {
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  bool flag=false;
  for (int i=0; i<n; i++) {
    if (a[i]>k)
      flag=true;
  }
  if (!flag) {
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  int g=a[0];
  for (int i=1; i<n; i++) {
    g=__gcd(g,a[i]);
  }
  if (k%g)
    cout<<"IMPOSSIBLE"<<endl;
  else
    cout<<"POSSIBLE"<<endl;
  return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

vint primeSieve(int n)
{
    vint ret;
    ret.reserve(n);
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            ret.pb(i);
            for (int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return ret;
}

void Main()
{
    int x = in();
    auto v = primeSieve(110000);
    for (auto c : v)
    {
        if (c >= x)
        {
            cout << c << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h,w,k;
    cin>>h>>w>>k;
    string c0[h];
    rep(0,i,h){
        cin>>c0[i];
    }
    ll c=0;
    rep(0,i,h){
        rep(0,j,w){
            if(c0[i][j]=='#')++c;
        }
    }
    ll ans=0;
    rep(0,bit1,(1<<h)){
        rep(0,bit2,(1<<w)){
            ll nc=0;
            rep(0,i,h){
                if(bit1&(1<<i))rep(0,j,w){
                    if(c0[i][j]=='#')++nc;
                }
            }
            rep(0,i,h){
                rep(0,j,w){
                    if(!(bit1&(1<<i))&&(bit2&(1<<j))&&c0[i][j]=='#')++nc;
                }
            }
            if(c-nc==k)++ans;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n-1) cin >> b[i];
    int ans = b[0]+b[n-2];
    rep(i,n-2) {
        ans += min(b[i],b[i+1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	ll a,b;cin>>a>>b;
	for(int i=1;i<=999;i++){{
			int c=(i+1)*i/2,d=(i+2)*(i+1)/2;
			if(d-c==b-a&&a<c&&b<d){
				cout<<d-b<<endl;
				return 0;
			}
		}
	}
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i,N) cin >> A[i];
  for(int i=0; i<M; i++) {
    N -= A[i];
    if(N<0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << N << endl;
}

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

using namespace std;

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

	long long int a,b;

	cin >> a >> b;

	if(a<=0 && b>=0)
	{
		cout << "Zero" << '\n';
	}
	else if(b<0)
	{
		long long int d = abs(a-b) + 1;
		if(d%2==1)
		{
			cout << "Negative" << '\n';
		}
		else
		{
			cout << "Positive" << '\n';
		}
	}
	else
	{
		cout << "Positive" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=1e5+5;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
int main()
{
    std::ios::sync_with_stdio(false);
    char s[N];
    while(cin>>s)
    {
        int l=strlen(s),flag=0;
        for(int i=0; i<l; i++)
        {
            if(s[i]=='d')
            {
                if(i+6<l&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'
                        &&s[i+6]=='r'&&s[i+7]!='a')
                {
                    i+=6;
                }
                else if(i+6<l&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'
                        &&s[i+6]=='r'&&s[i+7]=='a')
                {
                    i+=4;
                }
                else if(i+4<l&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')
                {
                    i+=4;
                }
                else
                {
                    flag=1;
                    break;
                }
            }
            else if(s[i]=='e')
            {
                if(i+5<l&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')
                {
                    i+=5;
                }
                else if(i+4<l&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')
                {
                    i+=4;
                }
                else
                {
                    flag=1;
                    break;
                }
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(flag)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
s = input()
s = s.translate(str.maketrans({'T': 'A', 'G': 'A', 'C': 'A'}))
s = list(s)+['END']

if s[0] == 'A':
    counter = 1
else:
    counter = 0

ans = 0

for i in range(len(s)):
    if s[i - 1] == s[i] == 'A':
        counter += 1
    else:
        if ans < counter:
            ans = counter
        if s[i] == 'A':
            counter = 1
        else:
            counter = 0
print(ans)


Measured memory_bytes: 3064
H, W = map(int, raw_input().split())
def calc(h, w):
    best = h*w
    for h1 in range(1, h):
        s1 = h1 * w
        s2 = (h - h1) * (w/2)
        s3 = h * w - s1 - s2
        best = min(best, max([s1, s2, s3]) - min([s1, s2, s3]))
        s2 = ((h - h1)/2) * w
        s3 = h * w - s1 - s2
        best = min(best, max([s1, s2, s3]) - min([s1, s2, s3]))
    return best
print min(calc(H, W), calc(W, H))

Measured memory_bytes: 5764
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, c, d, e, f, l, r;
    double mi = 0.0;
    l = r = 0;
    cin >> a >> b >> c >> d >> e >> f;
    for (int i = 0; i*100*a <= f; i++)
        for (int j = 0; i*100*a+j*100*b <= f; j++)
            for (int x = 0; i*100*a+j*100*b+x*c <= f; x++)
                for (int w = 0; i*100*a+j*100*b+x*c+w*d <= f; w++)
                    if ((x*c+w*d) <= (i*a+j*b)*e)
                        if ((double)(x*c+w*d)/(i*100*a+j*100*b+x*c+w*d) >= mi) {
                            r = x*c+w*d, l = i*100*a+j*100*b;
                            mi = (double)r/(l+r);
                        }
    cout << l+r << " " << r << endl;
    return 0;
}

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

int main()
{
    string Sd, T;
    cin >> Sd;
    cin >> T;
    string S = Sd;
    bool usd = false;
    //Sd.size() < T.size() のとき、.size()は符号なしのsize_tなので
    //Sd.size() - T.size()は負の数にならないことに注意
    for(int i = 0; i <= (int)Sd.size() - (int)T.size(); ++i) {
        bool flg = true;
        for(int j = 0; j < T.size(); ++j)
            if(Sd[i+j] != '?' && Sd[i+j] != T[j]) { 
                flg = false; break; 
            }

        if(flg) {
            string stmp = Sd;
            for(int j = 0; j < T.size(); ++j) stmp[i+j] = T[j];
            for(int j = 0; j < stmp.size(); ++j)
                if(stmp[j] == '?') stmp[j] = 'a';
            
            if(!usd) { S = stmp; usd = true; }
            else { if(S > stmp) S = stmp; }
        }
    }

    if(usd) cout << S << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}

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

unsigned long long int fact(int n,unsigned long long int s){
	if(n == 0){
		return 1;
	}else if(n == 1){
		return s;
	}else{
		return fact(n-1,n*s);
	}
}

int main(){
	int n;
	cin >> n;
	cout << fact(n,1) << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

    
int main(){
    int count = 0;
    int N;
    scanf("%d",&N);
    int data[200002];
    int max=0,max2=0;
    while(1){
        scanf("%d",&data[count]);
    if(data[count]>max)max = data[count];
    else if(data[count]<=max&&max2<data[count])max2 = data[count];
        count++;
        if(count==N)break;
    }
    for(int i=0;i<N;i++){
        if(data[i]==max)printf("%d\n",max2);
        else printf("%d\n",max);
    }

    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int k,t;
int a[10011];
int s=0;
int ma=-1;
int main()
{
    int i,j;
    
    cin>>k>>t;
    for(i=1;i<=t;i++)
    {
        cin>>a[i];
        s+=a[i];
        ma=max(ma,a[i]);
    }
    
    if(ma<=s-ma+1)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<ma-(s-ma)-1<<endl;
    }
    
    
    return 0;
} 



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

const int Mod = 1e9 + 7; 
const int MAX_N = 1 << 17; 

void pls(int &x, int y) { x += y; if (x >= Mod)  x -= Mod; } 

int bin[18], fac[MAX_N], ifc[MAX_N];
int N, M, ans, f[18][MAX_N], cnt[MAX_N], A[18]; 
inline int C(int n, int m) { 
	if (n < m) return 0; 
	else return 1ll * fac[n] * ifc[m] % Mod * ifc[n - m] % Mod; 
} 
int fpow(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod;
		y >>= 1; 
	} 
	return res; 
} 
 
int main() {
	scanf("%d%d", &N, &M); 
	cnt[0] = bin[0] = fac[0] = ifc[0] = 1; 
	for (int i = 1; i < 18; i++) bin[i] = bin[i - 1] << 1; 
	for (int i = 1; i <= bin[N]; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
	ifc[bin[N]] = fpow(fac[bin[N]], Mod - 2); 
	for (int i = bin[N] - 1; i; i--) ifc[i] = 1ll * ifc[i + 1] * (i + 1) % Mod; 
	for (int i = 1; i <= bin[N]; i++) cnt[i] = (i & 1) ? Mod - cnt[i >> 1] : cnt[i >> 1]; 
	for (int i = 1; i <= M; i++) scanf("%d", A + i); 
	sort(&A[1], &A[M + 1]); 
	f[M + 1][0] = 1; 
	for (int i = M; i; i--) 
		for (int S = 0; S < bin[N]; S++) 
			if (f[i + 1][S]) {
		        pls(f[i][S], f[i + 1][S]);
				int t = (bin[N] - 1) ^ S;
		        for (int j = 0; j < N; j++)
					if (!(S & bin[j]))
		    	        pls(f[i][S | bin[j]], 1ll * C(t - A[i] + 1, bin[j] - 1) * f[i + 1][S] % Mod * fac[bin[j]] % Mod); 
	        } 
	for (int i = 0; i < bin[N]; i++) 
	    pls(ans, 1ll * f[1][i] * fac[bin[N] - 1 - i] % Mod * cnt[i] % Mod); 
	ans = 1ll * ans * bin[N] % Mod; 
	printf("%d\n", ans); 
	return 0;
}

Measured memory_bytes: 9472
N, K, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7

fac = [0] * (N + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, N + 1):
    fac[i] = fac[i - 1] * i % MOD

finv = [0] * (N + 1)
finv[N] = pow(fac[N], MOD - 2, MOD)
for i in reversed(range(1, N + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[k] * finv[n - k] % MOD

ans = 0
for i, a in enumerate(sorted(A, reverse=True)):
    ans += a * comb(N - i - 1, K - 1)
    ans -= a * comb(i, K - 1)
    ans %= MOD
    
print(ans)


Measured memory_bytes: 70636
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int x;
    cin >> x;
    for (int a = 0; a <= 30; a++) {
        for (int b = 0; b <= 30; b++) {
            for (int c = 0; c <= 30; c++) {
                for (int d = 0; d <= 30; d++) {
                    for (int e = 0; e <= 30; e++) {
                        int f = (x - (100 * a + 101 * b + 102 * c + 103 * d + 104 * e)) / 105;
                        if (f >= 0 && f <= 1000000 && 100 * a + 101 * b + 102 * c + 103 * d + 104 * e + 105 * f == x) {
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

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

  auto a = make_vector(N, N, intmax_t(0));
  for (auto& ai: a)
    for (auto& aij: ai)
      scanf("%jd", &aij);

  size_t M = 1 << N;
  size_t S = M-1;
  std::vector<intmax_t> dp(M);
  for (size_t i = 0; i <= S; ++i) {
    intmax_t cur = 0;
    for (size_t j = 0; j < N; ++j)
      for (size_t k = 0; k < j; ++k)
        if ((i >> j & 1) && (i >> k & 1))
          cur += a[j][k];

    dp[i] = std::max(dp[i], cur);
    size_t T = (S ^ i);
    for (size_t j = T; true; (j = (j-1) & T)) {
      dp[i|j] = std::max(dp[i|j], dp[i]+dp[j]);
      if (j == 0) break;
    }
  }

  printf("%jd\n", dp[S]);
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int max_v(vector<int> & v, int idx1) {
	int ans = 0;
	for(int i=0; i<v.size(); i++) {
		if (v[i] > ans and i != idx1) ans = v[i];
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i=0; i<n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> w(n, vector<int>(3, 0)); 
	w[0][0] = a[0];
	w[0][1] = b[0];
	w[0][2] = c[0];

	for(int i=1; i<n; i++) {
		w[i][0] = max_v(w[i-1], 0) + a[i];
		w[i][1] = max_v(w[i-1], 1) + b[i];
		w[i][2] = max_v(w[i-1], 2) + c[i];
	}
	cout << max_v(w[n-1], 7) << endl;
}


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

int main(){
	int n, x, tot = 0;
	map<int, int> m;
	cin >> n; 

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

	for( map<int, int>::iterator it = m.begin(); it != m.end(); ++it )
		if( it->second%2 == 1 ) tot++;
	
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 4864
num=input()
num=int(num)

if num<=111:
    num=111
elif num<=222:
    num=222
elif num<=333:
    num=333
elif num<=444:
    num=444
elif num<=555:
    num=555
elif num<=666:
    num=666
elif num<=777:
    num=777
elif num<=888:
    num=888
else:
    num=999

print(num)

Measured memory_bytes: 38256