akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
print(s[0] + str(len(s)-2) + s[-1])

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

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

    cout << max(0, A-2*B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,sx,sy,gx,gy,sum,pos,k,x[ohara],y[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ld ans;
ll dp[ohara];
P p[ohara];
ll p_cou;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>sx>>sy>>gx>>gy>>n;
    rep(i,n)cin>>x[i]>>y[i];

    if(sx>gx){
        swap(sx,gx);
        swap(sy,gy);
    }
    if(sy==gy){
        rep(i,n){
            if(y[i]==sy&&sx<=x[i]&&x[i]<=gx){
                cnt+=2;
            }
        }
        ll hyaku;
        hyaku=(gx-sx)-cnt;
        ans=(100.0*(ld)hyaku)+((20.0*M_PI/4.0)*(ld)cnt+(90.0*(ld)cnt));
    }
    else if(sx==gx){
        rep(i,n){
            if(x[i]==gx&&min(sy,gy)<=y[i]&&y[i]<=max(sy,gy)){
                cnt+=2;
            }
        }
        ll hyaku;
        hyaku=(gy-sy)-cnt;
        ans=(100.0*(ld)hyaku)+((20.0*M_PI/4.0)*(ld)cnt+(90.0*(ld)cnt));
    }
    else{
        rep(i,n){
            if(sx<=x[i]&&x[i]<=gx&&min(sy,gy)<=y[i]&&y[i]<=max(sy,gy)){
            p[p_cou++]=m_p(x[i],y[i]);
            }
        }
        sort(p,p+p_cou);
        rep(i,p_cou)a[i]=p[i].se;
        if(sy>gy)rep(i,p_cou)a[i]*=-1;
        fill(dp,dp+p_cou,LINF);
        rep(i,p_cou){
            *lower_bound(dp,dp+p_cou,a[i])=a[i];
        }
        cnt=(lower_bound(dp,dp+p_cou,LINF)-dp);
        if(cnt==min(gx-sx,abs(gy-sy))+1){
            ll hyaku;
            cnt*=2;
            hyaku=abs(gy-sy)+abs(gx-sx)-cnt;
            ans=(20.0*M_PI/4.0)*2.0+(90.0*2.0);
            cnt-=2;
            ans+=(100.0*(ld)hyaku)+((20.0*M_PI/4.0)*(ld)cnt/2.0+(90.0*(ld)cnt));
        }
        else{
        ll hyaku;
        cnt*=2;
        hyaku=abs(gy-sy)+abs(gx-sx)-cnt;
        ans=(100.0*(ld)hyaku)+((20.0*M_PI/4.0)*(ld)cnt/2.0+(90.0*(ld)cnt));
        }
    }
    doublecout(ans);
    return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    if ((i % 2) == 0 && (a % 2) == 1) {
      ans ++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()
const int N = 1e6+5;

ll n , dp[N][2][2] , mod=1e9+7;

ll solve(int i , bool zero , bool nine)
{
    if (i>n)
        return (zero && nine);

    if (dp[i][zero][nine] != -1)
        return dp[i][zero][nine];

    ll ans=solve(i+1 , 1 , nine);
    ans = (ans+solve(i+1 , zero , 1))%mod;
    ans = (ans+1ll*8*solve(i+1,zero,nine))%mod;
  
    return dp[i][zero][nine] = ans;
}

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

    cin >> n;
    memset(dp , -1 , sizeof(dp));

    cout << solve(1,0,0) << '\n';
  
    return 0;
}

Measured memory_bytes: 97336
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>


int main(void)
{
    int64_t N, K;
    std::cin >> N >> K;

    int64_t count = 0;
    for (int64_t i = 0; i < N; ++i) {
        int64_t h;
        std::cin >> h;
        if (h >= K) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
def count(n,x):
    if x<=n:
        return 0
    elif x>=2**(n+2)-3-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
		OriginScanner os = new OriginScanner();
		
		try (PrintWriter pw = new PrintWriter(System.out)) {
			long a = os.nextLong();
			long b = os.nextLong();
			long k = os.nextLong();
			
			long ak = Math.min(a, k);
			a -= ak;
			k -= ak;
			b -= k;
			long bk = Math.max(b, 0);
			pw.println(a + " " + bk);
		}
	}

	static class OriginScanner {
		StringTokenizer token;
		BufferedReader br;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		
		String next() {
			while (token == null || !token.hasMoreElements()) { 
				token = new StringTokenizer(nextLine());
			}
			return token.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,c,l=0,s=0;
  int ans[101][101];
  cin >> r >> c;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin >> ans[i][j];
      s += ans[i][j];
    }
    ans[i][c] = s;
    s=0;
  }
  for(int j=0;j<=c;j++){
    for(int i=0;i<r;i++){
      l += ans[i][j];
    }
  ans[r][j] = l;
  l = 0;
}
  for(int i = 0;i<=r;i++){
    for(int j = 0;j<=c;j++){
      cout << ans[i][j];
      if(j!=c) cout << " ";
      else cout << endl;
    }
    
  }
}



Measured memory_bytes: 3100
h, n = map(int, input().split())
ab = []
for _ in range(n):
  a, b = map(int, input().split())
  ab.append((a, b))
dp = [0] * (h+1)
for c in range(1, h+1):
  dp[c] = min([dp[max(0, c-a)] + b for a, b in ab])
print(dp[-1])

Measured memory_bytes: 42332
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

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

    ll n, m;
    cin >> n >> m;
    ll copym = m;
    ll MN = m / n;
    ll mx = 1;
    if (m%n == 0)cout << m / n << endl;
    else{
        for (int i = 2; i <= MN; i++) {
            if (m%i == 0)mx = i;
        }
        cout << mx << endl;
    }
    /*
    int maxmelement = 1, div=3;
    if (m % 2 == 0) {
        maxmelement = 2;
        while (1) {
            if (m % 2 == 0)m /= 2;
            else break;
        }
    }
    while (1) {
        if (div > copym / n) break;
        if (m == 1)break;
        if (m%div == 0) {
            maxmelement = div;
            while (1) {
                if (m % div == 0)m /= div;
                else break;
            }
        }
        div += 2;
    }
    cout << maxmelement << endl;
    */
    return 0;
}


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

using namespace std;
int main() {
	int n; cin >> n;
	vector<double>coin(n); for (int i = 0; i < n; i++)cin >> coin[i];
	vector<vector<double>>dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		for (int front = 0; front <= i; front++) {
			int back = i - front;
			dp[front + 1][back] += dp[front][back] * coin[i];
			dp[front][back + 1] += dp[front][back] * (1 - coin[i]);
		}
	}
	double ret = 0.0;
	for (int back = 0; back <= n / 2; back++) ret += dp[n - back][back];
	cout << fixed << setprecision(15) << ret << endl;
	return 0;
}

