akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n,a;
  cin >> n >> a;
  cout << n*n-a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int M[200][200];
  int n,u,k,v,i,j;

  scanf("%d",&n);
  for(i = 0;i <n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 1;i <=n  ;i++){
    for(j = 0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 684
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int K,A,B;

int main(){
    cin>>K>>A>>B;

    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK";
            return 0;
        }
    }

    cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll p=(a-1)/c;
ll q=b/c;
 q-=p;
 ll r=(a-1)/d;
 ll s=b/d;
 s-=r;
 ll gd=__gcd(c,d);
 ll cd=(c*d)/gd;
 ll x=b/cd;
 ll y=(a-1)/cd;
 x-=y;
 ll ans=q+s-x;
 ll res=b-a+1-ans;
 cout<<res<<endl;

}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> N >> A;
	rep(x, N+1){
		rep(y, N+1-x){
			if(x*10000+y*5000+(N-x-y)*1000 == A){
				printf("%d %d %d", x, y, N-x-y);
				return 0;
			}
		}
		if(x == N && N*10000 == A) {
			printf("%d 0 0", N);
			return 0;
		}
	}
	printf("-1 -1 -1");
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
int n,p,q=2,nn,pp;
long long lcm=1;
int main(){
	while(cin>>n>>p){
		nn=n;pp=p;
		while(1){
			if(n%q==0&&p%q==0){
			n/=q;p/=q;lcm*=q;q=2;}else{
			q++;}
			if(q>n&&q>p){
			break;}

		}
			cout<<lcm<<" "<<nn/lcm*pp<<endl;
			q=2;lcm=1;
	}
    return 0;}


Measured memory_bytes: 1156
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

double a[N];

int main () {
    to_pray();

    int n;
    cin >> n;

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

    sort(a + 1, a + 1 + n);

    double cur = (int)a[1];

    for (int i = 2; i <= n; ++ i) {
        cur = (cur + a[i]) / 2;
    }

    cout << fixed << setprecision(8) << cur;

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
sx, sy , tx , ty = map(int , input().split())
dx = tx-sx
dy= ty-sy
now = ""
for i in range(0 ,dy):
	now= now+'U'
for i in range(0 , dx):
	now = now+'R'

for i in range(0 , dy):
	now = now+'D'
for i in range(0 , dx):
	now = now+'L'

now = now+'L'
for i in range(0 , dy+1):
	now = now+'U'
for i in range(0 , dx+1):
	now = now+'R'
now = now+'D'

now = now+'R'
for i in range(0 , dy+1):
	now = now+'D'
for i in range(0 , dx+1):
	now = now+'L'
now = now+'U'
print(now)



Measured memory_bytes: 72860
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const int INF=1e9+5;
int main()
{
	fast();
	int n;
	scanf("%d",&n);
	vector<int> h(n);
	for(int &x : h)
		scanf("%d",&x);
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j: {i+1,i+2})
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
	}
	printf("%d",dp[n-1]);
}

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

using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int sum = 0;
  int d = 0;
  for (int i = 0; i <= n; i++) {
    if (i == 0) {
      if (d <= x) sum++;
      continue;
    }
    int l;
    cin >> l;
    d = d + l;
    if (d <= x) sum++;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int answer = 360 / gcd(x, 360);
    System.out.println(answer);
  }
  static int gcd(int a, int b){
    if(b == 0){
      return a;
    }
    return gcd(b, a % b);
  }
}

Measured memory_bytes: 35844
n = gets.chomp.to_i
a = (1..150).map{|i|i}
combs = a.repeated_permutation(3).to_a

def hoge(x,y,z)
  x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
end

hash = {}
combs.each do |c|
  result = hoge(*c)
  hash[result] ? hash[result] += 1 : hash[result] = 1
end

n.times do |i|
  puts hash[i+1] ? hash[i+1] : 0
end

Measured memory_bytes: 203968
#include <iostream>
#include<cctype>
using namespace std;
int main(void){
    
    string s;
    getline(cin,s);
    
    for(int i=0;i<s.length();i++){
        if(islower(s[i])){
            s[i]=toupper(s[i]);
        }else if(isupper(s[i])){
            s[i]=tolower(s[i]);
        } 
    }
    cout << s << endl;
    
    
    
}



