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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int d, t, s;
  cin >> d >> t >> s;

  if (updiv(d, s) <= t)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i, j, N;
	cin >> N;
	vector<int> num(N);
	for (i = 0; i < N; i++)
	{
		cin >> num[i];
	}
	vector<int> kouho(3);
	vector<int> cost(3);
	for (i = 0; i < 3; i++)
	{
		kouho[i] = accumulate(num.begin(), num.end(), 0) / N + i - 1;
	}
	for (i = 0; i < 3; i++)
	{
		int tmp = 0;
		for (j = 0; j < N; j++)
		{
			tmp += pow(kouho[i] - num[j], 2);
		}
		cost[i] = tmp;
	}
	cout << *min_element(cost.begin(), cost.end());
}

Measured memory_bytes: 3660
//
//  main.cpp
//  knapsack
//
//  Created by r on 7/12/17.
//  Copyright © 2017 r. All rights reserved.
//

#include <iostream>
using namespace std;

long long dp[110][100010];
long long v[1001];
long long w[1001];

long long N,W;


int main() {
    cin >> N >> W;
    for (long long i = 1; i<=N; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i<=N; i++) {
        for (int j = 0; j<100010; j++) {
            dp[i][j] = 100000000001;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i<=N; i++) {
        for (int j = 0; j<100010; j++) {
            if (j-v[i] >= 0) {
                dp[i][j] = min(dp[i][j], w[i]+dp[i-1][j-v[i]]);
            }
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
        }
    }
    int best = 0;
    for (int i = 0; i<100010; i++) {
        if (dp[N][i] <= W) {
            best = i;
        }
    }
    cout << best << endl;
    return 0;
}




Measured memory_bytes: 80128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Array.IArray

main :: IO ()
main = do
    _ <- getLine
    s <- BS.unpack <$> BS.getLine
    lr <- map ((\[a,b] -> (a,b)) . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines <$> BS.getContents
    mapM_ print $ solve s lr

solve :: String -> [(Int,Int)] -> [Int]
solve s = arr `seq` map (\(l,r) -> arr!(r-1) - arr!(l-1))
  where
    n = length s
    arr = listArray (0,n+1) (0:f 1 s) :: Array Int Int
    f :: Int -> String -> [Int]
    f _ []  = []
    f _ [_] = []
    f i (s1:s2:sx) =
        let x = if [s1,s2] == "AC" then 1 else 0
        in arr!(i-1) + x : f (i+1) (s2:sx)

Measured memory_bytes: 17916
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int t = in.nextInt();
        int s = in.nextInt();
        System.out.println(t*s>=d ? "Yes" : "No");
    }
}


Measured memory_bytes: 35640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long k;
  int i;
  scanf("%lld", &k);
  printf("50\n");
  for(i = 0; i < 50; i++){
    if(i) printf(" ");
    printf("%lld", (i < k%50 ? 100 : 49) + k/50 - k%50);
  }
  printf("\n");
}


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

int main() {
  ll x;
  cin >> x;
  int ans = 0;
  ans = (x/500)*1000+((x%500)/5)*5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);

    int a, b;
    a = sc.nextInt();
    b = sc.nextInt();

      if(a>b){

      System.out.println( "a > b" );

      }else if(a==b){

      System.out.println( "a == b" );

      }else{

      System.out.println( "a < b" );

      }

    } 
}


Measured memory_bytes: 26400
n=int(input())
arr=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n)]
dp[0]=arr[0]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=arr[i][j]+max(dp[i-1][k] for k in range(3) if k!=j)
print(max(dp[n-1]))

Measured memory_bytes: 47384
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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 digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

const int MAX = 5001;
const int NX = 2500;
ll dp[51][MAX] = {};
int main() {
	IOS;
	int n, a;
	cin >> n >> a;
	dp[0][NX] = 1;
	vector<ll> v(n);
	REP(i, n) {
		cin >> v[i];
		v[i] -= a;
	}
	FOR(i,1, n + 1) {
		ll y = v[i - 1];
		REP(j, MAX) {
			if (j - y < 0 || j - y >= MAX)dp[i][j] = dp[i - 1][j];
			else dp[i][j] = dp[i - 1][j] + dp[i - 1][j - y];
		}
	}
	dump(dp[n][NX] - 1);
}




Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
char a[100005],b[100005];
int main()
{
	cin>>a;
	
	int len=strlen(a);
	for(int i=0;i<len;++i)
	{
		int loc=len-i-1;
		b[loc]=a[i];
		if(b[loc]=='p') b[loc]='q';
		else if(b[loc]=='q') b[loc]='p';
		else if(b[loc]=='b') b[loc]='d';
		else if(b[loc]=='d') b[loc]='b';
	}
	for(int i=0;i<len;++i) 
	if(a[i]!=b[i]) {cout<<"No"<<endl; goto u;}
	cout<<"Yes"<<endl;
	u: ;
	return 0;
}

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

