akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int MAX = 100001;
		int[] s = new int[N];
		int[] t = new int[N];
		int[] c = new int[N];
		for(int i = 0; i < N; i++) {
			s[i] = sc.nextInt();
			t[i] = sc.nextInt();
			c[i] = sc.nextInt() - 1;
		}
		sc.close();
		int[][]a = new int[C][MAX];
		for(int i = 0; i < N; i++) {
			a[c[i]][s[i] - 1]++;
			a[c[i]][t[i]]--;
		}
		for(int i = 0; i < C; i++) {
			for(int j = 1; j < MAX; j++) {
				a[i][j] += a[i][j - 1];
			}
		}
		int max = 0;
		for(int i = 0; i < MAX; i++) {
			int cnt = 0;
			for(int j = 0; j < C; j++) {
				if(a[j][i] != 0) {
					cnt++;
				}
			}
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 98520
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        mut s: Chars, mut t: Chars
    }

    t.pop();
    if t == s {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, N)
    {
        if (s[i] == 'R')
            cnt++;
    }
    if (N - cnt < cnt)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    int F[110][11] = {}, P[110][11] = {};
    rep(i, n) rep(j, 10) cin >> F[i][j];
    rep(i, n) rep(j, 11) cin >> P[i][j];

    int ans = -INF;
    REP(mask, 1, (1 << 10)) {
        int sum = 0;
        rep(i, n) {
            int cnt = 0;
            rep(j, 10) {
                if(mask & (1 << j) && F[i][j]) cnt++;
            }
            sum += P[i][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << '\n';
    return 0;
}

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

double dp[610];
int flag[610];

int main(){
	int N, M; cin >> N >> M;
	vector<int> G[N];
	for(int i=0; i<M; i++){
		int s, t; cin >> s >> t;
		s--; t--;
		G[s].push_back(t);
	}
	for(int i=N-2; i>=0; i--){
		for(int j=0; j<G[i].size(); j++){
			dp[i] += (dp[G[i][j]] + 1) / G[i].size();
		}
	}
	queue<int> que;
	flag[0] = 1;
	que.push(0);
	while(que.size()){
		int aaa = que.front(); que.pop();
		for(int i=0; i<G[aaa].size(); i++){
			if(flag[G[aaa][i]] != 1){
				flag[G[aaa][i]] = 1;
				que.push(G[aaa][i]);
			}
		}
	}
	double ANS = dp[0];
	for(int i=0; i<N; i++){
		double dp2[N];
		double ma = -1;
		int mai;
		for(int j=0; j<G[i].size(); j++){
			if(dp[G[i][j]] > ma){ ma = dp[G[i][j]]; mai = G[i][j]; }
		}
		dp2[i] = 0;
		if(G[i].size() == 1 && flag[i] == 1) continue;
		for(int j=i+1; j<N; j++) dp2[j] = dp[j];
		for(int j=0; j<G[i].size(); j++){
			if(G[i].size() == 1) dp2[i] = dp[G[i][j]] + 1;
			else{
				if(G[i][j] != mai){
					dp2[i] += (dp[G[i][j]]+1)/(G[i].size()-1);
				}
			}
		}
		for(int j=i-1; j>=0; j--){
			dp2[j] = 0;
			for(int k=0; k<G[j].size(); k++){
				dp2[j] += (dp2[G[j][k]]+1)/G[j].size();
			}
		}
		if(ANS > dp2[0]) ANS = dp2[0];
	}
	cout << setprecision(15) << ANS << endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int n;
	cin>>n;
	cout<<3*n*n;
	return 0;
}

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

#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++)
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
void solve();
int dp[SIZE]={0};
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

int  j=1, n, t, m=0, dot=0, i,  l, r, k, q, x, y, z, n1, m1;

void solve()
{
//    cin >> t;while(t--)
   {
       cin  >> n;
       vi a(n), b(n), c(n-1);
       f(i,n) cin >> a[i];
       f(i,n) cin >> b[i];
       f(i,n-1) cin>> c[i];

        dot=0;
       f(i,n)
       {
           if(i<n-1)
               if(a[i]+1==a[i+1]) dot+=c[a[i]-1];

            dot += b[a[i]-1];          
       } 

       cout << dot;
   }
}

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

// # DEFINES # //
#define ll long long
#define M (ll)(1e9+7)
#define EPS 1e-9

using namespace std;

ll s(ll n) {
    ll count = 0;
    while(n) {
        count += n % 10;
        n /= 10;
    }
    return count;
}

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


    ll ab, bc, ca;

    cin >> ab >> bc >> ca;

    cout << (bc*ab)/2 << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int ans[3]={a,b,c};
sort(ans,ans+3);
cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
return 0;
}



Measured memory_bytes: 3104
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val m = nextInt()
    println(48 - m)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31844
#include <iostream>
using namespace std;
int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if( x - r < 0 || x + r > w || y - r < 0 || y +r > h ){
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3108
// ABC127_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    vector<pll> vec(M);
    ll left = -1, right = INF;
    REP(i, M) {
        cin >> vec[i].F >> vec[i].S;
        left = max(left, vec[i].F);
        right = min(right, vec[i].S);
        if (left > right) {
            cout << 0 << "\n";
            return 0;
        }
    }
    
    // calculation
    ll res = 0;
    for (ll i = 1; i <= N ; ++i) {
        if (left <= i && i <= right) {
            res++;
        }
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
using System;

public class A {
    public static void Main(){
        string[] line = Console.ReadLine().Split(' ');
        int N = int.Parse(line[0]);
        int R = int.Parse(line[1]);
        if (N>=10)
        {
            Console.WriteLine(R);
        }
        else
        {
            Console.WriteLine(R+100*(10-N));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int mod = 1e9 + 7;

inline void inc(int &x, int y) { x += y; if( x >= mod ) x -= mod; }

struct Matrix
{
	int a[4][4];
	Matrix() { fill( a, 0 ); }
	inline void init() { for( int i = 0 ; i < 4 ; i++ ) a[ i ][ i ] = 1; }
	Matrix operator * ( const Matrix &b ) const
	{
		Matrix c;
		for( int k = 0 ; k < 4 ; k++ )
			for( int i = 0 ; i < 4 ; i++ )
				for( int j = 0 ; j < 4 ; j++ )
					inc( c.a[ i ][ j ], 1LL * a[ i ][ k ] * b.a[ k ][ j ] % mod );
		return c;
	}
}ans, p, q;

Matrix qpow(Matrix x, int y)
{
	Matrix ret; ret.init();
	for( ; y ; y >>= 1, x = x * x ) if( y & 1 ) ret = ret * x;
	return ret;
}

int lst, n, m;

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d", &n, &m );
	ans.init();
	p.a[ 0 ][ 0 ] = 2; p.a[ 0 ][ 1 ] = 1; p.a[ 0 ][ 2 ] = 1; p.a[ 0 ][ 3 ] = 1;
	p.a[ 1 ][ 0 ] = 1; p.a[ 1 ][ 1 ] = 1; p.a[ 1 ][ 2 ] = 0; p.a[ 1 ][ 3 ] = 1;
	p.a[ 2 ][ 0 ] = 1; p.a[ 2 ][ 1 ] = 0; p.a[ 2 ][ 2 ] = 1; p.a[ 2 ][ 3 ] = 1;
	p.a[ 3 ][ 0 ] = 1; p.a[ 3 ][ 1 ] = 0; p.a[ 3 ][ 2 ] = 0; p.a[ 3 ][ 3 ] = 1;
	q.a[ 0 ][ 0 ] = 1; q.a[ 0 ][ 1 ] = 1; q.a[ 0 ][ 2 ] = 1; q.a[ 0 ][ 3 ] = 1;
	q.a[ 1 ][ 0 ] = 0; q.a[ 1 ][ 1 ] = 1; q.a[ 1 ][ 2 ] = 0; q.a[ 1 ][ 3 ] = 1;
	q.a[ 2 ][ 0 ] = 0; q.a[ 2 ][ 1 ] = 0; q.a[ 2 ][ 2 ] = 1; q.a[ 2 ][ 3 ] = 1;
	q.a[ 3 ][ 0 ] = 0; q.a[ 3 ][ 1 ] = 0; q.a[ 3 ][ 2 ] = 0; q.a[ 3 ][ 3 ] = 1;
	while( m-- )
	{
		int x;
		scanf( "%d", &x );
		ans = ans * qpow( p, ( x - lst - 1 ) ) * q;
		lst = x;
	}
	ans = ans * qpow( p, n - lst );
	printf( "%d\n", ans.a[ 0 ][ 3 ] );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<max(a,max(b,c))-min(a,min(b,c));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int num2 = scan.nextInt();
		scan.close();
		
		int result = (num1-1)*(num2-1);
		System.out.println(result);
		
	}

}


Measured memory_bytes: 22868
import numpy as np

N = int(input())
lis = np.zeros(10**5)

As = np.array(input().split()).astype(np.int64)
NUM = As.sum()

for n in As:
  lis[n-1] += 1

Q = int(input())
for q in range(Q):
  B, C = map(int, input().split())
  nnn = lis[B-1]
  lis[B-1] = 0
  lis[C-1] += nnn
  NUM = NUM - B*nnn + C*nnn
  print(int(NUM))

Measured memory_bytes: 40052
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

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

  for (int i=n; i>n/2; i--){
    b[i]=a[i];
    if (b[i]){m++;}
  }

  for (int i=n/2; i>0; i--){
    int sum=0;
    for (int j=2; i*j<=n; j++){
      sum+=b[i*j];
    }
    if (sum%2==a[i]){b[i]=0;} else{b[i]=1;m++;}
  }

  cout << m << endl;
  rep(i,n){if(b[i+1]){cout << i+1 << " ";}}


  return 0;
}


Measured memory_bytes: 2432
N = int(input())
As = list(map(int, input().split()))
# 絶対値の差は、
# 奇数の場合はN+1から2ずつ減らして行った分しかない。(N+1)/2
# 偶数の場合はNから2ずつ減らして行った分しかない。N/2
nums = {}
exists = True
if N % 2 == 0:
    for A in As:
        if A in nums:
            nums[A] += 1
        else:
            nums[A] = 1
    for key, value in nums.items():
        if key == 0:
            exists = False
        if value != 2:
            exists = False

else:
    for A in As:
        if A in nums:
            nums[A] += 1
        else:
            nums[A] = 1
    for key, value in nums.items():
        if key == 0:
            if value != 1:
                exists = False
        else:
            if value != 2:
                exists = False
if not exists:
    print(0)
else:
    ans = 1
    if N % 2 == 0:
        for i in range(int(N / 2)):
            ans = ans * 2
            ans %= 10**9 + 7
    else:
        for i in range(int((N - 1) / 2)):
            ans = ans * 2
            ans %= 10**9 + 7
            # 絶対値の差は0の時は1人だけ。そのほかは2人だけ。これが満たせるなら
            # (偶数)2**(N+1/2)
            # (奇数)2**(N/2)
    print(ans)


Measured memory_bytes: 20604
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  int c = stoi(to_string(a)+to_string(b));
  for(int i = 1; i*i <= c; i++){
    if(i*i == c){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

S = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def dfs(s, i):
    if len(s) == N:
        return [s]
    result = []
    for j in range(i+1):
        if j == i:
            result += dfs(s+S[j], i+1)
        else:
            result += dfs(s+S[j], i)
    return result
print("\n".join(dfs("", 0)))


Measured memory_bytes: 12636
#include <iostream>
#include <vector>

using namespace std;

const int INF = 2147483647;

struct SegmentTree {
    int n;
    vector<int> heap;
    
    SegmentTree(int n): n(n) {
        heap.assign(4 * n, INF);
    }
    
    void update(int nodeId, int l, int r, int ql, int qr, int v) {
        if (qr < l || ql > r) {
            return;
        }
        else if (ql <= l && r <= qr) {
            heap[nodeId] = v;
        }
        else {
            pushdown(nodeId);
            int m = l + (r - l)/2;
            update(nodeId * 2, l, m, ql, qr, v);
            update(nodeId * 2 + 1, m + 1, r, ql, qr, v);
        }
    }
    
    int query(int nodeId, int l, int r, int q) {
        if (q < l || q > r) {
            return -1;
        }
        else if (l == r) {
            return heap[nodeId];
        }
        else {
            pushdown(nodeId);
            int m = l + (r - l)/2;
            return max(query(nodeId * 2, l, m, q), query(nodeId * 2 + 1, m + 1, r, q));
        }
    }
    
    void pushdown(int nodeId) {
        //cout << "push: " << nodeId << endl;
        if (heap[nodeId] != -1) {
            heap[nodeId * 2] = heap[nodeId];
            heap[nodeId * 2 + 1] = heap[nodeId];
            heap[nodeId] = -1;   
        }
    }
    
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree st(n);
    for (int i = 0; i < q; i++) {
        int cmd;
        cin >> cmd;
        if (cmd == 0) {
            int ql, qr, v;
            cin >> ql >> qr >> v;
            st.update(1, 0, n -1, ql, qr, v);
//            for (int i = 0; i < 4 * n; i++) {
//                cout << i << ":" << st.heap[i] << endl; 
//            }
        }
        else {
            int pos;
            cin >> pos;
            cout << st.query(1, 0, n-1, pos) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4432
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

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

int main() {
  int n, target;
  scanf("%d %d", &n, &target);
  vector<int> values(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &values[i]);
  int g = 0;
  for (int i = 0; i < n; ++i)
    g = gcd(g, values[i]);
  int max_value = *max_element(values.begin(), values.end());
  if (target % g == 0 && target <= max_value)
    printf("POSSIBLE\n");
  else
    printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        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_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_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, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input! {
        n: i32,
        k: i32,
        x: i32,
        y: i32
    };
    println!("{}", solve(n, k, x, y));
}

fn solve(n: i32, k: i32, x: i32, y: i32) -> String {
    // write solution here
    let result;
    if n < k {
        result = n * x;
    } else {
        result = k * x + (n - k) * y;
    }
    // return answer
    format!("{}", result)
}


Measured memory_bytes: 4352
//dpではとけなかった(なんでかは分からん)

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

//long dp[6][1100];
/*
long rec(int a, int b){ //a本目，最後に当てた位置b
	if(dp[a][b]>=0) return dp[a][b];
	
	long ret=0;
	long tmp=0;
	
	if(a==4) ret=0;
	else{
		for(int i=b; i<=n; ++i){
			tmp=rec(a+1, i)+p[i];
			if(tmp>m) tmp=0;	
			
			ret=max(ret, tmp);
			
		}		
	}
	
	return dp[a][b]=ret;
}
*/

int n;
long m, p[1001], q[1100000];

int main(){
	while(1){
		
		scanf(" %d %ld", &n, &m);
		if(n==0) break;
		p[0]=0; //投げない選択肢
		for(int i=1; i<=n; ++i) scanf(" %ld", &p[i]);
		sort(p, p+n);
		
		//半分全列挙(?)
		long now=0;
		for(int i=0; i<=n; ++i)
		for(int j=i; j<=n; ++j)
		q[now++]=p[i]+p[j];
		sort(q, q+now);
		
		//for(long i=0; i<now; ++i) printf("q[%ld]=%ld\n", i, q[i]);
		
		/*
		memset(dp, -1, sizeof(dp));
		printf("%ld\n", rec(0,0));
		*/
		
		long ans=0;
		for(long i=0; i<now; ++i){
			long rem=m-q[i];
			if(rem<0) break;
			
			//2分探索
			long left=0, right=now;
			while(left<right){
				long center=(left+right)/2;
				if(rem>q[center]){
					left=center+1;
				}
				else if(rem<q[center]){
					right=center;
				}
				else	break;
			}
			
			ans=max(ans, q[i]+q[right-1]);
		}
		
		printf("%ld\n", ans);
	}
}

Measured memory_bytes: 5304
N,W = map(int,input().split())
dp=[[0]*(W+100) for _ in range(N+10)]
for i in range(N):
    w,v= map(int,input().split())
    for j in range(W+1):
        if j-w>=0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v)
        else:
            dp[i+1][j]=dp[i][j]
print(dp[N][W])

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

signed main(){
	int n;
	cin>>n;
	while(true){
		if(n%111==0){
			cout<<n<<endl;
			break;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int q[200007];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &q[i]);
	int in = 1;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		if (q[i] == in)
			in++;
		else
			sum++;
	}
	printf("%d", sum == n ? -1 : sum);
	return 0;
}

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

int main(){
  int n,odd = 0,even = 0;cin >> n;
  rep(i,n){int a;cin >> a;if(a%2 != 0)odd += 1;}
  if(odd%2 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

constexpr long long MOD = 1000000007;
constexpr long long S_MAX = 2001;
using namespace std;

long long A[S_MAX];

int main() {
	long long S;
	cin >> S;
	A[0] = 1, A[1] = 0, A[2] = 0;

	for (int i = 3; i <= S; ++i) {
		A[i] = (A[i - 1] + A[i - 3]) % MOD;
	}

	cout << A[S] << endl;
	return 0;
}

Measured memory_bytes: 3596
N = str(input())
if N[-1] == '3':
    print('bon')
elif (N[-1] == '0') or (N[-1] == '1') or (N[-1] == '6') or (N[-1] == '8'):
    print('pon')
elif (N[-1] == '2') or (N[-1] == '4') or (N[-1] == '5') or (N[-1] == '7') or (N[-1]=='9'):
    print('hon')

Measured memory_bytes: 9076
#include<stdio.h>

int main(){
        int n, i, j, k;
        scanf("%d", &n);
        int len[n], count=0;
        for(i=0; i<n; i++){
                scanf("%d", &len[i]);
        }
        for(i=0; i<n; i++){
                for(j=i+1; j<n; j++){
                        for(k=j+1; k<n; k++){
                                if((len[i]!=len[j])&&(len[j]!=len[k])&&(len[k]!=len[i])){

                                if((len[i]+len[j]>len[k])&&(len[j]+len[k]>len[i])&&(len[k]+len[i]>len[j])){
                                        count++;
                                }

                                }
                        }
                }
        }
        printf("%d", count);
        return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> Map(H + 1, vector<char>(W + 1));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> Map[i][j];
	for (int i = 0; i < H; i++) Map[i][W] = '.';
	for (int i = 0; i < W; i++) Map[H][i] = '.';
	int y = 0, x = 0;
	if (Map[H - 2][W - 1] == '#' && Map[H - 1][W - 2] == '#') {
		cout << "Impossible" << endl;
		return 0;
	}
	bool ans = true;
	while (y != H - 1 || x != W - 1) {
		if ((Map[y][x + 1] == '#' && Map[y + 1][x] == '#') ||
			(Map[y][x + 1] == '.' && Map[y + 1][x] == '.') ||
			(x > 0 && y > 0 && Map[y][x - 1] == '#' && Map[y - 1][x] == '#')) {
			ans = false;
			break;
		}
		if (Map[y][x + 1] == '#') x++;
		else y++;
	}
	cout << (ans ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

ll f(ll a){

    if(a%4 == 0) return a;
    if(a%4 == 1) return (a^(a-1));
    if(a%4 == 2) return (a^(a-1)^(a-2));
    if(a%4 == 3) return 0LL;

    return 0LL;
}


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

    if(a == 0) cout << f(b) << endl;
    else cout << (f(b)^f(a-1)) << endl;

    // for(int i=0; i<12; i++) cout << f(i) << endl;
    
}

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

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

    vector< long long > a(n + 2, 0), b(n + 1, 0);

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

    long long crr = 0;
    long long sum = 0;
    for(int i = 0; i < n + 1; i++) {
        sum += min(a[i], b[i]);
        crr = max(0LL, b[i] - a[i]);
        if(crr > 0) {
            long long del = min(a[i + 1], crr);
            a[i + 1] -= del;
            sum += del;
        }
    }
    cout << sum << endl;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
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); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE

	fastio;
	ll h, n;
	cin >> h >> n;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	vector<ll> dp(10 * 10001, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (ll j = 0; j + a[i] <= 10 * h; ++j) {
			dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
		}
	}
	ll ans = INF;
	for (ll j = h; j <= 10 * h; ++j) {
		ans = min(ans, dp[j]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    int ans = -1;
    int left = 0;
    int right = n;
    while(left < right) {
      int med = (left + right) / 2;
      if(a[med] < k) {
        boolean[][] dp = new boolean[n][k]; 
        if(med != 0) {
          dp[0][0] = true;
          if(a[0] < k) dp[0][(int)a[0]] = true;
        } else {
          dp[0][0] = true;
          if(n > 1) {
            dp[1][0] = true;
            if(a[1] < k) dp[1][(int)a[1]] = true;
          }
        }
        for(int i = 1; i < n; i++) {
          dp[i][0] = true;
          for(int j = 1; j < k; j++) {
            dp[i][j] = dp[i - 1][j];
            if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][(int)(j - a[i])]);
          }
        }
        int p = 0;
        for(int j = (int)(k - a[med]); j < k; j++) {
          if(dp[n - 1][j]) p++;
        }
        if(p == 0) {
          ans = med;
          left = med + 1;
        } else {
     //     ans = med;
          right = med;
        }
       } else {
     //    ans = med;
         right = med;
       }
      }
      
    ans++;
    System.out.println(ans);
  }
}

Measured memory_bytes: 205756
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
const int inf=2e3;
#define maxx 200005
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
vi adj[maxx];
int cnt;
bool vis[maxx];
void dfs(int src){
   vis[src]=1;
   cnt++;
   for(int i=0;i<adj[src].size();i++){
    if(!vis[adj[src][i]]){
        dfs(adj[src][i]);
    }
   }
   return;
}
int main(){
    FASTIO;
    int n,m,a,b,mx=0;
    cin>>n>>m;
    REP(i,0,m){
      cin>>a>>b;
      adj[a].PB(b);
      adj[b].PB(a);
    }
    REP(i,1,n+1){
      cnt=0;
      if(!vis[i]){
        dfs(i);
        mx=max(mx,cnt);
      }
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 21012
from itertools import product
n = int(input())
mod = 10 ** 9 + 7
dp = [[[[0] * 5 for _ in range(5)] for _ in range(5)] for _ in range(n + 1)]
dp[0][0][0][0] = 1
# 1:A, 2:G, 3:C, 4:T
for t in range(n):
	for i, j, k, l in product(range(5), repeat=4):
		if not (l == 0 or (j == 1) & (k == 2) & (l == 3) or (i == 1) & (j == 2) & (l == 3) or (j == 1) & (k == 3) & (l == 2)
				  or (j == 2) & (k == 1) & (l == 3) or (i == 1) & (k == 2) & (l == 3)):
			dp[t + 1][j][k][l] += dp[t][i][j][k] % mod
ans = sum(dp[-1][i][j][k] % mod for i, j, k in product(range(1, 5), repeat=3)) % mod
print(ans)

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

int n, p;
ll val[10101];
string s;

int main()
{
    cin >> n >> p >> s;
    
    if(p == 2 || p == 5)
    {
        ll res = 0;
        for (int i = 0; i < n; i++)
        {
            if((s.at(i) - '0') % p == 0)
            {
                res += (long)(i + 1);
            }
        }
        cout << res << endl;
        return 0;
    }

    int sum = 0, cur = 1;
    for (int i = n - 1; i >= 0; i--)
    {
        sum += ((cur * (s.at(i) - '0')) % p);
        sum %= p;
        val[sum]++;
        cur *= 10;
        cur %= p;
    }

    //rep(i, n) cout << val[i] << " "; cout << endl;

    ll res = 0;
    for (int i = 0; i < p; i++)
    {
        res += (long)((val[i] * (val[i] - 1)) / 2);
    }
    res += val[0];
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define N 200005
int n,m,ans,a[N],s[N];
int max(int x,int y) {return x>y?x:y;}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for(int i=m;i<=n;++i) ans=max(ans,s[i]-s[i-m]);
	ans+=m;printf("%d",ans>>1);if(ans&1) puts(".5");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N=1e5+5;

struct node{
    int t,x,y;
}p[N];

int main(void){
    int n;
    cin>>n;
    p[1].t=0,p[1].x=0,p[1].y=0;
    for(int i=2;i<=n+1;i++)   scanf("%d%d%d",&p[i].t,&p[i].x,&p[i].y);
    for(int i=2;i<=n+1;i++){
        int t=p[i].t-p[i-1].t;
        int dis=abs(p[i].x-p[i-1].x)+abs(p[i].y-p[i-1].y);
        //cout<<"t="<<t<<"dis="<<dis<<endl;
        if(t<dis){
            printf("No\n");
            return 0;
        }
        else{
            int d=t-dis;
            if(d%2==1){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 100005

int imos[ARRAY_MAX];

int main(){

    int n;
    cin >> n;
    int ans = 0;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        imos[a]++;
        imos[b+1]--;
    }
    REP(i,ARRAY_MAX-1){
        imos[i+1] += imos[i];
    }

    for(int i = 1;i < ARRAY_MAX;i++){
        if(i <= imos[i]+1){
            ans = i-1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3488
s = input()
k = int(input())

counter = [1]
before = s[0]
for i in range(1, len(s)):
    if s[i] == before:
        counter[-1] += 1
    else:
        counter.append(1)
    before = s[i]


if s[0] == s[-1] and len(counter) >= 2:
    c_tmp = counter[0] + counter[-1]
    btw_sum = c_tmp // 2
    tot = 0
    for i in range(len(counter)):
        if i != 0 and i != len(counter) - 1:
            tot += (counter[i] // 2) * k
        else:
            tot += counter[i] // 2
    tot += btw_sum * (k - 1)

elif s[0] == s[-1] and len(counter) == 1:
    tot = (len(s) * k) // 2
else:
    tot = 0
    for i in range(len(counter)):
        tot += (counter[i] // 2) * k

print(tot)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,c;
main(){
	cin>>a>>b>>c;
	if((a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)||(a==5&&b==5&&c==7))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int s = int.Parse(input);
        int[] frequency = new int[10000000];
        int count = 0;
        while (true)
        {
            count++;
            if (frequency[s] == 1) break;
            frequency[s]++;
            if (s % 2 == 0) { s = s / 2; }
            else { s = 3 * s + 1; }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11088
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	string s; cin >> s;
	rep (i, s.length()) {
		if (i % 2 == 0) cout << s[i];
	}
	cout << endl;
	return;
}

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

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

ll n,a[100010],b[100010],ans=0;
mp p[100010];

int main(void){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		p[i] = {a[i]+b[i],i};
	}
	sort(p,p+n);
	rep(i,n){
		if(i%2==0){
			//高橋
			ans+=a[p[n-1-i].second];
		}else{
			ans-=b[p[n-1-i].second];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    double x1,x2,y1,y2,qx,qy;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&qx,&qy)!=EOF){
        if(x1==x2){
            printf("%.6lf %.6lf\n",2*x1-qx,qy);
            continue;
        }
        if(y1==y2){
            printf("%.6lf %.6lf\n",qx,2*y1-qy);
            continue;
        }

        double a1=(y2-y1)/(x2-x1);
        double a2=(-1)/a1;
        double b1=y1-a1*x1;
        double b2=qy-a2*qx;
        double xm=(b2-b1)/(a1-a2);
        double x=2*xm-qx;
        double y=x*a2+b2;
        printf("%.6lf %.6lf\n",x,y);
    }
}

Measured memory_bytes: 1084
N = int(input())
a = input()

def myc(n):
    ret = 0
    while n % 2 == 0:
        ret += 1
        n //= 2
    return ret

def func(c):
    odd = 0
    count = 0
    if a[0] == c:
        count += 1
    if a[-1] == c:
        count += 1
    for i in range(1, N // 2):
        odd += myc(N-i) - myc(i)
        if a[i] == c and odd == 0:
            count += 1
        if a[-i-1] == c and odd == 0:
            count += 1
    if N % 2 == 1:
        if a[N // 2] == c and odd + myc(N // 2 + 1) - myc(N // 2) == 0:
            count += 1
    return count % 2 == 0

if '2' in a:
    if func('2'):
        print(0)
    else:
        print(1)
else:
    if func('3'):
        print(0)
    else:
        print(2)

Measured memory_bytes: 5736
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from heapq import heappush, heappop
import sys
INF = 10**10
def main(H, W, K, x1, y1, x2, y2, C):
    dist = [[INF] * W for _ in range(H)]
    q = [(0, x1, y1)]
    dist[x1][y1] = 0
    while q:
        d, i, j = heappop(q)
        if dist[i][j] < d: continue
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            for dt in range(1, K + 1):
                ni, nj = i + di * dt, j + dj * dt
                if not (0 <= ni < H and 0 <= nj < W): break
                if C[ni][nj] == '@': break
                if dist[ni][nj] == d + 1: continue
                if dist[ni][nj] < d + 1: break
                heappush(q, (d + 1, ni, nj))
                dist[ni][nj] = d + 1
    ans = dist[x2][y2]
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
    C = [input().rstrip() for _ in range(H)]
    main(H, W, K, x1, y1, x2, y2, C)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
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> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

std::vector<ll> divisor(ll n){
  std::vector<ll> div;
  for(ll p=1;p*p<=n;++p){
    if(n%p==0){
     div.push_back(p);
     if(p*p!=n)div.push_back(n/p);
    }
  }
  std::sort(div.begin(),div.end());
  return div;
}
map<ll,ll> p;

bool is_prime(ll x){
  if(x==1)return false;
  if(x==2)return false;
  for(ll p=3;p*p<=x;p+=2){
    if(x%p==0)return false;
  }
  return true;
}

signed main(){

  ll n;
  cin>>n;

  int ans = 0;
  auto ok = [](ll n,ll k){
    if(k==1)return false;
    if(n==k)return true;
    while(n>=k){
      if(n%k==0)n/=k;
      else n%=k;
    }
    return n==1;
  };

  for(auto x:divisor(n)){
    ans += ok(n,x);
  }
  for(auto x:divisor(n-1)){
    ans += ok(n,x);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<long long>a(n),b(n);
  for(int i=1;i<n;i++){
    b[i]=0;
  }
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
 
  for(int i=1;i<n;i++){
    cout<<b[i]<<endl;
  }
  cout<<"0"<<endl;
}

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

int main() {
  uint64_t c[100][4][4][4];

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        c[0][i][j][k] = 1;
      }
    }
  }
  c[0][2][0][1] = 0;
  c[0][0][1][2] = 0;
  c[0][0][2][1] = 0;
  int n;
  std::cin >> n;
  for (int m = 1; m < n - 2; m++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          c[m][i][j][k] = c[m - 1][0][i][j]
            + c[m - 1][1][i][j] + c[m - 1][2][i][j]
            + c[m - 1][3][i][j];
          if (k == 1 && j == 2) {
            c[m][i][j][k] -= c[m - 1][0][i][j];
          } else if (k == 1 && i == 2) {
            c[m][i][j][k] -= c[m - 1][0][i][j];
          }
          c[m][i][j][k] %= 1000000007;
        }
      }
    }
    c[m][2][0][1] = 0;
    c[m][0][1][2] = 0;
    c[m][0][2][1] = 0;
  }

  int ans = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ans += c[n - 3][i][j][k];
        ans %= 1000000007;
      }
    }
  }

  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;
int a[100005];
int main(){
	int n,b;
	cin>>n>>b;
	int ans=0;
	for(int i=0;i<b;i++){
		cin>>a[i];
		ans+=a[i];
	}
	if(ans>=n)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int H,W;cin>>H>>W;
    char A[H][W];
    map<int,int>hmemo;
    map<int,int>wmemo;
    REP(i,H){
        REP(j,W)cin>>A[i][j];
    }
    REP(i,H){
        bool ok=true;
        REP(j,W){
            if(A[i][j]=='#'){
                ok=false;
                break;
            }
        }
        if(ok)hmemo[i]++;
    }
    REP(j,W){
        bool ok=true;
        REP(i,H){
            if(A[i][j]=='#'){
                ok=false;
                break;
            }
        }
        if(ok)wmemo[j]++;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(hmemo[i]==0&&wmemo[j]==0)cout<<A[i][j];
        }
      	if(hmemo[i]==0)cout<<endl;  
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string S;
  cin >> S;

  int len = S.size();

  int ans = 1000;
  for (int i = 0; i < len - 2; i++){
    int x = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
    ans = min(abs(x - 753), ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#![allow(unused_imports)]
use num::integer::gcd;
use proconio::*;
use std::cmp::*;
use std::collections::VecDeque;
use std::collections::HashSet;
use std::ops::*;

fn main() {
   input! {
      n: usize,
      s: [String; n]
   }

   let mut set = HashSet::new();
   for s in s {
      set.insert(s);
   }
   println!("{}", set.len());
}


Measured memory_bytes: 24860
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 100001


int main(){
	int a[N];
	vector<int> b;
	b.push_back(1);
	int n, k;
	int x, y, z;
	long long s, ans;
	s = 0;
	ans = 0;
	x = 6;
	while (x < 100000){
		b.push_back(x);
		x = x * 6;
	}
	x = 9;
	while (x < 100000){
		b.push_back(x);
		x = x * 9;
	}
	scanf("%d", &n);
	a[0] = 0;
	f(i, n){
		k = 10000000;
		f(j, b.size()){
			if (b[j] <= (i + 1)){
				x = a[i - b[j] + 1] + 1;
				if (x < k)k = x;
			}
		}
		a[i + 1] = k;
	}
	printf("%d\n", a[n]);

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n,S[10000],q,T[500],c=0,i,i2,toread,cnt;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)cin>>T[i];
	for(i=0;i<n;i++){
		for(i2=0;i2<n;i2++){
			if(S[i]<S[i2]){
				toread=S[i];
				S[i]=S[i2];
				S[i2]=toread;
			}
		}
	}
	for(i=0;i<q;i++){
		cnt=0;
		toread=n;
		while(toread>1){
			if(toread%2==0)toread/=2;
			else toread=(toread+1)/2;
			if(S[(toread-1)+cnt]<T[i])cnt+=toread;
			else if(S[(toread-1)+cnt]==T[i]){
				c++;
				break;
			}
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int a,b,c,d,e;
int am, bm,cm , dm ,em;
int l[5];
int one;
int maxi;
int tmp;
int total;
int mini = 10;
int plus;
int mini_id;
bool flag = false;

int main(){

    // cin >> a >> b >> c >> d >> e;
    REP(i,5){
        cin >> l[i];
    }
    // maxi = max( a, max(b, max(c, max(d, e))))
    REP(i,5){
        one = (l[i] % 10);
        if(min(mini , one) != 0){
            mini = min(mini, one);
            mini_id = i;
            // debug(mini);
        }
        total += l[i];
        
        
        if(one != 0){
            tmp += 10 - one;
        }
        // debug(one);
    }

    if(mini == one){
        mini = one;
        // debug(mini);
    }
    cout << total + tmp - (10 - mini) << endl;

}

Measured memory_bytes: 256
import math
N = int(input())
xy = []
length = 0
for i in range(N):
    x, y = map(int, input().split())
    if i!=0:
        for j in xy:
            length+=math.sqrt((x-j[0])**2+(y-j[1])**2)
    
    
    xy.append([x, y])
    
            
print(length*2/N)

Measured memory_bytes: 61732
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0; i < 3; i++) a[i] = scan.nextInt();
        Arrays.sort(a);
        System.out.println(a[2] * 10 + a[1] + a[0]);
        scan.close();
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main(){
  string N;
  cin >> N;
  if (N.at(0)==N.at(1) && N.at(0)==N.at(2) || N.at(3)==N.at(2) && N.at(3)==N.at(1)){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256