akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場


//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> fri(a);
	vector<int> mic(b);
	vector<int> cos(m);
	ff(i, 0, a) {
		cin >> fri[i];
	}
	ff(i, 0, b) {
		cin >> mic[i];
	}
	ff(i, 0, m) {
		int x, y, c;
		cin >> x >> y >> c;
		x--;
		y--;
		cos[i] = fri[x] + mic[y] - c;
	}
	srt(fri);
	srt(mic);
	srt(cos);
	cout << min(fri[0] + mic[0], cos[0]) << endl;
	return 0;
}


Measured memory_bytes: 1408
N, M = map(int, input().split())
sum_a = 0
sum_b = 0

if N % 2 == 0:
    sum_a = (N/2) * (N-1)
else:
    sum_a = N * ((N-1)/2)

if M % 2 == 0:
    sum_b = (M/2) * (M-1)
else:
    sum_b = M * ((M-1)/2)

sum = sum_a + sum_b

print(int(sum))


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int s;
			int max = 0;
			int min = 1000;
			int ave = 0;
			if(n==0) break;
			for(int i = 0;i < n;i++){
				s = sc.nextInt();
				ave += s;
				if(s < min) min = s;
				if(s > max) max = s;
			}
			ave -= min + max;
			System.out.println(ave/(n-2));
		}
	}
}

Measured memory_bytes: 20948
#include <iostream>
int main() {
	long long n, a[10101], ans = 0, add = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++)
		std::cin >> a[i];

	for (int i = 0; i < n*2; i++) {
		for (int j = 0; j < n; j++) {
			if (a[j] % 2 == 0) {
				a[j] /= 2;
				add++;
			}
			else
				goto g;
		}
		if (add == n) {
			ans++;
			add = 0;
		}
		else
			goto g;
	}
g:
	std::cout << ans << std::endl;

}

Measured memory_bytes: 256
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    K = []
    S = []
    for i in range(M):
        buf = input()
        buflist = buf.split()
        K.append(int(buflist[0]))
        S.append(list(map(int, buflist[1:])))
    buf = input()
    buflist = buf.split()
    P = list(map(int, buflist))
    on_pattern = 0
    for i in range(2 ** N):
        sw = []
        for j in range(N):
            sw.append(i >> j & 1 > 0)
        all_on = True
        for j in range(M):
            on_count = 0
            for x in S[j]:
                if sw[x-1]:
                    on_count += 1
            if on_count % 2 != P[j]:
                all_on = False
                break
        if all_on:
            on_pattern += 1
    print(on_pattern)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 200005;
int n, q, cnt[MAX_N];
VI adj[MAX_N];
void input() {
    RI(n, q);
    REP(i, n-1) {
    	int a, b;
    	RI(a,b);
    	a--; b--;
    	adj[a].PB(b);
    	adj[b].PB(a);
    }

    REP(i, q) {
    	int a, x;
    	RI(a,x);
    	a--;
    	cnt[a]+=x;
    }
}

void dfs(int u, int e, int val) {
	cnt[u] += val;
	for(auto v:adj[u]) {
		if(v != e) dfs(v, u, cnt[u]);
	}
}

void solve() {
	dfs(0, -1, 0);
	REP(i, n-1) printf("%d ", cnt[i]);
	printf("%d\n", cnt[n-1]);
}

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


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int ans[200010], vis[200010];