int main()
{
	int N;
	cin >>N;
	vector<int> vec(N);
	rep(i,N){
		cin >>vec.at(i);
	}

	int min = 200001;
	int sum = 0;
	rep(i,N){
		if(vec.at(i)<min){
			sum++;
			min = vec.at(i);
		}
	}
	cout <<sum <<endl;
}

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    a--;
    A[a]++;
  }

  for (int i = 0; i < N; i++) {
    if (K - (Q - A[i]) > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
from fractions import gcd


def make_prime_factors2(n):
    """自然数nの素因数を列挙した圧縮済みリストを出力する
    計算量：O(sqrt(N))
    入出力例：156 -> [(2, 2), (3, 1), (13, 1)]
    """
    prime_factors = []
    for k in range(2, int(n**0.5) + 1):
        cnt = 0
        while n % k == 0:
            cnt += 1
            n = n // k
        if cnt != 0:
            prime_factors.append((k, cnt))
    if n != 1:
        prime_factors.append((n, 1))
    return prime_factors


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

li = make_prime_factors2(gcd(a, b))
print(len(li) + 1)


Measured memory_bytes: 64748
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,k;
	cin>>n>>k;
	lvi a(n+1);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	lvvi dp(n+2,lvi(k+2,0));
	dp[n][0]=1;
	lvi prefix_row(k+2,0);
	for (int i = 0; i <=k; ++i)
	{
		prefix_row[i]=1;
	}
	for (ll i = n-1;i>=0; --i)
	{
		lvi new_prefix(k+2,0);
		for(ll j=0;j<=k;j++)
		{
			ll l=min(a[i],j);
			if(j-l==0) dp[i][j]=prefix_row[j];
			else dp[i][j]=(prefix_row[j]-prefix_row[j-l-1]+mod)%mod;
			if(j==0) new_prefix[j]=dp[i][j];
			else new_prefix[j]=(dp[i][j]+new_prefix[j-1])%mod;
		}
		prefix_row=new_prefix;
	}
	cout<<dp[0][k]<<endl;
	return 0;
}

Measured memory_bytes: 81776
fn main() {
    proconio::input! {
        a: i64,
        b: i64,
        c: i64,
    }
    if a % 2 == 0 || b % 2 == 0 || c % 2 == 0 {
        println!("0");
    } else {
        let mut v = vec![];
        v.push(((a / 2) * b * c - (a / 2 + a % 2) * b * c).abs());
        v.push(((b / 2) * a * c - (b / 2 + b % 2) * a * c).abs());
        v.push(((c / 2) * a * b - (c / 2 + c % 2) * a * b).abs());
        let min = v.iter().min().unwrap();
        println!("{}", min);
    }
}


Measured memory_bytes: 2112
D, G = (int(i) for i in input().split())
P = []
C = []
for a in range(D):
    pp, cc = (int(i) for i in input().split())
    P.append(pp)
    C.append(cc)

reslis = []
for i in range(2**D):
    su = 0
    num = 0
    for j in range(D):
        if i & 2**j:
            su += C[j] + P[j] * (j+1) * 100
            num += P[j]
        else:
            pass

    for j in range(D-1, -1 ,-1):
        if G - su <= 0:
            break
        if not i & 2**j:
            if G - su >  (P[j] - 1) * (j+1) * 100:
                su += (P[j] - 1) * (j+1) * 100
                num += P[j] - 1
            else:
                num += (G - su +  (j+1) * 100 - 1) // ( (j+1) * 100 )
                break
    else:
        continue
    reslis.append(num)

reslis.sort()
print(reslis[0])

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

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

  int n, m;
  deque<int> a;
  deque<int> b;
  deque<int> c;

  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    int anum;
    cin >> anum;
    a.push_back(anum);
  }

  for (int i = 0; i < m; i++) {
    int bnum, cnum;
    cin >> bnum >> cnum;
    b.push_back(bnum);
    c.push_back(cnum);
  }

  priority_queue<pair<int, int>> PQ;

  deque<int>::iterator it;

  for (it = a.begin(); it != a.end(); it++) {
    auto p = make_pair(*it, 1);
    PQ.push(p);
  }

  for (int i = 0; i < m; i++) {
    auto p = make_pair(c[i], b[i]);
    PQ.push(p);
  }

  long long sum = 0;

  for (int count = 0; count < n; count++) {
    auto p = PQ.top();
    PQ.pop();
    sum += p.first;

    auto tmpP = make_pair(p.first, p.second - 1);
    if (tmpP.second > 0) {
      PQ.push(tmpP);
    }
  }

  cout << sum << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, l;
  cin >> n >> l;

  vector<ll> a(n);
  rep(i, n) {
    a[i] = l + i;
  }

  ll min_d = INF;

  ll sum = accumulate(all(a), 0);
  rep(i, n) {
    if (abs(min_d) > abs(a[i])) {
      min_d = a[i];
    }
  }

  cout << (sum - min_d) << endl;

  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
