akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
  int i,N,num,ans=0,sum=0;
  int buf[1000000];
	scanf("%d %d",&N,&num);
	for(i = 0;i < num; i++){
	  scanf("%d",&buf[i]);
	  sum += buf[i];
	}
  
	ans = N - sum;
	if(ans > -1)
	  printf("%d\n",ans);
	else 
	  printf("-1\n");
	  return 0;

}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll X;
    cin >> X;
    X /= 200;
    cout << 10-X << endl;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

    int i = 0;
    for(int a = 0; a <=A; a++)
        for(int b = 0; b <= B; b++)
            for(int c = 0; c <= C; c++)
            {
                int sum = 500*a + 100*b + 50*c;
                if(sum == X) i++;
            }
    cout << i << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int i;
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
  do{
    scanf("%c", &st);
 
    for(i=0;i<52;i++)
      if(al[i] == st){
        st = al[ (i+26)%52 ];
        break;
      }
 
    printf("%c", st);
 
  }while(st != '\n');
 
  return 0;
}



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

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

    bool ans = (a < b) && (b < c);
    for(int i = 0; i < k; i++){
        if (a >= b)b *= 2;
        else if (b >= c)c *= 2;
        
        ans = (a < b) && (b < c);
        if (ans)break;
    }
    if (ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long sum = A.Sum(n => n);
            var counter = new ElementCounter<long>();
            foreach (int a in A) counter.Add(a);

            var dic = counter.Dic;
            var Q = long.Parse(Console.ReadLine());
            for (int i = 0; i < Q; i++)
            {
                var BC = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                var b = BC[0];var c = BC[1];
                if (dic.ContainsKey(b))
                {
                    sum += dic[b] * (c - b);
                    if (dic.ContainsKey(c))
                    {
                        dic[c] += dic[b];
                        dic[b] = 0;
                    }
                    else
                    {
                        dic.Add(c, dic[b]);
                        dic[b] = 0;
                    }
                }
                Console.WriteLine(sum);
            }
        }
    }

    class ElementCounter<T>
    {
        public Dictionary<T, long> Dic;

        public ElementCounter()
        {
            Dic = new Dictionary<T, long>();
        }
        public long this[T key]
        {
            get
            {
                if (Dic.ContainsKey(key))
                {
                    return Dic[key];
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                if (Dic.ContainsKey(key))
                {
                    Dic[key] = value;
                }
                else
                {
                    Dic.Add(key, value);
                }
            }
        }
        public void Add(T item)
        {
            if (Dic.ContainsKey(item))
            {
                Dic[item] += 1;
            }
            else
            {
                Dic.Add(item, 1);
            }
        }
        public void Remove(T item)
        {
            if (Dic.ContainsKey(item))
            {
                Dic[item] = Dic[item] != 0 ? Dic[item] - 1 : 0;
            }
        }
    }
}


