akhauriyash/Code-Regression huggingface dataset:
// B - Palindrome-phobia
// https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> s;
  n = s.size();
  vlli d(26, 0);
  set<char> g;
  rep(i, 0, n)
  {
    for (char x = 'z'; x >= 'a'; --x)
    {
      if (s[i] == x)
      {
        d[count]++;
      }
      count++;
    }
    count = 0;
  }
  rep(i, 0, 26)
  {
    if (d[i] > 0 && 3 * (d[i] - 1) >= n)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 3772
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k[] = new int[n];
        int sum = 0;
        ArrayList<Integer> a = new ArrayList<>();
        int count = 0;
        for(int i = 0; i < n; i++){
        	k[i] = sc.nextInt();
            sum += k[i];
            for(int j= 0; j < k[i]; j++){
            	a.add(sc.nextInt());
            }
        }
        if(n == 1){
        	System.out.println(k[0]);
        }else{
        	for(int i = 1; i < m + 1; i++){
                int counta = 0;
            	for(int j = 0; j < sum; j++){
                	if(i == a.get(j)){
                    	counta++;
                    }
                }
                if(counta == n){
                	count++;
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 38720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    ll L, R;
    cin>>L>>R;
    ll ans=200200200;
    if(R-L >=2019){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=L;i<R;i++){
        for(ll j=i+1;j<=R;j++){
            ll tmp=i*j;
            tmp%=2019;
            ans=min(ans, tmp);
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
const int MAX = 1e5+10;
int a[MAX]={};
int main()
{
    int n,m;
    scanf("%d%d", &n,&m);
    int x,y;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d ", &x, &y);
        a[x]++;
        a[y]++;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]&1)
        {
           return printf("NO\n"), 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string s, t;
    cin >> s >> t;
    int ma = 0, mi = INF;
    sort(All(s));
    sort(t.rbegin(), t.rend());
    if(s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var x = parseInt(input[0].split(" ")[0]);
  var y = parseInt(input[0].split(" ")[1]);
  var z = parseInt(input[0].split(" ")[2]);
  var ans=0;
  ans=Math.floor((x-z)/(z+y));
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n;cin>>n;
    string s;cin>>s;
    {ll cnt=0;
    rep(i,n){
        if(s[i]=='(')cnt++;
        else cnt=max<ll>(0,cnt-1);   
    }
    rep(i,cnt)s.push_back(')');}
    // cout<<s<<endl;
    reverse(all(s));
    {ll cnt=0;
    rep(i,s.size()){
        if(s[i]==')')cnt++;
        else cnt=max<ll>(0,cnt-1);   
    }
    reverse(all(s));
    rep(i,cnt)s.insert(0,"(");
    }
    cout<<s<<endl;
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c;
	int t;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b){
		t = b;
		b = a;
		a = t;
	}
	if(b > c){
		t = c;
		c = b;
		b = t;
	}
	if(a > b){
		t = b;
		b = a;
		a = t;
	}
	printf("%d %d %d\n", a, b, c);
	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);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] a = new int[n];
		long sum = 0;
		for( int i=0; i<n ;i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int count=0;
		for( int i=0 ; i<n ; i++ ) {
			if( a[i]* 4 * m >=sum )count++;
		}
		
		if ( count >= m )
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, cnt = 0;
	cin >> n;
	int a[n];
	for (auto &i:a) cin >> i;
	for (int i=1;i<n-1;i++){
		if ((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i+1] < a[i] && a[i] < a[i-1])){
			cnt ++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = []
B = []
C = []
for _ in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

dp = [[0]*N for _ in range(3)]

dp[0][0] = A[0]
dp[1][0] = B[0]
dp[2][0] = C[0]

for i in range(1, N):
    dp[0][i] = max(dp[1][i-1], dp[2][i-1])+A[i]
    dp[1][i] = max(dp[2][i-1], dp[0][i-1])+B[i]
    dp[2][i] = max(dp[0][i-1], dp[1][i-1])+C[i]

ans = max(dp[0][-1], dp[1][-1], dp[2][-1])
print(ans)


Measured memory_bytes: 26788
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    ll v=0;
    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%3==0||a[i]%5==0){

            }
            else{
                v++;
            }
        }
    }
    if(v==0){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }
    
}

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;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int n;
  cin >> n;
  cout << 800 * n - 200 * int(n/15) << endl;
}


Measured memory_bytes: 256
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
    public function nextString() {
        return (string)$this->next();
    }
}