Measured memory_bytes: 70784
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

N, K = MAP()
A = LIST()

B = []
for i in range(2):
    for a in A:
        B.append(a)
# print(B)
tenchi1 = bubble_sort(A)
tenchi2 = bubble_sort(B)

ni = tenchi2-2*tenchi1
# print(ni)

# tenchi = bubble_sort(A)
# print(tenchi)
# wa1 = 0.5 * (K) * (K+1)
wa2 =  (K) * (K-1) // 2
# wa2 = wa2
# ans1 = wa1 * tenchi1
# print("wa1", wa1)
# print("wa2", wa2)
# print("tenchi1", tenchi1)
# print("tenchi2", tenchi2)
# print("ni", ni)
ans1 = K*tenchi1
ans2 = wa2 * ni
ans = ans1 + ans2

ans = ans % mod
print(ans)


Measured memory_bytes: 5396
#include<iostream>
#include<vector>
int main(){
  int n,m,l;
  std::cin >> n >> m >> l;
  unsigned long long A[n][m], B[m][l], C[n][l];
  for(int i=0; i<n; i++) for(int j=0; j<m; j++) std::cin >> A[i][j];
  for(int i=0; i<m; i++) for(int j=0; j<l; j++) std::cin >> B[i][j];
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      C[i][j] = 0;
      for(int k=0; k<m; k++) C[i][j] += A[i][k] * B[k][j];
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++) std::cout << C[i][j] << (j < l-1 ? " " : "\n");
  }
  return 0;
}