int main()
{
	int n, x;
	gii(n, x);
	if (n == 2)
	{
		if (x == 2)
		{
			printf("Yes\n1\n2\n3\n");
			return 0;
		}
		puts("No");
		return 0;
	}
	int round = n;
	n <<= 1;
	--n;
	int A = n - x, B = x - 1;
	if (B >= 1 && A >= 2)
	{
		ans[round] = x;
		ans[round + 1] = x - 1;
		ans[round - 1] = x + 1;
		ans[round + 2] = x + 2;
		vis[x] = vis[x + 1] = vis[x - 1] = vis[x + 2] = 1;
		int t = 0;
		for (int i = 1; i <= n; ++i)
		{
			while (ans[t + 1]) ++t;
			if (!vis[i]) ans[++t] = i;
		}
		puts("Yes");
		for (int i = 1; i <= n; ++i)
			printf("%d\n", ans[i]);
		return 0;
	}
	else if (B >= 2 && A >= 1)
	{
		ans[round] = x;
		ans[round + 1] = x + 1;
		ans[round - 1] = x - 1;
		ans[round + 2] = x - 2;
		vis[x] = vis[x + 1] = vis[x - 1] = vis[x - 2] = 1;
		int t = 0;
		for (int i = 1; i <= n; ++i)
		{
			while (ans[t + 1]) ++t;
			if (!vis[i]) ans[++t] = i;
		}
		puts("Yes");
		for (int i = 1; i <= n; ++i)
			printf("%d\n", ans[i]);
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main() {
	char group[12] = { 'A','C','A','B','A','B','A','A','B','A','B','A' };
	int x, y;

	cin >> x >> y;

	cout << (group[x-1] == group[y-1] ? "Yes" : "No") << endl;

}

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

int main(){
  int N; cin >> N;
  vector<string> s(N + 1);
  map<string, int> MAP;
  for(int i = 1; i <= N; i++){
    cin >> s[i];
    MAP[s[i]] = 0;
  }
  sort(s.begin(), s.end());
  for(int i = 1; i <= N; i++){
    MAP[s[i]]++;
  }
  int maxs = 0;
  for(int i = 1; i <= N; i++){
    maxs = max(maxs, MAP[s[i]]);
  }
  for(int i = 1; i <= N;){
    if(maxs == MAP[s[i]]){ 
      cout << s[i] << endl;
      i += maxs;
    }
    else i++;
  }
}

Measured memory_bytes: 26752
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N = 3;
    vi A(N); REP(i,N) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    int ans = A[0] * 10 + A[1] + A[2];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        N: usize,
        A: [usize1; N],
        B: [usize; N],
        C: [usize; N-1],
    }

    let mut ans = 0;

    for i in 0..N-1 {
        ans += B[A[i]];
        if A[i] + 1 == A[i+1] {
            ans += C[A[i]]
        }
    }
    ans += B[A[N-1]];

    println!("{}", ans);
}

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

