akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>

using std::multiset;
using std::tuple;
using std::vector;
using std::unordered_map;

struct Block
{
	int S;
	int T;
	int X;
};

vector<int> Solve(int N, int Q, const vector<Block> &blocks, const vector<int> &D)
{
	vector<tuple<int, int, int>> events;
	for (const auto &b : blocks)
	{
		events.push_back(std::make_tuple(b.S - b.X, 0, b.X));
		events.push_back(std::make_tuple(b.T - b.X, 1, b.X));
	}
	for (int d : D)
	{
		events.push_back(std::make_tuple(d, 2, 0));
	}
	std::sort(events.begin(), events.end());
	
	multiset<int> set;
	std::vector<int> ans;
	for (const auto &e : events)
	{
		int t = std::get<2>(e);
		switch (std::get<1>(e))
		{
		case 0:
			set.emplace(t);
			break;
		case 1:
			set.erase(set.find(t));
			break;
		case 2:
			ans.push_back((set.size() > 0) ? *set.begin() : -1);
			break;
		}
	}
	return ans;
}

int main(int argc, char *argv[])
{
	int	N, Q;
	std::cin >> N >> Q;
	vector<Block> blocks(N);
	for (int i = 0; i < N; ++i)
	{
		auto &b = blocks[i];
		std::cin >> b.S >> b.T >> b.X;
	}
	vector<int> D(Q);
	for (int i = 0; i < Q; ++i)
	{
		std::cin >> D[i];
	}
	for (int ans : Solve(N, Q, blocks, D))
	{
		std::cout << ans << std::endl;
	}
	return 0;
}


