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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

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

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

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

  int i = 357;
  while(n >= i) {

    int a = i;
    bool f3, f5, f7, f;
    f3 = f5 = f7 = f = false;
    while(a) {
      int l = a % 10;
      a /= 10;
      if(l == 3) f3 = true;
      else if(l == 5) f5 = true;
      else if(l == 7) f7 = true;
      else {f = true; break;}
    }

    if(f3 && f5 && f7 && !f) cnt++;
    
    if(i % 10 == 7) {
      if(i / 10 % 10 == 7) i += 50;
      else i += 10;
      i += 6;
    }
    else i += 2;
    
  }
  
  co << cnt << en;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
bool isprime(int x)
{
    for(int i = 2;i*i<=x;i++)
        if(x%i==0)
            return false;
    return true;
}

int main()
{
    int n ;
     cin>>n;
    for(int i = 11;n;i+=10)
     {
         if(isprime(i))
            {cout<<i<<' ';
                n--;
            }
     }
     cout<<'\n';

}


Measured memory_bytes: 256
x1,y1,x2,y2=[int(i) for i in input().split(" ")]


onefour=(y1-y2,x2-x1)
x3,y3=x2+y1-y2,y2+x2-x1
x4,y4=x1+y1-y2,y1+x2-x1

print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 3060
def rec(lst,d):
    for i in range(1,len(lst)+1):
        if i not in lst:
            lst[d]  = i
            if d+1 == len(lst):
                a = list(lst)
                P.append(a)
                lst[d] = 0
                return
            else:
                rec(lst,d+1)
                lst[d] = 0

N = int(input())
S = list(map(int,input().split()))

P = []

lst = []
for i in range(N):
    lst.append(0)

rec(lst,0)

for i in range(len(P)):
    if S == P[i]:
        if i != 0:
            print(*P[i-1])
        print(*P[i])
        if i+1 != len(P):
            print(*P[i+1])



Measured memory_bytes: 78304
#include<bits/stdc++.h>
using namespace std;
int main()  
{
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=9;i++){
  	if(n%i==0&&(n/i)<=9) ans=1;
  }
  if(ans) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;

/*int <= 10^9*/


int main() {


	int N; cin >> N;
	vint A(N);
	rep(i, N)cin >> A[i];

	int ans = INT_MIN;
	rep(i, N)rep(j, N) {
		if (i >= j)continue;
		ans = max(ans, abs(A[i] - A[j]));
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 256
n= int(input())

mat = [ [0]*10 for i in range(10)]

for i in range(1,n+1):
  a,b = int(str(i)[0]), i%10
  mat[a][b] += 1

ans = 0
for i in range(1,10):
  for j in range(1,10):
    ans += mat[i][j]*mat[j][i]

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;



void Main(){

    int N; cin>>N;

    string S; cin>>S;

    int ans=N;

    reps(i,1,N){
        if(S[i]==S[i-1]) ans--;
    }

    cout<< ans<<"\n";
}

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


Measured memory_bytes: 512
N=int(input())
S=input()

r_cnt=S.count('R')
g_cnt=S.count('G')
b_cnt=S.count('B')

ans=r_cnt*g_cnt*b_cnt

for i in range(N):
  for d in range(N):
    j=i+d
    k=j+d
    if k>=N:break
#等号がないと範囲外参照になる、0-indexだからk=S[N]は無い      
    if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
      ans-=1
      
print(ans)

Measured memory_bytes: 73528
#include<iostream>
using namespace std;
 
int main(){
 
int a,b;
 
cin >> a>>b;
 
if(a>b) cout<<"a > b"<<endl;
else if(a<b) cout<<"a < b"<<endl;
else cout<<"a == b"<<endl;
 
 
return 0;
 
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, hm[26], ans = 0;
string s;
int main(){
	cin >> n >> s;
	REP(i, n) {
		ll now = 1;
		hm[s[i] - 'a']++;
		REP(j, 26) if (j != s[i] - 'a' and hm[j] > 0) now = now * (hm[j] + 1) % MOD;
		ans += now;
		ans %= MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
#include<stdio.h>
#define INF 10000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){

    scanf("%d %d",&n,&k);

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j] = (i==j?0:INF);

    if(n==0 && k==0)break;
    
    for(i=0;i<k;i++){
      scanf("%d",&x);
      
      if(x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }

    }

  }
  
  return 0;
}

void warshall_floyd(void){
  int i,j;

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      }
    }
}