int main(){
  int x, y;
  cin >> x >> y;
  bool judge = false;
  
  for(int i = 0; i <= x; i++){
    if(y == 2*(x-i) + 4*i){
      judge = true;
      break;
    }
  }
  
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
      

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

ll INF = 1LL << 57;
ll dp[110][100010]; // i番目までの荷物を使って価値の総和jを達成する重みの最小値
ll w[110];
int v[110];
int main(){
    int N, W;
    cin >> N >> W;
    int vsum = 0;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
        vsum += v[i];
    }
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= vsum; j++) dp[i][j] = INF;
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= vsum; j++){
            if(dp[i][j] == INF) continue;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j + v[i] <= vsum) dp[i+1][j + v[i]] = min(dp[i+1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    int ans = 0;
    for(int i = 0; i <= vsum; i++){
        if(dp[N][i] != INF && dp[N][i] <= W) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	sc := NewScanner()
	aa := sc.nextIntSlice(n)
	bb := sc.nextIntSlice(n)
	cc := sc.nextIntSlice(n)

	sort.Ints(aa)
	sort.Ints(cc)

	sum := 0
	for _, b := range bb {
		i := search(aa, b)
		j := search(cc, b+1)
		sum += i * (n - j)
	}

	fmt.Println(sum)
}

func search(a []int, t int) int {
	low := 0
	high := len(a) - 1
	for low <= high {
		mid := (low + high) / 2
		if t <= a[mid] {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return low
}

// Scanner .
type Scanner struct {
	sc *bufio.Scanner
}

// NewScanner .
func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}


Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  ll N,K;
  cin >> N >> K;
  if(N>K) N = N%K;
  if(N <= K/2) cout << N << endl;
  else cout << abs(K-N) << endl;

  

  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				if (i % 2 == 0) {
					for (int j = 0; j < W; j++) {
						if (j % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				} else {
					for (int j = 0; j < W; j++) {
						if (j % 2 == 0) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
		sc.close();
	}
}



Measured memory_bytes: 32984
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
	int n, d; cin >> n >> d;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ll x, y; cin >> x >> y;
		if(sqrt(x*x+y*y) < d + 1e-8) ans++;
	}
	cout << ans << endl;
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

const int MAXX = 1e9 + 7;

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

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]),
                    dp[i-2] + abs(a[i-2] - a[i]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int m,d;cin>>m>>d;
int cnt=0;
for(int i=22;i<=d;i++){
    int d1=i%10,d10=(i/10)%10;
    if(d1>=2&&d10>=2&&d1*d10<=m){cnt++;}
}
cout<<cnt<<endl;
return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int n,k;cin>>n>>k;
  int r,s,p;cin>>r>>s>>p;
  string tt;cin>>tt;
  string t=string(tt);
  REP(i,n){
    if(t[i]=='r'){
      t[i]='p';
    }else if(t[i]=='s'){
      t[i]='r';
    }else if(t[i]=='p'){
      t[i]='s';
    }
  }
  FOR(i,k,n){
    if(t[i-k]==t[i]){
      if(t[i]=='p'){
        if(i>=n-k){
          t[i]='r';
          continue;
        }
        if(t[i+k]=='r'){
          t[i]='s';
        }else if(t[i+k]=='s'){
          t[i]='r';
        }else{
          t[i]='r';
        }
      }else if(t[i]=='r'){
        if(i>=n-k){
          t[i]='p';
          continue;
        }
        if(t[i+k]=='p'){
          t[i]='s';
        }else if(t[i+k]=='s'){
          t[i]='p';
        }else{
          t[i]='p';
        }
      }else if(t[i]=='s'){
        if(i>=n-k){
          t[i]='p';
          continue;
        }
        if(t[i+k]=='r'){
          t[i]='p';
        }else if(t[i+k]=='p'){
          t[i]='r';
        }else{
          t[i]='p';
        }
      }
    }
  }
  int ans=0;
  REP(i,n){
    if(t[i]=='r'&&tt[i]=='s'){
      ans+=r;
    }
    if(t[i]=='p'&&tt[i]=='r'){
      ans+=p;
    }
    if(t[i]=='s'&&tt[i]=='p'){
      ans+=s;
    }
  }
  cout << ans << endl;
}

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


using namespace std;


int N, M, Q;
int ans;
vector<int> A;
vector<tuple<int, int, int, int>> conditions;


int calc(void) {
    int ret = 0;
    for (auto t : conditions) {
        int a, b, c, d;
        a = get<0>(t);
        b = get<1>(t);
        c = get<2>(t);
        d = get<3>(t);

        if (A[b] - A[a] == c) {
            ret += d;
        }
    }
    return ret;
}


void solve_sub(int depth) {
    if (depth == N) {
        ans = max(ans, calc());
        return;
    }

    int a_now = *A.rbegin();
    for (int a_next = a_now; a_next <= M; a_next++) {
        A.push_back(a_next);
        solve_sub(depth + 1);
        A.pop_back();
    }
}


void solve(void) {
    for (int i = 1; i <= M; i++) {
        A.push_back(i);
        solve_sub(0);
        A.pop_back();
    }
}


int main(void) {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        conditions.push_back(make_tuple(a, b, c, d));
    }

    solve();

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=1e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------

void solve()
{
    int n;
    int h[sz];
    cin >> n;
    f(i,0,n)cin >> h[i];
    int cost[sz]={0};
    cost[n-1] = 0;
    cost[n-2] = abs(h[n-1] - h[n-2]);
    fr(i,n-3, 0){
        cost[i] = min(abs(h[i+1] - h[i]) + cost[i+1], abs(h[i+2] - h[i]) + cost[i+2]);
    }
    cout << cost[0];
} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 4396
#include<iostream>
#include<vector>
#include <string>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> A(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int Max = A[0] + K - A[N - 1];
	int Max_index = 0;

	for (int i = 0; i < N - 1; i++) {
		if (Max < A[i + 1] - A[i]) {
			Max_index = i + 1;
			Max = A[i + 1] - A[i];
		}
	}

	cout << K - Max;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

double dp_table(int i, int j, int k, const int n,
                vector<vector<vector<double>>>& dp)
{
    if (dp[i][j][k] > 0.0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double next = static_cast<double>(n);
    if (i > 0) next += dp_table(i - 1, j, k, n, dp) * i;
    if (j > 0) next += dp_table(i + 1, j - 1, k, n, dp) * j;
    if (k > 0) next += dp_table(i, j + 1, k - 1, n, dp) * k;
    return dp[i][j][k] = (next / static_cast<double>(i + j + k));
}

int main()
{
    int n;
    cin >> n;
    int n1{0}, n2{0}, n3{0};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == 1)
            n1++;
        else if (a == 2)
            n2++;
        else
            n3++;
    }

    vector<vector<vector<double>>> dp(
        310, vector<vector<double>>(310, vector<double>(310, 0.0)));
    cout << setprecision(12) << dp_table(n1, n2, n3, n, dp) << endl;
    return 0;
}

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

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B, C, D = map(int, input().split())

N = B - A + 1

g = lcm(C,D)
C_ = B//C - (A-1)//C
D_ = B//D - (A-1)//D
CD_ = B//g - (A-1)//g
ans = N - C_ - D_ + CD_
print(ans)


Measured memory_bytes: 5348
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	char a, b;
	cin >> a >> b;
	if((a=='H'&&b=='H')||(a=='D'&&b=='D'))
	{
		cout << 'H' << endl;
	}else
	{
		cout << 'D' << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i==N-1){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, k; cin >> n >> k;
	int p[n]; rep(i,n) cin >> p[i];
	sort(p, p + n);
	int sum = 0;
	rep(i,k) sum += p[i];
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int N;
    double n;
    cin >> N;
    if (N % 2 == 1){
        n=(N+1)/2;
        cout << n / N;
    }
    else {
        n= N / 2;
        cout << n / N;
        
    }
}
                         

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

using namespace std;

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

    // f(x) = floor(Ax / B) - A * floor(x / B)とおく
    // f(x + B) = f(x)が成り立つ
    // f(x) = floor(Ax / B) - A * floor(x / B)
    // f(x + B) = floor(Ax/B + A) - A * floor(x/B + 1) = A + floor(Ax / B) - A - A * floor(x / B) -> f(x) = floor(Ax / B) - A * floor(x / B) = f(x)
    // よって、0 <= x <= B - 1 区間のみを考えればよい。
    // 上記の場合、floor(Ax / B)の最大値を求めればよいので、xの最大値を求めていく
    // N < B - 1　-> x == N
    // B - 1 <= N -> x == B - 1

    int64_t ans = 0;

    if (N < B - 1) {
        ans = (A * N) / B;
    } else {
        ans = (A * (B - 1)) / B;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, M;
  cin >> N >> M;
  VEC<pair<int, int>> B(N);
  REP(i, 0, N) { cin >> B[i].first >> B[i].second; }
  auto comp = [](pair<int, int> a, pair<int, int> b) -> bool {
    if (a.first != b.first) return a.first < b.first;
    return a.second > b.second;
  };
  sort(ALL(B), comp);
  // DUMP(B);
  priority_queue<int> pq;
  int j = 0;
  LL cnt = 0;
  REP(i, 1, M + 1) {
    // DUMP(i, j);
    while (j < N && B[j].first <= i) {
      // DUMP(j);
      pq.push(B[j].second);
      j++;
    }
    // DUMP("HI");
    if (!pq.empty()) {
      // DUMP(pq.top());
      cnt += pq.top();
      pq.pop();
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1660
/**
 *   created: 02 August 2020 (Sunday)  17:29:11
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define int long long

void solve(){
	int N; cin >> N;
	int x=0, cnt=0, n, itr= 1000000;
	while(itr>=0)
	{
		x = x*10+7;
		x=x%N;
		cnt++;
		itr--;
		if(x==0)
		{
			cout<<cnt;
			return;
		}
	}
	cout<<"-1";
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

Measured memory_bytes: 3560
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

cost=99999999999999

for i in range(2**n):
    shujukudo=[0]*m
    tmp_cost=0
    for j in range(n):
        if ((i>>j)&1):
            for m_i in range(m):
                shujukudo[m_i]+=ca[j][m_i+1]
            tmp_cost+=ca[j][0]
    tf=[s >= x for s in shujukudo]
    if all(tf):
        cost=min(cost,tmp_cost)
print(cost if cost!=99999999999999 else -1)


Measured memory_bytes: 9208
import java.util.Scanner;
class Main
{
public static void main(String args[])
{

  Scanner sc = new Scanner(System.in);

    short a = sc.nextShort();
    short b = sc.nextShort();
    short c = sc.nextShort();
    sc.close();
    short d = 0;


    if (a>b)
    { d=a;
      a=b;
      b=d;  }

    if (b>c)
    {  d=b;
       b=c;
       c=d;  }

    if (b<a)
    { d=b ; b=a; a=d;}
    System.out.println(a + " " + b + " " + c);
}
}



Measured memory_bytes: 26272
// https://atcoder.jp/contests/abc154/tasks/abc154_e

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 100;
const int K_MAX = 3;

char S[S_MAX + 1];
int N, K;

int dp[S_MAX + 1][2][K_MAX + 1];

void solve() {
  N = strlen(S);
  dp[0][0][0] = 1;
  REP(i, N) {
    int d = S[i] - '0';
    REP(smaller, 2) REP(j, K + 1) REP(x, smaller ? 10 : d + 1) {
      if (j == K && x > 0) continue;
      dp[i + 1][smaller || x < d][j + (x > 0)] += dp[i][smaller][j];
    }
  }

  // REP(smaller, 2) {
  //   REP(_i, N + 1) REP(_j, K + 1) printf("%d%c", dp[_i][smaller][_j], _j == K ? '\n' : ' ');
  //   puts("");
  // }

  printf("%d\n", dp[N][0][K] + dp[N][1][K]);
}

void input() {
  scanf("%s", S);
  scanf("%d", &K);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)

int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> S(N);
  vector<int> C(N);
  REP(i,N)cin >> S[i];
  REP(i,N)cin >> C[i];
  vector<int> P(N);
  REP(i,N){
    if(S[i]-C[i] >= 0){
      ans += S[i] -C[i];
    }
  }
  cout << ans << endl;
}


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

int main() {
  long long a,b,c,n,ans = 0;
  cin >> a >> b >> c >> n;
  for(int i = n/a ; ~i ; --i) 
    for(int j = (n-i*a)/b ; ~j ; --j) 
      if((n-i*a-j*b)%c == 0) 
        ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF (1LL<<60)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
typedef pair<ll,int> edge;
int n,m;
vector<P> G[100001];
ll dist[100001];

ll solve(int s,int t){
	for(int i=0;i<n;i++){
		dist[i]=INF;
	}
	dist[s]=0;
	priority_queue<edge,vector<edge>,greater<edge> > que;
	que.push(P(0,s));
	while(que.size()){
		edge e=que.top();
		que.pop();
		//printf("%d %lld\n",e.second,e.first);
		if(e.first>dist[e.second])continue;
		for(int i=0;i<G[e.second].size();i++){
			int nv=G[e.second][i].first;
			if(dist[nv]>dist[e.second]+G[e.second][i].second){
				dist[nv]=dist[e.second]+G[e.second][i].second;
				que.push(P(dist[nv],nv));
			}
		}
	}
	return dist[t];
}

int main(void){
	int s,t;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	s--;
	t--;
	for(int i=0;i<m;i++){
		int a,b,c;
		ll d;
		scanf("%d%d%d%lld",&a,&b,&c,&d);
		a--;
		b--;
		c--;
		G[a].push_back(P(b,d));
		G[a].push_back(P(c,d));
		G[b].push_back(P(a,d));
		G[b].push_back(P(c,d));
		G[c].push_back(P(a,d));
		G[c].push_back(P(b,d));
	}
	printf("%lld\n",solve(s,t));
	return 0;
}


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

int main() {
  int N;
  int list[110];
  
  cin >> N;
for(int i = 0; i<N ;i++){
  cin >> list[i] ;
}
  int num[110]={0};
  
for(int i = 0; i<N ;i++){
 num[list[i]]++ ;
}
 
int count = 0;
for(int i = 0; i<110 ;i++){
 if(num[i] != 0){
   count = count+1 ;
 }
}
cout << count <<endl;
}

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

int compare(const void *a,const void *b){
	return *(int*)a-*(int*)b;
}

int main(){
	int time[5];
	int fn[5];
	int last;
	int i,j;
	int ans;
	
	for(i=0;i<5;i++){
		scanf("%d",&time[i]);
	}
	
	for(i=0;i<5;i++){
		fn[i]=time[i]%10;
	}
	
	qsort(fn,5,sizeof(int),compare);
	
	last=0;
	while(fn[last]==0){
		last++;
		if(last==5)	break;
	}
	
	ans=0;
	for(i=0;i<5;i++){
		time[i]-=time[i]%10;
		ans+=time[i];
	}
	
	for(i=0;i<5;i++){
		if(i!=last){
			if(fn[i]!=0)	ans+=10;
		}else{
			ans+=fn[i];
		}
	}
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  double r; cin >>r;
  double res = 2 * r * M_PI;
  cout <<fixed <<setprecision(12) <<res <<endl; 
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, w;
    cin >> n >> w;

    vector<ll> weight(n);
    vector<ll> value(n);
    vector<vector<ll>> dp(n+1, vector<ll>(w+1));
    

    rep(i,n){
        cin >> value[i] >> weight[i];
    }
    
    rep(i, n){

        for(ll j = 0; j <= w; j++){
            if(j - weight[i] >= 0){
                chmax(dp[i+1][j], dp[i][j-weight[i]] + value[i]); 
            }
            chmax(dp[i+1][j], dp[i][j]); 
        }
    }
    
    
    

    cout << dp[n][w] << endl;


}


Measured memory_bytes: 10688
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M,K,a;cin>>N>>M;
  vector<int> food(M,0);
  REP(i,0,N){
    cin>>K;
    REP(j,0,K){
      cin>>a;
      a--;
      food[a]++;
    }
  }
  int ans=0;
  REP(i,0,M){
    if(food[i]==N)ans++;
  }
  print(ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(2e6+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;
ll n,m;
string s;
vector<ll> v[ARRS];
ll ct[ARRS][2];
ll f[ARRS];
ll t[ARRS];
stack<ll> g;


int main(){
	cin>>n>>m;
	cin>>s;
	for(int i=1; i<=n; i++)
		t[i]=(s[i-1]=='A');
	for(int i=0; i<m; i++){
		ll k,p;
		cin>>k>>p;
		v[k].pb(p);
		v[p].pb(k);
		ct[p][t[k]]++;
		ct[k][t[p]]++;
	}
	for(int i=1; i<=n; i++){
		if(!ct[i][0]||!ct[i][1])g.push(i);
	}
	while(g.size()){
		auto x=g.top();
		g.pop();
		if(f[x])continue;
		f[x]=1;
		for(auto y:v[x]){
			ct[y][t[x]]--;
			if(!ct[y][0]||!ct[y][1])g.push(y);
		}
	}
	for(int i=1; i<=n; i++){
		if(!f[i]){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}


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

int main() {
  int64_t n,k;
  cin>>n>>k;
  
  vector<int64_t> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  sort(h.begin(),h.end());
  
  int64_t sum=0LL;
  for(int i=0; i<n-k; i++) sum+=h[i];
  
  cout << sum << endl;
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  for(int i=0;i<S.size();i++){
    S.at(i)+=N;
    if(90<S.at(i))
      S.at(i)-=26;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int h,w,k;
    cin>>h>>w>>k;
    char s[h][w];
    int x[h][w];
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            x[i][j]=0;
        }
    }
    int c=1;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                x[i][j]=c;
                c++;
            }
        }
    }
    vector<int> f(h);
    rep(i,h){
        int z=0;
        rep(j,w){
            if(x[i][j]!=0){
                z=x[i][j];
                break;
            }
        }
        if(z==0){
            f[i]=-1;
        }
        else{
            rep(j,w){
                if(x[i][j]!=0&&x[i][j]!=z){
                    z=x[i][j];
                }
                x[i][j]=z;
            }
            f[i]=i;
        }

    }
    int g=-1;
    rep(i,h){
        if(f[i]!=-1){
            g=f[i];
        }
        else if(g!=-1&&f[i]==-1){
            f[i]=g;
        }
    }
    g=-1;
    rrep(i,h){
        if(f[i]!=-1){
            g=f[i];
        }
        else if(g!=-1&&f[i]==-1){
            f[i]=g;
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<x[f[i]][j]<<" ";
        }
        cout<<endl;
    }
        
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	pair<int, int>p1, p2;
	cin>>p1.first>>p1.second;
	cin>>p2.first>>p2.second;

	int dx=p2.first-p1.first;
	int dy=p2.second-p1.second;

	pair<int, int>p3, p4;
	p3.first=p2.first-dy; p3.second=p2.second+dx;
	p4.first=p3.first-dx; p4.second=p3.second-dy; 

	cout<<p3.first<<" "<<p3.second<<" ";
	cout<<p4.first<<" "<<p4.second<<endl;

	return 0;
}


Measured memory_bytes: 256
<?php
while (true) {
    list($a, $op, $b) = explode(' ', trim(fgets(STDIN)));
    switch ($op) {
        case '+':
            echo $a + $b, PHP_EOL;
            break;
        case '-':
            echo $a - $b, PHP_EOL;
            break;
        case '*':
            echo $a * $b, PHP_EOL;
            break;
        case '/':
            echo floor($a / $b), PHP_EOL;
            break;
        case '?':
            exit;
        default:
            break;
    }
}

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

const int N = 1e5 + 5;

int t[N], x[N], y[N];

int manhattan_distance(int a, int b) {
    return abs(x[a] - x[b]) + abs(y[a] - y[b]);
}

int main() {
    int n;
    scanf(" %d", &n);
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++) {
        scanf(" %d %d %d", &t[i], &x[i], &y[i]);
    }
    bool can = true;
    for (int i = 1; can && i <= n; i++) {
        int d_m = manhattan_distance(i - 1, i);
        int d_t = t[i] - t[i - 1];
        if (d_m > d_t || (d_t - d_m) % 2 != 0)
            can = false;
    }
    if (can) 
        printf("Yes\n");
    else 
        printf("No\n");
}



Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
const int maxn=2e5+2;
int main(){
	int x[maxn],y[maxn],m,n,l=0,r=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		y[i]=x[i];
	}
	sort(y+1,y+1+n);
	int pos=n/2;
	if(n%2==1)pos=(n+1)/2;
	int mid=y[pos];
	for(int i=1;i<=n;i++){
		if(n%2!=0&&x[i]!=mid)printf("%d",mid);
		if(x[i]<mid&&n%2==0)printf("%d",y[pos+1]);
		if(x[i]>mid&&n%2==0)printf("%d",y[pos]);
		if(x[i]==mid&&n%2==0)printf("%d",y[pos+1]);
		if(x[i]==mid&&n%2!=0)printf("%d",y[pos-1]);
printf("\n");
}

}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<ll, ll> mp1, mp2;
    for(int i = 0; i < n; i++) {
        mp1[i - a[i]]++;
        mp2[i + a[i]]++;
    }
    ll ans = 0;
    for(auto e : mp1) {
        ans += e.second * mp2[e.first];
    }
    cout << ans << endl;
}

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

int main(){
    long long n, k; cin >> n >> k;
    
    long double res = 0;
    for(long long  i=1; i<n+1; ++i){
        long long  d = i;
        long double x = 1.0;
        
        while(d<k){
            d *= 2; x /= 2;
        }
        res += x;
    }
    
    res /= n;
    cout << fixed << setprecision(15) << res << endl;
    return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[100100];

int main(void){
	int n,i,p=0,ans=0;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> d[i];
	}
	sort(d,d+n);
	cout << d[n/2]-d[n/2-1] << endl;
	return 0;
}


Measured memory_bytes: 768
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long x;
	cin >> x;
	long long ans = 1;
	for (long long i = 2; i <= sqrt(x); ++i) {
		long long geko = i * i;
		while (geko * i <= x)geko *= i;
		ans = max(ans, geko);
	}
	cout << ans << endl;
}


Measured memory_bytes: 888