akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll n_dishes;
vector<vector<vector<double> > > dp;

double expected_value(vl dishes){
    if(dishes[3] == 0 && dishes[2] == 0 && dishes[1] == 0){
        return 0;
    }
    if(dp[dishes[0]][dishes[1]][dishes[2]] != -1.){
        return dp[dishes[0]][dishes[1]][dishes[2]];
    }
    double res = 0.;
    vl next_dishes(dishes);
    FORD(i, 1, sz(dishes)){
        if(dishes[i] == 0) {continue;}
        next_dishes[i]--;
        next_dishes[i-1]++;
        res += dishes[i] / (double) n_dishes * expected_value(next_dishes);
        next_dishes[i-1]--;
        next_dishes[i]++;
    }
    res++;
    if(dishes[0] != 0){
        double prob =  dishes[0] / (double) n_dishes;
        res =  res / (1 - prob);
    }
    dp[dishes[0]][dishes[1]][dishes[2]] = res;
    
    return res;
}

int main() {

    vl dishes (4, 0);
    cin >> n_dishes;
    dp.assign(n_dishes+1, vector<vector <double > >(n_dishes+1, vector<double>(n_dishes+1, -1.)));

    FOR(i, 0, n_dishes){
        ll tmp;
        cin >> tmp;
        dishes[tmp]++;
    }
    
    cout << setprecision(15) << expected_value(dishes) << endl;

    return 0;
}



Measured memory_bytes: 216960
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		int q = in.nextInt();
		if (n + q == 0) return false;

		String[] names = new String[n];
		ArrayList<int[]> list = new ArrayList<>();

		for (int i=0; i<n; i++) {
			names[i] = in.next();
			int eb = in.nextInt();
			int y = in.nextInt();
			list.add(new int[]{i, eb, y});
		}

		Collections.sort(list, new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
				return (a[2] - a[1]) - (b[2] - b[1]);
			}
		});

		for (int i=0; i<n; i++) {
			dump(list.get(i));
		}

		while (q-- > 0) {
			int y = in.nextInt();
			if (y <= list.get(0)[2] - list.get(0)[1]) {
				out.println("Unknown");
			} else {
				int pos = 1;
				while (pos < n && list.get(pos)[2] - list.get(pos)[1] < y) pos++;
				pos--;
				int x = y - (list.get(pos)[2] - list.get(pos)[1]);
				if (list.get(pos)[1] < x) {
					out.println("Unknown");
				} else {
					out.println(names[list.get(pos)[0]] + " " +x);
				}
			}
		}

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 73920
package main
 
import (
	"fmt"
)
 
func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&h[i])
	}
	ans := "Yes"
	for i:=n-2; i>0; i-- {
		if h[i]-h[i+1]==1 {
			h[i]--
		} else if h[i]-h[i+1]>1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println(ans)
}

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

