akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int h,w,n;
signed main(){
    cin>>h>>w>>n;
    int m=max(h,w);
    int ans=(n+m-1)/m;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;

int n, m, q, x, y;
array<int, MAXN> arr, brr;
string s;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> s;
    if (s.back() != 's') s.push_back('s');
    else s.push_back('e'), s.push_back('s');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3648
A, B, K = map(int, input().split())

if B - A + 1 <= K * 2:
  for i in range(A, B + 1):
    print(i)
else:
  for i in range(A, A + K):
    print(i)
  for i in range(B - K + 1, B + 1):
    print(i)


Measured memory_bytes: 3060
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let csts = Array.init n @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun s t c -> c, s, t
let acc = Array.make 100002 0
let _ = Array.(sort compare csts; fold_left (fun (c0, t0) (c, s, t) -> if c0 = c && t0 = s then acc.(t0 + 1) <- acc.(t0 + 1) + 1 else acc.(s) <- acc.(s) + 1; acc.(t + 1) <- acc.(t + 1) - 1; c, t) (0, 0) csts |> ignore; iteri (fun i a -> if i > 0 then acc.(i) <- acc.(i) + acc.(i - 1)) acc; fold_left max 0 acc) |> Printf.printf "%d\n"

Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int MAX_N = 110;
const int MAX_K = 110;
const int MAX_P = 3;
const int MOD = 10000;

int main(){
    int n, k;
    cin >>n >>k;
    vector<int> pasta(n, -1);
    REP(i, k){
        int day, p;
        cin >>day >>p;
        day--;
        p--;
        pasta[day] = p;
    }

    int dp[MAX_N][MAX_P][2];
    memset(dp, 0, sizeof(dp));
    //init
    if(pasta[0] != -1) dp[0][pasta[0]][0] = 1;
    else REP(i, MAX_P) dp[0][i][0] = 1;

    //dp
    REP(i, n - 1){
        REP(j, MAX_P){
            REP(k, MAX_P){
                if(pasta[i] != -1 && pasta[i] != j) continue;

                if(j == k){
                    dp[i + 1][k][1] = (dp[i + 1][k][1] + dp[i][j][0]) % MOD;
                } else{
                    dp[i + 1][k][0] = (dp[i + 1][k][0] + dp[i][j][0] + dp[i][j][1]) % MOD;
                }

            }
        }
    }

    //debug
    //REP(i, n){
    //    REP(j, MAX_P){
    //        cout <<dp[i][j][0] <<" ";
    //    }
    //    cout <<endl;
    //}
    //cout <<endl;
    //REP(i, n){
    //    REP(j, MAX_P){
    //        cout <<dp[i][j][0] <<" ";
    //    }
    //    cout <<endl;
    //}

    int ans = 0;
    if(pasta[n - 1] != -1){
        ans = (ans + dp[n - 1][pasta[n - 1]][0] + dp[n - 1][pasta[n - 1]][1]) % MOD;
    } else{
        REP(i, MAX_P){
            ans = (ans + dp[n - 1][i][0]) % MOD;
            ans = (ans + dp[n - 1][i][1]) % MOD;
        }
    }

    cout <<ans <<endl;


    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;

const int maxn = 305, MOD = 998244353;
const int seed = 23333;
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], d[maxn][maxn], power[maxn];
char s[maxn][maxn];
int n, ans;

int check(int x, int y) {
	int A, B;
	rep (k, 1, n) {
		A = (1LL * b[(k+y+n-1)%n+1][x+1] * power[x] + a[(k+y+n-1)%n+1][x]) % MOD;
		B = (1LL * d[y+1][(k+x+n-1)%n+1] * power[y] + c[y][(k+x+n-1)%n+1]) % MOD;
		// printf("%d %d\n", A, B);
		if (A != B) return 0;
	}
	return 1;
}

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%s", s[i] + 1);
	power[0] = 1;
	rep (i, 1, n) power[i] = 1LL * power[i-1] * seed % MOD;
	
	rep (i, 1, n) {
		rep (j, 1, n) 
			a[i][j] = (1LL * a[i][j-1] * seed + s[i][j]) % MOD;
		per (j, n, 1)
			b[i][j] = (b[i][j+1] + 1LL * s[i][j] * power[n-j]) % MOD;
	}
	rep (j, 1, n) {
		rep (i, 1, n)
			c[i][j] = (1LL * c[i-1][j] * seed + s[i][j]) % MOD;
		per (i, n, 1)
			d[i][j] = (d[i+1][j] + 1LL * s[i][j] * power[n-i]) % MOD;
	}
		
	rep (i, 0, n-1) rep (j, 0, n-1)
		ans += check(i, j);
	printf("%d\n", ans);
		
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            switch(x)
            {
                case 3:
                case 5:
                case 7:
                    Console.WriteLine("YES");
                    break;
                default:
                    Console.WriteLine("NO");
                    break;

            }
        }

    }
}


