akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;
// Nとnはll型(mintではない)
// -------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> D(N);
    map<int,int> mp;
    for(int i=0; i<N; i++){
        cin >> D[i];
        mp[D[i]]++;
    }
    int M;
    cin >> M;
    vector<int> T(M);
    for(int i=0; i<M; i++){
        cin >> T[i];
    }
    for(int i=0; i<M; i++){
        if(mp[T[i]] > 0){
            mp[T[i]]--;
        }else{
            cout << "NO" << enld;
            return 0;
        }
    }
    cout << "YES" << enld;
    return 0;
}

Measured memory_bytes: 11264
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;


std::vector<int> pre;
std::vector<int> in;
std::vector<int> post;

int count = 0;
int next(std::vector<int>& v)
{
    int res = v[count];
    count++;
    return res;
}

void reconstruction(int l, int r)
{
    if (l >= r) return;

    int c = next(pre);
    int m = std::distance(in.begin(), std::find(in.begin(), in.end(), c));

    reconstruction(l, m);
    reconstruction(m + 1, r);

    post.push_back(c);
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    pre.resize(n);
    in.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> pre[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> in[i];
    }

    reconstruction(0, n);

    for (int i = 0; i < n - 1; i++) {
        cout << post[i] << " ";
    }
    cout << post[n - 1] << endl;

    return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    cin >> n;
    map<string, int> dict;
    rep(i, n) {
        string s;
        cin >> s;
        dict[s]++;
    }
    out(dict.size());

    return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N,K;
    cin >> N >> K;
    set<int> s;
    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++){
            int x;
            cin >> x;
            s.insert(x);
        }
    }
    cout << N - s.size() << endl;
}


Measured memory_bytes: 3632
import java.util.*;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        int min = Integer.MAX_VALUE;
        int count = 0;
        long sum = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            if(A[i] < 0)
                count++;
            min = Math.min(min, Math.abs(A[i]));
            sum += Math.abs(A[i]);
        }
        sc.close();

        if(count%2 == 0)
            System.out.println(sum);
        else {
            System.out.println(sum-min*2);
        }
    }
}

Measured memory_bytes: 50136
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    string s1,s2,s3;
    cin>>s1>>s2;

    int x,y;
    cin>>x>>y;

    cin>>s3;

    if ( s3 == s1 )
    {
        cout<<x-1<<" "<<y<<endl;
    }
    else if ( s3 == s2 )
    {
        cout<<x<<" "<<y-1<<endl;
    }
    return 0;
}

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

int main()
{
	int ans;
	
	int a,b,c;
	
	cin >> a >> b >> c;
	
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(c>a) swap(c,a);
	
	cout << (a*10+b)+c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n; cin  >> n;
    vector<int> num;
    bool flag = true;
    REP(i, n){
        int a = in();
        if(a % 2 == 0){
            if(a % 3 != 0 and a % 5 != 0)  flag = false;
        }
    }
    cout << (flag ? "APPROVED" : "DENIED") << endl;
}

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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vi a(n);
		for(auto&m:a) cin >> m;

		int c_max=0;
		ll ans=0;
		for(int i=0;i<n;i++)
		{
			max_u(c_max, a[i]);
			ans+=c_max-a[i];
		}

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


Measured memory_bytes: 3988
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  if(n==1){
    cout <<"1\n0\n";
  }else if(n==2){
    cout <<"2\n0\n11\n";
  }else{
    cout << n-1<<endl;
    for(ll len = 2;len<=n;len++){
      for(int i=0;i<len;i++){
        if(i==0||i==len-1){
          cout << '1';
        }else{
          cout <<'0';
        }
      }
      cout << endl;
    }
  }
}



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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'


using namespace std;

void quick ()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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

void readFromText()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
   quick();