Measured memory_bytes: 23528
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	int x, a;
	cin >> x >> a;
	if (x < a){
		cout << 0 << endl;
	}
	else if (x >= a){
		cout << 10 << endl;
	}
	return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){
    int h, w;
    cin >> h >> w;
    array<bitset<601>, 601> v;
    vector<pair<int,int>> p;
    for(int i = 0; i < h; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < w; ++j)
            if(s[j] == '#'){
                v[i + j].set(i - j + 300);
                p.emplace_back(i + j, i - j + 300);
            }
    }

    vector<vector<int>> r(602, vector<int>(602));
    for(int i = 0; i < 601; ++i)
        for(int j = 0; j < 601; ++j)
            r[i + 1][j + 1] = v[i][j];
    for(int i = 0; i < 602; ++i)
        for(int j = 1; j < 602; ++j)
            r[i][j] += r[i][j - 1];
    for(int j = 0; j < 602; ++j)
        for(int i = 1; i < 602; ++i)
            r[i][j] += r[i - 1][j];

    i64 ans = 0;

    for(auto& elm : p){
        int x, y;
        tie(x, y) = elm;
        for(int d = 1; d <= 600; ++d){
            if(x + d <= 600 && y + d <= 600 && v[x + d][y])
                ans += r[x + 1][y + d] + r[x + d + 1][y + d + 1] - r[x + 1][y + d + 1] - r[x + d + 1][y + d];
            if(x + d <= 600 && y - d >= 0 && v[x + d][y])
                ans += r[x][y - d] + r[x + d][y - d + 1] - r[x][y - d + 1] - r[x + d][y - d];

            if(y + d <= 600 && x + d <= 600 && v[x][y + d])
                ans += r[x + d][y] + r[x + d + 1][y + d] - r[x + d][y + d] - r[x + d + 1][y];
            if(y + d <= 600 && x - d >= 0 && v[x][y + d])
                ans += r[x - d][y + 1] + r[x - d + 1][y + d + 1] - r[x - d][y + d + 1] - r[x - d + 1][y + 1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n; cin >> n;
   	vector<string> s(n);
  	for(int i=0; i<n; i++) cin >> s[i];
                                    
   vector<multiset<char> > sset(n);
    for(int i=0; i<n; i++) {
      for(auto x : s[i]) {
        sset[i].insert(x);
      }
    }
	multiset<char> ans; 
 	set<char> tmp;
  for(auto x:sset[0] ) tmp.insert(x);
  	for(auto x : tmp) {
      int f = sset[0].count(x);
      for(int i=1;i<n; i++) 
        f = min((int)sset[i].count(x),f);
      for(int i=0;i<f;i++)
        ans.insert(x);
    }
	for(auto x : ans) cout << x;
  	cout << endl;
}

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

int main(){
    string N;
    cin >> N;
    for (char n : N) n == '1' ? (cout << '9') : (cout << '1');
    cout << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }

    val cords = mutableListOf<IntArray>()

    for (i in 0 until n) {
        val cord = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
        cords.add(cord)
    }


    var cnt = 0
    for (i in 0 until cords.size - 1) {
        for (j in i+1 until cords.size) {

            var sum = 0
            for ( k in 0 until d) {
                sum += (cords[i][k] - cords[j][k]) * (cords[i][k] - cords[j][k])
            }

            val dist = Math.sqrt(sum.toDouble())

            if(dist == dist.toInt().toDouble()) {
               cnt += 1
            }
        }
    }

    println(cnt)
}

Measured memory_bytes: 38124
#include <bits/stdc++.h>
using namespace std;
int N,X,Y;
int cnt[2020];

int main(){
  cin>>N>>X>>Y;
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      cnt[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  for(int k=1;k<N;k++)cout<<cnt[k]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n = 0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '+') {
			n++;
		}
		else {
			n--;
		}
	}
	cout << n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n;
 cin >> n;
 map<string,ll> m;
 for(ll i=0;i<n;i++){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  m[s]++;
 }
 ll ans=0;
 for(auto p:m){
  ll x=p.second;
  ans+=x*(x-1)/2;
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i = 1; i < N; i++){
    if((N-i)/i <= i) break;
    if((N-i) % i == 0) ans += (N-i)/i;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
  	int N;
  	cin >> N;
  	vector<long long> L(N);
  	for(int i=0;i<N;i++) cin >> L[i];
  	sort(L.begin(), L.end());
    int counter = 0;
  	for(int i=0;i<N;i++){
      	for(int j=0;j<i;j++){
          	if(L[i] == L[j]) continue;
          	for(int k=0;k<j;k++){
              	if(L[j] == L[k]) continue;
              	if(L[i] < L[j] + L[k]) counter++;
            }
        }
    }
  	cout << counter << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int INF = 1e9;

int main(){
	int n;
	int s[100];
	
	
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		int sum = 0;
		int avg = 0;
		int min = INF;
		int max = 0;
		for(int i = 0;i < n;i++){
			scanf("%d",&s[i]);
			sum += s[i];
			if(max < s[i]) {max = s[i];}
			if(min > s[i]) {min = s[i];}
		}
		sum = sum - min - max;
		avg = sum / (n - 2);
		printf("%d\n", avg);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[114];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, b[114];
	cin>>n;
	FOR(i, 1, n+1){
		cin>>b[i];
	}
	vi ans;
	FORR(i, 1, n+1){
		int cnt=1, cand=-1;
		FOR(j, 1, n+1){
			if(used[j]){
				continue;
			}
			if(cnt==b[j]){
				cand=j;
			}
			++cnt;
		}
		if(cand==-1){
			cout<<-1<<'\n';
			return 0;
		}
		ans.push_back(b[cand]);
		used[cand]=true;
	}
	FORR(i, 0, n){
		cout<<ans[i]<<'\n';
	}
	return 0;
}


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

#define N 20
#define UL ( INT_MAX >> 1 )
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )

static int d[ N ][ N ];
static int n;

static int jintan[ N ] = { 0 };

static int
FSA (
  int p,
  int t
  )
{
  int res = UL;
  int i;

  if ( p == t )       return ( 0 );
  if ( jintan[ p ] )  return ( UL );

  jintan[ p ] = 1;

  for ( i = 0; i < n; ++i )
  {
    int tmp;

    if ( d[ p ][ i ] == -1 ) continue ;

    tmp = FSA ( i, t ) + d[ p ][ i ];
    res = MIN( res, tmp );
  }

  jintan[ p ] = 0;

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int m, x1, x2, y1, y2;
  int res;

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

  memset ( d, -1, sizeof ( d ) );
  while ( m-- )
  {
    int a, b, c1, c2;

    scanf ( " %d,%d,%d,%d", &a, &b, &c1, &c2 );
    d[ a - 1 ][ b - 1 ] = c1;
    d[ b - 1 ][ a - 1 ] = c2;
  }
  scanf ( " %d,%d,%d,%d", &x1, &x2, &y1, &y2 );

  res  = FSA ( x1 - 1, x2 - 1 );
  res += FSA ( x2 - 1, x1 - 1 );

  printf ( "%d\n", y1 - y2 - res );

  return ( 0 );
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define MAX 200000000000

int main() {
  long long n,k,res;
  scanf("%llu %llu", &n, &k);
  long long div;

  if (k%2 != 0) {
    div = n/k;
    res = div*div*div;
  } else {
    div = n/(k/2);
    if (div%2 == 0) {
      res = (div/2)*(div/2)*(div/2)*2;
    } else {
      res = (div/2+1)*(div/2+1)*(div/2+1)+(div/2)*(div/2)*(div/2);
    }

  }

  printf("%llu\n", res);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, k, ans = 0;
    string s;

    cin >> n >> k >> s;

    for (int i = 0; i < n; i++) {

        if (s[i] == 'L' && i && s[i-1] == 'L') ans++;
        if (s[i] == 'R' && i < n-1 && s[i+1] == 'R') ans++;
    }

    cout << min(n-1, ans+2*k);

    return 0;
}


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

int solve() {
    int N, T = 0;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        T += A[i];
    }
    bitset<4000001> dp;
    dp.set(0);
    for ( int i = 0; i < N; i++ ) {
        dp |= (dp << A[i]);
    }
    int h = (T+1)/2;
    while ( h <= T && dp[h] == 0 ) h++;
    return h;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long i,j;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	long long t,k;
	cin >> t>>k;
	if(500*t>=k) cout <<"Yes";
	else cout << "No";
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
  
     char A = toupper(a[0]);
     char B = toupper(b[0]);
     char C = toupper(c[0]);

    cout << A << B << C << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;++i){
    cin>>d.at(i);
  }
    sort(d.begin(),d.end());
    cout<<d.at(N/2)-d.at(N/2-1)<<endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    char c;
    cin>>c;
    c++;
    cout<<c el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> r(n+1,0);
  rep(i,n) r[i+1] = r[i]+a[i];
  map<ll,ll> mp;
  ll ans=0;
  rep(i,n+1){
    mp[r[i]]++;
  }
  for(auto it:mp)if(it.S!=1){
    ans += it.S*(it.S-1)/2;
  }
  cout << ans << endl;  
  return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
{ int temp=INT_MAX;
for(int j=i-1;j>=0 && i-j<=k;j--)
	{int x=dp[j]+abs(arr[i]-arr[j]);
	if(x<temp)
	temp=x;
}
dp[i]=temp;}
 //for(int i=0;i<n;i++)
 //cout<<dp[i]<<" ";
// cout<<endl;
cout<<dp[n-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		Integer[] B = new Integer[N];
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			A[i] = a;
			B[i] = a;
		}
		
		Arrays.sort(B, Comparator.reverseOrder());
		int max = B[0];
		int secMax = B[1];
		
		for(int i=0;i<N;i++) {
			int skipInt = A[i];
			if(max != skipInt) {
				System.out.println(max);
			}else {
				System.out.println(secMax);
			}
		}
		
		sc.close();	
	}
}

