akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
int A, B;
vector<ll> dpa;
vector<ll> dpb;
vector<int> a;
const ll INF = LLONG_MAX;
int en;

void init()
{
	cin >> N >> A >> B;
	dpa.RS(N, INF);
	dpb.RS(N, INF);
	CINV(a, N);
	en = a[N-1];
}

void solve()
{
	if (N == 1) {
		cout << abs(B-a[0]) << endl;
		return;
	}
	dpa[N-1] = dpb[N-1] = abs(en - a[N-2]);
	rreps(i, N-1, 1) {
		dpa[i] = dpb[i] = abs(en - a[i-1]);
		reps(j, i+1, N) {
			dpa[i] = max(dpa[i], dpb[j]);
			dpb[i] = min(dpb[i], dpa[j]);
		}
	}
	dpa[0] = abs(en - B);
	reps(i, 1, N) {
		dpa[0] = max(dpa[0], dpb[i]);
	}
	cout << dpa[0] << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> l(n);
    rep(i,n)cin>>l[i];
    ll ans = 0;
    rep(i,n){
        rep2(j,i+1,n){
            rep2(k,j+1,n){
                if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]&&abs(l[i]-l[j])<l[k]&&l[k]<l[i]+l[j])ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int A,B,C,D;
    while(scanf("%d%d%d%d",&A,&B,&C,&D)!=EOF)
    {
        int a=1;
        while(1)
        {
            if(a%2==1)
            {
                if(B-C>=0)
            {
                printf("Yes\n");
                break;
            }
            else
            {
                C=C-B;
                a++;
            }
            }
            else
            {
                if(D-A>=0)
                {
                    printf("No\n");
                    break;
                }
                else
                {
                    A=A-D;
                    a++;
                }
                
            }
            
        }
    }
    return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#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 int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#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
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; }
//#define int long long

void solve() {
	int n; cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, n) {
		cin >> a[i]; a[i] --;
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n - 1) {
		cin >> c[i];
	}
	int ans = 0;
	rep(i, n) {
		ans += b[a[i]];
		if(i < n - 1 && a[i] + 1 == a[i + 1]) ans += c[a[i]];
	}
	cout << ans << 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 <stdio.h>

int main(void)
{
  int N;
  scanf("%d", &N);
  int ans = 0;
  if(N > 194){
    ans = 5;
  } else if(N > 188){
    ans = 4;
  } else if(N > 164){
    ans = 3;
  } else if(N > 134){
    ans = 2;
  } else if(N > 104){
    ans = 1;
  }  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
//BISMILLAHIR RAHMANIR RAHEEM
                                                //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


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

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////

//main function is here.........

int main()
{
    //ios
ll h,n,sum=0;
cin>>h>>n;
ll arr[h];
for(ll i=0;i<h;i++){cin>>arr[i];}
sort(arr,arr+h);
for(ll i=0;i<h-n;i++){
    sum+=arr[i];
}
cout<<sum;
}




//Alhamdulillah


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;


int main(){
    LL n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    LL x=__gcd(n,m);
    LL mx=n*m/x;
    LL u=0,v=0;
    for(;u<s.length()&&v<t.length();){
        if(s[u]!=t[v]){
            puts("-1");
            return 0;
        }
        u+=n/x;
        v+=m/x;
    }
    cout << mx << endl;
    return 0;
}


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

int main(void){
    int n;

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

    int a = p[0];
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(a <= p[i]){
            if(i+1 < n && p[i] <= p[i + 1]){
                cnt++;
            }
        } else {
            if(i+1 < n && p[i] >= p[i + 1]){
                cnt++;
            }
        }
        a = p[i];
    }

    cout << cnt << endl;

    return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[a[i] - 1] = i;
		}
		long cnt = 0;

		UnionFind uf = new UnionFind();
		uf.init(N);

		for (int i = N - 1; i >= 0; i--) {
			int pos = b[i];
			long g1 = 1;
			long g2 = 1;
			if (pos + 1 < N && a[pos] < a[pos + 1]) {
				g1 += uf.getGroupSize(pos + 1);
				uf.union(pos, pos + 1);
			}
			if (pos - 1 >= 0 && a[pos] < a[pos - 1]) {
				g2 += uf.getGroupSize(pos - 1);
				uf.union(pos, pos - 1);
			}
			cnt += a[pos] * (g1 * g2);
		}

		System.out.println(cnt);
	}

	public class UnionFind {

		int[] par;
		int[] rank;
		int groupCnt;

		void init(int n) {
			groupCnt = n;
			par = new int[n];
			rank = new int[n];
			Arrays.fill(par, -1);
		}

		void union(int x, int y) {
			x = find(x);
			y = find(y);
			if (x == y) {
				return;
			}
			groupCnt--;
			if (rank[x] < rank[y]) {
				par[y] += par[x];
				par[x] = y;
			} else {
				par[x] += par[y];
				par[y] = x;
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}

		int find(int x) {
			if (par[x] < 0) {
				return x;
			} else {
				return par[x] = find(par[x]);
			}
		}

		int getGroupSize(int x) {
			return -par[find(x)];
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 67004
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define ROF(i,a,b) for(i=a ; i>=b ; i--)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
 #define off 1000000
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

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

i64 a[maxn] , b[maxn] , c[maxn] ;

i64 dp[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld",&n) ;

    FOR(i,1,n) scanf("%lld",&a[i]) ;
    FOR(i,1,n) scanf("%lld",&b[i]) ;
    FOR(i,1,n) scanf("%lld",&c[i]) ;

    sort(a+1,a+n+1) ; sort(b+1,b+n+1) ; sort(c+1,c+n+1) ;

    dp[0] = 0 ;  j = 0 ;

    b[0] = -INF ;

    for(i=1 ; i<=n ; i++)
    {
        while( j+1 <=n && a[j+1] < b[i] ) j++ ;
        dp[i] += j ;
       // printf("%lld\n",j) ;
    }

    i64 sum = 0 , ans = 0 ;
j = 0 ;
    for(i=1 ; i<=n ; i++)
    {
        while( j+1 <=n && b[j+1] < c[i] )
        {
            j++ ;
            sum += dp[j] ;
        }
        ans += sum ;
     //   printf("%lld\n",j) ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}


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

using namespace std;

int main(){

	int n;
	cin>>n;

	vector<int> arr(n);
	vector<bool> v(n,false);

	for(int i = 0;i<n;i++)
		cin>>arr[i];

	bool flag = true;

	for(int i=n-2; i>=0; i--){
        if(arr[i+1] < arr[i]){
            if(arr[i+1]+1 == arr[i])
                arr[i]--;
            else{
                flag = false;
                break;
            }
        }
    }

	if(flag)
		cout<<"Yes\n";
	else
		cout<<"No\n";

	return 0;
}


Measured memory_bytes: 640
# coding: utf-8
# Your code here!

n = input()

# print(n)
# print(n[-1])

# 2, 4, 5, 7, 9
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print('hon')

# 0, 1, 6, 8
if n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')

# 3
if n[-1] == '3':
    print('bon')

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

        signed main() {
        int n;
        cin>>n;
        for(int i=0;i*4<=n;i++){
            if((n-i*4)%7==0){
                cout<<"Yes";
                return 0;
            }
        }
        cout<<"No";
        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) (int)a.size()
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

int n,m;

void test() {

    cin >> n;
    int x = 0;
    vi v(n);
    for( int i = 0; i < n; i++) {
        int t;
        cin >> t;
        x ^= t;
        v[i] = t;
    }
    for( int i = 0; i < n; i++) {
        cout << (x^v[i]) << ' ';
    }
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 4776
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    vector<P> sushi;
    for (int i = 0; i < N; i++) {
        P s;
        scanf("%d %d", &s.second, &s.first);
        s.second = s.second - 1;
        sushi.push_back(s);
    }
    sort(sushi.begin(), sushi.end(), greater<P>());
    long int x = 0;
    vector<P> sushi_line[N];
    vector<P> sushi_multiple;
    long int sum_d = 0;
    long int ans = 0;
    for (int i = 0; i < N; i++) {
        bool flag = false;
        if (i < K) flag = true;
        else {
            if (sushi_line[sushi[i].second].size() <= 0 && sushi_multiple.size() > 0) {
                flag = true;
                sum_d -= sushi_multiple[sushi_multiple.size() - 1].first;
                sushi_line[sushi_multiple[sushi_multiple.size() - 1].second].pop_back();
                sushi_multiple.pop_back();
            }
        }
        if (flag) {
            if (sushi_line[sushi[i].second].size() <= 0) x++;
            sushi_line[sushi[i].second].push_back(sushi[i]);
            if (sushi_line[sushi[i].second].size() >= 2) sushi_multiple.push_back(sushi[i]);
            sum_d += sushi[i].first;
            ans = max(ans, sum_d + x * x);
        }
    }
    
    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 5876
#include <stdio.h>
#include <math.h>

#define N 10000

int isprime(int);

int main(){
  int n, i, con, num = 0, a;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &a);
    con = isprime(a);
    num = num+con;
  }
    
    printf("%d\n", num);

  return 0;
}

int isprime(int x){
  int i;
  if(x == 2){
    return 1;
  }

  if(x < 2 || x%2 == 0){
    return 0;
  }

  i = 3;
  while(i <= sqrt(x)){
    if(x%i == 0){
      return 0;
    }
    i = i + 2;
  }

  return 1;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	int m = 0;
	for (int i = 1; i < N; i++) {
      	int cnt=0;
      	map<char, int>mp1;
		map<char, int>mp2;
		string T = S.substr(0, i);
		string U = S.substr(i, N - i);
		for (char c = 'a'; c <= 'z'; c++) {
			for (int j = 0; j < T.size(); j++) {
				if (T[j] == c){mp1[T[j]]++;}
			}
			for (int j = 0; j < U.size(); j++) {
				if (U[j] == c){mp2[U[j]]++;}
			}
        }
      for(char c='a'; c<='z'; c++){
          	if (mp1[c] > 0 && mp2[c] > 0){ cnt++;}
      }
          	          m = max(m, cnt);
    }
	cout << m << endl;
}



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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,m;
    int ans=INT_MAX;
    string s;
    cin>>n;
    cin>>s;
    int w=0;
    int e=0;
    int ec=count(s.begin(), s.end(),'E');
    for(int i = 0; i < n; ++i){
        int r=ec-e;
        if(s[i]=='E') --r;
        ans=min(ans,r+w);
        if(s[i]=='E') ++e;
        else ++w;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
int main(void){

int a[1000],i,n;

scanf("%d",&n);

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

for(i=n-1;i>=0;i--){
printf("%d",a[i]);

if( i != 0 ){
printf (" ");
}
}

printf("\n");

return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (i & 1 and s[i] == 'R') return cout << "No" << '\n', 0;
    if (~i & 1 and s[i] == 'L') return cout << "No" << '\n', 0;
  }
  cout << "Yes" << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  rep(i,100000){
    if(i*8/100==a&&i/10==b){
      cout<<i<<endl;
      return(0);
    }
  }
  cout<<-1<<endl;
  return(0);
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    ll n, a,ans=0;
    cin >> n;
    vector<ll>arr(n);
    rep(i, n) {
        cin >> arr[i];
    }
    sort(all(arr));
    ans = arr[n - 1];
    a = (n-2LL) / 2LL;
    for (int i = n - a; i < n; i++) {
        ans += arr[i - 1];
        ans += arr[i - 1];
    }
    if ((n - 2) % 2 == 1) {
        ans += arr[n - a - 2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4824
def main():

    N = int(input())
    P = list(map(int, input().split()))

    ans = 0
    min_v = float('inf')
    for i in range(N):
        if P[i] <= min_v:
            min_v = P[i]
            ans += 1
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 99912
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
#include<queue>
#include <sstream>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
   string s,t;
   cin>>s>>t;
   string p=s+t;
   stringstream geek(p);
   int x=0;
   geek>>x;
   int e=x;
   int g=sqrt(e);
   if(g*g==x)
    cout<<"Yes\n";
   else
    cout<<"No\n";
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
//#define ull unsigned long long
const int maxm=3e5+5;
pair<int,int>p[maxm];
int r[maxm],c[maxm];
int n,m,k;
signed main(){
    ios::sync_with_stdio(0);
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        int x,y;cin>>x>>y;
        p[i]={x,y};
        r[x]++,c[y]++;
    }
    int ma1=-1,num1=0;
    for(int i=1;i<=n;i++)ma1=max(ma1,r[i]);
    for(int i=1;i<=n;i++)num1+=(r[i]==ma1);
    int ma2=-1,num2=0;
    for(int i=1;i<=m;i++)ma2=max(ma2,c[i]);
    for(int i=1;i<=m;i++)num2+=(c[i]==ma2);
    int cnt=0;
    for(int i=1;i<=k;i++){
        int x=p[i].first,y=p[i].second;
        cnt+=(r[x]==ma1&&c[y]==ma2);
    }
    cout<<ma1+ma2-(cnt==num1*num2)<<endl;
    return 0;
}
/*
令r[i]为第i行的点数和,
令c[i]为第i列的点数和.
显然答案一定是从最大行和最大列中选一个配对.
需要判断交点处是否被标记.


*/


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
import numpy as np
import os
import sys

n=int(input())
tt=[]
for i in range(n):
    a,b=input().split()
    tt.append([a,int(b)])
t=tt.copy()
t=sorted(t,key=lambda x: x[1],reverse=True)
t=sorted(t,key=lambda x: x[0])

for i in t:
    print(tt.index(i)+1)

Measured memory_bytes: 13800
#include <iostream>
using namespace std;
typedef long long ll;
ll mod=998244353;

ll fac[3000010];
 
ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}
 
void modfac(){
    fac[0]=1;
    for(ll i=1;i<3000010;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}
 
ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}
 
ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

ll modhom(ll n,ll k){
  if(n==0&&k==0) return 1;
  else if(n<0||k<0) return 0;
  else return modcomb(n+k-1,k);
}
 
ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

int main(){
  modfac();
  ll n,m;
  cin >> n >> m;
  ll ans=modhom(n,3*m);
  for(ll i=m+1;i<=n;i++){
    if((3*m-i)%2==0){
      ans=(ans-modcomb(n,i)*modhom(n,(3*m-i)/2)%mod+mod)%mod;
      ans=(ans+modcomb(n,i)*modhom(n,(m-i)/2)%mod*n%mod)%mod;
      ans=(ans-modcomb(n-1,i)*modhom(n-1,(m-i)/2)%mod*n%mod+mod)%mod;
    }
  }
  ans=(ans-modhom(n,m)*n%mod)%mod;
  ans=(ans+modhom(n-1,m)*n%mod)%mod;
  cout << (ans+mod)%mod << endl;
}


Measured memory_bytes: 23808
const B=1000
function f(X,Y,x,y)
	z=x[:]
	w=y[:]
	for i=1:B
		tx=X+x[i]
		ty=Y+y[i]
		theta=atan2(ty,tx)
		if ty<0
			theta+=2*pi
		end
		id=floor(Int,theta*B/(2*pi))+1
		if hypot(z[id],w[id])<hypot(tx,ty)
			z[id]=tx
			w[id]=ty
		end
	end
	z,w
end
function main()
	x=zeros(Int,B)
	y=zeros(Int,B)
	N=parse(Int,readline())
	for i=1:N
		X,Y=map(x->parse(Int,x),split(readline()))
		if X!=0||Y!=0
			x,y=f(X,Y,x,y)
		end
	end
	ans=0
	for i=1:B
		ans=max(ans,hypot(x[i],y[i]))
	end
	println(ans)
end
main()

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, c;
    cin >> n >> c;
    vector<vector<int32>> d(c, vector<int32>(c));
    REP(i,c)REP(j,c)cin >> d[i][j];
    vector<map<int32,int32>> colorCnt(3);
    REP(i,n)REP(j,n){
        int32 grid;
        cin >> grid;
        grid--;
        colorCnt[(i + j) % 3][grid]++;
    }
    vector<vector<int32>> discomfort(3, vector<int32>(c,0));
    REP(i,3){
        REP(j,c){
            for(pii p : colorCnt[i]){
                discomfort[i][j] += d[p.first][j] * p.second;
            }
        }
    }
    int32 ans = INF;
    REP(i,c)REP(j,c)REP(k,c){
        if(i == j || j == k || k == i)continue;
        ans = min(ans, discomfort[0][i] + discomfort[1][j] + discomfort[2][k]);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cassert>
#include <random>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

typedef complex<double> P;
typedef double ld;

double eps = 1e-13;
double cross(P a, P b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

signed main() {
	int n, i;
	vector<P> ps;
	
	cin >> n;
	rep(i, n) {
		double x, y;
		cin >> x >> y;
		ps.push_back(P(x, y));
	}
	
	pair<P, ld> res = min_ball(ps.begin(), ps.end());
	printf("%.14f\n", sqrt(res.second));
	return 0;
}

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

const int INF = 999999999;

int d[210][210];
int n, m, r;
int ans = INF;

void WF() {
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int dfs(int s, vector<bool> a, int cost, vector<int> visit) {
  a[s] = true;
  bool flg = true;
  for (auto v: visit) if (!a[v]) flg = false;
  if (flg) return cost;
  int min_ = INF;
  for (auto v: visit) {
    if (a[v]) continue;
    if (d[s][v] == INF) continue;
    int t = dfs(v, a, cost + d[s][v], visit);
    if (min_ > t) {
      min_ = t;
    }
  }
  return min_;
}

int main() {
  cin >> n >> m >> r;
  vector<int> visit(r);
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = INF;
  for (int i = 0; i < r; i++) {
    int t;
    cin >> t;
    visit[i] = t - 1;
  }

  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c;
    d[b][a] = c;
  }

  WF();

  int min_ = INF;
  for (int i = 0; i < r; i++) {
    vector<bool> f(210);
    fill(f.begin(), f.end(), false);
    min_ = min(min_, dfs(visit[i], f, 0, visit));
  }
  cout << min_ << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    deque<char> ds(s.size());
    rep(i, s.size()) ds[i] = s[i];
    
    int q; cin >> q;
    int t;
    int flag = 0;
    rep(i, q){
        cin >> t;
        if(t == 2){
            int f; char c;
            cin >> f >> c;
            f--;
            if(flag) f = 1 - f;
            if(f == 0) ds.push_front(c);
            else ds.push_back(c);
        }else{
            flag = 1 - flag;
        }
    }
    if(flag) reverse(ds.begin(), ds.end());
    for(auto it : ds) cout << it;
    cout << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
int main(){
	int t, n;
	std::cin >> t;
	int MA = 0, MN = 0;
	int saizo[101];
	while(t--){
		std::cin>>n;
		for(int i = 0; i < n; ++i)
			std::cin >> saizo[i];
		for(int i = 0; i < n-1; ++i){
			int dif=saizo[i+1]-saizo[i];
			MA=std::max(MA,dif);
			MN=std::min(MN,dif);
		}
		std::cout<<MA<<" "<<-MN<<std::endl;
		MN=0,MA=0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M,a,b; cin>>N>>M;
	map<int,int> ct;
	for (int i=0; i<M; i++) {
		cin>>a>>b;
		ct[a]++; ct[b]++;
	}

	for (auto it : ct)
		if(it.second%2) {
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	string s;
	cin >> s;
	int n = 0;
	for (char c : s) {
		int d = c - '0';
		n += d;
	}
	cout << (n % 9 == 0 ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3748
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll a,b;
    cin >> a >> b;

    cout << a * b << endl;
    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


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

const int MAX=pow(10,5);
long long int DP[MAX+2];
long long int Tab[MAX+5];

int N;
int main()
{
   ios::sync_with_stdio(false);
   cin >> N;
   for(int i=0;i<N;i++)
      cin >> Tab[i];
   Tab[N]=Tab[N-1];
   Tab[N+1]=Tab[N];
    for(int i=N-1;i>=0;i--)
      DP[i]=min(DP[i+1]+abs(Tab[i]-Tab[i+1]),DP[i+2]+abs(Tab[i]-Tab[i+2]));
   cout<< DP[0];
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int main(void)
{
	char ch1[10], ch2[10], ch3[10];
	int len1, len2;
	scanf("%s %s %s", ch1, ch2, ch3);
	len1 = strlen(ch1);
	len2 = strlen(ch2);
	if ((ch1[len1-1] == ch2[0]) && (ch2[len2-1] == ch3[0]))
		printf("YES");

	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 128
import std.stdio; // ??\????????????????????????
import std.string; // chomp????????????????????????(?????????????????????)
import std.conv; // to????????????????????????
import std.array; // split?????????????????????
import std.algorithm; // map?????????????????????

void main() {
    auto input = readln.split.map!(to!int);
    auto a = input[0];
    auto b = input[1];
    auto c = input[2];

    if (a < b && b < c) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}

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





int main(){
	int n; cin >> n;
	
	int count = 0;

	for(int i=1; i <= n; i++){
		int j = n/i - (n%i == 0);
		count += j;		
	}

	cout << count << endl;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int array[][] = new int[2+1][N+1];
        for(int i = 1; i < 2+1; i++){
            for( int j = 1; j < N+1; j++) {
                array[i][j] = sc.nextInt();
            }
        }
        
        int dp[][] = new int[2+1][N+1];
        
        for( int i = 1; i < 2+1; i++ ){
            for( int j = 1; j < N+1; j++ ) {
                dp[i][j] = array[i][j] + Math.max( dp[i][j-1], dp[i-1][j] );
            }
        }
        
        System.out.println( dp[2][N] );
        
    }
}


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

//Author: Ashish

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<vector<int>> comp(n,vector<int>(n));
	for(auto&itr:comp)
		for(auto&iitr:itr)
			cin>>iitr;
	const int mod=1e9+7;
	vector<vector<int>> dp(n,vector<int>(1<<n,-1));
	function<int(int,int)> dpfunction = [&](int index,int mask) {
		if(index==n) return 1LL;
		if(dp[index][mask]!=-1) return dp[index][mask];
		int ways=0;
		for(int i=0;i<n;i++)
			if(comp[index][i]==1 && ((mask&(1<<i))==0))
				ways=(ways+dpfunction(index+1,mask|(1<<i)))%mod;
		return dp[index][mask]=ways;
	};
	cout<<dpfunction(0,0);
	
	return 0;
}

Measured memory_bytes: 363808
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,d; cin >> n >> d;
	cout << (((n % (d * 2 + 1)) == 0) ? n / (d * 2 + 1) : (n / (d * 2 + 1))+1 )<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
char s[202020];
int main() {
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int l = 1,r = n,ans = 0;
	while (l < r) {
		while (s[l] == 'R' && l < r)
			l++;
		while (s[r] == 'W' && l < r)
			r--;
		if (l < r)
			ans++,l++,r--;
	}
	printf("%d\n",ans);
	return 0;
}
/*
4
8 3
2 3 2 1 3 3 2 1
6 3
2 3 2 3 2 3
8 3
2 3 2 1 3 3 2 1
12 4
1 2 3 4 4 3 2 1 2 4 1 3

*/

Measured memory_bytes: 3424
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define int long long
#define iter set<int>::iterator
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+5;
const int mod=2520;

int n,m,p;
vector< pair< pair<int,int>,int > >q;
vector< pair< pair<int,int>,int > >qq;
int d[N];
int d1[N];
int d2[N];

main ()
{
    ios;
    cin>>n>>m>>p;
    for (int i=1;i<=m;++i){
        int x,y,z;
        cin>>x>>y>>z;
        z-=p;
        z=-z;
        q.pb({{x,y},z});
        qq.pb({{y,x},z});
    }
    for (int i=1;i<=n-1;++i){
        d1[i]=inf;
    }
    for (int i=1;i<=n;++i){
        for (int j=0;j<qq.size();++j){
            int x=qq[j].ff.ff;
            if (d1[x]==inf)continue;
            int y=qq[j].ff.ss;
            int cost=qq[j].ss;
            if (d1[x]+cost<d1[y]){
                d1[y]=d1[x]+cost;
            }
        }
    }
    for (int i=2;i<=n;++i){
        d[i]=inf;
    }
    for (int i=1;i<=n;++i){
        for (int j=0;j<q.size();++j){
            int x=q[j].ff.ff;
            if (d[x]==inf)continue;
            int y=q[j].ff.ss;
            int cost=q[j].ss;
            if (d[x]+cost<d[y]){
                d[y]=d[x]+cost;
            }
        }
    }
    for (int i=1;i<=n;++i){
        d2[i]=d[i];
    }
    for (int i=1;i<=2*n;++i){
        for (int j=0;j<q.size();++j){
            int x=q[j].ff.ff;
            if (d[x]==inf)continue;
            int y=q[j].ff.ss;
            int cost=q[j].ss;
            if (d[x]+cost<d[y]){
                d[y]=d[x]+cost;
            }
        }
    }
    bool t=false;
    for (int i=1;i<=n;++i){
        if (d[i]<d2[i] && d1[i]!=inf){
            t=true;
            break;
        }
    }
    if (t || d[n]==inf){
        cout<<-1<<endl;
    }
    else {
        if (d[n]<0){
            cout<<-d[n]<<endl;
        }
        else {
            cout<<0<<endl;
        }
    }
}


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	int cnt1=1,cnt2=1;
	rep(i,n){
		int a; scanf("%d",&a);
		cnt1*=3;
		if(a%2==0) cnt2*=2;
	}
	printf("%d\n",cnt1-cnt2);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long solve(const vector<int>& s)
{
    int n = s.size();
    long long ans = 0;
    for(int diff=1; diff<=n/2; ++diff){
        long long sum = 0;
        int x = 0;
        int y = n - 1;
        for(int k=1; (k+1)*diff<n; ++k){
            x += diff;
            if(x == y)
                break;
            y -= diff;
            if(x == y)
                break;
            sum += s[x] + s[y];
            ans = max(ans, sum);
        }
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];
    cout << solve(s) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <queue>

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b)
{
    return b?gcd(b,a%b):a;
}

LL a[100010];

int main()
{
    LL n,m,i,c,k;
    LL s;
    cin >> n >> m;
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    k=-1;
    s=1;
    for(i=0; i<n; i++)
    {
        c=1;
        while (a[i]%2==0)
        {
            a[i]/= 2;
            c*=2;
        }
        if (k==-1) k=c;
        else if (k!= c)
        {
            cout << 0 << endl;
            return 0;
        }
        s=s/gcd(s,a[i])*a[i];
        if(s>m)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/(k/2*s)+1)/2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int a[3];
int n, b;

int main() {
    while (cin >> a[0] >> a[1] >> a[2]) {
        if (a[0] == 0) break;
        sort(a, a+3);
        int sum = a[0] * a[0] + a[1] * a[1];
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> b;
            if (b * b * 4 > sum) puts("OK");
            else puts("NA");
        }
    }
    return 0;
}


Measured memory_bytes: 1128
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

X, Y, Z = iInM()

ans = (X - Z) // (Y + Z)

print(ans)

Measured memory_bytes: 62284
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val playList = List.fill(sc.nextInt())(sc.next() -> sc.nextInt())
  val sleepySong = sc.next()
  val _ :: xs = playList.dropWhile(_._1 != sleepySong)
  println(xs.map(_._2).sum)
}


Measured memory_bytes: 55592
use proconio::input;

fn main() {
	input! {
		k: i64,
	}
	
	if k % 2 == 0 || k % 5 == 0 {
		println!("-1");
	} else {
		let mut ans = 1;
		let mut value = 7 % k;
		while value > 0 {
			value = (value * 10 + 7) % k;
			ans += 1;
		}
		println!("{}", ans);
	}
}

Measured memory_bytes: 2104
H, W, K = map(int, input().split())

dp = [[0]*W for _ in range(H+1) ] 
dp[0][0] = 1

mod = int(1e9 + 7)

for i in range(H):
    for j in range(W):
        for bit in range(2**(W-1)):
            is_valid = True
            for k in range(W-2):
                if (bit >> k & 1) and ((bit >> (k + 1)) & 1):
                    is_valid = False
            if not is_valid:
                continue

            if bit >> j & 1:
                dp[i+1][j+1] += dp[i][j]
                dp[i+1][j+1] %= mod
            elif j > 0 and (bit >> (j-1)) & 1:
                dp[i+1][j-1] += dp[i][j]
                dp[i+1][j-1] %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod

print (dp[H][K-1])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();	//回数
		int W = sc.nextInt();	//K番目に小さいかず
		
		if (H == 2 || W ==2){
			System.out.println("No");
			return;
		}
		
		if (H==1 || H==3 || H==5 || H==7 || H==8 || H==10 ||H==12){
			if (W==1 || W==3 || W==5 || W==7 || W==8 || W==10 ||W==12){
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
			return;
		}
		
		if (H==4 || H==6 || H==9 || H==11){
			if (W==4 || W==6 || W==9 || W==11){
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		
	}

}


Measured memory_bytes: 21972