akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


struct UnionFind {
    vector<int> par;
    vector<int> sizes;
    vector<int> maxs;
    vector<int> mins;

    UnionFind(int n) :
            par(n), sizes(n, 1), maxs(n), mins(n) {
        rep(i, n) par[i] = i;
        rep(i, n) maxs[i] = i;
        rep(i, n) mins[i] = i;
    }

    int root(int x) {
        if (x == par[x]) return x;
        else return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        maxs[x] = max(maxs[y], maxs[x]);
        mins[x] = min(mins[y], mins[x]);
        sizes[x] += sizes[y];
        return true;
    }

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

    int size(int x) {
        return sizes[root(x)];
    }

    int getMax(int x) {
        return maxs[root(x)];
    }

    int getMin(int x) {
        return mins[root(x)];
    }

};


int main(){
    ll n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];

    vector<ll> ans(m);
    ans[m-1] = n*(n-1)/2;
    UnionFind uf(n+1);
    for(int i=m-1; i>=1; i--){
        if(uf.same(a[i], b[i])) ans[i-1] = ans[i];
        else{
            ll x = uf.size(a[i]);
            ll y = uf.size(b[i]);
            ans[i-1] = ans[i] - x*y;
            uf.merge(a[i], b[i]);
        }
    }

    rep(i, m) cout << ans[i] << endl;
}

Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int L_max = 1;
	int L_sum = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		L_sum += tmp;
		if (tmp>L_max)
		{
			L_max = tmp;
		}
	}
	if (L_sum-L_max>L_max)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,h[200005]={},ans=0;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h,h+n);
  for(int i=0; i<n-k; i++) {
    ans+=h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll ;
 
int main()
{
    int a,b; cin>>a>>b;
    int s[10002];
    for (int i=1; i<=a; i++) cin>>s[i];
    
    int sum=0;
    for (int i=1; i<=a; i++)
    {
    	if (sum+s[i]<=b) 
		    sum+=s[i];
    	else 
    	{
    		cout << i;
    		return 0;
		}
	}
	cout << a+1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A;
        long[] aList;
        long[] xList;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            aList = new long[N];
            xList = new long[N];
            for(int i = 0; i < N;i++){
                aList[i] = sc.nextLong();
            }
        }
        long result = 0;
        int s = 1;
        for(int i = 0;i < N;i++){
            result += ((s) * aList[(N-i)-1]);
            s *= -1;
        }
        //result は N1
        //X <- (X1 - (A1)/2)*2
        xList[0] = result;
        for(int i = 1; i < N;i++){
            xList[i] = (aList[i-1] - (xList[i-1] / 2))*2;
        }
        StringBuilder sb = new StringBuilder();
        for(long i : xList){
            sb.append(i).append(" ");
        }
        System.out.println(sb.toString());
    }


}


Measured memory_bytes: 56556
#include<bits/stdc++.h> 
#define ll long long
using namespace std;
const int INF = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	int x;
	cin>>x;
	if(x>=30){
		cout<<"Yes"<<'\n';
	}
	else{
		cout<<"No"<<'\n';
	}
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, M;
    cin >> N >> M;

    int l = 1, r = N;
    for (int i = 0, a, b; i < M; i++) {
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }

    cout << max(0, r - l + 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, f; };
    struct Edge { int i, n; };
    Graph(int n, int m) : z(n), y(n), r(n), v(n, { -1, 0 }), e(m), n(n), m(0), l(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i) {
        v[i].f = 1;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (v[o.i].f) continue;
            dfs(o.i);
        }
        y[i] = l;
        z[l] = i;
        l++;
    }
    void solve(Graph f) {
        for (int i1 = 0; i1 < n; i1++) {
            int i = z[i1];
            int i0 = -1, y0 = n;
            for (int j = f.v[i].n; j >= 0; j = f.e[j].n) {
                Edge& o = f.e[j];
                if (y[o.i] < y0) {
                    y0 = y[o.i];
                    i0 = o.i;
                }
            }
            r[i] = i0;
        }
        for (int i = 0; i < n; i++) {
            cout << r[i] + 1 << '\n';
        }
        cout << flush;
    }
    int l;
    vector<int> z, y, r;
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n, m;
    cin >> n >> m;
    int k = n - 1 + m;

    vector<int> c(n);
    Graph g(n, k), f(n, k);
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        f.add_edge(b, a);
        c[b] = 1;
    }

    int i0;
    for (int i = 0; i < n; i++) {
        if (c[i] == 0) i0 = i;
    }

    g.dfs(i0);
    g.solve(f);
    //bに現れないのが根
    //根からDFSして深さを浅いほうへ更新したら要らない辺 深いほうへ更新したら要るかも
    //一度訪れた頂点は適切に更新したら即return でないと経路数は爆発する
    //訪れるたびに親を更新
    //半順序が入るのでは？移動元のうち最も近いもの

    return 0;
}