int min(int x,int y){
  return (x<y)?x:y;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
char c;
cin>>c;
if(c>='A' && c<='Z')
cout<<"A";
else
cout<<"a";
return 0;
}
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3648
#include<iostream>                                 
using namespace std;                               
                                                   
int main() {                                       
    int n;                                         
    cin >> n;                                      
    int l[n];                                      
    int maximum = 0, max_num, sum = 0;             
    for (int i = 0;i < n;i++) {                    
        cin >> l[i];                               
        if (maximum < l[i]) {                      
            maximum = l[i];                        
            max_num = i;                           
        }                                          
    }                                              
                                                   
    for (int i = 0;i < n;i++) {                    
        if (i != max_num) sum += l[i];             
    }                                              
                                                   
    if (maximum < sum) cout << "Yes" << endl;      
    else cout << "No" << endl;                     
}                                                  

Measured memory_bytes: 256
//____________________________________________________________________
  //________________________________NAMAN_______________________________
 //________________________________TALAYCHA______________________________
//__________________________________________________________________________

#include <bits/stdc++.h>
#define ll              long long
#define int             long long
#define pmin            priority_queue < ll, vector<ll>, greater<ll> >
#define pmax            priority_queue <ll>
#define endl            '\n'
#define mii             map<ll , ll >
#define pii             pair< ll, ll >
#define vi              vector<ll>
#define all(a)          (a).begin(), (a).end()
#define DEBUG           cerr<<"/n>>>I'm Here<<</n"<<endl;
#define rep(i, a, b )   for (ll i = a; i < b; i++)
#define rrep(i, a, b)   for (ll i = a; i >= b; i--)
#define bs              binary_search
#define present(c, x)   ((c).find(x) != (c).end())
#define cpresent(c, x)  (find(all(c), x) != (c).end())
#define p1(i)           cout<<i<<endl;
#define p2(i,j)         cout<<i<<" "<<j<<endl;
#define line            cout<<endl;
#define prt(s,b,n)      rep(i,(b),(n)) { cout<<(s)[i]<<" ";} line
#define lower(u)        transform(u.begin(), u.end(), u.begin(), ::tolower);  //convert string u to lowercase;
#define upper(u)        transform(u.begin(), u.end(), u.begin(), ::toupper);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define hell 1e6+3
#define mod 998244353

  using namespace std;

//_________________________________________________________________________________________________________
//__________________________________________START____________________________________________________________

//................EVERY COIN HAS TWO SIDES...............................................................................................................

void solve()
{
  ll n; 
  //ll m=0 , mx=0 , mn=0 , k=0 , ans=0 , flag=0 , res=0 ;
  cin>>n;
  //for(ll i=0;i<n;i++)
  //string s;  cin>>s;
 vi a(n); rep(i,0,n){ cin>>a[i];}
  ll d[n+1];
  rep(i,0,n+1) d[i]=INT_MAX;
  d[0]=0;
  d[1]=0;
  d[2]=abs(a[0]-a[1]);
  rep(i,3,n+1)
  {
     d[i]=min(d[i-1]+abs(a[i-1]-a[i-2]),d[i-2]+abs(a[i-1]-a[i-3]));
  }
  cout<<d[n]<<endl;
  return;
}

//__________________________________________________________________________________________________________
//__________________________________________END______________________________________________________________

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

  #ifndef ONLINE_JUDGE 
  freopen("input.txt" , "r", stdin);
  freopen("out12.txt" , "w", stdout);
  #endif  
