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

constexpr size_t maxN = 33;
constexpr int_fast64_t arms[maxN] = {4294967296, 2147483648, 1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int_fast64_t N, p[1010][2], prty;

void tapris(int_fast64_t x, int_fast64_t y, size_t i){
    if(i >= maxN)return;
    assert(abs(x) + abs(y) < 2 * arms[i]);
    assert((x + y) % 2);
    if(x < y){
        if(x + y > 0){
            tapris(x, y - arms[i], i + 1);
            printf("U");
        }else{
            tapris(x + arms[i], y, i + 1);
            printf("L");
        }
    }else{
        if(x + y > 0){
            tapris(x - arms[i], y, i + 1);
            printf("R");
        }else{
            tapris(x, y + arms[i], i + 1);
            printf("D");
        }
    }
}

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", p[i], p[i] + 1);
        if(!i)prty = (1 & (p[i][0] + p[i][1]));
        if(prty != (1 & (p[i][0] + p[i][1])))return 0 & puts("-1");
        if(!prty)--p[i][0];
    }
    puts(prty ? "33" : "34");
    puts("1 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 2147483648 4294967296" + 2 * prty);
    for(int i = 0; i < N; ++i){
        if(!prty)printf("R");
        tapris(p[i][0], p[i][1], 0);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    string s; cin>>s;
    int x = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') x++;
    }
    if(x>n-x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const int MAX = 2000005;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


int main(){
    ll H,W,A,B; cin >> H >> W >> A >> B;


    // (1,1) -> (H-A, j) -> (H-A+1, j) -> (H, W)
    COMinit();
    ll ans = 0;
    for(int j=B+1; j<=W; j++){
        ans += COM(H-A-1 + j-1, j-1)*COM(A-1 + W-j, W-j);
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll used[200005];
char s[305][305];
ll ans=0;
ll v=-1,w;

int main(){
	int n,m;
	int x,y;
	cin>>n>>m;
	int a[55];
	for(i=0;i<=n;i++){
		a[i]=0;
	}
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x]+=1;
		a[y]+=1;
	}
	for(i=1;i<=n;i++){
		pe(a[i]);
	}
	p("");
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define INF 1e9
#define LINF 1e18
#define ld double
#define ll long long
#define ull unsigned long long

namespace io {
	const int SZ = 1 << 13;
	char buff[SZ], *pos = buff + SZ - 1;
	char gc() {
		if (++ pos == buff + SZ) fread(pos = buff, 1, SZ, stdin);
		return *pos;
	}
}

template <typename T>
inline void read(T &x) {
	x = 0; int f = 1, c = io :: gc();
	for (;!isdigit(c);c = io :: gc()) if (c == '-') f = -f;
	for (; isdigit(c);c = io :: gc()) x = (x<<3) + (x<<1) + (c^48);
	x *= f;
}

int main() {
	int a, b, c; read(a); read(b); read(c);
	printf("%d\n", b + min(a + b + 1, c));
	
	return 0;
}


Measured memory_bytes: 256
/* algae.c */
#include<stdio.h>

int main(void)
{
  int i,r,d,x;
  scanf("%d %d %d",&r,&d,&x);
  for(i=0;i<10;i++){
    x=(x*r)-d;
    printf("%d\n",x);
  }
  return 0;
}


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

int main()
{
	long long n, a, b;
	cin >> n >> a >> b;
	long long m = 0;
	m = (n / (a + b));
	n -= m * (a + b);
	long long k;
	k = (n > a ? a : n);
	cout << a * m + k << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int left, right; left = right = 0;
    int tmp = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '(') {
            right++;
        }
        else {
            if (right) {
                right--;
            }
            else left++;
        }
    }
    for (int i = 0; i < left; i++) {
        S = '(' + S;
    }
    for (int i = 0; i < right; i++) {
        S += ')';
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    string res = s;
    if(a < 3200)
    {
        res = "red";
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
for e in iter(input,'0 0'):
 r,_=map(int,e.split())
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=max(c,r-c)
  a=max(a,b)
 print(a)


Measured memory_bytes: 6916
#include <iostream>

using namespace std;

main(){
  int n, p, data[50], wan;
  while(cin >> n >> p && (n|p)){
    for(int i=0;i<50;i++) data[i] = 0;
    wan = p;
    int pos = 0;
    for(;;){
      if(wan){
        if(++data[pos] == p) break;
        wan--;
      }else{
        wan += data[pos];
        data[pos] = 0;
      }
      pos = (pos + 1) % n;
    }
    cout << pos << endl;
  }
}

Measured memory_bytes: 868
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,a=2,b=2,p;
  cin>>N;
  vec v(N);
  brep(i,N)cin>>v[i];
  rep(i,N){
    if(b<v[i]){
      cout<<-1<<endl;
      return 0;
    }
    p=b/v[i]+1;
    b=p*v[i]-1;
    p=(a+v[i]-1)/v[i];
    a=p*v[i];
    if(b<a){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    int n[3];
    inrep(3,n);
    int k;
    cin >> k;
    sort(n,n+3);
    rep(i,0,k)n[2] *= 2;
    P(n[0] + n[1] + n[2]); 
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
int i,sum=0;
  for(i=0;i<s.size();i++){
  sum+=(s[i]-'0');
     }
  if(sum%9==0){
 cout << "Yes" << endl; 
  }else{
  cout << "No" << endl;
  }
}

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


int main(){
    int n;
    char A[40],Anum[40],B[40],Bnum[40],v,vnum;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i]>>Anum[i];
    for(int i=0;i<n;i++){
        B[i]=A[i];
        Bnum[i]=Anum[i];
    }
    for(int I=0;I<n;I++){
        for(int i=n-1;i>I;i--){
            v=A[i];
            vnum=Anum[i];
            if(Anum[i] < Anum[i-1]){
                A[i]=A[i-1];
                Anum[i]=Anum[i-1];
                A[i-1]=v;
                Anum[i-1]=vnum;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<A[i]<<Anum[i];
        if(i!=n-1)cout<<" ";
    }
    cout<<endl<<"Stable"<<endl;

    int minj;
    for(int i=0;i<n;i++){
        minj=i;
        for(int j=i+1;j<n;j++){
            if(Bnum[minj] > Bnum[j]){
                minj=j;
            }
        }
        swap(B[minj],B[i]);
        swap(Bnum[minj],Bnum[i]);
    }
    for(int i=0;i<n;i++){
        cout<<B[i]<<Bnum[i];
        if(i!=n-1)cout<<" ";
    }
    cout<<endl;
    
    bool ok=1;
    for(int i=0;i<n;i++){
        if(A[i]!=B[i] || Anum[i]!=Bnum[i])ok=0;
    }
    if(ok)cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}






Measured memory_bytes: 3076
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll  = long long;

const int nox=1e5+7;

vector<int> edge[nox];
bool visited[nox];
int dist[nox];
int indegree[nox];
 
void dfs(int a){
	visited[a]=true;
	for(int b:edge[a]){
		dist[b]=max(dist[b],dist[a]+1);
		--indegree[b];
		if(indegree[b]==0){
			dfs(b);
		}
	}
}


int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n,m,x,y;
	cin>>n>>m;
	while(m--){
		cin>>x>>y;
		//edge[x].push_back(y);
		edge[x].emplace_back(y);
		++indegree[y];
	}
	
	for(int i=1; i<=n ; ++i){
		if(!visited[i] && indegree[i]==0)
		dfs(i);
	}
	
	int ans=0;
	for(int i=1;i<=n; ++i){
		ans=max(ans,dist[i]);
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 14508
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int x, t; cin >> x >> t;
	cout << max(0, x-t);
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, x;
  cin >> n >> x;
  vll a(n);
  vin(a);
  sort(all(a));
  ll rem =x;
  ll ans = 0;
  while(rem > 0){
    rem -= a.at(ans);
    if(rem < 0) break;
    if(ans == n - 1 && rem != 0) break;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll A, B, C;
    cin >> A >> B >> C;

    cout << min((ll)B/A, C) << endl;

	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int H, W;
string S[10];
int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') cnt++;
		}
	}
	if (cnt == H + W - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;
using mat = vector<vint>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string ope = "LRUD";

int N, L;
string S;

int idx = 0;

mat mat_calc(mat);
mat mat_rept(mat);

mat mat_init() {
  mat res(N, vector<int>(N));
  rep(i, N) rep(j, N) res[i][j] = N*i+j;
  return res;
}

void mat_print(mat mtrx) {
  rep(i, N) rep(j, N) cout << mtrx[i][j]+1 << (j==N-1 ? '\n' : ' ');
}

int getNum() {
  int res = 0;
  for(; idx < L && isdigit(S[idx]); idx++) res = res*10 + (S[idx]-'0');
  return res;
}

mat mat_shift(mat mtrx) {
  char shift = S[idx++];
  int num = getNum(); num--;
  if(shift == 'L') {
    int tmp = mtrx[num][0];
    for(int j = 0; j < N-1; j++) mtrx[num][j] = mtrx[num][j+1];
    mtrx[num][N-1] = tmp;
  } else if(shift == 'R') {
    int tmp = mtrx[num][N-1];
    for(int j = N-1; j > 0; j--) mtrx[num][j] = mtrx[num][j-1];
    mtrx[num][0] = tmp;
  } else if(shift == 'U') {
    int tmp = mtrx[0][num];
    for(int j = 0; j < N-1; j++) mtrx[j][num] = mtrx[j+1][num];
    mtrx[N-1][num] = tmp;
  } else if(shift == 'D') {
    int tmp = mtrx[N-1][num];
    for(int j = N-1; j > 0; j--) mtrx[j][num] = mtrx[j-1][num];
    mtrx[0][num] = tmp;
  } else {
    assert(false);
  }
  return mtrx;
}

mat mat_calc(mat mtrx) {
  if(ope.find(S[idx]) != string::npos) mtrx = mat_shift(mtrx);
  else if(S[idx] == '(') mtrx = mat_rept(mtrx);
  else assert(false);
  return mtrx;
}

mat mat_rept(mat mtrx) {
  idx++; // (
  mat res = mat_init();
  mat tmp = mat_init();
  while(S[idx] != ')') tmp = mat_calc(tmp);
  idx++; // )
  int num = getNum();
  for(int i = 0; (num>>i); i++) {
    if((num>>i)&1) {
      rep(i, N) rep(j, N) res[i][j] = tmp[res[i][j]/N][res[i][j]%N];
    }
    mat tmp2 = tmp;
    rep(i, N) rep(j, N) tmp[i][j] = tmp2[tmp[i][j]/N][tmp[i][j]%N];
  }
  mat tmp3 = mtrx;
  rep(i, N) rep(j, N) mtrx[i][j] = tmp3[res[i][j]/N][res[i][j]%N];

  return mtrx;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> L >> S;
  mat mtrx = mat_init();
  while(idx < L) mtrx = mat_calc(mtrx);
  mat_print(mtrx);

  return 0;
}

Measured memory_bytes: 112392
#include<cstdio>

#define	EPS		1e-9
#define	pb(a)	push_back(a);

#define	ID_CCW	0
#define	ID_CW	1
#define	ID_GO	2
#define	ID_BACK	3

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy) : x(xx),y(yy){}
};

Point &operator -=(Point &a,const Point &b)
{
	a.x-=b.x;
	a.y-=b.y;
	return a;
}

double dot(const Point &a,const Point &b)
{
	return a.x*b.x+a.y*b.y;
}

double cross(const Point &a,const Point &b)
{
	return a.x*b.y-a.y*b.x;
}

int ccw(const Point &a,Point b,Point c)
{
	b-=a;
	c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)		return ID_CCW;
	if(rotdir<-EPS)		return ID_CW;
	if(dot(b,c)>EPS)	return ID_GO;
	return ID_BACK;
}

int main()
{
	Point p[4];
	while(1){
		if(scanf("%lf,%lf",&p[0].x,&p[0].y)==EOF)	break;
		for(int i=1;i<4;i++)	scanf(",%lf,%lf",&p[i].x,&p[i].y);
		bool b1=true;
		for(int i=0;i<4;i++)	if(ccw(p[i],p[(i+1)%4],p[(i+2)%4])!=ID_CCW)	b1=false;
		bool b2=true;
		for(int i=0;i<4;i++)	if(ccw(p[i],p[(i+1)%4],p[(i+2)%4])!=ID_CW)	b2=false;
		puts(b1||b2?"YES":"NO");
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, count = 0;
  int a[100];

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

  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = n - 1; i > 0; i--) {
      if (a[i] < a[i - 1]) {
        swap(a[i], a[i - 1]);
        flag = true;
        count++;
      }
    }
  }

  for (int i = 0; i < n; i++) cout << a[i] << ((i == n - 1) ? '\n' : ' ');
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3084
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let rec loop i acc l =
        if i = n then acc else
            if s.[i] = '0' then loop (i + 1) (acc ^ "0") (l + 1) else
            if s.[i] = '1' then loop (i + 1) (acc ^ "1") (l + 1) else
                let l = max 0 (l - 1) in
                loop (i + 1) (String.sub acc 0 l) l
    in
    loop 0 "" 0 |> print_endline
)

Measured memory_bytes: 3744
#include <stdio.h>
#include <stdlib.h>

int main() {
	int N=0;
	int count=0;
	scanf("%d\n", &N);
	int* arr = (int*)malloc(N*sizeof(*arr));
	for (int i = 0; i <N-1 ; ++i) {
		scanf("%d ", arr+i);
	}
	scanf("%d\n", arr+N-1);
	for (int k = 0; k <N ; ++k) {
		int frnd=arr[k]-1;
		if (arr[frnd]==k+1 && k<frnd)
			count++;
	}
	printf("%d\n", count);
	return 0;

}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int v[1010]={0};
int w[1010]={0};
int dp[1010][10010]={{0}};
int n,W;
int main(){
	cin>>n>>W;
	 for(int i =0;i <n;i++){
		cin>>v[i]>>w[i];
	}
	
	for(int i =0;i < n;i++){
		for(int j =0;j <=W;j++){
			if(j-w[i]>= 0){
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else{
				dp[i + 1][j] = dp[i][j];
			}

		}

	}

	cout << dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 5220
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class MainClass {
  public static void Main (string[] args) {
	// 入力
    var str = Console.ReadLine();
    
    //処理
    var stack = new Stack<char>();
    foreach(var s in str){
      if(s == '0' || s == '1'){
        stack.Push(s);
      }else{
        try{
          stack.Pop();
        }
        catch(Exception e){}
      }
    }
    
    //出力
    foreach (Object obj in stack.Reverse()){
      Console.Write("{0}", obj );
    }
      Console.WriteLine("");
  }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	ll a, b, c, d, n,aa,bb;
	cin >> a >> b;
	cin >> c >> d;
	cin >> n;

	if (a > c) {
		aa = a - b * n;
		bb = c - d * n;
		if (aa <= bb)cout << "YES";
		else cout << "NO";
	}
	else {
		aa = a + b * n;
		bb = c + d * n;
		if (aa >= bb)cout << "YES";
		else cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
    bool ans=true;
  	if(a*b%2==0) ans=false;
    //出力
    if(ans) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


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

int main() {
    char a, b;
    cin >> a;
    if (a == 'A') b = 'T';
    else if (a == 'T') b = 'A';
    else if (a == 'G') b = 'C';
    else if (a == 'C') b = 'G';
    cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n, k, s;
        cin >> n >> k >> s;
        for(int i = 0; i < k; ++i) cout << s << " ";
        for(int i = 0; i < n - k; ++i) cout << (s == 1000000000 ? 1000000000 - 1 : 1000000000) << " ";
        return 0;
}


Measured memory_bytes: 3624
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        要素xが属するグループの根を返す
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        要素xが属するグループと要素yが属するグループとを併合する
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """
        要素xが属するグループのサイズ（要素数）を返す
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        要素x, yが同じグループに属するかどうかを返す
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """
        要素xが属するグループに属する要素をリストで返す
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """
        すべての根の要素をリストで返す
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """
        グループの数を返す
        """
        return len(self.roots())

    def all_group_members(self):
        """
        {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        """
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        A, B = map(int, input().split())
        uf.union(A-1, B-1)
    ans = uf.group_count()
    ans -= 1
    print(ans)
    return




if __name__ == '__main__':
    main()

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;

  int sum = b + a * 3;
  cout << sum / 2 << endl;
  
  return (0);
}

Measured memory_bytes: 3656
#include<stdio.h>

int main(){
  int n,num[100],alice,bob,tmp;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
 
  for(int j=0;j<n;j++){
    for(int k=j+1;k<n;k++){
      if(num[j]<num[k]){
        tmp=num[j];
        num[j]=num[k];
        num[k]=tmp;
      }
    }
  }
    for(int l=0;l<n;l++){
      if(l%2==0) alice+=num[l];
      else bob+=num[l];
    }
 
    printf("%d\n",alice-bob);
    return 0;
 
}


Measured memory_bytes: 128
#  Author: Amey Bhavsar
#  ID: bhavsar
#  IDE: Geany/Ubuntu
#  Platform: AtCoder Beginner Contest 174
from math import sqrt, floor, pi, cos, sin, log, log2
n=int(input())
if (n>=30):
	print("Yes")
else:
	print("No")

#  n,m=map(int,input().split())
#  a=list(map(int,input().split()))
#  mat = []
#  for i in range(n):
	#  r = input()
	#  r = list(map(int,input().split()))
	#  mat.append(r)



Measured memory_bytes: 9140
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii; // solved, penalty, team

int main() {
  int T, P, R;
  
  while(cin >> T >> P >> R && (T|P|R) ) {
    int wa[100][100] = {{}};
    bool ac[100][100] = {{}};
    vector<Piii> data(T);
    
    for(int i=0; i<T; i++) {
      data[i].second.second = -i;
    }
    for(int i=0; i<R; i++) {
      int t, p, r;
      string mes;
      cin >> t >> p >> r >> mes;
      t --; p --;
      if(mes[0]=='W') {
	wa[t][p] ++;
      }
      else {
	if(!ac[t][p]) {
	  ac[t][p] = true;
	  data[t].first ++;
	  data[t].second.first -= wa[t][p]*1200 + r;
	}
      }
    }
    sort(data.begin(), data.end(), greater<Piii>() );
    int const N = data.size();
    for(int i=0; i<N; i++) {
      cout << -data[i].second.second + 1 << " " << data[i].first << " " << -data[i].second.first << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1268
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
#input()
N,K=map(int,input().split())
XYC=[input().split() for i in range(N)]
for i in range(N):
    x,y,c=XYC[i]
    XYC[i]=[int(x),int(y),c]

lstB=[[0 for i in range(K)] for m in range(K)]
lstW=[[0 for i in range(K)] for m in range(K)]
for x,y,c in XYC:

    if ((x//K + y//K) + (c=="W") * 1)%2==0:
        lstB[x%K][y%K]+=1
    else:
        lstW[x%K][y%K]+=1

#print(lstB)
#print(lstW)
sumB=[sum(lstB[x]) for x in range(K)]
sumW=[sum(lstW[x]) for x in range(K)]
ruisumB=[0]
ruisumW=[0]
for i in range(0,K):
    ruisumB.append(ruisumB[i]+sumB[i])
    ruisumW.append(ruisumW[i]+sumW[i])


ruiBy=[[0] for k in range(K)]
ruiWy=[[0] for k in range(K)]
for y in range(K):
    for x in range(K):
        ruiBy[y].append(lstB[x][y]+ruiBy[y][x])
        ruiWy[y].append(lstW[x][y]+ruiWy[y][x])
Revalue=0
for x in range(K+1):
    value=0
    value+=ruisumW[x]
    value+=ruisumB[K]-ruisumB[x]
    Revalue=max(Revalue,value)
    for y in range(K):
        value+=ruiWy[y][K]-2*ruiWy[y][x]
        value-=ruiBy[y][K]-2*ruiBy[y][x]
        Revalue=max(Revalue,value)

for x in range(K+1):
    value=0
    value+=ruisumB[x]
    value+=ruisumW[K]-ruisumW[x]
    Revalue=max(Revalue,value)
    for y in range(K):
        value+=ruiBy[y][K]-2*ruiBy[y][x]
        value-=ruiWy[y][K]-2*ruiWy[y][x]
        Revalue=max(Revalue,value)

print(Revalue)


Measured memory_bytes: 125780
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);

 //debug func
template<typename T>
void vprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vvprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		String temp = "";
		if(a>b) {
			temp = ">";
		}else if (a<b) {
			temp = "<";
		}else {
			temp = "==";
		}
		System.out.println("a " + temp + " b");
		scanner.close();
	}

}


Measured memory_bytes: 26368
// Rafael Saddatimov
#include <bits/stdc++.h>
#define MAX 200005
using namespace std;

int pos[MAX];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        pos[x] = i;
    }
    set<int> s;
    long long res = 0;
    s.insert(0);
    s.insert(n + 1);
    for (int i = 1; i <= n; ++i) {
        auto it = s.lower_bound(pos[i]);
        int r = *it, l = *(--it);
        res += 1LL * i * (r - pos[i]) * (pos[i] - l);
        s.insert(pos[i]);
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 10368
def construct_floor(num_rooms):
    return [0] * num_rooms


def construct_building(num_floors, num_rooms):
    building = []

    for i in range(num_floors):
        building.append(construct_floor(num_rooms))

    return building


def construct_buildings(num_buildings, num_floors, num_rooms):
    buildings = []

    for i in range(num_buildings):
        buildings.append(construct_building(num_floors, num_rooms))

    return buildings


def floor_to_string(floor):
    room_strings = list(map(str, floor))

    return ' ' + ' '.join(room_strings)


def building_to_string(building):
    floor_strings = list(map(floor_to_string, building))

    return '\n'.join(floor_strings)


def show_buildings(buildings):
    building_strings = list(map(building_to_string, buildings))

    separator = ''.join(['#'] * 20)

    separator = '\n' + separator + '\n'

    buildings_string = separator.join(building_strings)

    print(buildings_string)


if __name__ == "__main__":
    num_inputs = int(input())

    inputs = []

    for i in range(num_inputs):
        inputs.append(input())

    tenant_leaver_notices = list(
        map(lambda input_value: list(map(int, input_value.split())), inputs)
    )

    official_house = construct_buildings(4, 3, 10)

    for tenant_leaver_notice in tenant_leaver_notices:
        building = tenant_leaver_notice[0] - 1
        floor = tenant_leaver_notice[1] - 1
        room = tenant_leaver_notice[2] - 1
        num_people = tenant_leaver_notice[3]

        official_house[building][floor][room] += num_people

    show_buildings(official_house)



Measured memory_bytes: 5660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;
static const int INF = 1000000000;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	int answer = INF;
	for(int i = 0; i + k <= n; ++i){
		const int l = a[i], r = a[i + k - 1];
		const int al = abs(l), ar = abs(r);
		if((l < 0) == (r < 0)){
			answer = min(answer, max(al, ar));
		}else{
			answer = min(answer, min(al, ar) * 2 + max(al, ar));
		}
	}
	cout << answer << endl;
	return 0;
}



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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int n;
    cin >> n;
    int sol=n;
    while(n--)
        sol+=n;
    cout << sol;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    int ans=1;
    for(int i=1; i<N; i++){
        if (S.at(i)!=S.at(i-1)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9456
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

/***ベルマンフォード法***/
const int INF = 1<<30;
vector<long long> bellman_ford(int s,vector<vector<pair<int,long long> > > const &g){
    int n = g.size();
    vector<long long> dist(n,INF);
    dist[s]=0;
    for(int i=0;i<n;i++){
        for(int v=0;v<n;v++){
            for(auto e : g[i]){
                if(dist[v]!=INF&&dist[e.first]>dist[v]+e.second){
                    dist[e.first] = dist[v] + e.second;
                }
            }
        }
    }
    return dist;
}

using P = pair<int,ll>;
void dijkstra(int s,vector<ll> &d,vector<vector<P> > &G) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(All(d),INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            P e = G[v][i];
            if (d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                que.push(P(d[e.first], e.first));
            }
        }
    }
}


int main(){
    int N,M;
    cin >> N >> M;

    using pii = pair<int,ll>;
    cout << endl;
    vector<vector<pii> > G(1<<N);
    rep(i,M){
        ll a,b;cin >> a >> b;
        int next = 0;
        rep(j,b){
            int c;
            cin >> c;
            c--;
            next|=(1<<c);
        }
        rep(j,1<<N){
            if(((~j)&next)!=0){
                G[j].push_back(make_pair((j|next),a));
            }
        }
    } 
    vector<ll> dist(1<<N);
    dijkstra(0,dist,G);
    ll res = dist[(1<<N)-1];
    if(res == INF){
        cout << -1 << endl;
    }else{
        cout << res << endl;
    }
    // rep(i,(1<<N)){
    //      cout << i << endl;
    //      for(auto &x:G[i])cout << x.first << " " << x.second << ":";
    //      cout << endl;
    // }
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 100000
#define INF 100000000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[1010][1010];
int cum[1010][1010];
int cnt2;
vector<int> vec[1000010];
int cnt[1000010];
queue<P> que;
int ans;

signed main() {
	cin >> n;
	int x = n * (n - 1) / 2;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			cnt2++;
			cum[i][j] = cnt2;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++) {
			cin >> a[i][j];
			if (2 <= j) {
				vec[cum[min(i, a[i][j - 1])][max(i, a[i][j - 1])]].push_back(cum[min(i, a[i][j])][max(i, a[i][j])]);
				cnt[cum[min(i, a[i][j])][max(i, a[i][j])]]++;
			}
		}
	}
	int cnt3 = 0;
	for (int i = 1; i <= x; i++) {
		if (!cnt[i])que.push({ i,1 });
	}
	while (!que.empty()) {
		P p = que.front(); que.pop();
		ans = max(ans, p.second);
		cnt3++;
		int v = p.first;
		for (int i = 0; i < (int)vec[v].size(); i++) {
			cnt[vec[v][i]]--;
			if (!cnt[vec[v][i]])que.push({ vec[v][i],p.second + 1 });
		}
	}
	if (cnt3 != x)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 60928
def divisors(N):
    U = int(N ** 0.5)
    L = [i for i in range(1, U) if N % i == 0]
    C = [U] if M % U == 0 else []
    R = [N // r for r in reversed(L)]
    return L + C + R

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3060
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        mut aa: [usize; n]
    };
    aa.sort();
    let mut min_colors = 0;
    let mut free_colors = 0;
    let mut pre = std::usize::MAX;
    for a in aa {
        let num = a / 400;
        if num >= 3200 / 400 {
            free_colors += 1;
        } else if pre != num {
            pre = num;
            min_colors += 1;
        }
    }
    if (min_colors == 0) && (free_colors > 0) {
        min_colors += 1;
        free_colors -= 1;
    }
    println!("{} {}", min_colors, min_colors + free_colors);
}


Measured memory_bytes: 2100
#include <iostream>

using namespace std;
int x[100010],a[100010],b[100010],cnt[100010] = {},y[100010];
int main(){
	int i,n,q;
	cin >> n >> q;
	x[0] = 0;
	for(i=0;i<n;i++) y[i] = i;
	for(i=0;i<q;i++){
		cnt[y[x[i]]]++;
		if(x[i]!=0) cnt[y[x[i]-1]]++;
		if(x[i]!=n) cnt[y[x[i]+1]]++;
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
		int k = y[a[i]]; 
		y[a[i]] = y[b[i]]; y[b[i]] = k;
		if(x[i]==a[i]) x[i+1] = b[i];
		else if(x[i]==b[i]) x[i+1] = a[i];
		else x[i+1] = x[i];
	}
	cnt[y[x[q]]]++;
	if(x[q]!=0) cnt[y[x[q]-1]]++;
	if(x[q]!=n) cnt[y[x[q]+1]]++;
	int ans = 0;
	for(i=0;i<n;i++){
		if(cnt[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include<algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <cstdio>
#include <ctype.h>
#include <cstdlib>
using namespace std;

int main() {
	int n;
	long long t, sum;
	cin >> n >> t;
	long long a[n];
	sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		long long k = a[i + 1] - a[i];
		

		if (t <= k) {
			sum += t;

		}
		if (t > k) {
			sum += k;

		}
	}
	cout << sum + t << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    string n;cin >> n;
    unsigned long long sum = 0;
    for(int i = 0; i < n.size(); i++)sum += int(n[i]-'0');
    if(!(sum % 9)) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3752
class DisjointSet
  def initialize(n)
    @parents = Array.new(n, &:to_i)
    @ranks = Array.new(n, 0)
  end

  def unite(x, y)
    link(find_set(x), find_set(y))
  end

  def same?(x, y)
    find_set(x) == find_set(y)
  end

  private

  def link(x, y)
    if @ranks[x] > @ranks[y]
      @parents[y] = x
    else
      @parents[x] = y

      if @ranks[x] == @ranks[y]
        @ranks[y] += 1
      end
    end
  end

  def find_set(v)
    if v != @parents[v]
      @parents[v] = find_set(@parents[v])
    end

    @parents[v]
  end
end

if $PROGRAM_NAME == __FILE__
  n, q = gets.chomp.split.map(&:to_i)

  ds = DisjointSet.new(n)

  q.times do
    command, x, y = gets.chomp.split.map(&:to_i)

    case command
    when 0
      ds.unite(x, y)
    when 1
      puts ds.same?(x, y) ? 1 : 0
    else
      raise "unknown command: #{command}"
    end
  end
end

Measured memory_bytes: 8908
while True:
    n,x=map(int,input().split())
    if n==x==0:break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans+=1
    print(ans)


Measured memory_bytes: 5596