akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/dsu>
typedef long long int ll;
using namespace std;
using namespace atcoder;
int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, K;
  cin >> S >> K;
  bool q = true;
  for(int  i = 0; i < S.size(); i++) {
    if(!(S[i] == K[i])) {
      q = false;
    }
  }
  if(q) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
  string a,b;ll c=0;
  cin>>a>>b;
  ll l=a.length(),x=a.length();
  for(ll i=0;i<l;i++)
    if(a[i]!=b[i])
    c++;
  if(c)

    cout<<"No"<<nn;
  else
    cout<<"Yes"<<nn;



    return 0;
}


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

//long long型(64bit整数)
typedef long long ll;

#define MOD 1000000007ll

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

    ll ans = 0;
    if(n % 2 == 0){
        bool isok = true;
        for(int i=0; i<n; i++){
            if(i % 2 == 0){
                if(a[i] != i+1) isok = false;
            }else{
                if(a[i] != i) isok = false;
            }
        }
        if(isok){
            ans = 1ll;
            for(int i=1; i<=n/2; i++){
                ans = ans * 2ll % MOD;
            }
        }
    }else{
        bool isok2 = true;
        for(int i=0; i<n; i++){
            if(i % 2 == 0){
                if(a[i] != i) isok2 = false;
            }else{
                if(a[i] != i+1) isok2 = false;
            }
        }
        if(isok2){
            ans = 1ll;
            for(int i=1; i<=n/2; i++){
                ans = ans * 2ll % MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

  int n, a[10], ans, cnt=0;

  cin>>n;
  ans=pow(3, n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2) cnt++;
  }

  cout<<ans-pow(2, n-cnt)<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    map<ll, ll> drink;

    rep(i,n) {
        int tmp,tmp2;
        cin >> tmp >> tmp2;

        drink[tmp] += tmp2;
    }
    ll ans = 0;
    ll get = 0;
    for(auto d : drink) { 
        ll buy = min(m-get,d.second);
        ans += d.first*buy;
        get += buy;
        if(get>m) { break; }
    }

    //for(auto d : drink) { cout << d.first << "," << d.second << endl; 
    
    cout << ans << endl;


    return 0;
}


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

using namespace std;

int main()
{
    int N; 
    int l; 
    int r;
    int data;

    cin >> N;

    int i;
    i = 0;

    while(i < N)
{
    cin >> l;
    cin >> r;
    data += r- l + 1;
    i++;
}
    cout << data << endl;
}

Measured memory_bytes: 256
import statistics
import math

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


ureshimi = []
k = 0
l = 2

B = 0
C = 0
D = 0
E = 0

sumBC = sum(A[0:2])
sumDE = sum(A) - sumBC

for i in range(2, N - 1):
    for j in range(k, i):
        if j == i - 1:
            k = j
            C = sumBC - B
            break
        elif B + A[j] >= sumBC / 2:
            if sumBC / 2 - B  > A[j] / 2:
                B += A[j]
                k = j + 1
                C = sumBC - B
                break
            else:
                k = j
                C = sumBC - B
                break
        B += A[j]
    for j in range(l, N):
        if j == N - 1:
            l = j
            E = sumDE - D
            break
        elif D + A[j] >= sumDE / 2:
            if sumDE / 2 - D > A[j] / 2:
                D += A[j]
                l = j + 1
                E = sumDE - D
                break
            else:
                l = j
                E = sumDE - D
                break
        D += A[j]
    ureshimi.append(max([B, C, D, E]) - min([B, C, D, E]))
    sumBC += A[i]
    sumDE -= A[i]
    D -= A[i]
        

print(min(ureshimi))

Measured memory_bytes: 27764
N = int(input())
a = list(map(int, [input() for i in range(N)]))

current_index = 1
cnt = 0
for i in range(N - 1):
    next_index = a[current_index - 1]
    cnt += 1
    if next_index == 2:
        print(cnt)
        exit()
    current_index = next_index

print(-1)


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

namespace _170A
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine()?.Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
            for(int i = 0 ; i < x.Length ; i++)
            {
                if (x[i] == 0)
                {
                    Console.WriteLine(i+1);
                    break;
                }
            }
        }
    }
}


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

int main(){
     
    vector<int>v;

    for(int i=0;i<3;i++){
    	int x;
    	cin>>x;

    	v.push_back(x);
    }

    sort(v.begin(),v.end());

    if((v[0] == v[1] && v[1]!=v[2]) or (v[1] == v[2] and v[1]!=v[0])){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }

	return 0;
}

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

