akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define INF 1000000
using namespace std;

int que[100000];
int head,tail,leng=100000;
 
int isEmpty(){
  return head==tail;
}
 
void enqueue(int x){
  que[tail]=x;
  if(tail+1==leng) tail=0;
  else tail++;
}
 
int dequeue(){
  int x;
  x=que[head];
  if(head+1==leng) head=0;
  else head++;
  return x;
}
 

int a[101][101];
int d[101];
int n;

void bfs(int s){
int t;
  for(int i=1;i<=n;i++)d[i]=INF;
  d[s]=0;
   while(!isEmpty()){
    t=dequeue();
    for(int i=1;i<=n;i++){
      if(d[i]!=INF || a[t][i]!=1) continue;
       enqueue(i),d[i]=d[t]+1;
    }
  }
}

int main(){
  int top,m,s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>top>>m;
    for(int j=0;j<m;j++)
      cin>>s,a[top][s]=1;
     } 
  enqueue(1);
   bfs(1);
   for(int i=1;i<=n;i++){
     if(d[i]==INF) d[i]=-1;
     cout<<i<<" "<<d[i]<<endl;
   }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
       long long int a,b,c;
       cin>>a>>b>>c;
       if(a==b&&c!=b)
        cout<<"Yes"<<endl;
       else if(b==c&&a!=b)
         cout<<"Yes"<<endl;
       else if(a==c&&b!=a)
         cout<<"Yes"<<endl;
       else
         cout<<"No"<<endl;


          return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int A,B,C,D;
int main(){
	cin>>A>>B>>C>>D;

	if(A*B>C*D)cout<<A*B<<endl;
	else cout<<C*D<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc137_b
{
    static class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().ToIntArray();
            var k = items[0];
            var x = items[1];
            var count = k * 2 - 1;
            var stones = new int[count];
            for (int i = 0; i < count; i++)
            {
                stones[i] = x - k + 1 + i;
            }
            Console.WriteLine(string.Join(" ", stones));
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }

        static int[] ToIntArray(this string s, char separator = ' ')
        {
            return s.Split(separator).Select(m => m.ToInteger()).ToArray();
        }
    }
}


Measured memory_bytes: 13396
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

void insertion(int *a,int n)
{
	int k,idx;
	for(int i=1 ; i<n ; i++)
	{
		k=a[i];
		idx=i-1;
		while(idx>=0 && a[idx]>k)
		{
			a[idx+1]=a[idx];
			idx--;
		}
		a[idx+1]=k;
		forin(j,0,n-1)
		printf("%d ",a[j]);
		printf("%d",a[n-1]);
		newline;
	}
}

int main()
{
	int n;
	int a[20000];
	scd(n);
	scarrd(a,n);
	forin(j,0,n-1)
	printf("%d ",a[j]);
	printf("%d",a[n-1]);
	newline;
	insertion(a,n);
	return 0;
}

Measured memory_bytes: 3224
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0

for i in range(n):
  ans+=b[a[i]-1]

for i in range(n-1):
  if a[i]==a[i+1]-1:
    ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int main(void){
    int p,q;
    while(EOF != scanf("%d%d",&p,&q)){
        map< int ,int > flg;
        
        //cout<<<<endl;
        for(int i = 1;;i++){
            int x = p / q;

            if(i!=1)cout << x;
            if(p % q == 0){
                break;
            }
            p -= x*q;
            p *= 10;    
            
            
            //cout<<p<<"-"<<x*q<<endl;
            if(flg[p] != 0){
                cout<<endl;
                for(int j = 0;j < flg[p]-1;j++)cout<<" ";
                for(int j = flg[p];j < i;j++)cout<<"^";   
                break;
            }
            flg[p] = i;

             
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<Integer>();
    int A = sc.nextInt();
    ar.add(A);
    int B = sc.nextInt();
    ar.add(B);
    int C = sc.nextInt();
    ar.add(C);
    int K = sc.nextInt();
    Collections.sort(ar);
    for(int i=0;i<K;i++){
      if(ar.get(2) == A){
        ar.remove(2);
        A *= 2;
        ar.add(A);
      }else if(ar.get(2) == B){
        ar.remove(2);
        B *= 2;
        ar.add(B);
      }else{
        ar.remove(2);
        C *= 2;
        ar.add(C);
      }
    }
    Collections.sort(ar);
    System.out.println(ar.get(0)+ar.get(1)+ar.get(2));
  }
}


Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	rep(i, n)cin >> s.at(i);
	sort(s.begin(), s.end());
	int count = 1;
	rep(i, n - 1) {
		if (s.at(i) != s.at(i + 1))count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 9564
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    while (true) {
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();

        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) {
            pw.println("F");
        } else if (m + f < 30) {
            pw.println("F");
        } else if (30 <= m + f && m + f < 50 && 50 <= r) {
            pw.println("C");
        } else if (30 <= m + f && m + f < 50) {
            pw.println("D");
        } else if (50 <= m + f && m + f < 65) {
            pw.println("C");
        } else if (65 <= m + f && m + f < 80) {
            pw.println("B");
        } else if (80 <= m + f) {
            pw.println("A");
        } else {
            // do nothing
        }
    }

    pw.flush();
    sc.close();
  }
}