//sieve();
  ll TESTS = 1;
  //cin>>TESTS;
  while (TESTS--) 
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m, cnt;
int head[MAX], vet[MAX], h[MAX], Next[MAX];

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        scanf("%d", &h[i]);
    }
    int x, y;
    for(int i = 1; i <= m; i++){
        scanf("%d%d", &x, &y);
        add(x, y), add(y, x);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int flag = 1;
        for(int j = head[i]; j; j = Next[j]){
            int v = vet[j];
            if(h[v] >= h[i]) flag = 0;
        }
        if(flag) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

string s;
int a,b,i;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>s;
	REP(i,s.size())
	{
		if (s[i]=='A') a++;
		else b++;
	}
	if (a==0 || b==0)
		cout <<"No"<<endl;
	else
		cout <<"Yes"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

int main() {
  int64_t N;
  cin >> N;
  int64_t a, b, ans;
  
  for(int i=1; i<=sqrt(N)+1; i++){
    if(N%i==0)a=i;
  }
  
  b=N/a;
  ans = a+b-2;
  
  cout << ans << endl;
}

Measured memory_bytes: 3656
using System;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int t = int.Parse(s[1]);
        int ans = 0;
        if (n > t) ans = n - t;
        Console.WriteLine(ans);
    }
}


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

int main() {
	char a,b;
  	cin >> a >> b;
  
  	if(a == 'H' && b == 'H') cout << "H" << endl;
  	if(a == 'H' && b == 'D') cout << "D" << endl;
  	if(a == 'D' && b == 'H') cout << "D" << endl;
  	if(a == 'D' && b == 'D') cout << "H" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
//const ll MAX_P=200010;
//ll fact[MAX_P];
int N,K;
/*
void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}
*/
const int NMAX=200010;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  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 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;
  }
};
mint fact[NMAX],infac[NMAX];
void Make_Fact(int n){
  fact[0]=fact[1]=1;
  rep1(i,n){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(int n){
  infac[0]=infac[1]=1;
  rep1(i,n){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}


int main(){
  cin>>N>>K;
  int n=max(K-1,N-K+1);
  Make_Fact(n);
  Make_InvFact(n);  
  rep1(i,K){
    //    ll res=mod_comb(K-1,i-1,MOD)*mod_comb(N-K+1,i,MOD)%MOD;
    mint res=Comb(K-1,i-1)*Comb(N-K+1,i);
    prin(res.x);
  }
  return 0;
}


Measured memory_bytes: 3328
n=int(input())
alist=list(map(int,input().split()))
sosu=10**9+7
tenlist=[0]*60

for a in alist:
    tmp=str(format(a,"b"))
    for i in range(len(tmp)):
        if tmp[-(i+1)]=="1":
            tenlist[i] = tenlist[i]+1

out=0
for i, ten in enumerate(tenlist):
    out += (ten*(n-ten))*pow(2,i,sosu)
    out %= sosu


print(int(out))

        

Measured memory_bytes: 122936
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(be(s[i]));
    }
    sort(s,s+n);
    ll ans=0;
    ll index=1;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            ans+=index;
            index++;
        }
        else{
            index=1;
        }
    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//強連結を知りたいとき、深さを知りたいとき、他
int max_len;
struct DirectedGraph{
    int V;

    vector<vector<int>> to;
    vector<vector<int>> from;

    vector<int> vs;
    vector<int> depth;
    vector<bool> used;
    vector<int> cmp;

    void dfs(int v){
        used[v]=true;
        for(auto t:to[v]) if(!used[t]) dfs(t);
        vs.push_back(v);//帰りがけ
    }
    //k:始点,rdfsがkに戻る→強連結成分
    int r_dfs(int v,int k){
        int ret=0;
        used[v]=true;
        cmp[v]=k;
        for(const auto t:from[v]){
            if(!used[t]) r_dfs(t,k);
            depth[v]=max(depth[v],depth[t]+1);
        }
    }
    DirectedGraph(int V) : V(V),
        to(vector<vector<int>>(V)),
        from(vector<vector<int>>(V)),
        cmp(vector<int>(V)),
        depth(vector<int>(V))
        {}
    
    void add_edge(int from_,int to_){
        to[from_].push_back(to_);
        from[to_].push_back(from_);
    }


    //強連結成分:任意の2頂点を行き来できる部分グラフ
    //          1点だけのも競連結成分
    //順方向帰りがけdfsと逆方向行き止まりまでdfs
    int scc_num=-1;
    //scc_num:強連結成分の個数
    int scc(){
        used=vector<bool>(V,false);
        vs.clear();
        for(int v=0;v<V;v++) if(!used[v]) dfs(v);
        used=vector<bool>(V,false);
        scc_num=0;
        for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]){
            max_len=max(max_len,r_dfs(vs[i],scc_num++));
        }
        return scc_num;
    }

    bool isCyclic(){
        //強連結成分が全部1点だけのものであれば
        //強連結成分の数は点数と一致し、閉路はない
        return (scc_num!=V);
    }

    //sccの後潰してトポロジカル順序のグラフを作る
    //デバッグとかしてないし試したことない知らん
    DirectedGraph makeTopologicalGraph(){
        DirectedGraph TG(scc_num);
        rep(s,V) for(auto t:to[s]){
            if(cmp[s]!=cmp[t]) TG.add_edge(cmp[s],cmp[t]);
        }
        return TG;
    }
};


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

    int n,m;cin>>n>>m;
    DirectedGraph g(n);
    while(m--){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g.add_edge(a,b);
    }
    g.scc();
    cout<<(g.isCyclic()?0:-1)<<endl;
    return 0;
}


