akhauriyash/Code-Regression huggingface dataset:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()

# N // 2個の整数をどの２箇所も連続しないように選ぶ
# 和の最大値を求めよ

# 通りの数は？　まあまあ多い
# 偶数の場合
# 始点がA[1]なら１通りに定まる
# 始点がA[0]なら?
# 次に3個先を取ると1通りに定まる
# 次に2個先を取り、その次に3個先を取ると1通りに定まる

# dp[i][j]: i回目までに3つ飛ばしをj回使った
# 長さが偶数なら1回まで使える
if N % 2 == 0:
    dp = [[-float('inf')] * 2 for i in range(N)]
    dp[0][0] = A[0]
    dp[1][0] = A[1]
    for i in range(2, N):
        for j in range(1, -1, -1):
            if j == 0:
                dp[i][j] = max(dp[i][j], dp[i - 2][j] + A[i])
            elif j == 1 and i - 3 >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 2][j] + A[i])
            if i - 3 >= 0 and j - 1 >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 3][j - 1] + A[i])
    # 0個飛ばしdp[-2]:奇数個目だけ 0個飛ばしdp[-1]:偶数個目だけ 1個飛ばしdp[-1]
    print(max(dp[-2][0], dp[-1][0], dp[-1][1]))
# 長さが奇数なら2回まで使える
else:
    dp = [[-float('inf')] * 3 for i in range(N)]
    dp[0][0] = A[0]
    dp[1][0] = A[1]
    for i in range(2, N):
        for j in range(2, -1, -1):
            if j == 0:
                dp[i][j] = max(dp[i][j], dp[i - 2][j] + A[i])
            elif j >= 1 and i - 3 >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 2][j] + A[i])
            if i - 3 >= 0 and j - 1 >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 3][j - 1] + A[i])
    opt_1 = [A[i] for i in range(N) if i % 2 == 0]
    opt_2 = [A[i] for i in range(N) if i % 2 == 1]
    # 2個飛ばしならdp[-1]のが該当
    # 1個飛ばしならdp[-1], dp[-2]のが該当
    # 0個飛ばしは奇数個目だけ - その中の最小値、偶数個目だけ
    print(max(dp[-1][2], dp[-1][1], dp[-2][1], sum(opt_1) - min(opt_1), sum(opt_2)))

Measured memory_bytes: 149308
#include <bits/stdc++.h>
using namespace std;
#define B begin()
#define E end()
#define F first
#define S second
#define pub push_back
#define mkp make_pair
#define migmig ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long double ld;
typedef long long ll; 
typedef vector<ll> vll;
typedef map<ll,ll> mll;
const ll N=1e5+5;
ll n, k, sum, l, x, m, i, a[N], ans;
int main(){
	cin>> n;
	for(ll i=0; i<n; i++){
		cin>> a[i];
	}
	x = 2;
	ans = a[0] - 1;
	for(ll i=1; i<n; i++){
		ans += (a[i] - 1) / x;
		if(a[i] == x)
          x++;
	}
	cout<<ans;
}











Measured memory_bytes: 4424
import sys

N, K = map(int, input().split())
s = input() + "#"

pre, cons, comp = '#', 0, [(0, -1)]
for i in range(len(s)):
    if pre != '#' and pre != s[i]:
        if cons > 0:
            print(cons, s[i-1], file=sys.stderr)
            comp.append((cons, s[i-1]))
            cons = 1
    else:
        cons += 1

    pre = s[i]

acc = [0 for _ in range(len(comp))]
for i in range(1, len(comp)):
    acc[i] = acc[i-1] + comp[i][0]

ans = 0
for i in range(len(comp) - 1):
    lim = len(comp) - 1
    if comp[i+1][1] == '1':
        lim = min(lim, i + 2*K + 1)
    else:
        lim = min(lim, i + 2*K)
    print("i = {}, lim = {}".format(i, lim), file=sys.stderr)
    ans = max(ans, acc[lim] - acc[i])

