akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_mut)]

use crate::rust::library::{data_structure::union_find::UF, util::io::*};
use itertools::*;

fn main() {
    input!{
        n:usize,
        m:usize,
        v:[(usize1,usize1);m],
    }
    let mut uf=UF::new(n);
    for (s,t) in v{
        uf.unite(s,t);
    }
    println!("{}",(0..n).map(|t|uf.size(t)).max().unwrap());
}




pub mod rust {

pub mod library {

pub mod data_structure {

pub mod union_find {

pub struct UF{
    par:Vec<usize>,
    rank:Vec<usize>,
}
impl UF{
    pub fn new(n:usize)->UF{
        let mut v=vec![0;n];
        for i in 0..n{
            v[i]=i;
        }
        UF{
            par:v,
            rank:vec![1;n],
        }
    }
    pub fn root(&mut self,x:usize)->usize{
        if x==self.par[x]{
            x
        }else{
            let par=self.par[x];
            let res=self.root(par);
            self.par[x]=res;
            res
        }
    }
    pub fn same(&mut self,a:usize,b:usize)->bool{
        self.root(a)==self.root(b)
    }
    pub fn unite(&mut self,a:usize,b:usize)->bool{
        let ap=self.root(a);
        let bp=self.root(b);
        if ap==bp{
            return false;
        }
        if self.rank[ap]<self.rank[bp]{
            self.par[bp]=ap;
            self.rank[ap]+=self.rank[bp];
        }else{
            self.par[ap]=bp;
            self.rank[bp]+=self.rank[ap];
        }
        return true;
    }
    pub fn size(&mut self,a:usize)->usize{
        let ap=self.root(a);
        self.rank[ap]
    }
}

}  // mod union_find

}  // mod data_structure

pub mod util {

pub mod io {

#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export] 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export] 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    
    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

}  // mod io

}  // mod util

}  // mod library

}  // mod rust



Measured memory_bytes: 13844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    string s;
    cin >> s;
    char tmp = s[0];
    for(int i=0; i < 3; ){
        if(s[i] == s[++i]){
            cout << "Bad"<<endl; return 0;
        }
    }

    cout << "Good" << endl;return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 4005;
const int inf = 0x3f3f3f3f;
vector<int>VR,VG,VB;
char a[N];
ll ans=0,x=0,R,G,B;
int main()
{
	int n;
	scanf("%d%s",&n,a);
	for(int i=0;i<n;i++)
	if(a[i]=='R')R++;
	else if(a[i]=='G')G++;
	else B++;
	ans=R*G*B;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int k=j*2-i;
			if(k<n&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
			x++;
		}
	}
	cout<<ans-x;
	return 0;
}

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

typedef long long int ll;

ll gcd(ll a, ll b){
    if( a < b ) swap(a, b);
    int c;
    while( a%b ){
        c = a%b;
        a = b;
        b = c;
    }
    return b;
}

int main(){
    int a[3], m[3];
    while( cin>>a[0]>>m[0]>>a[1]>>m[1]>>a[2]>>m[2],
           a[0]|m[0]|a[1]|m[1]|a[2]|m[2] ){
        int p[3];
        ll c[3];
        for(int i = 0; i < 3; i++){
            c[i] = 1;
            p[i] = a[i]%m[i];
            while( p[i]-1 ){
                p[i] = a[i]*p[i]%m[i];
                c[i]++;
            }
        }
        ll LCM = c[0]*c[1]/gcd(c[0], c[1]);
        cout << LCM*c[2]/gcd(LCM, c[2]) << endl;
    }
    return 0;
}

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

cnt = 0
for i in range(1,101):
    flg = False
    for j in range(N):
        if H[j] >= i:
            flg = True
        elif flg:
            flg = False
            cnt += 1
    if flg:
        cnt += 1
print(cnt)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    int a[n + 2];
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    rep(i, n + 1)
        sum += abs(a[i] - a[i + 1]);

    for (int i = 1; i <= n; i++)
    {
        OP(sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]));
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
#define pli pair<LL, int>
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

int n, m;
LL dis[MAXN];
bool vis[MAXN];
priority_queue<pli> q;

struct Edge {
	int v, w, nxt;
} e[MAXN << 1];
int first[MAXN], ecnt;