Measured memory_bytes: 26384
#include <cstdio>
#include <vector>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main() {
    int d, g, ans = INF;
    scanf("%d%d", &d, &g);
    g /= 100;
    vector<int> p(d + 1), c(d + 1);
    for (int i = 1; i <= d; ++i) {
        scanf("%d%d", p.begin() + i, c.begin() + i);
        c.at(i) /= 100;
    }
    for (int i = 0; i < (1 << d); ++i) {
        int sum = 0, m = 0, t = 0;
        for (int j = 0; j < d; ++j) {
            if (i & (1 << j)) {
                sum += (j + 1) * p.at(j + 1) + c.at(j + 1);
                t += p.at(j + 1);
            }
            else m = j + 1;
        }
        if (sum >= g) ans = min(ans, t);
        else if ((g - sum - 1) / m + 1 < p.at(m)) ans = min(ans, t + (g - sum - 1) / m + 1);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof(x))
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int M4 = 1e4+10, M5 = 1e5+10, M6 = 1e6+10;

int a[M5];
pii b[M5];


int main()
{_
	int n,m;    cin >> n >> m;
	for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    for(int i = 0; i < m; i++)
        cin >> b[i].fr >> b[i].sc;
    sort(b, b+m, [&](pii x, pii y){return x.sc > y.sc;});

    int p = 0;
    for(int i = 0; i < m and p < n; i++)
    {
        int c = b[i].sc;
        int q = lb(a+p, a+n, c)-a-1;
        smin(q, p+b[i].fr-1);
        if(q-p+1 > 0)
            for(;p<=q; p++)
                a[p] = c;
    }
    ll s = 0;
    for(int i = 0; i < n; i++)
        s += a[i];
    cout << s;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
static const int N = 100;

int getScore(int n, int k, int A[]){
  int ms = 0;
  for ( int i = 0; i < n-k+1; i++ ){
    int p = 1;
    for ( int j = i; j < i+k; j++ ){
      p *= A[j];
    }
    ms = max(ms, p);
  }
  return ms;
}

main(){
  int A[N], n, k, C1, C2;
  while(1){
    cin >> n >> k;
    if ( n == 0 && k == 0 ) break;
    C1 = C2 = 0;
    for ( int i = 0; i < n; i++ ) cin >> A[i];
    C1 = getScore(n, k, A);

    for ( int i = 0; i < n; i++ ){
      for ( int j = 0; j < n; j++ ){
	swap(A[i], A[j]);
	C2 = max(C2, getScore(n, k, A));
	swap(A[i], A[j]);
      }
    }
    cout << C2 - C1 << endl;
  }
}

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

int main(){
    int n, m;
    cin >> n>> m;
    // int a[n], b[n];

    ll sum = 0;
    vector <pair<ll, ll>> pair(n);

    rep(i, n){
        // cin >> a[i] >> b[i];
        cin >> pair[i].first >> pair[i].second;
    }

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

    rep(i, n){
        if(m > pair[i].second){
            sum += pair[i].first * pair[i].second;
            m -= pair[i].second;
        }else{
            sum += pair[i].first * m;
            // m -= pair[i].second;
            break;
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int m = s.size();
    for (int i = 0; i < m; i ++ )
    {
        for (int j = i+1; j < m; j ++ )
        {
            if(s[i] == s[j])
            {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;

    return 0;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n;
  cin>>n;
  vector<int> vec(2*n-1);
  rep(i,2*n-1) scanf("%d", &vec[i]);

  int l=0, r=2*n;
  while(r-l>1){
    int m=(r+l)/2;

    vector<bool> v(2*n-1);
    rep(i,2*n-1) v[i] = vec[i]>=m;
    // m以上はtrueになってる
    bool res;
    int dl=n-2,dr=n;
    while(dl>=0){
      bool bl = v[dl]==v[dl+1];
      bool br = v[dr]==v[dr-1];
      if(bl||br){
        if(bl){ res=v[dl]; break;}
        if(br){ res=v[dr]; break;}
      }
      dl--; dr++;
    }
    if(dl<0){
      if(n%2==0) res=!v[n-1];
      else res=v[n-1];
    }

    if(res) l=m;
    else r=m;
  }

  cout<<l<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll K, N;
    cin >> N >> K;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    sort(all(v));
    ll sum = 0;
    rep(i, K) {
        sum += v[N-1-i];
    }
    print(sum);
    return 0;
}


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

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=b){
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
  return 0;
}


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

using namespace std;

int n;
long long dp[100002][3];
long long h[100010][3];

long long get(int i, int type) {
    if (i < 0) {
        return -1;
    }
    if (i == 0) {
        return h[i][type];
    }
    if (dp[i][type] != -1) {
        return dp[i][type];
    }

    for (int j = 0; j < 3; ++j) {
        if (j != type) {
            dp[i][type] = max(dp[i][type], get(i-1, j) + h[i][type]);
        }
    }

    return dp[i][type];
}

int main(void) {
    cin>>n;
    for(int i = 0; i < n; ++i) {
        cin>>h[i][0]>>h[i][1]>>h[i][2];
        dp[i][0] = dp[i][1] = dp[i][2] = -1;
    }

    cout<<max(max(get(n-1, 0), get(n-1, 1)), get(n-1, 2));

    return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long h, w, k;
  cin >> h >> w >> k;

  vector<vector<char>> corg(h, vector<char>(w));

  for (long i = 0; i < h; i++) {
    for (long j = 0; j < w; j++) {
      char tmp;
      cin >> tmp;
      corg.at(i).at(j) = tmp;
    }
  }

  // w * h通り
  long n = h + w;
  long ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<vector<char>> c(h, vector<char>(w));
    for (long row = 0; row < h; row++) {
      for (long col = 0; col < w; col++) {
        c.at(row).at(col) = corg.at(row).at(col);
      }
    }
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {  // 列挙に i が含まれる時
        if (i < h) {
          c.at(i) = vector<char>(w, 'r');
        } else {
          for (long ii = 0; ii < h; ii++) {
            c.at(ii).at(i - h) = 'r';
          }
        }
      }
    }
    // 判定
    long count = 0;
    for (long ii = 0; ii < h; ii++) {
      for (long jj = 0; jj < w; jj++) {
        if (c.at(ii).at(jj) == '#') {
          count++;
        }
      }
    }
    if (count == k) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3536
#!python3

def mii():
    return map(int, input().split())

from heapq import heappush, heappop

def resolve():
    N, M = mii()
    ab = [[] for i in range(N)]
    for i in range(M):
        a, b, c = mii()
        ab[a-1].append((b-1, c))

    used = [False] * N
    q = [(0, set())]
    while q:
        p1, s1 = q.pop()

        for p2, x in ab[p1]:
            if p2 in s1:
                print("inf")
                return

            s2 = set(s1)
            s2.add(p2)
            q.append((p2, s2))

    q = []
    heappush(q, (0, 0))
    dp = [10**9*N+1] * N
    while q:
        t1, p1 = heappop(q)

        for p2, t2 in ab[p1]:
            t3 = t1 - t2
            if t3 < dp[p2]:
                dp[p2] = t3
                heappush(q, (t3, p2))

    print(-dp[-1])

def resolve():
    N, M = mii()
    ab = [[] for i in range(N)]
    for i in range(M):
        a, b, c = mii()
        ab[a-1].append((b-1, c))


    INF = 10**9*N + 1
    dp = [-INF] * N
    dp[0] = 0
    for i in range(N + 1):
        updated = False
        for p1 in range(N):
            if dp[p1] == -INF: continue

            for p2, t2 in ab[p1]:
                t3 = dp[p1] + t2
                if t3 > dp[p2]:
                    dp[p2] = t3

                    updated = True
        if i == N-1:
            dp0 = dp[-1]
        elif i == N:
            dp1 = dp[-1]
            if dp0 == dp1:
                print(dp1)
            else:
                print("inf")

        if not updated:
            print(dp[-1])
            return



if __name__ == "__main__":
    resolve()


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n,a);
    lli B[n];
    REP(i,0,n) {
        B[i] = a[i] - (i+1);
    }
    sort(B,B+n);
    lli b = B[(n+1)/2-1];
    lli ans = 0;
    REP(i,0,n) {
        ans += abs(B[i]-b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

ll N,inp;
vector<ll>V;

void solve()
{
	cin>>N;

	for(ll i = 0; i < N; i++)
	{
		cin>>inp;
		V.pb(inp);
	}

	ll curr_max = V[0], res = 0;

	for(ll i = 1; i < N; i++)
	{
		if(V[i] > curr_max)
			curr_max = V[i];

		else
			res += (curr_max - V[i]);

	}

	cout<<res<<endl;
}

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


	solve();

	return 0;
}

Measured memory_bytes: 5320
using System;

namespace abc162B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            long A = long.Parse(Console.ReadLine());
            long ans = 0;
            for(long i = 1; i <= A; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                    ans = ans + i;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27476
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
P.sort()

su = 0
S = -P[0][0]
ans = -10**19
for a, b in P:
    S = min(S, su - a)
    ans = max(ans, su + b - a - S)
    su += b
print(ans)


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;

  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int total = C;
    for (int j = 0; j < M; j++) {
      int Aij;
      cin >> Aij;
      total += (Aij * B[j]);
    }
    if (total > 0) {
      ans += 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
/* 
	بسم الله الرحمن الرحیم
		
	(; طلا یک جهانی
*/

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

#define int long long
#define F first
#define S second

const int MAX_N = 1000 * 1000 + 5;
int n, a[MAX_N];

int32_t main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int cnt = 0;
	for (auto i: s)
		cnt += i == 'x';
	if (cnt < 8)
		cout << "YES";
	else
		cout << "NO";
}


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

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

    int max_profit = numeric_limits<int>::min();
    int min_value = numeric_limits<int>::max();

    for (int x; n-- && cin >> x;) {
        max_profit = max(x - min_value, max_profit);
        min_value = min(x, min_value);
    }

    cout << max_profit << endl;

    return 0;
}

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

int main(void){
    int N, D, ans=0;
    std::cin >> N >> D;
    std::vector<std::vector<int>> X(N, std::vector<int>(D));

    for (int i=0; i<N; ++i){
        for (int j=0; j<D; ++j){
            std::cin >> X.at(i).at(j);
        }
    }

    for (int i=0; i<N-1; ++i){
        for (int j=i+1; j<N; ++j){
            int tmp = 0;
            for (int k=0; k<D; ++k){
                tmp += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
            }
            double d = sqrt(tmp);
            if (tmp == (int)d *  (int)d) ++ans;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  double data[N];
  rep(i,N){
	cin >> data[i];
    data[i] = 1/data[i];
  }
  double sum = 0;
  rep(i,N){
    sum += data[i];
  }
  cout << 1/sum << endl;
}

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

int main() {
    int N;
    string S;
    cin >> N>>S;
    bool judge = false;
    for(int i=0; i<N/2;i++){
        if(S.at(i) != S.at(N/2 + i)){
            judge = true;
        }
    }
    if(judge) cout <<"No" <<endl;
    else if (N%2 != 0) cout << "No" <<endl;
    else cout << "Yes" <<endl;
}

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


int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	long t,d;cin>>t>>d;
	long c=0;
	while(t--){
		double a,b;cin>>a>>b;
		if(sqrt(a*a+b*b)<=d)c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3820
def main():
    N = int(input())

    def check():
        for i in range(1, 10):
            for j in range(1, 10):
                if i * j == N:
                    return True
        return False

    cond = check()

    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

template <class T>
class SegmentTree{
  ll N;                         //葉の数
  vector<T> data;               //データを格納(要素数2*N-1)
  T def;                        //初期値かつoperationの単位元
  function<T(T,T)> operation;   //区間クエリで使う関数ラムダ式で入れる
  function<T(T,T)> update;      //一点更新で使う関数

  T _query(ll a,ll b,ll k,ll l,ll r){   //区間(a,b)を考え半開区間[l,r)が管轄
      if(b <= l || r <= a) return def;  
      if(a <= l && r <= b){
          return data[k];
      }else{
          T c1 = _query(a,b,k*2+1,l,(l+r)/2);   //左の子
          T c2 = _query(a,b,k*2+2,(l+r)/2,r);   //右の子
          return operation(c1,c2);
      }
  }
  public:
  SegmentTree(size_t _N,T _def,function<T(T,T)> _operaition,function<T(T,T)> _update):def(_def),operation(_operaition),update(_update){
          N = 1;                //N必要サイズにNを調整
          while(N < _N){
              N *= 2;
          }
          data = vector<T>(2*N-1,def);
  }

  void change(ll i,T x){
      i += N-1;
      data[i] = update(data[i],x);
      while(i > 0){
          i = (i-1)/2;
          data[i] = operation(data[i*2+1],data[i*2+2]);
      }
  }

  T query(ll a,ll b){
      return _query(a,b,0,0,N);
  }

  T operator[](ll i){
      return data[i+N-1];
  }
};


ll N;

auto f = [](ll a,ll b){return max(a,b);};
auto g = [](ll a,ll b){return b;};
SegmentTree<ll> ST(100010,0,f,g);

ll lwb(ll x,ll t){
    ll l = t,r = N+1;
    while(r-l > 1){
        ll mid = (l+r)/2;
        if(ST.query(t,mid) > x)r = mid;
        else l = mid;
    }
    if(r == N+1)return N;
    return r-1;
}

ll lwb2(ll x,ll t){
    ll l = -1,r = t;
    while(r-l > 1){
        ll mid = (l+r)/2;
        if(ST.query(mid,t) > x)l = mid;
        else r = mid;
    }
    return l;
}

int main(){
    cin >> N;
    vector<ll> A(N);
    
    rep(i,N){
        cin >> A[i];
        ST.change(i,A[i]);
    }
    ll ans = 0;
    rep(i,N){
        ll a,b,c,d;
        c = lwb(A[i],i);b = lwb2(A[i],i);
        d = lwb(A[i],c+1);a = lwb2(A[i],b);
        ans += ((d-c) * (i-b) + (c-i) * (b-a)) * A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>


using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    k = max(a,b);
    k = max(k,c);
    int q = 3*k - a - b -c;
    if (q % 2 == 0){
        cout << q / 2;
    }
    else{
        cout << (q+3)/2;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#

int main() {
    int a,b;
    while (1) {
        scanf("%d %d", &a,&b);
        if(a==0 && b==0) break;
        if (a>b) {
            int d=a;
            a=b;
            b=d;
        }
       printf("%d %d\n", a,b);
    }
}


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

struct Point {
  int x, y;
};

struct Line {
  int i;
  vector<Point> ps;
};

void turn(Line &l) {
  for (int i = 0; i < l.ps.size(); i++) {
    int tmp = l.ps[i].x;
    l.ps[i].x = - l.ps[i].y;
    l.ps[i].y = tmp;
  }
}

void normal(Line &l) {
  int x = l.ps[0].x;
  int y = l.ps[0].y;
  for (int i = 0; i < l.ps.size(); i++) {
    l.ps[i].x -= x;
    l.ps[i].y -= y;
  }
}

void reverse(Line &l) {
  int m = l.ps.size();
  for (int i = 0; i < m / 2; i++) {
    Point tmp = l.ps[i];
    l.ps[i] = l.ps[m - i - 1];
    l.ps[m - i - 1] = tmp;
  }
}

int main() {
  int n;
  while (cin >> n, n != 0) {
    vector<Line> lines;
    lines.reserve((n + 1) * 8);
    for (int i = 0; i <= n; i++) {
      int m;
      cin >> m;

      Line l;
      l.i = i;
      l.ps.resize(m);
      for (int j = 0; j < m; j++) {
	cin >> l.ps[j].x >> l.ps[j].y;
      }
      normal(l);
      lines.push_back(l);
      reverse(l);
      normal(l);
      lines.push_back(l);

      for (int j = 0; j < 3; j++) {
	turn(l);
	normal(l);
	lines.push_back(l);
	reverse(l);
	normal(l);
	lines.push_back(l);
      }
    }

    Line line = lines[0];
    for (int i = 1; i <= n; i++) {
      if (line.ps.size() != lines[i * 8].ps.size()) {
	continue;
      }
      for (int j = i * 8; j < (i + 1) * 8; j++) {
	bool flag = false;
	Line l = lines[j];
	for (int k = 0; k < l.ps.size(); k++) {
	  if (l.ps[k].x != line.ps[k].x || l.ps[k].y != line.ps[k].y) {
	    break;
	  }
	  if (k == l.ps.size() - 1) {
	    cout << l.i << endl;
	    flag = true;
	  }
	}
	if (flag) {
	  break;
	}
      }
    }

    cout << "+++++" << endl;
  }

  return 0;
}

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

int N, X, Y;
vector<int> K;

void solve(void) {
	for (int i = 1; i <= N - 1; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			if (j <= X || i >= Y) {
				int d = j - i;
				++(K[d]);
			}
			else {
				int d1 = j - i;
				int d2 = abs(X - i) + 1 + abs(Y - j);
				int d = min(d1, d2);
				++(K[d]);
			}
		}
	}
}

int main(void) {
	cin >> N >> X >> Y;
	K.resize(N, 0);
	solve();
	for (int i = 1; i < N; ++i)
		cout << K[i] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool contain(int mask, int pos){
  return (mask & (1 << pos));
}

int main(){
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }

  int ans = INT_MAX;
  for(int mask = 0; mask < (1 << D); mask++){
    int score = 0, problems = 0;
    for(int i = 0; i < D; i++){
      if(contain(mask, i)){
	problems += p[i];
	score += 100 * (i + 1) * p[i] + c[i];
      }
    }
    
    for(int i = D - 1; i >= 0; i--){
      if(contain(mask, i)) continue;
      for(int j = 0; j < p[i]; j++){
	if(G <= score) break;
	score += 100 * (i + 1);
	problems++;
      }
      break;
    }

    if(G <= score) ans = min(ans, problems);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){ fast;
	
	int n, answer = 0; cin>>n;
	for(int i = 1; i <= n; i++){
		if(i % 3 != 0 && i % 5 != 0){
			answer += i;
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3648
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int X;
    cin >> X;
    if(X == 3 || X == 5 || X == 7) cout << "YES" << endl;
    else cout << "NO" << endl; 
}

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

int main() {
	int n, a[100002], b[100001];
	long long monsters=0;
	
	cin>>n;
	for(int i=0;i<n+1;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	
	for(int i=n-1;i>=0;i--){
		if(a[i+1]>b[i]){
			monsters+=b[i];
			a[i+1]-=b[i];
			b[i]=0;
			continue;
		}
		else {
			b[i]-=a[i+1]; monsters+=a[i+1]; a[i+1]=0;
			if(a[i]>b[i]){
				a[i]-=b[i]; monsters+=b[i]; b[i]=0;
				continue;
			}
			else{
				b[i]-=a[i]; monsters+=a[i]; a[i]=0;
			}
		}
	}
	cout<<monsters;
	return 0;
}

Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    s = get_data(n, [str])
    ans = 0
    a = 0
    b = 0
    ba = 0
    for si in s:
        if si[-1] == 'A':
            a += 1
        if si[0] == 'B':
            b += 1
        if si[-1] == 'A' and si[0] == 'B':
            ba += 1
        for c1, c2 in zip(si, si[1:]):
            if c1 == 'A' and c2 == 'B':
                ans += 1
    if ba != a or ba != b or ba == 0:
        ans += min(a, b)
    else:
        ans += ba - 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 70740
def main():
    n,k=map(int,input().split())
    pp=list(map(int,input().split()))
    m=s=sum(pp[i] for i in range(k))
    for i in range(k,n):
        s=s-pp[i-k]+pp[i]
        if s>m:
            m=s
    print(0.5*k+0.5*m)

main()

Measured memory_bytes: 25060
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List
import           Data.Bits

input :: IO [Int]
input = do
    d <- (fst . fromJust) . BS.readInt <$> BS.getLine
    map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine

process :: [Int] -> Integer
process xs = foldr ((.|.) . shift 1) (0 :: Integer) xs

main :: IO ()
main = do
    [n,k] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
    ass <- replicateM k input
    putStr $ show $ result n ass
    where
        hammingWeight ass = popCount $ convoluton (map process ass)
        result n ass = n - hammingWeight ass
        convoluton = foldl (.|.) (0::Integer)

Measured memory_bytes: 4972
import collections
 
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a = [int(i)-1 for i in a]
 
ex = collections.defaultdict(lambda:-1)
step=1
cur=0
ex[0]=0
while 1:
    if ex[a[cur]]!=-1:
        cycle = step-ex[a[cur]]
        k-=ex[a[cur]]-1
        #print(k%cycle)
        break
    else:
        if step==k:
            print(a[cur]+1)
            exit()
        ex[a[cur]]=step
        cur=a[cur]
    step+=1

#print(ex,k%cycle)
for i in range(k%cycle):
    cur = a[cur]
print(cur+1)

Measured memory_bytes: 33900
#include <stdio.h>

int main(){
  long long int A,B1,B2;
  scanf("%lld %lld.%02lld",&A,&B1,&B2);
  B1=B1*100LL+B2;
  A*=B1;
  A/=100LL;
  printf("%lld\n",A);
  return 0;
}


Measured memory_bytes: 1732
n,p,a = map(int,input().split())

ll = [int(input()) for i in range(a)]


import collections

c = collections.Counter(ll)

for i in range(n):
  if c.get(i+1)==None:
    if p - a > 0:
      print("Yes")
    else:
      print("No")
    continue
  if a - c.get(i+1) >= p:
    print("No")
  else:
    print("Yes")
  

      

Measured memory_bytes: 11916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC140A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N =  int.Parse(Console.ReadLine());

            Console.WriteLine(Combination(Enumerable.Range(1, N), 3).Count());
        }

        public static IEnumerable<T[]> Combination<T>(IEnumerable<T> items, int k)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };

                foreach (var rightside in Combination(items, k - 1))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}

Measured memory_bytes: 11348
N = int(input())

a = list(map(int,input().split()))

a.sort()


x = []
i = len(a)-1
#print(a)

while i > 0:
    if a[i] == a[i-1]:
        x.append(a[i])
        i-=1

    i-=1
    
    if len(x) == 2:
        print(x[0]*x[1])
        exit()



print(0)




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

#define MOD 1000000007
#define ll long long
#define rep(i, n) for(ll i = 0, i_length = (n); i < i_length; i++)

int main() {
	ll x;
	cin >> x;
	// a.b=+,-
	rep(i, 1000) rep(j, 1000) {
		if (pow(i, 5) + pow(j, 5) == x) {
			cout << i << " " << (-1) * j << endl;
			goto END;
		}

		if (i > j && pow(i, 5) - pow(j, 5) == x) {
			cout << i << " " << j << endl;
			goto END;
		}
	}

END:
	return 0;
}

Measured memory_bytes: 3944
import sys

def main():
    N = int(input())
    zoro = 0
    for i in range(N):
        Ds = [int(s) for s in sys.stdin.readline().split()]
        if(Ds[0] == Ds[1]):
            zoro += 1
            if(zoro > 2):
                print("Yes")
                return(0)
        else:
            zoro = 0
    print("No")

main()

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <climits> 



int main()
{
    long N;
    std::cin >> N;
    for(long i=1; i<=9; i++){
        if(N%i==0 && 1<=N/i && N/i<=9){
            std::cout << "Yes" << std::endl;
            break;
        }
        if(i==9){
            std::cout << "No" << std::endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    now = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x == y:
            now += 1
        else:
            now = 0
        if now == 3:
            print("Yes")
            return
    print("No")
resolve()

Measured memory_bytes: 62108
#include <bits/stdc++.h>
using namespace std;
map <long long ,int >m;
int main()
{
    int n;
    cin>>n;
    long long ans=0;
    for (int i=0;i<n;i++)
    {
        long long x=0;
        cin>>x;
        ans+=m[i-x];
       // cout<<i-x<<"    "<<m[i-x]<<endl;
         m[x+i]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 26348
using System;
using System.Linq;

namespace _5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                for (int i = 0; i < x[0]; i++)
                {
                    for (int I = 0; I < x[1]; I++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9300
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
	int q;
	cin >> q;
	while(q > 0){
		double x = (double)q/2;
		while(abs(pow(x,3)-q) >= 0.00001*q){
			x = x-(pow(x,3)-q)/3/pow(x,2);
		}
		printf("%.6f\n",x);
		cin >> q;
	}
}

Measured memory_bytes: 0
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    vii X(N);
    REP(i, N)
    {
        X[i] = {A[i], i + 1};
    }
    RSORT(X);
    vvi dp(N + 1, vi(N + 1));
    REP1(i, N)
    {
        auto [a, k] = X[i - 1];
        dp[i][0] = dp[i - 1][0] + a * abs(k - (N - i + 1));
        REP1(j, i - 1)
        {
            dp[i][j] = max(dp[i - 1][j - 1] + a * abs(k - j), dp[i - 1][j] + a * abs(k - (N - (i - j - 1))));
        }
        dp[i][i] = dp[i - 1][i - 1] + a * abs(k - i);
    }
    OUT(*max_element(ALL(dp[N])));
}

Measured memory_bytes: 34692
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();

    if (500*k >= x) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>

using namespace std;
#define N 4
#define NN 16

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
int H[NN][NN];

struct Puzzle
{
  int f[NN],space,MD;
  int cost;

    bool operator < (const Puzzle& p) const {
    for(int i=0; i<NN; i++) {
        if( f[i] == p.f[i] ) continue;
        return f[i] < p.f[i];
    }
    return false;
    }
};

struct State
{
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const{
    return estimated > s.estimated;
  }
};

int getAllMD(Puzzle pz){
    int sum=0;
    for(int i=0; i<NN; i++) {
    if( pz.f[i] == NN ) continue;
    sum += H[i][pz.f[i]-1];
    }
    return sum;
}

int astar(Puzzle s){
  priority_queue<State> PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);

  while(!PQ.empty()){
    State st = PQ.top(); PQ.pop();
    u = st.puzzle;
    if( u.MD == 0 ) return u.cost;
    V[u] = true;

    int sx = u.space / N;
    int sy = u.space % N;

    for(int r=0; r<4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if( tx<0 || ty<0 || tx>=N || ty>=N ) continue;
        v = u;

        v.MD -= H[tx*N+ty][v.f[tx*N+ty]-1];
        v.MD += H[sx*N+sy][v.f[tx*N+ty]-1];

        swap(v.f[sx*N+sy], v.f[tx*N+ty]);
        v.space = tx*N+ty;
        if( !V[v] ) {
        v.cost++;
        State news;
        news.puzzle = v;
        news.estimated = v.cost + v.MD;
        PQ.push(news);
        }
    }
    }
    return -1;
}

int main(){
for(int i = 0; i<NN; i++)
  for(int j =0;j < NN;j++)
    H[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for(int i=0;i<NN;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = NN;
      in.space = i;
    }
  }

  cout << astar(in) << endl;
  return 0;
}


Measured memory_bytes: 257600
#pragma region Macros
// ===========
// include
// ===========
#include <bits/stdc++.h>

using namespace std;

// ===========
// typedef
// ===========
typedef int64_t int64;
typedef vector<int64> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// ===========
// conversion
// ===========
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

// ===========
// math
// ===========
template<class T> inline T sqr( T x ){ return x * x; }
inline int64 Factorial( int64 n ){ return n == 0 ? 0 : ( n == 1 ? 1 : Factorial( n - 1) * n  ); }

// ===========
// repetition
// ===========
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a), __length = int(b); i < __length; ++i)

void input(vector<int64> *vec, const int size){ vec->resize(size); rep(i, size) { cin >> vec->at(i); } }
void input(vector<string> *vec, const int size){ vec->resize(size); rep(i, size) { cin >> vec->at(i); } }

#pragma endregion //Macros

int main()
{
    int X;
    cin >> X;
    if( X >= 30 )
    {
        cout << "Yes" << endl;
    } else 
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620