print(ans)


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    map<string, int> st;
    int n;
    cin>>n;
    rep(i, n)
    {
        string temp;
        cin >> temp;
        st[temp]++;
    }
    cout << "AC x " << st["AC"] << endl;
    cout << "WA x " << st["WA"] << endl;
    cout << "TLE x " << st["TLE"] << endl;
    cout << "RE x " << st["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
#define vi vector<ll>
#define umap unordered_map
//rows indicate maximum weight - row 0 means 0 max weight...
//column j indicates maximum possible value for items [0,j]
umap<ll,vi> max_value_for_weight;
vi weights, values;

ll find_max_value(int last_item_index, ll max_weight)
{
	if (max_weight == 0)
		return 0;
	else if (last_item_index == 0)
	{
		if (max_weight >= weights[0])
			return values[0];
		else
			return 0;
	}

	if (max_value_for_weight.find(max_weight) != max_value_for_weight.end() &&
		!max_value_for_weight[max_weight].empty() &&
		max_value_for_weight[max_weight][last_item_index] > -1)
		return max_value_for_weight[max_weight][last_item_index];

	ll value_without_item = find_max_value(last_item_index - 1, max_weight);
	if (weights[last_item_index] > max_weight) //Item doesn't fit in the knapsack
	{
		if (max_value_for_weight[max_weight].empty())
			max_value_for_weight[max_weight] = vi(weights.size(),-1);
		
		max_value_for_weight[max_weight][last_item_index] = value_without_item;
		return value_without_item;
	}

	ll value_with_item = find_max_value(last_item_index - 1, max_weight - weights[last_item_index]) + values[last_item_index];

	if (max_value_for_weight[max_weight].empty())
		max_value_for_weight[max_weight] = vi(weights.size(),-1);
	max_value_for_weight[max_weight][last_item_index] = max(value_without_item, value_with_item);
	return max(value_without_item, value_with_item);
}

int main()
{
	ios::sync_with_stdio(false);
	int no_items, max_weight; cin >> no_items >> max_weight;
	weights = vi(no_items); values = vi(no_items);
	for (size_t i = 0; i < no_items; i++)
	{
		cin >> weights[i] >> values[i];
	}

	cout << find_max_value(no_items - 1, max_weight);
	return 0;
}

Measured memory_bytes: 83492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MAXN   10000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    sieve();
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    set<int> s;
    ll fg=0;
    for(int i=0;i<n;i++)
    {
    	set<int> st;
    	vector <int> p = getFactorization(arr[i]);
    	for(int j=0;j<p.size();j++)
    	{
    		if(st.find(p[j])==st.end() && s.find(p[j])!=s.end())
    		{
    			fg=1;
    			break;
    		}
    		else
    		{
    			st.insert(p[j]);
    			s.insert(p[j]);
    		}
    	}
    	if(fg==1)
    	break;
    	
    }
    if(fg==0)
    {
    	cout<<"pairwise coprime";
    }
    else
    {
    	int gcd=arr[0];
    	for(int i=1;i<n;i++)
    	{
    		gcd=__gcd(arr[i],gcd);
    	}
    	if(gcd==1)
    	{
    		cout<<"setwise coprime";
    	}
    	else
    	{
    		cout<<"not coprime";
    	}
    }
	return 0;
}

Measured memory_bytes: 46636
using System;
using System.Linq;
using System.Reflection.Metadata.Ecma335;

namespace ABC170_a
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] vals = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();

            for(int i=0; i<5; i++) {
                if (vals[i] != i+1) {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


Measured memory_bytes: 28116
import java.io.*;
import java.util.*;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(in.readLine());
    
    int N = Integer.parseInt(st.nextToken());
    int L = Integer.parseInt(st.nextToken());
    
    String[] s = new String[N];
    
    for (int i = 0; i < N; i++) {
        s[i] = in.readLine();
    }
    
    Arrays.sort(s);
    
    String l = "";
    
    for (int i = 0; i < N; i++) {
        l += s[i];
    }
    
    System.out.println(l);
  }
}