Measured memory_bytes: 95716
#include<iostream>
#include<math.h>
using namespace std;

int gcd( int x,  int y) {
	if (x < y) {
		return gcd(y, x);
	}
	else if (x>=y&&x%y != 0) {
		return gcd(x%y, y);
	}
	else { return y; }
}
int main() {
	long long int x, y;
	cin >> x >> y;
	cout<<gcd(x, y)<<endl;
	return 0;
	

}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int a,b; cin>>a>>b;
    int ans=0;
    if(a<=b) ans=a;
    else ans=a-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<vector<ll>>memo(n,vector<ll>(n+1,-1e18));
  function<ll(ll,ll,bool)>dfs=[&](ll l,ll r,bool f){
    ll res;
    if(memo[l][r]>-1e18)return memo[l][r];
    if(r-l==1){
      if(f)return memo[l][r]=a[l];
      return memo[l][r]=-a[l];
    }
    if(f){//maximize
      res=-1e18;
      chmax(res,dfs(l,r-1,!f)+a[r-1]);
      chmax(res,dfs(l+1,r,!f)+a[l]);
    }
    else{
      res=1e18;
      chmin(res,dfs(l,r-1,!f)-a[r-1]);
      chmin(res,dfs(l+1,r,!f)-a[l]);
    }
    return memo[l][r]=res;
  };
  cout<<dfs(0,n,1)<<endl;

  return 0;

}


