akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b){
    swap(a,b);
  }
  if(b>c){
    swap(b,c);
  }
  if(a>b){
    swap(a,b);
  }
  cout<<(c-b)+(b-a);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	while(cin>>s,s!="0"){
		int co=0,n=s.size();
		vi dp(n+1);
		rep(i,n){
			if(i%2)	dp[i+1]=dp[i]-s[i]+'0';
			else	dp[i+1]=dp[i]+s[i]-'0';
			dp[i+1]=(dp[i+1]+22)%11;
		}
		map<int,int>ma;
		for(int i=n;i>=0;i--){
			if(i<n&&s[i]!='0')co+=ma[dp[i]];
			ma[dp[i]]++;
		}
		cout<<co<<endl;
	}
}

Measured memory_bytes: 3480
#[allow(unused_macros)]
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" ) } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }

fn main() {
    input! {
        n: String,
    }
    if n == n.chars().rev().collect::<String>() {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    int now = 1;
    rep(i, n) {
        now = min(now*2, now+k);
    }
    cout << now << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    int ketasum=0;
    int tmp=n;
    while(tmp>0){
        ketasum += tmp%10;
        tmp/=10;
    }
    bool is=false;
    if(n % ketasum == 0) is = true;
    if(is) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def main():
    tables = []
    tables.append([int(x) for x in input().strip().split()])
    tables.append([int(x) for x in input().strip().split()])
    tables.append([int(x) for x in input().strip().split()])
    a = [min(tables[0]), min(tables[1]), min(tables[2])]
    b = [tables[0][0]-a[0], tables[0][1]-a[0], tables[0][2]-a[0]]

    for i in range(3):
        for j in range(3):
            if tables[i][j] != a[i] + b[j]:
                return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.next();
			if(s.compareTo("0")==0)break;
			int a = 0;
			int b = 0;
			String t = "";
			for(int i=1;i<s.length();i++){
				t = s.substring(i,i+1);
				if(t.compareTo("A")==0)a++;
				if(t.compareTo("B")==0)b++;
			}
			if(a>b)a++;
			if(b>a)b++;
			System.out.println(a + " " + b);
		}
		
	}	
}

Measured memory_bytes: 17124
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int k, x;
	cin >> k >> x;
	int xs = x - (k - 1);
	int xf = x + (k - 1);
	REP(i, xs, xf + 1) {
		cout << i << (i == xf ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int,input().split()))
d=collections.Counter(a)
s=0
#print(d)
for i in d:
    s=s+d[i]*(d[i]-1)//2