Measured memory_bytes: 23380
/*******************************************************************
 * 		Author : yash1402_										   *
 ******************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

void solve() {
	string s,t;
	cin >> s >> t;
	ll ans = t.size();
	for(int i=0;i+t.size()<=s.size();i++) {
		ll c = t.size();
		for(ll j=i,k=0;k<t.size();j++,k++) {
			if(s[j]==t[k]) c--;
		}
		ans = min(ans,c);
	}
	
	cout << ans << "\n";
}

int main() {
	ll T=1;
	//cin >> T;
	while(T--) {
		solve();
	}
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w, m, i;
    cin >> h >> w >> m;
    vector<ll> col (w + 1, 0), row(h + 1, 0), freq(h + 1, 0);
    vector<pair<ll, ll>> p(m);
    for(i = 0; i < m; i++) {
    	cin >> p[i].ff >> p[i].ss;
    	col[p[i].ss]++;
    	row[p[i].ff]++;
    }
    priority_queue<pair<ll, ll>> pq;
    for(i = 1; i <= w; i++) {
    	pq.push({col[i], i});
    }
    ll maxi = pq.top().ff;
    set<ll> pos;
    while(!pq.empty()) {
    	auto cur = pq.top();
    	pq.pop();
    	if(cur.ff == maxi) {
    		pos.insert(cur.ss);
    	} else {
    		break;
    	}
    }
    int n = pos.size();
    for(i = 0; i < m; i++) {
    	if(pos.find(p[i].ss) != pos.end()) {
    		freq[p[i].ff]++;
    	}
    }
    ll ans = 0;
    for(i = 1; i <= h; i++) {
    	ll cur_ans = row[i] + maxi;
    	if(freq[i] == n) {
    		cur_ans--;
    	}
    	ans = max(ans, cur_ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 33816
#include <bits/stdc++.h>
using namespace std;
    long long int n, q;
int main() {
    int n, k;
    string s;

    cin >> n >> s >> k;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    cout << s << endl;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {
  
}

int main() {
  
  ll a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;

  

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    sort(all(a));
    vector<pair<int,int>> v;
    rep(i,n-1){
        if(a[i]>a[n-1]/2) v.push_back({a[n-1]-a[i],a[i]});
        else v.push_back({a[i],a[i]});
    }
    sort(all(v));

    cout<<a[n-1]<<" "<<v[n-2].second<<endl;
}


Measured memory_bytes: 4692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S="E869120";
    int cnt=0;
    for(int i=0;i<N;i++){
        string T;cin>>T;
        if(S==T) cnt++;
    }
    cout<<cnt<<endl;
}





Measured memory_bytes: 3232
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class RMQ_Index{
	private:
	vp rmq;
	P Query_func(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return {inf,0};
		if(a<=l&&r<=b) return rmq[k];
		else{
			int mid=(l+r)/2;
			P vl=Query_func(a,b,k*2+1,l,mid);
			P vr=Query_func(a,b,k*2+2,mid,r);
			return (vl<vr)?vl:vr;
		}
	}
	public:
	int n;
	void Init(int n_){
		n=1;
		while(n<n_) n*=2;
		rmq=vp(2*n-1,{inf,0});
		for(int i=0;i<n;i++) rmq[i+n-1].second=i;
	}
	void Update(int k,int x){
		k+=n-1;
		rmq[k].first=x;
		while(k>0){
			k=(k-1)/2;
			P L=rmq[k*2+1],R=rmq[k*2+2];
			rmq[k]=L<R?L:R;
		}
	}
	P Query(int a,int b){
		return Query_func(a,b,0,0,n);
	}
};

int n;
RMQ_Index rmq[2];
vi a;

pair<P,P> f(int l,int r){
	if(l==r) return {{-inf,-inf},{0,0}};
	P p=rmq[l%2].Query(l/2,r/2),q=rmq[(l+1)%2].Query((a[p.first]+1)/2,(r+1)/2);
	return {{-p.first,-q.first},{l,r}};
}

void Open(pair<P,P> p){
	cout<<p.first.first<<' '<<p.first.second<<' '<<p.second.first<<' '<<p.second.second<<endl;
}

int main(){
	cin>>n;
	int N=n/2;
	priority_queue<pair<P,P> > q;
	rmq[0].Init(N);
	rmq[1].Init(N);
	a=vi(n+1);
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		rmq[i%2].Update(i/2,A);
		a[A]=i;
	}
	q.push(f(0,n));
	for(int i=0;i<N;i++){
		pair<P,P> tmp=q.top();
		q.pop();
		P A=tmp.first,B=tmp.second;
		int x=-A.first,y=-A.second,l=B.first,r=B.second,I=a[x],J=a[y];
		q.push(f(l,I));
		q.push(f(I+1,J));
		q.push(f(J+1,r));
		if(i) cout<<' ';
		cout<<x<<' '<<y;
	}
	cout<<endl;
}

Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string s;
    cin >> s;
    bool flag = true;
    rep(i, s.size()) {
        if (i%2) {
            if (s[i]!='i') flag = false;
        }
        else {
            if (s[i]!='h') flag = false;
        }
    }
    if (s.size()%2) flag = false;
    
    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	unordered_set<size_t> as;
	as.reserve(n);
	for (int i = 0; i < n; i++) {
		size_t a;
		cin >> a;
		auto it = as.find(a);
		if (it == as.end()) {
			as.insert(a);
		}
		else {
			as.erase(it);
		}
	}
	cout << as.size() << endl;
}

Measured memory_bytes: 4224
#include <cstdio>
int main()
{
	int a,b,c=1;
	scanf("%d %d",&a,&b);
    if(a>0)
    	printf("Positive");
    if(a<=0&&b>=0)
    	printf("Zero");
    if(b<0)
    {
    	if((b-a)%2==0)
    		printf("Negative");	
		else
			printf("Positive");
	}
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int h,w; cin>>h>>w;
  int ch,cw; cin>>ch>>cw; --ch; --cw;
  int dh,dw; cin>>dh>>dw; --dh; --dw;
  vector<string> s(h);
  for(int i=0; i<h; ++i) cin>>s[i];
  vector<vector<bool>> p(h,vector<bool>(w,false)),r(h,vector<bool>(w,false));
  deque<long long> q;
  long long res=0;
  while(1){
    if((0<=ch)&&(ch<h)&&(0<=cw)&&(cw<w)){
      for(int a=max(0,ch-2); a<=min(h-1,ch+2); ++a)
        for(int b=max(0,cw-2); b<=min(w-1,cw+2); ++b){
          if((0<=a)&&(a<h)&&(0<=b)&&(b<w)) if(s[a][b]=='.'&&p[a][b]==false){
            if(abs(a-ch)+abs(b-cw)==1) q.push_front((res<<20)+(a<<10)+b);
            else if(r[a][b]==false){ q.push_back(((res+1)<<20)+(a<<10)+b); r[a][b]=true;}
          }
        }
      p[ch][cw]=true;
    }
    if(p[dh][dw]==true) break;
    if(q.empty()){ res=-1; break;}
    else{ res=q.front()>>20; ch=(q.front()&1047552)>>10; cw=(q.front()&1023); q.pop_front();}
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 5992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	xi := make([]int, n)
	for i := 0; i < n; i++ {
		xi[i] = nextInt()
	}

	ans := 100000000
	for p := 1; p <= 100; p++ {
		sum := 0
		for _, x := range xi {
			sum += (x - p) * (x - p)
		}
		if sum < ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 1e9+7;
const int INF = 1e9+7;

int n, m;
string g[21];
bool vis[21][21];

bool valid(int x, int y){
	return 0<=x && x<n && 0<=y && y<m && !vis[x][y] && g[x][y] == '.';
}

int bfs(int x, int y){
	int ans = 0;
	queue<pair<pii, int>> q;
	q.push({{x,y}, 0});
	while(!q.empty()){
		pii atual = q.front().F;
		//cout << atual.F << ' ' << atual.S << '\n';
		if(vis[atual.F][atual.S]){
			q.pop(); continue;
		}
		vis[atual.F][atual.S] = true;
		int d = q.front().S;
		q.pop();
		if(valid(atual.F+1, atual.S))
			q.push({{atual.F+1, atual.S}, d+1});
		if(valid(atual.F-1, atual.S))
			q.push({{atual.F-1, atual.S}, d+1});
		if(valid(atual.F, atual.S+1))
			q.push({{atual.F, atual.S+1}, d+1});
		if(valid(atual.F, atual.S-1))
			q.push({{atual.F, atual.S-1}, d+1});
		ans = max(ans, d);
	}
	return ans;
}

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

	cin >> n >> m;
	FOR(i, n) cin >> g[i];

	int ans = 0;
	FOR(i, n){
		FOR(j, m){
			if(g[i][j] == '.'){
				memset(vis, false, sizeof(vis));
				ans = max(ans, bfs(i, j));
			}
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    int K;
    scanf("%d", &K);
    string ans = "";
    
    // 2. 'ACL' を K回 繰り返し.
    rep(i, K) ans += "ACL";
    
    // 3. 出力.
    printf("%s\n", ans.c_str());
    return 0;
    
}

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



int main() {
        int n, limit; cin >> n >> limit;
        int w[n], v[n];
        long long dp[n][limit + 1];
        for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

        for (int i = 0; i < n; i++)
                for (int j = 0; j <= limit; j++) dp[i][j] = 0;

        for (int i = 0; i < n; i++) {
                for (int j = 0; j <= limit; j++) {
                        if (i) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
                        if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], (i ? dp[i - 1][j - w[i]] : 0) + v[i]);
                }
        }

        printf("%lld", dp[n - 1][limit]);
}

Measured memory_bytes: 81784
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N; ll W; cin >> N >> W;
   ll w[110], v[110]; rep(i, N) cin >> w[i] >> v[i];
   ll dp[110][100100]; //i - 1番目までの品を価値jで選んだ時の最小の重さの和
   rep(i, N + 1) {
       rep(j, 100100) {
           dp[i][j] = INF;
       }
   }
   fill(dp[0], dp[0] + 100100, INF); //選べないところはINFにしておいて遷移してきても無駄にする
   dp[0][0] = 0;
   rep1(i, N) {
       rep(j, 100100) {
           chmin(dp[i][j], dp[i - 1][j]);
           if(j >= v[i - 1]) chmin(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
       }
   }
   ll ans = 0;
   rep1(j, 100001) {
       if(dp[N][j] <= W) ans = j;
   }
   cout << ans << endl;
   return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    ll a, b1, b2;
    scanf("%lld %lld.%lld", &a, &b1, &b2);

    ll b = b1*100 + b2;
    ll ans = a * b / 100;

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

Measured memory_bytes: 3732
import java.util.Scanner;

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

		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();

		int count = 0;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			if (A >= H && B >= W) {
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 25320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    ll n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            if(a[j]>a[j+1]){
                ans++;
                swap(a[j],a[j+1]);
            }
        }
    }
    ans=(ans*k)%MOD;
    ll cnt[2001]={};
    for(int i=0;i<n;i++){
        cnt[a[i]]++;
    }
    for(int i=2;i<=2000;i++){
        ll s=cnt[i]*cnt[i-1];
        ll t=k*(k-1)/2;
        s%=MOD;
        t%=MOD;
        ans+=s*t;
        ans%=MOD;
        cnt[i]+=cnt[i-1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve(n, a, b, c, d, s):
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    for left, right in [(a, c), (b, d)]:
        for i in range(left, right):
            if s[i:i+2] == '##':
                return "No"
    if d < c:
        for i in range(b, d+1):
            if s[i-1:i+2] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

n, a, b, c, d = map(int, input().split())
s = input()
print(solve(n, a, b, c, d, s))


Measured memory_bytes: 3572
from collections import defaultdict as ddict
d = ddict(int)
n = int(input())
for i in range(1,n+1):
  for p in range(2,int(i**.5)+2):
    while i%p == 0:
      d[p] += 1
      i//=p
  if i>1:
    d[i] += 1
g = [2,4,14,24,74]
f = [0]*5
for x in d.values():
  for i in range(5):
    if x >= g[i]:
      f[i] += 1
ans = f[1]*(f[1]-1)//2*(f[0]-2) + f[3]*(f[0]-1) + f[2]*(f[1]-1) + f[4]
print(ans)

Measured memory_bytes: 3316
# coding: utf-8
# Your code here!
#matrixbがパターン
def check_match(matrixa, matrixb):
    arow=len(matrixa)
    acol=len(matrixa[0])
    brow=len(matrixb)
    bcol=len(matrixb[0])
    for i in range(arow-brow+1):
        for j in range(acol-bcol+1):
            flag=True
            for k in range(brow):
                for l in range(bcol):
                    if matrixa[i+k][j+l]!=matrixb[k][l]:
                        flag=False
                        break
                if not flag:
                    break
            if flag==True:
                return (i,j)
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
print("Yes"if check_match(A,B) else "No")
    

Measured memory_bytes: 3064
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	cin>>a>>b;
	vector<vector<char>> arr(a,vector<char>(b));
	vi rows(a),cols(b);
	REP(i,0,a-1) {
		REP(j,0,b-1) {
			char c;
			cin>>c;
			arr[i][j]=c;
			if(c=='.'){cols[j]++;rows[i]++;}
		}
	}
	REP(i,0,a-1) {
		if(rows[i]==b)continue;
		REP(j,0,b-1) {
			if(cols[j]==a)continue;
			cout<<arr[i][j];
		}
		cout<<"\n";
	}
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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


#include<iostream>
#include<math.h>
#include<string>
#include<vector>

/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : B - One out of Three
/// Method              : brute force
/// Date                : 19/2/2020
///****************************************************************************************************************************************///



