akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scan_ = new Scanner(System.in);
        int hours_    = 0;
        int minutes_  = 0;
        int secconds_ = 0;
        int totalSecconds_ = scan_.nextInt();
        
         hours_ = totalSecconds_ / 3600;
         totalSecconds_ -= hours_ * 3600;
         minutes_ = totalSecconds_ / 60;
         totalSecconds_ -= minutes_ * 60;
         secconds_ = totalSecconds_;
         System.out.println(hours_ + ":" + minutes_ + ":" + secconds_);
    }
}


Measured memory_bytes: 26188
N,  K = map(int, input().split())
candles = list(map(int, input().split()))
ans = float('inf')
for i in range(N - K + 1):
    if candles[i] * candles[i + K - 1] >= 0:
        t = max(abs(candles[i]), abs(candles[i + K - 1]))
    else:
        t = candles[i + K - 1] - candles[i] + min(abs(candles[i]), abs(candles[i + K - 1]))
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> fl(3);
  for(int i =0; i<3; i++) {
    cin >> fl.at(i);
  }
  sort(fl.begin(),fl.end());
  cout << fl.at(0) + fl.at(1) << endl;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 3013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
ll arr[MAXN];
ll dp[MAXN][MAXN];
bitset<MAXN> vis[MAXN];

ll solve(int l, int r)
{
	if (l > r) return 0;
	if (vis[l][r]) return dp[l][r];
	vis[l][r] = true;
	if ((l + r + N) & 1)
	{
		dp[l][r] = max(solve(l + 1, r) + arr[l], solve(l, r - 1) + arr[r]);
	}
	else
	{
		dp[l][r] = min(solve(l + 1, r) - arr[l], solve(l, r - 1) - arr[r]);
	}
	return dp[l][r];
}


int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N) cin >> arr[i];
	cout << solve(0, N - 1) << '\n';
}


Measured memory_bytes: 72064
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static char s[1 << 20];
    multiset < int , greater < int > > S;
    fi>>(s + 1);
    int n = strlen(s + 1);
    for (int i = 1;i <= n;++i)
    {
        if (!S.empty())
        {
            int node = *S.begin();
            if (s[node] == 'S' && s[i] == 'T')
                S.erase(S.begin());
            else
                S.insert(i);
        }
        else S.insert(i);
    }
    fo << (S.size()) << '\n';
    return 0;
}

Measured memory_bytes: 9728
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> dv;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            if(i*i==m){
                dv.push_back(i);
            }
            else{
                dv.push_back(i);
                dv.push_back(m/i);
            }
        }
    }
    sort(dv.begin(),dv.end());
    auto it=lower_bound(dv.begin(),dv.end(),n)-dv.begin();
    cout << m/dv[it] << endl;
    return 0;
} 

Measured memory_bytes: 256
n, k = gets.split.map &:to_i
ptR, ptS, ptP = gets.split.map &:to_i
enemy = gets.chomp.chars

hands = []
ans = 0

for i in 0 .. n - 1

  case enemy[i]

  when "r"
    if i < k
      hands << "p"
      ans += ptP
    else
      if hands[i - k] != "p"
        hands << "p"
        ans += ptP
      else
        hands << "n"
      end
    end

  when "s"
    if i < k
      hands << "r"
      ans += ptR
    else
      if hands[i - k] != "r"
        hands << "r"
        ans += ptR
      else
        hands << "n"
      end
    end

  when "p"
    if i < k
      hands << "s"
      ans += ptS
    else
      if hands[i - k] != "s"
        hands << "s"
        ans += ptS
      else
        hands << "n"
      end
    end
  end
end

puts ans


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

class Card {
    char name;
    char value;

    Card(char name, char value) {
        this.name = name;
        this.value = value;
    }
}