//    readFromText();
    int n ; cin >> n ; long long sum = 0 ;
    for (int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= n ; j++){
            for (int k = 1 ; k <= n ; k++){
                sum+=gcd(gcd(i,j),k);
            }
        }
    }
    cout <<  sum << endl ;
    return 0;
}



Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<Integer>();
    int N = sc.nextInt();
    for(int i=0;i<N;i++){
      int a = sc.nextInt();
      ar.add(a);
    }
    Collections.sort(ar,Comparator.reverseOrder());

    int Alice = 0;
    for(int i=0;i<N;i+=2){
      Alice += ar.get(i);
    }

    int Bob = 0;
    for(int i=1;i<N;i+=2){
      Bob += ar.get(i);
    }
    System.out.println(Alice - Bob);
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
int main()
{
	long long a, b, a1, a2, b1, b2;
	cin >> a >> b;
	cin >> a1 >> a2;
	cin >> b1 >> b2;
	if(a1 > b1 && a2 > b2) 
	{
		cout << '0' << '\n';
		return 0;
	}
	else if(a1 * a + a2 * b == b1 * a + b2 * b)
	{
		cout << "infinity" << '\n';
		return 0;
	}
	else
	{
		if(a1 > b1)
		{
			swap(a1, b1);
			swap(a2, b2);
		}
		lli one = (b1 - a1) * a;
		lli two = (a2 - b2) * b;
		if(one > two)
		{
			cout << '0';
			return 0;
		}
		lli all = (b1 - a1) * a;
		lli temp = two - one;
//		cout << all << ' ' << temp << '\n';
		lli ans = 0;
		if(all > two)
		{
			all -= temp * ceil((double)(all - two) / temp);
			if(all - two <= 0) ans ++;
		}
		ans += 2 * (all / temp);
		if(all % temp) ans ++;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
typedef pair <int,int> pii;
typedef pair <int,LL> piL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=305*4;
int n;
int d1,d2;
pii p1[N],p2[N];
int c1=0,c2=0;
int vis[N][N];
int color[N][N];
void dfs1(int x,int y,int c){
  	if (x<1||y<1||x>n*2||y>n*2)
      	return;
 	if (vis[x][y])
      	return;
 	vis[x][y]=1;
  	color[x][y]|=c;
  	For(i,1,c1)
      	dfs1(x+p1[i].fi,y+p1[i].se,c^1);
}
void dfs2(int x,int y,int c){
  	if (x<1||y<1||x>n*2||y>n*2)
      	return;
 	if (vis[x][y])
      	return;
 	vis[x][y]=1;
  	color[x][y]|=c;
  	For(i,1,c2)
      	dfs2(x+p2[i].fi,y+p2[i].se,c^2);
}
int main(){
  	n=read(),d1=read(),d2=read();
  	For(i,0,d1){
		int a=d1-i*i;
      	if (a>=0){
          	int j=sqrt(a);
          	if (j*j==a){
              	p1[++c1]=mp(i,j);
              	p1[++c1]=mp(i,-j);
              	p1[++c1]=mp(-i,j);
              	p1[++c1]=mp(-i,-j);
            }
        }
  	}
  	For(i,0,d2){
      	int a=d2-i*i;
      	if (a>=0){
        	int j=sqrt(a);
        	if (j*j==a){
              	p2[++c2]=mp(i,j);
              	p2[++c2]=mp(i,-j);
              	p2[++c2]=mp(-i,j);
              	p2[++c2]=mp(-i,-j);
            }
      	}
    }
  	clr(vis);
  	For(i,1,n*2)
      	For(j,1,n*2)
      		if (!vis[i][j])
              	dfs1(i,j,0);
	clr(vis);
  	For(i,1,n*2)
      	For(j,1,n*2)
      		if (!vis[i][j])
              	dfs2(i,j,0);
 	For(t,0,3){
      	int c=0;
      	For(i,1,n*2)
          	For(j,1,n*2)
          		if (color[i][j]==t)
                  	c++;
     	if (c>=n*n){
          	c=n*n;
          	For(i,1,n*2)
              	For(j,1,n*2)
              		if (c>0&&color[i][j]==t)
                      	c--,printf("%d %d\n",i-1,j-1);
         	return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 29440
#include <iostream>
using namespace std;
int main(){
    int n,x,y,c=0;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        x=i%2;
        if(x==1){
            y=a[i]%2;
            if(y==1){
                c++;
            }
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; int Q; cin >> S >> Q;
    int flow=0;
    string front="",back="";
    for (;Q--;){
        int T; cin >> T;
        if (T==1) flow^=1;
        else {
            int F; char C; cin >> F >> C; --F;
            F^=flow;
            if (F) back+=C;
            else front+=C;
        }
    }
    reverse(front.begin(),front.end());
    S=front+S+back;
    if (flow) reverse(S.begin(),S.end());
    cout << S << '\n';
}

Measured memory_bytes: 1200
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from bisect import bisect_right, bisect_left
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort()
    C.sort()
    ans = 0


    for b in B:
        a = bisect_left(A, b)
        c = bisect_right(C, b)
        ans += a*(N-c)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27444
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

vector<pair<ll, ll> > v;

ld dist(pair<ll, ll> p1, pair<ll, ll> p2) {
	ll d1 = p1.first - p2.first;
	ll d2 = p1.second - p2.second;
	return sqrtl(d1 * d1 + d2 * d2);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t1, t2;
		cin >> t1 >> t2;
		v.push_back(make_pair(t1, t2));
	}

	vector<int> p;
	for (int i = 0; i < n; i++) {
		p.push_back(i);
	}
	ld ret = 0;
	ll num = 0;
	do {
		ld cur = 0;
		for (int i = 0; i < n - 1; i++) {
			cur += dist(v[p[i]], v[p[i + 1]]);
		}
		ret += cur;
		num++;
	} while (next_permutation(p.begin(), p.end()));
	ret /= num;
	printf("%.10Lf\n", ret);
	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl;
#define SZ(a) (int)a.size()
using LL = long long; template<class T> using V = vector <T>; template <class T> using VV = V<V<T>>;

int dp[5][10][301];

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

	int N, M, L; cin >> N >> M >> L;
	//[0,8)をきめる * 5
	using tp = tuple<int, int, int, int>;
	V<tp>Info(M);
	V<int>d(M), a(M), k(M), t(M);
	FOR(i, 0, M) {
		cin >> d[i] >> a[i] >> k[i] >> t[i];
	}
	FOR(x, 0, 5) {
		if (x >= 1) {
			FOR(z, 1, L + 1) {
				dp[x][0][z] = dp[x - 1][N][z];
			}
		}
		FOR(y, 1, N + 1) {
			FOR(z, 1, L + 1) {
				dp[x][y][z] = dp[x][y - 1][z];
			}
			FOR(z, 0, M) {
				if (d[z] == x && a[z] + k[z] - 1 == y) {
					FOR(v, 1, L + 1) {
						dp[x][y][v] = max(dp[x][y][v], dp[x][a[z] - 1][v - 1] + t[z]);
					}
				}
			}
		}
	}

	int ans = 0;
	FOR(i, 1, L + 1) {
		ans = max(ans, dp[4][N][i]);
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3244
//34
#include<iostream>
#include<algorithm>

using namespace std;

int nx[100][100];
int ny[100][100];
int c[100][100];

int dfs(int y,int x){
  if(c[y][x]==2){
    return 0;
  }else if(c[y][x]==1){
    return 1;
  }else{
    int r;
    c[y][x]=1;
    r=dfs(ny[y][x],nx[y][x]);
    c[y][x]=2;
    return r;
  }
}

int main(){
  for(int n;cin>>n,n;){
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	cin>>nx[y][x]>>ny[y][x];
      }
    }
    fill(c[0],c[100],0);
    int ans=0;
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	ans+=dfs(y,x);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1276
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ret = 0;
        for (int i = 0; i < 4; i++)
        {
            if (s[i] == '+') ret++;
            else ret--;
        }
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

class UnionFind {
 protected:
  vector<int> data;

 public:
  UnionFind(int size) : data(size, -1) {}
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) {
        swap(x, y);
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  //
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int di[] = {1, 0, -1, 0};
  int dj[] = {0, 1, 0, -1};
  UnionFind uf(h * w);
  rep(i, h) {
    rep(j, w) {
      rep(k, 4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (0 <= ni && ni < h && 0 <= nj && nj < w) {
          if (s[i][j] != s[ni][nj]) {
            uf.unite(i * w + j, ni * w + nj);
          }
        }
      }
    }
  }
  map<int, pll> mp;
  rep(i, h) {
    rep(j, w) {
      bool black = s[i][j] == '#';
      int r = uf.root(i * w + j);
      if (mp.find(r) == mp.end()) {
        mp[r] = make_pair(black, !black);
      } else {
        mp[r].first += black;
        mp[r].second += !black;
      }
    }
  }
  ll ans = 0;
  for (auto& m : mp) {
    ans += m.second.first * m.second.second;
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
  int n, b, f, r, v;
  int room[4][3][10];

  cin >> n;

  for( int i = 0; i < 4; i++){
    for( int j = 0; j < 3; j++){
      for( int k = 0; k < 10; k++){
	room[i][j][k] = 0;
      }
    }
  }

  for( int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    room[b-1][f-1][r-1] += v;
  }

  for( int i = 0; i < 4; i++){
    if( i > 0 ){
      for( int j = 0; j < 20; j++){
	cout << '#';
      }
      cout << endl;
    }
    for( int j = 0; j < 3; j++){
      for( int k = 0; k < 10; k++){
	cout << " " << room[i][j][k];
      }
      cout << endl;
    }
  }
	
  
  return 0;
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var segtree = new SegmentTree<int>(A, GCD,0);
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans = Max(ans, GCD(segtree.Query(0, i), segtree.Query(i + 1, N)));
        }
        WriteLine(ans);
    }
 
    static int GCD(int a, int b)
    {
        while (b != 0)
        {
            var c = a;
            a = b;
            b = c % b;
        }
        return a;
    }
}
 
public class SegmentTree<T>
{
    T[] buffer;
    int N;
    T IE;
    Func<T, T, T> Op;//デリゲート遅そう　

    public SegmentTree(int cap, Func<T, T, T> op, T E)//モノイドが直接渡せれば　C#9.0ではいるか
    {
        N = cap;
        buffer = new T[N * 2];
        for (int i = 0; i < buffer.Length; i++) buffer[i] = E; //Array.Fill(buffer, E);// NETCOREAPP Only
        Op = op;
        IE = E;
    }

    public SegmentTree(T[] init, Func<T, T, T> op, T E)
    {
        N = init.Length;
        buffer = new T[N * 2];
        Array.Copy(init, 0, buffer, N, init.Length);
        for (int i = N - 1; i > 0; i--)
        {
            buffer[i] = op(buffer[i * 2], buffer[i * 2 + 1]);
        }
        Op = op;
        IE = E;
    }

    public void Update(int index, T value)//index [0, N)
    {
        index += N;
        buffer[index] = value;
        while (index > 1)
        {
            buffer[index >> 1] = Op(buffer[index], buffer[index ^ 1]);
            index >>= 1;
        }
    }

    public T this[int index]
    {
        set//setの式形式はC#7.0以降
        {
            Update(index, value);
        }
        get
        {
            return buffer[index + N];
        }
    }

    public T Query(int l, int r)//[l, r) 0 <= l, r <= N // 0 <= r - l のとき空区間
    {
        var lv = IE;
        var rv = IE;
        l += N;
        r += N;
        while (l < r)
        {
            if ((l & 1) == 1)
            {
                lv = Op(lv, buffer[l++]);
            }
            if ((r & 1) == 1)
            {
                rv = Op(buffer[--r], rv);
            }
            l >>= 1;
            r >>= 1;
        }
        return Op(lv, rv);
    }
}


Measured memory_bytes: 26972
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int a,b ,k; cin >> a>> b>>k;
    int n=max(a,b);
    int count=0,i;
    for (i = n; i >0 ; i--)
    {
        if(a%i==0 && b%i==0) count++;
        if(count == k) break;
    }
    cout << i << endl;
    
    
    return 0;
}

Measured memory_bytes: 3164
ans 2 t =
  if t > 2000
  then 0
  else if t > 1000
       then 2001 - t
       else t + 1

ans 4 t =
    sum $ map (\i -> let a = ans 2 i
                         b = ans 2 (t-i)
                     in
                         a * b ) [0..t]

main = do
  c <- getContents
  let i = map read $ lines c :: [Integer]
      o = map (ans 4) i
  mapM_ print o


Measured memory_bytes: 5556
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n m
a1 ... an

n 10^5
m 10^9
ai 10^9
 */

int n,m;
ll b[100001];

int main(){
  cin>>n>>m;
  REP(i,n){
    int a;
    cin>>a;
    b[i+1] = (a+b[i])%m;
  }

  sort(b,b+n+1);

  ll pre = b[0];
  ll ans = 0;
  int cnt = 0;
  FOR_IN(i,1,n+1){
    if(b[i]==pre)
      cnt++;
    else
      cnt = 0;
    ans += cnt;
    pre = b[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
#print(n)
s=''
k=1
if n==0:
    s='0'
else:
    while n!=0:
        if abs(n)%abs((-2)**k)!=0:
            n-=(-2)**(k-1)
            s='1'+s
        else:
            s='0'+s
        k+=1
    
print(s)
    

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace B {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            for(int i = 0; i < S.Length; ++i) {
                char last = S.Last();
                S = last + S.Substring(0, S.Length - 1);

                if(S == T) {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct Edge{
    int u, v, cost;
    Edge() = default;
    Edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
};

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

    int n, m;
    cin >> n >> m;
    vector<Edge> es(m);
    vector<vector<int>> dist(n, vector<int>(n, INF));
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist[a][b] = c;
        dist[b][a] = c;
        es[i] = Edge(a, b, c);
    }
    for(int i = 0; i < n; ++i)  dist[i][i] = 0;
    
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < m; ++i){
        int u = es[i].u, v = es[i].v, cost = es[i].cost;
        if(dist[u][v] != cost)  ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	static class NumString{
		void patternString() {
			for(;;) {
				int n = Integer.parseInt(sc.nextLine());
				if(n==0) break;
				StringBuffer str = new StringBuffer(sc.nextLine());

				for(int i=0; i<n; i++) {
					StringBuffer nstr = new StringBuffer();
					int count=1;
					for(int j=0; j<str.length(); j++) {
						if(j == str.length()-1) {
							nstr.append(Integer.toString(count));
							nstr.append(str.charAt(j));
						}else if(str.charAt(j) != str.charAt(j+1)) {
							nstr.append(Integer.toString(count));
							nstr.append(str.charAt(j));
							count=1;
						}else {
							count++;
						}
					}
					str = nstr;
				}

				System.out.println(str);
			}
		}
	}

	public static void main(String[] args) {
		NumString ns = new NumString();
		ns.patternString();
	}
}

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

int main(){
    int k, n, max=0, max_n, length=0;
    cin >> k >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=1; i<n; i++){
        if (a[i]-a[i-1] > max){
            max = a[i] - a[i-1];
            max_n = i;
        }
    }
    if (k-a[n-1]+a[0] > max) max_n = 0;

    for (int i=1; i<n; i++){
        if (i == max_n) continue;
        length += a[i] - a[i-1];
    }
    if (max_n != 0) length += k-a[n-1]+a[0];
    cout << length << endl;
    return 0;
}

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

using namespace std;


const string temp = "AKIHABARA";

int main()
{
  string S;
  cin >> S;

  int ptr = 0;
  for(int i = 0; i < S.size(); i++) {
    if(ptr < temp.size() && S[i] == temp[ptr]) {
      ++ptr;
    } else {
      if(temp[ptr] == 'A') {
        ++ptr;
        --i;
      } else {
        cout << "NO" << endl;
        return (0);
      }
    }
  }
  if(ptr < temp.size()) ++ptr;

  if(ptr >= temp.size()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vd dp(10);
  while (cin >> dp[0]) {
    loop(i, 1, 10) dp[i] = odd(i) ? dp[i - 1] * 2 : dp[i - 1] / 3;
    cout << prec(8) << accumulate(all(dp), 0.0) << endl;
  }
}

Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String str[] = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int max=a;
        int min=a;
        long total=a;
        for(int i=1;i<n;i++){
            int b = Integer.parseInt(str[i]);
            if(max<b) max=b;
            if(min>b) min=b;
            total = total + b;
        }
        System.out.println(min+" "+max+" "+total);
    }
}

Measured memory_bytes: 28252
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll N;
	cin >> N;
	vector<double> v(N);
	priority_queue<double, vector<double>, greater<double> > que;
	rep(i, N) {
		cin >> v[i];
		que.push(v[i]);
	}
	double a, b;
	rep(i,N-1) {
		a = que.top();
		que.pop();
		b = que.top();
		que.pop();
		que.push((a+b)/2);
	}
	printf("%.16f\n", que.top());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

vector<int> adj[MAXN];
bool vis[MAXN] = {false};
int cnt = 0;

void dfs(int s){
    vis[s] = true;
    cnt++;
    for(int v: adj[s]){
        if(!vis[v]) dfs(v);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    for(int i= 0;i<m;i++){
        int t1, t2;
        cin>>t1>>t2;
        adj[t1].pb(t2);
        adj[t2].pb(t1);
    }
    int ans = 0;
    for(int i= 1;i<=n;i++){
        if(!vis[i]){
            cnt = 0;
            dfs(i);
            ans = max(ans, cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 20928
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        long[] count=new long[n+1];
        for(int i=0;i<n;i++){
            count[nums[i]]++;
        }
        long sum=0;
        for(int i=0;i<n+1;i++){
            sum+=count[i]*(count[i]-1)/2;
        }
        for(int i=0;i<n;i++){
            System.out.println(sum-count[nums[i]]+1);
        }

    }

}

Measured memory_bytes: 94140
#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define vecll vector<ll>
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
bool f(ll n){
    ll sum=0,cnt=0,p=n*(n+1)/2;
    vecll a(n);
    rep(i,n) sum+=a[i]=in();
    if(sum%p!=0)return false;
    ll num=sum/p;
    rep(i,n){
        ll k=a[(i+1)%n]-a[i]-num;
        if(k>0||k%n!=0)return false;
        cnt-=k/n;
    }
    return cnt==num;
}
int main(){
    string a=f(in())?"YES":"NO";
    cout<<a;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    for(int n; cin >> n;){
        int cnt = 0;
        rep(i, 10)rep(j, 10)rep(k, 10)rep(h, 10)
          if(i + j + k + h == n) cnt++;
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if(op == '+')
    cout << A + B << endl;
  else if(op == '-')
    cout << A - B << endl;
  else if(op == '*')
    cout << A * B << endl;
  else if(op == '/')
    cout << A / B << endl;
} 

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

void magicSquare(vector<vector<int> > &v1) {
  int n = v1.size();
  int r = (n / 2 + 1), c = n / 2;
  
  v1[r][c] = 1;
  for(int cnt = 2; cnt <= n * n; ++cnt) {
	r = (r == n - 1 ? 0 : r + 1);
	c = (c == n - 1 ? 0 : c + 1);

	while(v1[r][c] != 0) {
	  r = (r == n - 1 ? 0 : r + 1);
	  c = (c == 0 ? n - 1 : c - 1);
	}
	v1[r][c] = cnt;
  }
}

void printVector(vector<vector<int> > &v1) {
  int n = v1.size();
  for(int i = 0; i < n; ++i) {
	  for(int j = 0; j < n; ++j) {
		cout << right << setw(4) << v1[i][j];
	  }
	  cout << endl;
	}
}

int main() {
  int n;
  while(cin >> n) {
	if(n == 0) break;

	vector<vector<int> > v1(n, vector<int>(n, 0));
	magicSquare(v1);
	printVector(v1);
  }
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
// #define int long long    // %d=>%lld
#define pb push_back
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

const int MAX_n = 100;
int n,a[MAX_n];



signed main(){

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

    int mi=INF;
    int ma=0;

    for(int i = 0;i < n;i++){
        if(a[i]>ma){
            ma=a[i];
        }
        if(a[i]<mi){
            mi=a[i];
        }
    }

    printf("%d\n", ma-mi);

    return 0;
}

Measured memory_bytes: 256
float x[100],y[100],t,u,a,b;n,i,j,k,c,s;main(m){for(;c=i=scanf("%d",&n)*n;printf("%d\n",m))for(m=1;j=c?scanf("%f,%f",x+c,y+--c):--i;)for(;s=!c&&j--;)for(u=acos(hypot(a=x[j]-x[i],b=y[j]-y[i])/2),t=atan2(b,a);c=0,u<9&&s+3;s-=2)for(k=n;k--;)hypot(x[i]+cos(b)-x[k],y[i]+sin(b=t+s*u)-y[k])<1.1&&++c>m?m=c:0;}

Measured memory_bytes: 772
x = int(input())
y = 0

for i in range(1, x+1):
    if i % 3 == 0:
        print(" %d"%i, end='')

    else:
        y = i
        while (y):
            if y % 10 == 3:
                print(" %d"%i, end='')
                break
            y //= 10
print()



Measured memory_bytes: 5872
#include<stdio.h>

int main(){
  int n,i,F[50];

  scanf("%d",&n);
  F[0] = F[1] = 1;
  for(i=2;i<=n;i++)F[i] = F[i-1] + F[i-2];
  printf("%d\n",F[n]);

  return 0;
}
  



Measured memory_bytes: 2104
#include<stdio.h>
int main(void){
  int a,b,c,d,e;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  if(a==0)
    printf("%d",1);
  if(b==0)
    printf("%d",2);
  if(c==0)
    printf("%d",3);
  if(d==0)
    printf("%d",4);
  if(e==0)
    printf("%d",5);
  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int r, d, x, a = 0; cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++) {
		a = r * x - d;
		cout << a << endl;
		x = a;
	}
	cin >> r;
}

Measured memory_bytes: 256
def myfunc():
    N = int(input())

    counter = 0
    for i in range(N):
        A, B = map(int, input().split())
        if A == B:
            counter += 1
            if counter >= 3:
                print('Yes')
                return 0
        else:
            counter = 0
    print('No')

if __name__ == "__main__":
    myfunc()

Measured memory_bytes: 9172
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let n: usize = input!(r, usize);
    let mons = input!(r, Vec<usize>; n);
    println!("{}", mons.iter().skip(1).fold(mons[0], |acc, x| gcd(acc, *x)));
}

fn gcd(a: usize, b: usize) -> usize {
    if a == 0 {
        return b;
    }
    if b == 0 {
        return a;
    }
    if a > b {
        return gcd(a % b, b);
    } else {
        return gcd(b % a, a);
    }
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int X = ni();
        int g = gcm(360,X);
        int lcm = 360*X/g;
        out.println(lcm/X);
    }
    int gcm(int a,int b){
        if(a%b==0) return b;
        else return gcm(b,a%b);
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 32760
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int n,t,a;
double d=100000000;
int p;
cin >> n >> t >> a;
vector<double> vec(n);
vector<double> vecx(n);
for(int i = 0;i<n;i++)
cin >> vec.at(i);
for(int i = 0;i<n;i++)
vecx.at(i)=abs(t-0.006*vec.at(i)-a);
for(int i =0;i<n;i++)
{
    if(d>vecx.at(i)){
    p=i;
    d=vecx.at(i);
    }
}
cout << p+1 << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
links = [set() for i in range(n)]
for i in range(m):
	a,b = [int(i)-1 for i in input().split()]
	links[a].add(b)
	links[b].add(a)

ans = 0
pre = [-1]*n
low = [-1]*n

def dfs(v,p,a):
	global ans
	if pre[v] != -1:
		low[a] = min(low[a],low[v])
		return low[a]
	pre[v] = p
	low[v] = p
	for u in links[v]:
		if u == a:
			continue
		low[v] = min(low[v],dfs(u,p+1,v))
	if pre[v] == low[v]:
		ans += 1
	return low[v]

dfs(0,0,None)
print(ans-1)

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

typedef long long ll;

int main() {
    int n, x;
    vector<ll>a;
    while (true) {
        int ans = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                for (int k = j+1; k <= n; k++) {
                    if (i+j+k == x) {
                        ans++;
                    }
                }
            }
        }
        a.push_back(ans);
    }
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << endl;
    }
}



Measured memory_bytes: 3116
n=int(input())
shiritori=[]
for i in range(n):
  shiritori.append(input())
check=set(shiritori)
if len(check)!=n:
  print("No")
else:
  flag=0
  for i in range(n-1):
    if shiritori[i][-1]!=shiritori[i+1][0]:
      flag=1
      break
  if flag==0:
    print("Yes")
  else:
    print("No")

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

using namespace std;

int main() {
    int n;
    cin >> n;
    using lint = long long int;
    vector<lint> t(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    auto calc_gcd = [](lint a, lint b)
    {
        lint r = a % b;
        while (r != 0)
        {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    };

    auto calc = [calc_gcd](lint a, lint b)
    {
        lint gcd = calc_gcd(a, b);
        return (a / gcd) * b;
    };
    
    if(n == 1)
    {
        cout << t[0] << endl;
    }else {
        lint temp = calc(t[0], t[1]);
        for (int i = 2; i < n; ++i) {
            temp = calc(temp, t[i]);
        }
        cout << temp << endl;
    }
    return 0;
}


Measured memory_bytes: 256