///defines
///****************************************************************************************************************************************///
#define rep0(i,x)         for(int i=0; i<=x ;++i)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define lp(i,v)          for(int i=0;i<sizeof(v);++i)
#define lpi(i,j,n)       for(int i=(j);i>=(int)n;++i)
#define lpd(i,j,n)       for(int i=(j);i>=(int)n;--i)
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
///#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define rep1(i,x)        for(int i=1;i<x;++i)
#define rep2(i,x)        for(int i=2;i<x;++i)
#define RE               return
//#define LD               long double
#define all(v) ((v).begin()),((v).end())
///****************************************************************************************************************************************///



///****************************************************************************************************************************************///
const  int  N   = (int) 1e5+100;
const  int  M   = (int) 1e4+4;
const  int  INF = (int) 0x3f3f3f3f;
///const double ESP = 1e-7;
///const ll MOD=1e8+9;
///****************************************************************************************************************************************///



int a,b,c(0);


int main()
{
FasterIO;


cin>> a>>b>>c;
(a==b&& a!=c ) ? cout <<c : ((a==c&&a!=b) ? cout << b : (  (b==c&&b!=a) ? cout << a  : cout<<0));





RE0
;}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

INF = 10**18

class RMQ:
    def __init__(self, a):
        self.n = len(a)
        self.size = 2**(self.n - 1).bit_length()
        self.data = [INF] * (2*self.size-1)
        self.initialize(a)

    # Initialize data
    def initialize(self, a):
        for i in range(self.n):
            self.data[self.size + i - 1] = a[i]
        for i in range(self.size-2, -1, -1):
            self.data[i] = min(self.data[i*2 + 1], self.data[i*2 + 2])

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])

    # Min value in [l, r)
    def query(self, l, r):
        L = l + self.size; R = r + self.size
        s = INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