$sc = new Scanner();
$s = $sc->nextString();

if (strlen($s) === 3) {
    echo strrev($s);
} else {
    echo $s;
}

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

bool binarySearch(int A[], int n, int key) {
    int left = 0;
    int right = n-1;
    int mid;
    while(left <= right) {
        mid = (left + right)/2;
        if(key == A[mid]) return true;
        else if(key < A[mid])right = mid - 1;
        else if(key > A[mid])left = mid + 1;
    }
    return false;
}

int main() {
    int n, S[100010], q, key, sum = 0;
    cin>>n;
    for(int i=0; i<n; i++)scanf("%d", &S[i]);

    sort(S, S+n);

    cin>>q;
    for(int i=0; i<q; i++) {
        scanf("%d", &key);
        if(binarySearch(S,n,key))sum++;
    }
    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
#define to_digit(c) c-'0';
int main()
{
ll n; cin >> n;
ll arr[n];
rep(0,n)
cin >> arr[i];
ll ans = 0;
for(ll i = 0; i < n-2; i++)
{
    for(ll j = i+1; j < n-1; j++)
    {
        for(ll k= j + 1; k < n; k++)
        {
            if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k])
            if((arr[i]+arr[j] > arr[k]) && (arr[i] + arr[k] > arr[j]) && (arr[k] + arr[j] > arr[i]))
            {
                //cout << i << " " << j << " " << k << endl;
                ans++;
            }
        }
    }
}
cout << ans << endl;
return 0;
}

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

int main() {
  char X,Y;
  cin >>  X >> Y;
  if ( X < Y ) cout << "<" << endl;
  else if ( X == Y ) cout << "=" << endl;
  else cout << ">" << endl;
  return 0;
}


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

int main() {

  int K; cin >> K;
  if (K % 2 == 0) {
    cout << K * K / 4 << endl;
  }
  else {
    cout << (K + 1) * (K - 1) / 4 << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a + b == 3) cout << "3" << endl;
    else if(a + b == 4) cout << "2" << endl;
    else if(a + b == 5) cout << "1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, C;
      cin >> A >> B >> C;
     
      if (A+B+C <= 21) {
        cout << "win" << endl;
      }
      else {
        cout << "bust" << endl;
      }
    }

Measured memory_bytes: 256
while 1:
    n,x=map(int,raw_input().split())
    conbi = 0
    if n == 0 and x == 0:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if (i + j + k) == x:
                    conbi = conbi + 1
    print conbi

Measured memory_bytes: 6428
import sys
readline = sys.stdin.readline
from operator import itemgetter
class UnionFind:
    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n
    def find_root(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_root(self.p[x])
        return self.p[x]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)
        if u == v: return
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
        else:
            self.p[v] = u
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1
n, m = map(int, readline().split())
edges = []
for _ in [0] * (m):
    s, t, w = map(int, readline().split())
    edges.append((s, t, w))
edges.sort(key=itemgetter(2), reverse=True)
uf = UnionFind(n)
ans = 0
for _ in [0] * (n - 1):
    while edges:
        s, t, w = edges.pop()
        if not uf.same(s, t):
            uf.unite(s, t)
            break
    ans += w
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll lb = 1e9, ub = 0;
    while (lb - ub > 1)
    {
        ll mid = (lb + ub) / 2;
        bool f = true;
        // 1~mid
        vector<P> v;
        v.push_back(P(1, a[0]));
        for (int i = 1; i < n; i++)
        {
            if (a[i] > a[i - 1])
            {
                v.push_back(P(1, a[i] - a[i - 1]));
                continue;
            }
            ll sum = a[i - 1];
            while (sum > a[i])
            {
                P last = v.back();
                v.pop_back();
                if (sum - a[i] >= last.second)
                {
                    sum -= last.second;
                    continue;
                }
                last.second -= sum - a[i];
                assert(last.second > 0);
                sum = a[i];
                v.push_back(last);
            }
            assert(sum == a[i]);
            ll cnt = 0;
            while (!v.empty() && v.back().first == mid)
            {
                cnt += v.back().second;
                v.pop_back();
            }
            if (v.empty())
            {
                f = false;
                break;
            }
            P last = v.back();
            v.pop_back();
            if (last.second == 1)
            {
                last.first++;
                v.push_back(last);
            }
            else
            {
                assert(last.second > 1);
                v.push_back(P(last.first, last.second - 1));
                v.push_back(P(last.first + 1, 1));
            }
            if(cnt) v.push_back(P(1, cnt));
            if (a[i] == 1)
            {
                // cout << "!" << i << endl;
                // for (auto p : v)
                //    cout << p.first << " " << p.second << endl;
            }
        }
        // cout << mid << ": ";
        // cout << (f ? "YES" : "NO") << endl;
        if (f)
            lb = mid;
        else
            ub = mid;
    }
    cout << lb << endl;
}