Measured memory_bytes: 72704
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int M = nextInt();
		String S = nextString();
		String T = nextString();
		long ans=lcm((long)N,(long)M);

		int gcd=(int)gcd((long)N,(long)M);
		for(int i=0;i<gcd;i++){
			if(S.charAt((N/gcd)*i)!=T.charAt((M/gcd)*i)){
				ans=-1;
				break;
			}
		}

		System.out.println(ans);

	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

public static long lcm(long a, long b) {
	long x, y;

	return ((a/gcd(a,b))*b);
}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 23892
#include <iostream>
using namespace std;
int main(void){
    int n;
    float x,ans;
    string u;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>x>>u;
        if (u=="JPY"){
            ans+=x;
        }
        else{
            ans+=x*380000.0;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	ll N; cin >> N;

	vector<int> p;

	while(N > 0){
		N--;
		p.push_back(N%26);
		N /= 26;
	}

	reverse(all(p));

	REP(i,p.size()) cout << (char)(p[i] + 'a');
	cout << endl;

	return 0;

}


Measured memory_bytes: 3592
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a;
    int N;
    string str;
    while(1){
        cin>>a;
        if(a==0)break;
        cin>>N;
        cin>>str;
        int ans=0;
        char bef;
        int L=0;
        for(int i=0;i<=N;i++){
            if(i==0){
                if(str[i]=='I')L=1;
                if(str[i]=='O')L=0;
                bef=str[i];
            }
            else if(i==N){
                ans+=max(0,((L-1)/2)-(a-1));
                break;
            }
            else{
                if(bef!=str[i])L++;
                else{
                    ans+=max(0,((L-1)/2)-(a-1));
                    if(str[i]=='I')L=1;
                    if(str[i]=='O')L=0;
                }
                bef=str[i];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2104
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let mut n = iter.next().unwrap().parse::<usize>().unwrap();
    let p_vec = iter.map(|e| e.parse::<usize>().unwrap()).collect::<Vec<usize>>();

    let mut ans = 0_usize;
    for &p in &p_vec {
        if p <= n {
            ans += 1;
            n = p;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [None] * len(A)
    X[0] = sum(A) - 2 * sum([A[i] for i in range(1, len(A), 2)])
    for i in range(len(A)-1):
        X[i+1] = 2 * A[i] - X[i]
    
    print(' '.join(list(map(str, X))))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 19144
K = int(input())
cur = 7
count = 1
digit = 10
X = K
if X % 2 == 0 or X % 5 == 0 :
    print(-1)
else:
    while cur % K != 0:
        count += 1
        cur += 7*digit
        digit = (digit*10)%K
    print(count)


Measured memory_bytes: 63112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
  	int a,z;
  	cin>>s;
  	for(int i=0;i<s.size();i++){
   	 	if(s[i]=='A'){
      		a=i;
      		break;
    	}
  	}
  	for(int i=s.size()-1;i>=0;i--){
    	if(s[i]=='Z'){
    	  z=i;
    	  break;
    	}
  	}
    cout << z-a+1 << endl;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 1;i<=9;i++) {
			for(int j = 1;j<=9;j++) {
				if(j*i==N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");

	}

}


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

using namespace std;

int main(){
    int n1,n2,b,e;
    cin >> n1;
    vector<int>a(n1);
    for(int i = 0;i < n1;++i){
        cin >> a[i];
    }
    
    cin >> n2;
    for(int i = 0;i < n2;++i){
        cin >> b >> e;
        reverse(a.begin() + b,a.begin() + e);
    }
    for(int i = 0;i < n1;++i){
        cout << a[i];
        if(i + 1 < n1){
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3116
n, m = map(int, input().split())
L_max, R_min = map(int, input().split())
for i in range(m-1):
    L, R = map(int, input().split())
    L_max = max(L_max, L)
    R_min = min(R_min, R)

print(max(R_min - L_max + 1, 0))

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  int ans[N+1];
  for(int i=0;i<=N;++i) ans[i] = 0;
  for(int i=0;i<N;++i) {
    cin>>ans[i];
  }
  int next[N+1];
  bool fin;
  for(int i=0;i<K;++i) {
    for(int j=0;j<=N;++j) next[j] = 0;
    for(int j=0;j<N;++j) {
      next[max(0, j-ans[j])]++;
      next[min(N, j+ans[j]+1)]--;
    }
    for(int j=1;j<=N;++j) next[j] += next[j-1];
    for(int j=0;j<=N;++j) ans[j] = next[j];
    fin = true;
    for(int j=0;j<N;++j) {
      if(ans[j]<N) fin = false;
    }
    if(fin) break;
  }
  for(int i=0;i<N;++i) cout<<ans[i]<<" ";
  cout<<endl;
}



Measured memory_bytes: 5108
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

string S;
bool flag = true;

int main() {
	cin >> S;
	int L = S.length();
	for (int i = 1; i < L; i++) {
		if (S[i - 1] == S[i]) flag = false;
	}
	if (flag) cout << "Good" << endl;
	else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////
#define int long long

void solve(){

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

	int ans = 0;

	for(int i = 0 ; i < k ; ++i)
		ans += a[i];

	cout<<ans<<endl;

}

signed main(){

	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

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

const long long inf = 1e18;

struct Task {
	int n;
	vector<vector<int> > g;
	vector<int> a, f;

	Task(int n): n(n), a(n), f(n), g(n) {
		for (auto& item : a) {
			cin >> item;
		}
		for (int i = 0; i < n - 1; ++i) {
			int x, y;
			cin >> x >> y;
			--x; --y;
			g[x].push_back(y);
			g[y].push_back(x);
		}
	}

	void dfs(int v, int pr = -1) {
		f[v] = 0;
		for (auto& to : g[v]) {
			if (to == pr || a[to] >= a[v]) {
				continue;
			}
			dfs(to, v);
			if (!f[to]) {
				f[v] = 1;
				break;
			}
		}
	}

	void run() {
		for (int root = 0; root < n; ++root) {
			dfs(root);
			if (f[root]) {
				cout << root+1 << ' ';
			}
		}
		cout << '\n';
	}
};

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

	int n;
	cin >> n;

	Task a(n);
	a.run();

	return 0;
}

Measured memory_bytes: 512
num_1 , num_2 , num_3 = input().split()
num_1 = int(num_1)
num_2 = int(num_2)
num_3 = int(num_3)
num_list = [num_1 , num_2 , num_3]
num_list.sort()
if (num_1 % 2 == 0) or (num_2 % 2 == 0) or (num_3 % 2 == 0):
    difference = 0
else:
    difference = num_list[0] * num_list[1]

print(difference)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5050, mod = 1e9 + 7;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &i : a) cin >> i;
	int ans = 0;
	for(auto i : a)
		for(auto j : a)
			for(auto k : a) {
				if(i == k || i == j || k == j) continue;
				int s = i+j+k;
				if(s-max({i, j, k}) > max({i, j, k})) ans++;
			}
			cout << ans/6 << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#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;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
class union_find {
private:
    vector<int> parent;
public:
    union_find(int n) : parent(n, -1) {}
    ~union_find() {}
    void link(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (parent[x] > parent[y])
            swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
    }
    int find(int x) {
        if (parent[x] < 0)
            return x;
        return parent[x] = find(parent[x]);
    }
    int count(int x) {
        return -parent[find(x)];
    }
    bool linked(int x, int y) {
        return find(x) == find(y);
    }
};

int main()
{
    int N, M, K; cin >>N>>M>>K;
    union_find uf(N);
    vector<int> ans(N, 0);
    rep(i, M) {
        int a, b; cin >> a >> b; a--; b--;
        uf.link(a, b);
        ans[a]--;
        ans[b]--;
    }
    rep(i, N) {
        ans[i] = ans[i] + uf.count(i)-1;
    }
    rep(i, K) {
        int c, d; cin >> c >> d; c--; d--;
        if (uf.linked(c, d)) {
            if (ans[c] > 0) ans[c]--;
            if (ans[d] > 0) ans[d]--;
        }

    }
    cout_h(ans);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll x,y;
    cin >> x;
    x -= (x%5);
    y = x - (x%500);
    cout << y*2+(x-y) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LinkedList<Integer> e = new LinkedList<>();
        long each;
        Object[] disinct;

        for(int i = 0; i < 12; i++) {
            e.add(sc.nextInt());
        }

        if(e.stream().distinct().count() > 3) {
            System.out.println("no");
            return;
        }
        Collections.sort(e);
        disinct = e.stream().distinct().toArray();
        for(Object a : disinct) {
            each = e.stream().filter(i -> i == a).count();
            if(each != 4 && each != 8 && each != 12) {
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 32148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();

            int[] p = new int[N];

            for (int i = 0; i < N; i++)
            {
                p[i] = cin.nextInt();
            }

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                var now = p[i];
                var expect = i + 1;

                if(now != expect)
                {
                    count++;
                }
            }

            Console.WriteLine(count <= 2 ? "YES" : "NO");
        }
    }





    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int m, k;
	cin >> m >> k;
	int p = pow(2, m);
	if (k >= p) {
		printf("%d\n", -1);
		return 0;
	}
	p--;
	vector<int> vec;
	while (p > -1) {
		if (p == k) {
			p--;
			continue;
		}
		vec.push_back(p);
		p--;
	}
	if (m <= 1) {
		if (m == 0) {
			if (k == 0) printf("%d %d\n", 0, 0);
			else printf("%d\n", -1);
		}
		else {
			if (k == 0) printf("%d %d %d %d\n", 0, 0, 1, 1);
			else printf("%d\n", -1);
		}
		return 0;
	}
	vector<int> rec = vec;
	reverse(all(rec));
	for (int c : vec) cout << c << ' ';
	cout << k << ' ';
	for (int c : rec) cout << c << ' ';
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 2936
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    REP(i, N) cin >> W[i];
    int ans = 11000;
    for(int i = 1; i < N; i++) {
        int sum1 = 0;
        int sum2 = 0;
        for(int j = 0; j < i; j++) {
            sum1 += W[j];
        }
        for(int k = i; k < N; k++) {
            sum2 += W[k];
        }
        chmin(ans,abs(sum1-sum2));
    }
    cout << ans << endl;
}

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

typedef long long ll;
int N;
ll T[100010]={0},A[100010]={0},R[100010];
ll inf = 1e9+7;

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> T[i];
	}
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	R[1] = 1;
	R[N] = 1;
	bool judge = true;
	ll ans = 1;
	if(T[N]!=A[1]) judge = false;
	else{
		for(int i=1;i<=N;i++){
			if(T[i]>T[i-1] || A[i]>A[i+1]){
				R[i] = 1;
				if(T[i]>T[i-1] && (T[i]>A[i+1] && T[i]!=A[i])) judge = false;
				if(A[i]>A[i+1] && (A[i]>T[i-1] && T[i]!=A[i])) judge = false;
			}
			else R[i] = min(A[i],T[i]);
			ans = (ans*R[i])%inf;
		}
	}
	if(!judge) cout << 0 << endl;
	else cout << ans << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s, t; std::cin >> s >> t;
  int pos = -1;
  int slen = s.size(), tlen = t.size();
  auto check = [&](int offset) {
    bool ok = true;
    rep(i, tlen) {
      if (s[i+offset] != t[i] && s[i+offset] != '?')
        ok = false;
    }
    return ok;
  };
  rep(i, slen-tlen+1) {
    if (check(i)) pos = i;
  }
  rep(i, tlen) s[i+pos] = t[i];
  rep(i, slen) if (s[i] == '?') s[i] = 'a';
  std::cout << (pos == -1 ? "UNRESTORABLE" : s) << "\n";
}


Measured memory_bytes: 256
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

n,k  = Ri()
s = set([i+1 for i in range(0,n)])
for i in range(k):
    val = int(ri())
    temp  = Ri()
    for j in temp:
        if j in s:
            s.remove(j)
print(len(s))



Measured memory_bytes: 67728
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

char s[N];

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d%s", &n, &s);
        int cnt = 0;
        for(int i = 0; i < n; i++) cnt += (s[i] == 'R');
        int ans = 0;
        for(int i = 0; i < cnt; i++) ans += (s[i] == 'W');
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3948
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

const N_MAX: usize = 500;

static mut costs: [i32; (N_MAX + 2) * (N_MAX + 2)] =
    [0; (N_MAX + 2) * (N_MAX + 2)];
static mut exited: [bool; (N_MAX + 2) * (N_MAX + 2)] =
    [false; (N_MAX + 2) * (N_MAX + 2)];
static mut queue: [usize; N_MAX * N_MAX] = [0; N_MAX * N_MAX];

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        ps: [Usize1; n * n],
    }

    let mut ans = 0;

    unsafe {
        for x in 1..=n {
            for y in 1..=n {
                costs[x * (n + 2) + y] =
                    min(min(x - 1, n - x), min(y - 1, n - y)) as i32;
            }
        }

        for p in ps {
            let x = p / n;
            let y = p % n;
            let p = (x + 1) * (n + 2) + (y + 1);

            exited[p] = true;
            ans += costs[p];

            let mut nelem = 1;
            queue[0] = p;

            while nelem > 0 {
                nelem -= 1;
                let p1 = queue[nelem];

                let c = costs[p1] + if exited[p1] { 0 } else { 1 };
                for &p2 in &[p1 - 1, p1 + 1, p1 - (n + 2), p1 + (n + 2)] {
                    if costs[p2] > c {
                        costs[p2] = c;
                        queue[nelem] = p2;
                        nelem += 1;
                    }
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 7688
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=5+1e5;
LL N;
int main(){
	LL x;
	cin.tie(0);
	cin >> N;
	LL least=0,ans=0;
	REP(i,N){
		cin >> x;
		//cout << least << endl;
		if(x<=least+1){
			least=max(least,x);
			continue;
		}
		ans+=(x-1)/(least+1);
		if(least==0) least=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n % 2 == 0:
    b.reverse()

for i in b:
    print('{} '.format(i), end='')
print()

Measured memory_bytes: 25412
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n+1)
	a[0], a[1] = 2, 1
	if n == 1 {
		fmt.Println("1")
		return
	}
	for i := 2; i <= n; i++ {
		a[i] = a[i-2] + a[i-1]
	}
	fmt.Println(a[n])
}


Measured memory_bytes: 512
import math
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    A, B, H, M = ZZ()
    Mt = math.radians(6 * M)
    Ht = math.radians(30 * H + M/2)
    Mx = B * math.cos(Mt)
    My = B * math.sin(Mt)
    Hx = A * math.cos(Ht)
    Hy = A * math.sin(Ht)
    print(((Hx - Mx) ** 2 + (Hy - My) ** 2) ** 0.5)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9516