n, m = [int(item) for item in input().split()]
dist = [INF] * n
dist[0] = 0
rmq = RMQ(dist)
lrc = []
for i in range(m):
    l, r, c = [int(item) for item in input().split()]
    l -= 1; r -= 1
    lrc.append((l, r, c))
lrc.sort()

for l, r, c in lrc:
    min_dist = rmq.query(l, r+1)
    r_dist = rmq.query(r, r+1)
    if min_dist + c < r_dist:
        rmq.update(r, min_dist+c)

ans = rmq.query(n-1, n)
if ans == INF:
    print(-1)
else:
    print(ans)

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   /*vector<ll> v,v1;*/

    cin>>n;
    cout<<n*(n+1)/2<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    /*freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);*/

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
ll a, b, n;
ll cal(ll x) {
	return x % b * a / b;
}

signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> a >> b >> n;
	cout << cal(min(b-1, n)) << '\n';
//
//	ll l = 0, r = n, m;
//	while (l < r) {
//		m = l + r >> 1;
//		ll a = cal(m), b = cal(m+1);
//		if (a > b) l = m+1;
//		else r = m;
//	}
//	cout << cal(l) << '\n';
}



Measured memory_bytes: 3608
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a;
  int ln;
  long long n;
  string s;
  while(cin>>n&&n){
    s="";
    a=n<0;
    n=n>0?n:-n;
    for(i=0;n;i++){
      if(n%(long long)pow(10,i+1)){
	if((i+a)%2){
	  s+=10-n%(long long)pow(10,i+1)/(long long)pow(10,i)+'0';
	  n+=(long long)pow(10,i+1)-n%(long long)pow(10,i+1);
	}else{
	  s+=n%(long long)pow(10,i+1)/(long long)pow(10,i)+'0';
	  n-=n%(long long)pow(10,i+1);
	}
      }else
	s+='0';
    }
    ln=s.length();
    for(i=0;i<ln;i++)
      cout<<s[ln-i-1];
    cout<<endl;
  }
  return 0;
}

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