blue_card_str = []

N.times do
	blue_card_str << gets.chomp
end

M = gets.to_i
red_card_str = []

M.times do
	red_card_str << gets.chomp
end

max = 0
blue_card_str.each do |str|
	blue_num = blue_card_str.count(str)
	red_num = red_card_str.count(str)

	max = blue_num - red_num > max ? blue_num - red_num : max
end

puts max


Measured memory_bytes: 1788
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
count = 0
(0..a).each do |l|
  (0..b).each do |m|
    (0..c).each do |n|
      count += 1 if 500 * l + 100 * m + 50 * n == x
    end
  end
end
puts count

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

int main() {
    ll n,m;
    std::cin >> n>>m;
    vector<ll> a(m);
    ll sum = 0;
    
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
        sum += a[i];
    }
    
    if(sum>n){
        std::cout << -1 << std::endl;
    }else{
        std::cout << n-sum << std::endl;
    }
    
    
}



Measured memory_bytes: 3652
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int p =0;
    for(int i = 1;i<=a;i++){
      p+=i;
    }
    System.out.println(p);
  }
}

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

int main(int argc, char* argv[]){
	int N;
  	cin >> N;
  	vector<long long> A, B, A_B;
  	for (int i = 0; i < N; i++) {
      long long tmpA, tmpB;
      cin >> tmpA >> tmpB;
      A.push_back(tmpA);
      B.push_back(tmpB);
      A_B.push_back(tmpA+tmpB);
    }
  	
  	vector<int> idx(N);
  	iota(idx.begin(), idx.end(), 0);
  	sort(idx.begin(), idx.end(),
         [&A_B](int i1, int i2){return A_B[i1]>A_B[i2];});
  	
  	long long Akou=0, Bkou=0; 	
  
  	for (int i = 0; i < N; i++) {
      if (i % 2 == 0)
        Akou += A[idx[i]];
      else
        Bkou += B[idx[i]];
    }
  	cout << Akou - Bkou;
  	return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=N;
  for(int i=0;i<N-1;i++){
    if(S[i]==S[i+1]){
      --ans;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    inf = 1 << 18
    dp = [inf]*(n+1)
    dp[0] = 0
    for i in range(n):
        dp[i+1] = min(dp[i+1], dp[i]+1)
        k = 1
        while i+6**k <= n:
            dp[i+6**k] = min(dp[i+6**k], dp[i]+1)
            k += 1
        k = 1
        while i+9**k <= n:
            dp[i+9**k] = min(dp[i+9**k], dp[i]+1)
            k += 1
    print(dp[n])


    




                
if __name__ == '__main__':
    main()

Measured memory_bytes: 9384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int f(int x) {
    if (x % 10 == 0)return x;
    else return x + (10 - x % 10);
}

int g(int x) {
    if (x % 10 == 0)return 10;
    else return x % 10;
}

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    cout << f(A) + f(B) + f(C) + f(D) + f(E) - (10 - min({ g(A) ,g(B),g(C),g(D),g(E) })) << endl;

    return 0;

}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
    };
    match n {
        1 => {
            println!("Hello World");
            return;
        }
        2 => {
            input! {
                a: usize,
                b: usize,
            };
            println!("{}", a + b);
        }
        _ => unreachable!(),
    }
}