#print(s)
for i in range(n):
    print(s-(d[a[i]]*(d[a[i]]-1))//2+(max(d[a[i]]-1,0))*(max(d[a[i]]-2,0))//2)
    

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

int n;
int q;
int a[50];
int m[200];

int solve(int i,int m){
    if(m == 0)
        return 1;
    
    if(i >= n)
        return 0;

    int res = solve(i+1,m) || solve(i+1, m-a[i]);
    return res;
}

int main(void)
{
    //input
    cin >> n;
    for(int i=0; i<n; i++) scanf("%d", &a[i]);
    cin >> q;
    for(int i=0; i<q; i++) scanf("%d", &m[i]);

    //calculate & output
    for(int i=0; i<q; i++){
        if(solve(0,m[i]) == 1)
            printf("yes\n");
        else
            printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 55, M = 210;
int n, m, s, c[N], d[N], f[N][N * N];
int cnt, h[N], to[M], nxt[M], a[M], b[M];
inline void add (int u, int v, int x, int y) {
	to[++cnt] = v, a[cnt] = x, b[cnt] = y, nxt[cnt] = h[u], h[u] = cnt;
}
struct node {
	int res, u, s;
	inline bool operator < (const node &x) const { return res > x.res; }
} ; priority_queue<node> q;
inline void Dij() {
	q.push (node {0, 1, s});
	while (!q.empty()) {
		node t = q.top(); q.pop();
		if (f[t.u][t.s] < t.res) continue;
		for (int i = h[t.u]; i; i = nxt[i])
			if (t.s >= a[i] && f[to[i]][t.s - a[i]] > t.res + b[i])
				f[to[i]][t.s - a[i]] = t.res + b[i], q.push (node {t.res + b[i], to[i], t.s - a[i]});
		int qwq = min (2500ll, t.s + c[t.u]);
		if (f[t.u][qwq] > t.res + d[t.u])
			f[t.u][qwq] = t.res + d[t.u], q.push (node {t.res + d[t.u], t.u, qwq});
	}
}
signed main() {
	read (n), read (m), read (s); s = min (s, 2500ll);
	memset (f, 0x3f, sizeof (f)); f[1][s] = 0;
	for (int i = 1, u, v, x, y; i <= m; ++i) {
		read (u), read (v), read (x), read (y);
		add (u, v, x, y), add (v, u, x, y);
	} for (int i = 1; i <= n; ++i) read (c[i]), read (d[i]); Dij (); 
	for (int i = 2; i <= n; ++i) {
		int res = f[0][0];
		for (int j = 0; j <= 2500; ++j) res = min (res, f[i][j]);
		printf ("%lld\n", res);
	} return 0;
}

Measured memory_bytes: 7644
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  printf("%.9f\n", (double)((n+1)/2) / n);
  return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
a = list(map(int,input().split()))
cnt = [0]*(50)
for i in a:
    for j in range(42):
        if((i)&(1<<j) == 0):
            cnt[j] += (1<<j)
        else:
            cnt[j] -= (1<<j)
# for i in range(50):
#     print(i,cnt[i])
gg = []
for i in range(50):
    gg.append([cnt[i],i])
gg.sort(reverse = True)
ans = 0
for i in gg:
    if i[0] < 0:
        break
    if (1<<i[1]) <= k:
        k -= (1<<i[1])
        ans += i[0]
print(ans+sum(a))


Measured memory_bytes: 14620
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> a1;
    vector<int> a2;

    a1.pback(0);
    a2.pback(0);

    rep(i,n){
        int tmp;
        cin >> tmp;
        a1.pback(a1[i] + tmp);
    }

    rep(i,n){
        int tmp;
        cin >> tmp;
        a2.pback(a2[i] + tmp);
    }

    int ans = 0;

    rep(i,n){
        ans = max(ans,a1[i + 1] - a1[0] + a2[n] - a2[i]);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    vector<string> S;


    cin >> n;

    for( int i = 0; i < n; ++i ){
        string str;
        cin >> str;
        S.push_back(str);
    }


    int moji[26] = { 0 };
    for( int i = 0; i < n; ++i ){
        int tmp[26] = { 0 };
        int len = S[i].length();

        for( int j = 0; j < len; ++j ){ //各アルファベットの個数を調べる
            ++tmp[S[i].c_str()[j]-'a'];
        }

        for( int j = 0; j < 26; ++j ){ //使えるアルファベットを調べる
            if( i == 0 ) moji[j] = tmp[j];
            if( tmp[j] < moji[j] ) moji[j] = tmp[j];
        }
    }


    for( int i = 0; i < 26; ++i ){
        for( int j = 0; j < moji[i]; ++j ){
            cout << (char)('a'+i);
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
vector<int> B;
const int INF = 1e5 + 7;

int main() {
  cin >> n;
  B.assign(n, INF);

  long ans = 0;
  rep(i, n - 1) { cin >> B[i + 1]; }

  reverse(B.begin(), B.end());
  ans += B[0];

  for (int i = 1; i < n; i++) {
    ans += min(B[i - 1], B[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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 (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

// https://algo-logic.info/prime-fact/
template <typename T>
struct PrimeFact {
    vector<T> spf;

    PrimeFact(T N) { init(N); }

    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }

    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main() {
    ll MAX = 10000000;
    auto spf = PrimeFact(MAX);
    ll N;
    cin >> N;
    ll ans = 1;
    for (ll i = 2; i <= N; i++) {
        map<ll, ll> temp = spf.get(i);
        ll cnt = 1;
        for (auto now: temp) cnt *= now.second + 1;
        ans += i * cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81208
#define		_CRT_SECURE_NO_WARNINGS
#include <cstdio>

int main()
{
	int		n, x;

	for (;;)
	{
		scanf("%d %d", &n, &x);

		if ((n == 0) && (x == 0))
		{
			break;
		}

		if (x >= 3 * n)
		{
			printf("0\n");
		}
		else
		{
			int		div3 = x / 3;
			int		Cnt = 0;
			for (int i = 1; i < div3; i++)
			{
				int j = i + 1;
				for (; j < x / 2; j++)
				{
					int		sum12 = i + j;
					int		del = x - sum12;

					if (j >= del)
						break;

					if ((j <= n) && (del <= n))
						Cnt++;
				}
			}
			printf("%d\n", Cnt);
		}
	}

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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 (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int m, d;
    cin >> m >> d;

    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            if(j < 10) continue;
            if(j%10 < 2 or j/10 < 2) continue;
            if(j%10 * (j/10) == i) ++cnt;
        }
    }
    ppp(cnt);


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int k,a,b,i;
    cin>>k;
    cin>>a>>b;int p=0;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            p=1;
            break;
        }
    }
    if(p==1)
    cout<<"OK"<<endl;
    else
    {
        cout<<"NG"<<endl;
    }
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main (){
    vector<int> v(9);
    int count=0;

    for(int i=0;i<9;i++){
        cin >> v.at(i);
    }
    
    if(v.at(3)-v.at(0) == v.at(4)-v.at(1) && v.at(5)-v.at(2) == v.at(4)-v.at(1)){
            count++;
        }
    if(v.at(6)-v.at(3) == v.at(7)-v.at(4) && v.at(6)-v.at(3) == v.at(8)-v.at(5)){
            count++;
        }
    
    if(count == 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val weather = new BufferedReader(new InputStreamReader(System.in)).readLine()
    System.out.println(
      weather match {
        case "Sunny" => "Cloudy"
        case "Cloudy" => "Rainy"
        case "Rainy" => "Sunny"
        case _ => ""
      }
    )
  }
}


Measured memory_bytes: 25404
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    ll ans = INF;
    for(int i = 1; i <= 100; i++){
        ll tmpans = 0;
        for(int j = 0; j < n; j++){
            tmpans += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, tmpans);
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }

    multiset<int> st;
    int c = 1;
    st.insert(v[n - 1]);
    for(int i = n - 2; i >= 0; --i) {
        auto p = st.upper_bound(v[i]);
        if(p == st.end()) {
            st.insert(v[i]);
            ++c;

        } else {
            st.erase(p);
            st.insert(v[i]);

        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 5376
N = int(input())
counter = 0
flag = False

for i in range(N):
    l = input().split(" ")
    if l[0] == l[1]:
        counter += 1
    else:
        counter = 0
    if counter == 3:
        flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h)rep(j,w)cin >> s[i][j];
    vector<vector<int>> y(h,vector<int>(w));
    vector<vector<int>> t(h,vector<int>(w));
    rep(i,h){
        int c = 0;
        rep(j,w){
            if(s[i][j]=='.')c++;
            if(s[i][j]=='#')c=0;
            y[i][j]=c;
        }
        for(int j=w-2;j>=0;j--){
            if(s[i][j]=='.'&&s[i][j+1]=='.')y[i][j]=y[i][j+1];
        }
    }
    rep(j,w){
        int c = 0;
        rep(i,h){
            if(s[i][j]=='.')c++;
            if(s[i][j]=='#')c=0;
            t[i][j]=c;
        }
        for(int i=h-2;i>=0;i--){
            if(s[i][j]=='.'&&s[i+1][j]=='.')t[i][j]=t[i+1][j];
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')chmax(ans,t[i][j]+y[i][j]-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 35584
K = int(input())
lun = []

def make(n):
    if len(n) > 10:
        return 0
    if int(n) > 3234566667:
        return 0
    else:
        if n[0] == "0":
            p = ["0","1"]
        elif n[0] == "9":
            p = ["8","9"]
        else:
            p = [str(int(n[0])-1),n[0],str(int(n[0])+1)]

        lun.append(int(n))
        for i in p:
            lun.append(int(i+n))
            make(i+n)
        return 0
for i in range(10):
    make(str(i))

ans = list(set(lun))
ans.sort()
#print(ans)
print(ans[K])

Measured memory_bytes: 106200
"""
10**5以下の各数に対して、その数字以下の2017に似た数の個数をカウントしておく。
"""
prime = [1]*(10**5+1)
prime[0] = 0
prime[1] = 1
count = [0,0]
for i in range(2,10**5+1):
    count.append(count[-1])
    if prime[i]:
        for j in range(i*i,10**5+1,i):
            prime[j] = 0
        if i>2 and prime[(i+1)//2]==1:
            count[-1] += 1

Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    print(count[r]-count[l-1])

Measured memory_bytes: 52260
#include <stdio.h>
typedef long long ll;
ll dp[3005][3005],pre[3005];
ll a[3005];
ll max(ll x, ll y)
{
    if(x>=y)return x;
    return y;
}
int main(void) {
	// your code goes here
	int n,k,i;
	scanf("%d",&n);
	for(i=1; i<=n; i++)
	{
	    scanf("%lld",&a[i]);
	    pre[i] = pre[i-1] +a[i];
	}
	int len,j;
	for(i=1;i<=n;i++)dp[i][i] = a[i];
	for(i=1; i<n; i++)dp[i][i+1] =  max(a[i],a[i+1]);
	for(len= 3; len<=n; len++)
	{
	    for(i=1; i<=n;i++)
	    {
	        j = i  +  len  - 1;
	        if(j>n)break;
	        ll fir = pre[j] - pre[i] - dp[i+1][j]+ a[i];
	        ll sec = pre[j-1] -  pre[i-1] - dp[i][j-1] +  a[j];
	        dp[i][j] = max(fir,sec);
	    }
	}
	printf("%lld\n",2*dp[1][n] - pre[n]);
	return 0;
}



Measured memory_bytes: 69888
#include <bits/stdc++.h>
using namespace std;
typedef float fl;
struct Point { double x,y;};

void koch(int n, Point a, Point b){
    if (n == 0) return;
    Point s,t,u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1,a,s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1,t,b);
}


int main(){
    Point a,b;
    int n;

    scanf("%d",&n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}



Measured memory_bytes: 3208
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    H = [int(x) for x in input().split()]

    cnt = 0
    prev = H[0]
    ans = 0
    for i in range(1, N):
        if prev >= H[i]:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
        prev = H[i]

    ans = max(ans, cnt)
    print(ans)


    

if __name__ == '__main__':
    main()



Measured memory_bytes: 20260
require 'pp'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i).sort!{|x, y| y <=> x }

found = []

min = 10 ** 10
min_index = 0
1.upto(n-1) do |i|
    x = ((a_n[0] / 2.to_f) - a_n[i]).abs
    if min > x
        min = x
        min_index = i
    end
end

#pp min
#pp min_index
puts "#{a_n[0]} #{a_n[min_index]}"


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	int ans = min(n%k , k - n%k);
	cout << ans;
}


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

int n, a[100000], b[100000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0;i < n; i++) 
        cin>>a[i];
    int x, y;
    for(int i = 0;i < n; i++) {
        b[i+1] = 0x3f3f3f3f;
        if(i>=1 && a[i-1]>a[i]) x = i;
        else b[i+1] = b[x]+1;
        if(i>=1 && a[i-1]<a[i]) y = i;
        else b[i+1] = min(b[i+1],b[y]+1); 
    }
    cout<<b[n]<<endl;  
return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int n,A[2000];

int rec(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int r =rec(i+1,m) || rec(i+1,m-A[i]);
  return r;
}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(rec(0,m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>

int main(){
        int i = 0;
        int tmp;
        int n,len[3];
        scanf("%d",&n);
        while(i != n){
                scanf("%d %d %d",&len[0],&len[1],&len[2]);
                if(len[0] > len[1]){
                        tmp = len[0];
                        len[0] = len[1];
                        len[1] = tmp;
                }
                
                if(len[1] > len[2]){
                        tmp = len[1];
                        len[1] = len[2];
                        len[2] = tmp;
                }
                if(len[0] * len[0] + len[1] * len[1] == len[2] * len[2]){
                        printf("YES\n");
                }else{
                        printf("NO\n");
                }
                i++;
        }
        return 0;
}

Measured memory_bytes: 1008
from collections import defaultdict, Counter

N = int(input())

memo = []
for n in range(2, N + 1):
    k = 2
    while k * k <= n:
        count = 0
        while n % k == 0:
            n //= k
            memo.append(k)
        k += 1
    if n > 1:
        memo.append(n)

MOD = 10 ** 9 + 7
result = 1
for n in Counter(memo).values():
    result = (result * (n + 1)) % MOD
print(result)

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

int main() {
  int N;
  cin >> N;
  int hp[N];
  for (int i = 0; i < N; i++) {
    cin >> hp[i];
  }
  int ans;
  ans = __gcd(hp[0], hp[1]);
  for (int i = 2; i < N; i++) {
    ans = __gcd(ans, hp[i]);
  }
  cout << ans;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;

    int ii = -1;
    rep(i, S.size()) {
        bool ok = true;
        for (int j = i, k = 0; k < T.size(); j++, k++) {
            if (j >= S.size()) {
                ok = false;
                break;
            }
            if (S[j] != '?' && S[j] != T[k]) ok = false;
        }

        if (ok) ii = i;
    }

    if (ii != -1) {
        rep(j, S.size()) {
            if (S[j] == '?') S[j] = 'a';
            if (ii <= j && j < ii + T.size()) S[j] = T[j - ii];
        }
        cout << S << endl;
        return 0;
    }

    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

dsum :: Int -> Int
dsum n
    | q == 0    = r
    | otherwise = r + dsum q
  where
    (q, r) = n `divMod` 10

main :: IO ()
main = do
    n <- readLn :: IO Int
    let as = do
            a <- [1 .. n `div` 2]
            let b = n - a
            return $ dsum a + dsum b
    print $ minimum as

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;cin>>n;
  	string s,t;cin>>s>>t;
  	for(int i=0;i<n;i++){
    	if(s.substr(i,n-i)==t.substr(0,n-i)){
          cout<<n+i<<endl;
          return 0;
        }
    }
  cout<<2*n<<endl;
}

Measured memory_bytes: 256
def d_summer_vacation(N, M, Works):
    from collections import defaultdict
    from heapq import heappush, heappop  # 最小値を取り出すので、リストを-1倍する
    work_dict = defaultdict(list)
    for a, b in Works:
        work_dict[a].append(-b)

    candidate, ans = [], []
    for day in range(1, M + 1):
        for x in work_dict[day]:
            heappush(candidate, x)
        if len(candidate) != 0:
            ans.append(-heappop(candidate))
    return sum(ans)

N, M = [int(i) for i in input().split()]
Works = [[int(i) for i in input().split()] for j in range(N)]
print(d_summer_vacation(N, M, Works))

Measured memory_bytes: 45668
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=2e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int n,i,a[maxn]={0};
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			puts("NO");return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
typedef long long ll;
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll cum[n];
    ll sum=0;
    ll mod=1000000007;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        cum[i]=sum;
    }

    ll temp=cum[n-1];
    ll ans=0;
    ll x;
    for(int i=0;i<n;i++)
    {

        x=((a[i]%mod)*((temp-cum[i])%mod))%mod;
        ans=((ans%mod)+(x%mod))%mod;
    }

    cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 6756
// ABC 157-D
// 2020.3.1 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

#define MAX 100005

/* UNION-FIND library */
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q) {
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

int N; // グラフの頂点数
int hi[MAX], *to[MAX];
int x[MAX];

void getGraph1(int M) {
	int i, k, a, b, c;
	int *memo, sz;

	init(N+1);
	memo = malloc(M*2*sizeof(int));
	sz = 0; for (i = 0; i < M; ++i) {
		a = in(), b = in();
		unite(a, b);
		hi[a]++, hi[b]++;
		memo[sz++] = a, memo[sz++] = b;
	}
	for (i = 1; i <= N; ++i) if (hi[i]) {
		to[i] = malloc(hi[i]*sizeof(int));
	}
	memset(hi, 0, sizeof(hi));

	i = 0; while (i < sz) {
		a = memo[i++], b = memo[i++];
		k = hi[a]++, to[a][k] = b;
		k = hi[b]++, to[b][k] = a;
	}
	free(memo);
}

int main()
{
	int i, M, K;

	N = in(), M = in(), K = in();
	getGraph1(M);
	while (K--) {
		int c = in(), d = in();
		if (connected(c, d)) x[c]++, x[d]++;
	}
	out(size[root(1)]-1 - hi[1]-x[1]);
	for (i = 2; i <= N; ++i) {
		pc(' '), out(size[root(i)]-1 - hi[i]-x[i]);
	}
	pc('\n');
	return 0;
}


Measured memory_bytes: 6640
def group(x):
    if x == 2:
        return 2
    if x in [4, 6, 9, 11]:
        return 1
    return 0


def main():
    x, y = map(int, input().split())
    if group(x) == group(y):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

# define ll long long
ll mod=pow(10,9)+7;

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

    int l,r,d;
    cin>>l>>r>>d;
    int temp1=l/d;
    temp1*=d;
    if(temp1<l)
        temp1+=d;
    temp1/=d;
    int temp2=r/d;
    cout<<temp2-temp1+1<<endl;
}


Measured memory_bytes: 3636
def main():
    nk = [int(_x) for _x in input().split()]
    N = nk[0]
    K = nk[1]
    AA = [int(_x) for _x in input().split()]
    A = [0] + AA
    hyoten = 1
    for i in range(N+1):
        if i <= K:
            continue
        if A[i] > A[i-K]:
            print("Yes")
        else:
            print("No")
main()



Measured memory_bytes: 31540
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int n,i;
  bool flag = true;
  int ans = 0;
  cin >> n;
  vector<int> a(n);

  for(i=0; i<n; i++) cin >> a[i];
  for(i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0) flag = false;
    }
  }
  if(flag == true) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


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

int main(){
	int n, k;
	cin >> n >> k;
	int a;
	cin >> a;
	int maxb = a;
	for(int i = 1; i < n; i++){
		int b;
		cin >> b;
		a = __gcd(a,b);
		maxb = max(maxb,b);
	}
	if(k % a == 0 && k <= maxb){
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}


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

using namespace std;

typedef long long ll;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
    int x = 0, f = 1;
    char c = nc();
    while (c < 48) {
        if (c == '-')
            f = -1;
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x * f;
}

inline ll s3(ll x) {
    return x * x * x;
}

int main() {
    ll n = rd(), k = rd();
    ll ans = s3(n / k);
    if (k % 2 == 0) {
        ll d = n / k;
        if (n % k >= k / 2) {
            d ++ ;
        }
        ans += s3(d);
    }
    cout << ans << endl ;
    return 0;
}

Measured memory_bytes: 256
/*ex3_1
  moriai ryo 19B30920*/

#include <stdio.h>

int main(void){
  int pencil;
  scanf("%d",&pencil);
  int digit_1=pencil%10;/*一桁目 = mod10*/
  if(digit_1==3){
    printf("bon\n");
  }
  else if(digit_1==0 || digit_1==1 || digit_1==6 || digit_1==8){
    printf("pon\n");
  }
  else{
    printf("hon\n");
  }
  return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
#define LL long long 
int n;
LL ans, s, x[N];
LL a[N];
LL sol(int l, int r){
	//printf("l=%d r=%d al=%lld ar=%lld\n", l, r, a[l], a[r]);
	if(x[l] > s){
		ans += x[r] - s;
		return x[r];
	}
	if(x[r] < s){
		ans += s - x[l];
		return x[l];
	}
	if(a[l] >= a[r]){
		a[l] += a[r];
		ans += abs(x[r] - sol(l, r - 1));
		return x[r];
	}
	else{
		a[r] += a[l];
		ans += abs(x[l] - sol(l + 1, r));
		return x[l];
	}
}
int main(){
	cin>>n>>s;
	for(int i = 1;i <= n; i++){
		scanf("%lld%lld", &x[i], &a[i]);
	}
	sol(1, n);
	cout<<ans<<endl;
	return 0;
}


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

int N,M;
int place;

vector<vector<int>> adj_list;
vector<int> t,visited;


void dfs(int i) {
	visited[i]=true;
	for (int u:adj_list[i])
	{
		if(!visited[u])
			dfs(u);
	}
	t[place] = i;
	place--;
}

void top_sort() {
	t.resize(N+1);
	visited.assign(N+1,0);

	place = N;
	for(int i=1;i<=N;++i) {
		if(!visited[i]) 
			dfs(i);
	}
}


int main() {

	cin>>N>>M;
	adj_list.resize(N+1);
	for (int i = 0; i < M; ++i)
	{
		int x,y;
		cin>>x>>y;
		adj_list[x].push_back(y);
	}

	top_sort();

	vector<int> path(N+1);


	for (int i = N; i >= 0; --i)
	{
		int node = t[i];
		if(adj_list[node].empty()) {
			path[node] =0;
		}
		else {
			for(int u:adj_list[node]) {
				path[node] = max(path[node],path[u]+1);
			}
		}
	}

	cout<<*max_element(path.begin(),path.end());




	return 0;
}

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

bitset<10> sws;

int main(){

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

	vector<vector<int>> bsb(M);
	for(int i=0;i<M;i++){
		int qt;
		cin >> qt;
		for(int j=0;j<qt;j++){
			int sw; cin >> sw;
			bsb[i].push_back(sw-1);
		}
	}
	vector<int> p(M);
	for(int i=0;i<M;i++){
		cin >> p[i];
	}

	int comb = 0;
	for(int i=0;i<(1 << N);i++){
		sws = i;
		int on = 0;
		for(int j=0;j<M;j++){
			int sts = 0;
			for(int k=0;k<(int)bsb[j].size();k++){
				if(sws[bsb[j][k]]){
					sts++;	
				}
			}
			if((sts - p[j])%2 == 0){
				on++;
			}
		}
		if(on == M){
			comb++;
		}
	}

	cout << comb << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())

a=list(map(int,input().split()))

max=0
for i in range(n):
    for j in range(n):
        if i!=j:
            x=int(a[i]-a[j])
            if x<0:
                x *=-1
                if max<=x:
                    max=x


print(max)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


vector<int> pp;
void preparePrime( int maxp )
{
    int i;
    vector<int> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        int k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

int main(int argc, char* argv[])
{
    int x;
    scanf("%d", &x);
    preparePrime( x*2+100);
    int k=lower_bound(pp.begin(), pp.end(), x) - pp.begin();
    printf("%d\n", pp[k]);

    return 0;
}



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

int main () {
  int N, K;
  cin >> N >> K;
  
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (data[i] >= K) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
package main

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

func main() {
	var p [100000]int
	var n, k, q int
	fmt.Scan(&n, &k, &q)

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

	for i := 0; i < q; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		p[a-1]++
	}

	for i := 0; i < n; i++ {
		if k-q+p[i] > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

Measured memory_bytes: 3968
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int alp[12] ={1,3,5,7,9,11,15,17,19,21,23,25};
int main()
{
  string str;
  string temp;
  int n;
  scanf("%d\n",&n);
  for(int i = 0;i < n;i++){
    bool flag = false;
    getline(cin,str);
    temp = str;
    if(!flag){
      for(int j = 0;j <12;j++){//α
	for(int k = 0; k <=26;k++){//β
	  if(!flag&&(temp.find("this") !=string::npos||temp.find("that")!=string::npos)){
	    cout <<temp<<endl;
	    flag = true;
	    break;
	  }
	  for(int l = 0;l <str.length();l++){
	    if(str[l] >= 'a' && str[l] <= 'z'){
	      temp[l] =((((str[l]-'a')*alp[j])+k)%26)+'a';
	    }
	  }
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int counter = 1;
int howMany(ll r){
  if(r / 10 == 0){
    return counter;
  }
  counter ++;
  return howMany(r / 10);
}

int main()
{
  ll n = 0;
  cin >> n;
  ll div,r = 0;

  for(int i = 1; i <= pow(n,0.5); i++){
    if(n % i == 0){
      div = i;
    } 
  }

 r = n / div;

 //howMany(r);

  cout << howMany(r) << endl;
  return 0;
}

Measured memory_bytes: 4028
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == '9') s[i] = '1';
        else if(s[i] == '1') s[i] = '9';
    }
    cout << s << endl;
}


Measured memory_bytes: 3624
A,B,C,X,Y=map(int,input().split())

ABcheap=min(C*2,A+B)
Acheap=min(A,C*2)
Bcheap=min(B,C*2)
answer=0

while(True):
  if(X>=1 and Y>=1):
    answer+=ABcheap
    X-=1
    Y-=1
  elif(X>=1 and Y==0):
    answer+=Acheap
    X-=1
  elif(X==0 and Y>=1):
    answer+=Bcheap
    Y-=1
  else:
    print(answer)
    exit()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <limits.h>
#include <map>

using namespace std;

int main(){
  int n;cin>>n;
  map<int,bool> m[3];
  for(int i=0;i<3;i++){
    int num;cin>>num;
    for(int j=0;j<num;j++){
      int id;cin>>id;
      m[i][id] = true;
    }
  }
  int cnt=0;
  for(int i=1;i<=n;i++){
    if((!m[0][i]&&m[2][i]) || (m[1][i]&&m[2][i])){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3108
#pragma GCC optimize("O3")
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

#define int long long

vector<int> wt;
vector<int> val;
vector<vector<int>> dp;

int solve(int n, int w){
    if(w == 0 || n == 0) return 0;
    if(dp[n][w] != -1) return dp[n][w];
    if(wt[n-1] > w) return dp[n][w] =  solve(n-1, w);
    return dp[n][w] = max(solve(n-1,w-wt[n-1])+val[n-1], solve(n-1, w));
} 

inline void test_case(){
    int n;
    cin>>n;
    int w;
    cin>>w;
    wt.resize(n);
    val.resize(n);
    dp.assign(n+1, vector<int>(w+1, -1));
    for(int i=0; i<n; i++){
        cin>>wt[i]>>val[i];
    }
    cout<<solve(n, w)<<'\n';
    log(dp);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    test_case();
}   



Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, p; cin >> a >> p;

    dunk((3*a+p)/2);
}

    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unsigned long long n;
unsigned long long a[1005],sum;
unsigned long long gcd(unsigned long long x,unsigned long long y)
{
    if(y==0) return x;
    else return gcd(y,x%y);
}
int main()
{
    cin>>n;
    cin>>a[1];
	sum=a[1]; 
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];
        a[i]=a[i]/gcd(a[i],a[i-1])*a[i-1];
    }
    cout<<a[n];
    return 0;
}

Measured memory_bytes: 256