akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int A, B, C, D = 0;
  cin >> A >> B >> C >> D;
  
  if(A*B == C*D){
    cout << A*B <<endl;
  }
  else if(A*B > C*D){
    cout << A*B <<endl;
  }
  else{
    cout << C*D << endl;
  }
}

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

using namespace std;
#define int long long

int32_t main() {
    int N;
    cin>>N;
    vector<int> A(N+1);
    vector<int> dp(N+1,0);
    dp[0]=0;
    cin>>A[0]>>A[1];
    dp[1]=abs(A[1]-A[0]);
    for(int i=2;i<N;i++)
    {
        cin>>A[i];
        dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i]-A[i-2]));
        
    }
    cout<< dp[N-1];
    return 0;
    
}

Measured memory_bytes: 1792
#include <iostream>
 
int main() {
  const static int NUM_OF_BOXES = 3;
  char boxes[3];
  std::cin >> boxes;
  int numOfBalls = 0;
  for (size_t i = 0U; i < NUM_OF_BOXES; ++i) {
    if (boxes[i] == '1') {
      numOfBalls++;
    }
  }
  std::cout << numOfBalls;
}

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

int main() {
  string S;
  getline(cin,S);
  if(S.at(0)==S.at(1)) cout<<"Bad"<<endl;
  else if(S.at(1)==S.at(2)) cout<<"Bad"<<endl;
  else if(S.at(2)==S.at(3)) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
  
}


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

int main() {
    int cnt;
    cin >> cnt;
    int* num = new int[cnt];
    if (num == NULL) { return -1; }
    for (int i = 0; i < cnt; i++) {
        cin >> num[i];
    }
    int Scnt = 0;
    bool flag = true;
    for (int i = 0; i < cnt; i++) {
        int minj = i;
        for (int j = i; j < cnt; j++) {
            if (num[j] < num[minj]) {
                minj = j;
            }
        }
        if(i!=minj){
            swap(num[i], num[minj]);
            Scnt++;
        }
    }
    for (int i = 0; i < cnt; i++) {
        if (i)cout << ' ';
        cout << num[i];
    }
    cout << endl << Scnt << endl
        ;
    delete num;
    return 0;
}


Measured memory_bytes: 3076
n = STDIN.gets.to_i
i = 1
check1 = true
check2 = true
check3 = true

while true do
  x = i
  if x % 3 == 0 && check1  then
    print " " + i.to_s
    check2 = false
    check3 = false
  end
  
  if x % 10 == 3 && check2 then
    print " " + i.to_s
    check3 = false
  end

  if check3 then
    while true do
      x /= 10
      if x > 0 then
        if x % 10 == 3 then
          print " " + i.to_s
          break
        end
      else
        break
      end
    end
  end
  
  i += 1
  if i > n
    break
  end

  check1 = true
  check2 = true
  check3 = true
end
print "\n"