Measured memory_bytes: 2076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var point = new Tuple<int, int>[n[0]];
        for(int i = 0; i < n[0]; i++)
        {
            var a = ReadLine().Split().Select(int.Parse).ToArray();
            point[i] = new Tuple<int, int>(a[0], a[1]);
        }
        var check = new Tuple<int, int>[n[1]];
        for(int i = 0; i < n[1]; i++)
        {
            var a = ReadLine().Split().Select(int.Parse).ToArray();
            check[i] = new Tuple<int, int>(a[0], a[1]);
        }
        for(int i = 0; i < n[0]; i++)
        {
            int temp = 0;
            for(int j = 1; j < n[1]; j++)
            {
                if(Abs(point[i].Item1 - check[j].Item1) + Abs(point[i].Item2 - check[j].Item2) <
                    Abs(point[i].Item1 - check[temp].Item1) + Abs(point[i].Item2 - check[temp].Item2))
                {
                    temp = j;
                }
            }
            WriteLine(temp + 1);
        }
    }
}


Measured memory_bytes: 18796
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> safe(N, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        safe[a] = false;
    }

    vector<int> p(N+1, 0);

    p[0] = 1;
    if (safe[1]) p[1] = 1;

    for (int n = 2; n <= N; ++n) {
        if (safe[n-1]) p[n] += p[n-1];
        if (safe[n-2]) p[n] += p[n-2];
        p[n] %= MOD;
    }
    cout << p[N] << endl;
}

Measured memory_bytes: 640
N = int(input())
ans = ''

i = 1
while True:
    if N <= 26**i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N%26)
            N //= 26
        break
    else:
        N -= 26 ** i
    i+=1
print(ans[::-1])

Measured memory_bytes: 9184
#include <iostream>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

int a, b;
int main() {
	cin >> a >> b;
	cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    ll n = SZ(s);
    ll ans = 0;
    ll cnt = 0;
    rep(i, n){
        if(s[i] == 'W'){
            ans += cnt;
        }else{
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
N=int(input())
C,S,F=map(list,zip(*[list(map(int,input().split())) for i in range(N-1)]))
r=[0]*N
for i in range(N-2,-1,-1):
    x=S[i]+C[i]
    for j in range(i+1,N-1):
        x=S[j]+C[j] if x<S[j] else -(-x//F[j])*F[j]+C[j]
    r[i]=x
print(*r,sep='\n')

Measured memory_bytes: 9168
#include<stdio.h>
#include<math.h>
#include<string.h>

int main(){
    int h,n,sum=0;
    scanf("%d%d",&h,&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(h<=sum){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
const int INF = 1e+8;
const int MAX_W = 20;
const int MAX_N = 8;

int dx[5] = {0,0,-1,1,0};
int dy[5] = {-1,1,0,0,0};
int w, h, n;
int num[MAX_N], g[MAX_N], d[MAX_N], s[MAX_N], e[MAX_N];
char c[MAX_W][MAX_W];
 
int place[256] = {0};
int sx, sy, max_t;
int memo[MAX_W][MAX_W][256][101] = {0};

struct State{
	int x, y, bits, t;
	State(int x_, int y_, int bits_, int t_){
		x = x_; y = y_; bits = bits_; t = t_;
	}
};

void debug(int bx, int by, int ax, int ay, int bits, int t){
	cout << "[debug]" << endl;
	cout << "t:" << t << " bits:";
	for(int i=0 ; i < n ; i++ ){
		cout << (( bits & (1<<i) )? "1" : "0");
	}
	cout << endl;
	cout << "place:" << place[bits] << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( ax == x && ay == y ){
				cout << 'P';
			}else if( bx == x && by == y ){
				cout << 'p';
			}else{
				cout << c[y][x];
			}
		}
		cout << endl;
	}
	cout << endl;
}

int solve(){
	// place[bits] := 商品の状態 bits の値引きの合計
	// あらかじめ商品の状態を表す任意の bits について値引きを計算しておく (2^n通り)
	for(int i=0 ; i < (1<<n) ; i++ ){
		place[i] = 0;
		for(int j=0 ; j < n ; j++ ){
			if( i & (1<<j) ){
				place[i] += d[j];
			}
		}
	}
	// memo[y][x][bits][t] := (x,y) の時刻t, 商品の状態bits のときの最大値引き
	// 初期化
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			for(int i=0 ; i < 256 ; i++ ){
				for(int t=0 ; t < 101 ; t++ ){
					memo[y][x][i][t] = 0;
				}
			}
		}
	}
	// キューは (今いる座標,商品の状態,時間) を保持
	queue<State> q;
	q.push( State(sx,sy,0,0) );
	
	int res = 0;
	while( !q.empty() ){
		int x = q.front().x;
		int y = q.front().y;
		int bits = q.front().bits;
		int t = q.front().t;
		q.pop();
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || w <= mx || h <= my ) continue;
			if( '0' <= c[my][mx] && c[my][mx] <= '9' ){
				int id = num[c[my][mx] - '0'];
				
				if( s[id] <= t && t < e[id] ){
					bits |= 1 << id;
				}
			}
		}
		if( memo[y][x][bits][t] == 0 ){
			memo[y][x][bits][t] = 1;
		}else{
			continue;
		}
		res = max(res,place[bits]);
		for(int i=0 ; i < 5 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || w <= mx || h <= my ) continue;
			if( c[my][mx] == '.' && t+1 <= max_t ){
				State next = State(mx,my,bits,t+1);
				q.push(next);
			}
		}
	}
	return res;
}