Measured memory_bytes: 11776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int x = Integer.parseInt(tokenizer.nextToken());
        int y = Integer.parseInt(tokenizer.nextToken());
        int z = Integer.parseInt(tokenizer.nextToken());
        x -= z;
        if (x < 1) {
            System.out.println(0);
        } else {
            System.out.println(x / (y + z));
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0;i < N;i++)cin >> A[i];
	ll ans = 0;
	for (int i = N - 1;i >= 0;i--) {
		if (A[i] > i) { ans = -1; break; }
		if (i < N - 1) {
			if (A[i] < A[i + 1] - 1) { ans = -1; break; }
			else if (A[i] >= A[i + 1]) ans += A[i];
		}
		else ans += A[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
using namespace std;
int main(){
    int n, a;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        cin >> a;
        s.insert(a);
    }
    if(n == s.size()) cout << "YES";
    else cout << "NO";
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1, y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x2 - y - x << " " << y2 + x - y << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int student;
         
        while (true) {
            student = stdin.nextInt();
            if (student == 0) {
                break;
            }
             
            for (int i = 0; i < student; i++) {
                int m = stdin.nextInt();
                int e = stdin.nextInt();
                int j = stdin.nextInt();
                if (m == 100 || e == 100 || j == 100) {
                    System.out.println("A");
                } else if (90 <= (e + m) / 2) {
                    System.out.println("A");
                } else if (80 <= (m + e + j) / 3) {
                    System.out.println("A");
                } else if (70 <= (m + e + j) / 3) {
                    System.out.println("B");
                } else if (50 <= (m + e + j) / 3 && (80 <= m || 80 <= e)) {
                    System.out.println("B");
                } else {
                    System.out.println("C");
                }
            }
        }
    }
}

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

namespace ABC082_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var m = 100000;
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ac = new int[m + 1];
            var c = 0;
            for (int i = 0; i < N; i++)
            {
                if (a[i] > m)
                {
                    c++;
                    continue;
                }
                ac[a[i]]++;
            }

            for (int i = 1; i <= m; i++)
            {
                if (ac[i] > i) c += ac[i] - i;
                else if (ac[i] < i) c+= ac[i];
            }
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 24540
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}


$A = $data[0][0];
$B = $data[0][1];
$H = $data[0][2];
$M = $data[0][3];

$short = ($H * 60 + $M) * 0.5;
$long = $M * 6;

$sin = sin(deg2rad($long - $short));
$cos = cos(deg2rad($long - $short));
$tan = tan(deg2rad($long - $short));

$alpha = $A * $cos;
$height = sqrt($A * $A - $alpha * $alpha);
$beta = $B - $alpha;
$ans = sqrt($height * $height + $beta * $beta);

echo $ans;