class Main {
    public static Card[] BubbleSort(Card[] cards, int n) {
        Card tmp;
        for (int i = 0; i < n; i++) {
            for (int j = n - 1; j >= i + 1; j--) {
                if (cards[j - 1].value > cards[j].value) {
                    tmp = cards[j - 1];
                    cards[j - 1] = cards[j];
                    cards[j] = tmp;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (i != 0)
                System.out.print(" ");
            System.out.printf("%c%c", cards[i].name, cards[i].value);
        }
        System.out.print("\nStable\n");
        return cards;
    }

    public static Card[] SelectSort(Card[] cards, int n) {
        int minIdx;
        Card tmp;
        for (int i = 0; i < n; i++) {
            minIdx = i;
            for (int j = i; j < n; j++) {
                if (cards[minIdx].value > cards[j].value)
                    minIdx = j;
            }
            tmp = cards[i];
            cards[i] = cards[minIdx];
            cards[minIdx] = tmp;
        }

        for (int i = 0; i < n; i++) {
            if (i != 0)
                System.out.print(" ");
            System.out.printf("%c%c", cards[i].name, cards[i].value);
        }
        System.out.print("\n");
        return cards;
    }

    public static void isStable(Card[] a, Card[] b, int n) {
        for (int i = 0; i < n; i++) {
            if (a[i].name != b[i].name) {
                System.out.print("Not stable\n");
                return;
            }
        }
        System.out.print("Stable\n");
    }

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n;
        Card[] cards, cards2;

        String[] inputData;
        try {
            n = Integer.parseInt(br.readLine());
            cards = new Card[n];
            cards2 = new Card[n];
            inputData = br.readLine().split(" ");

            for (int i = 0; i < n; i++) {
                cards[i] = new Card(inputData[i].charAt(0), inputData[i].charAt(1));
                cards2[i] = new Card(inputData[i].charAt(0), inputData[i].charAt(1));
            }

            isStable(BubbleSort(cards, n), SelectSort(cards2, n), n);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24868
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	if(n > m) swap(n, m);
	if(n == 1 && m == 1) cout << 1 << endl;
	else if(n == 1) cout << m - 2 << endl;
	else{
		ll ans = (n - 2ll) * (m - 2);
		cout << ans << endl;
	}
	
	return 0;
}

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

int r[99];

int main(){
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    int ans = INT_MAX;
    for(int i = 1; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            int z = abs(x[j] - i);
            if(r[z] != 0) {
                sum += r[z];
            }else {
                sum += r[z] = z * z;
            }
        }
        ans = min(sum, ans);
    }
    cout << ans << endl;
    return 0;
}

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

#define MAXN (300010) 
#define ll long long

int n;
int a[MAXN];
ll max_sum[MAXN], min_sum[MAXN];
std::multiset<int> set;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n + n + n; ++ i){
		scanf("%d", a + i);
	}
	
	ll sum = 0;
	for(int i = 1; i <= n; ++ i) set.insert(a[i]), sum += a[i];
	max_sum[n] = sum;
	for(int i = n + 1; i <= n + n; ++ i){
		std::multiset<int>::iterator it = set.begin();
		if(*it < a[i]){
			sum += a[i] - *it;
			set.erase(it);
			set.insert(a[i]);
		}
		max_sum[i] = sum;
	}
	
	set.clear();
	sum = 0;
	for(int i = n + n + n; i > n + n; -- i) set.insert(a[i]), sum += a[i];
	min_sum[n + n + 1] = sum;
	for(int i = n + n; i > n; -- i){
	    std::multiset<int>::iterator it = -- set.end();
	    if(*it > a[i]){
	    	sum += a[i] - *it;
	    	set.erase(it);
	    	set.insert(a[i]);
	    }
	    min_sum[i] = sum;
	}
	
	ll ans = LLONG_MIN;
	for(int i = n; i <= n + n; ++ i){
		ans = std::max(ans, max_sum[i] - min_sum[i + 1]);
	}
	
	printf("%lld\n", ans);
	
    return 0;
}

Measured memory_bytes: 9088
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000000007

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))
#define mx 6e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
#define ll long long
const int maxn = 20005;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int main()
{
    ll n,k;
    cin>>n>>k;
    ll x = ((n-1) * (n-2))/2;
    
    if(k>x)
    {
        cout<<-1<<endl;
        exit(0);
    }
    
    ll extra = x-k;
    ll total = n-1 + extra;
    
    cout<<total<<endl;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cout<<i<<' '<<j<<endl;
            total--;
            if(total==0)
            {
                exit(0);
            }
        }
    }
}

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