Measured memory_bytes: 384
//Vinh copy code nhi quoc gia, dung chui Vinh hu hu :(
#include <iostream>
using namespace std;
long long sums[405],n,a[405],f[405][405];
long long trau(int i,int j)
{
    if (i == j) return 0;
    long long &res = f[i][j];
    if (res!=-1) return res;
    res=1e18;
    for (int mid = i; mid < j; ++mid)
    {
        res=min(res,trau(i,mid)+trau(mid+1,j));
    }
    res+=(sums[j]-sums[i-1]);
    return res;
}
int main()
{
    cin>>n;
    for (long long i = 1; i <= n; i++)
    {
        cin>>a[i];
        sums[i]=sums[i-1] + a[i];
    }
    for (long long i = 0; i <= n;++i)
    {
        for (long long j = 0; j <= n; ++j)
            f[i][j]=-1;
    }
    long long res=1e8;
    for (int length = 2; length <= n; ++length)
    {
        for (int i = 1; i <= n; i++)
        {
            int j=i+length-1;
            if (j>n) break;
            res=trau(i,j);
        }
    }
    cout<<trau(1,n)<<endl;
    return 0;
}

Measured memory_bytes: 4872
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

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

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int main(void){
    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    REP(i, N){
        int A;
        cin >> A;
        que.push(A);
    }
    REP(i, M){
        int p=que.top();que.pop();
        que.push(p/2);
    }
    ll cnt=0;
    while (!que.empty()) {
        cnt+=que.top();
        que.pop();
    }
    cout << cnt << endl;
    return 0;
}


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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[][] game = new int[N][3];
		int[][] flag = new int[N][3];
		int[] tokuten = new int[N];
		for(int i=0; i<N; i++){
			tokuten[i] = 0;
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				flag[i][j]=0;
			}
		}
		
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				game[i][j] = s.nextInt();
			}
		}
		for(int i=0; i<3; i++){
			for(int j=0; j<N; j++){
				for(int k=0; k<N; k++){
					if(j==k) continue;
					if(game[j][i]==game[k][i]){
						flag[j][i]=1;
						flag[k][i]=1;
					}
				}
			}
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				if(flag[i][j]==0){
					tokuten[i]+= game[i][j];
				}
			}
		}
		for(int i=0; i<N; i++){
			System.out.println(tokuten[i]);
		}
	}
}