Measured memory_bytes: 3244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    char c[5100],tmp[7],s[30000][7];
    int k;
    scanf ("%s%d",c,&k);
    strncpy(tmp,c,1);
    tmp[strlen(tmp)]='\0';
    
    int count=0;
    for (int i=1; i<k+1 && i<strlen(c)+1; i++){
        for(int j=0; j<strlen(c)+1-i; j++){
            strncpy(s[count],c+j,i);
            s[count][strlen(s[count])]='\0';
            count++ ;
            for (int l=0; l<count-1; l++){
                if(strcmp(s[l],s[count-1])==0){
                    count--;
                    break ;
                }
            }
        }
    }
    for (int i=0; i<count; i++){
        int count2=0 ;
        for (int j=i+1; j<count; j++){
            if (strcmp(s[i],s[j])<0){
                strcpy(tmp,s[i]);
                tmp[strlen(s[i])]='\0';
                strcpy(s[i],s[j]);
                s[i][strlen(s[j])]='\0';
                strcpy(s[j],tmp);
                s[j][strlen(tmp)]='\0';
                count2++;
                if(count2==k+1){
                    break;
                }
            }
        }
    }
    printf ("%s\n",s[count-k]);
    return 0 ;
}

Measured memory_bytes: 256
N = int(input())
dp = [[0]*3 for i in range(N+1)]

for i in range(N):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1] + a, dp[i][2] + a, dp[i][0])
    dp[i+1][1] = max(dp[i][2] + b, dp[i][0] + b, dp[i][1])
    dp[i+1][2] = max(dp[i][0] + c, dp[i][1] + c, dp[i][2])

print(max(dp[N]))


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