bool check(string s) {
    int n = s.size();
    for (int i = 0; i < n; i++)
        if (s[i] != s[n-i-1]) return false;
    return true;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    cout << (check(s) && check(s.substr(0, (n-1)/2)) && check(s.substr((n+1)/2)) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long n,k,res;
    while(scanf("%lld%lld",&n,&k)==2){
        res=k;
        res*=pow((k-1),(n-1));
        printf("%lld\n",res);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    ll prv=-1,cnt=0;
    vector< pair<ll,ll> > vec;
    for(ll i=0;i<n;i++){
        ll val = s[i]-'0';
        if(val==prv)cnt++;
        else{
            if(prv!=-1)vec.push_back({prv,cnt});
            cnt=1;
            prv=val;
        }
    }
    vec.push_back({prv,cnt});
    vector<ll> prfx(vec.size()+1);
    for(ll i=0;i<(ll)vec.size();i++)prfx[i+1]=prfx[i] + vec[i].second;
    ll ans = 0;
    for(ll i=0;i<(ll)vec.size();i++){
        ll r = i + (vec[i].first==0?2*k:2*k+1);
        ll cnt = prfx[min(r,(ll)vec.size())]-prfx[i];
        ans=max(ans,cnt);
    }
    cout<<ans;
}


Measured memory_bytes: 2752
import numpy as np
N,D = list(map(int,input().split()))
 
lis =[list(map(int,input().split())) for i in range(N)]
lis_np = np.array(lis)
counter = 0
for i in range(N-1):
    for j in range(i+1,N):
        kyori = (sum((lis_np[:][i] - lis_np[:][j])**2))**0.5
        if kyori == int(kyori):
            counter += 1
        
print(counter)


Measured memory_bytes: 27252
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')
xy = [(0, 1), (0, -1), (1, 0), (-1, 0)]


#A
def A():
    h, w = LI()
    A = SR(h)
    check = [[True for _ in range(w)] for i in range(h)]
    q = deque([])
    for tate in range(h):
        for yoko in range(w):
            if A[tate][yoko] == "#":
                q.append((tate, yoko))
                check[tate][yoko] = False
    new_q = deque([])
    ans = 0
    while True:
        while q:
            y, x = q.pop()
            for movex, movey in xy:
                if 0 <= y + movey < h and 0 <= x + movex < w and check[y + movey][x + movex]:
                    check[y + movey][x + movex] = False
                    new_q.append((y + movey, x + movex))
        if not new_q:
            break
        ans += 1
        q = new_q
        new_q = deque([])
    print(ans)
                    

        
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 122588
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

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

Measured memory_bytes: 3608
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
const int INF = INT_MAX/4;
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  //for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      //if(i==j)
        {
          if(graph[start][j]<INF/2 && graph[j][j]<0)
        {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
        }
        }
    }
    }
   
    for(int i=0;i<vertex;i++)
      {
    if(graph[start][i]>=INF/2)
      {
        cout << "INF" << endl;
      }
    else
      {
    cout << graph[start][i] << endl;
      }
      }
  return 0;
}
 
int fastmin(int a, int b)
{
    int c = a-b;
  return (((c)>>31)&(c))+b;
}
 
void check()
{
  //  int next;
  //int here = start;
  //for(int i=0;i<vertex;i++)
   
  for(int k=0;k<vertex;k++)//v=4
    {
      for(int i=0;i<vertex;i++)
    {
      int gik= graph[i][k];
      for(int j=0;j<vertex;j++)
        {

          //if(graph[i][k] !=INF && graph[k][j]!=INF)
        {
          graph[i][j]= min(gik+graph[k][j], graph[i][j]);
        }
        }
    }
    }
   
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
      {
    if(i==j)
      {
        graph[i][j]=0;
      }
    /*else
      {
        graph[i][j]=INF;
        }*/
      }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
      dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
    {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
   }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
    {
      cout << graph[i][j] << " ";
    }  
      cout << endl;    
      }*/
   
 
}

