akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    string s;
    cin>>s;
 
    map<char,int> maps;

    for(int i=0;i<4;i++){
        if(maps.count(s.at(i)))
            maps.at(s.at(i))++;
        else
            maps[s.at(i)]=1;
    }
 
    bool flag=false;
    if(maps.size()==2){
        for(auto p: maps){
            auto k=p.first;
            auto v=p.second;
            if(v==2)
                flag = true;
            else
                flag = false;
            
        }
    }else
        flag =false;

    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
        
    return 0;
}   

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int N,M;
	cin >> N >> M;
	vector<int>h(N);
	REP(i,N)cin >> h[i];
	vector<vector<int>>g(N);
	REP(i,M){
		int a,b;
		cin >> a >> b;
		--a;--b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	int ans = 0;
	REP(i,N){
		int flg = 1;
		for(auto e:g[i]){
			if(h[i] <= h[e])flg = 0;
		}
		if(flg)++ans;
	}
	out(ans);
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  double sum=0, smax=0; 
  cin >> N >> K;
  vector<double> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
    vec.at(i)=(vec.at(i)+1)/2;
  }
  
  for (int i=0; i<K; i++) {
    sum+=vec.at(i);
  }
  if(sum>smax) {
    smax=sum;
  }
  
  for (int i=K; i<N; i++) {
    sum+=vec.at(i)-vec.at(i-K);
    
    if (sum>smax) {
      smax=sum;
    }
  }
  cout << fixed << setprecision(6);
  cout << smax << endl;
}

Measured memory_bytes: 1792
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if not directed:
            pt[t[i]-1].append(s[i]-1)
    return pt

N,M = LI()
A,B = LIR(M,2)

pt = edges_to_pt(A,B,N)
par = [0]*N
s = 0

n = len(pt)
d = [-1]*n
d[s] = 0
q = [s]
c = 1
while q:
    q1 = []
    for v in q:
        for u in pt[v]:
            if d[u] == -1:
                d[u] = c
                par[u] = v
                q1.append(u)
    q = q1
    c += 1

print('Yes')
for i in range(1,N):
    print(par[i]+1)

Measured memory_bytes: 140976
#include <cstdio>
#include <algorithm>
#include <set>
#define MAX(a,b) ((a)>(b))?(a):(b)
using namespace std;