Measured memory_bytes: 9428
import java.util.Scanner;                                                                                                                          

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if(a < b && b < c) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        } 
    } 
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	string S;
	int K;

	cin >> S >> K;
	int N = S.length();

	set<string> v;
	rep(i,N) rep(k,K) if( i + k < N ){
		v.insert(S.substr(i,k+1));
	}

	string ans;
	for(auto t: v){
		K--;
		if(K == 0){
			ans = t;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <iostream> 
#include <vector> 
#include <string>
#include <algorithm> 
#include <stack> 
#include <set>

using namespace std;

int	main()
{
	int si;
	string s;
	cin >> s;
	si = s.size();
	for (int i = 0; i < si; i += 2)
	{
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 512
import Foundation

// 1
//let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let R = Int(split[1])!

if N < 10 {
  print(R + (100 * (10 - N)))
} else {
  print(R)
}
// 1 2 3 4 5
//let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

Measured memory_bytes: 7908
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 1000005



int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
//   freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
   int n,m;
   cin>>n>>m;
   cout<<n*m;
   return 0;
}


Measured memory_bytes: 3648
//
// Created by Harshit on 21-08-2020.
//
#include "bits/stdc++.h"
using namespace std;
const int modd=1e9+7;
int main(){
    int H,W;
    char x;
    cin>>H>>W;
    vector <vector <bool>> grid(H,vector <bool> (W,false));
    //vector <int > dp(W,0);
    //vector <int> new_dp(W,0);
    //dp[0]=1;
    vector <vector <int> > dp(H,vector<int> (W,0));
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>x;
            if(x=='#'){
                grid[i][j]=true;
            }
        }
    }
    /*
    for(int i=0;i<H;i++){
        new_dp.assign(W,0);
        for(int j=0;j<W;j++){
            if(grid[i][j])
                dp[j]=0;
            else {
                if(j+1<W)
                    dp[j + 1] += dp[j];
                if(i+1<H)
                    new_dp[j] += dp[j];
            }
        }
        dp=new_dp;
    }
    for(int j=0;j<W;j++){
        if(j==0 && grid[H-1][j])
            dp[j]=0;
        if(j!=0 && !grid[H-1][j-1])
            dp[j]+=dp[j-1];
    }*/
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(grid[i][j])
                continue;
            if(i==0){
                if(j!=0 && grid[i][j-1]==false){
                    dp[i][j]=dp[i][j-1]%modd;
                }
            }
            else{
                if(!grid[i-1][j])
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%modd;
                if(j>0 && !grid[i][j-1])
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%modd;
            }
        }
    }
    cout<<dp[H-1][W-1]<<endl;

}



Measured memory_bytes: 7676
#include <iostream>
using namespace std;
int dp[2][3]={},ar[100001][3]={};
int main()
{
	int n;cin>>n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<3;j++) {cin>>ar[i][j];}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<3;j++)
		{
			dp[i%2][j] = -1;
			for (int k=0;k<3;k++)
			{
				if (j!=k)
				{
					dp[i%2][j] = max(dp[(i-1)%2][k],dp[i%2][j]);
				}
			}
			dp[i%2][j] += ar[i-1][j];
			//cout<<i<<" "<<j<<" "<<dp[i%2][j]<<"\n";
		}
	}
	cout<<max(dp[n%2][0],max(dp[n%2][1],dp[n%2][2]))<<"\n";
	return 0;
}