int main(){
  int n;
  vector<int> vc;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vc.push_back(x);
  }

  sort(vc.begin(), vc.end());

  cout << vc[n - 1] - vc[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans,x[3100000];
char ch,s[3100000],t[3100000];
int main(){
//	freopen("string.in","r",stdin);
//	freopen("string.out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s); scanf("%s",t);
	int j=n,k=0,l=0;
	for (int i=n-1;i>=0;i--){
		if (j>i&&t[i]!=s[i]) j=i;
		if (j<=i&&t[i]!=s[j]){
		    while (j>=0&&t[i]!=s[j]) j--;
		    if (j<0){ puts("-1"); return 0;}
		    k++; l++; x[j+l]++;
		    ans=max(ans,k);
		}
		k-=x[i+l]; x[i+l]=0;
    }
	printf("%d\n",ans);
	return 0;
}
/*
13
utsasttpqrstk
uuuuaaaaapppp

13
utsasttpqrstk
uusaaaaaapppp
*/

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

using namespace std;

int n;
int a[100010],dp[100010];

void read()
{
    cin >> n;
    for (int i = 1;i <= n;i++){
        cin >> a[i];
    }
}

void solve()
{
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for (int i = 3;i <= n;i++){
        dp[i] = min(abs(a[i-1] - a[i]) + dp[i-1], abs(a[i-2] - a[i]) + dp[i-2]);
    }
    cout << dp[n];
}

main()
{
    read();
    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

const int KIND = 26;
int D;
int c[KIND];
int s[400][KIND];
int last[KIND];

ll calc_score(vector<ll> t) {
    ll score = 0;
    fill(last, last + 26, -1);
    for(int d = 0; d < D; d++) {
        score += s[d][t[d]];
        last[t[d]] = d; 
        for(int i = 0; i < KIND; i++) {
            score -= c[i] * (d - last[i]);
        }
        cout << score << endl;
    }
    return score;
}

int main() {
    cin >> D;
    for(int i = 0; i < KIND; ++i) {
        cin >> c[i];     
    }
    for(int d = 0; d < D; d++) {
        for (int i = 0; i < KIND; i++) {
            cin >> s[d][i];
        }
    }

    vector<ll> t(D);
    for (auto &elem : t) {
        cin >> elem;
        elem--;
    }

    calc_score(t);

    return 0;
}

Measured memory_bytes: 3660
import sys
from collections import deque
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
dist[0][0] = 1
Q = deque()
Q.append([0, 0])
c = 0
for l in s:
    c += l.count('.')

yudlr = [1, -1, 0, 0]
xudlr = [0, 0, -1, 1]

while len(Q) > 0:
    q = Q.popleft()
    y, x = q[0], q[1]
    for i in range(4):
        y1 = y + yudlr[i]
        x1 = x + xudlr[i]
        if y1 < 0 or y1 >= H or x1 < 0 or x1 >= W:
            continue
        if s[y1][x1] == '#':
            continue
        if dist[y1][x1] != -1:
            continue
        dist[y1][x1] = dist[y][x] + 1
        if y1 == H - 1 and x1 == W - 1:
            print(c - dist[y1][x1])
            sys.exit()
        Q.append([y1, x1])

print('-1')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,K;
  cin>>n>>K;
  vector<int> d(n,INT_MAX),h(n);
  for(auto& i:h)cin>>i;
  d[0]=0;
  for(int i=1;i<n;++i)for(int k=1;k<=min(K,i);++k)d[i]=min(d[i],d[i-k]+abs(h[i]-h[i-k]));
  cout<<d[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct UnionFind {
    vector< int > data;
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, q; cin >> n >> q;
    UnionFind uf(n);
    rep (_, q) {
        int c, u, v; cin >> c >> u >> v;
        if (c == 0) uf.unite(u, v);
        // else cout << (uf.find(u)) << " " << (uf.find(v)) << "\n";
        else cout << (uf.find(u) == uf.find(v)) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3876
n = int(input())
array = input().split()
s = 0
suma = 0
for i in range(len(array)):
    array[i] = int(array[i])

for i in range(len(array)):
    if i >= 1:
        if array[i-1] > array[i]:
            s = array[i - 1] - array[i]
            array[i] += s
            suma += s
print(suma)

Measured memory_bytes: 25112
K=[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]
a=int(input())
print(K[a-1])

Measured memory_bytes: 3060
function main(input) {
    const args = input.split('\n');
    var one = args[0].split(' ');
    var Bs = args[1].split(' ');

    var N = parseInt(one[0], 10);
    var M = parseInt(one[1], 10);
    var C = parseInt(one[2], 10);

    var B = 0;
    var ans = [];
    var ans_count = 0;

    for(var i = 0; i < N; i++) {
        As = args[i + 2].split(' ');
        ans[i] = 0;
        for (var j = 0; j < M; j++) {
            B = parseInt(Bs[j], 10);
            A = parseInt(As[j], 10);
            ans[i] += A * B;
        }
    }

    for(var i = 0; i < N; i++) {
        ans[i] += C;
        if(ans[i] > 0) {
            ans_count ++;
        }
    }

    console.log(ans_count);


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
	int a, b, c; cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main()
 {
  int n; cin>>n;
  int sum= n;
  for(int i=0; i<=n; i++) {
    int cc=0,t=i;
    while(t>0)
 {
      cc += t%6;
      t /= 6;
    }
    t = n-i;
    while(t>0)
{
      cc += t%9;
      t /= 9;
    }
    if(sum>cc) sum = cc;
  }
  cout<<sum;
}


Measured memory_bytes: 256
(defun solve(n k h)
    (declare (inline sort))
  (declare (inline sb-impl::stable-sort-list))
    (let ((_h (make-array (length h) :initial-contents (sort h #'<=)))
	  (ans (expt 10 9)))
      (dotimes (i (1+ (- n k)) ans)
	(setf ans (min ans (- (aref _h (+ i (1- k)))
			      (aref _h i)))))))

(defun main ()
  (let* ((n (read))
	 (k (read))
	 (h (make-array n)))
    (dotimes (i n)
      (setf (aref h i) (read)))
    (princ (solve n k h))
    (fresh-line)))


(main)


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

int main() {
    int n, m;
    cin >> n;
    map<string, int> mapa;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mapa[s]++;
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        string s;
        cin >> s;
        mapa[s]--;
    }
    int ans = 0;
    for (auto x: mapa) ans = max(ans, x.second);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;

struct edge {
    int to, cost;
};

class dijkstra {
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<P>> que;

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    int find(int e) {
        return d[e];
    }
};

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

bool prime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y)) return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}

signed main() {
    int n,w[100],cnt=0;
    cin>>n;
    rep(i,n){
        cin>>w[i];
        cnt+=w[i];
    }
    int ans=LLONG_MAX,cnt2=0;
    rep(i,n){
        cnt2+=w[i];
        ans=min(ans,abs(cnt-cnt2*2));
    }
    cout<<ans<<endl;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===



int iipow(int a, int n)
{
	int res = 1;
	for (; n > 0; n >>= 1) {
		if (n & 1) res *= a;
		a *= a;
	}
	return res;
}



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

	unordered_map<int, int> factor;
	for (int i = 2; i <= N; ++i) {
		int i_copy = i;
		for (int j = 2; j <= N; ++j) {
			while (i_copy % j == 0) {
				++factor[j];
				i_copy /= j;
			}
			if (i_copy == 1) break;
		}
	}

	int n2 = 0, n4 = 0, n14 = 0, n24 = 0, n74 = 0;
	for (auto& fa : factor) {
		if (fa.second >= 74) {
			++n2; ++n4; ++n14; ++n24; ++n74;
		}
		else if (fa.second >= 24) {
			++n2; ++n4; ++n14; ++n24;
		}
		else if (fa.second >= 14) {
			++n2; ++n4; ++n14;
		}
		else if (fa.second >= 4) {
			++n2; ++n4;
		}
		else if (fa.second >= 2) {
			++n2;
		}
	}

	int ans = n74 + n24 * (n2 - 1) + n14 * (n4 - 1) + n4 * (n4 - 1) * (n2 - 2) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 1000005;
const int MOD = 1e9 + 7;
int n;
int f[MAXN], sum[MAXN], ans;

int main() {
    scanf("%d", &n);
    int n_1_2 = 1ll * (n - 1) * (n - 1) % MOD;
    f[0] = sum[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = i >= 3 ? sum[i - 3] : 0;
        sum[i] = sum[i - 1];
        f[i] = (f[i] + f[i - 1]) % MOD, sum[i] = (sum[i] + f[i]) % MOD;
    }
    for (int i = 0; i < n - 1; i++)
        ans = (ans + 1ll * f[i] * n_1_2) % MOD;
    for (int i = 0; i < n - 1; i++)
        ans = (ans + 1ll * f[i] * (i + 1)) % MOD;
    ans = (ans + 1ll * f[n - 1] * (n - 1) + f[n]) % MOD;
    printf("%d", ans);
	return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

void input() {
    cin >> a >> b >> x;
}

long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}

void solve() {
    input();
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++) {
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    string a[h];

    for(int i=0; i<h; i++) cin >> a[i];

    rep(i, h){
        if(i == 0){
            rep(j, w+2) cout << "#";
            cout << endl;
        }
        cout << "#" << a[i] << "#";
        cout << endl;
        if(i == h -1){
            rep(j, w+2) cout << "#";
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
bool prime[233333];
void makeprime(int n){
    memset(prime,1,sizeof(prime));
    prime[0]=prime[1]=0;
    for(int i=2;i<=sqrt(n);i++){
        if(prime[i]){
            for(int j=2;j<=n/i;j++){
                prime[i*j]=0;
            }
        }
    }
}
int f[233333];
int main(){
	int T;
	cin>>T;
	makeprime(100010);
	for(int i=3;i<=100000;i++){
		if(i%2==1 && prime[i] && prime[(i+1)/2]){
			f[i]=f[i-1]+1;
		}
		else{
			f[i]=f[i-1];
		}
	}
	while(T--){
		int l,r,ans=0;
		cin>>l>>r;
		cout<<f[r]-f[l-1]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int>h(N);
    for(int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    vector<int>S(N);
    S[0] = 0;
    S[1] = abs(h[1]-h[0]);
    for(int i = 2; i < N; i++)
    {
        S[i] = min((S[i-1] + abs(h[i]-h[i-1])),(S[i-2] + abs(h[i] - h[i-2])));
    }
    cout << S[N-1] << endl;
}

Measured memory_bytes: 4016
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static HashMap<Integer, TreeSet<Integer>> dp = new HashMap<Integer, TreeSet<Integer>>();
	static int n;
	static int max = Integer.MAX_VALUE;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for (int i = 0; i < n - 1; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			if (!dp.containsKey(a)) {
				TreeSet<Integer> list = new TreeSet<>();
				list.add(b);
				dp.put(a, list);
			} else {
				dp.get(a).add(b);
			}

			if (!dp.containsKey(b)) {
				TreeSet<Integer> list = new TreeSet<>();
				list.add(a);
				dp.put(b, list);
			} else {
				dp.get(b).add(a);
			}

		}
		int[] f = bfs(1);
		int[] s = bfs(n);

		int ansF = 0;
		int ansS = 0;
		for (int i = 1; i <= n; i++) {
			if (f[i] <= s[i]) {
				ansF++;

			} else {
				ansS++;

			}
		}

		if (ansF > ansS) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}

	}

	public static int[] bfs(int u) {
		int[] ans = new int[n + 1];
		Deque<Integer> q = new ArrayDeque<Integer>();
		q.offer(u);
		Arrays.fill(ans, max);
		ans[u] = 0;
		Iterator<Integer> it = null;

		while (!q.isEmpty()) {
			// 調べるノードを取り出す
			int v = q.poll();
			it = dp.get(v).iterator();
			while (it.hasNext()) {
				int temp = it.next();
				if (ans[temp] == max) {
					ans[temp] = ans[v] + 1;
					q.offer(temp);
				}
			}
		}
		return ans;

	}

}

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

typedef pair<int,int> P;

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

int main() {
    int n, m;
    while (cin >> n >> m, n || m) {
        vector<string> G1(m), G2(m);
        queue<P> que1, que2;
        for (int i = 0; i < 55; i++)
            for (int j = 0; j < 55; j++)
                for (int l = 0; l < 55; l++)
                    for (int k = 0; k < 55; k++)
                        d[i][j][k][l] = true;
        for (int i = 0; i < m; i++) {
            cin >> G1[i] >> G2[i];
            for (int j = 0; j < n; j++) {
                if (G1[i][j] == 'L') que1.push(P(i, j));
                if (G2[i][j] == 'R') que2.push(P(i, j));
            }
        }

        d[que1.front().first][que1.front().second][que2.front().first][que2.front().second] = false;

        bool res = false;
        while (1) {
            if (!que1.size() || !que2.size()) break;
            P p1 = que1.front(); que1.pop();
            P p2 = que2.front(); que2.pop();

            int x1 = p1.first;
            int y1 = p1.second;
            int x2 = p2.first;
            int y2 = p2.second;
            for (int i = 0; i < 4; i++) {
                int nx1 = x1 + dx[i];
                int ny1 = y1 + dy[i];
                int nx2 = x2 + dx[i];
                int ny2 = y2 - dy[i];

                if ( nx1 < 0 || nx1 >= m || ny1 < 0 || ny1 >= n || G1[nx1][ny1] == '#') nx1 = x1, ny1 = y1;
                if ( nx2 < 0 || nx2 >= m || ny2 < 0 || ny2 >= n || G2[nx2][ny2] == '#') nx2 = x2, ny2 = y2;

                if (G1[nx1][ny1] == '%' && G2[nx2][ny2] == '%') {
                    res = true;
                    break;
                }
                if (G1[nx1][ny1] == '%' || G2[nx2][ny2] == '%') continue;
                if (d[nx1][ny1][nx2][ny2]) {
                    d[nx1][ny1][nx2][ny2] = false;
                    que1.push(P(nx1, ny1));
                    que2.push(P(nx2, ny2));
                }
            }
        }

        cout << (res ? "Yes" : "No") << endl;
    }

    return 0;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i,0,tx-sx){
        cout << 'R';
    }
    rep(i,0,ty-sy){
        cout << 'U';
    }
    rep(i,0,tx-sx){
        cout << 'L';
    }
    rep(i,0,ty-sy){
        cout << 'D';
    }
    cout << 'L';
    rep(i,0,ty-sy+1){
        cout << 'U';
    }
    rep(i,0,tx-sx+1){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    rep(i,0,ty-sy+1){
        cout << 'D';
    }
    rep(i,0,tx-sx+1){
        cout << 'L';
    }
    cout << 'U' << endl;
}

Measured memory_bytes: 256
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 void solve() {
		int n = in.nextInt();
		String s = in.next();
		String t = in.next();
		for (int i=0; i<n; i++) {
			boolean f = true;
			for (int j=i; j<n; j++) {
				if (s.charAt(j) != t.charAt(j-i)) {
					f = false;
				}
			}

			if (f == true) {
				out.println((n+i));

				return;
			}
		}

		out.println(2*n);
	}

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

		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: 9812
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, d;
	cin >> n >> d;
	cout << n / (d * 2 + 1)  + (n % (d * 2 + 1) == 0 ? 0 : 1) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int a, b;

void read()
{
	cin >> a >> b;
}

void solve()
{
	if(a <= 0 && b >= 0) 
	{
		cout << "Zero" << endl;
		return;
	}

	if(a < 0 && (b - a) % 2 == 0) cout << "Negative" << endl;
	else cout << "Positive" << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 256
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

static const int MOD = 1000000007;

struct modll {
	long long x;
	modll() : x(0) { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	modll inverse() {
		modll r = 1, a = x;
		for (int b = MOD - 2; b; b >>= 1) {
			if (b & 1) {
				r *= a;
			}
			a *= a;
		}
		return r;
	}
};

int main(int argc, char *argv[])
{
	int n, m;
	cin >> n >> m;
	modll ans = 0;
	int a = min(n, m), b = max(n, m);
	if (a == b) {
		ans = 2;
		for (int i = 1; i <= a; ++i) {
			ans *= i;
			ans *= i;
		}
	} else if ((a + 1) == b) {
		ans = 1;
		for (int i = 1; i <= a; ++i) {
			ans *= i;
			ans *= i;
		}
		ans *= b;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i;
    string s;
    cin>>s;
    for(i=1;i<s.length();i++)
    {
        if(s[i]==s[i-1])
            break;
    }
    if(i==s.length())
        cout<<"Good"<<endl;
    else
        cout<<"Bad"<<endl;
    return 0;
}

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

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, x, t;
	cin >> n >> x >> t;
	int cnt = 0;
	while(n > 0){
		n -= x;
		cnt += t;
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 3620
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
int d[105][2];

int main() {
	cin >> n;
	cont(i, n) cin >> d[i][0] >> d[i][1];
	cont(i, n - 2) if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main() {
    ll V, E, r;
    cin >> V >> E >> r;
    WeightedGraph<ll> g(V);
    rep(i, E) {
        ll s, t, d;
        cin >> s >> t >> d;
        g[s].emplace_back(t, d);
    }

    for(auto &dist : dijkstra(g, r)) {
        if(dist == numeric_limits<ll>::max()) cout << "INF" << endl;
        else cout << dist << endl;
    }
}



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

using namespace std;
#define ll long long

ll INF = 1e18;

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

    int n;
    cin>>n;

    vector<pair<int,int>> res(n);

    for(int i=0;i<n;i++)
    {
        int a; cin>>a;

        res[i].first = a;
        res[i].second = i+1;
    }

    sort(res.begin(), res.end());

    for(int i=0;i<n;i++)
        cout<<res[i].second<<" ";
    cout<<endl;

    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

int n;
vector<vector<int> > adjList;
map<pair<int, int>, int> mp;
vector<int> edges, dp;
int cnt = 0, counter = 0;
vector<int> start, finish;
bool isCycle;

void mapping(int a, int b){
    pi p1 = make_pair(a, b);
    pi p2 = make_pair(b, a);

    if (mp.count(p1)) edges.emplace_back(mp[p1]);
    else {
        mp[p1] = cnt;
        mp[p2] = cnt;
        cnt;
        edges.emplace_back(cnt);
        cnt++; 
    }
}

int backtrack(int node){

    if (start[node] != -1 && finish[node] == -1){
            isCycle = true;
    }

    int &ret = dp[node];
    if (ret != -1) return ret;

    ret = 0;
    start[node] = counter++;
    for (auto child : adjList[node]){
        
        ret = max(ret, backtrack(child) + 1);
    }
    finish[node] = counter++;
    return ret;
}

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    
    int e = n*(n-1);
    e /= 2;
    adjList.assign(e, vector<int>());
    dp.assign(e, -1);

    int x;
    for (int i=1;i<=n;++i){
        edges.clear();
        for (int j=0;j<n-1;++j){
            cin>>x;
            mapping(i, x);
        }

        for (int j=n-3;j>=0;j--){
            adjList[edges[j+1]].push_back(edges[j]);
        }
    }

    start.assign(e, -1);
    finish.assign(e, -1);
    isCycle = false;

    int ans = -1;
    for (int i=0;i<e;++i){
        if (dp[i] == -1)
            ans = max(ans, backtrack(i));
        else ans = max(ans, dp[i]);
    }

    if (isCycle) cout<<"-1"<<endl;
    else cout<<ans+1<<endl;
    
    return 0;
}

Measured memory_bytes: 96000
N,D=map(int,input().split())
List=[list(map(int,input().split())) for i in range(N)]
i=0
tmp=0 #2点間の距離
k=1 #整数確認
ans=0 #組数

for n in range(N):
    for m in range(n+1,N):
        for d in range(D): #D次元分繰り返す
            tmp+=(List[n][d]-List[m][d])**2
        while k**2 <= tmp:
            if k**2 == tmp:
                ans+=1
            k+=1
        tmp,k=0,0
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	REP(i, S.size()-8) cout << S[i];
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
a_len, b_len, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ds = [[int(i) for i in input().split()] for _ in range(m)]

min = min(a) + min(b)
for x, y, c in ds:
    price = a[x-1] + b[y-1] - c
    if price < min:
        min = price

print(min)


Measured memory_bytes: 32496
def distance(x, y):
    return (x ** 2 + y ** 2) ** (1 / 2)


def main():
    n, d = map(int, input().split())
    xy_lst = [list(map(int, input().split())) for _ in range(n)]
    count = 0

    for i in range(n):
        x = xy_lst[i][0]
        y = xy_lst[i][1]
        if distance(x, y) <= d:
            count += 1

    print(count)


if __name__ == '__main__':
    main()

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

int main(){
    string a;
    cin >> a;
    int n = 0,w = 0,s = 0,e = 0;
    rep(i,a.size()){
        if(a[i] == 'N')n = 1;
        else if(a[i] == 'W')w = 1;
        else if(a[i] == 'S')s = 1;
        else if(a[i] == 'E')e = 1;
    }
    if(s == n && w == e) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import Counter

N, M=map(int, input().split())
m=[]
ans = 300

for i in range(N):
    m.append(list(map(int,input().split())))

def search(ln):
    #l = []
    cnt = Counter()
    for r in m:
        cnt[r[0]] += 1
    s,c = cnt.most_common(1)[0]
    global ans
    ans = min(ans, c)
    ln.remove(s)
    for r in m:
        r.remove(s)
    if len(ln) == 0:
        return 
    search(ln)
search(list(range(1, M+1)))
print (ans)

Measured memory_bytes: 6876