using namespace std;

static const int N = 100;

void print(int A[], int n) {
    for(int i = 0; i < n; i++) {
        if(i) printf(" ");
        printf("%d", A[i]);
    }
}

int selectionSort(int A[], int n) {
    int i, j, num = 0;

    for(i = 0; i < n; i++) {
        int mini = i;
        for(j = i; j < n; j++) {
           if(A[j] < A[mini]) mini = j;
        }
        if(i != mini) {
            swap(A[i], A[mini]);
            num++;
        }
    }
    return num;
}

int main()
{
    int n, A[N+1];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int num = selectionSort(A, n);
    print(A, n);
    printf("\n%d\n", num);
    return 0;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  double R;

  void init() {
    cin >> R;
  }

  void solve() {
    printf("%.20lf\n", 2 * M_PI * R);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3788
let split = Str.split (Str.regexp_string " ");;

let rec read () =
  let n = read_float () in
  if n > 0. then begin
    let l = read_line () |> split |> List.map float_of_string in
    let avg = (List.fold_left (+.) 0. l)/.n in
    (List.fold_left (fun x y -> x +. (y-.avg)**2.) 0. l)/.n
    |> sqrt |> Printf.printf "%.8f\n";read ()
    end;;

let () = read ();;

Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
struct Edge{
    ll from,to,cost;
};
class Bellman_Ford{
    private:
        vector<Edge> edges;
        vector<ll> d;
        ll V;
    public:
        Bellman_Ford(vector<Edge>& g,ll v):edges(g),V(v){
            d.resize(v,INF);
        }
        bool bellman_ford(ll s){
            d[s] = 0;
            rep(i,V){
                rep(j,edges.size()){
                    Edge e = edges[j];
                    if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
                        d[e.to] = d[e.from]+e.cost;
                        if (i == V-1) return true;
                    }
                }
            }
            return false;
        }
        ll operator[](ll a){
            return d[a];
        }
};
vector<vector<ll>> g(2510);
vector<bool> done(2510,0);
void dfs(ll v){
    done[v] = true;
    for (ll u:g[v]){
        if (done[u]) continue;
        dfs(u);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,v,e;
    cin >> v >> e;
    vector<vector<ll>> graph(e,vector<ll>(3));
    rep(i,e){
        cin >> a >> b >> c;
        c *= -1;
        --a;
        --b;
        g[b].push_back(a);
        graph[i] = {a,b,c};
    }
    dfs(v-1);
    vector<Edge> ng;
    rep(i,e){
        if (done[graph[i][0]] && done[graph[i][1]]){
            ng.push_back(Edge{graph[i][0],graph[i][1],graph[i][2]});
        }
    }
    Bellman_Ford solve(ng,v);
    if (solve.bellman_ford(0)) PRINT("inf");
    else PRINT(-solve[v-1]);
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = [c == '1' for c in S()]
    r = []
    c = n
    while c > 0:
        nc = -1
        for i in range(min(c,m),0,-1):
            if s[c-i]:
                continue
            r.append(i)
            nc = c - i
            break
        if nc == -1:
            return -1
        c = nc

    return JA(r[::-1], " ")


print(main())





Measured memory_bytes: 14416
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read freopen("blue.txt","r",stdin);
#define write freopen("red.txt","w",stdout);

const int N=200005;

using namespace std;

int n,a,x[N];

int main()
{
    fastio;

	cin>>n;

	for(int i=2;i<=n;i++)
	    cin>>a,x[a]++;

	for(int i=1;i<=n;i++)
	    cout<<x[i]<<endl;


	return 0;


}


Measured memory_bytes: 4376
def partition(arr, p, r):
    x = arr[r]
    i = p - 1
    for j in range(p, r):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]

    arr[i+1], arr[r] = arr[r], arr[i+1]
    return i+1

num = int(input())
num_list = [int(s) for s in input().split()]

idx = partition(num_list, 0, len(num_list) - 1)

print(*num_list[:idx], end="")
print(" [" + str(num_list[idx]) + "] ", end="")
print(*num_list[idx+1:])



Measured memory_bytes: 16368
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long lli;

const lli M = 10000000000000LL;

lli digits(lli x){
  lli res = 0;
  if(!x) return 1;
  while(x){
    res++;
    x /= 10;
  }
  return res;
}

lli calc1(string s){
  lli res = 0;
  for(int i=0;i<s.size();i++){
    res *= 2;
    res += s[i] - '0';
  }
  return res;
}

string calc2(string s){
  lli sum = 0;
  lli m = M;
  for(int i=0;i<s.size();i++){
    m /= 2;
    if(s[i] == '1') sum += m;
  }
  lli tmp = 13 - digits(sum);
  while(sum && sum % 10 == 0) sum /= 10;
  string res;
  if(!sum) return "0";
  while(sum){
    res += sum % 10 + '0';
    sum /= 10;
  }
  if(tmp != -1) for(int i=0;i<tmp;i++) res += '0';
  reverse(res.begin(), res.end());
  return res;
}

string calc3(lli x){
  string res;
  while(x >= 2){
    res += '0' + x % 2;
    x /= 2;
  }
  if(x) res += '0' + x;
  int size = 4 - res.size();
  for(int i=0;i<size;i++) res += '0';
  reverse(res.begin(), res.end());
  return res;
}

string conv(string& in){
  string res;
  for(int i=0;i<in.size();i++){
    lli num;
    if('0' <= in[i] && in[i] <= '9') num = in[i] - '0';
    else num = in[i] - 'a' + 10;
    res += calc3(num);
  }
  return res;
}

main(){
  int T;
  cin >> T;
  while(T--){
    string in;
    cin >> in;
    string data = conv(in);
    if(data[0] == '1') cout << "-";
    cout << calc1(data.substr(1, 24)) << "." << calc2(data.substr(25)) << endl;
  }
}

Measured memory_bytes: 1212
#E問題
import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Measured memory_bytes: 7884
MOD = 10**9+7
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
dp = [0] * (n+1)
dp[0] = 1
for i in range(1, n+1):
    if i not in a:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[n])

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N+1);
    rep(i,N+1){
        vec.at(i) = i;
        if(i%3 == 0) vec.at(i) = 0;
        if(i%5 == 0) vec.at(i) = 0; 
        if(i%3 == 0 && i%5 == 0) vec.at(i) = 0;
    }
    ll sum = 0;
    rep(i,N+1){
        sum += vec.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 11100
import Data.List.Split

main = do
 [y, m, d] <- map read . splitOn "/" <$> getLine
 putStrLn $ if (y < 2019)
 				then "Heisei"
                else if (y == 2019) && (m < 4)
                		then "Heisei"
                        else if (y == 2019) && (m == 4) && (d <= 30)
                        	then "Heisei"
                            else "TBD"

Measured memory_bytes: 508
#include<iostream>
#include<map>
using namespace std;
using ll = long long;

int main() {
	ll n,ans = 0,now = 0;
	cin >> n;
	map<ll, ll>mp;
	mp[0]++;
	for (int i = 0;i < n;i++) {
		ll a;
		cin >> a;
		now += a;
		ans += mp[now];
		mp[now]++;
	}
	cout << ans;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<vector>

using namespace std;

#define INF 0x3f3f3f3f
#define gc getchar()

typedef long long ll;
int read()
{
	char c=gc;int u=0,f=1;
	while(c!='-' && (c<'0' || '9'<c))c=gc;
	if(c=='-'){
		f=-1;
		c=gc;
	}
	while('0'<=c && c<='9'){
		u=u*10+c-'0';
		c=gc;
	}
	return u*f;
}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline void swap(int &a,int &b){int t=a;a=b;b=t;}

struct node{
	int k,next;
}G[100010];

int head[100010],cnt=1;

inline void ins(int a,int b)
{
	G[++cnt].k=b;
	G[cnt].next=head[a];
	head[a]=cnt;
}

int fa[100010],dep[100010],ind[100010];

int dp(int k)
{
	vector<int> a;
	int p=0;
	for(int i=head[k];i;i=G[i].next)a.push_back(dp(G[i].k));
	sort(a.begin(),a.end());
	int tim=0;
	for(int i=0;i<a.size();i++){
		tim=max(tim,a[i]);
		tim++;
	}
//	cout<<k<<' '<<tim<<endl;
	return tim;
}

int main()
{
	int n=read();
	for(int i=2;i<=n;i++){
		fa[i]=read();
		ins(fa[i],i);
	}
	cout<<dp(1)<<endl;
	return 0;
}

Measured memory_bytes: 9600
fn main() {
    let v: Vec<u32> = read_vec();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    let d = v[3];
    println!("{}", if a*b>c*d{a*b}else{c*d})
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	
	public Graph() { totalVertex = 0; }
	
	public void loadAdjList() {
		
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		
		for(int i = 0; i < totalVertex; i ++) {
			
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			
			adjList.add(tmp);
		}
		
		in.close();
	}
	
	//do an iterator
	//ID, neighbor, actual neighbors following neighbors
	public void printAdjMatrix() {
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		
		Iterator<LinkedList<Integer>> iter = adjList.iterator();
		
		
		
		for(int i = 0; i < adjList.size(); i++) {
			LinkedList<Integer> currList = iter.next();
			Iterator<Integer> currListIter = currList.iterator();
			
			for(int j = 0; j < currList.size(); j++) {
				adjMatrix[i][currList.get(j)] = 1; 
			}
		}
		
		for(int k = 0; k < adjList.size(); k++) {
			for(int l = 0; l < adjList.size(); l++) {
				if(l < adjList.size()-1) {
					System.out.print(adjMatrix[k][l] + " ");
				} else if(l == adjList.size()-1) {
					System.out.print(adjMatrix[k][l]);
					System.out.println();
				}
			}
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


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

int main() {
  int n;
  cin >>n;
  
  vector<int>h(n);
  for(int i=0; i<n; i++){
    cin >>h[i];
  }
  
  int high = h[0];
  int sum = 1;
  
  for(int i=0; i<n; i++){
    if(h[i+1]>=high&& h[i+1] >= h[i]){
      high = h[i+1];
      sum++;
    }  
  }
  
  printf("%d\n",sum);
  
}

Measured memory_bytes: 256
void main()
{
    long n, m;
    rdVals(n, m);

    long result = n * (n - 1) / 2 + m * (m - 1) / 2;

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
#define pf push_front
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
#define mp make_pair
#define pii pair<int,int>
#define T int t;cin>>t;while(t--)

typedef long long int ll;

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}

int main(){ 
	int n,a,b;
	vector<pii>v;
	cin>>n;
	for(all){
		cin>>a>>b;
		v.pb({b,a});
	}
	sort(v.begin(), v.end());
	int time=0,flag=1;
	for(int i=0; i<n; i++){
		time+=v[i].second;
		if(time>v[i].first){
			flag=0;
			break;
		}
	}
	if(flag==0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}



Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H, W, N;
    cin >> H >> W >> N;
    int ans;
    if (H>W) {
        ans = N/H;
        if ((N%H)>0)
            ans++;
        
    } else {
        ans = N/W;
        if((N%W)>0)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1000000000;
const int MOD=1000000007;

int main()
{
  ll n, t;
  cin >> n >> t;
  ll time[n+1], diff[n+2], ans=0;
  diff[n+1]=INF;
  for(int i=1;i<n+1;i++) cin >> time[i];
  for(int i=1;i<n;i++) diff[i+1]=time[i+1]-time[i];
  for(int i=2;i<n+2;i++){
    if(diff[i]>=t) ans+=t;
    else ans+=diff[i];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3328
'use strict'
function Main(input) {
    input = input.split("\n")
    const string = input[0].split('').map(i => {
      return parseInt(i, 10)
    })

    const arrayN = [...Array(string.length).keys()]
    let model0 = []
    let model1 = []

    arrayN.forEach(v => {
      if(v % 2 == 0) {
        model0.push(0)
        model1.push(1)
      } else {
        model0.push(1)
        model1.push(0)
      }
    })

    const result0 = string.filter((v, i) => {
      return v !== model0[i]
    }).length

    const result1 = string.filter((v, i) => {
      return v !== model1[i]
    }).length

    console.log(Math.min(result0, result1))

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 25340
from itertools import accumulate
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ruiseki = list(accumulate(A[::-1]))

def syakutori(mid):
    x = 0
    cnt = 0
    ans = 0
    for i in range(N)[::-1]: # 大きい方から
        while x < N:
            if A[i] + A[x] >= mid:
                cnt += N - x
                if N - x >= 1:
                    ans += A[i] * (N - x) + ruiseki[N - x - 1]
                break
            else:
                x += 1

    return cnt, ans

# 自分以上の数の個数がM個以上になる値のうち最大のもの
ok = 0
ng = 10 ** 15
while ok + 1 < ng:
    mid = (ok + ng) // 2
    cnt, ans = syakutori(mid)
    if cnt >= M:
        ok = mid
    else:
        ng = mid
# okで終わってる場合はcntがM個以上の場合があるから過分を引く
# ngで終わってる場合は残りM-cnt個のokを足す
print(ans + ok * (M - cnt)) 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

int main(){
    cin >> s;
    rep(i,1<<3){
        ll num = s[0] - '0';
        rep(j,3){
            if(i & (1 << j))num += s[j+1] - '0';
            else num -= s[j+1] - '0';
        }
        if(num == 7){
            cout << s[0];
            rep(j,3){
                if(i & (1 << j))cout << "+";
                else cout << "-";
                cout << s[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string s,t;
    cin>>N>>s>>t;
    
    int res=s.size()+t.size();
    
    for(int i=0;i<s.size();i++){
        if(s.substr(i,s.size()-i)==t.substr(0,s.size()-i)){res=i+t.size();break;}
    }
    
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
typedef vector<vector<ll> > matrix;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e5+5;
const int MAX_LOG=17;

int N, a, res=INT_MAX;
unordered_map<int,int>MP1, MP0;
vector<pi> odd, even;

inline int cal(pi a1, pi a2)
{
    if(a1.s==a2.s)
        return N-max(a1.f, a2.f);
    return N-a1.f-a2.f;
}

int main()
{
    N=in();
    MP0.clear();
    MP1.clear();
    Forn(i, N)
    {
        a=in();
        if(i&1)
           MP1[a]++;
        else
           MP0[a]++;
    }
    foreach(it, MP0)
    {
        odd.eb(mp(it->s, it->f));
        sort(odd.rbegin(), odd.rend());
        while(odd.size()>2)
            odd.pop_back();
    }
    foreach(it, MP1)
    {
        even.eb(mp(it->s, it->f));
        sort(even.rbegin(), even.rend());
        while(even.size()>2)
            even.pop_back();
    }
    foreach(it, odd)
        foreach(ii, even)
            res=min(res, cal(*it, *ii));
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 4376
import math
a,b,h,m = map(int,input().split())
def bbb(h,m):
    z = m/60
    x = ((h)*60 + m)/720
    z*=360
    x*=360
    c = min(abs(x-z),(360-abs(z-x)))


    # print(math.cos(c))
    # print((2*b*a*math.cos(c)))

    ans = a**2 + b**2 - (2*a*b*math.cos(math.radians(c)))
    return ans**0.5
print(bbb(h,m))

Measured memory_bytes: 9580
/*

*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

bool func(int num)
{
    for (int i = 2; i <= sqrt(num); i++)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    std::cin >> n;
    int cnt = 0, i = 1;

    while (cnt < n)
    {
        if (func(i * 5 + 1))
        {
            cnt++;
            std::cout << i * 5 + 1 << " ";
        }
        i++;
    }

    return 0;
}

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

using namespace std;

#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 10000005

int32_t main()
{
	int x, y;
	cin >> x >> y;
	for(int i = 1; i <= x; i++)
	{
		int ans = i*2 + ((x-i)*4);
		int ans2 = i*4 + ((x-i)*2);
		if(ans == y)
		{
			cout << "Yes\n";
			return 0;
		}
		if(ans2 == y)
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M;
    cin >> N>> M;
    int K = 0;
    for(int i=0;i<M;i++){
        int J;
        cin >>J;
        K += J;
    }

    if(N - K >= 0){
        cout << N - K << endl;
    }else{
        cout << -1 << endl;
    }
 
}


Measured memory_bytes: 3632
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

string s;

int d;

int dp[N][2][104];

void add_self(int &a,int b)
{
    a+=b;
    
    if(a>=mod)
    a-=mod;
}

int rec(int ind,int flag,int rem)
{
    if(ind==s.size())
    {
        return rem==0;
    }
    
    int &ans=dp[ind][flag][rem];
    
    if(ans!=-1)
    return ans;
    
    ans=0;
    
    int lim=9;
    
    if(flag==0)
    lim=s[ind]-'0';
    
    rep(i,0,lim+1)
    {
        int hf=flag,hrem=rem;
        
        if(i<lim)
        hf=1;
        
        hrem=(hrem+i)%d;
        
        ll here=rec(ind+1,hf,hrem);
        
        add_self(ans,here);
    }
    
    return ans;
}

int main()                  
{
    memset(dp,-1,sizeof(dp));
    
    cin>>s;
    
    scn(d);
    
    int ans=rec(0,0,0);
    
    ans--; //we have to count from 1 to given number, so subtract contribution of 0
    
    if(ans==-1)
    ans+=mod;
    
    printf("%d ",ans);
} 

Measured memory_bytes: 82304
#include <iostream>
#include <cmath>
#include <cstdio>
#define PI 3.14159265
using namespace std;

struct Point{
  double x;
  double y;
  Point(double _x,double _y){
    x=_x;
    y=_y;
  }
};

Point* rotate(Point p, Point base, double rad){
  return new Point(
      cos(rad)*(p.x-base.x) - sin(rad)*(p.y-base.y) + base.x,
      sin(rad)*(p.x-base.x) + cos(rad)*(p.y-base.y) + base.y);
}

void koch(Point p1,Point p2,int depth){
  if(depth==0){
    printf("%.8lf %.8lf\n",p1.x,p1.y);
    return;
  }
  Point *s,*t,*u;
  s = new Point( (p2.x - p1.x)/3.0 + p1.x, (p2.y - p1.y)/3.0 + p1.y );
  t = new Point( (p2.x - p1.x)*2.0/3.0 + p1.x, (p2.y - p1.y)*2.0/3.0  + p1.y);
  u = rotate(*t,*s,PI/3.0);
  koch(p1,*s,depth-1);
  koch(*s,*u,depth-1);
  koch(*u,*t,depth-1);
  koch(*t,p2,depth-1);
}

int main(){
  int n; cin>>n;
  Point p1(0,0);
  Point p2(100,0);
  koch(p1,p2,n);
  printf("%.8lf %.8lf\n",p2.x,p2.y);
}

Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
struct node{
    int l, r;
};
const int N = 1e6 + 7;
string s[N];
int n;

vector<node>a;
vector<node>b;

bool cmp(node x, node y){
    return x.r < y.r;
}

bool cmp1(node x, node y){
    return x.l < y.l;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout .tie(0);
    //scanf("%d", &n);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        int len = s[i].length();
        int l =0, r = 0;
        for(int j = 0; j < len; j++){
            if(s[i][j] == '(') l++;
            else if(l) l--;
            else r++;
        }
        if(l >= r) a.push_back({l, r});
        else b.push_back({l, r});
    }
    sort(a.begin(), a.end(), cmp);
    sort(b.begin(), b.end(), cmp1);
    int sum = 0, ok = 0;
    for(int i = 0; i < a.size(); i++){
        sum -= a[i].r;
        if(sum < 0){
            ok = 1;
            break;
        }
        sum += a[i].l;
    }
    int sum1 = 0;
    for(int i = 0; i < b.size(); i++){
        sum1 -= b[i].l;
        if(sum1 < 0){
            ok = 1;
            break;
        }
        sum1 += b[i].r;
    }
    if(ok){
       puts("No");
    }else{
        if(sum == sum1){
            puts("Yes");
        }else{
            puts("No");
        }
    }

}

Measured memory_bytes: 42452
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	if(!n&&!m)printf("0 0"),exit(0);
	n=pow(2,n)-1;
	if(m>n||(n==1&&m==1))printf("-1"),exit(0);
	if(n==1&&m==0)printf("0 0 1 1"),exit(0);
	for(int i=0;i<=n;i++)if(i!=m)printf("%d ",i);
	printf("%d ",m);
	for(int i=n;i>=0;i--)if(i!=m)printf("%d ",i);
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
using namespace std;
ll a[27];
int main()
{
	ll n,m,i,j;
	cin>>n>>m;
	string s[n+1];
	for(i=0;i<n;++i)
	{
		cin>>s[i];
		for(j=0;j<m;j++)a[s[i][j]-'a']++;
	}
	for(i=0;i<26;i++)a[i]%=4;
	ll tw=0,on=0,th=0;
	for(i=0;i<26;i++)
	if(a[i]==1)on++;else
	if(a[i]==2)tw++;else
	if(a[i]==3)th++;
	if(n%2==0&&m%2==0)
	{
		if(on==0&&tw==0&&th==0)cout<<"Yes";else cout<<"No";return 0;
	}else
	if(n%2==1)
	{
		if(m%2==1)
		{
			if((on+th==1)&&tw<=(n/2+m/2))cout<<"Yes";else cout<<"No";return 0;
		}else
		{
			if(tw<=m/2&&(th+on==0))cout<<"Yes";else cout<<"No";return 0;
		}
	}else
	{
		if(tw<=n/2&&(th+on==0))cout<<"Yes";else cout<<"No";return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n, ans, sz[N];
vector<ll> G[N], vec[N];
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll sum(ll a, ll b) {
	return (a + b) % Mod;
}
ll sub(ll a, ll b) {
	return (a + Mod - b) % Mod;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; a = mul(a, a), b >>= 1)
		if (b & 1) res = mul(res, a);
	return res;
}
ll inv(ll x) {
	return Pow(x, Mod - 2);
}
ll ddd(ll a, ll b) {
	return mul(a, inv(b));
}
ll dfs(ll v  = 1, ll par = 0) {
	sz[v] ++;
	for (auto u : G[v]) 
		if (u ^ par) {
			ll res = dfs(u, v);
			vec[v].pb(res);
			sz[v] += res;
		}
	if (n != sz[v])vec[v].pb(n - sz[v]);
	return sz[v];
	
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n;
    for (int i = 0; i < n - 1; i ++) {
    	ll v, u;
    	cin >> v >> u;
    	G[v].pb(u);
    	G[u].pb(v);
	}
	
	dfs();    
    ll ans = 0;
    
    for (int i = 1; i <= n; i ++) {
    	//cout << i << endl;
    	ll res = Pow(2, n - 1);
    	ll cur = 1;
    	for (int j = 0; j < vec[i].size(); j ++) cur = sum(cur, sub(Pow(2ll, vec[i][j]), 1ll));
    	res = sub(res, cur);
    	ans = sum(ans, res);
	}


	ans = ddd(ans, ll(Pow(2, n)));
	cout << ans << endl;	
    return (0) ;
}

Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

const int N=2e5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	deque<char> Q;
	int rev=0;
	int q;
	cin>>s>>q;
	for(char c:s) Q.push_back(c);
	while(q--){
		int t;
		cin>>t;
		if(t==1) rev^=1;
		else{
			int f;
			char add;
			cin>>f>>add;
			if(rev) f=3-f;
			if(f==1) Q.push_front(add);
			else Q.push_back(add);
		}
	}
	if(rev) reverse(Q.begin(),Q.end());
	for(char c:Q) cout<<c;
	return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, T;
	cin >> A >> B >> T;
	cout << (T / A) * B << endl;

	return 0;
}


Measured memory_bytes: 256
s=input()
cont=0
for i in range(0,len(s),2):
  if s[i]=="L":
    print("No")
    cont+=1
    break
for j in range(1,len(s),2):
  if s[j]=="R" and cont==0:
    print("No")
    cont+=1
    break
if cont==0:
    print("Yes")

Measured memory_bytes: 9080
//#pragma GCC optimize(2)
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 1000011
#define f(x,y) (y*n+x)
using namespace std;
struct apple{
	int v,nxt;
}edge[N*11];
int indexx[N],tot,cur[N],vist[N*11],n,No[N],Stack[N*11],top,type[N*11];
void addedge(int x,int y){
	edge[++tot].v=y;
	edge[tot].nxt=indexx[x];
	indexx[x]=tot;
}
struct Tree{
	int fa[N],Root,d[N];
	void init(int op){
		for(int i=1;i<=n;i++){
			scanf("%d",&fa[i]);
			if(fa[i]==-1) Root=i;
			else{
				d[fa[i]]++;
				addedge(f(fa[i],op),f(i,op));
				addedge(f(i,op),f(fa[i],op));
			}
		}
		for(int i=1;i<=n;i++) d[i]&=1;
	}
}T1,T2;
void dfs(int u){
	Stack[++top]=u;
	type[top]=1;
	while(top){
		u=Stack[top];
		int flag=1;
		if(type[top]==1){
			int t=cur[u],vv;
			while(t){
				vv=edge[t].v;
				cur[u]=t;
				if(!vist[t] && !vist[((t-1)^1)+1]){
					vist[t]=1;
					flag=0;
					Stack[++top]=vv;
					type[top]=1;
					break;
				}
				t=edge[t].nxt;
			}
			if(flag) type[top]=2;
		}
		else{
			top--;
		}
	}
}
int main(){
	scanf("%d",&n);
	T1.init(0);
	T2.init(1);
	for(int i=1;i<=n;i++){
		if(T1.d[i]!=T2.d[i]){
			printf("IMPOSSIBLE\n");
			return 0;
		}
		if(!T1.d[i]){
			addedge(f(i,0),f(i,1));
			No[i]=tot;
			addedge(f(i,1),f(i,0));
		}
	}
	printf("POSSIBLE\n");
	addedge(f(T1.Root,0),f(T2.Root,1));
	addedge(f(T2.Root,1),f(T1.Root,0));
	memcpy(cur,indexx,sizeof(indexx));
	dfs(1);
	for(int i=1;i<=n;i++){
		if(!T1.d[i]){
			if(vist[No[i]]) printf("1 ");
			else if(vist[((No[i]-1)^1)+1]) printf("-1 ");
			else printf("! ");
		}
		else printf("0 ");
	}
	return 0;
}

Measured memory_bytes: 19740
n = int(input())
a = list(map(int,input().split()))

ans = 0

#a.insert(0,0)
a.append(99999999999999999)
tmp = 0
for i in range(n):
  #print(tmp)
  if a[i] <= a[i+1]:
    tmp = 0
    continue
  else:
    tmp = a[i] - a[i+1]
    a[i+1] += tmp
    ans += tmp
    
print(ans)
#print(a)

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


int main() {
  string S ; 
  cin >> S ; 
  
  for(int i = 0 ; i < 3 ; i++){
    if (S.at(i) == S.at(i+1)) {
      cout << "Bad" << endl ; 
      return 0 ; 
    }
  }
  
  cout << "Good" << endl ; 
  
  
  
}

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

w_rotation = 0
e_rotation = S.count("E")
ans = w_rotation + e_rotation
for i in range(N):
    if S[i] == "W":
        w_rotation += 1
    else: # S[i] == "E":
        e_rotation -= 1
    if ans > w_rotation + e_rotation:
        ans = w_rotation + e_rotation

print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi A(N);
    map<int,int> m;
    rep(i,N) {
        cin >> A[i];
        A[i]-=i;
        m[A[i]]++;
    }
    int ans=0;
    rep(i,N){
        ans+=m[-A[i]-i*2];
        m[A[i]]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 27432
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String w;
		int count=0;
		
		Scanner scan = new Scanner(System.in);
		w=scan.next().toLowerCase();
		while(true){
			String temp = scan.next();
			if(temp.equals("END_OF_TEXT")){
				break;
			}
			char[] c = temp.toLowerCase().toCharArray();
			temp="";
			for(int i = 0;i<c.length;i++){
				if(c[i]>='a'&&c[i]<='z'){
					temp+=c[i];
				}
			}
			if(temp.equals(w))
				count++;
		}
		scan.close();
		System.out.println(count);
	}
}


Measured memory_bytes: 26324
import java.util.Scanner;
import java.util.Arrays;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String str = sc.nextLine();
      String[] str2 = str.split(" ");
      int[] x = new int[2];
      for (int i = 0; i < 2; i++){
        x[i] = Integer.parseInt(str2[i]);
      }
      if(x[0] == 0 && x[1] == 0){
        break;
      }
      Arrays.sort(x);
      System.out.println(x[0] + " " + x[1]);
    }
  }
}


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

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

  int minans = max((int)(A * 12.5), B*10);
  int ans = -1;
  for(int i = minans; i <= min(minans * 2, 10000); ++i){
    if((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

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

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  string s,t;
  cin >> s >> t;
  int ans = 1e8;
  rep(i,s.size()-t.size()+1){
    int cnt = 0;
    rep(j,t.size()){
      if(s[i+j]!=t[j])cnt++;
    }
   
    chmin(ans,cnt);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3668
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    A[a - 1] = max(A[a - 1], H[b - 1])
    A[b - 1] = max(A[b - 1], H[a - 1])

ans = sum(H[i] > A[i] for i in range(N))
print(ans)

Measured memory_bytes: 20152
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> students(n);
  for (int i = 0; i < n; ++i) {
    int x, y; cin >> x >> y;
    students[i] = {x, y};
  }

  vector<pair<int, int>> checkpoints(m);
  for (int i = 0; i < m; ++i) {
    int x, y; cin >> x >> y;
    checkpoints[i] = {x, y};
  }

  for (int i = 0; i < n; ++i) {
    int result = 0;
    for (int j = 1; j < m; ++j) {
      int result_d = abs(checkpoints[result].first - students[i].first) +
        abs(checkpoints[result].second - students[i].second);
      int curr_d = abs(checkpoints[j].first - students[i].first) +
        abs(checkpoints[j].second - students[i].second);

      if (curr_d < result_d) result = j;
    }

    cout << result + 1 << "\n";
  }
}


Measured memory_bytes: 3616