Measured memory_bytes: 5300
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)

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

  vector<vector<int>> jobs(m + 1);
  priority_queue<int> q;

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if(a > m)
      continue;

    jobs[a].push_back(b);
  }

  ll ans = 0;
  rep(i, m + 1) {
    rep(j, jobs[i].size()) { q.push(jobs[i][j]); }

    if(q.size() > 0) {
      ans += q.top();
      q.pop();
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5504
#include <stdio.h>

int main(void)
{
    char s[4];
    scanf("%s", s);
    int n = 0;
    if (s[0] == '1')
        n++;
    if (s[1] == '1')
        n++;
    if (s[2] == '1')
        n++;
    printf("%d\n", n);
    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

string S;
int n;
lint ans = 0;

void dfs(int i, lint cur) {
	if (i == n) { ans += cur; return; }
	for_(j,i,n) {
		lint x = 0;
		for_(k,i,j+1) x = 10 * x + (S[k] - '0');
		dfs(j + 1, cur + x);
	}
}

int main() {
	cin >> S;
	n = S.size();
	dfs(0, 0);
	cout << ans << endl;
}

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

using namespace std;

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

    vector<int> a(3);
    for(int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    if(a[0] == 5 && a[1] == 5 && a[2] == 7)
        cout << "YES";
    else
        cout << "NO";

    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    int n=atoi(a.c_str());

    for(int i=1;i<2000;i++){
        if(i*i==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  ll n;
  cin >> n;
  ll x = INF;
  vector<ll> v;
  REP(i, n) {
    ll p;
    cin >> p;
    v.pb(p);
    x = min(x, p);
    if (p % 2 == 1) {
      cout << "first" << endl;
      return 0;
    }
  }
  sort(v.begin(), v.end());
  cout << "second" << endl;
}

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

using namespace std;

int main() {
    string s;
    char a, b;
    int anum = 0, bnum = 0;
    cin >> s;
    a = s[0];
    int j = 1;
    rep(i, 3) {
        if (s[i + 1] != a) {
            b = s[i + 1];
            break;
        }
    }
    rep(i, 4) {
        if (s[i] == a)
            anum++;
        else if (s[i] == b)
            bnum++;
    }
    if (anum == 2 && bnum == 2)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	string ret;
	if(s < t)
		ret = "Yes";
	else
		ret = "No";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool solve(string s,string t){
    return (s==t);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    string s,t;
    cin>>N>>s>>t;
    
    rep(i,N){
        int n=N-i;
        if(solve(s.substr(i,n),t.substr(0,n))){
            cout1(N+i)
            return 0;
        }
    }
    cout1(N+N)
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int[] o = new int[n];
			int max = -1;
			int min = 9999;
			boolean alMax = false;
			boolean alMin = false;
			for(int i = 0; i < n; i++) {
				o[i] = stdIn.nextInt();
				if(max < o[i]) {
					max = o[i];
				}
				if(min > o[i]) {
					min = o[i];
				}
			}
			int sum = 0;
			Arrays.sort(o);
			for(int i = 1; i < n-1; i++) {
				sum += o[i];
			}
			System.out.println(sum/(n-2));
		}
	}
}

Measured memory_bytes: 21012
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[102];
int main(){
  int i;
  int res = 0;
  N = rd(S);
  for(i=(0);i<(N/2);i++){
    if(S[i] != S[N-1-i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int N; char S[102];
// {
//   int i, res = 0;
//   rd(S@N);
//   rep(i,N/2) if(S[i] != S[N-1-i]) res++;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(0,min(min(b-a,d-c),min(b-c,d-a))) << endl;


}

Measured memory_bytes: 256
def main():
    from sys import stdin
    input = lambda:stdin.readline().rstrip()
    H,W,K = map(int,input().split())
    S = []
    num_strawberry = [0]*H
    for i in range(H):
        line = list(map(lambda  x: True if x=='#' else False,list(input())))
        S.append(line)
        num_strawberry[i] = line.count(True)
    
    segment = 0
    ans = []
    for i in range(H):
        ans.append([0]*W)
    for i in range(H):

        if num_strawberry[i] != 0:
            segment += 1
            cake = S[i]
            ansline = ans[i]
            num_s = 0
            for j in range(W):
                ansline[j] = segment
                if cake[j] and num_s < num_strawberry[i] -1:
                    num_s += 1
                    segment += 1
    
    determined = -1
    for i in range(H):
        if num_strawberry[i] != 0:
            determined = i
            break
    if determined > 0:
        for i in range(determined):
            ans[i] = ans[determined]
    for i in range(determined+1,H):
        if num_strawberry[i] != 0:
            determined = i
        else:
            ans[i] = ans[determined]



    for line in ans:
        print(*line)


        



main()

Measured memory_bytes: 46684
a=int(input())
b=list(map(int,input().split()))
cnt=0
for i in range(a-2):
  for j in range(i+1,a-1):
    for k in range(j+1,a):
      if not b[i]==b[j] and not b[j]==b[k] and not b[k]==b[i]:
        if b[i]+b[k]>b[j] and b[k]+b[j]>b[i] and b[i]+b[j]>b[k]:
          cnt+=1
print(cnt)

Measured memory_bytes: 9204
#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>;

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int K = d[N /2] - d[N / 2 - 1];
  cout << K << endl;
  
  return 0;
}


Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main()
    {
        int n;
        n = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++)
        {
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(a);
            if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 9428
k = int(input())-1

array = [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]

print(array[k])

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

int main() {
  int n, a, b;
  int tmp, tsum, sum = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    tsum = 0;
    tmp = i;
    while (tmp > 0) {
      tsum += tmp % 10;
      tmp /= 10;
    }
    if (a <= tsum && b >= tsum) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

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


int main(void){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
     
}


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

int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int res = 0;
	int id = 0;
	while (id < n)
	{
		int cnt = upper_bound(a, a + n, a[id]) - a - id;
		if(cnt > a[id]) res += cnt - a[id];
		else if(cnt < a[id]) res += cnt;
		id += cnt;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4000
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
 
      if(A<=B*2){
    System.out.println("0");
      }else{
	System.out.println(A-B*2);
      }
      }
}


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

int kyori(int i, int j){
	int y = i - j;
	if (y < 0) y *= -1;
	return y;
}

int main(){

	int x, a, b;
	cin >> x >> a >> b;
	
	a = kyori(x, a);
	b = kyori(x, b);

	if (a < b) cout << "A" << endl;
	else       cout << "B" << endl;
	 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct fenwick {
    vector<T> node;
    int n;
    fenwick(int _n)
        : n(_n) {
        node.resize(n);
    }
    void add(int x, T v) {
        while (x < n) {
            node[x] += v;
            x |= (x + 1);
        }
    }
    T get(int x) {
        T v = 0;
        while (x >= 0) {
            v += node[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }
    T get(int a, int b) {  // [a, b]
        return get(b) - (a ? get(a - 1) : 0);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> cnt(26);
    vector<int> a(n), val(26);
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a'].emplace_back(i);
    }
    for (int i = 0, c = 1 - n % 2; i < 26; i++) {
        if (cnt[i].size() % 2 == 1) {
            c++;
        }
        if (c == 2) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = 0, id = 0; i < n; i++) {
        int c = s[i] - 'a';
        int m = cnt[c].size();
        if (val[c] < (m + 1) / 2) {
            if (m % 2 == 1 && val[c] * 2 == m - 1) {
                a[cnt[c][val[c]]] = n / 2;
                continue;
            }
            a[cnt[c][val[c]]] = id;
            a[cnt[c][m - 1 - val[c]]] = n - 1 - id;
            id++;
            val[c]++;
        }
    }
    debug(a);
    fenwick<ll> bt(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += bt.get(a[i], n - 1);
        bt.add(a[i], 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3980
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << max(0, a-b) << endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

struct Edge{ int v,len; };
vector<Edge> g[100010];
int root;
vector<int> parent[17],depth;
void DFS(int v,int p,int d) {
    parent[0][v]=p; depth[v]=d;
    for(Edge u:g[v])if(u.v!=p)DFS(u.v,v,d+1);
}
void init(int V) {
    rep(i,0,17)parent[i].resize(V);
    depth.resize(V,-1); DFS(root,-1,0);
    rep(k,0,16)rep(v,0,V) {
        if(parent[k][v]<0)parent[k+1][v]=-1;
        else parent[k+1][v]=parent[k][parent[k][v]];
    }
}
int lca(int u,int v) {
    if(depth[u]>depth[v]) swap(u,v);
    rep(k,0,17)if((depth[v]-depth[u])>>k&1)v=parent[k][v];
    if(u==v)return u;
    rrep(k,16,-1)if(parent[k][u]!=parent[k][v])u=parent[k][u],v=parent[k][v];
    return parent[0][u];
}

int main(){
    int n,x,y; scanf("%d%d%d",&n,&x,&y); x--; y--;
    rep(i,0,n-1){
        int u,v; scanf("%d%d",&u,&v); u--; v--;
        g[u].push_back({v,1}); g[v].push_back({u,1});
    }root=x; init(n);
    int target=-1,ans=depth[y]-1;
    rep(i,0,n)if(i!=x){
        if(depth[lca(i,y)]*2<depth[y]&&chmax(ans,depth[i]+depth[y]-2*depth[lca(i,y)]-1)){
            target=i;
        }
    }
    cerr<<target<<endl;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 16000
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n;string s;
void solve(){
  cin>>n>>s;
  int w=0,r=0,z=0;
  for(auto i:s){
    if(i=='W')w++;
    else r++;
  }
  rep(i,0,r-1){
    if(s[i]!='R')z++;
  }
  cout<<z;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int gcd (int a, int b){
  while(true){
    if(a < b) swap(a, b);
    if(b == 0) break;
    a = a % b;
  }
  return a;
}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;

  ll bc = b/c;
  ll bd = b/d;
  ll bcd = b / (c * d / gcd(c, d));

  ll ac = a / c;
  ll ad = a / d;
  ll acd = a / (c * d / gcd(c, d));

  ll amade = a - (ac + ad - acd);
  ll bmade = b - (bc + bd - bcd);
  ll ans = bmade - amade;
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt()+1;
		int[] a = new int[n];
		int[] b = new int[n - 1];
		long sum = 0;
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		for (int i = 0; i < n - 1; i++)
			b[i] = sc.nextInt();
		for (int i = 0; i < n-1; i++) {
			if (b[i] > a[i]) {
				sum += a[i];
				b[i] = b[i] - a[i];
				if (b[i] > a[i + 1]) {
					sum += a[i + 1];
					a[i + 1] = 0;
				} else {
					sum += b[i];
					a[i + 1] = a[i + 1] - b[i];
				}
			}else {
				sum += b[i];
			}
		}
		System.out.println(sum);
	}
}

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

int main(){
  int N, X, Y;
  std::cin >> N >> X >> Y;
  std::vector<int> distance(N - 1, 0);
  for(int i = 0 ; i < N ; i++){
    for(int j = i + 1 ; j < N ; j++){
      int min = std::min(std::fabs(j - i), std::fabs(Y - j - 1) + 1 + std::fabs(X - 1 - i));
      distance[min - 1]++;
    }
  }

  for(auto && r : distance){
    std::cout << r << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
int main(){
    int l,r;
    cin >> l >> r;

    
    int ans=2018;
    r=min(r,l+4038);

    /*rとlの幅が2019以上なら割り切れる値が存在する*/
    /* if(r-l >= 2018){
        ans=0;
    }*/
    /*幅が2019未満なら全探索*/
    //else{
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                //iとjが異なる値で、最小値よりも小さい値なら最小値を更新
                int x= i*j%2019;
                ans=min(ans,x);
                //if(ans==0)break;
            }
            //if(ans==0)break;
        }
    //}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define zrep(i, a, b, c) for (int i = int(a); i < int(b); i+=int(c))
using ll = long long;
const int INF = 1001001001;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);

    rep(i, N) cin >> H[i];

    vector<vector<int>> to(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> OK;
    int ans = 0;
    rep(i, N) {
        int my_height = H[i];
        int cnt = 0;
        for(auto v: to[i]) {
            if(my_height > H[v]) {
                cnt++;
            }
        }
        if(cnt == to[i].size()) {
            ans++;
            OK.push_back(i);
        }
    }

    print(ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> P(50);
    for (int i = 0; i < n; i++) {
        cin >> P[i];
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (P[i] != i + 1) {
            cnt++;
        }
    }

    if (cnt == 0 || cnt == 2) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}


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

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int answer = min(b,d) - max(a,c);
	if (answer < 0) cout << 0;
	else cout << answer;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] dx = scanner.nextLine().split(" ", 2);
        int d = Integer.parseInt(dx[0]);
        int x = Integer.parseInt(dx[1]);

        int[] people = new int[n];
        for (int i = 0; i < n; i++) {
            people[i] = Integer.parseInt(scanner.nextLine());
        }

        int eaten = 0;
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n; j++) {
                if (i % people[j] == 0) {
                    eaten++;
                }
            }
        }
        System.out.println(x + eaten);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int e, o;
    cin >> e >> o;
    int ways = 0;
    for (int i = 1; i <= e; i++) ways += i - 1;
    for (int i = 1; i <= o; i++) ways += i - 1;

    cout << ways << "\n";
}


Measured memory_bytes: 256
import bisect
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

MAX_V = sum(x[1] for x in wv)

INF = 1 << 60
dp = [0] + [INF] * MAX_V

for w, v in wv:
    # 退避
    dp_tmp = dp[:]
    for j in range(1, MAX_V + 1):
        prev = max(0, j - v)
        dp_tmp[j] = min(dp[j], dp[prev] + w)
    dp = dp_tmp


print(bisect.bisect_right(dp, W) - 1)

Measured memory_bytes: 83924
#include<bits/stdc++.h>
using namespace std;
int k,s,sum=0;
int main(){
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0&&s-x-y<=k) sum++;}}//判断是否越界和正确 
    cout<<sum<<endl;
    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    double a, b;
    cin >> a >> b;
    for (int i = 1; i <= 20000; i++) {
        int aa = (double)i * 0.08;
        int bb = (double)i * 0.10;
        if (aa == a and bb == b) {
            dump(i);
            return 0;
        }
    }
    dump(-1);
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k,q,g;
    cin >> n >> k >> q;
    vector<int> v(n,0);
    for (int i=0;i<q;i++)
    {
        cin >> g;
        g--;
        v[g]++;
    }
    for (int i=0;i<n;i++)
        if(k-(q-v[i])<=0)
            cout << "No" << '\n';
        else
            cout << "Yes" << '\n';
}


Measured memory_bytes: 1024
from collections import defaultdict
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = defaultdict(list)
for i in range(m):
    a, b = map(int,input().split())
    c[a].append(b)
    c[b].append(a)
    
cnt = n
for k,v in c.items():
    for i in range(len(v)):
        if h[v[i] - 1] >= h[k - 1]:
            cnt -= 1
            break
print(cnt)

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
string reff = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    int n;
    cin>>n;
	string s;
	cin>>s;
	string ans = "";
	
	for(char c:s){
	    int index = c-'A' + n;
	    ans += reff[index%26];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  string s;cin>>s;
  int k;cin>>k;
  int n=(int)s.length();
  vector<string> sub(n*5+5,"zzzzzz");
  rep(i,n){
    rep1(j,5){
      sub[i*5+j]=s.substr(i,j);
    }
  }
  sort(sub.begin(),sub.end());
  int c=1;
  int buf;
  rep1(i,n*5){
    if(sub[i-1]==sub[i]);
    else c++;
    if(c>=k){
      buf=i;
      break;
    }
  }
  if(k==1)buf=1;
  cout<<sub[buf]<<endl;
  //cout<<buf<<endl;
  rep(i,n*5){
    //cout<<sub[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = [0]*N
B = [0]*N
C = [0]*N
for i in range(N):
    a,b,c = map(int, input().split())
    A[i] = a
    B[i] = b
    C[i] = c
    
dpa = [0]*N
dpb = [0]*N
dpc = [0]*N
dpa[0] = A[0]
dpb[0] = B[0]
dpc[0] = C[0]

for i in range(1, N):
    dpa[i] = max(dpb[i-1], dpc[i-1]) + A[i]
    dpb[i] = max(dpc[i-1], dpa[i-1]) + B[i]
    dpc[i] = max(dpa[i-1], dpb[i-1]) + C[i]
    
print(max(dpa[-1], dpb[-1], dpc[-1]))

Measured memory_bytes: 53080
#include <stdio.h>

#define INFTY 1000000001

int n,c=0,A[100000000];

int main(){
  int i;

  scanf("%d",&n);

  for(i=0; i < n; i++){
    scanf("%d",&A[i]);
  }
  
  mergeSort(A,0,n);

  for(i=0; i < n; i++){
    printf("%d",A[i]);
    if(i != n-1){
      printf(" ");
    }
  }
  
  printf("\n%d\n",c);
  

  return 0;
}

merge(int *A, int left, int mid, int right){
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  int L[n1+1];
  int R[n2+1];

  for(i=0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i=0; i < n2; i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  
  for(k=left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      c++;
    } else {
      A[k] = R[j];
      j = j + 1;
      c++;
    }
  }
}

mergeSort(int *A, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



Measured memory_bytes: 5616
#include<cstdio>
int main(void){
       int i,j;
       int n;
       int a[200200];

       scanf("%d", &n);
       for(i=0;i<n;i++){
               scanf("%d",&a[i]);
       }
       
       int c=1;
       for(i=0;i<n;i++){
               if(a[i]==c){
                       c++;
               }
       }
       if(c>1){
          printf("%d\n", n-c+1);
       } else {
               printf("-1\n");
       }

       return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, k;
    cin >> a >> b >> k;

    vector<ll> cd;
    rep(i, 1, 101){
        if(a % i == 0 && b % i == 0) cd.push_back(i);
    }
    sort(cd.begin(), cd.end(), greater<ll>());
    cout << cd[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

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

    }

    LL l = a[0];
    al -= a[0];
    LL res = llabs(al - l);
    for( int i = 1; i < n - 1; ++i ) {
        l += a[i];
        al -= a[i];
        res = min( res, llabs(al - l) );

    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p 998244353

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}

int fact(int N){
	static vector<int> _fact(1, 1);
	for(int i = _fact.size(); i <= N; i++){
		_fact.push_back(MOD(i * _fact[i - 1]));
	}
	return _fact[N];
}
 
int fact_inv(int N){
	static vector<int> inv(2, 1), _fact_inv(2, 1);
	for(int i = inv.size(); i <= N; i++){
		inv.push_back(MOD(-(p / i) * inv[p % i]));
		_fact_inv.push_back(MOD(inv[i] * _fact_inv[i - 1]));
	}
	return _fact_inv[N];
}
 
int combination(int N, int k){
	if(k < 0 || N < k || N < 0) return 0;
	else return MOD(fact(N) * MOD(fact_inv(N - k) * fact_inv(k)));
}

signed main(){
	int N, M, i, j;
	scanf("%lld%lld", &N, &M);
	int ans = 0, now;
	for(i = 0; i <= M && i <= N; i++){
		if(i % 2 != M % 2){
			continue;
		}
		ans = MOD(ans + N * MOD(combination(N - 1, i) * combination((M - i) / 2 + (N - 1) - 1, (N - 1) - 1)));
//		printf("ans = %lld\n", ans);
		now = combination((3 * M - i) / 2 + N - 1, N - 1);
//		printf("now1 = %lld\n", now);
/*		for(j = 2 * M; i + j <= 3 * M; j += 2){
			now = MOD(now - N * combination((3 * M - i - j) / 2 + (N - 1) - 1, (N - 1) - 1));
		}
*/		int K = N - 2, x = (3 * M - i) / 2;
		now = MOD(now - MOD(MOD(N * (K - M + x + 1)) * MOD(combination(K - M + x, K) * inverse(K + 1))));
//		printf("now2 = %lld\n", now);
		ans = MOD(ans + now * combination(N, i));
//		printf("ans[%lld] = %lld\n", i, ans);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 40424
n = int(input())
f = []
for i in range(n):#h:高さ
    f.append([int(m) for m in input().split()])
p = []
for i in range(n):#h:高さ
    p.append([int(m) for m in input().split()])

fcount = 0
pcount= 0
pli = []
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for i6 in range(2):
                            for i7 in range(2):
                                for i8 in range(2):
                                    for i9 in range(2):
                                        ili = [i0,i1,i2,i3,i4,i5,i6,i7,i8,i9]
                                        if ili != [0,0,0,0,0,0,0,0,0,0]:
                                            for j in range(n):
                                                for k in range(10):
                                                    if ili[k] == f[j][k] and ili[k] == 1:
                                                        fcount += 1
                                                pcount += p[j][fcount]
                                                fcount = 0
                                            pli.append(pcount)
                                            pcount = 0
print(max(pli))

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int left,int mid,int right){
  int i,j,k,n1=mid-left,n2=right-mid;

  for(i=0;i<n1;i++)L[i] = A[left + i];
  for(i=0;i<n2;i++)R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left;k<right;k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }
    else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[],int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int partition(struct Card A[],int p,int r){
  int i,j;
  struct Card a,x;
  x =A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j].value <= x.value){
      i++;
      a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  a = A[i+1];
  A[i+1] = A[r];
  A[r] = a;
  return i+1;
}

void quickSort(struct Card A[],int p,int r){
  int q;
  if(p<r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable = 1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  mergeSort(A,0,n);
  quickSort(B,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit)stable = 0;
  }
  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
}



Measured memory_bytes: 4196
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define FOR(i,a,b) for(int i=(a), i##_len=(b);i< i##_len; ++i)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int a, b;

signed main()
{
    cin >> a >> b;
    int ans = a > b ? a-1 : a;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256