Measured memory_bytes: 3160
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define Spa putchar(32)
int read()
{
	int s=0,c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int a=read(),b=read(),c=read(),d=read();
	write((a-c)*(b-d));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    int i,j;
    for(i=1; i<=9; i++)
        for(j=1; j<=9; j++)
            cout << i << "x" << j << "=" << i*j << endl;
    return 0;
}

Measured memory_bytes: 3008
//ysh_gpta
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;


#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r)   //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)


#define repf(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define repfe(i,L,R) for (int i = L; i <= R; i++)
#define repb(i,L,R) for (int i = L; i > R; i--)
#define repbe(i,L,R) for (int i = L; i >= R; i--)


typedef long long ll;
#define cerr if(false)cerr
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second


#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}


vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll dp[100005][2];

vvi adj(100005);

void dfs(ll node,ll from){
    dp[node][0]=1;
    dp[node][1]=1;
    if(from!=-1 && adj[node].size()==1)
    return;
    repf(i,0,adj[node].size()){
        ll to = adj[node][i];
        if(to != from){
            dfs(to,node);
            dp[node][0] *= (dp[to][0]+dp[to][1])%MOD;
            dp[node][0] %= MOD;
            dp[node][1] *= dp[to][0];
            dp[node][1] %= MOD;
        }
    }
}

int main(){
    FastIO
    ll n;
    cin>>n;
    repf(i,0,n-1){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    memset(dp,-1,sizeof(dp));
    dfs(0,-1);
    cout<<(dp[0][0]+dp[0][1])%MOD;

    return 0;
}

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

//UnionFind
int n = 100000;
vector<int> par(n);
vector<int> size(n);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
    size.at(i) = 1;
  }
}

int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}

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

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if (size.at(x) < size.at(y)){
    swap(x, y);
  }
  size.at(x) += size.at(y);
  par.at(y) = x;
}

int size_x(int x){
  return size.at(root(x));
}


int main(){
  int64_t N, M, K;
  cin >> N >> M >> K;
  init(N);
  vector<int> minus(N,0);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    unite(a,b);
    minus.at(a)--;
    minus.at(b)--;
  }
  for(int i=0; i<K; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(same(a,b)){
      minus.at(a)--;
      minus.at(b)--;
    }
  }
  
  for(int i=0; i<N; i++){
    cout << max(0,size_x(i) + minus.at(i) - 1) << " ";
  }
  cout << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    int n, m; cin>>n>>m;
    ll sum = 0;
    rep(i, m)
    {
        int x; cin>>x;
        sum +=x ;
    }
    if(sum > n) cout<<-1;
    else cout<<n-sum;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3660
#include<iostream>


using namespace std;

int main(){
   int N;
   cin >> N;
   int sum =0;
   for(int i=0;i<N;i++){
      
      int l,r;
      cin >>l>>r;
      sum+=r-l+1;
      
   }
   
   cout<<sum<<endl;
}
  

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

int main(){
	ll N, M;
	cin >> N >> M;
	ll ans;
	if (N==1 && M==1) ans=0;
	else if (N==1 || M==1) ans = 2;
	else ans = 2*M+2*N-4; 
	ans = N*M - ans;
	cout << ans << endl;
	return 0;
}


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

typedef long long int lli;

int main(void){
    // Here your code !
    lli i,o,t,j,l,s,z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    
    
    lli a = (i/2)*4+(l/2)*4+(j/2)*4;
    
    lli b = ((i-1)/2)*4+((l-1)/2)*4+((j-1)/2)*4+6;
    
    if(i==0||j==0||l==0)b = 0;
    
    if(a%2==1){
        a-=3;
    }
    if(b%2==1){
        b-=3;
    }
    
    a/=2;
    b/=2;
    
    
    cout << max(
        a
        ,
        b
        ) + o << endl;
    
    
    
}


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

using namespace std;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

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

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;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


int main(void){
        int sx, sy, tx, ty;
        cin >> sx >> sy >> tx >> ty;
        const int dx = tx-sx, dy = ty-sy;

        cout << string(dy,'U') << string(dx,'R');

        cout << string(dy,'D') << string(dx,'L');

        cout << 'L' << string(dy+1,'U') << string(dx+1, 'R') << 'D';

        cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';

        cout << endl;
        return 0;
}















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