Measured memory_bytes: 13140
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	count := 0
	for i:=0; i <= a; i++{
		for l:=0;l<=b;l++{
			for m:=0;m<=c;m++{
				if 500*i + 100*l + 50*m == x{
					count++
				}
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a >> b >> c;
	if ((c >= a) && ((c - a) < b)) {
		cout << "YES";
	}
	else cout << "NO";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		String[] not_in = new String[K];
		for(int i = 0; i < K; i++){
			not_in[i] = sc.next();
		}
		
		int answer = N;
		LOOP:
		while(true){
			for(final String in : not_in){
				if(Integer.toString(answer).contains(in)){
					answer++;
					continue LOOP;
				}
			}
			
			System.out.println(answer);
			break;
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 16592
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n;
    
    cin >> n;
    
    float ans = 0;
    
    if (n % 2 == 0) {
        ans = 0.5;
    }
    else ans = ((n / 2) + 1) / (float)n;
    
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        // 入力(A B C)
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println((a <= c && c <= b) ? "Yes" : "No");
        sc.close();
    }
}


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

class Restaurant{
public:
	int n;
	string name;
	int p; 
	Restaurant(){}
	Restaurant(int n, string name, int p){
		this->n=n;
		this->name=name;
		this->p=p;
	}	
};

int main(){
	/*input*/
	int n;	cin >> n;
	Restaurant* res = new Restaurant[n];
	for(int i = 0; i < n; i++){
		string name;
		int p;
		cin >> name >> p;
		res[i] = Restaurant(i + 1, name, p);
	}
	/*calculation*/
	for(int i = 0; i < n; i++){
		for(int j = n - 1; j > i;j--){
			if(res[j].name<res[j - 1].name){
				Restaurant temp = res[j - 1];
				res[j - 1] = res[j];
				res[j] = temp;
			}else if(res[j].name==res[j - 1].name){
				if(res[j].p>res[j - 1].p){ 
						Restaurant temp = res[j - 1];
						res[j - 1] = res[j];
						res[j] = temp;
				}
			}
		} 
	}

	/*output*/
	for(int i = 0; i < n; i++){
		cout << res[i].n <<  endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int time, h, m, s; 
    cin >> time;
    h = time / 3600;
    m = (time % 3600) / 60;
    s = time % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3096
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353LL
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
vector<long long> calc(vector<long long> a, vector<long long> b) {
	long long k = sqrt(a.size());
	vector<long long> ans;
	for (int i = 0; i < k; ++i) {
		for (int q = 0; q < k; ++q) {
			long long geko = 0;
			for (int t = 0; t < k; ++t) {
				geko += a[i * k + t] * b[t * k + q];
				geko %= MAX_MOD;
 			}
			ans.push_back(geko);
		}
	}
	return ans;
}
vector<long long> powered(vector<long long> a, long long n) {
	vector<long long> ans = a;
	n--;
	while (n != 0) {
		if (n % 2 == 1) {
			ans = calc(ans, a);
		}
		a = calc(a, a);
		n /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> gogo;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		gogo.push_back(make_pair(a, b));
	}
	int ans = n;
	for (int i = 0; i < gogo.size(); ++i) {
		for (int q = i + 1; q < gogo.size(); ++q) {
			int x = gogo[i].first - gogo[q].first;
			int y = gogo[i].second - gogo[q].second;
			int now_tmp = n;
			REP(j, n) {
				REP(t, n) {
					if (gogo[t].first - gogo[j].first == x && gogo[t].second - gogo[j].second == y) {
						now_tmp--;
					}
				}
			}
			ans = min(ans, now_tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout高速化のおまじない＋桁数指定
	Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
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; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }



void solve()
{
	string s,t;  cin >> s >> t;
	ll ns=sz(s);
	ll nt=sz(t);

	ll ans=INF;
	rep(i,0,ns-nt){
		ll cnt=0;
		rep(j,0,nt-1){
			if (s[i+j]!=t[j]){
				cnt++;
			}
		}
		chmin(ans,cnt);
	}
	cout << ans << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

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;
  IN(N);
  vll A(N), B(N);
  REP(i,N){
    IN(A[i], B[i]);
  }

  sort(ALL(A));
  sort(ALL(B));
  reverse(ALL(B));

  ll ans;
  if(N%2==1){
    ans = B[(N-1)/2]-A[(N-1)/2]+1;
  }else{
    ans = (B[(N-1)/2]+B[N/2]-A[(N-1)/2]-A[N/2])+1;
  }
  if(ans<0) ans=0;

  OUT(ans);

  return 0;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b;
  cin >> a >> b;
  vector<pair<int64_t,int64_t>> res;
  int64_t n=gcd(a,b);
  for(int64_t i=2;i*i<=n;i++){
    if(n%i!=0)continue;
    int64_t s=0;
    while(n%i==0){
      s++;
      n/=i;
    }
    res.push_back({a,s});
  }
  if(n!=1)res.push_back({n,1});
  cout << res.size()+1 << endl;
}
      
  


Measured memory_bytes: 3632
R, G, B ,N = list(map(int, input().split(' ')))

cnt = 0

li = [R, G, B]
li = sorted(li)

_i = N//li[2]
for i in range(_i+1):
    _j = (N - li[2]*i )//li[1]
    for j in range(_j + 1):
        if (N - i*li[2] -  j*li[1])%li[0] == 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int n[5];
	int i, j;
	int t;

	while(scanf("%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4]) != EOF) {
		// ツバツブツδ仰ソツーツト
		for(i = 0; i <= 4; i++) {
			for(j = 4; j > i; j--) {
				if(n[j] > n[j-1]) {
					t = n[j];
					n[j] = n[j-1];
					n[j-1] = t;
				}
			}
		}
		// ツ表ツ篠ヲ
		for(i = 0; i <= 4; i++) {
			printf("%d", n[i]);
			if(i != 4)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
	int N,K,i,j,t,Num;
	int item[50];

	scanf("%d", &N);	
	scanf("%d", &K);
	

	for(i = 0;i < N;i++){
		scanf("%d",&item[i]);
	}

	/*バブルソート*/
	for(i = 1;i < N;++i){
		for(j = N - 1;j >= i; --j){
			if(item[j-1] > item[j]){
				t = item[j-1];
				item[j-1] = item[j];
				item[j] = t;
			}
		}
	}
	/*for(t = 0;t < N;t++)
		printf("%d\n", item[t]);*/
	/*printf("%d\n",N-1 );
	printf("%d",item[N-1]);*/
	Num = item[N-1];

	for(i = 0;i < K-1;i++){
		Num = Num + item[N-2];
		N--;
	}

	printf("%d\n",Num);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio;
cin.tie(NULL);
cout.tie(NULL);
}
/*
bitset<MAX> prime;
void sieve()
{ 
prime.set();
  	prime[0]=0;
  	prime[1]=0;
    for (ll p=2; p*p<=MAX; p++) 
    { 
        if (prime[p] == 1) 
        { 
            for (ll i=p*p; i<=MAX; i += p) 
                prime[i] = 0; 
        } 
    } 
} 
bool comp(vector<ll> a,vector<ll> b)
{
	if(a[0]>b[0])
	return true;
	else if(a[0]<b[0])
	return false;
	else{
		if(a[4]>b[4])
		return true;
		else return false;
	}
}
long long power(long long a,long long b){			//(a^b)%mod
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
long long fact[200005],fact_inv[200005];			//n<=2*10^5+4
void pre(){
    fact[0]=1;
    fact_inv[0]=1;
    for(long long i=1;i<200005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inv[i]=power(fact[i],mod-2);
    }
}
long long ncr(long long n,long long r){
    if(n<0)return 1;
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
 ll exponentiation(ll base,ll exp) //fast modulo exponentiation
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % mod; 
  
    ll t = exponentiation(base, exp / 2); 
    t = (t * t) % mod; 
    if (exp % 2 == 0) 
        return t; 
  
    else
        return ((base % mod) * t) % mod; 
} 
*/
int main(){
	sync();
	ll t;
	t=1;
	while(t--){
		ll n,m;
		cin>>n>>m;
		ll ans=0;
		ans=n*(n-1)/2;
		ans=ans+m*(m-1)/2;
		cout<<ans;
		
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s,t;
    cin>>s>>t;
    ll a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if (s==u)
    {
        cout<<a-1<<" "<<b<<"\n";
    }
    else
    {
        cout<<a<<" "<<b-1<<"\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{ 
    vector<char > v; 
   long int n,r,s,p,k;
   scanf("%ld%ld",&n,&k);
   scanf("%ld%ld%ld",&r,&s,&p);
   long int i,sum=0;
  string s1;
  cin>>s1;
   for(i=0;i<n;++i)
   {
     if(i<k)
     {
        if(s1[i]=='r')
          { sum+=p;
            v.push_back('p');
          }
           
       
        else if(s1[i]=='s')
           { sum+=r;
             v.push_back('r');
           }
       
        else 
           { sum+=s;
             v.push_back('s');
           }
     }
     
     else
     {
        if(s1[i]=='r')
        {
           if(s1[i-k]=='r')
           {
             s1[i]='*';
             v.push_back('*');
           }
          
           else
              { sum+=p;
                v.push_back('s');
              }
        }
       
       else if(s1[i]=='p')
       {
          if(s1[i-k]=='p')
           {
               s1[i]='*';
               v.push_back('*');
           }
          
           else
             {  sum+=s;
                v.push_back('s');
             }
       }
       
       else
       {
         if(s1[i-k]=='s')
           {
              s1[i]='*';
              v.push_back('*');
              
           }
          
           else
              { sum+=r;
                v.push_back('r');
              }
       }
     }
   }
    
  
  printf("%d",sum);         
                
}

Measured memory_bytes: 640
from collections import deque

mod = 10**9+7
n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
    x, y = map(int, input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)

visited = [False]*n
q = deque([0])
lst = []  # 0を根として、深い頂点から見たい。
while q:
    v = q.popleft()
    visited[v] = True
    lst.append(v)
    for w in g[v]:
        g[w].remove(v)
        if not visited[w]:
            q.append(w)
lst = lst[::-1]

white = [1 for _ in range(n)]
black = [1 for _ in range(n)]

for v in lst:
    for w in g[v]:
        white[v] *= white[w]+black[w]
        white[v] %= mod
        black[v] *= white[w]
        black[v] %= mod

print((white[0]+black[0]) % mod)


Measured memory_bytes: 75040
from heapq import heappop, heapify
import sys
input = sys.stdin.buffer.readline

class UnionFind :
    """
    Union Find木
    ---
    頂点のインデックスは0~

    Attributes
    ---
    parent : list<int>
        親のリスト．parent[頂点のインデックス] = 親のインデックス
    height : list<int>
        各木の高さ
    size : list<int>
        各木の頂点数
    component : int
        連結成分の数
    """

    def __init__(self, size) :
        """
        Parameters
        ---
        size : int
            頂点数
        """
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        """
        親のインデックスの取得

        Parameters
        ---
        index : int
            取得する頂点のインデックス

        Returns
        ---
        rootIndex : int
            指定した頂点の根のインデックス
        """
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        """
        木の結合

        Parameters
        ---
        index1 : int
        index2 : int
            結合する頂点のインデックス
        """
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        """
        同じ木に属するかを判定する

        Parameters
        ---
        index1 : int
        index2 : int

        Returns
        ---
        boolean
        """
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        """
        指定した頂点の属する木の大きさを取得する
        """
        return self.size[self.root(index)]

    def getComponent(self) :
        """
        連結成分数を取得する
        """
        return self.component

N = int(input())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X.sort()
Y.sort()
edges = []

for (u, fr), (v, to) in zip(X, X[1:]):
    edges.append((abs(u - v), fr, to,))
for (u, fr), (v, to) in zip(Y, Y[1:]):
    edges.append((abs(u - v), fr, to,))

heapify(edges)
tree = UnionFind(N)
ans = 0
while edges:
    cost, fr, to = heappop(edges)
    if not tree.isSameRoot(fr, to):
        ans += cost
        tree.union(fr, to)

print(ans)


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

int main() {
    char s[11];
    int ans = 0, scr = 0;
    cin >> s;
    for(int i = 0; s[i] != NULL; i++) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            scr++;
            ans = max(ans, scr); 
        }
        else
            scr = 0; 
    }

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

Measured memory_bytes: 256
n,x = [int(i) for i in input().split()]

A = [int(i) for i in input().split()]
cnt = 0
for i in range(n-1):
    a = (A[i]+A[i+1])-x
    if a > 0:
        b = A[i+1] - a
        if b < 0:
            cnt += a
            A[i+1] = 0
            A[i] += b
        else:
            cnt += a
            A[i+1] -= a
      

print(cnt)

Measured memory_bytes: 14592
import java.util.Arrays;
import java.util.Scanner;

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

		int N = sc.nextInt();
		int L = sc.nextInt();

		String S[] = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Arrays.sort(S);

		for (int i = 0; i < S.length; i++) {
			System.out.print(S[i]);
		}
	}
}


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

using namespace std;
typedef long long ll;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll range_min = INF, range_max = -INF; 
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        range_min = min(range_min, A[i]);
        range_max = max(range_max, A[i]);
    }

    ll mc = INF;
    for (ll i = range_min; i <= range_max; i++) {
        ll cost = 0;
        for (int j = 0; j < N; j++) {
            cost += (A[j] - i) * (A[j] - i);
        }
        mc = min(mc, cost);
    }
    cout << mc << endl;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%s\n" @@ fun s ->
  let cs = Array.init (String.length s) (String.get s) in
  let (just, over) =
    Array.fold_right (fun c (just, over) ->
      let d = Char.code c - Char.code '0' in
      (d + min just (over + 1), min (just + 10 - d) (over + 9 - d))) cs (0, 1) in
  Printf.printf "%d\n" @@ min just (over + 1)

Measured memory_bytes: 15488
#include<stdio.h>
int main()
{
  char a;
  while(scanf("%c",&a)==1)
  {
    if(a=='A')
  	printf("T\n");
  else if(a=='T')
    printf("A\n");
  else if(a=='C')
    printf("G\n");
  else if(a=='G')
    printf("C\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c;
	cin>>a>>b>>c;
	set<ll> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size()==2)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

using namespace std;
int main() {
	vector<int>a(5);
	for(auto &e:a)cin>>e;

	int min_=644;
	for(int i=0; i<5; ++i) {
		int ans=0;
		for(int j=0; j<5;++j) {
			if(i==j)continue;
			ans+=ceil((double)a[j]/10.0)*10;
		}
		min_=min(min_, ans+a[i]);
	}
	cout<<min_<<endl;

	return 0;
}

Measured memory_bytes: 384
lst = input().split()

a = int(lst[0])
b = int(lst[1])
x = int(lst[2])

if a % x != 0:
   a = x * ((a // x) + 1)

if b % x != 0:
   b = x * (b // x)

print(((b - a) // x) + 1)

Measured memory_bytes: 9188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll d[100100];
bool visited[100100];
vector<int> g[100100];

void dfs(int u){
	int i,v;
	visited[u] = true;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		v = g[u][i];
		if(visited[v]){
			continue;
		}
		dfs(v);
	}
}

int main(void){
	int n,m,i,u,v,z,ans=0;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> u >> v >> z; --u; --v;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for(i=0; i<n; ++i){
		if(visited[i]){
			continue;
		}
		++ans; dfs(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8960
fun main() {
    val (n, m, x) = readLine()!!.split(" ").map(String::toInt)
    val list = Array(n) {
        readLine()!!.split(" ").map(String::toInt).toIntArray()
    }


    var min = Integer.MAX_VALUE
    for (bit in 0 until (1 shl n)) {
        val result = IntArray(m + 1)
        val bitString = Integer.toBinaryString(bit).toString().padStart(n, '0')
        for ((i, c) in bitString.toCharArray().withIndex()) {
            if (c == '1') {
                repeat(m + 1) { idx ->
                    result[idx] = result[idx] + list[i][idx]
                }
            }
        }
        if (result.drop(1).all { it >= x }) {
            min = Math.min(result[0], min)
        }
    }

    if (min == Integer.MAX_VALUE) {
        println(-1)
    } else {
        println(min)
    }
}





Measured memory_bytes: 43472
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()

#1/2n(n-1)>=N
def ans(n):
	return 1/2*n*(n-1)

for i in range(0,N+1):
	if ans(i+1) >= N:
		print(i)
		exit()
	


Measured memory_bytes: 64748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

ll gcd(ll i, ll j) { return i % j ? gcd(j, i % j) : j; }

vi prime, mnpf;
void preprime(int n) {

	prime.resize(0);
	mnpf.assign(n + 1, 1);
	rep(i, n + 1) {
		if (i < 2)continue;
		if (mnpf[i] != 1)continue;

		prime.push_back(i);
		mnpf[i] = i;
		int ii = i;
		while (ii <= n) {
			if (mnpf[ii] == 1)mnpf[ii] = i;
			ii += i;
		}
	}
}

int main() {

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	int g = a[0];
	rep(i, n)g = gcd(g, a[i]);
	if (g > 1){
		cout << "not coprime" << endl;return 0;
	}
	
	preprime(1010100);

	map<int,int> pri;

	rep(i, n) {
		int k = a[i];
		while (k > 1) {
			pri[mnpf[k]]++;
			int memo = mnpf[k];
			while(mnpf[k]==memo)k /= mnpf[k];
		}
	}

	bool pairwise = true;
	for (auto x : pri) {
		if (x.second > 1)pairwise = false;
	}
	if (pairwise)cout << "pairwise coprime" << endl;
	else cout << "setwise coprime" << endl;

}

Measured memory_bytes: 14944
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vvll t(n,vll(0));
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  vb ch(n,false);
  queue<ll> que;
  que.pu(0);
  vll ans(0);
  ans.pb(k);
  ch[0]=true;
  while(sz(que)){
    ll s=que.front();
    que.pop();
    ll kk=k-2;
    if(s==0) kk=k-1;
    ll j=sz(t[s])-1;
    if(s==0) j++;
    rep(i,j){
      ans.pb(kk);
      kk--;
    }
    for(auto p:t[s]){
      if(ch[p]) continue;
      ch[p]=true;
      que.pu(p);
    }
  }
  ll anss=1;
  rep(i,sz(ans)){
    anss*=ans[i];
    anss%=MOD;
  }
  COUT(anss);
}


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

int main()
{
  int N;

  cin >> N;

  vector<int> L(N);

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

  int count = 0;

  for (int i = 0; i < N - 2; i++)
  {
    for (int j = i + 1; j < N - 1; j++)
    {
      for (int k = j + 1; k < N; k++)
      {
        if ((L.at(i) != L.at(j)) && (L.at(j) != L.at(k)) && (L.at(i) != L.at(k)))
        {
          int len = L.at(i) + L.at(j) + L.at(k);
          int ma = max(L.at(i), max(L.at(j), L.at(k)));
          int rest = len - ma;
          if (ma < rest)
          {
            count++;
          }
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3628
x, y = map(int, input().split())
x, y = max(x, y), min(x, y)
# print(x, y)

while True:
    if x % y == 0:
        break
    else:
        x, y = max(y, x % y), min(y, x % y)
        # print(x, y)

print(y)


Measured memory_bytes: 5600
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
A = int(input())
# 500円を使った場合のあまりを計算
r = N % 500
# あまりがAより小さければYes
ans = "Yes" if r <= A else "No"
# 結果を表示
print(ans)


Measured memory_bytes: 2940
import math

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


# まずは素数表を作る
ten5 = 10**5

# x = 素数一覧
x = get_sieve_of_eratosthenes(ten5)

# P = 素数表(1 = 素数)
P = [0] * (ten5+1)

# LIKE = 似た数表
LIKE = [0] * (ten5+1)
for i in x:
    P[i] = 1

    if i == 2:
        LIKE[i] = 1
        continue

    # i は素数
    like = ((i+1)//2)
    LIKE[i] = P[like]

S = [0] * (ten5+1)
S[0] = LIKE[0]
for i in range(1, ten5+1):
    S[i] = S[i-1] + LIKE[i]


Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())

    ans = S[r]-S[l-1]
    if l <= 1:
        ans -= 1

    print(ans)

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main() {
	int d;
	int ans;
	while(cin>>d, !cin.eof()){
		ans = 0;
		for(int i=d; i<600; i+=d){
			ans += d * (i*i);
		}
		cout<<ans<<endl;
	}
}

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

const long long charbase = 'a';
struct RollingHash {
  long long Mod[2], Base[2];
  long long ssize, maxssize;
  string s;
  vector<long long> pow[2];
  vector<long long> hash[2];
  RollingHash(string inis = "") {
    Mod[0] = 1000000007;
    Mod[1] = 1000000009;
    Base[0] = 1009;
    Base[1] = 1007;
    maxssize = inis.size() + 10;
    for(int t = 0; t < 2; ++t) {
      pow[t].assign(maxssize, 0);
      pow[t][0] = 1;
      for(int i = 1; i < maxssize; ++i)
        pow[t][i] = pow[t][i - 1] * Base[t] % Mod[t];
    }
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    for(int t = 0; t < 2; ++t) {
      hash[t].assign(ssize + 1, 0);
      for(int i = 0; i < ssize; ++i) {
        if(i != 0)
          hash[t][i + 1] = hash[t][i] * Base[t] % Mod[t];
        hash[t][i + 1] += (s[i] - charbase);
        hash[t][i + 1] %= Mod[t];
      }
    }
  }
  // [l,r),0-indexed
  pair<long long, long long> calchash(int l, int r) {
    long long ans[2];
    for(int t = 0; t < 2; ++t) {
      ans[t] = hash[t][r];
      ans[t] -= hash[t][l] * pow[t][r - l] % Mod[t];
      while(ans[t] < 0) ans[t] += Mod[t];
      ans[t] %= Mod[t];
    }
    return make_pair(ans[0], ans[1]);
  }
};

long long n;
string s;
long long dp[5005][5005] = {0};

long long solve();
bool ch(long long x);

int main() {
  cin >> n >> s;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      if(s[i] == s[j]) {
        dp[i + 1][j + 1] =
            min(dp[i][j] + 1, (long long)j - i);
        ans = max(ans, dp[i + 1][j + 1]);
      }
  return ans;
}


Measured memory_bytes: 194944
import sys

input = sys.stdin.readline

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

d = [aa + bb for aa in a[:k] for bb in b[:k]]
d.sort(reverse=True)

e = [dd + cc for dd in d[:k] for cc in c[:k]]
e.sort(reverse=True)

print(*e[:k], sep='\n')


Measured memory_bytes: 208700
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll n;
	cin >> n;

	vector<ll> cnt(n+1,0);
	ll ans = 0;
	for(ll i = 1;i <= n;i++){
		for(ll j = i;j <= n;j+=i){
			cnt[j]++;
		}
		ans += i * cnt[i];
	}

	cout << ans << endl;
}


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

vector<bool> used(10, false);
int dfs(int prev, int n, int s){
	if(n==0){
		int sum=0;
		for(int i=0; i<10; i++){
			if(used[i]) sum+=i;
		}
		if(sum==s) return 1;
		else return 0;
	}
	
	int ret=0;
	for(int i=prev+1; i<10; i++){
		used[i] = true;
		ret += dfs(i, n-1, s);
		used[i] = false;
	}
	return ret;
}
int main(){
	while(1){
		int n,s;
		cin >> n >> s;
		if(n==0) break;
		cout << dfs(-1,n,s) << endl;
	}
	return 0;
}

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






int main() {
	char a[N];
	f(i, N)a[i] = 0;
	long long n;
	long long ans, s;
	scanf("%lld", &n);
	scanf("%s", a);
	if (a[0] == 'W') {
		printf("0\n");
		return 0;
	}
	n = 2 * n;
	if (a[(n - 1)] == 'W') {
		printf("0\n");
		return 0;
	}
	ans = 1;
	s = 1;
	f(i, (n - 1)) {
		if (a[i] != a[i + 1]) {
			s++;
		}
		else {
			if (s == 0) {
				printf("0\n");
				return 0;
			}
			ans = (ans*s) % MOD;
			s--;
			if (a[i + 1] == 'B')a[i + 1] = 'W';
			else a[i + 1] = 'B';
		}
	}
	if (s != 0) {
		printf("0\n");
		return 0;
	}
	n = n / 2;
	f(i, n) {
		ans = (ans*(i + 1)) % MOD;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _158_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string N=ReadLine();
            string a="AAA";
            string b = "BBB";

            if ( a== N || b == N) {
                WriteLine("No");
            }
            else {
                WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(1000000)
input=sys.stdin.readline


class SegTree():
    def __init__(self, l, INF):
        self.inf = INF

        N = len(l)
        v = 1
        while v<N:
            v *= 2

        self.size = v
        self.node = [self.inf] * (2*self.size-1)
        for i in range(N): # 最下段を埋める
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = min(self.node[2*i+1], self.node[2*i+2]) # 上段の更新をする

    def get(self, left, right, k=0, l=0, r=-1):
        if r < 0:
            r = self.size

        if (r <= left or right <= l):
            return self.inf
        if (left <= l and r <= right):
            return self.node[k]

        vl = self.get(left, right, 2*k+1, l, (l+r)//2)
        vr = self.get(left, right, 2*k+2, (l+r)//2, r)
        return min(vl, vr)

    def update(self, x, v):
        x += self.size-1
        self.node[x] = v

        while x>0:
            x = (x-1)//2
            self.node[x] = min(self.node[2*x+1], self.node[2*x+2])


class LCA():
    def __init__(self, N, G):
        self.depth = [0] * (N+1)
        self.euler_tour = []
        self.G = G
    
        self.idx = {}
        self._currentIndex = 0

        self._dfs(0, 0, 0)
        self.tree = SegTree(self.euler_tour, (2**31-1, 2**31-1))
    
    def _dfs(self, v, p, d):
        self.euler_tour.append((d, v))
        self.idx[v] = self._currentIndex
        self._currentIndex += 1

        self.depth[v] = d
        for u in self.G[v]:
            if u==p:continue
            self._dfs(u, v, d+1)
            self.euler_tour.append((d, v))
            self._currentIndex += 1
    
    def get(self, u, v):
        a, b = self.idx[u], self.idx[v]
        a, b = (a, b) if a<b else (b, a)
        return self.tree.get(a, b+1)[1]


if __name__ == "__main__":
    n = int(input())
    G = {i:[] for i in range(n)}
    for i in range(n):
        k, *l = map(int, input().split())
        G[i] = l
        for j in l:
            G[j].append(i)
    lca = LCA(n, G)
    q = int(input())
    for _ in range(q):
        u, v = map(int, input().split())
        print(lca.get(u, v))


Measured memory_bytes: 158096
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std;

int main()
{
  int K;
  cin >> K;
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v[K - 1] << endl;
}


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

using namespace std;

int main() {
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;

	int A,B;
	int C,D;
	C = D = -1;
	for(int i = 0; i*100*a <= f; i++)  {
		for(int j = 0; i*100*a+j*100*b<=f; j++) {
			A = 100*a*i + 100*b*j;
			for(int x = 0;  x*c+A <= f && 100*x*c <= e*A; x++) {
				for(int y = 0; x*c+y*d+A <= f && 100*x*c + 100*y*d <= e*A; y++) {
					B = c*x + d*y;
					if( 100*D*(A+B) < 100*B*(C+D) ) {
						C = A;
						D = B;
					}
				}
			}
		}
	}
	cout << C+D << " " << D << endl;
	return 0;
}




Measured memory_bytes: 256