Measured memory_bytes: 20900
#include <stdio.h>		/*TeraPadÉÄ"ÒW"¨"«·¦Ö~"*/
#include <math.h>
#define A 0
#define B 1
#define C 2
#define X 0
#define Y 1

void syori1(double a,double b,double c,double d,double e,double f,double *x,double *y){		/*x + y= (ªÓ½Â) Ìûö®ðð­B*/
	*x=( c*(e/b)-f )/( a*(e/b)-d );
	*y=( ( c-(a * *x) )/b );
}

int syori2(double n){	/*	¬_æ4ÊðlÌÜü	yg¢ûzn+=syori2(n) */
	n*=1000;
	n = n - (double)(int)n;
	if(n>=0.5){
		return (0.001);
	}else{
		return 0.;
	}
}

int main(){
	double	xy[3][2],
			xp,yp,r,
			a,b,c,
			cosA,
			as[2],at[2],uhen[2],
			t,s,
			AO[2];					/*AOxNg{x,y}*/
	int n,							/*f[^Zbg*/
		i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xy[A][X],&xy[A][Y],&xy[B][X],&xy[B][Y],&xy[C][X],&xy[C][Y]);
		
		c=sqrt( pow( xy[A][X] - xy[B][X] ,2) + pow( xy[A][Y] - xy[B][Y] ,2) );	/*	|AB|	(xNgÌå«³)	*/
		a=sqrt( pow( xy[B][X] - xy[C][X] ,2) + pow( xy[B][Y] - xy[C][Y] ,2) );	/*	|BC|						*/
		b=sqrt( pow( xy[C][X] - xy[A][X] ,2) + pow( xy[C][Y] - xy[A][Y] ,2) );	/*	|AC|						*/
			
		cosA	= ( pow(b,2) + pow(c,2) - pow(a,2) ) / (2*b*c);				/*	]·èæè		*/
		
		as[0]	= pow(c,2);													/*	|AB|^2				*/
		at[0]	= c*b*cosA;													/*	|AB|*|AC|*cos (A)	*/
		uhen[0]	= as[0]/2;													/*	sÌWÌQ		*/
		as[1]	= c*b*cosA;													/*	at[0]É¯¶			*/
		at[1]	= pow(b,2);													/*	|AC|^2				*/
		uhen[1]	= at[1]/2;													/*	tÌWÌQ		*/
		
		syori1(at[0],as[0],uhen[0],at[1],as[1],uhen[1],&t,&s);				/*y¨mç¹zsÆtªoÜµ½B()t+s=ÌA§ûö®*/
		
		AO[X]= s*( xy[B][X] - xy[A][X] ) + t*( xy[C][X] - xy[A][X] );		/*	AO = a*AB + t*AC	*/
		AO[Y]= s*( xy[B][Y] - xy[A][Y] ) + t*( xy[C][Y] - xy[A][Y] );
		
		
		r	= a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		xp	= AO[X] + xy[A][X];
		yp	= AO[Y] + xy[A][Y];
		
		r+=0.	;
		xp+=0.	;
		yp+=0.	;
		
		r	+= syori2(r);
		xp	+= syori2(xp);
		yp	+= syori2(yp);
		
		printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
int vis[20],mark[20];
int num[maxn];
void solve()
{
	int n;scd(n);
	scanf("%s",s+1);
	ll ans=0;
	int now=0;
	rep1(i,n){
		num[i]=now;
		if(!vis[s[i]-'0']){
			vis[s[i]-'0']=1;
			now++;
		}
	}
	rep(i,10){
		for(int j=n;j;j--){
			if(s[j]-'0'==i){
				mst(mark,0);
				for(int k=j-1;k;k--){
					if(!mark[s[k]-'0']){
						mark[s[k]-'0']=1;
						ans+=1ll*num[k];
					}
				}
				break;
			}
		}
	}ac;
}
int main(){
    //IOS;
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];
int Ans[35];