int main(){
	while( cin >> w >> h , w || h ){
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> c[y][x];
				if( c[y][x] == 'P' ){
					c[y][x] = '.';
					sx = x;
					sy = y;
				}
			}
		}
		cin >> n;
		max_t = 0;
		for(int i=0 ; i < n ; i++ ){
			cin >> g[i] >> d[i] >> s[i] >> e[i];
			num[g[i]] = i;
			max_t = max( max_t , e[i] );
		}
		int ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 46076
#include<stdio.h>
#include<vector>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int L=128,C=62;
vector<int> s[C*4+3];int diff,apr[C+1]={0};
static inline int decode(int x){return x<=26?64+x:(x<=52?96-26+x:48+x-52-1);}
static inline int ask(int u,int i,int j)
{
  int len=diff;
  printf("? ");rep(k,s[u].size()){len--;putchar(decode(s[u][k]));}len--;putchar(decode(s[u<<1][i]));
  rep(k,s[u<<1|1].size()-j){len--;putchar(decode(s[u<<1|1][k+j]));}puts("");fflush(stdout);
  int res;if(scanf("%d",&res)!=0)return res==len;else return -1;
}
static inline void solve(int u,int le,int ri)
{
  if(le==ri){s[u].resize(apr[le]);rep(i,apr[le]){s[u][i]=le;}return;}
  int mid=(le+ri)>>1;
  solve(u<<1,le,mid);solve(u<<1|1,mid+1,ri);
  for(int i=0,j=0;i<(int)s[u<<1].size()||j<(int)s[u<<1|1].size();)
  {
    if(i<(int)s[u<<1].size()&&(j==(int)s[u<<1|1].size()||ask(u,i,j))){s[u].push_back(s[u<<1][i]); i++;}
    else{s[u].push_back(s[u<<1|1][j]);j++;}
  }
}
int main(void)
{
  rep(i,C)
  {
    printf("? ");rep(j,L){putchar(decode(i+1));}puts("");fflush(stdout);
    int res;if(!scanf("%d",&res))return -1;
    apr[i+1]=L-res;
    diff+=L-res;
  }
  solve(1,1,C);
  printf("! ");rep(i,s[1].size())putchar(decode(s[1][i]));puts("");fflush(stdout);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<double> vec(n);
  
  for(int i = 0; i < n; i++){
    double v;
    cin >> v;
    vec.at(i) = v;
  }
  
  for(int i = 0; i < n - 1; i++){
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    double num;
    //末尾2つを足して2で割る
    num = (vec.at(vec.size() - 1) + vec.at(vec.size() - 2)) / 2;
    //末尾2つを消す
    vec.pop_back();
    vec.pop_back();
    //末尾にnumを追加
    vec.push_back(num); 
  }
  
  cout << vec.at(0) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;

int main(){
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

  int m, d;
  while( cin >> m >> d ){
    if( m == 0 || d == 0 ) break;

    int tmp = d;
    for(int i=0; i<m; i++) tmp += M[i];

    cout << w[tmp%7] << endl;
  }

  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

string sort_string(string &str);

vector<int> get_ordered_vec(int &n);

int main(){
    int n;
    cin >> n;
    vector<string> sorted_strs;
    for(int i = 0; i < n; ++i){
        string str;
        cin >> str;
        sorted_strs.emplace_back(sort_string(str));
    }

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

    size_t ans = 0;
    size_t match_len = 1;
    for(int i = 1; i < n; ++i){
        if(sorted_strs[i - 1] == sorted_strs[i]){
            match_len++;
        }else{
            ans += match_len * (match_len - 1) / 2;
            match_len = 1;
        }
    }

    ans += match_len * (match_len - 1) / 2;

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

string sort_string(string &str){
    vector<char> vec_char;
    for(int i = 0; str[i] != '\0'; ++i){
        vec_char.push_back(str[i]);
    }
    
    sort(vec_char.begin(), vec_char.end());
    string res = "";
    for(size_t i = 0; i < vec_char.size(); ++i){
        res += vec_char[i];
    }
    return res;
}

vector<int> get_ordered_vec(int &n){
    vector<int> res;
    for(int i = 0; i < n; ++i){
        res.push_back(i);
    }
    return res;
}

Measured memory_bytes: 4980
#include <iostream>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC115();
}

void ABC115(){
    int d;
    cin>>d;
    if(d==25)cout<<"Christmas"<<endl;
    if(d==24)cout<<"Christmas Eve"<<endl;
    if(d==23)cout<<"Christmas Eve Eve"<<endl;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int ans[100010];
int main(){
	int n,cur,maxv=-1;
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i];
	cur=n-1;
	ans[n-1]=n-1;
	for(int i=n-2;i>=0;i--){
		if(num[i+1]<=num[i])
			ans[i]=cur;
		else{
			cur=i;
			ans[i]=cur;
		}
	}
	for(int i=0;i<n;i++)
		maxv=max(maxv,ans[i]-i);
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		final int K = sc.nextInt();
    		int[] h = new int[N];
    		for (int i=0; i<N; i++) {
    			h[i] = sc.nextInt();
    		}
    		int[] costs = new int[N];


    		costs[0] = 0;
    		for (int i=1; i<N; i++) {
    			int minCost = Integer.MAX_VALUE;
    			for (int j=1; j<=K; j++) {
    				if (i-j >= 0) {
        				int tmpCost = costs[i-j] + Math.abs(h[i] - h[i-j]);
        				if (tmpCost < minCost) {
        					minCost = tmpCost;
        				}
    				}
    			}
    			costs[i] = minCost;
    		}
    		System.out.println(costs[N-1]);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 50320
#include <bits/stdc++.h>
#define P 1000000007

using namespace std;

int F[22][1 << 19], K[22][1 << 19], n, m, k, S[22][22];

void add(int& x, int y) {x = (x + y) % P;}

int main()
{
	memset(S, -1, sizeof S), scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= k; i++) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z), S[--x][--y] = z;
	}
	for(int i = 0; i < (1 << n - 1); i++)
		for(int lst = -1, j = n - 2; j >= 0; j--) {
			if((i >> j) & 1) lst = j;
			K[j][i] = i + (1 << j) - (lst != -1 ? 1 << lst : 0);
		}
	F[0][0] = 1;
	for(int O = 0; O < m; O++, memcpy(F[0], F[n - 1], sizeof F[0]))
		for(int T = 0; T < n - 1; T++) {
			memset(F[T + 1], 0, sizeof F[T + 1]);
			for(int i = 0; i < (1 << n - 1); i++) {
				if(S[O][T] != 1 && !((i >> T) & 1)) add(F[T + 1][i], F[T][i]);
				if(S[O][T] != 0) add(F[T + 1][K[T][i]], F[T][i]);
			}
		}
	int ans = 0;
	for(int i = 0; i < (1 << n - 1); i++) add(ans, F[n - 1][i]);
	return printf("%d\n", ans), 0;
}

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