inline void AddEdge(int u, int v, int w) {
	e[++ecnt].v = v;
	e[ecnt].w = w;
	e[ecnt].nxt = first[u];
	first[u] = ecnt;
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= m; ++i) {
		int l, r, c;
		read(l); read(r); read(c);
		AddEdge(l, r, c);
	}
	for (int i = 1; i < n; ++i) {
		AddEdge(i + 1, i, 0);
	}
}

void solve() {
	mset(dis, 0x3f);
	mset(vis, 0);
	dis[1] = 0;
	q.push(make_pair(0, 1));
	while (!q.empty()) {
		int u = q.top().se;
		q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (dis[v] > dis[u] + e[i].w) {
				dis[v] = dis[u] + e[i].w;
				q.push(make_pair(-dis[v], v));
			}
		}
	}
	printf("%lld\n", (dis[n] == INF)? -1 : dis[n]);
}

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


Measured memory_bytes: 4856
#include<iostream>
#include<algorithm>

using namespace std;

class Dice {
    public:
        int D[6];

        void constractor(int d1, int d2, int d3, int d4, int d5, int d6);
        void Rotate_E();
        void Rotate_N();
        void Rotate_S();
        void Rotate_W();

};

void Dice::constractor (int d1, int d2, int d3, int d4, int d5, int d6) {
    D[0] = d1;
    D[1] = d2;
    D[2] = d3;
    D[3] = d4;
    D[4] = d5;
    D[5] = d6;
}

void Dice::Rotate_E () {
    int tmp;

    tmp = D[2];
    D[2] = D[0];
    D[0] = D[3];
    D[3] = D[5];
    D[5] = tmp;
}

void Dice::Rotate_N () {
    int tmp;

    tmp = D[4];
    D[4] = D[0];
    D[0] = D[1];
    D[1] = D[5];
    D[5] = tmp;
}

void Dice::Rotate_S () {
    int tmp;

    tmp = D[4];
    D[4] = D[5];
    D[5] = D[1];
    D[1] = D[0];
    D[0] = tmp;
}

void Dice::Rotate_W () {
    int tmp;

    tmp = D[2];
    D[2] = D[5];
    D[5] = D[3];
    D[3] = D[0];
    D[0] = tmp;
}

bool Dice_Compare (Dice dice0, Dice dice1) {

    for (int X = 0; X < 6; X++) {

        Dice dice[2];
        dice[0] = dice0;
        dice[1] = dice1;

        if (X == 0) {

            dice[1].Rotate_S();
        
        } else if (X == 1) {

        } else if (X == 2) {

            dice[1].Rotate_W();
            dice[1].Rotate_S();

        } else if (X == 3) {

            dice[1].Rotate_E();
            dice[1].Rotate_S();

        } else if (X == 4) {

            dice[1].Rotate_S();
            dice[1].Rotate_S();

        } else {

            dice[1].Rotate_N();

        }

        for (int i = 0; i < 4; i++) {

            dice[1].Rotate_E();

            for (int i = 0; i < 6; i++) {
                if (dice[0].D[i] != dice[1].D[i]) {
                    // cout << "X: " << X << " i: " << i << endl;
                    break;
                }

                if (i == 5) {
                    // cout << "X: " << X << endl;
                    return true;
                }
            }
        }

    }

    return false;

}

