akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    
    if((a*b)%2==0) cout<<"Even";
    else cout<<"Odd";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;
const int N = 2019;

long long int power(long long int x,long long int y,long long int p) 
{ 
	long long int res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

void solve(){
	lli a,b,x; cin>>x;
	NA(i,-127,128){
		NA(j,-127,128){
			a = power(i,5,MOD*100LL);
			b = power(j,5,MOD*100LL);
			if(a-b == x) {cout<<i<<' '<<j; return;}
			else if(b-a==x) {cout<<j<<' '<<i; return;}
		}
	}
    return;
}
void test(){
	lli n = 1e9 + 1;
	NA(i,100, 1000) {
		lli s = 0;
		s += (4LL*i*i*i);
		s += (6LL*i*i);
		s += (4LL*i + 1LL);
		s *= i;
		if(s>n) {cout<<i; break;}
	}
	return;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("Ofast")

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING

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


int h, w, k;
char board[6][6];


int possible(int row_mask, int col_mask) {
	char new_board[6][6];
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			new_board[i][j] = board[i][j];

	for (int mask = 1, cnt=0; mask < (1 << h); mask <<= 1, ++cnt) {
		if (!(row_mask & mask)) continue;

		for (int j = 0; j < w; ++j)
			new_board[cnt][j] = '.';
	}

	for (int mask = 1, cnt = 0; mask < (1 << w); mask <<= 1, ++cnt) {
		if (!(col_mask & mask)) continue;

		for (int i = 0; i < h; ++i)
			new_board[i][cnt] = '.';
	}
	
	int black_cnt = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (new_board[i][j] == '#')
				++black_cnt;

	/*if (k == black_cnt) {
		cout << row_mask << ' ' << col_mask << '\n';
	}*/

	return black_cnt == k;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	cin >> h >> w >> k;

	int black_cnt = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			cin >> board[i][j];
			if (board[i][j] == '#')
				++black_cnt;
		}

	/*if (black_cnt == k) {
		++black_cnt;
	}*/

	int counter = 0;
	for (int row_mask = 0; row_mask < (1 << h); ++row_mask) {
		for (int col_mask = 0; col_mask < (1 << w); ++col_mask) {
			counter += possible(row_mask, col_mask);
		}
	}
	cout << counter << '\n';

	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=5000+10;
const int mod=1e9+7;
struct edge { int v,nxt; } e[N<<1];
int head[N];
inline void add(int u,int v)
{
    static int e_cnt=0;
    e[++e_cnt]=(edge){v,head[u]},head[u]=e_cnt;
}
int n,sz[N];
int f[N][N],g[N],tmp[N];
inline void dfs(int u,int fa)
{
    sz[u]=f[u][1]=1;
    for (int i=head[u];i;i=e[i].nxt)
	{
        int v=e[i].v; 
		if (v==fa) continue;
        dfs(v,u);
        for (int j=1;j<=sz[u]+sz[v];++j) tmp[j]=0;
        for (int j=1;j<=sz[u];++j)
            for (int k=0;k<=sz[v];++k)
                tmp[j+k]=(tmp[j+k]+1ll*f[u][j]*f[v][k])%mod;
        sz[u]+=sz[v];
        for (int j=1;j<=sz[u];++j) f[u][j]=tmp[j];
    }
    for (int i=2;i<=sz[u];i+=2)
        f[u][0]=(f[u][0]-1ll*f[u][i]*g[i]%mod+mod)%mod;
}
int main() 
{
    n=read();
    for (int i=1;i<n;++i) 
	{
        int u=read(),v=read();
        add(u,v),add(v,u);
    }
    g[0]=1;
    for (int i=2;i<=n;i+=2) g[i]=1ll*g[i-2]*(i-1)%mod;
    dfs(1,0);
	printf("%d\n",mod-f[1][0]);
    return 0;
}

Measured memory_bytes: 58236
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int N,K;
    cin>>N>>K;
    vll a(N);
    rep(i,0,N)cin>>a[i];
    rep(i,K,N){
        if(a[i-K]<a[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 4840
package main
import (
       "fmt"
       "os"
       "bufio"
       "strconv"
)

func main() {
     sc := bufio.NewScanner(os.Stdin)
     sc.Split(bufio.ScanWords)

     var prm [5]int
     for i := 0; sc.Scan(); i++ {
     	 prm[i], _ = strconv.Atoi(sc.Text())
     }

     if (prm[4] <= prm[2]) &&
     	(prm[2] <= prm[0] - prm[4]) &&
	(prm[4] <= prm[3]) &&
	(prm[3] <= prm[1] - prm[4]){
	fmt.Println("Yes")
     } else {
        fmt.Println("No")
     }
}


Measured memory_bytes: 1112
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        String result = "AGC";
        if (n < 1200) {
            result = "ABC";
        } else if (n < 2800) {
            result = "ARC";
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 35340
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

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

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

using namespace std;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red(a), green(b), nocolor(c), eat;
  for (int i=0; i<a; ++i) cin >> red.at(i);
  for (int i=0; i<b; ++i) cin >> green.at(i);
  for (int i=0; i<c; ++i) cin >> nocolor.at(i);
  sort(red.begin(), red.end(), greater<int>());
  sort(green.begin(), green.end(), greater<int>());
  sort(nocolor.begin(), nocolor.end(), greater<int>());
  
  for (int i=0; i<x; ++i) eat.push_back(red.at(i));
  for (int i=0; i<y; ++i) eat.push_back(green.at(i));
  sort(eat.begin(), eat.end());
  
  for (int i=0; i<min(c, x+y); ++i) {
    if (eat.at(i) < nocolor.at(i)) eat.at(i) = nocolor.at(i);
  }
  
  long long res = 0;
  for (int x : eat) res += x;
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 2552
#!/usr/bin/perl

use strict;
use warnings;

my ($s, $t);
{
    my $in = <STDIN>;
    ($s, $t) = split(" ", $in);
}
my ($a, $b);
{
    my $in = <STDIN>;
    ($a, $b) = split(" ", $in);
}
my $u = <STDIN>;
chomp $u;

$a-- if $s eq $u;
$b-- if $t eq $u;

print "$a $b\n";

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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int R = 0, B = 0;
	
	for(int i = 0; i < n; i++){
		if(s[i] == 'B'){
			B++;
		}
		else R++;
	}
	if(R > B){
		cout <<"Yes"<<"\n";
	}
	else cout <<"No"<<"\n";
}

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

#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)


void solve() 
{
    int n,k;cin>>n>>k;
    int cnt=0;
    while(n){
        cnt++;
        n/=k;
    }
    cout<<cnt<<endl;
}

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

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

int main() {
int a,b;
string s;
cin>>a>>b;
cin>>s;
  //cout<<s<<endl;
bool flg=1;
for(int i=0;i<a+b+1;i++){
char t=s[i];
if(i==a){
  if(t!='-'){
    flg=0;
    break;
  }
}
else{
  if(t=='-'){
    flg=0;
    break;
  }
}
}
if(flg) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
# 66

from decimal import *
import heapq

class UnionFind:
    def __init__(self, n):
        self.rank = [1] * n
        self.par = [int(x) for x in range(n)]
        
    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def unite(self, x, y):
        p_x = self.find(x)
        p_y = self.find(y)
        if p_x == p_y:
            return False
        if self.rank[p_x] < self.rank[p_y]:
            self.par[p_x] = p_y
            self.rank[p_x] += 1
        else:
            self.par[p_y] = p_x
            self.rank[p_y] += 1
        return True
    
    def same(self, x, y):
        p_x = self.find(x)
        p_y = self.find(y)
        if p_x == p_y:
            return True
        else:
            return False
    
while True:
    N = int(input())
    if N == 0:
        exit(0)
    C_L = [[int(Decimal(x) * (10**3)) for x in input().split()] for y in range(N)]
    
    UF = UnionFind(N)
    hq = []
    for i in range(N):
        i_x, i_y, i_z, i_r = C_L[i]
        for j in range(i+1,N):
            j_x, j_y, j_z, j_r = C_L[j]
            _d = ((i_x - j_x)**2 + (i_y - j_y)**2 + (i_z - j_z)**2) ** (0.5) - i_r - j_r
            hq.append([_d, i, j])
#     print(hq)
#     print("HOGE")
    ans = 0
    heapq.heapify(hq)
    while len(hq) > 0:
        _d, _i, _j = heapq.heappop(hq)
        if UF.same(_i, _j):
            continue
        ans += max(_d, 0)
        UF.unite(_i, _j)
    print("{:.3f}".format(ans / (10**3)))




Measured memory_bytes: 7076
use std::io;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();

    let _ = stdin.read_line(&mut buf);
    buf.clear();

    let _ = stdin.read_line(&mut buf);
    let mut vec: Vec<&str> = buf.split_whitespace().collect();
    vec.reverse();

    println!("{}", vec.join(" "));
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  int N,K;
  cin>>N>>K;
  vector<ll>V(N);
  for(int i=0;i<N;i++)cin>>V[i];
  ll sum=0;
  ll Max=0;
  for(int l=0;l<=K;l++){
    for(int r=0;r+l<=K&&r+l<=N;r++){
      ll ans=0;
      vector<ll>get;
      for(int i=0;i<l;i++)get.push_back(V[i]);
      for(int i=0;i<r;i++)get.push_back(V[N-(i+1)]);
      ll d=K-(r+l);
      sort(rng(get));
      for(int i=0;i<get.size();i++)ans+=get[i];
      for(int i=0;i<d&&i<get.size();i++){
        if(get[i]<0)ans-=get[i];
      }
      Max=max(Max,ans);
    }
  }
  cout<<Max<<endl;
  return 0;
}


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

int int_sort ( const void *a, const void *b){
    if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(void){
    int N = 0;
    int z[1001] ={ };
    int index=0;
    scanf("%d \n", &N);
    do{
    scanf("%d ",&z[index]);
    index++;
    }while(index < N);
    qsort( &z, N, sizeof(int), int_sort);

    printf("%d\n", (z[N-1] - z[0]));
    return 0;
}

Measured memory_bytes: 128
k,x=map(int,input().split())
maxx=0
minx=0
maxx=1000000 if x+k-1>1000000 else x+k-1
minx=-1000000 if x-k+1<-1000000 else x-k+1
ans=""
for i in range(minx,maxx+1):
  ans+=str(i)+" "
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    vector<int> A(3, 0);
    for (int i = 0; i < 3; i++)
    {
        cin >> A[i];
    }

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

    int ans = (A[1] - A[0]) + (A[2] - A[1]);
    cout << ans << endl;

    return (0);
}

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

int main(){
  int cards[4][13] = {{0}};
  int n,num;
  char s;
  cin >> n;
  for(int i = 0; i<n; i++ ){
    cin >> s >> num;
    if(s == 'S'){
      cards[0][num-1] = 1;
    }
    if(s == 'H'){
      cards[1][num-1] = 1;
    }
    if(s == 'C'){
      cards[2][num-1] = 1;
    }
    if(s == 'D'){
      cards[3][num-1] = 1;
    }
  }

  for(int i = 0; i<4; i++ ){
    for(int k = 0; k<13; k++ ){
      if(cards[i][k] != 1){
        if(i == 0){
          cout << 'S' << " " << k+1 << endl;
        }
        if(i == 1){
          cout << 'H' << " " << k+1 << endl;
        }
        if(i == 2){
          cout << 'C' << " " << k+1 << endl;
        }
        if(i == 3){
          cout << 'D' << " " << k+1 << endl;
        }
      }
    }
  }
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

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

  bool check = 0;
  double x = (double) n / 1.08;
  double y = (double)(n+1) / (double)1.08;

  for (int i = 1; i < 54002; i++) {
    if (x <= i && i < y) {
      cout << i << endl;
      check = 1;
      break;
    }
  }
  if (check == 0) {
    cout << ":(" << endl;
  }
}  

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    if(n%100<=(n/100)*5) {
    	System.out.println(1);
    }else {
    	System.out.println(0);
    }
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  map<string, int>mp;
  string S;
  for(int i = 0; i < N; i++){
    cin >> S;
    mp[S]++;
  }
  int max = 0;
  for(auto i = mp.begin(); i != mp.end();i++){
    if(i->second > max)max = i->second;
  }
  for(auto i = mp.begin(); i != mp.end();i++){
    if(i->second == max)cout << i->first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26764
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const int mod = 1e9+7;
const int N = 1e5+10; 
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
int main(){
  fast;
  int n;cin >> n;
  vector<ll> a(n);
  FOR(i,0,n-1)cin >> a[i];
  sort(all(a));
  FOR(i,1,n-1)a[i] += a[i-1];
  NFOR(i,n-2,0){
  	if(a[i+1] > 2*a[i]){
  		cout << n - 1 - i << "\n";
  		return 0;
  	}
  	if(i)a[i] -= a[i-1];
  }
  cout << n << "\n";
  return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline

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

    cnt = [0] * 3
    for a in A:
        cnt[a-1] += 1

    dp = [[[0.] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
    for k in range(N+1):
        for j in range(N+1-k):
            for i in range(N+1-j-k):
                ijk = float(i + j + k)
                if ijk == 0:
                    continue
                x = N / ijk
                tmp = 0
                if i > 0:
                    tmp += (dp[i-1][j][k] + x) * (i / ijk)
                if j > 0 and i < N:
                    tmp += (dp[i+1][j-1][k] + x) * (j / ijk)
                if k > 0 and j < N:
                    tmp += (dp[i][j+1][k-1] + x) * (k / ijk)
                dp[i][j][k] = tmp
    print(dp[cnt[0]][cnt[1]][cnt[2]])


if __name__ == '__main__':
    main()


Measured memory_bytes: 254492
_=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

a2=a.group_by(&:itself).select{|k,v|v.size==1}.map{|k,v|k}


if(a2.size==0 || a.size==1) 
    p a.reduce(:gcd)
else
    r=a2.min_by{|x| x.gcd(a2[0])}
    p [a.select {|x| x!=r}.reduce(:gcd) , a.drop(1).reduce(:gcd) ].max
    
end


Measured memory_bytes: 10244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class ALDS1_2B
    {
        static int count = 0;
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] iArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            SelectionSort(iArr, n);

            WriteArr(iArr);
            Console.WriteLine(count);

            Console.ReadLine();
        }

        static void SelectionSort(int[] _arr, int _n)
        {
            for (int i = 0; i < _n; i++)
            {
                int minj = i;
                for (int j = i; j < _n; j++)
                {
                    if(_arr[j] < _arr[minj])
                    {
                        minj = j;
                    }
                }
                if (i != minj)
                {
                    int tmp = _arr[i];
                    _arr[i] = _arr[minj];
                    _arr[minj] = tmp;
                    count++;
                }
            }
        }

        static void WriteArr(int[] _arr)
        {
            int len = _arr.Length;
            if (len > 0)
            {
                Console.Write(_arr[0]);
            }

            if (len > 1)
            {
                for (int i = 1; i < len; i++)
                {
                    Console.Write(string.Format(" {0}", _arr[i]));
                }
            }
            Console.Write("\r\n");
        }
    }
}

Measured memory_bytes: 9572
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 1e2+2;
const int MAXVAL = 1e3+2;
const int MAXSOL = MAXN*MAXVAL;

const int INF = 1e9+9;

int n, w;
int weight[MAXN], val[MAXN];
int dp[MAXN][MAXSOL];

int main() {
  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", weight+i, val+i);
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MAXSOL; ++j) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;
  dp[0][val[0]] = weight[0];

  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < MAXSOL; ++j) {
      dp[i][j] = dp[i-1][j];
    }
    for (int j = val[i]; j < MAXSOL; ++j) {
      dp[i][j] = min(dp[i][j], dp[i-1][j-val[i]]+weight[i]);
    }
  }

  int sol = 0;
  for (int i = MAXSOL-1; i >= 0; --i) {
    if (dp[n-1][i] <= w) {
      sol = i;
      break;
    }
  }

  printf("%d\n", sol);
  return 0;
}


Measured memory_bytes: 40064
#include<cstdio>
int main(){int n,i,j,s,m,a[5000];while(scanf("%d",&n)&&n){for(i=0;i<n;i++)scanf("%d",&a[i]);m=-100000*n-1;for(i=0;i<n;i++,s=0)for(j=i;j<n;)if((s+=a[j++])>m)m=s;printf("%d\n",m);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
int main(){
	int h, w; cin>>h>>w;
	vector<string> s(h);
	rep(i, h){
		cin>>s[i];
	}
	vector<vector<int>> f(h, vector<int>(w));
	rep(i, h){
		rep(j, w){
			if(i + j == 0){
				f[0][0] = (s[0][0] == '#');
			} else{
				f[i][j] = (int)1e9;
				if(i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
				if(j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
			}
		}
	}
	cout<<f[h - 1][w - 1]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)
ll max(ll a,ll b) {
    return a>b?a:b;
}
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    ll ans=0;
    //cout<<n;
    for(ll i=0;i<s.length();i++) ans+=s[i]-'0';
    if(ans%9==0) cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3772
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    P = [I() for _ in range(N)]

    # Pの最長連続増加部分列以外のところを動かす回数が答え
    # 最長連続増加部分列は、各数字を昇順に並べてP内のインデックスを見ればよい
    enum_P = [(i, e) for e, i in enumerate(P)]
    enum_P.sort()
    # print(enum_P)

    cis = []
    tmp = []
    for i in range(N):
        tmp.append(enum_P[i][1])
        if i < N - 1 and enum_P[i][1] > enum_P[i+1][1]:
            cis.append(tmp)
            tmp = []
    cis.append(tmp)

    ans = N - max([len(i) for i in cis])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 60520
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n, h, w;
    cin >> n >> h >> w;

    int64_t count = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t a, b;
        cin >> a >> b;
        count += (h <= a && w <= b ? 1 : 0);
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y,su):
        x = root(x)
        y = root(y)
        su += comb_2(s[x])+comb_2(s[y])
        if rank[x] < rank[y]:
            s[y] += s[x]
            su -= comb_2(s[y])
            par[x] = y
        else:
            s[x] += s[y]
            su -= comb_2(s[x])
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return su

    def comb_2(a):
        return a*(a-1)//2

    n,m = LI()
    v = LIR(m)
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = comb_2(n)
    ans = [su]
    for a,b in v[:0:-1]:
        a -= 1
        b -= 1
        if root(a) != root(b):
            su = unite(a,b,su)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 111324
#include <stdio.h>

int main(void)
{
    int n;
    int a[100];

    scanf("%d", &n);

    int i;

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

        scanf("%d", &a[i]);
    }

    int b[100];

    for (i = 0; i < n; i++)
    {
        b[i] = a[n - i - 1];
    }

    for (i = 0; i < n - 1; i++)
    {
        printf("%d ", b[i]);
    }

    printf("%d\n", b[i]);

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

ll N, X, L;


int main() {
    cin >> N >> X;
    ll S = 0;
    ll ans = 1;
    REP (i, N) {
        cin >> L;
        S += L;
        if (S <= X) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {


int main(void) {
  int H,W;cin>>H>>W;
  char S[H+10][W+10];
  rep(i,0,H-1) {
    rep(j,0,W-1) {
      cin >> S[i][j];
    }
  }

  vector<i_i> XY;
  XY.push_back(make_pair(1,0));
  XY.push_back(make_pair(0,1));
  XY.push_back(make_pair(-1,0));
  XY.push_back(make_pair(0,-1));

  int ans=0;

  rep(i,0,H-1) {
    rep(j,0,W-1) {
      if(S[i][j]=='#') continue;

      int seen[H+10][W+10];
      fill(seen[0],seen[H+10],0);
      int dist[H+10][W+10];
      fill(dist[0],dist[H+10],INF);
      queue<i_i> todo;

      todo.push(make_pair(i,j));
      dist[i][j]=0;
      while(!todo.empty()) {
        i_i tar = todo.front();
        todo.pop();
        if(!seen[tar.first][tar.second]) {
          // pr("==");
          // pr(tar.first,tar.second);
          // pr("--");
          for(auto xy:XY) {
            if((0<=tar.first + xy.first && 0<=tar.second+ xy.second) &&
            (tar.first+xy.first<H && tar.second+xy.second<W) &&
            (S[tar.first+xy.first][tar.second+xy.second] == '.')) {
              todo.push(make_pair(tar.first+xy.first,tar.second+xy.second));
              if(dist[tar.first+xy.first][tar.second+xy.second]==INF) dist[tar.first+xy.first][tar.second+xy.second]=dist[tar.first][tar.second]+1;
              ans = max(dist[tar.first+xy.first][tar.second+xy.second],ans);
              // pr(tar.first+xy.first,tar.second+xy.second);
            }
          }
          seen[tar.first][tar.second]=1;
        }
      }
    }
  }

  pr(ans);

  return 0;
}

#if 0
5 5
.#...
.#.#.
.#.#.
.###.
.....
#endif


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

# TLE
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)

def dfs(n):
    # print('Search Start: ' + str(n))
    if checked[n]:
        # print('Checked: ' + str(n))
        return path_len[n]
    # print(graph)
    stack = graph[n]
    y = 0
    while stack:
        x = stack.pop()
        y = max(y, 1 + dfs(x))
    checked[n] = True
    if path_len[n] <= y:
        path_len[n] = y
    # print('Search End: ' + str(n))
    # print(path_len)
    return y

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

graph = {i: deque() for i in range(N)}
checked = [False for _ in range(N)]
path_len = [0 for _ in range(N)]

for _ in range(M):
    x, y = list(map(int, input().split()))
    graph[x-1].append(y-1)

for i in range(N):
    if checked[i]:
        continue
    dfs(i)

print(max(path_len))


Measured memory_bytes: 205952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll N;
	cin >> N;
	ll ans = longinf;

	for(ll i = 1; i <= sqrt(N); i++) {
		if(N % i == 0) {
			ans = min(ans, i + N / i - 2);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> ab;
    ll ans = 0;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        ab.push_back(a+b);
        ans-=b;
    }
    sort(ab.begin(), ab.end(), greater<ll>());

    rep(i,n) {
        if(i%2==0) ans+=ab[i];
    }
    cout << ans << endl;
}


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

int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++){
        cin >> v.at(i);
    }
    stable_sort(v.begin(),v.end());
    cout << v.at(2)*10+v.at(1)+v.at(0) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long A, long long B, long long C) {
  cout<<max((long long)0,C-(A-B))<<endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;
set<int>T;
int32_t main()
{
    IOS;
    string k;
    cin>>k;

    for(auto i:k)
    {
       a[i-'A']++;
       T.insert((int)i);
    }
    if(T.size()!=2) {
        cout << "No";
        return 0;
    }
    else {
        for(auto i:T)
        {
            if(a[i-'A']!=2) {
                cout << "No";
                return 0;
            }
        }
    }

    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll N, W;
ll A[100000][2];
ll K[101][100001] = { 0 };
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll maxval(ll n, ll w){
	if (n == 0)return 0;
	if (K[n][w] != 0)return(K[n][w]);
	ll x;
	if (A[n - 1][0] > w){
		x = maxval(n - 1, w);
		K[n][w] = x;
	}
	else{
		x = max(maxval(n - 1, w - A[n - 1][0]) + A[n - 1][1], maxval(n - 1, w));
		K[n][w] = x;
	}
	return x;
}
int main(){
	IOS;
	cin >> N >> W;
	for (int i = 0; i < N; i++){
		cin >> A[i][0] >> A[i][1];
	}
	ll y = maxval(N, W);
	cout << y << endl;

}

Measured memory_bytes: 79488
s = input() # RRLRL
ans = [1] * len(s)

for i in range(1, len(s)-1): # 1~3
    if s[i-1] == s[i] == 'R': # a[0,1]~a[2,3]
        ans[i+1] += ans[i-1] # a[4] << a[2]
        ans[i-1] = 0

for i in reversed(range(1, len(s)-1)): # 3~1
    if s[i+1] == s[i] == 'L': # a[4, 3]~a[2, 1]
        ans[i-1] += ans[i+1] # a[0] << a[2]
        ans[i+1] = 0

print(" ".join(map(str, ans)))

Measured memory_bytes: 10484
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}
 
int n, m;
int A[3005];
int B[3005];
 
ModularInt dp[2][3005];
 
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    cin >> A[i];
  for(int i = 1; i <= m; i++)
    cin >> B[i];
  
  for(int i = 1; i <= n; i++) {
    int step = i % 2;
    for(int j = 1; j <= m; j++) {
      dp[step][j] = 0;
      if(A[i] == B[j])
        dp[step][j] += 1 + dp[!step][j - 1];
      dp[step][j] += dp[!step][j] + dp[step][j - 1] - dp[!step][j - 1];
    }
  }
  cout << dp[n % 2][m] + 1 << endl;
}


Measured memory_bytes: 256
n = int(input())
alist = list(map(int,input().split()))
ans = []

if len(alist) == 2:
    alist.sort(reverse = True)
    print(alist[0]-alist[1])
    print(' '.join(map(str,alist)))
else:
    plus =[w for w in alist if w>=0]
    minus =[x for x in alist if x<0]
    if minus == []:
        plus.sort()
        for y in range(len(plus)-2):
            ans.append(' '.join(map(str,plus[y:y+2])))
            plus[y+1] = plus[y]-plus[y+1]
        pplus = plus[::-1]
        ans.append(' '.join(map(str,pplus[0:2])))
        print(pplus[0]-pplus[1])
        for y in ans:
            print(y)
    elif plus == []:
        minus.sort(reverse = True)
        for y in range(len(minus)-1):
            ans.append(' '.join(map(str,minus[y:y+2])))
            minus[y+1] = minus[y]-minus[y+1]
        print(minus[-1])
        for y in ans:
            print(y)
    else:
        for z in range(len(plus)-1):
            ans.append(' '.join(map(str,[minus[0],plus[z]])))
            minus[0] = minus[0]-plus[z]
        for q in minus:
            ans.append(' '.join(map(str,[plus[-1],q])))
            plus[-1] = plus[-1]-q
        print(plus[-1])
        for t in ans:
            print(t)

Measured memory_bytes: 22052
#include <stdio.h>
#include<stdlib.h>


int main() {

	
	int i, n, *p, count=0;


	scanf("%d", &n);



	p = (int*)malloc(n * sizeof(int));

	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);


	for (i = 2; i < n; i++) {
		if ((p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i])) {
			count++;
		}
	}
	
	printf("%d\n", count);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a;cin>>a;
  cout<<3*a*a<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

int calc(int a, int b) {
  return (a + b - 2) / (b - 1);
}

int main() {
  int k, n;
  scanf("%d%d", &n, &k);
  int p;
  for (int i = 1; i <= n; ++ i) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      p = i;
  }
  int result = n;
  for (int i = 1; i + k - 1 <= n; ++ i) {
    if (p < i || p > i + k - 1) continue;
    result = std::min(result, calc(i - 1, k) + calc(n - (i + k - 1), k) + 1);
  }
  printf("%d\n", result);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 100005
#define M 100000000
#define LOG 22
#define KOK 4000000
using namespace std;

int n,a,b;
int dp[N];
vector<int> v[N];

void dfs(int node,int ata) {

	int deg=0;

	for(int i:v[node]) {

		if(i==ata) continue ;

		dfs(i,node);

		deg+=dp[i];

	}

	if(deg<=1) {

		dp[node]=!deg;

	}
	else {

		printf("First");

		exit(0);

	}

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

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

		scanf("%d %d",&a,&b);

		v[a].pb(b);
		v[b].pb(a);

	}

	if(n==2) {

		printf("Second");

		return 0;

	}

	int root=1;

	for(int i=1;i<=n;i++) if(sz(v[i])>1) root=i;

	dfs(root,0);

	printf("Second");

}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
// To give an input string after a integer or double is taken input
//cin.ignore();			// better to use 2 times getline(cin,s);
#define pb push_back
#define mk make_pair
#define siz size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
}


int main(void)
{
	fast();
	int a,b,c;
	cin>>a>>b>>c;
// 	int x=a;
// 	a=a-x;
// 	b=b-x;
// 	c=c-x;
	if((a==b && c!=a) || (b==c && a!=b) || (c==a && b!=c))
	{
	    cout<<"Yes"<<endl;
	}
	else
	{
	    cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <deque>
#include <algorithm>
#include <chrono>
#include <vector>
#include <tuple>
#include <iomanip>

using namespace std;

using ull = unsigned long long int;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;

tiii cities[100000] = {};

int prefecture[100000] = {};

int main(void) {

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

	//p,y
	for (int i = 0; i < M; i++) {
		int p, y;
		cin >> p >> y;
		get<0>(cities[i]) = y;
		get<1>(cities[i]) = p;
		get<2>(cities[i]) = i;
	}

	sort(cities, cities + M);

	for (int i = 0; i < M; i++) {
		int tmp = get<1>(cities[i]) - 1;
		prefecture[tmp]++;
		get<0>(cities[i]) = prefecture[tmp];
		swap(get<0>(cities[i]), get<2>(cities[i]));
	}

	sort(cities, cities + M);

	for (int i = 0; i < M; i++) {
		cout << setw(6) << std::setfill('0') << get<1>(cities[i]);
		cout << setw(6) << std::setfill('0') << get<2>(cities[i]) << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


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

    mint ans = 0;

    for (ll i = k; i <= n + 1; i++) {
        ll l = i * (i - 1) / 2;
        ll r = i * ((n - i + 1) + (n)) / 2;
        ll now = r - l + 1;
        ans += now;
    }

    cout << ans << endl;

}


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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


#define W 51
#define H 51

int c[H][W];


void dfs(int y,int x,int h,int w){
    c[y][x]=0;
    rep(dy,-1,2){
        rep(dx,-1,2){
            int nx=x+dx;
            int ny=y+dy;
            if(nx<0 || ny<0 || nx>=w || ny>=h)continue;
            if(c[ny][nx]==1)dfs(ny,nx,h,w);
        }
    }
}

void solve(){
    int h,w;
    while(cin >> w >> h){
        if(w==0 && h==0)break;
        rep(i,0,51)rep(j,0,51)c[i][j]=0;
        rep(i,0,h){
            rep(j,0,w){
                cin >> c[i][j];
            }
        }
        int ans=0;
        rep(i,0,h){
            rep(j,0,w){
                if(c[i][j]==1){
                    dfs(i,j,h,w);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }


    
}

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






Measured memory_bytes: 3316
while True:
  m, nmin, nmax = map(int, input().split())
  if m+nmin+nmax == 0:
    break
  P = [int(input()) for i in range(m)]
  gap = 0
  for i in range(nmin, nmax+1):
    if gap<=P[i-1]-P[i]:
      gap = P[i-1]-P[i]  
      n = i
  print(n)


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int m;
	cin >> m;
	vector<int> b(m);
	for(int i=0; i<m; i++){
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	int aidx=0, bidx=0;
	while(aidx<(int)a.size() && bidx<(int)b.size()){
		while(aidx<(int)a.size() && a[aidx]!=b[bidx]){
			aidx++;
		}
		if(aidx<(int)a.size()){
			aidx++;
			bidx++;
		}else{
			 break;
		}
	}
	
	if(bidx==(int)b.size()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void) {
  int A, B, C, D;
  int turn = 1; 
  
  scanf("%d %d %d %d", &A, &B, &C, &D);
  
  while(A > 0 && C > 0) {
    if(turn % 2 == 0) {
      A -= D;
    }else{
      C -= B;
    }
    turn++;
  }
  if(A > 0) {
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1736