Measured memory_bytes: 8792
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  ll occ[26] = {};
  string s;
  cin >> n >> s;
  ll ans = 1;
  for (char c : s)
    occ[c-'a']++;
  for (int i = 0; i < 26; i++)
    ans = (ans*(occ[i]+1))%mod;
  cout << ans-1;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    int ans = 0;
    rep(i,n) ans += s[i];
    if (ans % 10 != 0){
        cout << ans << endl;
        return 0;
    }

    sort(all(s));
    rep(i,n){
        if (s[i] % 10 != 0){
            cout << (ans - s[i]) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)


int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.size(),m=s2.size();
	int dp[n+1][m+1];

	ffor(i,0,n+1)
	{
		ffor(j,0,m+1)
		{
			if(i==0||j==0) dp[i][j]=0;
			else if(s1[i-1]==s2[j-1]) dp[i][j]=1+dp[i-1][j-1];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
   // cout<<dp[n][m];
	string s;
	int i=n,j=m;
	while(i>0&&j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			s.push_back(s1[i-1]);
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}

	bfor(k,(int)s.size(),0) cout<<s[k];

	return 0;
}


Measured memory_bytes: 35456
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in();
	vector<string>a(n), b(m);
	REPC(&i, a)cin >> i;
	REPC(&i, b)cin >> i;
	REP(y, n - m + 1) {
		REP(x, n - m + 1) {
			bool same = true;
			REP(dy, m) {
				REP(dx, m) {
					same &= b[dy][dx] == a[y + dy][x + dx];
				}
			}
			if (same) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;
int ret = 1 << 29;

int n, m, R;

//vector<vector<int>> d;
int r[9], d[201][201];
bool visited[9];

void dfs(int pos = -1, int cnt = 0, int dis = 0) {
	if (cnt == R) {
		if (ret > dis)
			ret = dis;
		return;
	}

	for (int i = 1; i <= R; i++) {
		if (!visited[i]) {
			visited[i] = true;
			if (pos == -1)
				dfs(i, cnt + 1, 0);
			else
				dfs(i, cnt + 1, dis + d[r[pos]][r[i]]);
			visited[i] = false;
		}
	}
}

int main(void) {
	cin >> n >> m >> R;
	//	d.resize(n + 1, vector<int>(n + 1, ret));
	//	for (int i = 1; i <= n; i++)
	//		d[i][i] = 0;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j) d[i][j] = ret;
	for (int i = 1; i <= R; i++)
		cin >> r[i];
	for (int i = 0; i < m; i++) {
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		if (d[ai][bi] > ci)
			d[ai][bi] = d[bi][ai] = ci;
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (d[i][j] > d[i][k] + d[k][j])
					d[i][j] = d[i][k] + d[k][j];
			}
		}
	}
	dfs();
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/perl
use POSIX qw(floor);

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my %c = ();
for(my $i=0;$i<$n;$i++){
  ( my $s = scalar(<STDIN>) ) =~ s/[\x00-\x20]+$//ios;
  $c{$s} ++;
}

$c{'AC'} -= 0;
$c{'WA'} -= 0;
$c{'TLE'} -= 0;
$c{'RE'} -= 0;


print "AC x $c{'AC'}\n";
print "WA x $c{'WA'}\n";
print "TLE x $c{'TLE'}\n";
print "RE x $c{'RE'}\n";



Measured memory_bytes: 6624
fun main(args: Array<String>) {
    val (a, b) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val s = readLine() ?: return

    for (i in 0 until a) {
        if (s[i] == '-') {
            println("No")
            return
        }
    }

    if (s[a] != '-') {
        println("No")
        return
    }

    for (i in (a + 1)..(a + b)) {
        if (s[i] == '-') {
            println("No")
            return
        }
    }

    println("Yes")
}

Measured memory_bytes: 37736
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll X, Y; cin >> X >> Y;
    if (abs(X-Y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define X first
#define PB push_back
#define Y second
using namespace std;
int n;
int a[200005];

bool can(int x)
{
    if(x == 1)
        return false;
    vector<pair<int , int> > posVal;
    for(int i = 1; i < n; i++)
    {
        if(a[i] <= a[i - 1])
        {
            while(posVal.size() && posVal.back().X > a[i])
            {
                posVal.pop_back();
            }
            int pos = a[i];
            
            while(true)
            {
                if(posVal.size() && posVal.back().X == pos)
                {
                    posVal.back().Y++;
                }
                else
                    posVal.PB({pos , 1});
                if(posVal.back().Y == x)
                {
                    posVal.pop_back();
                    pos--;
                }
                else
                    break;
            }
            if(pos == 0)
            {
                return false;
            }
        }
    }
    return true;
}
int main() 
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    bool canOne = true;
    for(int i = 1; i < n; i++)
    {
        canOne &= a[i] > a[i - 1];
    }
    if(canOne)
    {
        cout << 1;
        return 0;
    }
    int ans = 0;
    for(int i = 30; i >= 0; i--)
    {

        if(!can(ans + (1 << i)))
        {
            ans += (1 << i);
        }
    }
    cout << ans + 1;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
  int W,H,N,ans=0;
  cin>>W>>H>>N;
  int X,Y;
  int X1,Y1;
  cin>>X>>Y;
  for(int i=1;i<N;i++){
  	cin>>X1>>Y1;
    while(X1>X&&Y1>Y){
    	X++;Y++;ans++;
    }
    while(X1<X&&Y1<Y){
    	X--;Y--;ans++;
    }
    ans+=abs(X1-X);
    ans+=abs(Y1-Y);
    X=X1;Y=Y1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        double[] ave = new double[N];
        for (int i = 0; i < N; i++) {
            int H = sc.nextInt();
            ave[i] = Math.abs(T - H * 0.006 - A);
        }
        double min = Math.pow(10, 9);
        int res = 0;
        for (int i = 0; i < N; i++) {
            min = Math.min(min, ave[i]);
            if (ave[i] == min) {
                res = i + 1;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 22484
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	string n; cin >> n;
	for (int i = 0; i < n.size(); i++) {
		int cnt = 0;
		for (int j = 0; j < n.size(); j++) {
			if (j != i) {
				if (n[i] == n[j]) cnt++;
			}
		}
		if (cnt == 1) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {

	char S[102], T[102], U[103];
	scanf("%s%s", S, T);
	int len;
	len = strlen(S);
	int okflg = 0;

	bool jadge = false;
	if (strcmp(S, T) == 0) {
		jadge = true;
	}
	else {
		for (int j = 0; j < len; j++) {
			for (int i = len; i > 0; i--) {
				S[i] = S[i - 1];
			}
			S[0] = S[len];
			S[len] = NULL;

			if (strcmp(T, S) == 0) {
				jadge = true;
				break;
			}
		}
	}

	if (jadge == true) {
		puts("Yes");
	}
	else {
		puts("No");
	}




#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    static ref H: Mutex<Vec<i32>> = Mutex::default();
    static ref W: Mutex<Vec<i32>> = Mutex::default();
}

//abc163-D
// #[fastout]

const MOD: usize = 1000000000 + 7;

fn main() {
    input![n: usize, a: [usize; n]];

    let a_sum_div2: usize = a.iter().sum::<usize>() / 2;

    let mut idx = 2;
    let mut a1 = a_sum_div2;
    loop {
        if idx - 1 >= a.len() {
            break;
        }

        a1 -= a[idx - 1];
        idx += 2;
    }

    let mut anss = vec![0; n];
    anss[0] = a1;
    // print!("{} ", a1);
    for i in 1..n {
        anss[i] = a[i - 1] - anss[i - 1];
    }

    let ans = anss.iter().fold(String::new(), |mut mid_res, item| {
        mid_res.push_str(&format!("{} ", item * 2));
        mid_res
    });
    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 5688
[N, K] = input().split(' ')
N = int(N)
K = int(K)
As = input().split(' ')
As = [int(a) for a in As]
nums = {}
for a in As:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1

S = len(nums)

if S <= K:
    print(0)
else:
    xs = [v for v in nums.values()]
    xs.sort()
    print(sum(xs[0:S-K]))


Measured memory_bytes: 32260
#include <stdio.h>
 
int main(void){
    int a[3][10]={0},b[3][10]={0},c[3][10]={0},d[3][10]={0};
    int n,i,o,t,f,r,v,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&t,&f,&r,&v);
        switch(t){
            case 1:a[f-1][r-1]+=v;break;
            case 2:b[f-1][r-1]+=v;break;
            case 3:c[f-1][r-1]+=v;break;
            case 4:d[f-1][r-1]+=v;break;
        }
    }
    for(o=0;o<3;puts(""),o++)
        for(j=0;j<10;j++)
            printf(" %d",a[o][j]);
    for(i=0;i<20;i++)
        printf("#%s",i==19?"\n":"");
    for(o=0;o<3;puts(""),o++)
        for(j=0;j<10;j++)
            printf(" %d",b[o][j]);
    for(i=0;i<20;i++)
        printf("#%s",i==19?"\n":"");
    for(o=0;o<3;puts(""),o++)
        for(j=0;j<10;j++)
            printf(" %d",c[o][j]);
    for(i=0;i<20;i++)
        printf("#%s",i==19?"\n":"");
    for(o=0;o<3;puts(""),o++)
        for(j=0;j<10;j++)
            printf(" %d",d[o][j]);
    return 0;
}



Measured memory_bytes: 2104
#include<cstdio>
using namespace std;
int n;
int a[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    scanf("%d",&n);
    printf("%d",a[n-1]);
}

Measured memory_bytes: 128
N = int(input())
D = list(map(int,input().split()))

ans = 0

for i in range(N-1):
    a = D.pop(0)
    for j in range(N):
        
        try:
            # print("a="+ srt(a)
            # print("D[j]=" +str(D[j]))
            ans += a * D[j]
        except:
            continue
        #ans += D[i] * D[i+1]


print(ans)

Measured memory_bytes: 2940
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
elif x in c and y in c:
  print('Yes')
else:
  print('No')

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

int main() {
    int r, g, b;
    int x, rgb;
    string s;
    cin >> r >> g >> b;
    rgb = (r*10*10)+(g*10)+(b);
    x = rgb%4 == 0;
    if ( x ) s = "YES";
    else s = "NO";
    cout << s << endl;
}

Measured memory_bytes: 256
# @author 

import sys

class BFrog2:
    def solve(self):
        n, k = [int(_) for _ in input().split()]
        h = [int(_) for _ in input().split()]
        dp = [float('inf')] * n
        dp[0] = 0
        for i in range(n):
            for p in range(max(i - k, 0), i):
                dp[i] = min(dp[i], dp[p] + abs(h[i] - h[p]))

        print(dp[n - 1])

solver = BFrog2()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 55004
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int a, b;

int main() {
    cin >> a >> b;
    if(a <= 2*b) cout << 0 << endl;
    else cout << a - 2*b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

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

    ll ans = 0, cnt = 0;
    zep(i, 0, n){
        ll d1, d2; cin >> d1 >> d2;

        if(d1 == d2){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    
    print((ans >= 3)? "Yes" : "No")

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  bool ans = false;
  if (a == b && b != c) ans = true;
  if (a == c && a != b) ans = true;
  if (b == c && a != c) ans = true;

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if (a > x){
        cout << "NO" << endl;
    }else if (a + b >= x){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int NIL = -1;
const int MAX_N = 100100;
struct Node{ int parent, left, right; };
Node T[MAX_N];

int getDepth(int u){
    int d = 0;
    while(T[u].parent != NIL){
        u = T[u].parent;
        d++;
    }
    return d;
}

void printChildren(int u){
    vector<int> ch;
    if(T[u].left == NIL){
        cout << "[]";
    }else{
        u = T[u].left;
        ch.push_back(u);
        while(T[u].right != NIL){
            u = T[u].right;
            ch.push_back(u);
        }
    }
    if(ch.size() != 0){
        if(ch.size() == 1){
            printf("[%d]", ch[0]);
        }else{
            rep(i, ch.size()){
                if(i == 0){
                    printf("[%d, ", ch[i]);
                }else if(i == ch.size()-1){
                    printf("%d]", ch[i]);
                }else{
                    printf("%d, ", ch[i]);
                }
            }
        }
    }
}

int main()
{
    int n; cin >> n;
    // 初期化
    rep(i,n){
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }
    // 情報の読み込み
    rep(i,n){
        int p; cin >> p;
        int k; cin >> k;
        int ori_c = NIL;
        rep(j,k){
            int c; cin >> c;
            if(T[p].left == NIL) T[p].left = c;
            T[c].parent = p;
            if(ori_c != NIL) T[ori_c].right = c;
            ori_c = c;
        }
    }
    rep(i,n){
        printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, getDepth(i));
        if(T[i].parent == -1){
            printf("root, ");
        }else{
            if(T[i].left == NIL) printf("leaf, ");
            else printf("internal node, ");
        }
        printChildren(i); cout << endl;
    }
}


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

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

int a[200005];

int main(void){
	int N,M;
	long long sum = 0;
	cin >> N >> M;
	REP(i,N) cin >> a[i];
	sort(a,a+N);
	reverse(a,a+N);
	for(int i=M; i<N; i++) sum += a[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
if n < 2:
 print(1)
elif n < 4:
 print(2)
elif n < 8:
 print(4)
elif n < 16:
 print(8)
elif n < 32:
 print(16)
elif n < 64:
 print(32)
else:
 print(64)

Measured memory_bytes: 3060
{-# OPTIONS_GHC -Wall -Werror #-}

qq :: (Int, Int) -> String
qq (xi, yi) = x ++ "x" ++ y ++ "=" ++ ans
  where x   = show xi
        y   = show yi
        ans = show (xi * yi)

main :: IO ()
main = mapM_ putStrLn [qq (x, y) | x <- [1..9], y <- [1..9]]

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

int main(){
	int h, n;
    cin >> h >> n;
    int k = 0;
    int in = 0;
    rep(i, n){
     cin >> in;
     k += in;
    }
    if(h <= k){
	  cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
R=[tuple(map(int,input().split())) for i in range(M)]

E=[set() for i in range(N)]

for x,y in R:
    E[x-1].add(y-1)

DP=[M]*N
DP[N-1]=0

for i in range(N-2,-1,-1):
    score=0
    for x in E[i]:
        score+=1+DP[x]

    DP[i]=score/len(E[i])
        
ANS=DP[0]

for i in range(N-2):
    rem=-1
    remsc=0
    for j in E[i]:
        if DP[j]>remsc:
            rem=j
            remsc=DP[j]

    if remsc==0:
        continue

    E[i].remove(rem)

    NDP=[M]*N
    NDP[N-1]=0

    for l in range(N-2,-1,-1):
        
        score=0
        
        if len(E[l])==0:
            continue
        
        for x in E[l]:
            score+=1+NDP[x]

        NDP[l]=score/len(E[l])

    #print(i,rem,E,NDP)

    ANS=min(ANS,NDP[0])
    E[i].add(rem)

print(ANS)

Measured memory_bytes: 87516
n = int(input())
s = list(input())
a = ['0','1','2','3','4','5','6','7','8','9']
g = []
for i in a:
  for j in a:
    for k in a:
      g.append([i,j,k])
cnt=0
for i in g:
  d =0
  e =0
  while d < n:
    if s[d] == i[e]:
      e+=1
    d+=1
    if e==3:
      cnt+=1
      break
print(cnt)

Measured memory_bytes: 68352
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h, a;
	scanf("%d%d", &h, &a);
	int count = 0;
	while (h > 0) {
		count++;
		h -= a;
	}
	printf("%d\n", count);
	return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

class UnionFind {
    private:
        vi par;
        vi siz;

    public:
        UnionFind(int sz_) : par(sz_), siz(sz_, 1) { // すべて根とする
            rep(i, 0, sz_) par[i] = i;
        }

        void init(int sz_) { // 初期化
            par.resize(sz_);
            siz.resize(sz_, 1);
            rep(i, 0, sz_) par[i] = i;
        }

        int root(int x) { // 根を求める
            if(par[x] == x) return x;
            return par[x] = root(par[x]);
        }

        void unite(int x, int y) {
            int rx, ry;
            rx = root(x);
            ry = root(y);
            if(rx == ry) return;
            if(siz[rx] < siz[ry]) swap(rx, ry);
            siz[rx] += siz[ry];
            par[ry] = rx;
        }

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

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

int N,M,MAX=1e5+1;
vi A(MAX),B(MAX);

signed main() {
    cin>>N>>M;
    rep(i,0,M) {
        cin>>A[i]>>B[i];
    }

    vi d(M);
    UnionFind tree(N);
    rep(i,0,M) {
        int a = A[M-i-1]-1,b=B[M-i-1]-1;
        if(tree.same(a,b)) d[i]=0;
        else {
            d[i]=tree.size(a)*tree.size(b);
            tree.unite(a,b);
        }
    }
    int ret=0;
    rep(i,0,M) {
        ret+=d[M-i-1];
        cout<<ret<<endl;
    }
    return 0;
}
            







Measured memory_bytes: 5248
#include <iostream>
using namespace std;
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a[n+1];
    for(int i=0; i<n+1; i++) a[i]=0;
    for(int i=0; i<m; i++) {
        int b;
        cin >> b;
        a[b]=1;
    }

    int p=0, q=0;
    for(int i=0; i<=x; i++) p+=a[i];
    for(int i=x; i<n+1; i++) q+=a[i];
    cout << min(p, q) << endl;
    return 0;
}



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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0, j = n - 1; i < n and i < j;) {
        if (s[i] == 'W' and s[j] == 'R')swap(s[i++], s[j--]), ans++;
        else if (s[j] == 'W')j--;
        else if (s[i] == 'R')i++;
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

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

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

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

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish{
    ll time;
    ll taste;
};
int main()
{
    ll D, N;
    cin >> D >> N;
    if (N == 100) {
        cout << (pow_fast(100, D) * (N + 1)) << endl;
    } else {
        cout << (pow_fast(100, D) * N) << endl;
    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	int n;
	cin >> n;
	vector<double> ps(n);
	rep(i, n) cin >> ps[i];
	vector<vector<double>> dp(n + 2, vector<double>(n + 2, 0));
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, i+1) {
			dp[i + 1][j] += dp[i][j] * (1 - ps[i]);
			dp[i + 1][j+1] += dp[i][j] * ps[i];
		}
	}
	double sum = 0;
	for (int i = n / 2 + 1; i <= n; i++) {
		sum += dp[n][i];
	}
	cout << fixed << setprecision(10) << sum << endl;
	return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<int> v(n);
    int sum = 0;
    bool pos = 0, neg = 0;
    rep(i,0,n)
    {
        cin >> v[i];
        sum += abs(v[i]);
        pos |= (v[i] > 0);
        neg |= (v[i] < 0);
    }
    sort(all(v), greater<int>());
    if (pos && neg)
        cout << sum << '\n';
    else
        cout << sum - 2 * min(abs(v[0]), abs(v.back())) << '\n';
    int u = v.back();
    int i = 1;
    for (; i < n - 1 && v[i] > 0; ++i)
    {
        cout << u << ' ' << v[i] << '\n';
        u = u - v[i];
    }
    v.back() = u;
    for (; i < n; ++i)
    {
        cout << v[0] << ' ' << v[i] << '\n';
        v[0] = v[0] - v[i];
    }
    return 0;
}

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

int main(){
   double xA,yA,xB,yB,xC,yC,xD,yD;
   while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
      if(-0.0000000001 < (yA-yB)*(yC-yD) + (xC-xD)*(xA-xB) &&
	 (yA-yB)*(yC-yD) + (xC-xD)*(xA-xB) < 0.0000000001)
	 cout << "YES" << endl;
      else cout << "NO" << endl;
   }
   return 0;
}

Measured memory_bytes: 1224
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    print(n*(n-1)//2+m*(m-1)//2)

main()

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');

            if (0 < str[0].CompareTo(str[1]))
            {
                Console.WriteLine(">");
            }
            else if (0 > str[0].CompareTo(str[1]))
            {
                Console.WriteLine("<");
            }
            else
            {
                Console.WriteLine("=");
            }
        }
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int>> D(C,vector<int>(C));
  rep(y,C) rep(x,C) cin >> D[y][x];
  vector<vector<int>> c(N,vector<int>(N));
  rep(y,N) rep(x,N) {
    cin >> c[y][x];
    c[y][x]--;
  }
  ll ans = 1e18;
  vector<vector<ll>> cost(C,vector<ll>(3));
  rep(i,C) rep(j,3) cost[i][j]=0;
  rep(col,C){
    rep(y,N){
      rep(x,N){
        cost[col][(x+y)%3] += D[c[y][x]][col];
      }
    }
  }
  rep(i,C){
    rep(j,C){
      rep(k,C){
        if(i==j || j==k || i==k) continue;
        ll preans = cost[i][0] + cost[j][1] + cost[k][2];
        ans = min(ans,preans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
  long long n,k,l;
  cin >> n;
  for(long long i=1; i<=3500; i++) {
    for(long long j=1; j<=3500; j++) {
      k=4*i*j-n*j-n*i;
      l=n*i*j;
      if(k>0&&l%k==0) {
        cout << i << " " << j << " " << l/k << endl;
        return 0;
      }
    }
  }
}


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

def solve(N: int, M: int, S: int, U: "List[int]", V: "List[int]", A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    from collections import namedtuple
    from heapq import heappush, heappop
    MAX_COIN = sum(A)
    State = namedtuple('State', 'cost city coin')
    Edge = namedtuple('Edge', 'to fee cost')
    edges = [[] for _ in range(N+1)]
    for u, v, a, b in zip(U, V, A, B):
        edges[u].append(Edge(v, a, b))
        edges[v].append(Edge(u, a, b))
    for i, (c, d) in enumerate(zip(C, D), 1):
        edges[i].append(Edge(i, -c, d))
    hq = [State(0, 1, min(S, MAX_COIN))]
    min_costs = [[None] * (MAX_COIN+1) for _ in range(N+1)]
    while hq:
        s = heappop(hq)
        if min_costs[s.city][s.coin]:
            continue
        min_costs[s.city][s.coin] = s.cost
        for edge in edges[s.city]:
            if edge.fee > s.coin:
                continue
            ns = State(s.cost+edge.cost, edge.to, s.coin-edge.fee)
            if ns.coin > MAX_COIN or min_costs[ns.city][ns.coin]:
                continue
            heappush(hq, ns)
    return [min(filter(lambda x:x, c)) for c in min_costs[2:]]
        

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    U = [int()] * (M)  # type: "List[int]"
    V = [int()] * (M)  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        U[i] = int(next(tokens))
        V[i] = int(next(tokens))
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (N)  # type: "List[int]"
    D = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    print(*solve(N, M, S, U, V, A, B, C, D), sep='\n')

if __name__ == '__main__':
    main()


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    create_mod_tables(2*X);
    
    const int M = 510;
    static int64_t pre[M][M][M];
    for(int n=0; n<=X; n++) for(int s=0; s<=X; s++) pre[0][n][s] = 1;
    for(int i=0; i<N; i++) for(int n=0; n<=X; n++) for(int s=0; s<=X; s++){
        pre[i+1][n][s] = max(0, s-(L[i]-1)*n) * pre[i][n][s] % MOD;
    }

    static int64_t dp[2][M][M];
    dp[X%2][0][0] = 1;
    int pt = N-1;
    for(int x=X; x>0; x--){
        while(pt >= 0 && L[pt] > x) pt--;
        for(int n=0; (x+1)*n<=X; n++) for(int s=0; s<=X; s++){
            int64_t bef = dp[x%2][n][s];
            if(bef == 0) continue;
            if(n == 0 && pt < N-1) continue;
            if(n > 0) mul(bef, inv_mod(pre[pt+1][n][s]));

            for(int k=0; s+x*k<=X; k++){
                int n2 = n+k, s2 = s+x*k;
                int64_t res = bef;
                if(n2 > 0) mul(res, pre[pt+1][n2][s2] * comb_mod(n2, k) % MOD);
                add(dp[(x-1)%2][n2][s2], res);
            }
        }
        for(int n=0; n<=X; n++) for(int s=0; s<=X; s++) dp[x%2][n][s] = 0;
    }

    int64_t ans = 0;
    for(int n=1; n<=X; n++) for(int s=1; s<=X; s++){
        int rest = X-s-(n-1);
        if(rest < 0) continue;
        int64_t res = comb_mod(rest+n, n) * dp[0][n][s] % MOD;
        int blank = X-s;
        if(blank%2) res = MOD-res;
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

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



int main(){
	int ma[10]={0,2,5,5,4,5,6,3,7,6};
	int N,M;
	cin>>N>>M;
	int A[9];
	rep(i,M)cin>>A[i];
	sort(A,A+M,greater<int>());
	
	//dp[i]はi本のマッチで作れる整数の最大桁数
	int dp[MAX];
	dp[0]=0;
	rep1(i,N){
		dp[i]=-1;
		rep(j,M){
			if(ma[A[j]]>i)continue;
			dp[i]=max(dp[i],dp[i-ma[A[j]]]+1);
		}
	}
	int K=dp[N];
	int rm=N;
	while(rm>0){
		rep(j,M){
			if(rm-ma[A[j]]>=0 && dp[rm-ma[A[j]]]==K-1){
				cout<<A[j];
				K--;
				rm-=ma[A[j]];
				break;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class RangeAdd{
    int N;
    int[] d;
    public RangeAdd(int N){
        this.N = N;
        this.d = new int[N+1];
    }
    void add(int v, int l, int r){
        d[l] += v;
        d[r] -= v;
    }
    int[] out(){
        int[] ret = new int[N];
        ret[0] = d[0];
        for(int n=1; n<N; n++) {
            ret[n] = ret[n-1] + d[n];
        }
        return ret;
    }
}
public class Main {
    static int[] solve(int N, int K, int[] A){
        int[] ans = new int[N];
        for(int n=0; n<N; n++) ans[n] = A[n];

        int[] max = new int[N];
        Arrays.fill(max, N);
        for(int k=0; k<K; k++){
            RangeAdd next = new RangeAdd(N);
            for(int n=0; n<N; n++){
                next.add(1, Math.max(0,n-ans[n]), Math.min(n+ans[n]+1, N));
            }
            ans = next.out();
            if(Arrays.equals(ans,max)){
                break;
            } 
        }
        return ans;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int n=0; n<N; n++) A[n]=sc.nextInt();
        int[] ans = solve(N,K,A);
        for(int n=0; n<N-1; n++) System.out.print(ans[n] + " "); System.out.println(ans[N-1]);
        
    }
}


Measured memory_bytes: 64356
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>
 
using namespace std;
 
using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
 
 
int main(int argc, char **argv) {
    char c1,c2,c3;
    cin >> c1 >> c2 >> c3;
 
    if (c1 == '7' || c2 == '7' || c3 =='7')
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
/**
 *		author:  zvm
 *		created: 28.09.2020 10:18:12
**/

#include <bits/stdc++.h>

using namespace std ;

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

	string s ;
	cin >> s ;
	
	int x, y ;
	cin >> x >> y ;

	int n = s.size();
	vector<vector<int>> move(2);

	int dir = 0, steps = 0 ;
	for( int i = 0 ; i < n ; ++i ) {
		if( s[i] == 'T' ) {
			move[dir].push_back(steps);
			steps = 0 ;
			dir ^= 1 ;
		}
		else {
			steps++ ;
		}
	}
	move[dir].push_back(steps);

	int N = move[0].size();
	int M = move[1].size();
	
	vector<vector<int>> dpx(N+1,vector<int>(2*n+1,false));
	vector<vector<int>> dpy(M+1,vector<int>(2*n+1,false));

	dpx[0][n] = dpx[1][n+move[0][0]] = true ;
	dpy[0][n] = true ;

	auto valid = [&]( int x, int limit ) {
		return 0 <= x && x <= limit ;
	};

	for( int i = 2 ; i <= N ; ++i ) {
		for( int j = 0 ; j <= 2*n ; ++j ) {
			int lx = j-move[0][i-1] ;
			int rx = j+move[0][i-1] ;
			if( valid(lx,2*n) ) {
				dpx[i][j] |= dpx[i-1][lx] ;
			}
			if( valid(rx,2*n) ) {
				dpx[i][j] |= dpx[i-1][rx] ;
			}
		}
	}

	for( int i = 1 ; i <= M ; ++i ) {
		for( int j = 0 ; j <= 2*n ; ++j ) {
			int ty = j+move[1][i-1] ;
			int by = j-move[1][i-1] ;
			if( valid(ty,2*n) ) {
				dpy[i][j] |= dpy[i-1][ty] ;
			}
			if( valid(by,2*n) ) {
				dpy[i][j] |= dpy[i-1][by] ;
			}
		}
	}

	cout << ( dpx[N][n+x] && dpy[M][n+y] ? "Yes" : "No" ) << endl ;
}


Measured memory_bytes: 495384
use proconio::input;

fn main() {
    input!{
        n: usize,
    }

    let mut count_of_multiple_4: u64 = 0;
    let mut count_of_multiple_2: u64 = 0;
    let mut count_of_others: u64 = 0;

    for _i in 0..n {
        input!{
            a: u64,
        }

        if a % 4 == 0 {
            count_of_multiple_4 += 1;
        } else if a % 2 == 0 {
            count_of_multiple_2 += 1;
        } else {
            count_of_others += 1;
        }
    }

    let mut tmp = n;

    if count_of_multiple_2 == n as u64 {
        tmp = 0;
        count_of_multiple_2 = 0;
        count_of_others = 0;
        count_of_multiple_4 = 0;
    }

    while count_of_multiple_4 > 0 && count_of_others > 0 {
        tmp -= 2;
        count_of_multiple_4 -= 1;
        count_of_others -= 1;
    }

    if count_of_others == 0 {
        while tmp > 0 && count_of_multiple_2 > 0 {
            tmp -= 1;
            count_of_multiple_2 -= 1;
        }
    } else if count_of_others > 0 {
        count_of_others -= 1;
        tmp -= 1;
    }

    if (tmp > 0 && count_of_others > 0) || (tmp > 0 && count_of_multiple_2 > 0) {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 3184
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define IOI 101
#define IOIOIOIOI 101010101
int dp[10 * IOI][10 * IOI];
string s, t;
int main() {
    for (int i = 0; i < 10 * IOI; i++) {
        for (int j = 0; j < 10 * IOI; j++) {
            dp[i][j] = IOIOIOIOI;
        }
    }
    cin >> s; cin >> t;
    for (int i = 0; i <= s.size(); i++)dp[i][0] = i;
    for (int i = 0; i <= t.size(); i++)dp[0][i] = i;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            dp[i + 1][j + 1] = min(dp[i][j], min(dp[i + 1][j], dp[i][j + 1])) + 1;
            if (s[i] == t[j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
        }
    }
    cout << dp[s.size()][t.size()] << endl;
    return 0;
}


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,k;
int main()
{
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    if(k==0){printf("%lld\n",a-b);return 0;}
    k%=2;
    if(k==0) k=2;
    while(k--)
    {
        ll aa=b+c,bb=a+c,cc=a+b;
        a=aa;b=bb;c=cc;
    }
    printf("%lld\n",a-b);
}


Measured memory_bytes: 256