int main () {

    Dice dice[2];
    
    for (int i = 0; i < 2; i++) {
        
        int d1, d2, d3, d4, d5, d6;
        cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6;

        dice[i].constractor(d1, d2, d3, d4, d5, d6);

    }

    bool answer = Dice_Compare (dice[0], dice[1]);

    if (answer) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  Vs Sv(n);
  VIN(Sv)
  string ans = "";
  SORT(Sv);
  REP(i,n){
    ans += Sv[i];
  }
  OUT(ans);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int a[n][n];
    FOR(i,0,n-1) FOR(j,0,n-1) {
        cin >> a[i][j];
    }

    ll cost[(1<<n)];
    ll dp[(1<<n)]; dp[0] = 0;

    FOR(X,1,(1<<n)-1) {
        cost[X] = 0;
        FOR(i,0,n-1) FOR(j,i+1,n-1) if (((X & (1<<i)) > 0) and ((X & (1<<j)) > 0)) {
            cost[X] += a[i][j];
        }

        dp[X] = -(1e18+10);
        for (int Y = X; Y; Y = X & (Y-1)) {
            dp[X] = max(dp[X], dp[X^Y] + cost[Y]);
            //cout << '\t' << X << " :: " << Y << " " << dp[Y] << " " << cost[Y] << endl;
        }
        //cout << X << " : " << dp[X] << endl;
    }

    cout << dp[(1<<n)-1] << '\n';
}



Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, x;
    cin >> n >> x;
    int m[n];
    rep(i, n) { cin >> m[i]; }

    sort(m, m + n);
    int sum = 0;
    rep(i, n) { sum += m[i]; }
    x -= sum;
    int ans = n + x / m[0];
    cout << ans << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b > a) {
        int temp = a;
        a = b;
        b = temp;
    }
    if (b == 0) {
        return a;
    }
    return (b, b % a);
}


Measured memory_bytes: 256
n=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)


import collections
d=collections.Counter(L)
M=0
m=[0,0]
for v in d:
	if d[v]>=4:
		M=max(M,v)
	elif d[v]>=2:
		m.append(v)
m.sort(reverse=True)

print(max(M**2,m[0]*m[1],M*m[0]))

Measured memory_bytes: 22044
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = (int)1e9 + 7;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e7;
	
	
	void doIt() {
		int a = sc.nextInt();
		System.out.println(a + a * a + a * a * a);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
 
}

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

const double INITIAL_PROFIT = -DBL_MAX;

// O(n^2)
int search_result(vector<int> data)
{
  auto max_profit = INITIAL_PROFIT;

  for (auto i = 0; i < data.size(); i++)
  {
    for (auto j = i + 1; j < data.size(); j++)
    {
      auto v = data[j] - data[i];

      if (v > max_profit)
      {
        max_profit = v;
      }
    }
  }

  return max_profit;
}

// O(n)
int search_result2(vector<int> data)
{
  double minr = data[0];
  auto maxv = INITIAL_PROFIT;

  for (auto i = 1; i < data.size(); i++)
  {
    maxv = max(maxv, double(data[i]) - minr);
    minr = min(minr, double(data[i]));
  }

  return maxv;
}

int main()
{
  int n;
  cin >> n;
  auto input = vector<int>{};
  for (auto i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    input.push_back(k);
  }

  auto profit = search_result2(input);

  cout << profit << endl;

  return 0;
}



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

typedef long long LL;	

int n;

LL li[20][20];
LL ans[(1<<16)];
bool vis[(1<<16)];

LL dp(int x){
	if(vis[x]) return ans[x];
	vis[x] = 1;
	for(int i=x;i>0;i=((i-1)&x)){
		if(i==x) continue;
		ans[x] = max(ans[x] , dp(i) + dp(x^i));
	}
	return ans[x];
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%lld",&li[i][j]);
		}
	}
	for(int i=1;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(!((1<<j)&i)) continue;
			for(int k=j+1;k<n;k++){
				if((1<<k)&i) ans[i] += li[j][k];
			}
		}
	}
	LL jaw = dp((1<<n)-1);
//	for(int i=1;i<(1<<n);i++) cout << ans[i] << " < ";
	printf("%lld\n",jaw);
	return 0;
}

Measured memory_bytes: 896
def sieve(n):
    primes = [True] * n
    primes[0] = primes[1] = False
    for i in xrange(2, int(n ** 0.5) + 1):
        if primes[i]:
            for j in xrange(i * i, n, i):
                primes[j] = False
    return [i for i in xrange(n) if primes[i]]

primes = sieve(50000)
ret = [0] * 100001
for i in xrange(len(primes)):
    for j in xrange(i, len(primes)):
        tmp = primes[i] + primes[j]
        if tmp > 50000:
            break
        ret[tmp] += 1
while 1:
    n = input()
    if n == 0:
        break
    print ret[n]