struct entry {
    int score, cost;

    entry() {}
    entry(int a, int b): score(a), cost(b) {}

    bool operator < (const entry& o) const {
        return score == o.score ? cost > o.cost : score < o.score;
    }

    bool operator > (const entry& o) const {
        return score == o.score ? cost < o.cost : score > o.score;
    }
};

constexpr int INF = 1 << 28;

int N, P[100];

constexpr int LIM = 50050;
entry dp[105][LIM];

entry solve() {
    for (int i = 0; i <= N; ++i) for (int j = 0; j < LIM; ++j)
        dp[i][j] = entry(-INF, INF);
    dp[0][0] = entry(0, 0);

    for (int i = 0; i < N; ++i) {
        if (P[i] % 1000 <= 500) {
            int r = P[i]%1000 == 0 ? INF : 500 - P[i]%1000;
            int s = 500 + P[i]%1000;
            for (int j = 0; j < LIM; ++j) {
                dp[i+1][j] = dp[i][j];
                if (j >= r)
                    dp[i+1][j] = max(dp[i+1][j], entry(dp[i][j-r].score + 1, dp[i][j-r].cost + P[i]));
                if (j+s < LIM)
                    dp[i+1][j] = max(dp[i+1][j], entry(dp[i][j+s].score + 1, dp[i][j+s].cost + P[i]));
            }
        } else {
            int r = P[i]%1000 - 500;
            for (int j = 0; j < LIM; ++j) {
                dp[i+1][j] = dp[i][j];
                if (j+r < LIM)
                    dp[i+1][j] = max(dp[i+1][j], entry(dp[i][j+r].score + 1, dp[i][j+r].cost + P[i]));
                if (j-(500-r) >= 0)
                    dp[i+1][j] = max(dp[i+1][j], entry(dp[i][j-(500-r)].score, dp[i][j-(500-r)].cost + P[i]));
            }
        }
    }

    entry ans(0, 0);
    for (int i = 0; i < LIM; ++i) {
        ans = max(ans, dp[N][i]);
    }

    return ans;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    while (true) {
        cin >> N;
        if (N == 0) break;
        for (int i = 0; i < N; ++i) cin >> P[i];
        entry ans = solve();
        cout << ans.score << " " << ans.cost << endl;
    }
    return 0;
}