int main(){
    
    int a,b,c;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op=='+'){
            c = a+b;
            cout << c << endl;
        }
        else if(op=='-'){
            c = a-b;
            cout << c <<endl;
        }
        else if(op=='*'){
            c = a*b;
            cout << c <<endl;
        }
        else if(op=='/'){
            c = a/b;
            cout << c <<endl;
        }
        else break;
    }
    return 0;
}


Measured memory_bytes: 3088
a_lst = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_lst = [int(input()) for _ in range(n)]

answer = 'No'
for i in range(3):
    count = 0
    for j in range(3):
        number = a_lst[i][j]
        if number in b_lst:
            count += 1

    if count==3:
        answer = 'Yes'
        break

if answer=='No':
    for i in range(3):
        count = 0
        for j in range(3):
            number = a_lst[j][i]
            if number in b_lst:
                count += 1

        if count==3:
            answer = 'Yes'
            break

if answer=='No':
    lu = a_lst[0][0]
    ru = a_lst[0][2]
    cen = a_lst[1][1]
    ld = a_lst[2][0]
    rd = a_lst[2][2]

    if lu in b_lst:
        if cen in b_lst:
            if rd in b_lst:
                answer = 'Yes'

    if ru in b_lst:
        if cen in b_lst:
            if ld in b_lst:
                answer = 'Yes'

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  int table[2'000'000];
  int lis[2'000'000];
  fill(lis, lis + 2'000'000, 0);
  fill(table, table + 2'000'000, 0);
  for(int i = 2; i < 2'000'000; i++){
    if(lis[i] == 0){
      lis[i] = 1;
      for(int j = 2; i * j < 2'000'000; j++){
        if(lis[i * j] == 0) lis[i * j] = i;
      }
    }
  }
  lis[2] = 1;
  lis[1] = 1;
  lis[0] = 1;
  bool flag = true;
  rep(i, n){
    int a;
    cin >> a;
    int j = a;
    while(1){
      int k = lis[j];
      if(table[k] && k != 1) flag = false;
      table[k]++;
      if(lis[j] == 1){
        if(table[j] && j != 1) flag = false;
        table[j]++;
      }
      if(k == 1) break;
      while(lis[j] == k || j == k) j /= k;
      if(j == 1) break;
    } 
  }
  if(flag){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  for(int i = 2; i < 2'000'000; i++){
    if(table[i] == n){
      cout << "not coprime" << endl;
      return 0;
    }
  }
  cout << "setwise coprime" << endl;
}
  