Measured memory_bytes: 49580
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, T, A, ans;
    double diff = N_MAX;

    cin >> N >> T >> A;
    
    for (int i = 1; i <= N; i++) {
        int hi;
        double temp;
        cin >> hi;
        temp = T - hi * 0.006;
        if (diff > fabs(temp - A)) {
            diff = fabs(temp - A);
            ans = i;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m;
vi A,B;
int dp[52][52][110][2];
int mem[52][52][110][2][3];
int f(int a,int b,int co,int tu,int pas){
	if(pas==3)return 0;
	if(mem[a][b][co][tu][pas]+inf)return mem[a][b][co][tu][pas];
	 
	int A,B,TU=(tu+co)%2;
	if(!tu)A=a+(1+co)/2,B=b+co/2;
	else A=a+co/2,B=b+(1+co)/2;
	int out;
	if(TU==0){
		out=-inf;
		if(A<n)out=max(out,f(a,b,co+1,tu,0));
		out=max(out,dp[a][b][co][tu]+f(A,B,0,TU^1,pas+1));
//	if(a==2&&b==1&&co==0&&tu==0&&pas==2)cout<<A<<" "<<B<<" "<<pas+1<<" "<<f(A,B,0,TU^1,pas+1)<<endl;
	}else{
		out=inf;
		if(B<m)out=min(out,f(a,b,co+1,tu,0));
		out=min(out,dp[a][b][co][tu]+f(A,B,0,TU^1,pas+1));
	}
	return mem[a][b][co][tu][pas]=out;
}
int main(){
	cin>>n>>m;
	A=vi(n);rep(i,n)cin>>A[i];
	B=vi(m);rep(i,m)cin>>B[i];
	
	rep(l,2)rep(i,n+1)rep(j,m+1){
		int suma=0,sumb=0;
		int L=l,I=i,J=j;
		int co=0;
		while(1){
			dp[i][j][co][l]=suma-sumb;
			if(L&&J>=m||!L&&I>=n)break;
			if(L){
				if(B[J]+1)sumb+=B[J];
				else suma=0;
				J++;
			}else{
				if(A[I]+1)suma+=A[I];
				else sumb=0;
				I++;
			}
			L^=1;
			co++;
		}
	}   
	rep(i,52)rep(j,52)rep(k,110)rep(l,2)rep(q,3)
		mem[i][j][k][l][q]=-inf;
	cout<<f(0,0,0,0,1)<<endl;
}








Measured memory_bytes: 12348
#include <stdio.h>
#include <stdlib.h>

static const char* LUT[ 8 ] = {
  "Close", "Open", "Close", "", "Close", "", "Open", "" };

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int d1, d2, d3;

  scanf ( "%d%d%d", &d1, &d2, &d3 );
  puts ( LUT[ d1 << 2 | d2 << 1 | d3 ] );

  return ( EXIT_SUCCESS );
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e7 + 11 ;

int  main (  ) {

    FASTIO ;

    int n ;
    cin >> n ;

    int f = 0 ;

    while( n ){
        int k = n % 10 ;

        if( k == 7 ) f++ ;

        n /= 10 ;
    }
    if( f ) cout << "Yes" ;
    else   cout << "No" ;


    return  0 ;
}


Measured memory_bytes: 3616
#include<iostream>
#include<queue>
using namespace std;
struct xy{
  int tx,ty;
  int kx,ky;
  int ti;
};
int x,y;
xy tk;
int m[51][51],v[51][51][51][51]={};
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


bool g(int a,int b){
  if(a<1 || a>x || b<1 || b>y) return 0;
  return 1;
}

int bfs(){
  queue<xy> q;
  xy t,tmp;
  int ta,tb,ka,kb,ans=10000,tim,cnt=0;
  q.push(tk);
  while(!q.empty()){
    t=q.front(),q.pop();
        for(int i=0;i<4;i++){
      ta=t.tx+dx[i],tb=t.ty+dy[i],ka=t.kx-dx[i],kb=t.ky-dy[i],tim=t.ti+1;
      if(g(ta,tb) || g(ka,kb)){
	cnt++;
	if(!g(ta,tb))ta=t.tx,tb=t.ty;
	if(!g(ka,kb))ka=t.kx,kb=t.ky;

	if(m[ta][tb]==1) tmp.tx=t.tx,tmp.ty=t.ty;
	else tmp.tx=ta,tmp.ty=tb;
	
	if(m[ka][kb]==1) tmp.kx=t.kx,tmp.ky=t.ky;
	else tmp.kx=ka,tmp.ky=kb;
	
	if(v[tmp.tx][tmp.ty][tmp.kx][tmp.ky]==1)continue;
	if(m[ka][kb]==1 && m[ta][tb]==1)continue;
		tmp.ti=tim;
		v[tmp.tx][tmp.ty][tmp.kx][tmp.ky]=1;
	if(tmp.tx==tmp.kx && tmp.ty==tmp.ky){
	  if(ans>tmp.ti) ans=tmp.ti;
	  continue;
	}
	
       	if(tmp.ti>=100) break;
	q.push(tmp);
      }
    }
  }
  return ans;
}

int main(){
  while(1){
    int ans;
    cin>>x>>y;
    if(x+y==0) break;
    cin>>tk.tx>>tk.ty>>tk.kx>>tk.ky;
    for(int i=1;i<=x;i++)
      for(int j=1;j<=y;j++)
	for(int k=1;k<=x;k++)
	  for(int l=1;l<=y;l++) v[i][j][k][l]=0;
      v[tk.tx][tk.ty][tk.kx][tk.ky]=1;
    tk.ti=0;
    for(int i=1;i<=y;i++)
      for(int j=1;j<=x;j++)
	cin>>m[j][i];
      
       ans=bfs();
    if(ans<100) cout<<ans<<endl;
    else cout<<"NA"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 28188
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::vector<int64_t> A(N);
    for (auto& v : A) std::cin >> v;

    int64_t ans = 0;
    int64_t prev = A[0];

    for (int64_t i = 1; i < N; i++)
    {
        int64_t diff = prev - A[i];
        if (diff <= 0)
        {
            prev = A[i];
            continue;
        }
        ans += diff;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 4776
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	X := nextInt()
	var ans int
	dep := 100
	for {
		dep += dep / 100
		ans++
		if dep >= X {
			break
		}
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 1792
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu
// 2017.20.29

#include <stdio.h>
#include <stdlib.h>

int a[40003], b[40003];

int cmp(int *a, int *b) { return *b - *a; }

char buf[280000], *p;
int getint()
{
	int n;
	n = 0; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, k, ans;
	int *pt;

	while (fgets(p=buf, 8, stdin) && *p != '0') {
		n = getint();
		fgets(p=buf, 280000, stdin);
		i = n, pt = a; while (i--) *pt++ = getint(), p++;
		fgets(p=buf, 280000, stdin);
		i = n, pt = b; while (i--) *pt++ = getint(), p++;
#if 0
	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", a+i);
		for (i = 0; i < n; i++) scanf("%d", b+i);
#endif
		qsort(a, n, sizeof(int), cmp);
		qsort(b, n, sizeof(int), cmp);

		for (ans = n, i = k = 0; k < n; i++, k += 2) {
			if (a[k] > b[i]) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

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

#define ll long long

int main(void){
    int n; cin >> n;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll tmp; cin >> tmp;
        while(tmp%2==0) ans++,tmp/=2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    char symbol[500010]={};
    int  num[500010];
    scanf("%s",&symbol);
    int i,size;
    for(i=0;500001>i;i++){
        num[i]=-1;
        if(symbol[i]==NULL){
            size = i;
            break;
        }
    }
    int j,k,ct;

    if(symbol[0] == '<'){
        num[0]=0;
        ct=1; k=1;
        while(1){
                if(num[k]!=-1||k>size||symbol[k-1]=='>') break;
                else  num[k] = ct;
                ct++; k++;
            }
    }    
    //printf("%d\n",size);
    if(symbol[size-1] == '>'){
      num[size]=0;
      ct=1;j=size-1;
      while(1){
                if(j==-1||symbol[j]=='<'||num[j]>ct) break;
                else  num[j] = ct;
                ct++; j--;
            }
    } 
    
    for(i=0;size>i;i++){
        
        if(symbol[i]=='>'&&symbol[i+1]=='<'){
            num[i+1]=0;
            j=i; k=i+2; ct=1;
            while(1){
                if(j==-1||symbol[j]=='<'||num[j]>ct) break;
                else  num[j] = ct;
                ct++; j--;
            }
            ct=1;
            while(1){
                if(k>size||symbol[k-1]=='>'||num[k]>ct) break;
                else num[k] = ct;
                ct++; k++;
            }
        }
    }
  
    long int sum=0;
    for(i=0;size>=i;i++){
       // if(size>i)  printf("%d%c",num[i],symbol[i]);
        //if(num[i]<0) printf("error\n");
        /*else*/    sum+=num[i];
    }
    //printf("%d\n",num[size]);
    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 2560
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let d: i64 = sc.read();
    let mut ans = 0;
    for _ in 0..n {
        let x: i64 = sc.read();
        let y: i64 = sc.read();
        let d2 = x * x + y * y;
        if d2 <= d * d {
            ans += 1;
        }
    }

    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

void solve(){
	int n; cin>>n;
	if(n%10 == 3){
		cout<<"bon";
	}
	else if(n%10 == 1 || n%10 == 0 || n%10 == 6 || n%10 == 8){
		cout<<"pon";
	}
	else cout<<"hon";

}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 3652
#DP B
n,k=map(int,input().split())
h=list(map(int,input().split()))
data=[]
if n<=k:
    print(abs(h[n-1]-h[0]))
else:
    for i in range(k+1):
        data.append(abs(h[i]-h[0]))
    for i in range(k+1,n):
        a=float("inf")
        for j in range(1,k+1):
            a=min(a,abs(h[i]-h[i-j])+data[i-j])
        data.append(a)
    print(data[-1])

Measured memory_bytes: 57696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    unsigned long long f[87];
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp[4],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c;
    ll ma=max({a,b,c});
    ans=(ma-a)/2+(ma-b)/2+(ma-c)/2;
    a+=((ma-a)/2)*2;
    b+=((ma-b)/2)*2;
    c+=((ma-c)/2)*2;
    tmp[0]=a;
    tmp[1]=b;
    tmp[2]=c;
    sort(tmp,tmp+3);
    if(tmp[2]==tmp[0]){
        Cout(ans);
    }
    else if(tmp[2]==tmp[1]){
        Cout(ans+2);
    }
    else{
        Cout(ans+1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{
    string s,t;
    int i,c=0;
    cin>>s>>t;
    for(i=0;i<3;i++)
    {
        if(s[i]==t[i])
        {
            c++;
        }
    }
    cout<<c;

    return 0;
}


Measured memory_bytes: 3632
use std::io;
fn main() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let x: Vec<u8> = x.trim().split_whitespace().map(|x| x.parse::<u8>().unwrap()).collect();
    println!("{} {}", x[0] * x[1], 2 * x[0] + 2 * x[1]);
}


Measured memory_bytes: 5020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll l[n];
    rep(i, n){
        cin >> l[i];
    }

    sort(l, l+n);

    ll cnt = 0;
    rep(i, n){
        reps(j, i+1, n){
            reps(k, j+1, n){
                if(l[k] < l[i] + l[j]){
                    if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]){
                        continue;
                    }
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3648
#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];
    }
    int m=A[0];
    long int ans=0;
    for(int i=1;i<n;i++)
    {
        if(A[i]<m)
        {
            ans+=(m-A[i]);
        }
        else
        {
            m=A[i];
        }
        
    }
    cout<<ans<<endl;
}


       
    
    
    

Measured memory_bytes: 4372
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



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

	rep(i, m) {
		int a;
		cin >> a;
		n -= a;
	}
	cout << max(-1, n) << endl;
}




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

int main() {
    int a, b, c;
    int cho = 0;
    int hishi = 0;
    while (scanf("%d,%d,%d", &a, &b, &c)!= EOF) {

        if (a == b)
            hishi++;
        if (a*a + b*b == c*c)
            cho++;
        //printf("hishi=%d, cho=%d\n", hishi, cho);
    }

    cout << cho << endl;
    cout << hishi << endl;
}


Measured memory_bytes: 3120
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashSet<String> hs = new HashSet<String>();
		int N = sc.nextInt();
		for(int i = 0; i<N;i++) {
			hs.add(sc.next());
		}
		System.out.println(hs.size());

	}

}


Measured memory_bytes: 77928
/**
 *  author: andychen
 *  created: 09.19.2020 23:06:28
**/

#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353;

int sum(int idx, vector<int> &bit){
    int s = 0;
    for (int i = idx; i > 0; i -= (i & -i)){
        s += bit[i];
        s %= mod;
    }

    return s;
}

void add(int idx, int x, vector<int> &bit){
    for (int i = idx; i < (int) bit.size(); i += (i & -i)){
        bit[i] += x;
        bit[i] %= mod;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> s(k);
    for (int i = 0; i < k; i++)
        cin >> s[i].first >> s[i].second;

    vector<int> bit(n + 1);
    add(1, 1, bit);
    for (int i = 1; i <= n; i++){
        for (auto& [l_seg, r_seg] : s){
            int l = max(0, i - r_seg);
            int r = max(0, i - l_seg);

            if (r > 0){
                int val = sum(r, bit) - sum(l - 1, bit);

                while (val < 0){
                    val += mod;
                }

                add(i, val, bit);
            }
        }
    }

    int ans = sum(n, bit) - sum(n - 1, bit);
    while (ans < 0){
        ans += mod;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] topping = new char[3];
            topping[0] = S[0];
            topping[1] = S[1];
            topping[2] = S[2];

            Console.WriteLine(700 + topping.Where(x => x == 'o').Count() * 100);


        }
    }
}


Measured memory_bytes: 11220
def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = b[1]*a[0] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33920
#include <bits/stdc++.h>
using namespace std;
const int N=2.5e4+10,K=410,p=1e9+7;
int n,k,m,a[N],cnt[K];
long long ans,f[2][K],g[2][K];
inline long long fpow(register long long a,register long long b){
    register long long c=1;
    for(;b;b>>=1,(a*=a)%=p)
        if(b&1) (c*=a)%=p;
    return c;
}
inline void cadd(register long long &a,register long long b){a=(a+b)%p;}
long long work1(){
    register int o=0;
    memset(f[o],0,sizeof(f[o]));
    memset(g[o],0,sizeof(g[o]));
    f[o][0]=1;
    for(int i=0;i<n;i++){
        memset(f[o^1],0,sizeof(f[o^1]));
        memset(g[o^1],0,sizeof(g[o^1]));
        for(int j=0;j<k;j++){
            if(j+1!=k){
                cadd(f[o^1][j+1], f[o][j]*(k-j));
                cadd(f[o^1][j+2],-f[o][j]*(k-j));
                cadd(g[o^1][j+1], g[o][j]*(k-j));
                cadd(g[o^1][j+2],-g[o][j]*(k-j));
            }
            cadd(f[o^1][  1], f[o][j]);
            cadd(f[o^1][j+1],-f[o][j]);
            cadd(g[o^1][  1], g[o][j]);
            cadd(g[o^1][j+1],-g[o][j]);
        }
        o^=1;
        for(int j=1;j<k;j++){
            cadd(f[o][j],f[o][j-1]);
            cadd(g[o][j],g[o][j-1]);
        }
        for(int j=m;j<k;j++)
            cadd(g[o][j],f[o][j]);
    }
    long long res=0;
    for(int i=0;i<k;i++)
        cadd(res,g[o][i]);
    return res;
}
long long F[N],G[N];
void work2(long long f[2][K],long long F[N],long long _){
    register int o=0;
    memset(f[o],0,sizeof(f[o]));
    F[0]=f[o][_]=1;
    for(int i=0;i<n;i++){
        memset(f[o^1],0,sizeof(f[o^1]));
        for(int j=0;j<k;j++){
            if(j+1!=k)
                cadd(f[o^1][j+1], f[o][j]*(k-j)),
                cadd(f[o^1][j+2],-f[o][j]*(k-j));
            cadd(f[o^1][  1], f[o][j]);
            cadd(f[o^1][j+1],-f[o][j]);
        }
        o^=1;
        for(int j=1;j<k;j++)
            cadd(f[o][j],f[o][j-1]),
            cadd(F[i+1],f[o][j]);
    }
}
int main(){
    scanf("%d%d%d",&n,&k,&m);
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i]);
    ans=(n-m+1)*fpow(k,n-m)%p;
    int Cnt=0;
    if(m>=k) {
        for(int i=1;i<=k;i++)
            if(cnt[a[i]]++==0) Cnt++;
        for(int i=k+1;i<=m&&Cnt!=k;i++){
            if(--cnt[a[i-k]]==0) Cnt--;
            if(cnt[a[i  ]]++==0) Cnt++;
        }
        if(Cnt==k){
            printf("%lld\n",(ans+p)%p);
            return 0;
        }
        Cnt=1;
    }
    else {
        Cnt=0;memset(cnt,0,sizeof(cnt));
        for(int i=1;i<=m;i++)
            if(cnt[a[i]]++!=0) {Cnt=1;break;}
    }
    long long tmp=1;
    if(!Cnt){
        for(int i=k;i>k-m;i--) tmp=tmp*i%p;
        ans=(ans-fpow(tmp,p-2)*work1()%p)%p;
    } else {
        Cnt=0;memset(cnt,0,sizeof(cnt));
        for(tmp=1;tmp<=m;tmp++)
            if(cnt[a[tmp]]++!=0) {Cnt=1;break;}
        work2(f,F,tmp-1);
        Cnt=0;memset(cnt,0,sizeof(cnt));
        for(tmp=m;tmp>=1;tmp--)
            if(cnt[a[tmp]]++!=0) {Cnt=1;break;}
        work2(g,G,m-tmp);
        for(int i=0;i<=n-m;i++)
            ans=(ans-F[i]*G[n-m-i])%p;
    }
    printf("%lld\n",(ans+p)%p);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int n,m; cin>>n>>m;
    map<int,int> wa;
    map<int,int> ac;
    int wasum=0;
    FOR(i,m) {
        int p;
        string S;
        cin>>p>>S;
        if(ac.count(p))
            continue;
        if(S=="AC") {
            wasum += wa[p];
            ac[p]++;
        } else {
            wa[p]++;
        }
    }

    cout<<ac.size()<<" "<<wasum<<endl;

    return 0;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  bool can = true;
  
  if(S.at(0)!='A') can = false;
  
  int num_C = 0;
  for(int i=2;i<S.size()-1;i++){
    if(S.at(i)=='C') num_C ++;
  }
  if(num_C!=1) can =false;

  int num_upper = 0;
  for(int i=0;i<S.size();i++){
    if(isupper(S.at(i))) num_upper ++;
  }
  if(num_upper!=2) can = false;
  
  if(can) cout << "AC" << endl;
  else cout << "WA" << endl;  
}

Measured memory_bytes: 3592
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())

A=[a1,b1,a2,b2,a3,b3]

import collections
L=collections.Counter(A)

if set(list(L.values()))==set([1,2,2,1]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9460
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = in.nextInt();
            int a, b;
            a = 0;
            b = Math.abs(arr[0] - arr[1]);
            for (int i = 2; i < n; i++) {
                int temp = b;
                b = Math.min(b + Math.abs(arr[i] - arr[i - 1]), a + Math.abs(arr[i] - arr[i - 2]));
                a = temp;
            }
            out.println(b);
        }

    }
}



Measured memory_bytes: 49396
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n,m;
    cin >> n >> m;
    int a,b;
    cin >> a >>b;
    int x,y;
    int xm = -100,ym = 100;
    for(int i = 0;i < n;i++){
        cin >> x;
        xm = max(xm,x);
    }
    xm = max(xm,a);
    for(int i = 0;i < m;i++){
        cin >> y;
        ym = min(ym,y);
    }
    ym = min(ym,b);
    if(xm>=ym) cout <<"War" << endl;
    else cout << "No War" << endl;
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[200005],b[200005],ans;
pair<ll,ll>x[200005];
int main(){
	cin >> n;
	
	for(int i=1; i<=n; i++){
		cin >> a[i] >> b[i];
		x[i] = {a[i] + b[i],(ll)i};
	}
	sort(x+1,x+n+1);
	reverse(x+1,x+n+1);
	for(int i=1; i<=n; i++){
		if(i%2)ans += a[x[i].s];
		else ans -= b[x[i].s];
	}
	cout << ans;
	
	
	
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define LFOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define LREP(i, n) LFOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> l(k), r(k);
  for(int i = 0, cur = 0; cur < k;) {
    if (s[i] == 'x') {
      i++;
      continue;
    }
    l[cur] = i + 1;
    i += c + 1;
    cur++;
  }
  reverse(ALL(s));
  for(int i = 0, cur = 0; cur < k;) {
    if (s[i] == 'x') {
      i++;
      continue;
    }
    r[cur] = n - i;
    i += c + 1;
    cur++;
  }
  reverse(ALL(r));
  reverse(ALL(s));
  REP(i, k) {
    if (l[i] == r[i]) {
      cout << l[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 1000

bool is(ll x) {
  s = to_string(x);

  FOR(i, 0, s.size()/2) {
	if (s[i] != s[s.size() - i - 1]) return false;
  }
  return true;
}

int main(void) {
  ll a, b;

  cin >> a >> b;

  FOR(i, a, b + 1) {
	if (is(i)) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

#define MOD 1000000007
int main() {
    int N,K;
    cin >> N >> K;
    int a[N];

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

    vector<vector<long long>>dp(N, vector<long long>(K+1, 0));

    for(int i=0;i<N;i++){
        for(int j=0;j<=K;j++){
            if(i == 0 and j <= a[0])
                dp[i][j] = 1;
            
            if(j == 0)
                dp[i][j] = 1;
        }
    }

    for(int j=1;j<=K;j++){
        dp[0][j] += dp[0][j-1];
    }

    for(int i=1;i<N;i++){
        for(int j=1;j<=K;j++){
            int x = 0;
            if(j <= a[i])
                x = dp[i-1][j];
            else
                x = (dp[i-1][j]- dp[i-1][j-a[i]-1]+ MOD)%MOD;
            
            dp[i][j] = (dp[i][j-1] + x)%MOD;
        }
    }

    // for(int i=0;i<N;i++){
    //     for(int j=0;j<=K;j++){
    //        cout << dp[i][j]<<" ";
    //     }
    //     cout << endl;
    // }
    
    if(K-1 >= 0)
        cout << (dp[N-1][K] - dp[N-1][K-1] + MOD)%MOD;
    else 
        cout << dp[N-1][K]%MOD;

}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    char s[100000];
    cin>>n;
    for(int i = 0;i<n;i++)
        cin>>s[i];
    int count = 0;
    for(int i = 0;i<n-1;i++)
    {
        if(s[i] == s[i+1])
            count++;
    }
    cout<<n-count;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    int A, B, K;

    cin >> A >> B >> K;

    vector<int> endiv;
    for(int i = 100; i > 0; i--){
        if(A%i==0 && B%i==0){
            endiv.push_back(i);
        }
    }

    cout << endiv[K-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	vector<int>l;
	while (cin >> a){
		if (a == 0){
			cout << l.back()<<endl;
			l.pop_back();
		}else{
			l.push_back(a);
		}
	}
}

Measured memory_bytes: 3080
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int &n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a, b, n;
	cin >>a >>b >>n;
	if(n < 1000000){
		ll ans = -1000000;
		for(ll i=1; i<= n ; i++){
			ll w = (i * a )/b - a * (i/b);
			ans = max(ans, w);
			//printf("%d ",w);
		}
		cout << ans <<"\n";
		return 0;
	}
	ll c  = n>=b-1? b-1: n;
	ll w2 = (c*a)/b - a*(c/b);
	cout << w2 <<"\n";
	return 0;
}


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

int main() {
  string ans;
  int m, f, r;
  while(true) {
    scanf("%d %d %d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1) break;
    if(m == -1 || f == -1) printf("F\n");
    else if(m + f >= 80) printf("A\n");
    else if(m + f >= 65) printf("B\n");
    else if(m + f >= 50) printf("C\n");
    else if(m + f >= 30) {
      if(r >= 50) printf("C\n");
      else printf("D\n");
    }else printf("F\n");
  }
}


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

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

    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    int c = (a / k);
    if (k * c + k <= b || k * c == a)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<math.h>
#define ll long long
using namespace std;
ll n,a,b;
signed main(){
	scanf("%lld",&n);
	while(n--){
		scanf("%lld %lld",&a,&b);
		ll ans=sqrt(a*b);
		if(ans*(ans+1)<a*b) ans=ans*2-1;
		else if(ans*ans==a*b&&a!=b) ans=2*(ans-1)-1;
		else ans=2*(ans-1);
		printf("%lld\n",ans);
	}
}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int W = Integer.parseInt(str[0]);
		int H = Integer.parseInt(str[1]);
		int n = Integer.parseInt(str[2]);

		int xmin = 0;
		int xmax = W;
		int ymin = 0;
		int ymax = H;
		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			int a = Integer.parseInt(str[2]);
			if (a == 1)
				xmin = Math.max(xmin, x);
			if (a == 2)
				xmax = Math.min(xmax, x);
			if (a == 3)
				ymin = Math.max(ymin, y);
			if (a == 4)
				ymax = Math.min(ymax, y);
		}
		int ans = Math.max(0, xmax - xmin) * Math.max(0, ymax - ymin);
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[m];
	int sum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum=sum+a[i];
	}
	if(sum==n){
		cout<<"0";
	}
	else if(sum<n){
		cout<<n-sum;
	}
	else if(sum>n){
		cout<<"-1";
	}
  return 0;}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdbool.h>
bool f(int x) {
    int keta = 0;
    while (x) {
        keta++;
        x /= 10;
    }
    return keta%2 == 1;
}
int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n ; ++i) {
        if (f(i)) ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
a = list(map(int,input().split()))
minus = []
plus = []
ans = 10**100
for x in a:
    if x <0:minus.append(-x)
    else:plus.append(x)
minus = minus[::-1]
for i in range(min(k+1,len(minus)+1)):#負のものをi個通る
    if k-i > len(plus):continue
    res = 0
    if i-1 >=0:res += minus[i-1]
    res*=2
    if k-i-1 >=0 and k-i <= len(plus):res += plus[k-i-1]
    ans = min(ans,res)
    res = 0
    if k-i-1 >=0 and  k-i <= len(plus):res += plus[k-i-1]
    res *=2
    if i-1 >=0:res += minus[i-1]
    ans = min(ans,res)
print(ans)

    
    
    
    

Measured memory_bytes: 14480
n=int(input())
a=list(map(int,input().split()))
checker=0
count=0
for i in range(len(a)):
  if a[i]%2==0:
    checker+=1
    if a[i]%3==0 or a[i]%5==0:
      count+=1
if checker==count:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int out[60100];
int main()
{
	memset(out,0,sizeof(out));
	REP(i,1,101) REP(j,1,101) REP(k,1,101){
		out[i*i+j*j+k*k+i*j+j*k+k*i]++;
	}
	int n;cin>>n;
	rep(i,n) cout<<out[i+1]<<endl;
}


Measured memory_bytes: 3824