Measured memory_bytes: 42696
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, a[111];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  int Cm = INF;
  
  for (int i = -100; i <= 100; i ++) {
    int C = 0;
    
    for (int j = 0; j < N; j ++)
      C += (a[j] - i) * (a[j] - i);

    Cm = std::min(C, Cm);
  }

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


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

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= b; ++i) {
    if (a * i % b == c) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

int main() {
  double N, K;
  cin >> N >> K;

  double result = 0;
  loop(1, N+1, i) {
    double score = K / i;
    if (score <= 1) {
      result += 1;
      continue;
    }
    int times = ceil(log2(score));
    result += 1.0/pow(2, times);
  }
  cout << fixed << setprecision(9) << result/N << endl;
}

Measured memory_bytes: 4260
N = list(map(int,list((input()))))

if len(N) == 1:
    print(N[0])
elif set(N[1:]) == set([9]):
    print(N[0] + (len(N) - 1) * 9)
else:
    ans = 0
    for i in range(len(N)):
        tmp = sum(N[:i]) + (N[i] - 1) + 9 * (len(N) - 1 - i)
        ans = max(ans, tmp)
    print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum=0,max=0,mi=0;
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int [n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<k;i++) {
			for(int j=0;j<n;j++) {
				if(max<a[j]) {
					max=a[j];
					mi=j;
				}
			}
			sum += max;
			max=0;
			a[mi]=0;
		}
		System.out.print(sum);
		sc.close();
	}
}