Measured memory_bytes: 19220
K, N = map(int, input().split())
A = list(map(int, input().split()))

d_max = 0
tmp = 0

for a in A:
    d = a - tmp
    d_max = max(d_max, d)
    tmp = a

d_max = max(d_max, K - A[-1] + A[0])

print(K - d_max)



Measured memory_bytes: 26420
s = input()
t = input()
p = {}
q = {}
for i in range(len(s)):
    if s[i] in p and p[s[i]] != t[i]:
        print('No')
        exit(0)
    if t[i] in q and q[t[i]] != s[i]:
        print('No')
        exit(0)
    p[s[i]] = t[i]
    q[t[i]] = s[i]
print('Yes')


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

int main() {
  string s;
  cin >> s;
  int n = s.size(), u = 1, v = 1;
  bool ok = true;
  if(s[0] != '1' || s[n - 1] != '0') ok = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) ok = false;
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n / 2 + 1) s[n / 2 + 1 + i] = '0';
  reverse(all(s));
  vector<pair<int, int>> g;
  rep(i, n - 1) {
    v++;
    g.push_back({u, v});
    if(s[i + 1] == '1') u = v;
  }
  for(auto p : g) cout << p.first << ' ' << p.second << '\n';
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
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; }

const ll MOD = 998244353;