int main() {
	int n,p,q,r,max=-1,w;
	int i,j;
	int c;
	int *sum;
	set<int> under;
	set<int> over;
	bool flag=false;
	scanf("%d%d",&n,&q);
	sum=(int *)malloc(sizeof(int)*n);
	scanf("%d",&w);
	max=sum[0]=w;
	for(i=1; i<n; ++i) {
		scanf("%d",&w);
		max=MAX(w,max);
		sum[i]=sum[i-1]+w;
	}
	if(q==1) {
		printf("%d\n",sum[n-1]);
		return 0;
	}
	p=max;
	while(1) {
		i=0;
		for(c=0; c<q-1; ++c) {
			for(j=0; i+j<n; ++j) {
				if(i==0) {
					if(sum[j]>p) {
						i=j;
						j=0;
						break;
					}
				} else {
					if(sum[i+j]-sum[i-1]>p) {
						i+=j;
						j=0;
						break;
					}
				}
			}
			if(i+j==n-1 && c<q-2) {
				if(p==max || flag) {
					printf("%d\n",p);
					return 0;
				}
				over.insert(p);
				if(flag) {
					++p;
				} else if(!under.empty()) {
					p=((*over.begin())+(*(--under.end())))/2;
				} else {
					p=(max+p)/2;
				}
			}
		}
		r=sum[n-1]-sum[i-1];
		if(r==p) {
			printf("%d\n",p);
			return 0;
		} else if (!flag) {
			if(r<p) {
				over.insert(p);
				if(!under.empty()) {
					p=((*(over.begin()))+(*(--under.end())))/2;
				} else {
					p=r+(p-r)/2;
				}
			} else if(r>p) {
				if((!over.empty() && !under.empty() && (*(over.begin()))-(*(--under.end()))<=10) || r-p<=10 ) {
					flag=true;
					under.insert(p);
					++p;
				} else {
					under.insert(p);
					if(!over.empty()) {
						p=((*(over.begin()))+(*(--under.end())))/2;
					} else {
						p=p+(r-p)/2;
					}
				}
			}
		} else {
			if(r>p) {
				++p;
			} else {
				printf("%d\n",p);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3184
///////////////////////Loading Payloads.......////////////////////////////
#include<bits/stdc++.h>
#define f(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i > b;i--)
#define ll long long
#define fl(i,a,b) for(ll i = a; i < b; i++)
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VS vector<string>
#define VL vector<long long>
#define VC vector<char>
#define VF vector<float>
#define PB push_back
#define F first
#define S second
#define fa(i,skill) for(auto i : skill)
#define fr(i,skill) for(VI :: reverse_iterator i = skill.rbegin(); i != skill.rend(); i++)
#define PI pair<int,int>
#define mi map<int,int>
#define mci map<char,int>
#define all(x) x.begin(),x.end()
using namespace std;

///////////////////////Engine Check.......////////////////////////////
void edit(VI &skill,int n)
{
    f(i,0,n)
        {
            int x;
            cin >> x;
            skill.PB(x);
        }	
}

void achilles()
{
	int n;cin >> n;
	int i=0;
	VI ans;
	f(j,0,n)
	{
		int x,y;
		cin >> x >> y;
		if(x == y)
		{
			i++;
		}
		else
		{
			i = 0;
		}
		if(i == 3)
		{
			ans.PB(i);
			i=0;
		}
	}
	if(ans.size() > 0)
		cout << "Yes\n";
	else cout << "No\n";
}
///////////////////////3....2....1...Ignition////////////////////////////

int main()
{
	ios :: sync_with_stdio(0);
	cin.tie(0);
	/*int t;cin >> t;
	while(t--)*/
    achilles();
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000009;

int n, m;
char field[55][55];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%s", field[i]);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(field[i][j] == '.'){
				int cnt = 0;
				for(int k = -1; k < 2; k++){
					for(int l = -1; l < 2; l++){
						if(i+k < 0 || i+k >= n || j+l < 0 || j+l >= m){
							continue;
						}else{
							if(field[i+k][j+l] == '#'){
								cnt++;
							}
						}
					}
				}
				field[i][j] = cnt + '0';
			}
		}
	}
	for(int i = 0; i < n; i++){
		printf("%s\n", field[i]);
	}
	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s,t;
	cin >>s >>t;

	
	cout <<t <<s <<"\n";
	return 0;
}



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

// <editor-fold>

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// vector出力
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}
// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}
#define YES(n) printf("%s\n", ((n) ? "YES" : "NO"));
#define Yes(n) printf("%s\n", ((n) ? "Yes" : "No"));
#define yes(n) printf("%s\n", ((n) ? "yes" : "no"));
// </editor-fold>

// ===============================================

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> v;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      v.push_back(i);
    }
  }
  sort(v.rbegin(), v.rend());
  cout << v[k - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  string S, T;
  cin>>S>>T;
  T = T.substr(0, T.length() - 1);
  //  cout << T << endl;
  YesNo(S==T);
  return 0;
}


Measured memory_bytes: 3096
import math

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()


def Score(hand):
    if hand == "r":
        score = P
    elif hand == "s":
        score = R
    else:
        score = S
    return score


t = [[] for _ in range(K)]

for i in range(N):
    chk = i % K
    t[chk].append(T[i])

Ans = 0
for i in range(K):
    check = t[i]
    cnt = 1
    for j in range(len(check) - 1):
        if check[j] == check[j + 1]:
            cnt += 1
        else:
            Ans += Score(check[j]) * (math.ceil(cnt / 2))
            cnt = 1
    Ans += Score(check[-1]) * (math.ceil(cnt / 2))

print(Ans)


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

int n, m;
int best = 1;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i * i <= m; i++)
        if (m % i == 0) {
            if (m / i >= n) best = max(best, i);
            if (i >= n) best = max(best, m / i);
        }
    printf("%d\n", best);
    return 0;
}


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

using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;

long long fac[MAX], finv[MAX], inv[MAX];

unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i=1; i*i<=n; ++i){//nの二乗根まで調べれば良い。
        if(n%i != 0) continue;//割り切れない場合
        res.push_back(i);//割り切れたらresにいれる
        if(i*i != n) res.push_back(n/i);//二乗根じゃない場合もう片方の約数もいれる。
    }
    return res;
}


int main() {

    int n;cin >> n;
    string s;cin >> s;
    int ans = 0;

    for (int i = 0; i < 1000; ++i)
    {
        int c[3]={i/100,(i/10)%10,i%10};
        int f = 0;
        for (int j = 0; j < n; ++j)
        {
            if(s[j] == ('0'+c[f])) f++;
            if(f==3) break;
        }
        if(f==3) ans++;
    }
      cout << ans; 
return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans=0;
    int N,M,C;
    cin>>N>>M>>C;
    int B[M];
    for(int i=0;i<M;i++)cin>>B[i];
    int A[M];
    for(int i=0;i<N;i++){
        int tmp=0;
        for(int j=0;j<M;j++){
            cin>>A[j];
            tmp+=A[j]*B[j];
        }
        if(tmp+C>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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


// Util
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
//


// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
int get_str(char *str) {
    int c;
    while((c = getchar_unlocked()) > 32) *str++ = (char)c;
    *str = 0;
    return c;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
//


// Solve
int lcs(char *s, char *t) {
    const size_t M = strlen(s);
    const size_t N = strlen(t);
    int dp[1001][1001] = {};
    for(int i = 0; i < M; ++i)
        for(int j = 0; j < N; ++j)
            if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = MAX(dp[i + 1][j], dp[i][j + 1]);
    return dp[M][N];
}

int main(int argc, char **argv) {
    int q = get_uint();
    char s[1001], t[1001];
    for(int i=0;i<q;++i){
        get_str(s);
        get_str(t);
        put_uint(lcs(s, t));
        putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 5528
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, k, q;
    cin >> n >> k >> q;
    vi a(n, 0);
    rep(i, q){
        int t;
        cin >> t;
        a[t - 1]++;
    }
    
    rep(i, n){
        if (k - q + a[i] > 0){
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }
}


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

int main(){
    string a,b;
    cin >> a >> b;
    int la = a.size();
    int lb = b.size();
    if(la>lb){
        cout << "GREATER" << endl;
    }else if(la<lb){
        cout << "LESS" << endl;
    }else{
        for(int i=0;i<la;i++){
            if(a[i]>b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i]<b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
pub 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()
}

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let mut abc: Vec<u32> = read_vec();

    abc.sort();

    if abc[0] == abc[1] && abc[1] != abc[2] {
        println!("Yes");
    } else if abc[0] != abc[1] && abc[1] == abc[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#define ll long long
using namespace std;

int main(){
	
	ll n, s = 0;
	cin >> n;
	ll v[n];
	
	for(int i = 0; i < n; i++){
		cin >> v[i];
		s = s ^ v[i];
	}
	
	for(int i = 0; i < n; i++){
		cout << (s ^ v[i]);
		if(i+1 < n) {
			cout << " ";
		}
	}
	
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 5176
#include<iostream>
#include<string>
using namespace std;
string  day[] = {"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
int main(){
	int n;
	cin >> n;
	n += 3;
	n %= 7;
	cout << day[n] << endl;
	return 0;
}



Measured memory_bytes: 3220
import sys

h, w = map(int, input().split())
canvas = [list([i for i in input()]) for j in range(h)]
for i in range(h):
    for j in range(w):
        if canvas[i][j] == '#':
            if i == 0 and j == 0:
                if canvas[0][1] == '.' and canvas[1][0] == '.':
                    print('No')
                    sys.exit()
            elif i == 0 and j == w-1:
                if canvas[0][w-2] == '.' and canvas[1][w-1] == '.':
                    print('No')
                    sys.exit()
            elif i == h-1 and j == 0:
                if canvas[h-1][1] == '.' and canvas[h-2][0] == '.':
                    print('No')
                    sys.exit()
            elif i == h-1 and j == w-1:
                if canvas[h-1][w-2] == '.' and canvas[h-2][w-1] == '.':
                    print('No')
                    sys.exit()
            elif i == 0:
                if canvas[0][j-1] == '.' and canvas[0][j+1] == '.' and canvas[1][j] == '.':
                    print('No')
                    sys.exit()
            elif j == 0:
                if canvas[i-1][0] == '.' and canvas[i+1][0] == '.' and canvas[i][1] == '.':
                    print('No')
                    sys.exit()
            elif i == h-1:
                if canvas[h-1][j-1] == '.' and canvas[h-1][j+1] == '.' and canvas[h-2][j] == '.':
                    print('No')
                    sys.exit()
            elif j == w-1:
                if canvas[i-1][w-1] == '.' and canvas[i+1][w-1] == '.' and canvas[i][w-2] == '.':
                    print('No')
                    sys.exit()
            else:
                if canvas[i][j-1] == '.' and canvas[i][j+1] == '.' and canvas[i-1][j] == '.' and canvas[i+1][j] == '.':
                    print('No')
                    sys.exit()
print('Yes')


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;
    if (a * b > c * d)
        ans = a * b;
    else
        ans = c * d;
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
#define pi 3.14159265359
using namespace std;

void Onigiri()
{
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  //12 hours = 720 mins for 2pi
  //60 mins for 2pi
  int time=h*60+m;
  int min=time%60;
  int hour=time%720;
  double a1=2*pi*hour/720.00;
  if(a1>=2*pi)a1-=2*pi;
  double a2=2*pi*min/60.00;
   if(a2>=2*pi)a2-=2*pi;
  double ans=sqrt(a*a+b*b-2*a*b*(cos(a1-a2)));
  cout.precision(40);
  cout<<fixed<<ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int i = 0, j = s.size() - 1;

    int ans = 0;
    while (i < j) {
        if (s[i] != s[j]) ++ans;
        ++i;
        --j;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define inf 99999999
using namespace std;
const int MAX=100+10;
int map[MAX][MAX],n,m,result=0,book[MAX][MAX],bookt[MAX];
void path(int s,int sum){
    if(sum==n){
        result++;return;
    }
    for(int i=1;i<=n;i++){
        if(bookt[i]==0&&book[s][i]==0&&map[s][i]==1){
            //cout<<s<<"&"<<i<<"*"<<book[s][i]<<endl;
            bookt[i]=1;
            book[i][s]=book[s][i]=1;
            path(i,sum+1);
            book[i][s]=book[s][i]=0;
            bookt[i]=0;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int i,j,a,b;
    memset(map,0,sizeof(map));
    memset(book,0,sizeof(book));
    memset(bookt,0,sizeof(bookt));
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        map[a][b]=map[b][a]=1;
    }
    bookt[1]=1;
    path(1,1);
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for( int i=a; i<b; i++)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pii>vpi;
void solve(){
    ll n;
    cin>>n;
    vll h(n);
    vll step(n);
    for(ll i =0;i<n;i++){
        cin>>h[i];
    }
    step[n-1] = 0;
    step[n-2] = abs(h[n-1]-h[n-2]);
    for(ll i = n-3;i>=0;i--){
        step[i] = min(step[i+1]+abs(h[i+1]-h[i]),step[i+2]+abs(h[i+2]-h[i]));
    }
    cout<<step[0]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4612
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y,i;
main(){
  cin>>n>>k;
  r=n-1;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
}


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

namespace ConsoleApp15
{
    class Class200
    {
        struct edge { public int to, cost; }
        static List<edge>[] G;
        static bool[] frag;
        static bool[] ans;
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            G = new List<edge>[N];
            for (int i = 0; i < N; i++) G[i] = new List<edge>();
            for(int i = 0; i < N - 1; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int u = r[0] - 1, v = r[1] - 1, w = r[2];
                G[u].Add(new edge { to = v, cost = w });
                G[v].Add(new edge { to = u, cost = w });
            }
            frag = new bool[N];
            ans = new bool[N];

            DFS(0, false);
            for(int i = 0;i<N;i++)
                Console.WriteLine(ans[i]?0:1);
        }
        static void DFS(int n,bool b)
        {
            if (frag[n]) return;
            frag[n] = true;
            ans[n] = b;
            for(int i = 0; i < G[n].Count; i++)
            {
                var e = G[n][i];
                if (e.cost % 2 == 0) DFS(e.to, b);
                else DFS(e.to, !b);
            }
        }
    }
    
}


Measured memory_bytes: 31720
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int points = 0;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }
    for(int i = 0; i < n; i++)
    {
        points += b[a[i] - 1];
        if(i > 0 && a[i] == a[i - 1] + 1)
        {
            points += c[a[i - 1] - 1];
        }
    }
    cout << points;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
int main(){
  int N;
  vector<int> p;
  cin>>N;
  for(int i=0;i<N;++i){
    int tmp;
    cin>>tmp; 
    p.push_back(tmp);
  }
  (*max_element(p.begin(),p.end())/=2);
  int sum = accumulate(p.begin(),p.end(),0);
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,i;
    cin>>n;
    vector<int> w(n,0);
    rep(i,n)cin>>w[i];
    int ans=INF;
    for(i=0;i<n;i++){
        int s1=0,s2=0;
        int j;
        rep(j,i+1)s1+=w[j];
        for(j=i+1;j<n;j++)s2+=w[j];
        ans=min(ans,abs(s1-s2));
    }
    fin(ans);
    
//////////////////////////////////////////////////////
return 0;}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
ll inf=1e9+7;
vector<ll> a;int n;
vector<vector<ll> > dp;
ll solve(ll k,int i){
    if(k<0 or i>n){
        return 0;
    }
    if(k==0){
        return 1;
    }else if(i==n){
        return 0;
    }else if(dp[k][i]!=-1){
        return dp[k][i];
    }else{
        if(a[i]<k){
            ll ans1=solve(k-1,i);
            ll ans2=(solve(k,i+1)-solve(k-1-a[i],i+1)+2*inf)%inf;
            dp[k][i]=(ans1+ans2)%inf;
        }else{
            ll ans1=solve(k-1,i);ll ans2=solve(k,i+1);
            dp[k][i]=(ans1+ans2)%inf;
        }
        return dp[k][i];
    }
}
int main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll k;cin>>n>>k;      
    a.resize(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp.resize(k+1,vector<ll>(n,-1));
    cout<<solve(k,0)<<ln;
}


Measured memory_bytes: 88576
<?php
//空白区切りの標準入力取得
$stdin = explode(' ',trim(fgets(STDIN)));
$a = $stdin[0];
$b = $stdin[1];
$c = $stdin[2];
$d = $stdin[3];
$result = max($a * $c,$a * $d,$b * $c,$b * $d);

echo $result;
?>


Measured memory_bytes: 15964
#include <iostream>
#define int long long
using namespace std;

int a, b, c, n;
int x[1000], y[1000], z[1000];
int dx[6] = {1, 0, 0, -1, 0, 0};
int dy[6] = {0, 1, 0, 0, -1, 0};
int dz[6] = {0, 0, 1, 0, 0, -1};

bool isEscaped(int px, int py, int pz, int i) {
	if (px < 0 || py < 0 || pz < 0 || px >= a || py >= b || pz >= c) return true;
	for (int j = 0; j < i; j++) {
		if (px == x[j] && py == y[j] && pz == z[j]) {
			return true;
		}
	}
	return false;
}

signed main() {
	int i, j;
	int ans = 0;
	
	cin >> a >> b >> c >> n;
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
		
		int cnt = 0;
		for (j = 0; j < 6; j++) {
			int px = x[i] + dx[j];
			int py = y[i] + dy[j];
			int pz = z[i] + dz[j];
			if (isEscaped(px, py, pz, i)) {
				cnt++;
			}
		}
		ans += 6 - cnt * 2;
	}
	ans += 2 * (a * b + b * c + c * a);
	
	cout << ans << endl;
	return 0;
}

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

int main () {

    int a[100][100], b[100], c[100] = {};
    int n, m;

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        // cout << "Debug :" << '\n';
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            // cout << " " << a[i][j];    // Debug
        }
        // cout << endl;    // Debug
    }

    for (int j = 0; j < m; j++) {
        cin >> b[j];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += a[i][j]*b[j];
        }
        cout << c[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y){ ll ans = 1;x %= MOD;while(y){if(y&1)ans = (x * ans) % MOD;x = (x * x) % MOD;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

#define no cout << "NO\n"
#define yes cout << "YES\n"

void solve() {

}

int main() {
    fastio;
    ll n;
    cin >> n;
    if(n % 1000 == 0)
        cout << "0\n";
    else
        cout << 1000 - (n % 1000) << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> P(N), C(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    for(int i = 0; i < N; i++) cin >> C[i];
    long long ans = -1e18;
    vector<int> used(N, 0);
    vector<vector<long long>> vec(N);
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(used[i] == 1) continue;
        int flag = 0;
        int ind = i, ind2 = i;
        while(flag == 0 || ind != ind2){
            flag = 1;
            vec[cnt].push_back(C[ind]);
            used[ind] = 1;
            ind = P[ind];
        }
        cnt++;
    }
    vector<vector<long long>> memo(cnt, vector<long long>(N, -1e18));
    for(int i = 0; i < cnt; i++){
        long long siz = vec[i].size();
        long long temp = 0;
        long long res = 0;
        for(int j = 0; j < siz; j++){
            long long t = 0;
            for(int k = 0; k < siz; k++){
                t += vec[i][(j + k) % siz];
                memo[i][k] = max(memo[i][k], t);
            }
            temp += vec[i][j];
        }
        if(temp > 0) {
            res += K / siz * temp;
            long long temp2 = 0;
            if(K / siz > 0){
                temp2 = (K / siz - 1) * temp;
                long long m = *max_element(memo[i].begin(), memo[i].begin() + siz);
                temp2 += m;
            }
            long long t = 0;
            if(K % siz != 0) t = *max_element(memo[i].begin(), memo[i].begin() + K % siz);
            res += t;
            ans = max(res, ans);
            ans = max(temp2, ans);
        }
        else{
            long long r = *max_element(memo[i].begin(), memo[i].begin() + min(K, siz));
            res += r;
            ans = max(res, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 36692
#include <cstdio>
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline void Add(int &x, int y) { (x += y) >= MOD ? (x -= MOD) : 0; }
inline void Sub(int &x, int y) { (x -= y) < 0 ? (x += MOD) : 0; }
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
inline int calc(int a, int A, int b, int B)
{
	int res = 0;
	Add(res, (ll)b * quick_pow(a, B / b) % MOD);
	Add(res, (ll)a * quick_pow(b, A / a) % MOD);
	Sub(res, (ll)a * b % MOD);
	return res;
}
int binom[105][105], dp[105][105];
int main()
{
	// freopen("G.in", "r", stdin);
	int a, b, c, A, B, C;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &A, &B, &C);
	if (A % a || B % b || C % c)
	{
		puts("0");
		return 0;
	}
	int ans = 0;
	Add(ans, (ll)c * quick_pow(calc(a, A, b, B), C / c) % MOD);
	Add(ans, (ll)b * quick_pow(calc(a, A, c, C), B / b) % MOD);
	Add(ans, (ll)a * quick_pow(calc(b, B, c, C), A / a) % MOD);
	Sub(ans, (ll)b * c % MOD * quick_pow(a, B / b * C / c) % MOD);
	Sub(ans, (ll)a * c % MOD * quick_pow(b, A / a * C / c) % MOD);
	Sub(ans, (ll)a * b % MOD * quick_pow(c, A / a * B / b) % MOD);
	Add(ans, (ll)a * b % MOD * c % MOD);
	for (int i = 0; i <= A / a || i <= B / b; i++)
	{
		binom[i][0] = 1;
		for (int j = 1; j <= i; j++)
			binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % MOD;
	}
	for (int p = A / a; p; p--)
	{
		for (int q = B / b; q; q--)
		{
			dp[p][q] = (ll)binom[A / a][p] * binom[B / b][q] % MOD *
					   quick_pow(c, (A / a - p) * (B / b - q)) % MOD;
			for (int i = p; i <= A / a; i++)
			{
				for (int j = q + (i == p); j <= B / b; j++)
					Sub(dp[p][q], (ll)dp[i][j] * binom[i][p] % MOD * binom[j][q] % MOD);
			}
			if (p == A / a && q == B / b)
				continue;
			int tmp = 0;
			Add(tmp, quick_pow(quick_pow(b, p) + quick_pow(a, q) - 1, C / c));
			Sub(tmp, quick_pow(quick_pow(b, p), C / c));
			Sub(tmp, quick_pow(quick_pow(a, q), C / c));
			Add(tmp, 1);
			Add(ans, (ll)tmp * a * b * c % MOD * dp[p][q] % MOD);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

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

	string s;
	cin >> s;
	int n = s.size();
	if (s[0] == '0' || s[n - 2] == '0' || s[n - 1] == '1') {
		cout << -1 << '\n';
		return 0;
	}
	vector<int> v;
	for (int i = 1; i <= (n >> 1); ++i) {
		if (s[i - 1] != s[n - i - 1]) {
			cout << -1 << '\n';
			return 0;
		}
		if (s[i - 1] == '1') v.push_back(i);
	}
	
	if (v.size() == 1) {
		for (int i = 1; i < n; ++i) {
			cout << 1 << ' ' << i + 1 << '\n';
		}
		return 0;
	}

	cout << 1 << ' ' << 2 << '\n';
	int c = 2;
	for (int i = 1; i < v.size(); ++i) {
		for (int j = 1; j < v[i] - v[i - 1]; ++j) {
			cout << c << ' ' << c + j << '\n';
		}
		cout << c << ' ' << v[i] + 1 << '\n';
		c = v[i] + 1;
	}
	for (int i = 1; i < n - v.back(); ++i) {
		cout << c << ' ' << c + i << '\n';
	}
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int ans=100000;
	for(int i=0;i<n;i++){
		ans=(ans*1.05);
		int ans2=ans/1000;
		ans2*=1000;
		if(ans!=ans2){
			ans=ans2+1000;
		}else{
			ans=ans2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

vector<int> v[100010];
ll black[100010], white[100010], mod=1e9+7;

void dfs(ll x, ll p){
    for( auto y: v[x] ){
        if( y == p )
          continue;
        dfs( y, x);
        white[x] *= (white[y]+black[y])%mod;
        black[x] *= white[y];

        white[x] %= mod;
        black[x] %= mod;
    }
}

int main(){
   
   for(int i=0; i<100010; i++){
      black[i] = white[i] = 1;
   }

   ll n,x,y;
   cin>>n;

   for(int i=0; i<n-1; i++){
      cin>>x>>y;
      v[x].push_back(y);
      v[y].push_back(x);
   }
   dfs(1, -1);
   cout<<(white[1]+black[1])%mod<<endl;
} 

Measured memory_bytes: 17412
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

d = i()
if d == 25:
	print("Christmas")
elif d == 24:
	print("Christmas Eve")
elif d == 23:
	print("Christmas Eve Eve")
else:
	print("Christmas Eve Eve Eve")


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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

ll n, m;
int freq[26];

int main() {
    fast();
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')cout<<a+b;
    else cout<<a-b;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.nextLine();
        if (s.startsWith("2017"))
            System.out.println(s.replace("2017", "2018"));
        else
            System.out.println(s);
    }
}

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

int main(){
	char c;
	int sum = 0;
	while(true){
		while(cin >> noskipws >> c && c != '\n'){
			sum += c-'0';
		}
		if(sum == 0)
			break;
		else{
			cout << sum << endl;
			sum = 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ABS(a) ((a)>0 ? (a):-(a))
#define ll long long
#define SWAP(a,b) {a+=b;b=a-b;a-=b;}

ll cmb[52][52];

ll comb(ll n,ll r){
	if(r == 0 || n == r) return 1ll;
	if(r == 1) return n;
	if(cmb[n][r] != 0) return cmb[n][r];
	else return cmb[n][r] = comb(n-1,r-1) + comb(n-1,r);
}

int main(){
	ll n,a,b,v[52];
	double ave = 0;
	ll numin = 0,numall = 0,ch = 0;

	//input
	scanf("%lld %lld %lld",&n,&a,&b);
	FOR(i,0,n) scanf("%lld",&v[i]);

	//sort
	FOR(i,0,n-1){
		FOR(j,i+1,n)
		if(v[i] < v[j]) SWAP(v[i],v[j]);
	}

	//average
	FOR(i,0,a) ave += v[i];
	ave /= a;

	//choices
	FOR(j,0,a) if(v[j] == v[a-1]) numin ++;
	FOR(j,0,n) if(v[j] == v[a-1]) numall ++;

	memset(cmb,0,sizeof(cmb));

	if(v[0] == v[a-1]){
		FOR(k,a,fmin(b+1,numall+1)) ch += comb(numall,k);
	}else{
		ch = comb(numall,numin);
	}

	//output
	printf("%f\n",ave);
	printf("%lld\n",ch);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(string, S);
  
  rep(i, S.size()){
    //奇数番目
    char c = S[i];
    if(i % 2 == 0 && (c == 'R' || c == 'U' || c == 'D') ||
      i % 2 == 1 && (c == 'L' || c == 'U' || c == 'D')) {
      ///ok
    } else {
      fin("No");
      return 0;
    }
  }
  fin("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=300010;
inline int read()
{
   	int s=0,w=1; ri char ch=getchar();
   	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
   	while(ch>='0'&&ch<='9') s=s*10+ch-'0', ch=getchar();
   	return s*w;
}
int book[N],n,H,W,f[N],res;
struct Node{ int u,v,w; }e[N];
inline bool cp(Node x,Node y) { return x.w>y.w; }
inline int Find(int x) { return f[x]^x?f[x]=Find(f[x]):x; }
signed main()
{
	n=read(), H=read(), W=read();
	for(ri int i=1;i<=n;i++) e[i].u=read(), e[i].v=read()+H, e[i].w=read();
	for(ri int i=1;i<=H+W;i++) f[i]=i;
	sort(e+1,e+1+n,cp);
	for(ri int i=1;i<=n;i++)
	{
		int fx=Find(e[i].u), fy=Find(e[i].v);
		if(fx==fy)
		{
			if(book[fx]) continue;
			book[fx]=1, res+=e[i].w;
			continue;
		}
		if(book[fx] && book[fy]) continue;
		book[fx]|=book[fy], f[fy]=fx, res+=e[i].w;
	}
	printf("%lld\n",res);
	return 0;
} 

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


int main()
{
  	int A, B, max;
	cin >> A >> B;
	max= 0;
	max= A+B;
	if (A-B > max){
		max= A-B;

	}
	if (A*B > max){
		max = A*B;
	}
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } else return; }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<int> cnt(N, 0);
	REP(i,N) {
		int a; cin >> a;
		cnt[a]++;
	}
	int d;
	for(int i = N-1; 0 < i; --i){
		if(cnt[i]) {
			d = i;
			break;
		}
	}
	
	int flg = 1;
	if (d == 1 && N != 2) flg = 0;
	
	if(d%2){
		for (int i = 0;i < d / 2 + 1; ++i) {
			if (cnt[i]) flg = 0;
		}
		if (cnt[d/2+1] != 2) flg = 0;
		for (int i = d/2 + 2; i <= d; ++i) {
			if (cnt[i] < 2) flg = 0;
		}

		for (int i = d + 1; i < N; ++i) {
			if (cnt[i]) flg = 0;
		}

	}
	else{
		for (int i = 0; i < d/2; ++i) {
			if (cnt[i]) flg = 0;
		}
		if (cnt[d/2] != 1) flg = 0;
		for (int i = d/2 + 1; i <= d; ++i) {
			if (cnt[i] < 2) flg = 0;
		}
		for (int i = d + 1; i < N; ++i) {
			if (cnt[i]) flg = 0;
		}

	}
	cout << (flg ? "Possible" : "Impossible") << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int s;
  cin >> s;
  map<int,bool> has;
  has[s] = true;
  for (size_t i = 2; ; i++) {
    int a = s % 2 ? 3*s+1 : s/2;
    // debug1(i, a);
    if (has[a]) {
      cout << i << endl;
      return 0;
    }
    has[a] = true;
    s = a;
  }
  return 0;
}


Measured memory_bytes: 256