Measured memory_bytes: 23764
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    char a[3],b[3],c[3];
    cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<endl;
    
    
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int k,n=s.size(); cin>>k;
    set<string> S;
    vector<string> a;
    rep(i,n){
        string c="";
        rep(j,k){
            c=c+s[i+j];
            if(!(S.count(c))){
                a.push_back(c);
                S.insert(c);
            }
            if(i+j==n-1) break;
        }
    }
    sort(al(a));
    cout<<a[k-1]<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var A = my.GetIntArray(5);
		
		Array.Sort(A);
		Array.Reverse(A);
		
		my.WriteArray(A);
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
		private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
}

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x;
    else return ex(x*x,n/2);
};

int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    ll ans = k;
    ans *= ex(k-1,n-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main() {
	int n, k; while (cin >> n >> k) {
		if (!n && !k)return 0;
		string s[11];
		set<string>st;
		for (int i = 0; i < n; i++)cin >> s[i];
		if (k == 2) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i == j)continue;
					st.insert(s[i] + s[j]);
				}
			}
		}
		else if (k == 3) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i == j)continue;
					for (int p = 0; p < n; p++) {
						if (i == p || j == p)continue;
						st.insert(s[i] + s[j] + s[p]);
					}
				}
			}
		}
		else if (k == 4) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i == j)continue;
					for (int p = 0; p < n; p++) {
						if (i == p || j == p)continue;
						for (int q = 0; q < n; q++) {
							if (i == q || j == q || p == q)continue;
							st.insert(s[i] + s[j] + s[p] + s[q]);
						}
					}
				}
			}
		}
		cout << st.size() << endl;
	}
}

Measured memory_bytes: 3364
#include <stdio.h>

int main(void) {
  int donuts, dolls;
  scanf("%d", &dolls);

  if (dolls < 4 ) {
    printf("No");
    return 0;
  }

  for (donuts = 0; donuts*7 <= dolls; donuts++) {
    if ((dolls - donuts*7) % 4 == 0) {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  ll tmp;
  ll ans = 0;
  rep(i, 0, N){
    cin >> tmp;
    while(tmp%2==0){
      tmp/=2;
      ans+=1;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#pragma region Imports
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion
//cout<<"Case #"+to_string(tc+1)+": "+to_string(z)<<endl;
int main() {
  fio
  int n;
  ll k;
  in>>n>>k;
  ll a[n];
  ia(a,n)
  ll z[n+1][k+2];
  mem(z,0)
    z[0][1]=1;
    fb(i,n){
      fb(j,k)
        z[i][j+2]=(z[i][j+2]+z[i][j+1])%mod;
      fb(j,k+1){
        z[i+1][j+1]=((z[i][j+1]-z[i][max(0LL,j-a[i])]%mod)+mod)%mod;
      }
    }
  out<<z[n][k+1];
}

Measured memory_bytes: 79104