akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int a, b, k;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> k;
    FORE(i,min(a, b),1) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {
                cout << i;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll n,m;
    cin >> n >> m;

    ll ans=0;
    if(n!=1 && m!=1){
        ans=n*m-(n+m)*2+4;
    }else if(n!=1 && m==1){
        ans=n-2;
    }else if(n==1 && m!=1){
        ans=m-2;
    }else if(n==1 && m==1){
        ans=1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int counter=0;
  
  int m = S.size();

    for(int i=0;i<(m/2);i++){
      if(S.at(i) != S.at(m-1-i)){
        counter++;
      }
    }
  cout << counter <<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, int> nums;
    rep(i, n) {
        cin >> a[i];
        nums[a[i]]++;
    }

    sort(a.rbegin(), a.rend());
    int ans = 0, i = 0;
    while (i < n) {
        ll biggest_num = a[i++];
        if (nums[biggest_num] == 0) {
            continue;
        }
        nums[biggest_num]--;
        ll sumToBe = 0;
        while ((biggest_num >> sumToBe) > 0ll) {
            sumToBe++;
        }

        ll comp = (1 << sumToBe) - biggest_num;
        if (nums[comp]) {
            ans++;
            nums[comp]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <array>

using namespace std;
int n, m, x;
std::array<int, 12> c_list;
std::array<std::array<int, 12>, 12> a_list;

// 金額を返す
int calcImpl(std::array<int, 12> study, int next_check_index, int price_min)
{
    std::array<int, 12> studied = study;

    // 本を読む
    for (int i = 0; i < m; i++)
    {
        studied[i] += a_list[next_check_index][i];
    }
    price_min += c_list[next_check_index];

    // 出来上がったら金額を返す
    {
        bool mastered = true;
        for (int i = 0; i < m; i++)
        {
            if (studied[i] < x)
            {
                mastered = false;
                break;
            }
        }
        if (mastered)
        {
            return price_min;
        }
    }

    // まだ足りなくて、本を加えて読む場合
    if (next_check_index < n - 1)
    {
        // 次の本を指定
        int min = -1;
        for (int i = next_check_index + 1; i < n; i++)
        {
            int res = calcImpl(studied, i, price_min);
            if (res == -1)
            {
                continue;
            }
            if (min == -1 || min > res)
            {
                min = res;
            }
        }
        return min;
    }
    return -1;
}

int main(void)
{
    cin >> n >> m >> x;

    for (int i = 0; i < n; i++)
    {
        cin >> c_list[i];
        for (int k = 0; k < m; k++)
        {
            cin >> a_list[i][k];
        }
    }

    std::array<int, 12> study_init;
    study_init.fill(0);

    int min = -1;
    for (int i = 0; i < n; i++)
    {
        int res = calcImpl(study_init, i, 0);
        if (res == -1)
        {
            continue;
        }
        if (min == -1 || min > res)
        {
            min = res;
        }
    }

    cout << min;
}

Measured memory_bytes: 3632
import math

n=int(input())

def check(n):
  start=int(math.sqrt(n)//1)
  for i in range(2,start+1):
    if (n%i==0):
      return "False"
  return "True"

for i in range (n,100004):
  if (check(i)=="True"):
    print(i)
    break

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
map<string, bool >vis;

int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    int t;
    t = readint();
    int ans = 0;
    string str;
    while (t--)
    {
        cin >> str;
        if (vis.count(str) == 0)
        {
            ans++;
            vis[str] = 1;
        }
    }
    printf("%d\n", ans );
    return 0;
}




Measured memory_bytes: 18852
N = int(input().strip())
A = list(map(int, input().strip().split()))
x = N//2

C = [0]*N
for a in A:
    C[a]+=1

if N % 2 == 0:
    for i,c in enumerate(C):
        if i % 2 == 0:
            continue
        if C[i] != 2 :
            print("0")
            exit()
else:
    for i,c in enumerate(C):
        #print(i,c)
        if i % 2 == 1:
            continue
        if i == 0:
            if C[i] != 1:
                print("0")
                exit()
            else:
                continue
        elif C[i] != 2 :
            print("0")
            exit()

print((2**x)%int(1.0e9+7))

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define repe(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  double a, b;
  ll n;
  cin >> a >> b >> n;

  ll ans = 0;
  if(n >= b){
    ans = (ll)(floor(a*(b-1)/b) - a*floor((b-1)/b));
  }else{
    ans = (ll)(floor(a*n/b) - a*floor(n/b));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int w,h;
  while(cin>>w>>h,w+h){
    int xs,ys,xg,yg;
    bool Map[h+10][w+10]={};
    bool flag=false;
    cin>>xs>>ys>>xg>>yg;
    xs--;ys--;xg--;yg--;
    int n;cin>>n;
    int Map2[h+10][w+10]={};
    Map[ys][xs]=true;
    queue<pair<int,int> >que;
    que.push(mp(ys,xs));
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin>>c>>d>>x>>y;
      x--;y--;
      if(d==0){
	for(int i=y;i<y+2;i++)
	  for(int j=x;j<x+4;j++)
	    Map2[i][j]=c;
      }else if(d==1){
	for(int i=y;i<y+4;i++)
	  for(int j=x;j<x+2;j++)
	    Map2[i][j]=c;
      }
    }
    int vx[4]={0,-1,0,1};
    int vy[4]={1,0,-1,0};
    while(!que.empty()){
      pair<int,int>now=que.front();
      que.pop();
      if(now.F==yg&&now.S==xg){
	flag=true;
	break;
      }
      for(int kk=0;kk<4;kk++){
	int as=now.F+vx[kk];int bs=now.S+vy[kk];
	if(as<h&&as>=0&&bs<w&&bs>=0&&Map2[now.F][now.S]==Map2[as][bs]&&!Map[as][bs]){
	  que.push(mp(as,bs));
	  Map[as][bs]=true;
	}
      }
    }
    if(flag)
      cout<<"OK"<<endl;
    else
      cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main()
{
    long long odd=0,even=0,n,a;
    cin>>n;
    while(n--)
    {
        cin>>a;
        a%2==0?even++:odd++;
    }
    if(even+odd>2){odd%2==0?cout<<"YES":cout<<"NO";}
    else{odd==even?cout<<"NO":cout<<"YES";}

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

bool isPair(vector<ll> a,vector<ll> b){
    ll d=0;
    for(ll i=0;i<a.size();i++){
        d+=(a[i]-b[i])*(a[i]-b[i]);
    }
    ll d1=sqrt(d);
    if(d1*d1==d){
        return true;
    }
    return false;
}

int main() {

    IO; 

    ll l,r;
    cin>>l>>r;

    if(r-l+1>=2019){
        cout<<0<<endl;
    }
    else{
        ll ans=INT_MAX;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 256
import math
n, d = map(int, input().split())
x = []
ans=0
for i in range(n):
        o = list(map(int, input().split()))
        x += [o]
for i in range(n):
        for j in range(i+1,n):
                dis_net = 0
                dis=0
                for u in range(d):
                        dis += (x[i][u] - x[j][u])** 2
                dis_net = math.sqrt(dis)
                if dis_net % 1 == 0 and dis_net>=1:
                        ans += 1
print(ans)


Measured memory_bytes: 3064
def count_divisor(a:int,b:int,c:int)->int:
    n=0
    for i in range(a,b+1):
        if c % i == 0:
            n+=1
            
    return n


a,b,c=tuple(input().split())

print(count_divisor(int(a),int(b),int(c)))


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

public class Main {

    private static int total = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] nums = new int[N];
        for (int i = 0; i < N; i++) {
            nums[i] = sc.nextInt();
        }
        me(nums);
        System.out.println(Main.total);

    }

    public static void me(int[] nums) {

        int min = Integer.MAX_VALUE;
        for (int num : nums) {
            min = num < min ? num : min;
        }
        Main.total += min;
        int ti = 0;
        int i;
        for (i = 0; i < nums.length; i++) {
            nums[i] -= min;
            if (nums[i] == 0) {
                if (ti < i) {
                    me(Arrays.copyOfRange(nums, ti, i));
                }
                ti = i + 1;
            }
        }
        if (ti < i) {
            me(Arrays.copyOfRange(nums, ti, i));
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long int;
int main() 
{
     char ch;
     cin>>ch;
     if(isupper(ch))
     {
       cout<<'A'<<"\n";
     }
     else
     {
       cout<<'a'<<"\n";
     }
}

Measured memory_bytes: 3544
s=input()
def check(s):
    if s[-5:]=='dream':
        return 'dream'
    elif s[-7:]=='dreamer':
        return 'dreamer'
    elif s[-5:]=='erase':
        return 'erase'
    elif s[-6:]=='eraser':
        return 'eraser'
    else: return 'False'

count=0
while len(s)>0 and count==0:
    if check(s)=='False':
        count+=1
        print('NO')
    elif check(s)=='dream' or check(s)=='erase':
        s=s[:-5]
    elif check(s)=='eraser':
        s=s[:-6]
    elif check(s)=='dreamer':
        s=s[:-7]

if count==0:print('YES')

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t x,happy=0,y;
    cin>>x;
    if(x>=500){
        y=x/500;
        x=x%500;
        happy+=1000*y;
    }
    if(x>=5){
        y=x/5;
        x=x%5;
        happy+=5*y;
    }
    cout<<happy;    
    }


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, M, X, Y;
  while (cin >> N >> M >> X >> Y) {
    int mx = X;
    for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      mx = max(mx, x);
    }
    int mn = Y;
    for (int i = 0; i < M; i++) {
      int y;
      cin >> y;
      mn = min(mn, y);
    }
    bool res = mx + 1 <= mn;
    cout << (res ? "No War" : "War") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

/*
 * Binary string W/R
 * Finally string must be RRRWWW
 *
 * We need to remove all W left of the rightmost R,
 * or all R rigth of the leftmost W
 * dp
 * We can swap all pairs of wrong placed chars,
 * and need to flip the remaining.
 */
void solve() {
    cini(n);
    cins(s);
    vi cntR(n+1);
    vi cntW(n+1);

    for(int i=1; i<=n; i++)  {
        cntR[i]=cntR[i-1];
        cntW[i]=cntW[i-1];
        if(s[i-1]=='R')
            cntR[i]++;
        else
            cntW[i]++;
    }

    int ans=1e9;
    for(int i=0; i<=n; i++) {
        ans=min(ans, max(cntW[i], cntR[n]-cntR[i]));
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 6752
#include <iostream>

using namespace std;
int a, b, c;
int main()
{
    int N;
    cin >> N;
    char s;
    int Rcount=0, Bcount=0;
    for (int i=0; i<N; ++i){
        cin >> s;
        if (s=='R'){
            ++Rcount;
        }
        if (s=='B'){
            ++Bcount;
        }
    }
    if(Rcount>Bcount){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


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

class Program
{
	struct tenbodaiSt
	{
		public int h;
		public List<int> route;
	}

	static void Main(string[] args)
	{
		int i, j;

		string[] strInput = Console.ReadLine().Split(' ');
		int n = int.Parse(strInput[0]);
		int m = int.Parse(strInput[1]);

		tenbodaiSt[] tenbodai = new tenbodaiSt[n];


		strInput = Console.ReadLine().Split(' ');
		for (i = 0; i < n; i++)
		{
			tenbodai[i].h = int.Parse(strInput[i]);
			tenbodai[i].route = new List<int>();
		}

		for (i = 0; i < m; i++)
		{
			strInput = Console.ReadLine().Split(' ');
			int a = int.Parse(strInput[0]) - 1;
			int b = int.Parse(strInput[1]) - 1;

			tenbodai[a].route.Add(b);
			tenbodai[b].route.Add(a);
		}

		int result = 0;
		
		for (i = 0; i < n; i++)
		{
			if (tenbodai[i].route.Count == 0)
			{
				result++;
			}
			else
			{
				for (j = 0; j < tenbodai[i].route.Count; j++)
				{
					int k = tenbodai[i].route[j];

					if (tenbodai[i].h <= tenbodai[k].h)
					{
						break;
					}
					else if (j == tenbodai[i].route.Count - 1)  //最後のルート？
					{
						result++;
					}
				}
			}
		}

		Console.WriteLine(result);

		return;
	}
}

Measured memory_bytes: 60744
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int n,a,b,c,d,e;string s;
    cin >>a>>b;
    cout <<(a<=b?"unsafe":"safe")<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
	int x1,x2,x3=0;
	scanf("%d %d",&x1,&x2);
	if(x2>x1){
		x3=x2-x1;
		printf("%d\n",x3);
	}else if(x1>x2){
		x3=x1-x2;
		printf("%d\n",x3);
	}else if(x1==x2){
		x3=x1-x2;
		printf("%d\n",x3);
	}
	return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans = 0;
  rep(i,k) ans+=a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define mp make_pair
#define what_is(x) cerr << #x << " is " << x << endl;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(vector<int> s)
{
    int n = s.size();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
    return z;
}

mt19937 rnd(time(0));
/*
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct CHT : multiset<Line, less<>> {
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) { // floored division
        return a / b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        auto l = *lower_bound(x);
        return l.k * x + l.m;
    }
};
*/

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

    int n, d;
    cin>>n>>d;
    cout<<(n+2*d)/(2*d+1);

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll nCr(int x, int y){
    if (y > x) return 0;
    if (2*y > x) y = x - y;
    ll ans = 1;
    REP(i,y){
        ans *= (x-i);
        ans /= (i+1);
    }
    return ans;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    VL v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    reverse(ALL(v));
    ll s = 0;
    bool f = true;
    REP(i,a){
        s += v[i];
        if (v[i] != v[0]) f = false;
    }
    printf("%.7f\n", (double)s/a);
    if (f){
        int p = 0;
        REP(i,n) p += (v[0] == v[i]);
        ll ans = 0;
        FOR(i,a,b){
            ans += nCr(p,i);
        }
        cout << ans << endl;
        return 0;
    }
    int x = 0, y = 0;
    REP(i,a) x += (v[i] == v[a-1]);
    REP(i,n) y += (v[i] == v[a-1]);
    cout << nCr(y,x) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _021_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long res = 0;
            long div = 10;
            while (n >= 10)
            {
                res += 9;
                if (n % 10 < 9) n -= 10;
                n /= 10;
            }
            res += n;
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int A;
    static int B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        System.out.println(solve());
    }

    static String solve() {
        if( (B - A) % 2 == 0 ) {
            return "Alice";
        } else {
            return "Borys";
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21332
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val a = IntArray(n){scn.nextInt()}
	val s = a.reduce { acc, i -> acc xor i }
	val r = IntArray(n){s xor a[it]}
	println(r.joinToString(separator = " "))
}

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

int main(){
    int x,y; 
	
	cin>>x>>y;
   
if(x>=1&&x<=9&&y>=1&&y<=9)
{
	cout<<x*y<<endl;
	
}

else 
{
	cout<<-1<<endl;
}

    return 0;

}



Measured memory_bytes: 256
let n = -1;
let str;
var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", function(line) {
  if (n === -1) {
    n = Number(line);
  } else {
    str = line as string;
    console.log(rot13(str,n));
    process.exit(0)
  }
});
function rot13(str:string,n:number) {
    let newstr = "";
    for (let i = 0; i < str.length; i++) {
      const code = str[i].charCodeAt(0);
      if ("Z".charCodeAt(0) >= code && "A".charCodeAt(0) <= code) {
        newstr += String.fromCodePoint(
          ((code - "A".charCodeAt(0) + n) % 26) + "A".charCodeAt(0)
        );
      } else if ("z".charCodeAt(0) >= code && "a".charCodeAt(0) <= code) {
        newstr += String.fromCodePoint(
          ((code - "a".charCodeAt(0) + n) % 26) + "a".charCodeAt(0)
        );
      } else {
        newstr += str[i];
      }
    }
    return newstr;
  }
  

Measured memory_bytes: 7740
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):

    
    ansx = -1
    ansy = -1
    ansh = -1

    # ix = [i for i,x in enumerate(h) if(x > 0)][0]
    # print(ix)
    ix = h.index(max(h))

    for cx in range(101):
        for cy in range(101):
            H = h[ix] + abs(x[ix]-cx) + abs(y[ix]-cy)
            f = True
            for i in range(N):
                if(h[i] > 0 and H-h[i] != abs(x[i]-cx) + abs(y[i]-cy)):
                    f = False
                if(h[i] == 0 and H > abs(x[i]-cx) + abs(y[i]-cy)):
                    f = False
            if(f):
                ansx = cx
                ansy = cy
                ansh = H
        

    print(ansx, ansy, ansh)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	r := n - k
	for i := 1; i <= k; i++ {
		a := comb(r+1, i)
		b := comb(k-1, i-1)
		fmt.Println(mul(a, b))
	}
}

const mod int = 1e9 + 7

func pow(n, k int) int {
	if k == 0 {
		return 1
	} else if k%2 == 1 {
		return pow(n, k-1) * n % mod
	} else {
		t := pow(n, k/2)
		return t * t % mod
	}
}

func comb(n, r int) int {
	nu := 1
	for i := 0; i < r; i++ {
		nu = mul(nu, n-i)
	}

	de := 1
	for i := 1; i <= r; i++ {
		de = mul(de, i)
	}

	return div(nu, de)
}

func add(a, b int) int {
	return (a + b) % mod
}

func sub(a, b int) int {
	return (a + mod - b) % mod
}

func mul(a, b int) int {
	return a % mod * b % mod % mod
}

func div(a, b int) int {
	return mul(a, pow(b, mod-2))
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	x := make([]int, m)
	for i := 0; i < m; i++ {
		x[i] = nextInt()
	}
	sort.Ints(x)

	dis := make([]int, m)
	for i := 1; i < m; i++ {
		dis[i] = x[i] - x[i-1]
	}
	sort.Ints(dis)

	c := 0
	for i := 0; i < m-n+1; i++ {
		c += dis[i]
	}

	fmt.Println(c)
}


Measured memory_bytes: 2944
from itertools import product

n, m, x = map(int, input().split())
cas = [tuple(map(int, input().split())) for _ in range(n)]
ans = 10 ** 20

for elem in product(range(2), repeat=n):
    buy_rep = [0] * (m + 1)
    for i in range(n):
        if elem[i]:
            for j in range(1, m + 1):
                buy_rep[j] += cas[i][j]
            buy_rep[0] += cas[i][0]
    if m == len(list(filter(lambda y: x <= y, buy_rep[1:]))):
        ans = min(ans, buy_rep[0])
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 74324
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < q; i++) {
      int t = sc.nextInt() - 1;
      a[t]++;
    }
    for(int i = 0; i < n; i++) {
      String ans = "Yes";
      if(a[i] <= q - k) ans = "No";
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 56804
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
Smax = 0
for i in range(N):
    Sl = sum(A[0][0:i + 1])
    Sr = sum(A[1][i:])
    tmp = Sl + Sr
    if Smax < tmp:
        Smax = tmp
print(Smax)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  int minA = 0, minB = 0;
  for (int i = 0; i < N; i++) if (A[i] > minA) minA = A[i], minB = B[i];
  cout << minA + minB << endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(input())
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        if N * i <= M: ans = max(ans, i)
        if N * (M // i) <= M: ans = max(ans, M//i)
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
use proconio::input;
use std::cmp::min;

fn main() {
	input!(n: usize, k: usize, h: [i64; n]);

	const INF: i64 = 1000000000;

	let mut dp = vec![INF; n];
	dp[0] = 0;
	for i in 0..n-1 {
		for j in i+1..=min(i+k, n-1) {
			dp[j] = min(dp[j], dp[i] + (h[i] - h[j]).abs());
		}
	}

	println!("{}", dp[n-1]);
}

Measured memory_bytes: 3988
n = int(raw_input())
A = map(int, raw_input().strip().split(' '))
q = int(raw_input())
M = map(int, raw_input().strip().split(' '))
 
memo = []
for i in range(len(A)+1):
    memo.append([None]*2000)
 
def solve(i,m):
    if memo[i][m] != None: return memo[i][m]
    if m == 0:
        memo[i][m] = True
        return True
    elif i >= n:
        memo[i][m] = False
        return False
    else:
        ret = solve(i+1,m) | solve(i+1,m-A[i])
        memo[i][m] = ret
        return ret
 
for m in M:
    if solve(0,m): print "yes"
    else: print "no"

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

int main(){
	int n; cin>>n;
	int sum = 7;
	for(int i = 1; i<=n; i++){
		if(sum%n==0){
			cout<<i;
			return 0;
		}
		else
			sum = (sum*10+7)%n;
	}
	cout<<-1;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int leng = s.length();
		System.out.print(s.charAt(0));
		System.out.print(leng-2);
		System.out.println(s.charAt(leng-1));
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 string s;
 cin >> N;
  for(int i = 0; i < N; i++){
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N - 1){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,R,a,b,c;
	while(cin>>N>>M>>R) {
		VI r(R);
		REP(i, R) cin>>r[i],r[i]--;
		sort(ALL(r));
		VVI w(N, VI(N, INF));
		REP(i, N) w[i][i] = 0;
		REP(i, M) {
			cin>>a>>b>>c;
			a--;b--;
			w[a][b] = w[b][a] = c;
		}
		REP(k, N) REP(i, N) REP(j, N) w[i][j] = min(w[i][j], w[i][k]+w[k][j]);
		ll ans = INF;
		do {
			ll lans = 0;
			REP(ri, R-1) lans += w[r[ri]][r[ri+1]];
			if(lans < ans) {
				ans = lans;
			}
		} while(next_permutation(ALL(r)));
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 41

typedef struct node{
  int l, r;
}node;

node c[N];
int a[N], b[N];
int cnt=0;

void postorder(int root,int n){

        if(c[root].l != -1) postorder(c[root].l, n);
        if(c[root].r != -1) postorder(c[root].r, n);
        if(cnt < n - 1) printf("%d ", root);
        else printf("%d\n", root);

        cnt++;

        return;

}

int reconst(int start,int last,int n){
  int i, j;

  if(start == last) return b[start];
  else if(start > last) return -1;

  else {
    for(i = 1 ; i <= n ; i++){
      for(j = start ; j <= last ; j++){
        if(a[i] == b[j]){
          c[a[i]].l = reconst(start, j - 1, n);
          c[a[i]].r = reconst(j + 1, last, n);
          return a[i];
        }
      }
    }
  }
}


int main(){
  int n,i, root;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++) scanf("%d",&a[i]);
  for(i = 1 ; i <= n ; i++) scanf("%d",&b[i]);
  for(i = 1 ; i <= n ; i++){
    c[i].l = -1;
    c[i].r = -1;
  }

  root = reconst(1,n,n);

  postorder(root,n);

  return 0;

}


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

using namespace std;
typedef long long ll;

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

  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] < a[i - 1]) {
      ans += (ll)(a[i - 1] - a[i]);
      a[i] += (a[i - 1] - a[i]);
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 4044
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
  string s;
  cin>>s;
  if(s.size()<4){
    cout<<"No"<<endl;
    return 0;
  }
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long a = input.nextLong();
        long b = input.nextLong();
        long c = input.nextLong();
        long count = 0;
        if (a == 0){
            count++;
            count += b / c;
        }else if (a == 1){
            count += b / c;
        }else{
            count += b / c;
            count -= (a-1) / c;
        }

        System.out.println(count);
    }
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<int> hh(h, 0);
    vector<int> ww(w, 0);
    REP(i, h) REP(j, w) if (s[i][j] == '#') hh[i]++;
    REP(j, w) REP(i, h) if (s[i][j] == '#') ww[j]++;

    int p = 1;
    vector<vector<int>> ans(h, vector<int>(w));
    REP(i, h) {
        if (hh[i] == 0) continue;
        int c = 0;
        REP(j, w) {
            ans[i][j] = p;
            if (s[i][j] == '#' && c < hh[i] - 1) {
                c++;
                p++;
            }
        }
        p++;
    }
    REP(i, h) {
        if (hh[i] != 0) continue;
        bool ok = false;
        FOR(z, i + 1, h) {
            if (hh[z] != 0) {
                ok = true; 
                FOR(y, i, z) {
                    REP(j, w) {
                        ans[y][j] = ans[z][j];
                    }
                }
                break;
            }
        }
        if (!ok) {
            FORR(z, i - 1, 0) {
                if (hh[z] != 0) {
                    FOR(y, z + 1, i + 1) {
                        REP(j, w) {
                            ans[y][j] = ans[z][j];
                        }
                    }
                    break;
                }
            }
        }
    }

    REP(i, h) REP(j, w) cout << ans[i][j] << (j != w - 1 ? ' ' : EOL);
}


Measured memory_bytes: 1280
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]


    c = collections.Counter()

    ans = 0
    for i, a in enumerate(A):
        ans += c[a - i]
        c[-a - i] += 1

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 40292