Measured memory_bytes: 5512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] damWater = Console.ReadLine().Split(' ');
            int k = int.Parse(damWater[0]);
            int x = int.Parse(damWater[1]);
 
            List<string> answer = new List<string>();
 
            for(int i = x - k + 1; i < x + k; i++)
            {
                    answer.Add(i.ToString());
                
            }
 
            Console.WriteLine(String.Join(" ",answer.ToArray()));
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char a[3],b[3];
	cin>>a; 
	cin>>b; 
	int n=0;
	for(int i=0;i<3;i++)
	{
		if(a[i]==b[i])   n++;
	}
	printf("%d",n);
	return 0;
} 

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];
  bool f = (a[0] == 0);
  ll ans = 0;
  FOR(i,1,n) {
    if (a[i] > a[i-1]+1) f = false;
    ans += a[i];
    if (a[i] == a[i-1]+1) ans -= a[i-1];
  }
  if (f) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 bool flag=false;
 ll xo;
 ll a[n+10];
 vector<ll>b;
 map<ll,ll>map;
 ll cnt=0;
 rep(i,0,n){
  sc(a[i]);
  if(i==0)xo=a[i];
  else xo^=a[i];
  if(n%3!=0&&a[i]!=0){
   pn;return 0;
  }
  if(map[a[i]]==0){

   cnt++;push(b,a[i]);
  }
  map[a[i]]++;
 }
 if(xo!=0||cnt>3){
 // cout<<xo<<" "<<cnt<<endl;
  pn;return 0;
 }
 py;
return 0;}