Measured memory_bytes: 16680
#include <bits/stdc++.h>
using namespace std;
int main() {
	int ans = 1;
	int n,x;cin>>n>>x;
	int d =0;
	for(int i = 0; i < n; i++){
		int o ;cin>>o;
		d +=o;
		if(d <=x)ans++;
	}
	cout<<ans;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  set<ll>se;
  rep(i,0,n){
    ll a;cin>>a;
    se.insert(a);

  }
  if(se.size()==n)out("YES");
  else out("NO");

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,P;
vector<int> A;
void input(){
    fast_io();
    cin >> N >> P;
    for (size_t i = 0; i < N; i++)
    {
        int a; cin >> a;
        a%=2;
        A.push_back(a);
    }
    
}

int solve(){
    vector<ll> dp(3,0LL);
    dp[0] = 1;
    for (size_t i = 0; i < N; i++)
    {
        ll zero = dp[0];
        ll one = dp[1];
        dp[A[i]%2] += zero;
        dp[(A[i]+1)%2] += one;
    }
    cout << dp[P] << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    ll x;cin>>x;
    int a=x/500;
    x%=500;
    int b=x/5;
    ll res=a*1000+b*5;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, A, B, C, D;
char S[200011];

void MAIN() {
    scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
    scanf("%s", S);

    A--; B--; C--; D--;
    bool yes = true;
    for (int i=A; i<=C-1; i++) {
	if (S[i] == '#' && S[i+1] == '#') yes = false;
    }
    for (int i=B; i<=D-1; i++) {
	if (S[i] == '#' && S[i+1] == '#') yes = false;
    }

    if (yes && D < C) {
	bool ok = false;
	for (int i=B; i<=D; i++) if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') ok = true;
	yes = ok;
    }
    puts(yes? "Yes": "No");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
using System;

public class hello
{
    public static void Main()
    {
        var g = 100000;
        var a = 1.05;
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var res1 = Math.Ceiling(g*a / 1000) * 1000;
            g = (int)res1;
        }
        Console.WriteLine(g);
    }
}


Measured memory_bytes: 13928
/*
g++ -std=c++11 -o2 -Wall Educational_DP_C.cpp -o .\out\Educational_DP_C.out
.\out\Educational_DP_C.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

constexpr int INF = 1e9;

int dp[100005][3];
int a[100005][3];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      --ans;
    } else {
      ++ans;
    }
  }
  ans = n - abs(ans);
  cout << ans << "\n";
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
}


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

using namespace std;
typedef long long ll;

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

  return gcd(b, a % b);
}

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

int main()
{
  ll a, b;
  cin >> a >> b;

  cout << lcm(a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  ull n;
  string s;
  cin >> n;
  cin >> s;

  ull r = 0;
  ull b = 0;
  each(i, s.size()) {
    if (s[i] == 'R') {
      r++;
    } else {
      b++;
    }
  }

  if (r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,cnt=0;
  cin>>N>>D;
  vector<vector<double>> X(N,vector<double>(D));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin>>X[i][j];
    }
  }
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      double sum=0;
      for(int k=0; k<D; k++){
        sum+=pow(X[i][k]-X[j][k],2);
      }
      sum=sqrt(sum);
      if(ceil(sum)==floor(sum)){
        cnt++;
      }
    }
  }
  cout<<cnt<<endl;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    // int n, m;
    // cin >> n >> m;
    // vector<int> a(n);
    // map<int, int> map;
    // rep(i, n)
    // {
    //     int aa, b;
    //     cin >> aa >> b;
    //     a[i] = aa;
    //     map.insert(make_pair(aa, b));
    // }
    // sort(all(a));
    // int num = m;
    // int sum = 0;
    // rep(i, n)
    // {
    //     if ((num - map.at(a[i])) > 0)
    //     {
    //         num -= map.at(a[i]);
    //         sum += a[i] * map.at(a[i]);
    //     }
    //     else if ((num - map.at(a[i])) == 0)
    //     {
    //         sum += a[i] * map.at(a[i]);
    //         break;
    //     }
    //     else
    //     {
    //         sum += a[i] * num;
    //         break;
    //     }
    // }
    // cout << sum << endl;
    // return 0;
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> pairs(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    sort(pairs.begin(), pairs.end());
    int num = m;
    int sum = 0;
    rep(i, n)
    {
        if (num - pairs[i].second > 0)
        {
            num -= pairs[i].second;
            sum += pairs[i].first * pairs[i].second;
        }
        else if (num - pairs[i].second == 0)
        {
            sum += pairs[i].first * pairs[i].second;
            break;
        }
        else
        {
            sum += pairs[i].first * num;
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

int memo[20][20];
void solve(long long N, std::vector<long long> A, std::vector<long long> B,
           std::vector<long long> C) {
  for(int i = 0 ; i + 1 < N ; i++){
    memo[i][i+1] = C[i];
  }
  int ans = 0;
  for(int i = 0 ; i < N ; i++){
      ans += B[i];
  }
  for(int i = 0 ; i + 1 < N ; i++)
      ans += memo[A[i]-1][A[i+1]-1];
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }
  std::vector<long long> C(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &C[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#define ll long long
//#define maxn -99999
using namespace std;
int a[200005],b[200005];
int main()
{
	int n,i;
	cin>>n;
	ll sum=0,count=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
		count++;
		b[i]=abs(a[i]);
		sum+=b[i];
	}
	sort(b,b+n);
	if(count%2==0)
	cout<<sum<<endl;
	else
	cout<<sum-(b[0]*2)<<endl;
	return 0;
}

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

public static int [] m ={500,100,50,10,5,1};

	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);

	        while(true){
	        	
	        	int c =1000-scan.nextInt();
	        	if(c==1000)break;
	        		System.out.println(change(c));
	        	}

	        }
	    public static int change (int n){
	    	int sum=0;
	    	for(int i=0;i<6;i++){
	    		sum+=n/m[i];
	    		n%=m[i];
	    		
	    	}
	    	return sum;
	    }
	    
	}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int N;  cin >> N;
    vector<int> A(N);  rep(i, N+1) cin >> A[i];
    vector<int> B(N);  rep(i, N) cin >> B[i];
    
    ll sum = 0;
    rep(i, N) {
        if (A[i] >= B[i]) sum += B[i];
        else {
            sum += A[i] + min(A[i+1], B[i] - A[i]);
            if (A[i+1] > B[i] - A[i]) A[i+1] = A[i+1] - (B[i] - A[i]);
            else A[i+1] = 0; 
        }
    }

    print(sum);

    return 0;
}



Measured memory_bytes: 1024
h,w=map(int,input().split())
a=[ input() for _ in range(h)]
row=[0]*h
col=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            row[i]+=1
            col[j]+=1

for i in range(h):
    if row[i]==w:
        continue
    for j in range(w):
        if col[j]==h:
            continue
        print(a[i][j],end='')
    print()


Measured memory_bytes: 4468
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
//		int n = 30*15*35 + 30*5*15 + 30*10*5 + 30*20*10 + 30*25*20;
//		System.out.println(n);
//
//		int l = 30*35*5 + 35*15*5 + 30*5*25 + 5*10*20 + 5*20*25;
//		System.out.println(l);
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] M = new int[n][2];
		for (int i=0; i < n; i++) {
			String[] data = br.readLine().split(" ");
			M[i][0] = Integer.parseInt(data[0]);
			M[i][1] = Integer.parseInt(data[1]);
		}

		memo = new int[n+1][n+1][3];
		ismemorized = new boolean[n+1][n+1];

		int ans = miniCost(M, 0, M.length)[2];
		System.out.println(ans);
	}

	static int[][][] memo;

	static boolean[][] ismemorized;

	public static int[] miniCost(int[][] M, int begin, int end) {
		if (ismemorized[begin][end]) return memo[begin][end];

		if (end - begin == 1) {
			ismemorized[begin][end] = true;
			return memo[begin][end] = new int[] { M[begin][0], M[begin][1], 0 };
		}

		int mini = Integer.MAX_VALUE;
		for (int mid = begin+1; mid < end; mid++) {
			int newcost = miniCost(M, begin, mid)[0] * miniCost(M, mid, end)[1] * miniCost(M, begin, mid)[1];
			int oldcost = miniCost(M, begin, mid)[2] + miniCost(M, mid, end)[2];
			if (mini > newcost + oldcost) {
				mini = newcost + oldcost;
			}
		}
		ismemorized[begin][end] = true;
		return memo[begin][end] =  new int[] {M[begin][0], M[end-1][1], mini};
	}
}

Measured memory_bytes: 27132
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C, K = map(int, readline().split())

print(A - B) if K % 2 == 0 else print(B - A)


Measured memory_bytes: 12504
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
llint a;
llint mp[100005];
void solve(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    mp[a]++;
  }
  int mx=0;
  int mxidx=-1;
  llint s;
  for(int i=0;i<100000-2;i++){
    s=mp[i]+mp[i+1]+mp[i+2];
    if(s>mx){
      mx=s;
      mxidx=i+1;
    }
  }
  cout << mx << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
// typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    set<int> s1, s2;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        if (a == 1) s1.insert(b);
        if (b == N) s2.insert(a);
    }
    set<int> s;
    set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(s, s.end()));
    // print(s1);
    // print(s2);
    // print(s);
    if (!s.empty()) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 9600
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end


#####
n = gi
map = []
2.times do
  map.push(gmi)
end

max = 0
n.times do |nv|
  max = [max, map[0][0..nv].inject(:+) + map[1][nv..(n-1)].inject(:+)].max
end
puts max

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    map<string, int> mp;
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        mp[s] = 1;
    }

    cout << mp.size() << endl;
}


Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

//Articulation Points(AOJ)
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A&lang=jp
//about 1hr
//問題を見ただけでは全く解法がわからなかったので下記サイトを参照した。
//http://www.dais.is.tohoku.ac.jp/~shioura/teaching/ad09/ad09-13.pdf
//https://kagamiz.hatenablog.com/entry/2013/10/05/005213

vvin edge(100020);
vpii bridge;
vin articulation;
vin order(100020),low(100020);
vbo visit(100020,false);

void dfs(int v,int p,int &res){
    visit[v]=true;
    order[v]=res;
    res++;
    low[v]=order[v];
    bool isArticulation=false;
    int cnt=0;
    for(auto e:edge[v]){
        if(!visit[e]){
            cnt++;
            dfs(e,v,res);
            low[v]=min(low[v],low[e]);
            if(p!=-1&&order[v]<=low[e])isArticulation=true;
            if(order[v]<low[e])bridge.push_back(mp(min(v,e),max(v,e)));
        }
        else if(e!=p)low[v]=min(low[v],order[e]);
    }
    if(p==-1&&cnt>1)isArticulation=true;
    if(isArticulation)articulation.push_back(v);
}

int main(){
    int v,e;cin>>v>>e;
    int s,t;//1-indexならそれぞれ-1する. そして出力で+1
    rep(i,e){
        cin>>s>>t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }
    int res=0;
    rep(i,v)if(!visit[i])dfs(i,-1,res);
    //sort(all(articulation));
    sort(all(bridge));
    //rep(i,articulation.size())cout<<articulation[i]<<endl;
    rep(i,bridge.size())cout<<bridge[i].first<<" "<<bridge[i].second<<endl;
}


Measured memory_bytes: 7440
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;

int main(){
	int N,W;
	cin>>N>>W;
	lli w[101],v[101];
	rep1(i,N)cin>>w[i]>>v[i];
	lli a[102][MAX];
	//a[i][j]は添え字iまででweight j以下を取ったときの価値のmax
	rep(j,W)a[0][j]=0;
	rep1(i,N)rep(j,W+1){
		if(j>=w[i] )a[i][j]=max(a[i-1][j-w[i]]+v[i],a[i-1][j]);
		else a[i][j]=a[i-1][j];
	}
	cout<<a[N][W];
	
}


Measured memory_bytes: 79744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		for(int i = X-K+1; i < K+X; i++) {
			System.out.print(i+" ");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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; }
// bit all search
int main(){
    ll h,w,k;cin>>h>>w>>k;
    vector<string> c(h);
    vector<vector<ll>> num(h,vector<ll>(w,0));
    

    rep(i,h){
        cin>>c[i];
    }

    ll black=0;
    rep(i,h){
        rep(j,w){
            if(c[i][j]=='#') black++;
        }
    }

    ll ans=0;
    rep(i,(1<<h)){
        rep(j,(1<<w)){
            vector<vector<bool>> visit(h,vector<bool>(w,false));
            ll gyo=0,retu=0;
            rep(l,h){
                if((i>>l)&1){//l行選択
                    rep(o,w){
                        if(c[l][o]=='#'){
                            gyo++;
                            visit[l][o]=true;
                        }
                    }
                }
            }
            rep(l,w){
                if((j>>l)&1){//l行選択
                    rep(o,h){
                        if(c[o][l]=='#' && !visit[o][l]){
                            retu++;
                        }
                    }
                }
            }

            if(gyo+retu==black-k) ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3604
A, B = map(int,input().split())


def sum_xor(x):
    ans = 0
    x += 1
    for i in range(50):
        per = 1<<i
        cnt = (x//(2*per))*per
        cnt += max(0,(x%(2*per)-per))
        value = cnt%2
        ans += value<<i
    return ans

print(sum_xor(B)^sum_xor(A-1))

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

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, A, B;
  cin >> N >> A >> B;
  i64 D = max(A, B) - min(A, B);
  if(D % 2 == 0) {
    cout << D / 2 << endl;
    return 0;
  }
  i64 a = min(A, B);
  i64 b = max(A, B);
  i64 ans;
  i64 res;
  {
    i64 x = 1;
    i64 y = b - a + 1;
    y--;
    ans = a + (y - x) / 2;
  }
  {
    i64 x = a + (N - b);
    i64 y = N;
    x++;
    res = (N - b) + 1 + (y - x) / 2;
  }
  cout << std::min(ans, res) << endl;
}


Measured memory_bytes: 256
a = []
b = []
c = []
for i in range(5):
    a.append(int(input()))
    b.append(a[i]%10)
for i in range(5):
    if b[i] == 0:
        c.append(a[i])
    else:
        c.append(a[i]+10-b[i])
m = 0
for i in range(5):
    if m < 10-b[i] < 10 :
        m = 10-b[i]
print(sum(c)-m)

Measured memory_bytes: 3064
s=int(input())
def f(n):
    if n%2==0:
        return(int(n/2))
    else:
        return(3*n+1)

a=s
A=[s]
i=2
while True:
    a=f(a)
    if a in A:
        print(i)
        break
    else:
        i+=1
        A.append(a)


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys
import math


def solve(K: int):
    ans = 0
    for a in range(1, K+1):
        for b in range(a, K+1):
            for c in range(b, K+1):
                if a != b and b != c:
                    ans += 6 * math.gcd(a,math.gcd(b,c))
                elif a != c:
                    ans += 3 * math.gcd(a,math.gcd(b,c))
                else:
                    ans += math.gcd(a,math.gcd(b,c))
    print(ans)


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include <iostream>

using namespace std;

int main() {
  int N, n, cambio = 0, n1, n2;
  cin >> N;
  int Fila[N+1];
  Fila[0] = 0;
  for(int i = 1; i <= N; i++) cin >> Fila[i];
  for(int i = 1; i <= N; i++) 
  {
    if(cambio < 3)
    {
      if(Fila[i] != i)
      {
        if (i == Fila[Fila[i]])
        {
          cambio ++;
        }
        else
        {
          cambio += 3;
          break;
        }
      }
    }
  }
  if(cambio<3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi             first
#define se             second
#define pb             push_back
#define INF            LLONG_MAX/3
#define MOD            1000000007
#define bcnt           __builtin_popcount
#define all(x)         (x).begin(),(x).end()
#define uni(x)         x.erase(unique(all(x)),x.end())
#define ub(x,y)        (upper_bound(all(x),y)-x.begin())
#define lb(x,y)        (lower_bound(all(x),y)-x.begin())
#define ssort(x)       sort(all(x))
#define rep(i,n)       repl(i,0,n-1)
#define mkp(x,y)       make_pair(x,y)
#define mmax(x,y)      (x>y?x:y)
#define mmin(x,y)      (x<y?x:y)
#define maxch(x,y)     x=mmax(x,y)
#define minch(x,y)     x=mmin(x,y)
#define exist(x,y)     (find(all(x),y)!=x.end())
#define each(itr,v)    for(auto itr:v)
#define repl(i,a,b)    for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)  DVec(n1,Vec(n2,i))

int main(){
  cin.sync_with_stdio(false);
  ll n,m;
  cin >> n >> m;
  if(n >= 2)n-=2;
  if(m >= 2) m-=2;
  cout << n*m << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

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

c = defaultdict(int)
for a in A:
    c[a] += 1

if N % 2 == 0:
    probable = True
    for i in range(1, N, 2):
        if c[i] != 2:
            probable = False
    ans = 2 ** (N // 2) % (10 ** 9 + 7) if probable else 0
else:
    probable = True
    if c[0] != 1:
        probable = False
    for i in range(2, N, 2):
        if c[i] != 2:
            probable = False
    ans = 2 ** ((N - 1) // 2) % (10 ** 9 + 7) if probable else 0
print(ans)


Measured memory_bytes: 14812
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n; cin>>n; int h[n];
  rep(i,n){
    cin>>h[i];
  }
  int maxi=0,d=0;
  rep1(i,n){
    if(h[i-1]>=h[i]){
      d++;
    }else{
      d=0;
    }
    maxi=max(maxi,d);
  }
  cout<<maxi;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <functional>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  const int N = scan<int>();
  const int M = scan<int>();
  std::vector<std::vector<int>> graph(N);
  for (const int i: range(0, M)) {
    int a = scan<int>() - 1;
    int b = scan<int>() - 1;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  std::vector<int> color(N);
  int count;
  bool bipartite;
  auto dfs = [&](auto dfs, int u, int c) -> void {
    if (color[u] != 0) {
      return;
    }
    color[u] = c;
    ++count;
    for (const int v: graph[u]) {
      if (color[v] == c) {
        bipartite = false;
      }
      dfs(dfs, v, -c);
    }
  };
  long long cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for (const int i: range(0, N)) {
    if (color[i] == 0) {
      bipartite = true;
      count = 0;
      dfs(dfs, i, 1);
      if (count == 1) {
        ++cnt3;
      }
      else {
        ++cnt1;
        if (bipartite) {
          ++cnt2;
        }
      }
    }
  }
  std::cout << cnt1 * cnt1 + cnt2 * cnt2 + (cnt3 * N * 2 - cnt3 * cnt3) << '\n';
  return 0;
}


Measured memory_bytes: 9088
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]

for i in range(1, n):
  abc[i][0] += max(abc[i-1][1], abc[i-1][2])
  abc[i][1] += max(abc[i-1][0], abc[i-1][2])
  abc[i][2] += max(abc[i-1][0], abc[i-1][1])
print(max(abc[-1]))

Measured memory_bytes: 63064