int main() {
  int N, M; cin >> N >> M;
  
  memset(Ans, 0, sizeof(Ans));
  
  for (int i = 0; i < N; i++) {
    int K; cin >> K;
    for (int i = 0; i < K; i++) {
      int a; cin >> a;
      Ans[a]++;
    }
  }

  int fa = 0;
  for (int i = 0; i <= M; i++) {
    if (Ans[i] == N) {
      fa++;
    }
  }
  cout << fa << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n;
double dp[301][301][301];

double dfs(int i, int j, int k) {
    if (dp[i][j][k] != -1) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return dp[i][j][k] = 0;
    
    double res = 0;
    // 式変形した 自己ループ忘れないよう
    if (i) res = 1.0 * i * dfs(i - 1, j + 1, k);
    if (j) res += 1.0 * j * dfs(i, j - 1, k + 1);
    if (k) res += 1.0 * k * dfs(i, j, k - 1);
    res += n;
    res /= (i + j + k);
    
    return dp[i][j][k] = res;
}


int main() {
    cin >> n;
    
    int a = 0, b = 0, c = 0;
    int sum = 0;
    rep(i, n) {
        int num;
        cin >> num;
        if (num == 3) a++;
        else if (num == 2) b++;
        else c++;
        sum += num;
    }
    
    fill_n(**dp, 301 * 301 * 301, -1);
    
    cout << fixed << setprecision(10) << dfs(a, b, c) << '\n';
    
}


Measured memory_bytes: 213376
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main() {
	int h, a; std::cin >> h >> a;
	std::cout << (h + a - 1) / a << std::endl;
}

Measured memory_bytes: 888
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n] <- readInts
  input <- readInts
  print $ solve input

solve :: [Int] -> Int
solve = foldr (\x a-> (get2p x 0) + a) 0
  where
    get2p n p = if n `rem` 2 == 0
      then get2p (n `div` 2) (p + 1)
      else p

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 1276
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
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 priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,k;cin>>n>>k;
    k--;
    string s;cin>>s;
    s[k] += 32;
    cout<<s<<endl;


	return;
}

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

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