Measured memory_bytes: 9124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

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

    if (S.size() <= K ){
        cout << S << endl;
    } else{
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: i64 = input();

    let mut divs = vec![0; n as usize + 1];
    for i in 1..n + 1 {
        let mut temp = i;
        for j in 2..i + 1 {
            while temp % j == 0 {
                divs[j as usize] += 1;
                temp /= j;
            }
        }
    }

    let mut dp = vec![0; 76];
    dp[1] = 1;
    for i in 2..n {
        for j in (1..76).rev() {
            for k in 1..divs[i as usize] + 1 {
                let nxt = j * (k + 1);
                if nxt < 76 {
                    dp[nxt as usize] += dp[j];
                }
            }
        }
    }

    println!("{}", dp[75]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;

#define INF 1e9

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

	int minA = 1e9, maxA = -1e9;
	int minA_index, maxA_index;
	for (int i = 0; i < N; i++) {
		if (minA > A[i]) {
			minA = A[i];
			minA_index = i;
		}
		if (maxA < A[i]) {
			maxA = A[i];
			maxA_index = i;
		}
	}

	cout << 2 * N - 1 << endl;

	if (abs(minA) > abs(maxA)) {
		for (int i = 0; i < N; i++) {
			cout << minA_index+1 << " " << i+1 << endl;
		}

		for (int i = N - 1; i > 0; i--) {
			cout << i + 1 << " " << i - 1 + 1 << endl;
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			cout << maxA_index+1 << " " << i+1 << endl;
		}

		for (int i = 1; i < N; i++) {
			cout << i - 1 + 1 << " " << i + 1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

bool check_pass(string str) {
	if (str.length() < 6) {
		return false;
	}
	bool small,large,num;
	small = large = num = false;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] >= 'a' && str[i] <= 'z') {
			small = true;
		}
		if (str[i] >= 'A' && str[i] <= 'Z') {
			large = true;
		}
		if (str[i] >= '0' && str[i] <= '9') {
			num = true;
		}
	}
	return (small && large && num);
}

int main(void) {
	string str;
	cin >> str;
	if (check_pass(str)) {
		cout << "VALID" << endl;
	}
	else {
		cout << "INVALID" << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int calculateA = calculation(A);
		int calculateB = calculation(B); 
		int calculateAB = A+B;
		
		int maxAorB = Math.max(calculateA, calculateB);

		if(maxAorB < calculateAB) {
			System.out.println(calculateAB);
		}else {
			System.out.println(maxAorB);
		}
	}
	
	private static int calculation(int input) {
		return input + (input-1);
	}
}


Measured memory_bytes: 23380
import java.util.Scanner;
 
public class Main {
    public static void sort(int[] a,int i){
        int key=a[i];
        int j=i-1;
        while(j>=0 && a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
            sort(a,i);
            for(int k=0;k<n-1;k++){
                System.out.print(a[k]+" ");
            }
            System.out.println(a[n-1]);;
        }
    }
}

Measured memory_bytes: 33020
### constant

MAX_X = 5000
MAX_Y = 5000

### main

loop do
  n = gets.strip.to_i
  break if n == 0

  pts = []
  brd = (MAX_Y + 1).times.map{{}}

  n.times do
    x, y = gets.strip.split(' ').map{|s| s.to_i}
    pts << [x, y]
    brd[y][x] = true
  end

  npts = pts.length
  max_area = 0

  for i in (0...npts)
    x0, y0 = pts[i]
    for j in ((i + 1)...npts)
      x1, y1 = pts[j]
      dx = x1 - x0
      dy = y1 - y0

      for v in [[-dy, dx], [dy, -dx]]
        x2 = x0 + v[0]
        y2 = y0 + v[1]
        x3 = x1 + v[0]
        y3 = y1 + v[1]

        if x2 >= 0 && x2 <= MAX_X && y2 >= 0 && y2 <= MAX_Y &&
            x3 >= 0 && x3 <= MAX_X && y3 >= 0 && y3 <= MAX_Y &&
            brd[y2][x2] && brd[y3][x3]
          area = dx * dx + dy * dy
          max_area = area if max_area < area
        end
      end
    end
  end

  puts max_area
end

Measured memory_bytes: 6932
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n;
int main(int argc,char const* argv[])
{
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
W,H,N=map(int, input().split())
s=[[1]*W for i in range(H)]
for i in range(N):
    x,y,n=map(int,input().split())
    if n==1:
        for j in range(x):
            for k in range(H):
                s[k][j]=0
    elif n==2:
        for j in range(x,W):
            for k in range(H):
                s[k][j]=0
    elif n==3:
        for j in range(W):
            for k in range(y):
                s[k][j]=0
    elif n==4:
        for j in range(W):
            for k in range(y,H):
                s[k][j]=0
a=0
for i in s:
    a+=sum(i)
print(a)

Measured memory_bytes: 41456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void chmin(T &a, T b) {
    if (b < a) a = b;
}

int dp[10001];
int a[1000], b[1000];
int n;

int dfs(int h) {
    if (h <= 0) return 0;
    if (dp[h] > 0) return dp[h];

    int t = 1 << 30;
    for (int i = 0; i < n; i++) {
        chmin(t, dfs(h - a[i]) + b[i]);
    }
    return dp[h] = t;
}

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

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    cout << dfs(h) << endl;

    return 0;
}

Measured memory_bytes: 768
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

enum MOD = 10 ^^ 9 + 7;

void main()
{
    long ans = long.max;
    long[] inp;
    foreach (_; 0 .. 5)
        inp ~= lread();
    inp.sort();
    // writeln(inp);
    do
    {
        long tmp;
        foreach (i, a; inp)
        {
            if (tmp % 10 != 0)
                tmp += 10 - (tmp % 10);
            tmp += a;
        }
        ans = ans.min(tmp);
    }
    while (nextPermutation(inp));
    writeln(ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lines = line.split(" ", 0);
      
        int num = Integer.parseInt(lines[0]);
        int dis = Integer.parseInt(lines[1]);
      
      int count = 0;
        for (int i = 0; i < num; i++) {
            line = sc.nextLine();
        	String[] lines2 = line.split(" ", 0);
            double pos = Math.sqrt(Long.parseLong(lines2[0]) * Long.parseLong(lines2[0])
              + Long.parseLong(lines2[1]) * Long.parseLong(lines2[1]));
          if (pos <= dis) {
                count++;
            }else{
          }
        }
        
     System.out.println(count);
    }
}

Measured memory_bytes: 63332
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  string s;
  cin >> s;

  int ans = 0;
  rep(i,sz(s)-1) {
    if (s[i] == s[i+1]) {
      //debug(i);
      s[i+1] = (s[i]=='0'?'1':'0');
      ans++;
    }   
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
/// 標準入力マクロ
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    println!("{}", if a * b % 2 == 0 { "Even" } else { "Odd" });
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,l;
	cin>>n>>m>>l;
	vl k(n),s(m);
	rep(i,n)cin>>k[i],k[i]--;
	rep(i,m)cin>>s[i];
	
	sort(rall(k));
	vl cum(m+1);
	vvl dp(n,vl(n,LINF));
	ll sum=0,it=m-1,left,right;
	
	rep(i,m)sum+=s[i],cum[i+1]=sum;
	dp[0][0]=0;
	dp[1][0]=dp[0][1]=((cum[k[0]+1]-cum[k[1]])/l)*2;
	range(i,1,n-1){
		rep(j,max(1,i)){
			chmin(dp[i+1][j],dp[i][j]-(cum[k[j]+1]-cum[k[i]])/l+(cum[k[i]+1]-cum[k[i+1]])/l+(cum[k[j]+1]-cum[k[i+1]])/l);
			chmin(dp[i][i+1],dp[i][j]-(cum[k[j]+1]-cum[k[i]])/l+(cum[k[i]+1]-cum[k[i+1]])/l+(cum[k[j]+1]-cum[k[i+1]])/l);
			chmin(dp[i+1][i],dp[j][i]-(cum[k[j]+1]-cum[k[i]])/l+(cum[k[i]+1]-cum[k[i+1]])/l+(cum[k[j]+1]-cum[k[i+1]])/l);
			chmin(dp[j][i+1],dp[j][i]-(cum[k[j]+1]-cum[k[i]])/l+(cum[k[i]+1]-cum[k[i+1]])/l+(cum[k[j]+1]-cum[k[i+1]])/l);
		}
	}
	ll ans=LINF;
	rep(i,n-1)chmin(ans,dp[n-1][i]),chmin(ans,dp[i][n-1]);
	cout<<ans<<endl;
}



Measured memory_bytes: 35876
#include <iostream>

using namespace std;

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

    if(a == 'H'){
        if(b == 'H')cout << a << endl;
        else cout << b << endl;
    }else{
        if(b == 'H')cout << a << endl;
        else cout << 'H' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k, q = map(int, input().split())
    scores = [0] * n
    for _ in range(q):
        a = int(input())
        scores[a - 1] += 1
    for i in range(n):
        scores[i] = k - q + scores[i]

    for si in scores:
        if si <= 0:
            print('No')
        else:
            print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 47708
#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 long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int sum=0,k=-1;
    rep(i,n+1){
        sum+=i;
        if(sum==n){
            cout<<"Yes"<<endl;
            k=i+1;
        }
    }
    if(k==-1){
        cout<<"No"<<endl;
    }else{
        cout<<k<<endl;
        vector<int> s[k];
        int dia=0,str=1;
        for(int i=1;i<=n;i++){
            s[dia].push_back(i);
            s[str].push_back(i);
            dia++;
            if(dia==str){
                dia=0;
                str++;
            }
        }
        rep(i,k){
            cout<<s[i].size();
            for(auto j:s[i]){
                cout<<" "<<j;
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    string s,t;
    cin>>s;
    cin>>t;
    int count=0;

    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

void dfs(ll i, vector<ll> v[], ll dp[], bool vis[]){
	
	// mark 'has been visited'
	vis[i] = true;

	for(ll  j= 0; j < v[i].size(); j++){
		if(!vis[v[i][j]])
			dfs(v[i][j], v, dp, vis);


		//update value of dp
		dp[i] = max(dp[i] , 1 + dp[v[i][j]]);
	}

}

int longPath(vector<ll> v[], ll n){
	ll result = 0, dp[n+1] = {0};
	bool vis[n+1] = {false};
 	for(ll i = 1;i <= n;i++) {
 		if(!vis[i])
 			dfs(i, v, dp, vis);
	}

	for(ll i = 1; i <= n; i++) {
		result = max(result, dp[i]);
	}

	return result;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll m,n, x, y;
	cin>>n>>m;
	vector<ll> v[n+1];

	for(ll i=1;i<=m;i++){
		cin>>x>>y;
		v[x].push_back(y);
	}

	cout<<longPath(v,n)<<'\n';
	return 0;
}

Measured memory_bytes: 9984
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	while(-1){
		int n,x,i,j,ans=0;cin>>n>>x;
		if(n+x==0){RE;}
		for(i=1;i<n;i++){
			for(j=i+1;j<n;j++){
				if(j<x-i-j&&x-i-j<=n){ans++;}
			}
		}
		cout<<ans<<endl;
	}
	RE;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    set<int> ST;
    for (int i = 0; i < 3; i++){
        int x;
        cin >> x;
        ST.insert(x);
    }
    if (ST.size() == 2){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		Scanner sn=new Scanner(System.in);
		int s=sn.nextInt();
		int[] card=new int[101];
		int alice=0;
        int bob=0;
		for(int i=0;i<s;i++) {
			card[i]=sn.nextInt();
		}
		int max=0,save=0;
		for(int i=0;i<s;i++) {
			for(int j=0;j<s;j++) {
				if(card[i]>card[j]) {
					save=card[j];
					card[j]=card[i];
					card[i]=save;
				}
			}
		}
		for(int i=0;i<s;i++) {
			if(i%2==0){
              alice+=card[i];
            }else{
              bob+=card[i];
            }
		}
		System.out.println(alice-bob);
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define forr(i,k,n) for(int i=k; i<n; i++)
#define iforr(i,k,n) for(int i=n-1; i>=k; i--)
#define rep(i,n) forr(i,0,n)
#define irep(i,n) iforr(i,0,n)
#define aut(i,arr) for(auto& i:arr)
#define all(arr) arr.begin(), arr.end()
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>
#define f first
#define db double
#define s second
#define ll long long 
#define ull unsigned long long
#define E '\n'
#define lmax 9223372036854775807;
#define MOD 1000000007
using namespace std;
vi v;
vvi ed;
void dfs(int i)
{
	v[i]=1;
	aut(j,ed[i])
		if(!v[j])
			dfs(j);
}
void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("code.in","r",stdin);
    freopen("code.out","w",stdout);
    #endif
}

int main()
{
	//Fast_IO();
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		string s;
		string t;
		cin>>s>>t;
		int n=s.size();
		int m=t.size();
		vvi dp(n+1,vi(m+1,0));
		forr(i,1,n+1)
			forr(j,1,m+1)
				if(s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
					dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		string ans="";
		int i=n;
		int j=m;
		while(i>0&&j>0){
			if(s[i-1]==t[j-1]){
				ans+=s[i-1];
				i--;
				j--;
			}
			else if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
		reverse(all(ans));
		cout<<ans;
		cout<<E;
	}
	return 0;
}

Measured memory_bytes: 35584
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    X, Y = map(int, input().split())

    for i in range(0, X + 1):
        j = X - i
        if i * 2 + j * 4 == Y:
            print("Yes")
            return
    print("No")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9964
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
mod=10**9+7
dp=[[0]*(m+1) for i in range(n+1)]
total=[[0]*(m+1) for i in range(n+1)]
for i in range(n):
	for j in range(m):
		if s[i]==t[j]:
			dp[i+1][j+1]=(total[i][j]+1)%mod
		total[i+1][j+1]=(total[i+1][j]+total[i][j+1]-total[i][j]+dp[i+1][j+1])%mod
print((total[-1][-1]+1)%mod)

Measured memory_bytes: 131336
#include <iostream>
#include <string>
#include <map>
#include <math.h>

using std::cout;
using std::cin;
using std::endl;

int main()
{
    int n;
    cin >> n;
    
    if (floor(ceil(n/1.08) * 1.08) == n)
        cout << ceil(n/1.08);
    else
        cout << ":(";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll a,b,n;cin >> a >> b >> n;
  // if(b == 1) {
  //   cout << 0 << "\n";
  //   return 0;
  // }
  if(b <= n) {
    ll x = b - 1;
    ll res = (a*x)/b - a*(x/b);
    cout << res << "\n";
  }
  else {
    ll x = n;
    ll res = (a*x)/b - a*(x/b);
    cout << res << "\n";
  }
  
  return 0;
}


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

int main(){
    int N,X,m;
    int min = 100000;
    int cnt = 0;
    cin >> N >> X;
    for(int i = 0;i < N; i++){
        cin >> m;
        if(X >= m){
            X -= m;
            cnt++;
        }else{
            break;
        }
        if(min > m) min =m;
    }
    while(X >= min){
        X -= min;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256