const int N = (int) 1e5;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  set<ll> s;
  for (int i = 1; i <= 9; i++) {
    s.insert(i);
  } 
  while (s.size() < N) {
    set<ll> t;
    for (auto e : s) {
      if (e % 10 != 9) t.insert(e * 10 + (e % 10 + 1));
      if (e % 10 != 0) t.insert(e * 10 + (e % 10 - 1));
      t.insert(e * 10 + (e % 10));
      if (t.size() > N) break;
    }
    for (auto e : t) {
      s.insert(e);
    }
  }
  for (auto e : s) {
    --k;
    if (k == 0) {
      cout << e << '\n';
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 9728
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


factorial = [1]
modulo = 10**9+7
inverse_factorial = [0]


def pow1(a, p):
    if p == 0:
        return 1
    half = pow1(a, p//2)
    total = (half*half)%modulo
    if p%2 == 0:
        return total
    return (total*a)%modulo


def modpow(a, p):
    ans = 1
    while p:
        if p&1 == 1:
            ans = (ans*a)%modulo
        a = (a*a)%modulo
        p >>= 1
    return ans


def nCr(n, r):
    if r == 0 or r == n:
        return 1
    return (((factorial[n]*inverse_factorial[n-r])%modulo)*inverse_factorial[r])%modulo


def solve():
    """
    2 3 1 1
    ...
    x..  A

    B

    C(2, 1)*C(3, 2)

    m 0 n 1 C(m, n) 1
    m 1 n 2 C(m, n) 2
    m 0 n 2 C(m, n) 4
    m 1 n 3 C(m, n) 12
    """
    H, W, A, B = read_ints()
    for i in range(1, H+W):
        f = (factorial[-1]*i)%modulo
        factorial.append(f)
        inv_f = modpow(f, modulo-2)
        inverse_factorial.append(inv_f)
    T = 0
    for d in range(B, W):
        # d = 0, 1
        y0 = d
        x0 = H-A-1
        y1 = W-d-1
        x1 = A-1
        T = (T+(nCr(x0+y0, x0)*nCr(x1+y1, x1))%modulo)%modulo
    return T


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


Measured memory_bytes: 88376
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define B back()
#define FR front()
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
#define iceil(a) ((int)ceil(a))
#define ifloor(a) ((int)floor(a))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int ans = 1;
    int n;
    cin >> n;
    string s;
    cin >> s;

    for(int i = 1; i < n; i++){
        if(s[i] != s[i - 1]) ans++;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit = {
    val weather = scala.io.StdIn.readLine.split( "" )
    var count = 0
    var flag = false
    weather.foreach{ i =>
      if( i == "R" ) {
        if( flag ) count += 1
        else {
          count = 1
          flag = true
        }
      }
      if( i == "S" ) flag = false
    }
    println( count )
  }
}

Measured memory_bytes: 54564
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	long long n, t;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	t = n;

	int s = 0;
	vector<int> p;
	if (n % 2 == 0) {
		while (n % 2 == 0) {
			s++;
			n /= 2;
		}
		p.emplace_back(s);
	}
	for (int i = 3; i <= sqrtl(t); i+=2) {
		if (n % i == 0) {
			s = 0;
			while (n % i == 0) {
				s++;
				n /= i;
			}
			p.emplace_back(s);
		}
	}
	if (n != 1) {
		p.emplace_back(1);
	}

	int sum[101];
	for (long long i = 0; i <= 100; i++) {
		sum[i] = i * (i + 1) / 2;
	}
	int ans = 0;
	for (auto & i : p) {
		for (int j = 0; j < 101; j++) {
			if (i < sum[j]) {
				ans += j - 1;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3724
unittest
{
	assert( [ "5", "2 4 4 0 2" ].parse.expand.solve == 4 );
	assert( [ "7", "6 4 0 2 4 0 2" ].parse.expand.solve == 0 );
	assert( [ "8", "7 5 1 1 7 3 5 3" ].parse.expand.solve == 16 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

const MOD = 10L ^^ 9 + 7;

auto solve( long[] as )
{
	// 奇数人の場合 = 0が1人、1以上の偶数が2人ずつ じゃないと成り立たない
	// 偶数人の場合 = 1以上の奇数が2人ずつ じゃないと成り立たない
	
	as.sort();
	
	auto ans = 1L;
	auto d = 0L;
	if( as.length % 2 == 1 )
	{
		if( as[ 0 ] != 0 ) return 0L;
		as.popFront;
		d = 2;
	}
	else
	{
		d = 1;
	}
	
	for( auto i = 0L; i < as.length; i += 2 )
	{
		if( as[ i ] != d || as[ i + 1 ] != d ) return 0L;
		ans = ( ans * 2 ) % MOD;
		d += 2;
	}

	return ans;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    bool has9 = true;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != '9') {
            has9 = false;
        }
    }
        ans = s[0] - '1';
        ans += 9 * (s.size() - 1);
    if (has9 ) {
        cout << ans + 1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

macro_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! {
    v: [i32; 3]
  }
  
  let mut w = v;
  w.sort();

  println!("{}",
    if (w[0] == w[1] || w[1] == w[2]) && w[0] != w[2] { "Yes" }
    else { "No" }
  );
}

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

int sum_cost(vector<int> &a, int x){
  int cost=0;
  for(int i=0; i<a.size(); i++){
    cost+=(a.at(i)-x)*(a.at(i)-x);
  }
  return cost;
}
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int ans;
  for(int i=a.at(0); i<=a.at(N-1); i++){
    int S=sum_cost(a,i);
    if (i==a.at(0)) ans=S;
    ans=min(ans,S);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int h,w;
    cin >> h >> w;
    vs s(h);
    rep(i,h)cin >> s[i];
    vector<vi> a(h),b(w);
    rep(i,h)rep(j,w){
        if(s[i][j] == 'O')a[i].push_back(j);
        if(s[i][j] == 'I')b[j].push_back(i);
    }
    int ans = 0;
    rep(i,h)rep(j,w)if(s[i][j] == 'J'){
        int x = a[i].end() - lower_bound(all(a[i]),j);
        int y = b[j].end() - lower_bound(all(b[j]),i);
        //cout << i << " " << j << " " << x << " " << y << endl;
        ans += x*y;
    }
    cout << ans << endl;
}



Measured memory_bytes: 106444
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

struct edge {
    int to, cost;
};
vector<edge> G[100];

int main() {
    int n;
    cin >> n;
    int cost;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            cin >> cost;
            if (0 <= cost) {
                G[i].push_back((edge){j, cost});
                G[j].push_back((edge){i, cost});
            }
        }
    }
    vector<int> V(1, 0);
    bool used[100] = {};
    used[0] = true;
    int ret = 0;
    while (1) {
        edge e = (edge){-1, INT_MAX};
        for (int i=0; i<(int)V.size(); ++i) {
            for (int j=0; j<(int)G[V[i]].size(); ++j) {
                if ( ! used[G[V[i]][j].to] && G[V[i]][j].cost < e.cost) {
                    e = G[V[i]][j];
                }
            }
        }
        if (e.to < 0) break;
        V.push_back(e.to);
        used[e.to] = true;
        ret += e.cost;
    }

    cout << ret << endl;
    return 0;
}

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

int main(){
	string n;
	cin>>n;
	int len=n.length();
	len--;
	for(int i=0;i<=len;i++){
		if(n[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int A,B;
    cin >> A >> B;
    if(A + B >= 10) {
        cout << "error" << endl;
    }
    else {
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

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(){
    int n;
    cin >> n;
    Point a, b;
    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
#include <bits/stdc++.h>

using namespace std;

vector<int> num(100005);

int n;

int partition(int start, int end)
{
	int pivot = num[end];
	int pos = start - 1;
	for (int i = start; i <= end - 1; ++i) {
		if (num[i] <= pivot) {
			++pos;
			std::swap(num[pos], num[i]);
		}
	}
	std::swap(num[pos + 1], num[end]);
	return pos + 1;
}

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

	cin >> n;
	for (int i = 0; i < n; ++i) cin >> num[i];

	int pos = partition(0, n - 1);
	for (int i = 0; i < pos; ++i) cout << num[i] << ' ';
	cout << '[' << num[pos] << ']';
	if (pos != n - 1) cout << ' ';
	for (int i = pos + 1; i < n; ++i) {
		cout << num[i];
		if (i != n - 1) cout << ' ';
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    int P,Q,R;
    cin >> P >> Q >> R;
    cout << min(P+Q,min(Q+R,R+P)) << endl;
    return 0;
}






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

long long W, values[110], weight[110];
long long dp[110][100010] = {0};


int main() {
    int N;

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


    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - weight[i] >= 0) {
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + values[i]);
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79488
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    string s;
    int w;
    cin >> s >> w;
    string ans;
    rep(i, sz(s)) {
        if (i % w == 0) ans.push_back(s[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3608
N=int(input())
A = list(map(int, input().split()))
b4 = 0
b2 = 0
other = 0
for a in A:
    if a%4==0:
        b4 += 1
    elif a%2 == 0:
        b2 += 1
    else:
        other += 1

if N % 2 == 1:
    if b4 < other - 1:
        print("No")
    else:
        print("Yes")
else:
    if b4 < other:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 85208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, l, a[100010];
vector<ll>ans;

int main() {
	cin >> n >> l;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n - 1;i++) {
		if (a[i] + a[i + 1] >= l) {
			ans.eb(i + 1);
			for (int j = i - 1;j >= 0;j--)ans.eb(j + 1);
			for (int j = i + 1;j <n-1;j++)ans.eb(j + 1);
			break;
		}
	}
	if (ans.size() == 0) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for (int i = n - 2;i >= 0;i--) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2548
#!/usr/bin/env python3
H, W = map(int, input().split())
a = [None] * H
for i in range(H):
    a[i] = input()

c = [False] * W
r = [False] * H
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            break
        if j == W - 1:
            r[i] = True
for j in range(W):
    for i in range(H):
        if a[i][j] == '#':
            break
        if i == H - 1:
            c[j] = True

s = ''
for i in range(H):
    for j in range(W):
        if r[i] or c[j]:
            continue
        s += a[i][j]
    if not s:
        continue
    print(s)
    s = ''


Measured memory_bytes: 3064
S1 = list(input())
S2 = list(input())

ans = []

if len(S1) != len(S2):
  for s1, s2 in zip(S1[:-1], S2):
    ans.append(s1)
    ans.append(s2)
  ans.append(S1[-1])
else:
  for s1, s2 in zip(S1, S2):
    ans.append(s1)
    ans.append(s2)
    
print("".join(ans))

Measured memory_bytes: 3060
def examD():
    N, M = LI()
    X = [LI() for _ in range(N)]
    ans = 0
    for a in [-1,1]:
        for b in [-1,1]:
            for c in [-1,1]:
                que = []; ansC = 0
                for i in X:
                    cur = a*i[0] + b*i[1] + c*i[2]
                    heapq.heappush(que,-cur)
                for j in range(M):
                    ansC -= heapq.heappop(que)
                ans = max(ans,ansC)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 3944
//
//  atc1019.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/10/19.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
#include <algorithm>
const int N = 5e3+10;
int n;
int a[N];
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d", &n);
    for (int i=1; i<=n; i++) {
        scanf("%d", &a[i]);
    }
    std::sort(a+1, a+n+1);
    int ans = 0;
    for (int i=1; i<n-1; i++) {
        int r = i+2;
        for (int j=i+1; j<n; j++) {
            if (r == j) ++r;
            ans += r-j-1;
            while (r<=n && a[i]+a[j]>a[r]) {
                ++ans; ++r;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
S = input()
ok = []
for i in range(2**4):
    bit = bin(2**4 + i)[3:]
    ok.append("A"*int(bit[0]) + "KIH" + "A"*int(bit[1]) + "B" + "A"*int(bit[2]) + "R" + "A"*int(bit[3]))

print("YES" if S in ok else "NO")


Measured memory_bytes: 2940
class Cells
  def initialize
    @cells = {}
  end

  def [](row_index, col_index)
    @cells[[row_index, col_index]]
  end

  def []=(row_index, col_index, value)
    @cells[[row_index, col_index]] = value
  end
end

n = gets.to_i
ts = (n-1).times.map{gets.chomp.split.map(&:to_i)}
tree = Array.new(n+1){Array.new}
ans = Cells.new
k = 0
queue = [1]
parent_color = Array.new(n+1,0)
used_point = Array.new(n+1,0)
used_point[1] = 1
ts.each do |a,b|
  tree[a] << b
  tree[b] << a
end
while !(queue.empty?)
  v = queue.shift
  k = [tree[v].size , k].max
  current_color = 1
  tree[v].each do |u|
    next if used_point[u] == 1
    current_color += 1 if current_color == parent_color[v]
    parent_color[u] = ans[u,v] = ans[v,u] = current_color
    current_color += 1
    used_point[u] = 1
    queue.push(u)
  end
end

puts k
ts.each do|a,b|
  puts ans[a,b]
end

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

int main(){
	int N, M;
	cin >> N >> M;
	int K[N], i, j, k;
	int A[31][31];
	
	for(i=0; i<N; i++){
		cin >> K[i];
		for(j=0; j<K[i]; j++){
			cin >> A[i][j];
		}
	}
	
	int ans=0;
	for(k=1; k<=M; k++){
		int count=0;
		for(i=0; i<N; i++){
			for(j=0; j<K[i]; j++){
				if(A[i][j]==k)	count++;
			}
		}
		if(count==N)	ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import Data.Array
import Data.Array.ST
import Control.Monad.ST
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified          Data.Vector.Mutable as M
import qualified Data.Vector as V

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined


readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents
main=do
    getLine
    a <- getIntList
    let cnt = runST $ do
            --vec <- V.thaw $ V.fromList [1..m]
            --vec <- M.new m
            vec <- V.thaw $ V.replicate m 0
            forM_ a $ \ai ->
                forM_ (primeFactor ai) $ \j -> 
                    M.modify vec (+1) j
            V.freeze vec
        
    putStrLn$if (V.and $V.map (<=1) cnt) 
        then "pairwise coprime"
        else if (foldl1 gcd a == 1) 
            then  "setwise coprime"
            else  "not coprime"
    --print $ V.take 20 cnt


m = 10^6+1


table :: Array Int Int
table = runSTArray $ do
    arr <- newArray (2,m) 0
    forM_ [2..m] $ \i -> writeArray arr i i
    forM_ (takeWhile (\i -> i*i < m) [2..]) $ \i -> do
        arri <- readArray arr i
        when (arri >= i)$
            forM_ (takeWhile (\j -> i*j < m) [i..]) $ \j -> do
                v <- readArray arr (i*j)
                when (v == i*j) $ writeArray arr (i*j) i
    return arr

primeFactor :: Int -> [Int]
primeFactor 1 = []
primeFactor n = if (null prev || head prev /= p) then p:prev else prev
    where p = table ! n
          prev = primeFactor (n `div` p)

Measured memory_bytes: 332644
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const ll inf = 1e18 ; 
const int MxN = 300005; 
const ll mod = 1e9+7 ; 
const int MOD = 998244353 ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}
ll power(ll a , ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
			res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res%MOD;
}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============
 

string s ; 
int n ; 

bool solve(int k) {
	bool ok = 1, ok2 = 1 ; 
	rep(i,0,n) {
		if(i >= k || i + k < n)
			continue ; 
		if(s[i] == '0')
			ok = 0 ; 
		else
			ok2 = 0 ;
	}
	return (ok||ok2) ; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 
	
	cin >> s ; 
	n = s.size() ;
	int l = 1 ; 
	int r = n ; 
	int ans = 0 ; 

	while(l <= r) {
		int mid = (l+r)/2 ; 
		if(solve(mid)) {
			ans = max(ans, mid) ; 
			l = mid + 1 ; 
		} else {
			r = mid - 1 ; 
		}
	}
	
	cout << ans ;

	cerr <<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
	return 0 ; 
}


Measured memory_bytes: 3928
n, a, b = map(int, input().split())
s = input()
ans = []
a_b_cnt = 0
b_cnt = 0
for i in range(n):
    if s[i] == 'a' and 0 < a + b:
        print('Yes')
        a -= 1
    elif s[i] == 'b' and 0 < a + b and 0 < b:
        print('Yes')
        b -= 1
    else:
        print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

int ordnum(int n)
{
    int ret = 0;
    while (n != 0)
    {
        ret++;
        n /= 10;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> h(n, 0);
    rep(i, n) cin >> h[i];

    int cmax = -1;
    bool minus = false;
    rep(i, n)
    {
        if (cmax <= h[i])
        {
            cmax = h[i];
        }
        else
        {
            if (cmax <= h[i] + 1)
            {
                cmax = h[i] + 1;
            }
            else
            {
                cout
                    << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Long N = scanner.nextLong();
        Long K = scanner.nextLong();
        Long R1 = N % K;
        Long R2 = Math.abs(R1 - K);

        System.out.println(Math.min(R1,R2));
    }
}


Measured memory_bytes: 35524
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    vector<char> retu(6);
    vector<int> ans(6);
    for (int i = 0; i < 6; i++) {
        cin >> retu.at(i);
        ans.at(i) = retu.at(i);
    }
    ans.at(0) = retu.at(5);
    ans.at(1) = retu.at(4);
    ans.at(2) = retu.at(3);
    ans.at(3) = retu.at(2);
    ans.at(4) = retu.at(1);
    ans.at(5) = retu.at(0);
    string anss = "YES";
    for (int j = 0; j < 6; j++) {
        if (retu.at(j) != ans.at(j)) {
            anss = "NO";
        }
    }
    cout << anss << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
c2 = 0
c4 = 0
for i in range(N):
    if a[i]%4 == 0:
        c4 += 1
    elif a[i]%2 == 0:
        c2 += 1
f = c4 * 2 + 1
if f >= N or f + c2 - 1 >= N:
    print("Yes")
else:
    print("No")

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

int gcd(int a, int b){
  if(a < b){
    int temp = a;
    a = b;
    b = temp;
  }
  int r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(void){
  int n, x;
  vector<int> xx(100000);
  cin >> n >> x;

  for(int i = 0; i < n; i ++){
    cin >> xx.at(i);
  }

  vector<int> sub(99999);
  if(n == 1){
    cout << abs(x - xx.at(0)) << endl;
  }
  else{
    for(int i = 0; i < n-1; i ++){
      sub.at(i) = abs(xx.at(i) - xx.at(i+1));
    }

    vector<int> sub_a(100000);
    for(int i = 0; i < n; i ++){
      sub_a.at(i) = abs(xx.at(i) - x);
    }

    int g = sub.at(0);
    for(int i = 1; i < n-1; i ++){
      g = gcd(g, sub.at(i));
    }

    vector<int> res(100000);
    int i;
    for(i = 0; i < n-1; i ++){
      res.at(i) = gcd(g, sub_a.at(i));
    }

    cout << *max_element(res.begin(), res.begin() + i) << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = NextInt;
        Point[] red = Enumerable.Range(0, n).Select(_ => new Point() { Y = NextInt, X = NextInt }).OrderBy(x => x.X).ToArray();
        List<Point> blue = Enumerable.Range(0, n).Select(_ => new Point() { Y = NextInt, X = NextInt }).OrderBy(x => x.X).ToList();
        var res = 0;
        for (int i = red.Length - 1; i >= 0; i--)
        {
            var cands = blue.Where(x => red[i].X < x.X && red[i].Y < x.Y).ToArray();
            if (cands.Length == 0) continue;
            var pair = cands.OrderBy(x => x.Y).First();
            blue.Remove(pair);
            res++;
        }
        Console.WriteLine(res);
    }
}

class Point
{
    public int Y;
    public int X;
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


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

int main() {
  int N;
  int A[100];
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  
  sort(A,A+N);
  
  cout << A[N-1]-A[0] << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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, x;
	cin >> n >> x;

	vector<int> a(n);

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

	sort(a.begin(), a.end());

	int i = 0;
	int ans = 0;
	while (x >= 0 && i < n){
		if (x == 0){
			break;
		}

		if (x - a[i] < 0){
			break;
		}

		x -= a[i];
		ans++;
		i++;

		if (i == n && x > 0){
			ans--;
		}
	}

	cout << max(ans, 0) << endl;
} 


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  vector<int> A(3);
  int x;
  cin >> A[0] >> A[1] >> A[2] >> x;
  int count = 0;
  loop(i,0,A[0]+1) loop(j,0,A[1]+1) loop(k,0,A[2]+1) {
    count += 500*i + 100*j + 50*k == x;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A % B == 0){
    cout << -1 << endl;
    return 0;
  }
  else {
    cout << A << endl;
  }
  }
  


Measured memory_bytes: 256
#!/usr/bin/env python3
#import sys; sys.stdin=open('input_file.txt')
#------------------------------------------
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    if A[i]%2 == 0 and A[i]%3!=0 and A[i]%5!=0:
        print('DENIED')
        break
else:
    print('APPROVED')


Measured memory_bytes: 2940
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]

x, y = map(int, input().split())

if (x in g1 and y in g1) or (x in g2 and y in g2):
    print("Yes")
else:
    print("No")


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

#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c <= (a + b)) {
    cout << "No" << endl;
    return 0;
  }

  ll l = 4 * a * b, r = (c - (a + b)) * (c - (a + b));
  if (l < r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(1000000)
N = int(input())
graph = [[] for _ in range(N+1)]
for i in range(1, N):
    tmpa, tmpb, tmpc = map(int, input().split())
    graph[tmpa].append((tmpb, tmpc))
    graph[tmpb].append((tmpa, tmpc))

Q, K = map(int, input().split())
question = [[] for _ in range(Q+1)]
for i in range(1, Q+1):
    question[i] = list(map(int, input().split()))

#print(graph)
#print(question)
seen = [False] * (N+1)
dist = [0] * (N+1)
#Kからdfs
def dfs(here, seen, kyori):
    seen[here] = True
    dist[here] = kyori
    #print(f"here:{here} kyori:{kyori}")
    for node in graph[here]:
        nextkyori = kyori
        if not seen[node[0]]:
            nextkyori += node[1]
            dfs(node[0], seen, nextkyori)

dfs(K, seen, 0)
for quest in question[1:]:
    print(dist[quest[0]] + dist[quest[1]])


Measured memory_bytes: 157868