int main()
{
    int a,b,x;
    scanf("%d%d",&a,&b);
    x=b-a;

    printf("%d",(1+x)*x/2-b);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC145A
{
  class Program
  {
    static void Main(string[] args)
    {
      int a, b, c, x;
      
      var word = Console.ReadLine().Split(' ');
      
      a = int.Parse(word[0]);
      b = int.Parse(word[1]);
      c = int.Parse(word[2]);
      
      x = a * b;
      
      if (x < c)
        Console.WriteLine(x);
      
      else if (c < x)
        Console.WriteLine(c);
      
      else
        Console.WriteLine(x);
      
      Console.ReadKey();
    }
  }
}

Measured memory_bytes: 13140
#include<vector>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;

ll f(ll x,ll n){
  ll mod = 10;
  ll res = 1;
  while(n>0){
    if(n&1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  ll mod = 10;
  ll n,m,k;
  cin>>n>>m>>k;
  n%=mod;
  ll nm = f(n,m)%mod;
  set<ll> list;
  vector<ll> listl;
  list.insert(n);
  listl.push_back(n);
  ll loop=0;
  for(ll i=1;i<k;i++){
    n= nm*n%mod;
    if(list.count(n)>0){
      loop=i;
      break;
    }else{
      list.insert(n);
      listl.push_back(n);
    }
  }
  /*
  cout<<loop<<endl;
  for(int i=0;i<listl.size();i++){
    cout<<listl[i]<<" ";
  }cout<<endl;
  */
  ll loopsum = 0;
  for(auto i : list){
    loopsum +=i;
  }
  ll ans =0;
  ans += loopsum*(k/list.size());
  for(int i=0;i<(k%listl.size());i++){
    ans+=listl[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1208
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007  

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    int ans = 0;
    for(int i = 0; i < H; i++){
        cin >> c[i];
    }
    for(int bit = 0; bit < (1 << (H + W)); bit++){
        vector<string> cc(H);
        for(int i = 0; i < H; i++) cc[i] = c[i];
        for(int j = 0; j < (H+W); j++){
            if(1 & bit >> j){
                if(j < H){
                    for(int i = 0; i < W; i++){
                        cc[j][i] = 'r';
                    }
                }
                else{
                    for(int i = 0; i < H; i++){
                        cc[i][j - H] = 'r';
                    }
                }
            }
        }
        int cnt = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(cc[i][j] == '#') cnt++;
            }
        }
        if(cnt == K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

X, Y = getNM()
X = int(X)
Y = int(Y)

if (X - Y) ** 2 > 1:
    print("Alice")
else:
    print("Brown")

Measured memory_bytes: 83448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int N, M, Q;
vector<int> A, B, C, D;

vector<int> V;

int dfs(int n)
{
    int res = 0;
    if (n == N) {
        for (int i = 0; i < Q; i++) {
            if (V[B[i]] - V[A[i]] == C[i]) {
                res += D[i];            
            }
        }
        return res;
    }

    for (int v = (n == 0 ? 1 : V[n-1]); v <= M; v++) {
        V[n] = v;
        res = max(res, dfs(n+1));
    }
    return res;
}

int main()
{
    cin >> N >> M >> Q;
    A.resize(Q); B.resize(Q); C.resize(Q); D.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--; B[i]--;
    }
    V.resize(N);
    int ans = dfs(0);
    cout << ans << endl;
}

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

int main(){
    ll n;
    cin >> n;
    deque<ll> b;
    rep(i, 0, n){
        ll a; cin >> a;
        if(i % 2 == 0) b.push_back(a);
        else b.push_front(a);
    }
    if(n % 2 == 1){
        rep(i, 0, n){
            cout << b.back() << " ";
            b.pop_back();
        }
    }else{
        rep(i, 0, n){
            cout << b.front() << " ";
            b.pop_front();
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5216
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long x = sc.nextLong();
    long[] a = new long[N];
    long sum = 0;
    for(int i = 0; i < N; i++){
      a[i] = sc.nextLong();
    }
    if(a[0] > x){
      sum = a[0] - x;
      a[0] = x;
    }
    for(int i = 1; i < N; i++){
      if(a[i]+a[i-1] > x){
        long tmp = a[i] + a[i-1] - x;
        a[i] = a[i] - tmp;
        sum += tmp;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 61896
#include <bits/stdc++.h>
using namespace std;
/************************Contest Template**************************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b)
    { a=_a; b=_b; }
    const bool operator<(const S &o) const{
        return a<o.a;}
};
string exm;
inline void exf(void){ cout<<exm<<"\n"; exit(0); }
template <typename T>
inline void showAll(vector<T> &v,string sep=""){
    for(T &here:v) cout<<here<<sep;}
template <typename T>
inline void showAll(T a[],int st,int end,string sep=""){
    for(int i=st ; i<=end ; i++) cout<<a[i]<<sep; }
template <typename T>
inline void showAll(T a[],int x,int y,int z,int w,string p,string q){
    for(int i=x ; i<=y ; i++){for(int j=z ; j<=w ; j++)
        {cout<<a[i][j]<<p;}cout<<q;}}   
template <typename T>
inline vector<int> int_seperation(T N,int d=10){
    vector<int> v; while(N){v.push_back(N%d); N/=d;}
    reverse(v.begin(),v.end()); return v; }
/************************Contest Template**************************/
//const int SIZE=

int main(){
    int t;  scanf("%d",&t);	
	if(t>=30) printf("Yes\n");
  	else printf("No\n");
  	
  	return 0;
}
/*

*/






Measured memory_bytes: 3668
# -*- coding: utf-8 -*-
# ITP1_9_B
# シャッフル

while 1:
    card = input()
    if card == "-":
        break
    m = int(input())
    for i in range(m):
        h = input()
        card = card[int(h):] + card[:int(h)]

    print(card)



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

int main() {
  int A[4];
  for (int i=0; i<4; i++) {
    scanf("%d",A+i);
  }

  printf("%d",min(A[0],A[1])+min(A[2],A[3]));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>
#include <string>
#include <map>
#include <functional>
#include <algorithm>
#include <stack> 
#include <iomanip>
#include <stdio.h>
#include <set>
#include <array>
using namespace std; 

int main()
{
	long long n;
	cin >> n;
	if (n % 2 || n < 10) {
		cout << 0 << endl;
		return 0;
	}
	long long max5 = 1;
	long long res = 0;
	while (max5 < n) {
		max5 *= 5;
		res += (n / max5) / 2;
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

long long  N, X, ans;

long long solve(long long a,long long b) {
    if(a == 0) return 0;
    if(b % a == 0) return 2 * a * (b / a) - a;
    return solve(b % a, a) + 2 * a * (b / a);
}

int main() {
    cin >> N >> X;
    cout << N + solve(min(X, N - X), max(X, N - X)) << endl;
    return 0;
}

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

int main () {
    int A, B, C; cin >> A >> B >> C;
    if (A == B && A != C) {
        cout << "Yes" << endl;
    } else if(A == C && A != B) {
        cout << "Yes" << endl;
    } else if(B == C && A != B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
string n;
while(true){
  cin>>n;
  if(n[0]-'0'==0)break;
  int sum=0;
  for(int i=0;n[i]!='\0';i++){
  sum+=n[i]-'0';
  }
  cout<<sum<<endl;
}
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
/*!* [z_alg] *!*/
/*+* Zアルゴリズム
    最長共通接頭辞をO(N)で求める
    S : typename | コンテナの型
    str : S | 検索する列
    z_array : vector<int> | 結果（入力時は空のまま）
*+*/

template<typename S>
void ZAlgorithm(S str, vector<int> &z_array) {
    int n = str.size();
    int L = 0, R = 0;
    z_array.push_back(-1);
    for(int i = 1; i < n; i++) {
        if(i > R) {
            L = R = i;
            while(R < n && str[R - L] == str[R]) R++;
            z_array.push_back(R - L);
            R--;
        } else {
            int j = i - L;
            if(z_array[j] < R - i + 1) {
                z_array.push_back(z_array[j]);
            } else {
                L = i;
                while(R < n && str[R - L] == str[R]) R++;
                z_array.push_back(R - L);
                R--;
            }
        }
    }
}

// 方針: xor差分の一致部分を探す，初期位置でのxorをxとする．
int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), A_diff(N), B_diff(N);
    for(int &a : A) cin >> a;
    for(int &b : B) cin >> b;
    for(int i = 0; i < N; i++) {
        A_diff[i] = A[i] ^ A[(i + 1) % N];
        B_diff[i] = B[i] ^ B[(i + 1) % N];
    }
    vector<int> s, result;
    for(int a : A_diff) s.push_back(a);
    s.push_back(1 << 30);
    for(int i = 0; i < 2; i++) for(int b : B_diff) s.push_back(b);
    ZAlgorithm(s, result);
    vector<pair<int, int>> ans;
    for(int j = 0; j < N; j++) {
        if(result[N + 1 + j] >= N) {
            // $k \equiv j \mod N$
            int k = (N - j) % N;
            int x = A[0] ^ B[j];
            ans.push_back({k, x});
        }
    }
    sort(WHOLE(ans));
    for(auto a : ans) {
        cout << a.first << " " << a.second << endl;
    }
    return 0;
}



Measured memory_bytes: 18244