ll modpow(ll a, ll n, int mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin>>N;
    vector<ll> D(N);
    ll maxd = 0;
    map<int, int> map;
    rep(i,N){
        cin>>D[i];
        map[D[i]]++;
        chmax(maxd, D[i]);
    }
    if(D[0] != 0||map[0]>1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 1;
    rep(i,maxd){
        ans *= modpow(map[i],map[i+1],MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n;
  cin>>n;
  int ans=0;
  if(n<=111)ans=111;
  else if(n<=222)ans=222;
  else if(n<=333)ans=333;
  else if(n<=444)ans=444;
  else if(n<=555)ans=555;
  else if(n<=666)ans=666;
  else if(n<=777)ans=777;
  else if(n<=888)ans=888;
  else if(n<=999)ans=999;
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
using System;

class Program {
  static void Main(string[] args) {
    int n = int.Parse(Console.ReadLine());
    string[] val = Console.ReadLine().Split();
    int odd = 0;
    for (int i = 0; i < n; ++i) {
      int a = int.Parse(val[i]);
      if (a % 2 == 1) {
        ++odd;
      }
    }

    if (odd % 2 == 0) {
      Console.WriteLine("YES");
    }
    else {
      Console.WriteLine("NO");
    }
  }
}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, K; cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  ll c = 0;
  for (int i = 0; i < K; i++) c += A.at(i);
  ll p = 0;
  for (int i = K; i < N; i++) if (A.at(i) > 0) p += A.at(i);
  ll score = max(c, 0LL) + p;
  for (int i = 0; i + K < N; i++) {
    if (A.at(i) > 0) p += A.at(i);
    if (A.at(i+K) > 0) p -= A.at(i+K);
    c += A.at(i+K) - A.at(i);
    score = max(score, max(c, 0LL) + p);
  }
  cout << score << endl;

  return 0;
}



Measured memory_bytes: 1024
#!/usr/bin/perl

my $s = <STDIN>;
$s =~ s/[^\d]+$//sio;
my ($k) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $r = '';
if( $s =~ /^[1]*([2-9])/o ){
  my $m = $&;
  my $d1 = $1;
  $r = ($k < length($m) ? '1' : $d1);
} else {
  $r = substr($s,$k-1,1);
}
print "$r\n";

exit(0);



Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int check(int v) {
    int ans;
    if(v > 0 || (v < 0 && abs(v)%2 == 0)) ans = 1;
    if(v < 0 && abs(v)%2 == 1) ans = -1;
    if (v == 0) ans = 0;
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;

    if(a <= 0 && b >= 0)cout << "Zero";
    else if(a > 0) cout << "Positive";
    else if(abs(a-b) % 2 == 0)cout << "Negative";
    else if(abs(a-b) % 2 == 1)cout << "Positive";

    return 0;
}

Measured memory_bytes: 256
def resolve():
    (N) = int(input())
    abcs = [list(map(int, input().split(" "))) for _ in range(N)]
    dps = [[0]*3 for _ in range(N)]
    dps[0] = abcs[0]

    for i in range(1, N):
        for j in range(3):
            dps[i][j] = max(dps[i-1][(j+1)%3]+abcs[i][j], dps[i-1][(j+2)%3]+abcs[i][j])

    print(max(dps[-1]))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 74072
#include <stdio.h>

void printCN(char c, int n)
{
 while(n>0){
  putchar(c);
  n--;
 }
}

int main()
{
 int sx, sy, tx, ty;
 scanf("%d%d%d%d", &sx, &sy, &tx, &ty);

 printCN('U', ty-sy);
 printCN('R', tx-sx);
 printCN('D', ty-sy);
 printCN('L', tx-sx);

 putchar('L');
 printCN('U', ty-sy+1);
 printCN('R', tx-sx+1);
 putchar('D');
 putchar('R');
 printCN('D', ty-sy+1);
 printCN('L', tx-sx+1);
 putchar('U');
 
 return 0;
}

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

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

       for(int x = a;x<=b;x++){
	      if(c%x != 0) continue;
	      i++;
       }

       cout<<i<<endl;

       return 0;
}

Measured memory_bytes: 3080
///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   █▀█─█──█──█▀█─█─█
///   █▄█─█──█──█▄█─█▄█
///   █─█─█▄─█▄─█─█─█─█

///   كُلُّ نَفْسٍ ذَآئِقَةُ الْمَوْت
///   Every soul shall taste death.

/// TODO::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;


#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(0);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)
//***********************************************  The END **********************************************************************************************************************************
using ll = long long;
const ll N = 1e5 + 1;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

vector < ll > e[N];

ll dp[N],node , edge , u , v;

ll recur ( ll node ){

  if ( e[node].size()==0 ) return 0;

  ll &ret = dp[node];

  if(~ret) return ret;

  ll mx = 0;
  for ( auto u : e[node] ){
      mx = max ( mx , 1 + recur( u ) );
  }

  return ret = mx;

}





int main()
{

  MOHAMMAD

  memset ( dp , -1 , sizeof dp );

 cin >> node >> edge;

 while ( edge-- ){
      cin >> u >> v;
      e[u].push_back(v);
 }

 ll len = 0;
 for ( ll i = 1 ; i<=node ; ++i ){
      len = max ( len , recur ( i ) );
 }

 cout << len  << "\n";

 return 0;

}


/*





  Alhamdulillah
*/



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

using namespace std;

vector<int> nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int K;
    cin >> K;
    cout << nums[K-1];
}

Measured memory_bytes: 256