int main() {
  int H, W;
  cin >> H >>W;

  // N要素の配列
  string str;

  //上の枠
  for(int i=0; i<W+2; i++){
   cout << '#';}
  cout <<endl;
  
  // 中間部の表示
  for(int i =0; i < H; i++){
     cout << '#';
     cin >> str;
     cout << str;
     cout << '#' <<endl;
  }
  // 下の枠
  for(int i=0; i<W+2; i++){
   cout << '#';}
  cout <<endl;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using Real = double;
using Point = complex< Real >;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001LL;
constexpr double INF = 1e10;
constexpr Real EPS = 1e-10;
const Real PI = acos(-1);
using number = double;


int main() {
    int n; cin >> n;
    cout << (n - 1) / 2 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool has_key(T mp, U key) { return mp.find(key) != mp.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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        vector<vector<pll>> data(N);
        rep(i, 0, N) {
                cin >> A[i];
                rep(j, 0, A[i]) {
                        ll x, y;
                        cin >> x >> y;
                        data[i].push_back(pll{x, y});
                }
        }

        ll mx = -inf;
        rep(bit, 0, 1<<N) {
                vll choice;
                rep(i, 0, N) {
                        if (bit & (1<<i)) {
                                choice.push_back(i);
                        }
                }


                bool flg = true;
                rep(i, 0, len(choice)) {
                        ll c = choice[i];
                        rep(j, 0, len(data[c])) {
                                ll x = data[c][j].first;
                                ll y = data[c][j].second;

                                if (y == 1) {
                                        if (find(all(choice), x-1) == choice.end()) {
                                                flg = false;
                                        }
                                } else {
                                        if (find(all(choice), x-1) != choice.end()) {
                                                flg = false;
                                        }
                                }
                        }
                }

                if (flg) {
                                        //print1d(choice);
                        chmax(mx, len(choice));
                }
        }

        cout << mx << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  cout << ((N%2==0)?N:2*N)<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;

  string dream = "maerd", dreamer = "remaerd", erase = "esare",
         eraser = "resare";

  REVERSE(S);
  ll index = 0;
  while (index < (ll)S.size()) {
    string sub = S.substr(index, 5);

    if (sub == dream || sub == erase) {
      index += 5;
      continue;
    }

    sub = S.substr(index, 6);
    if (sub == eraser) {
      index += 6;
      continue;
    }

    sub = S.substr(index, 7);
    if (sub == dreamer) {
      index += 7;
      continue;
    }

    COUT("NO");
    return 0;
  }
  COUT("YES");

  return 0;
}

Measured memory_bytes: 3732
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for i in range(N - K + 1):
    l = x[i]
    r = x[i + K - 1]
    ans = min(ans, abs(l) + abs(r - l))
    ans = min(ans, abs(r) + abs(r - l))
print(ans)


Measured memory_bytes: 14384
#include <stdio.h>

int main() {
    long long a, b;
    char op; 
    scanf("%lld %c %lld", &a, &op, &b);
    if(op==43){
        printf("%lld\n",a+b);
    }else if(op==45){
        printf("%lld\n",a-b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  string a,b,c;
  cin>>a>>b>>c;
  int x=a.length();
  int y=b.length();
  int z=c.length();
  if(a[x-1]==b[0]&&b[y-1]==c[0])
  {
    YES
  }
 else
 {
   NO
 }

}
return 0;
}


Measured memory_bytes: 256
class UnionFindTree:
    __slots__ = ('__tree', '__current')

    def __init__(self, n):
        self.__tree = [-1] * n
        self.__current = iter(self.__tree)

    def find(self, x):
        t = self.__tree
        if t[x] < 0:
            return x
        root = self.find(t[x])
        t[x] = root
        return root

    def union(self, x, y):
        t = self.__tree
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if t[x] > t[y]:
            x, y = y, x
        t[x] += t[y]
        t[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.__tree[self.find(x)]

    def __next__(self):
        try:
            return next(self.__current)
        except StopIteration:
            self.__current = iter(self.__tree)
            raise StopIteration()

    def __iter__(self):
        return self


def spline(func_=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func_, iter_)


def main():
    n, m = spline()
    tree = UnionFindTree(n)
    for i in range(1, m + 1):
        x, y, _ = spline()
        x -= 1
        y -= 1
        tree.union(x, y)
    ans = 0
    for i in tree:
        if i < 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5428
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
const int MaxN = 1e5;

long long a[2 * MaxN + 5];

int main()
{
	long long n,x,ans,piu;
	while(~scanf("%lld",&n))
	{
		ans = 0;
		a[0] = 0;
		for(int i = 1;i <= n;i++)
		{
			scanf("%lld",&x);
			a[i] = a[i - 1] + x;
		}
		sort(a,a + 1 + n);
		piu = 1;
		for(int i = 1;i <= n;i++)
		{
			if(a[i] == a[i - 1]) piu++;
			else
			{
				ans += piu * (piu - 1) / 2;
				piu = 1;
			}
		}
		ans += piu * (piu - 1) / 2;
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main(int argc, const char * argv[])
{
    int n[5];
    for (int i = 0; i < 5; i++) {
        scanf("%d", &n[i]);
    }
    sort(&n[0], &n[5]);
    reverse(&n[0], &n[5]);
    
    for (int i = 0; i < 5; i++) {
        printf("%d", n[i]);
        if (i != 4) {
            printf(" ");
        }
    }
    puts("");
    
    return 0;
}

Measured memory_bytes: 1216
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    int ans = 0;
    for(int i = 0; i < a.length; i++){
      a[i] = Integer.parseInt(sc.next());
      ans = ans + a[i];
    }
    if(21 < ans){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}

Measured memory_bytes: 21844
from sys import stdin


def main():
    N = int(input())
    a_list = [int(x) for x in stdin.readline().rstrip().split()]
    a_set = set(a_list)

    if len(a_set) == 1:
        if sum(a_set) == 0:
            print("Yes")
        else:
            print("No")

    elif len(a_set) == 2:
        a_1, _2 = sorted(a_set)
        if a_1 == 0:
            if a_list.count(a_1) * 3 == N:
                print("Yes")
            else:
                print("No")
        else:
            print("No")

    elif len(a_set) == 3:
        a_1, a_2, a_3 = a_set
        if a_list.count(a_1) == a_list.count(a_2) and a_list.count(a_2) == a_list.count(a_3):
            if a_1 ^ a_2 == a_3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14212
#include<stdio.h>


int main(void){

    int Th,Ta,Ah,Aa;
    scanf("%d %d %d %d", &Th,&Ta,&Ah,&Aa);

    while(1){
        
        Ah -=Ta;
        if(Ah<=0){
            printf("Yes");
            break;
        }

        Th -=Aa;
        if(Th<=0){
            printf("No");
            break;
        }      
    }

    return 0;
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int A,B;cin>>A>>B;
    string S;cin>>S;
    cout<<(regex_match(S,regex("^\\d{"+to_string(A)+"}\\-\\d{"+to_string(B)+"}$"))?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main(){ 
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> cum(h+1, vector<int>(w+1,0));
  rep(i,h) rep(j,w) cum[i + 1][j + 1] = s[i][j] - '0';
  rep(i,h) rep(j,w) cum[i + 1][j + 1] += cum[i + 1][j] + cum[i][j + 1] - cum[i][j]; 
  int n = (h - 1);
  int res = INF;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> cut;
    for (int i = 0; i < n; i++) if (bit & (1 << i)) cut.emplace_back(i + 1);
    cut.emplace_back(h);

    int cnt = __builtin_popcount(bit);
    int prew = 0;
    bool ok = true;

    for (int j = 1; j <= w; j++) {
      int preh = 0;
      int now = 0;

      for (auto i : cut) {
        int tmp = cum[i][j] - cum[preh][j] - cum[i][prew] + cum[preh][prew];
        now = max(tmp, now);
        preh = i;
      }

      if (now  > k) {
        if (j == 1) {
          ok = false; 
          break;
        }
        prew = j - 1;
        j--;
        cnt++;
      }
    }
    int now = 0;
    int preh = 0;
    for (auto i : cut) {
      int tmp = cum[i][w] - cum[preh][w] - cum[i][prew] + cum[preh][prew];
      now = max(tmp, now);
      preh = i;
    }
    if (now > k) ok = false;
    if (ok) res = min(res, cnt);
  }
  cout << res << endl;
  return 0;
} 

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int r, c = a[0];
    r = a.back();
    for (int i = 0; i < n - 1; i++) {
        int tmp = min(a[i], a.back() - a[i]);
        if (min(c, a.back() - c) < tmp) {
            c = a[i];
        }
    }
    cout << r << " " << c << endl;
    return 0;
}

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

int main(){
	int H, W, i, j;
	 
	while(1){
		cin>>H>>W;
			
		if(H == 0 && W == 0) break;
		 
		for(i = 1; i <= H; i++){
			for(j = 1; j <= W; j++){
				if((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) cout<<".";
				else cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


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

void Swap(int *x, int *y);

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

    long long int ans=0;
    int minusNum=0;

    for(int i=0;i<n;i++){
        if(a[i]<0){
            minusNum++;
            a[i]*=-1;
        }
    }
    
    int small=a[0];
    for(int i=0;i<n;i++){
        ans+=a[i];
        small=min(small,a[i]);
    }

    if(minusNum %2 !=0)ans-=small*2;


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


void Swap(int *x,int *y){
    int i=*x;
    *x=*y;
    *y=i;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
using namespace std;

int main(){
	int n; cin >> n;
	while(n--){
	double x[3] = {};
	double y[3] = {};

	for(int i=0; i<3; i++)
		cin >> x[i] >> y[i];

	double a,b,c,d,e,f;
	a = x[1] - x[0];
	b = y[1] - y[0];
	c = x[2] - x[0];
	d = y[2] - y[0];
	e = (-pow(x[0],2.0)+pow(x[1],2.0)-pow(y[0],2.0)+pow(y[1],2.0))/2;
	f = (-pow(x[0],2.0)+pow(x[2],2.0)-pow(y[0],2.0)+pow(y[2],2.0))/2;

	double Xo = (d*e-b*f)/(a*d-b*c);
	double Yo;
	if(b != 0)
		Yo=(e-a*Xo)/b;
	else
		Yo=(f-c*Xo)/d;

	cout << fixed;
	cout << setprecision(3) << Xo << " " << Yo << " " << sqrt(pow(Xo-x[0],2.0)+pow(Yo-y[0],2.0)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val s = scala.io.StdIn.readLine
  var cnt = 0
  (1 until n).foreach { x =>
    val s1 = s.take(x).toCharArray.toSet
    val s2 = s.takeRight(n - x).toCharArray.toSet
    cnt = List((s1 intersect s2).toList.size, cnt).max
  }
  println(cnt)
}


Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C >> D;
    REP(i, 101) {
        if (A < i && i <= B && C < i && i <= D) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
from collections import Counter
N=int(input())

s=input().split()
c=Counter(s)
count=0
for i in c:
    if int(i)>c[str(i)]:
        count+=int(c[str(i)])
    elif int(i)<c[str(i)]:
        count+=int(c[str(i)])-int(i)
    else:
        continue
print(count)

Measured memory_bytes: 20848
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
//↓強連結成分分解
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef vector<bool> vb;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
struct Edge {
	int from, to, cost;
};
using Graph = vector<vector<Edge>>;
 
class SCCD {
public:
	stack<int> post;
	vb used;
 
	void dfs(int pos, int par, const Graph &G) {
		used[pos] = true;
		rep(i, G[pos].size()) {
			int to = G[pos][i].to;
			if (used[to])continue;
			dfs(to, pos, G);
		}
		post.push(pos);
	}
 
	void dfsrev(int pos, int par, const Graph &rev, vi &group) {
		used[pos] = true;
		group.push_back(pos);
		rep(i, rev[pos].size()) {
			int to = rev[pos][i].to;
			if (used[to])continue;
			dfsrev(to, pos, rev, group);
		}
	}
 
	Graph SCC(Graph G, vvi &scc, vi &n2g) {
		int N = G.size();
		Graph rev(N);
		rep(i, N) {
			rep(j, G[i].size()) {
				Edge e = G[i][j];
				rev[e.to].push_back(Edge{ e.to,e.from,1 });
			}
		}
 
		used = vb(N, false);
		rep(i, N) {
			if (!used[i])dfs(i, -1, G);
		}
 
		fill(all(used), false);
		while (!post.empty()) {
			int pos = post.top();
			post.pop();
			if (used[pos])continue;
			vi group;
			dfsrev(pos, -1, rev, group);
			scc.push_back(group);
		}
 
		rep(i, scc.size()) {
			rep(j, scc[i].size()) {
				n2g[scc[i][j]] = i;
			}
		}
 
		Graph dag(scc.size());
		set<pair<int, int>> usedEdges;
 
		rep(i, N) {
			rep(j, G[i].size()) {
				Edge e = G[i][j];
				int s = n2g[e.from];
				int t = n2g[e.to];
				if (usedEdges.find(mp(s, t)) == usedEdges.end() && s != t) {
					dag[t].push_back(Edge{ t,s,1 });
					usedEdges.insert(mp(s, t));
				}
			}
		}
 
		return dag;
	}
};
//↑強連結成分分解
int main(){
	int N,M;
	cin>>N>>M;
	Graph G(N);
	for(int i=0;i<M;i++){
		int s,t;
		cin>>s>>t;
		G[s].pb(Edge{s,t,1});
	}
	vector<vint> scc;
	vint n2g(N);
	SCCD sccd;
	Graph dagr=sccd.SCC(G,scc,n2g);
	int Q;
	cin>>Q;
	int seibun[SIZE];
	for(int i=0;i<scc.size();i++)
		for(int j=0;j<scc[i].size();j++)
			seibun[scc[i][j]]=i;
	for(int i=0;i<Q;i++){
		int a,b;
		cin>>a>>b;
		cout<<(seibun[a]==seibun[b])<<endl;
	}
	return 0;
}


Measured memory_bytes: 4964
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

class Edge {
    int to;
    int cost;

    Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

class Pair implements Comparable<Pair> {
    int dist;
    int index;

    Pair(int dist, int index) {
        this.dist = dist;
        this.index = index;
    }

    public int compareTo(Pair p2) {
        return dist - p2.dist;
    }
}
 
public class Main {
    static final int INF = 2000000000;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();

        int res = 0;
        int[] coin = {1, 5, 10, 25};
        for(int i = coin.length - 1; i >= 0; i--) {
            res += n / coin[i];
            n %= coin[i];
        }

        System.out.println(res);
 
        sc.close();
    }
}



Measured memory_bytes: 26372
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 200005
int main()
{
    int a,b,c,x;
    in3(a,b,c);
    x=min(c,a-b);
    out(c-x);

}





Measured memory_bytes: 384
def div(n): 
    div =[] 
    for i in range(1,int(n ** 0.5) + 1): 
        if n % i == 0: 
            div.append(i) 
            if not n // i in div: 
                div.append(n // i)
    return div

n = int(input())
ans = 0 
d =div(n) 
for d in d:
    if d != 1:
        q,mod = divmod(n,d-1)

        if q == mod: 
            ans += d - 1 
print(ans)

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    if(n%2==0){
        n/=2;
        cout<<min({d*n,s*2*n,h*4*n,q*8*n})<<endl;
    }
    else{
        int x=n/2;
        ll ans=0;
        ans+=min({d*x,s*2*x,h*4*x,q*8*x});
        ans+=min({s,2*h,4*q});
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;


int main() {
    int n = 0, a = 0, b = 0;
    cin >> n >> a >> b;
    int diff = b - a - 1;
    if (diff == 0) {
        cout << "Borys" << endl;
    }
    else {
        if (diff%2 == 1) {
            cout << "Alice" << endl;
        }
        else {
            cout << "Borys" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//agc046_a.cpp
//Sat Jul 11 10:01:31 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

//最大公倍数、最大公約数（ユークリッド互除法）
ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll lcm (ll a, ll b){ //最小公倍数
	ll temp = gcd(a,b);
	return (a/temp)*b;
}


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

	int ans = lcm(n,360);


	cout << ans/n << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3620
import java.util.*

data class Edge(val from: Int, val to: Int, val delta: Long)

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map(String::toInt)
  val graph = Array(n, { mutableListOf<Edge>() })
  repeat(m) {
    val (lRaw, rRaw, dInt) = readLine()!!.split(" ").map(String::toInt)
    val l = lRaw - 1
    val r = rRaw - 1
    val d = dInt.toLong()
    graph[l].add(Edge(l, r, d))
    graph[r].add(Edge(r, l, -d))
  }

  val values = LongArray(n)
  val visited = BooleanArray(n)

  fun dfs(s: Int): Boolean {
    val stack = Stack<Int>()
    stack.push(s)
    visited[s] = true
    while (stack.isNotEmpty()) {
      val v = stack.pop()!!
      for (e in graph[v]) {
        val u = e.to
        if (visited[u]) {
          if (values[u] != values[v] + e.delta) {
            return false
          }
        } else {
          stack.push(u)
          visited[u] = true
          values[u] = values[v] + e.delta
        }
      }
    }
    return true
  }

  var ans = true
  for (s in 0 until n) {
    if (!visited[s]) {
      if (!dfs(s)) {
        ans = false
        break
      }
    }
  }
  println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 105360
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var rgb = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var num = rgb[0]*100 + rgb[1]*10 + rgb[2];

            Console.WriteLine(num%4==0?"YES":"NO");
        }
    }
}


Measured memory_bytes: 13268