Measured memory_bytes: 1408
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [int(w) for w in input().split()]
    wt = [0] * (N + 1)
    for i, w in enumerate(W):
        wt[i+1] = wt[i] + w
    minD = 1000000
    for i in range(N):
        minD = min(minD, abs(wt[i+1] - (wt[N] - wt[i+1])))
    print(minD)

    return 0

if __name__ == "__main__":
    solve()

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

int main(){
  int n;

  while(cin >> n, n){
    int mn = INT_MAX;
    int mx = -1;

    for(int i = 0; i < n; i++){
      int sum = 0;
      for(int j = 0; j < 5; j++){
        int x;
        cin >> x;
        sum += x;
      }
      mn = min(mn, sum);
      mx = max(mx, sum);
    }
    cout << mx << " " << mn << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	int i,len,num,count;
	int flag,temp;
	while(cin>>s)
	{
		len=s.size();
		temp=-1;
		num=0;
                flag=1;
		if(s[0]!='A')
		{
			cout<<"WA"<<endl;
			continue;
		}
		else
		{
			for(i=2;i<len-1;i++)
		    {
			    if(s[i]=='C')
			    {
			       	num++;
			       	temp=i;
				}
	      	}
	 	    if(num!=1)
		    {
		    	cout<<"WA"<<endl;
		    	continue;
			}
		    for(i=1;i<len;i++)
		    {
			    if(i!=temp)
			    {
				   if(s[i]>='A'&&s[i]<='Z')
				   {
				   	flag=0;
				   }
			    }
		    }
		    if(flag==0)
		    {
			   cout<<"WA"<<endl;
		 	   continue;
		    }
	    }
		cout<<"AC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
k,n = map(int, input().split())
a = list(map(int, input().split()))

max = 0
sum = 0
for i in range(n):
	if i+1 == n:
		buf = k - (a[i] - a[0])
	else:
		buf = a[i+1] -a[i]
	if buf > max:
		max = buf
	sum += buf
sum -= max
print(sum)


Measured memory_bytes: 25840
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>

using namespace std; 

const long long mod=1e9+7;

int main(){

    long double a,b,c;
    cin>>a>>b>>c;

    if(a+b+2.0*sqrt(a*b) < c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
// Aizu Vol-2 0281: Formation
// 2017.8.6

#include <stdio.h>

#define MAX 200
int t[MAX + 2], N;

int main()
{
	int c, a, n, ans, cn;

	scanf("%d", &cn);
	while (cn--) {
		scanf("%d%d%d", &c, &a, &n);
		if (n <= c && n <= a) {
			ans = n, c -= n, a -= n;
			if (a <= c) {
				if (2 * a >= c) ans += c / 2;
				else {
					ans += a, c -= 2 * a;
					ans += c / 3;
				}
			} else ans += c / 2;
		}
		else if (a <= c && a <= n) ans = a + (c - a) / 3;
		else ans = c;    // c <= a && c <= n
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    string S;
    cin >> S;
    ll N=S.size();
    ll a=0;
    ll b=0;
    for(ll i=0;i<N;i++){
        if(S[i]=='0')a++;
        else b++;
    }
    print(min(a,b)*2)

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;

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 long long INF = 1LL << 60;

using lint = long long;

int main(void)
{
	int N, W;
	cin >> N >> W;
	vector <lint> w(N);
	vector <lint> v(N);

	rep(i, N) cin >> w[i] >> v[i];
	vector<vector<lint>> dp(N+1, vector<lint>(W+1, 0));

	rep(i, N){
		rep(j, W+1){
			//cout << j << endl;
			if (j - w[i] >= 0){
				chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
			
			chmax(dp[i + 1][j], dp[i][j]);
			
		}
	}

	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<map>
#include<queue>
#define MAX 10000
#define INF 100000000
#include<vector>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,m,d,p;
	while(cin>>n>>m,n||m){
		priority_queue<P> que;
		for(int i=0;i<n;i++){
			cin>>d>>p;
			que.push(P(p,d));
		}
		int ans=0;
		while(!que.empty()){
			P p=que.top();
			que.pop();
			if(m-p.second<0){
				ans+=(p.second-m)*p.first;
				break;
			}
			m-=p.second;
		}
		while(!que.empty()){
			P p=que.top();
			que.pop();
			ans+=p.second*p.first;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

ll x;
map<ll,ll>mp;
void solve(){
    vector<ll>a;
    mp[0]=0;
   for(ll i=1;i*i*i*i*i<=100*x;i++){
       ll cur=i*i*i*i*i;
       mp[cur]=i;
       mp[-cur]=-i;
       if(mp.count(cur-x)!=0){
           cout<<i<<" "<<mp[cur-x]<<endl;
       }
   }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>x;
    solve();
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 500005;
int n,a[MAXN],lf[MAXN],rf[MAXN];
char str[MAXN];

int main()
{
	scanf("%s",str+1);
	n = strlen(str+1)+1;
	for(int i = 2; i<=n; i++)
		lf[i] = str[i-1]=='<'?lf[i-1]+1:0;
	for(int i = n-1; i>=1; i--)
		rf[i] = str[i]=='>'?rf[i+1]+1:0;
	ll ans = 0;
	for(int i = 1; i<=n; i++)
		ans += max(lf[i],rf[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6400
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,a,b,asp;
vi h;

bool explosion(int k){
    int r = 0;
    for (auto v: h){
        int split = max(0LL,v - k * b);
        r += split/asp;
        r += (split % asp > 0);
    }
    return r <= k;
}

signed main(){
    I(n); I(a); I(b);
    asp = a-b;
    h.resize(n);
    REP(i,n) I(h[i]);

    int lo = *max_element(all(h));
    int hi = 0;
    while(abs(lo-hi) > 1){
        int mid = (lo+hi)/2;
        (explosion(mid) ? lo : hi) = mid;
    }
    cout << lo << endl;
}

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

int main () {
  int x = 0, n, max = 0;
  char s;
  cin >> n;
  int i;
  for (i = 0; i < n; i++){
    cin >> s;
    if(s == 'I'){
      x++;
    } else {
      x--;
    }
    if(max < x){
      max = x;
    }
  }
  cout << max << endl;
  return 0;
}

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


const int MAX_H = 2010;
const int MAX_W = 2010;
int H, W, v[MAX_H][MAX_W],h[MAX_H][MAX_W];
string M[MAX_H];

int dfs_v (int y, int x, int num){
	if (v[y][x] != 0) return v[y][x];
	if (M[y][x] == '#' || y >= H) return num;
	return v[y][x] = dfs_v(y+1, x, num+1);
}


int dfs_h (int y, int x, int num){
	if (h[y][x] != 0) return h[y][x];
	if (M[y][x] == '#' || x >= W) return num;
	return h[y][x] = dfs_h(y, x+1, num+1);
}

int main(){
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			v[i][j] = 0;
			h[i][j] = 0;
		}
	}
	cin >> H >> W;
	for (int i = 0; i < H; ++i){
		cin >> M[i];
	}
	int ans = 0;
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			ans = max(ans, dfs_v(i, j, 0)+dfs_h(i, j, 0)-1);
		}
	}
	cout << ans << endl;
}


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

int main()
{
	int a,b,t;
	scanf("%d%d%d",&a,&b,&t);
	int ans=0;
	for(int i=a;i<=t;i+=a)
	{
		ans+=b;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T,typename U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

bool dp[200010][2][2] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> P(N);
    vec<int> indeg(N,0);
    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        p--;
        P[i] = p;
        indeg[p]++;
    }
    vec<int> num(N,0);
    vec<set<int>> vs(N,set<int>());
    queue<int> Q;
    for(int i=0;i<N;i++) if(indeg[i]==0){
        Q.push(i);        
    }
    vec<int> vis(N,0);
    
    if(Q.empty()){
        cout << (N%2? "IMPOSSIBLE":"POSSIBLE") << endl;
        return 0;
    }

    while(!Q.empty()){
        int cur = Q.front(); Q.pop();
        int n = 0;
        vis[cur] = 1;
        while(vs[cur].count(n)) n++;
        num[cur] = n;
        indeg[P[cur]]--;
        vs[P[cur]].insert(num[cur]);
        if(indeg[P[cur]]==0){
            Q.push(P[cur]);
        }
    }

    int s = 0,e = 0;
    vvec<int> X(N);
    for(int i=0;i<N;i++){
        if(!vis[i]){
            s = i;
            int n = 0;
            while(vs[i].count(n)) n++;
            X[i].push_back(n);
            n++;
            while(vs[i].count(n)) n++;
            X[i].push_back(n);
        }
    }
    int now = s;
    dp[s][0][0] = dp[s][1][1] = true;
    while(true){
        int ne = P[now];
        if(ne==s){
            e = now;
            break;
        }
//        cerr << now << " " << X[now][0] << " " << X[now][1] << endl;
        for(int k=0;k<2;k++){
            if(X[ne][0]!=X[now][0]) dp[ne][0][k] |= dp[now][0][k];
            if(X[ne][0]!=X[now][1]) dp[ne][0][k] |= dp[now][1][k];
            if(X[ne][0]==X[now][0]) dp[ne][1][k] |= dp[now][0][k];
            if(X[ne][0]==X[now][1]) dp[ne][1][k] |= dp[now][1][k];
        }
        now = ne;
    }
    bool ok = false;
//    cerr << dp[e][0][0] << " " << dp[e][0][1] << " " << dp[e][1][0] << " " << dp[e][1][1] << endl;
    if(dp[e][0][0] && X[s][0]!=X[e][0]) ok = true;
    if(dp[e][1][0] && X[s][0]!=X[e][1]) ok = true;
    if(dp[e][0][1] && X[s][0]==X[e][0]) ok = true;
    if(dp[e][1][1] && X[s][0]==X[e][1]) ok = true;
    cout << (ok? "POSSIBLE":"IMPOSSIBLE") << endl;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, k;
	cin >> n >> k;
	vi arr(n);
	M00(i, n) {
		cin >> arr[i];
	}
	M00(i, k) {
		vi pref(n+1);
		M00(i, n) {
			int start = max(0, i - arr[i]);
			int end = min(n-1, i + arr[i]);
			pref[start]++;
			pref[end+1]--;
		}
		int roll = 0;
		bool stop = true;
		M00(i, n) {
			roll += pref[i];
			arr[i] = roll;
			if(arr[i] != n) stop = false;
		}
		if(stop) break;
	}
	M00(i, n) cout << arr[i] << " ";
	cout << endl;
}


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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin >> n;
    string ans = "";
    int can = 0;
    while(n) {
        --n;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef long long ll;

const ll INF = 1e18;

void solve(void){
	ll N, x;
	cin >> N >> x;
	vector <ll> as(N), ms(N, INF);
	rep(N, i) cin >> as[i];
	ll ans = INF;
	rep(N, i) {
		ll res = 0LL;
		rep(N, j) {
			ms[j] = min(as[(j-i+N)%N], ms[j]);
			res += ms[j];
		}
		ans = min(ans, res + i * x);
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

	ll ans = 0;
	// O(N^2)なのでダメでした
	// for(int a = K; a<=N; a++){
	// 	for(int b = K+1; b<=N; b++){
	// 		if(a == 0) break;//K=0のときにa=0として計算されるが,aは正の整数なので除外
	// 		if(a < b) {
	// 			ans += N - b + 1;
	// 			break;
	// 		}
	// 		if(a%b >= K) ans++;
	// 	}
	// }


	if(K==0){
		cout << (ll)N * N << endl;
		return 0;
	}
	for(int b=K+1; b<=N; b++){		
		int tmp1 = (N-K+1) / b;//　何周期　あまりが　ぐるぐる回るか
		int tmp2 = b - K ;// 1周期(0~ b-1 の中)にK以上のものが何個あるか 
		ans += tmp1 * tmp2;   // 

		// for(int a = b+1; a<=N; a++){}
		int tmp3 = (N-K+1) % b;// 周期の最後にaが Nに達するまで何回インクリメントできるか
		ans += min(tmp3, tmp2);
	}


	cout << ans << endl;

	return 0;
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> s(n + 1);
    rep(i, n) s[i + 1] = (s[i] + a[i]) % k;
    map<int, int> mp;
    ll ans = 0;
    queue<int> q;
    rep(j, n + 1) {
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        if (q.size() == k) {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int i, ret, x, ans;
    int[] cre = {-1, 1};
    int N = Integer.parseInt(br.readLine());
    String[] array = br.readLine().split("");
    x = ans = 0;
    for (String Si: array) {
      ret = Si.equals("I") ? 1 : 0;
      x += cre[ret];
      ans = Math.max(x, ans);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21076
import fractions

n = int(input())
an = [int(x) for x in input().split()]

l = [0]*n
r = [0]*n
l[0] = an[0]
r[n-1] = an[n-1]

for i in range(1,n):
  l[i] = fractions.gcd(an[i], l[i-1])
  r[n-1 - i] = fractions.gcd(an[n-1 - i], r[n - i])

m = [0]*n
m[0] = r[1]
m[n-1] = l[n-2]
for i in range(1,n-1):
  m[i] = fractions.gcd(l[i-1], r[i+1])
  
print(max(m))




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

int N,M,xx,yy,x1,x2,y1,y2,ans;
int Vert[15+1][15+1], Horiz[15+1][15+1];

int T_search(int xx, int yy){
	if (xx<0 || yy<0){
		return 0;
	}else if (xx==0 && yy==0){
		return 1;
	}else if (Vert[xx][yy]==0 && Horiz[xx][yy]==1){
		return T_search(xx-1, yy);
	}else if (Vert[xx][yy]==1 && Horiz[xx][yy]==0){
		return T_search(xx, yy-1);
	}else if (Vert[xx][yy]==0 && Horiz[xx][yy]==0){
		return 0;
	}else{
		return T_search(xx,yy-1) + T_search(xx-1,yy);
	}
}

int main(){
	
	cin >> N;
	for (int Q=0; Q<N; Q++){
		for (int a=0; a<=15; a++){
			for (int b=0; b<=15; b++){
				Vert[a][b] = 1;
				Horiz[a][b] = 1;
			}
		}
		
		cin >> xx >> yy;
		cin >> M;
		for (int P=0; P<M; P++){
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 == x2){
				Vert[x1][max(y1,y2)] = 0;
			}else{
				Horiz[max(x1,x2)][y1] = 0;
			}
		}
		ans = T_search(xx,yy);
		
		if (ans > 0){
			cout << ans << endl;
		}else{
			cout << "Miserable Hokusai!" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using namespace atcoder;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n, m;
    cin >> n >> m;
    dsu tree(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        tree.merge(a, b);
    }
    vector<vector<int>> v = tree.groups();
    cout << v.size() - 1 << endl;

    return 0;
}


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

int main(){
	int m,f,r;
 	
 	while(1){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		
		if(m==-1||f==-1){
			cout<<'F'<<endl;
		}else if(m+f>=80){
			cout<<'A'<<endl;
		}else if(m+f>=65){
			cout<<'B'<<endl;
		}else if(m+f>=50){
			cout<<'C'<<endl;
		}else if(m+f>=30){
			if(r>=50){
				cout<<'C'<<endl;
			}else{
				cout<<'D'<<endl;
			}
		}else{
			cout<<'F'<<endl;
		}
 	}
  	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

    n %= 10;

    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
    default:
        break;
    }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Component {
  int delta;
  int min;
};

Component Encode(const string& s) {
  int min = 0;
  int current = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '(') {
      current++;
    } else {
      current--;
      min = std::min(min, current);
    }
  }
  return {current, min};
}

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

  int n;
  cin >> n;
  vector<Component> l_components, r_components;
  int delta_sum = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    Component component = Encode(s);
    if (component.delta >= 0) {
      l_components.push_back(component);
    } else {
      r_components.push_back({-component.delta, component.min - component.delta});
    }
    delta_sum += component.delta;
  }

  if (delta_sum != 0) {
    cout << "No" << endl;
    return 0;
  }

  auto check_components_fn = [](const vector<Component>& components) -> bool {
    deque<Component> q(components.begin(), components.end());
    sort(q.begin(), q.end(), [](Component c1, Component c2) { return c1.min > c2.min; });

    auto compare_fn = [](Component c1, Component c2) {
      return c1.delta < c2.delta;
    };
    priority_queue<Component, vector<Component>, decltype(compare_fn)> pq(compare_fn);

    int current = 0;
    while (true) {
      while (!q.empty() && current + q.front().min >= 0) {
        Component c = q.front();
        q.pop_front();
        pq.push(c);
      }
      if (pq.empty()) break;
      Component c = pq.top();
      pq.pop();
      current += c.delta;
    }

    return q.empty();
  };

  bool ans = check_components_fn(l_components) && check_components_fn(r_components);
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 23044