akhauriyash/Code-Regression huggingface dataset:
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_074_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(3).
    01 K      PIC 9(3).

    01 INP    PIC X(300).
    01 maxlen PIC 9(3).
    01 cur    PIC 9(3)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(3).
    01 ans    PIC X(5).

    01 x      PIC 9(3).

    01 sm     PIC 9(5)  VALUE 0.

    01 ZS     PIC Z(6).
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT K.
    ACCEPT INP.

    MOVE N TO maxlen.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO x

        COMPUTE x = FUNCTION MIN(x, K - x)
        MULTIPLY 2 BY x
        ADD x TO sm

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE sm TO ZS

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 892
#include<iostream>  
#include<cstdio>  
#include<cstring> 
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<cmath>
//#define inf  0x3f3f3f3f3f3f3f3f
#define bit(x) (1<<(x)) 
using namespace std;
const int maxn = int(1e5)+100;
const int mod = 998244353;
const int inf = 2 * int(1e9) + 100;
const double pi = acos(-1);
typedef long long LL;
int a[maxn], b[maxn];
int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) 
		scanf("%d", &b[i]);
	LL sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i])
			sum1 += a[i] - b[i];
		else
			sum2 += (b[i] - a[i]) / 2;
	}
	if (sum2 < sum1) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
ll dp[100005];
ll arr[100005];
int main(){
	IOS 
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	dp[1]=0;
	dp[2]=abs(arr[1]-arr[2]);
	for(int i=3;i<=n;i++){
		dp[i]=1e18;
		for(int j=max(1,i-k);j<i;j++){
			dp[i]=min(dp[j]+abs(arr[j]-arr[i]),dp[i]);
		} 
		
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 2000000;
    for (int i = 0; i < (1<<n); i++) {
        bitset<12> bit(i);
        vector<int> skill(m, 0);
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (bit[j] == 1) {
                sum += c[j];
                for (int k = 0; k < m; k++) {
                    skill[k] += a[j][k];
                }
            }
        }
        bool ok = true;
        for (int k = 0; k < m; k++) {
            if (skill[k] < x) ok = false;
        }
        if (ok) ans = min(ans, sum);
    }
    if (ans == 2000000) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll INF = 1e18;
void mainsolve(){

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

	vector<ll> key(m); // 開けられる宝箱
	vector<ll> cost(m); // 鍵の値段
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		cost[i] = a;
		rep(j,b){
			ll c;
			cin >> c;
			key[i] += 1<<(--c);
		}
	}

	vector<ll> dp(1<<n, INF);
	dp[0] = 0;
	rep(i,1<<n){
		rep(j,m){
			ll next = i | key[j];
			if(next < (1<<n)){
				dp[next] = min(dp[next], dp[i] + cost[j]);
			}
		}
	}

	if(dp[(1<<n)-1] == INF) cout << -1 << endl;
	else cout << dp[(1<<n)-1] << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct CT {
  int c, t;
  CT(int c, int t): c(c), t(t) {}
  bool operator< (const CT& x) const {return c < x.c;}
};
ostream& operator<<(ostream& s, const CT& x) {
  return s<< "(" << x.c << "," << x.t << ")";
}
void p(const vector<CT>& xs) {
  cout<< xs.size() << ": ";
  for (const auto& x:xs) cout<< x <<",";
  cout<<endl;
}
int N,T;
vector<CT> v1,v2;
int main() {
  scanf("%d%d", &N, &T);
  for (int n=0;n<N;n++) {
    int c,t; scanf("%d%d",&c,&t); v1.push_back(CT(c, t));
  }
  //p(v1);
  for (int i=0;i<v1.size();i++) {
    if (v1[i].t <= T) v2.push_back(v1[i]);
  }
  if (v2.size()==0) { printf("TLE\n"); exit(0); }
  //p(v2);
  sort(v2.begin(), v2.end());
  //p(v2);
  printf("%d\n", v2[0].c);
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
M = INT()
T = LIST()

cnt_D = Counter(D)
cnt_T = Counter(T)
for t in T:
	if cnt_D[t] < cnt_T[t]:
		print("NO")
		break
else:
	print("YES")


Measured memory_bytes: 58812
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;


int main(){
	ios::sync_with_stdio(false);
	int x,y;
    cin>>x>>y;
    if(x%y==0) cout<<-1<<endl;
    else cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
//16D8104007J Kanehiro Maho 兼弘真帆 2018年4月20日

#include<stdio.h>
#include<math.h>

int main(void){
  int n;
  scanf("%d",&n);
  int i,j;
  int x;
  int count=0;
  int ans;
  for(i=0;i<n;i++){
    ans=1;
    scanf("%d",&x);
    for(j=2;j<=sqrt(x);j++){
      if(x%j==0){
	ans=0;
	break;
      }
    }
    if(ans){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2044
#include<cstdio>
#include<cstring>

int main(void){
    int s, n;
    int i, j;
    int flag = 0;
    char txt[101];
    char pat[101];

    scanf("%s", txt);
    scanf("%s", pat);

    n = strlen(txt);
    s = strlen(pat);

    for(i = 0; i < n; i++){
        int p = i;
        while(j < s){
            if(p == n) p = 0;
            if(txt[p] == pat[j]){
                p++;
                j++;
            }else{
                j = 0;
                break;
            }
        }
        if(j == s){
            printf("Yes\n");
            flag = 1;
            break;
        }
    }

    if(!flag){
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 948
#include<stdio.h>
int main()
{
	int n,i,j,sum,ans=0;
	int a[55]={};
	while(~scanf("%d",&n)){
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				sum=a[i]*a[j];
				ans+=sum;
			}
		}printf("%d\n",ans);
		ans=0;
	}
}

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    int x;
    cin >> x;

    for (long long B = 0; B < 200; ++B) {
        for (long long A = B + 1; A * A * A * A * A - B * B * B * B * B <= x; ++A) {
            if (A * A * A * A * A - B * B * B * B * B == x) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }

    for (long long B = 0; B < 200; ++B) {
        for (long long A = 0; A < 200; ++A) {
            if (A * A * A * A * A + B * B * B * B * B == x) {
                cout << A << "  " << -B << endl;
                return;
            }
        }
    }
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[105],sum,ans,d;
inline int X(int d)
{
	sum=0;
	for(int i=1;i<=n;i++)
		sum+=(a[i]-d)*(a[i]-d);
	return sum;
}
int main()
{
	ans=0x3f3f3f3f;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=-100;i<=100;i++)
		ans=min(ans,X(i));
	printf("%d",ans);
}

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

// 構造体で座標を決まる
struct Point { double x, y;};

void koch(int n, Point a, Point b)
{
    // nが0のときは何も返さない
    if (n == 0) return;

    // 座標s, t, uを二次元に定める
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;  // 度からラジアンに単位を変換

    // 三等分したときの左側の座標
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    // 三等分したときの右側の座標
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    // sの起点として60度tを左に傾けた座標がuだから回転行列をかける
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    /*
    nが0になるまで再帰を続ける
    そしてnが0になった時点での座標をそれぞれ出力する
    */
    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main()
{
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 2716
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <climits>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;

#define mkp make_pair
#define eb emplace_back
#define sz(s) (ll)(s.size())
const int N = 3e6 + 123;
const int mod = 1e9 + 7;
const int INF = INT_MAX;

#define all(s) s.begin(), s.end()

main (){
	clog << "Ready\n";
	
	string s;
	int n;
	cin >> n >> s;
	
	for (int i = 0; i < sz(s); ++ i) {
		s[i] = s[i] + n;
		if (s[i] > 90)
			s[i] -= 26;
	}
	
	cout << s;
	
    cout << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>

using namespace std;

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
void f(){
  LL i, x, k, d, mod;
  cin >> x >> k >> d;
  
  i = 1;
  x = abs(x);
  i = x / d;
  mod = x % d;
  if(abs(x - (i+1)*d) <= mod)
    i++;
  //while(abs(x - i*d) >= abs(x - (i+1)*d))
    //i++;
  //cout << i << endl;
  if(i > k){
    cout << abs(x - k*d) << endl;
    return;
  }
  if(i == k){
    cout << abs(x - i*d) << endl;
    return;
  }
  if((k-i) % 2 == 0)
    cout << abs(x - i*d) << endl;
  else
    cout << d - abs(x - i*d) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  f();
 return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n,a,b;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>a>>b;
    ll lo = b + (n-1) * a;
    ll hi = a + (n-1) * b;
    cout<<max(0ll,hi-lo+1)<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;

    set<int> alph[26];
    for(int i=0; i<n; i++){
        alph[s[i]-'a'].insert(i);
    }

    for(int k=0; k<q; k++){
        int sw; cin >> sw;
        if(sw == 1){
            // query 1
            int i; cin >> i; i--;
            char c; cin >> c;
            // 入れ替え操作に対応
            // alph[c-'a'].insert(i);
            // alph[s[i]-'a'].erase(i);
            alph[s[i]-'a'].erase(i);
            s[i] = c; // これ必要じゃん！！
            alph[s[i]-'a'].insert(i);

        }
        else if(sw == 2){
            // query 2
            int l, r;
            cin >> l >> r;
            l--;
            int typs = 0;
            for(int i=0; i<26; i++){
                set<int>::iterator it;
                it = alph[i].lower_bound(l);
                if(it != alph[i].end() && *it < r){
                    typs++;
                }
            }
            cout << typs << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[][] list = new int[n][2];
      int correct=0;
      int penalty=0;
      for(int i=0;i<m;i++){
        int p = sc.nextInt();
        String s = sc.next();
        if(s.equals("AC") && list[p-1][0]!=1){
          list[p-1][0]=1;
          correct++;
          penalty+=list[p-1][1];
        }else if(s.equals("WA") && list[p-1][0]!=1){
          list[p-1][1]++;
        }
      }      
      System.out.println(correct+" "+penalty);
    }
}


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

int main (void){
    int i,m=0,min=1e9;
    long long int ans=0;
    int N; 

    scanf("%d",&N);

    long long int A[N]; 

    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
        if(A[i]<0)m++;
        int a = abs(A[i]);
        ans += a;
        if(min>a){min=a;}
    }

    if(m%2==0){
        printf("%lld\n",ans);
    }
    else{
        printf("%lld\n",ans-2*min);
    }

    return 0;
}

Measured memory_bytes: 896
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  ll a;
  long double b;
  cin >> a >> b;
  cout << ll(a * b) << endl;
}


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

using ll = long long;
using pii = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

template <unsigned int MOD>
struct ModInt {
	using uint = unsigned int;
	using ull = unsigned long long;
	using M = ModInt;

	uint v;

	ModInt(ll _v = 0) { set_norm(_v % MOD + MOD); }
	M& set_norm(uint _v) { //[0, MOD * 2)->[0, MOD)
		v = (_v < MOD) ? _v : _v - MOD;
		return *this;
	}

	explicit operator bool() const { return v != 0; }
	M operator+(const M& a) const { return M().set_norm(v + a.v); }
	M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }
	M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }
	M operator/(const M& a) const { return *this * a.inv(); }
	M& operator+=(const M& a) { return *this = *this + a; }
	M& operator-=(const M& a) { return *this = *this - a; }
	M& operator*=(const M& a) { return *this = *this * a; }
	M& operator/=(const M& a) { return *this = *this / a; }
	M operator-() const { return M() - *this; }
	M& operator++(int) { return *this = *this + 1; }
	M& operator--(int) { return *this = *this - 1; }

	M pow(ll n) const {
		if (n < 0) return inv().pow(-n);
		M x = *this, res = 1;
		while (n) {
			if (n & 1) res *= x;
			x *= x;
			n >>= 1;
		}
		return res;
	}

	M inv() const {
		ll a = v, b = MOD, p = 1, q = 0, t;
		while (b != 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(p -= t * q, q);
		}
		return M(p);
	}

	bool operator==(const M& a) const { return v == a.v; }
	bool operator!=(const M& a) const { return v != a.v; }
	friend ostream& operator<<(ostream& os, const M& a) { return os << a.v; }
	static int get_mod() { return MOD; }	
};

using Mint = ModInt<1000000007>;

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

	V<Mint> dp(K + 1);
	Mint ans;

	for (int i = K; i >= 1; --i) {
		dp[i] = Mint(K / i).pow(N);
		for (int j = i * 2; j <= K; j += i) {
			dp[i] -= dp[j];
		}
		ans += dp[i] * (Mint)i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3788
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var sum = Array(n) { i -> 0}
    var w = 0
    s.forEachIndexed {i, c ->
        sum[i] += w
        w += if (c == 'W') 1 else 0
    }
    var e = 0
    s.reversed().forEachIndexed {i, c ->
        sum[n - i - 1] += e
        e += if (c == 'E') 1 else 0
    }
    println(sum.min())
}

Measured memory_bytes: 50684
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  int k,x;
  cin>>k>>x;
  Yes(k*500>=x);


}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{ int N,i,C0=0,C1=0,C2=0,C3=0;
 char S[100000];
 scanf("%d",&N);
 for(i=0;i<N;i++)
 { scanf("%s",S);
   if(S[0]=='A')
     C0 = C0+1;
   else if(S[0]=='W')
     C1 = C1+1;
   else if(S[0]=='T')
     C2=C2+1;
   else 
     C3=C3+1;
 }
 printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",C0,C1,C2,C3);
   return 0;
}
 


Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






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


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

bool dp[1000001] = {};

int main(){
    int n, a, b;
    while(cin >> n >> a >> b, n+a+b){
        memset(dp, 0, sizeof(dp));
        dp[0] = true;
        for(int i = 0; i <= n; i++){
            if(!dp[i])  continue;
            if(i+a <= n)    dp[i+a] = true;
            if(i+b <= n)    dp[i+b] = true;
        }

        int cnt = n;
        for(int i = 1; i <= n; i++) cnt -= dp[i];

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
long long a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]=a[i]-i;
    }
    sort(a+1,a+n+1);
    long long k=a[(n+1)/2],ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=(long long)abs(a[i]-k);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m; cin >> n >> m;
    vvl v(n, vl(3));
    rep(i,n){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    ll mul[3];
    ll ans = 0;
    for(ll bit=0; bit<(1<<3); bit++){
        rep(i,3){
            if(bit & (1<<i)) mul[i] = 1;
            else mul[i] = -1;
        }
        priority_queue<ll> pq;
        rep(i,n){
            ll sum = 0;
            rep(j,3){
                sum += v[i][j] * mul[j];
            }
            pq.push(sum);
        }
        ll s = 0;
        rep(i,m){
            s += pq.top(); pq.pop();
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<tgmath.h>
#include<cstdio>
using namespace std;

int main()
{

    int i,j,k,m,n,val,t=0,test;
    cin>>i>>j>>k;
    if(k>=i && k<=j)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Hina ios_base::sync_with_stdio(false), cin.tie(0)
#define MAXN 100000
#define pb push_back
#define int long long
using namespace std;
 
int n, m, q, k;
int a, b, c;
int dsu[MAXN+5];
bool tf = 1, p;
vector < pair<int,int> > arr;
 
int finding(int a) {
    return a == dsu[a] ? a : dsu[a] = finding(dsu[a]);
    if (dsu[a] != a) dsu[a] = finding(dsu[a]);
    return dsu[a];
}
 
signed main() {
    Hina;
    cin >> n >> m >> q;
    for (int i = 0; i < n; i++) dsu[i] = i;
    k = n;
    for (int i = 0; i < q; i++) {
        cin >> a >> b >> c;
        if (finding(a) != finding(b) && c == 0) {
            dsu[finding(a)] = finding(dsu[b]);
            k--;
        } else if (c) {
            arr.pb({a, b});
        }
        if (c) p = 1;
    }
    for (int i = 0; i < arr.size(); i++) {
        if (finding(arr[i].first) == finding(arr[i].second)) {
            tf = 0;
        }
    }
    if (m > n-k + k*(k-1)/2/* || (k<=2 && p)*/ || (m==n-1 && p)) tf = 0;
    if (tf) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        int ans = c - a + b;
        pw.println(ans < 0 ? 0 : ans);

        pw.close();
    }
}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std; 

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
    IOS;
    ll n,d;
    cin >>n>>d;
    // ll x[N],y[N];
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(a*a+b*b<=d*d) ans++;
    }
    cout << ans<<"\n";
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a , b , c , d , e ;
    cin >> a >> b >> c >> d >> e ;

    int s = a + b + c + d + e ;
    s -= 15 ;

    cout << abs ( s ) ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3596
K, N = map(int,input().split())
A_list = list(map(int,input().split()))

Distance = []
for i in range(N-1):
    Distance.append(A_list[i+1]-A_list[i])
Distance.append(A_list[0]+K-A_list[N-1])
Distance.sort(reverse=True)

print(K-Distance[0])

Measured memory_bytes: 26060
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> A(N+2); // position
  vector <int> sum_cost(N+2);
  A[0] = 0;
  sum_cost[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    sum_cost[i] = sum_cost[i-1] + abs(A[i]-A[i-1]);
  }
  A[N+1] = 0;
  sum_cost[N+1] = sum_cost[N] + abs(A[N+1]-A[N]);
  
  for (int i = 1; i <= N; i++) {
    int ans = sum_cost[i-1];
    ans += (sum_cost[N+1] - sum_cost[i+1]);
    ans += abs(A[i+1]-A[i-1]);
    cout << ans << endl;
  }
  return 0;
}


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

long long dp[55][55][2555],N,A,x[55];

int main(){
	cin>>N>>A;
	for(int i=1;i<=N;i++) cin>>x[i];
	dp[0][0][0]=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N*50;k++){
				dp[i][j][k]+=dp[i-1][j][k];
				dp[i][j+1][k+x[i]]+=dp[i-1][j][k];
			}
		}
	}
	long long sum=0;
	for(int i=1;i<=N;i++) sum+=dp[N][i][i*A];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<int> A;
    rep(i,n){
        int a;
        cin >> a;
        A.push(a);
    }
    rep(i,m){
        int a = A.top();
        A.pop();
        A.push(a / 2);
    }
    long long ans = 0;
    rep(i,n){
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    }

Measured memory_bytes: 892
N, M = map(int, input().split())
A = list(map(int, input().split()))
check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1
ans = N - x
if ans >= M :
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#!/usr/bin/env python3


def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = [100*A,0]
    # 水の量で全探索する
    N = F // (100*A)
    M = F // (100*B)
    for i in range(N+1):
        for j in range(M+1):
            if i == j == 0:# 水なしはだめ
                continue
            water = 100*A*i + 100*B*j
            if water > F:
                continue
            K = (F - water) // C
            L = (F - water) // D
            for k in range(K+1):
                for l in range(L+1):
                    sugar = C*k + D*l
                    if sugar > (A*i + B*j) * E:# 溶け残りはだめ
                        continue
                    if water + sugar > F:# 溢れたらだめ
                        continue
                    if ans[1] / ans[0] < sugar / (sugar+water):
                        ans = [water+sugar, sugar]
            
    print(*ans)
                    

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m;
vl adj[605];
double s[605],temp[605],ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    rep(i,0,m)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
    }
    s[n]=0;
    sep(i,n-1,1)
    {
        for(auto j:adj[i])
            s[i]+=(s[j]+1)/sz(adj[i]);
    }
    ans=s[1];
    rep(k,1,n)
    {
        temp[n]=0;
        sep(i,n-1,1)
        {
            temp[i]=0;
            if(k!=i)
            {
                for(auto j:adj[i])
                    temp[i]+=(temp[j]+1)/sz(adj[i]);
                if(temp[i]==0)
                    temp[i]=m+1;
            }
            else
            {
                double mx=-1;
                ll nd=-1;
                for(auto j:adj[i])
                {
                    if(temp[j]>mx)
                    {
                        mx=temp[j];
                        nd=j;
                    }
                }
                for(auto j:adj[i])
                {
                    if(j!=nd)
                        temp[i]+=(temp[j]+1)/(sz(adj[i])-1);
                }
                if(temp[i]==0)
                    temp[i]=m+1;
            }
        }
        ans=min(ans,temp[1]);
    }
    printf("%0.10lf\n",ans );
}


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

int main(){
	
	int x,y;
	while(cin>>x>>y){
		if(x==0&&y==0)
			break;
		else{
			if(x>y)
			swap(x,y);
			cout<<x<<" "<<y<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

// ccw (c ?????´???(??????) ab ???????????????????????????????????¢?????????)
// +1 ... a ??? b ??§???????¨??????????????????? b ??? c (COUNTER_CLOCKWISE)
// -1 ... a ??? b ??§????¨??????????????????? b ??? c (CLOCKWISE)
// +2 ... c, a, b ??????????????§????????´?????¶???????????´??? (ONLINE_BACK)
// -2 ... a, b, c ??????????????§????????´?????¶???????????´??? ( or a == b ) (ONLINE_FRONT)
//  0 ... c ????????? ab ??????????????´??? (??? a, b ????????????) (ON_SEGMENT)
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

int main() {
    P a, b, c; cin >> a.X >> a.Y >> b.X >> b.Y;
    int n; cin >> n;
    map<int, string> m;
    m[1] = "COUNTER_CLOCKWISE";
    m[-1] = "CLOCKWISE";
    m[2] = "ONLINE_BACK";
    m[-2] = "ONLINE_FRONT";
    m[0] = "ON_SEGMENT";
    rep(i,0,n) {
        cin >> c.X >> c.Y;
        int ans = ccw(a, b, c);
        cout << m[ans] << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
class UnionFind:
    def __init__(self,n):
        self.d = []
        for i in range(n):
            self.d.append(-1)
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            y, x = x, y
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]

n, m, k = map(int, input().split())

dame = [set() for _ in range(n)]
uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)
    dame[a].add(b)
    dame[b].add(a)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if not uf.same(c, d):
        continue
    dame[c].add(d)
    dame[d].add(c)

for i in range(n):
    ans = uf.size(i) - 1
    ans -= len(dame[i])
    print(ans, end=" ")
print()

Measured memory_bytes: 62212
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007



using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting

int main()
{
  fast;
   ll n,k;
   cin>>n>>k;
   ll a[n];
   forin cin>>a[i];
   sort(a,a+n);
   ll ans=0;
   for(int i=0;i<k;i++)
    ans+=a[i];
   cout<<ans<<endl;



}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end());
int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<ll, int>> a(N);
    for (int i = 0; i < N;++i){
        ll b;
        int c;
        cin >> b >> c;
        a[i] = make_pair(b, c);
    }
    SORT(a);
    ll ans = 0;
    int cnt = 0;
    int i = 0, d = 0;
    while(cnt!=M){
        if (a[d].second > i){
            ans += a[d].first;
            ++i;
            ++cnt;
        }
        else{
            i = 0;
            ++d;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string S;
vector<int> dp;

int a(string &S, vector<int> &dp, int v) {
  if (dp[v] != -1) return dp[v];
  
  if (dp[v] == -1) {
    if ((S[v-1] == '>' && S[v] == '<') || (v == 0 && S[v] == '<') || (v == S.size() && S[v-1] == '>')) {
      return dp[v] = 0;
    }

    if (v == 0 && S[v] == '>') return dp[v] = a(S, dp, v+1) + 1;
    if (v == S.size() && S[v-1] == '<') return dp[v] = a(S, dp, v-1) + 1;

    if (S[v-1] == '<' && S[v] == '>') return dp[v] = max(a(S, dp, v-1)+1, a(S, dp, v+1)+1);
    
    if (S[v-1] == '<' && S[v] == '<') return dp[v] = a(S, dp, v-1) + 1;
    if (S[v-1] == '>' && S[v] == '>') return dp[v] = a(S, dp, v+1) + 1;
  }
}

int main() {
  cin >> S;

  dp.assign(S.size()+2, -1);
  for (int i = 0; i < S.size()+1; ++i) { 
    a(S, dp, i);
  }

  int64_t ans = 0;
  for (int i = 0; i < S.size()+1; ++i) {
    ans += dp[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 41860
s = input()

max = 0
cnt = 0

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
        if max < cnt:
            max = cnt
    else:
      cnt = 0

print(max)


Measured memory_bytes: 9112
/*
	The Islad Was Silent before.
	.....
	And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ioso ios_base::sync_with_stdio(0),cin.tie(0);
#define ffe freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);cin.tie(0);

int main() {
	#ifndef ONLINE_JUDGE
	ffe
	#endif
	ll a,b,c,k;
	cin >> a >> b >> c >> k;;

	ll an = min(k, a);

	k -= an;
	ll man = an;

	 an = min(k,b);
	k-=an;


	an = min(k,c);

	man += (an*(-1));

	cout << man << endl;	
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};



int main() {
    int H,N; cin>>H>>N;
    vector<int> A(N),B(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i]>>B[i];
    }
    vector<vector<ll>> dp(N+1,vector<ll>(2e4+10,MOD));
    dp[0][0]=0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 1e4 + 10; ++j) {
           dp[i+1][j]=min(dp[i+1][j],dp[i][j]) ;
           if(j-A[i]>=0) dp[i+1][j]=min(dp[i+1][j-A[i]]+B[i],dp[i+1][j]);
        }
    }

    ll ans=INF;
    for (int i = H; i < 2e4+10 ; ++i) {
        ans=min(ans,dp[N][i]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 160640
import sys
def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0]
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])


Measured memory_bytes: 5588
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int a[5];
	int k;
	rep(i,5){
		cin >> a[i];
	}
	cin>> k;
	bool ans=true;
	int big=0;
	rep(i,5){
		rep(j,5){
			big=max(big,a[j]-a[i]);
		}
	}

	ans=(k>=big);
	if(ans){
		cout <<"Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

def Battle(a, b, c, d):
    if c > b:
        c -= b
        if a > d:
            a -= d
            Battle(a, b, c, d)
        else:
            print('No')
    else:
        print('Yes')

Battle(a,b,c,d)

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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {

    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    bool compatible[n][n];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            int a;
            cin >> a;

            compatible[i][j] = (a == 1);
        }
    }

    vector<int> dp((1 << n), 0);
    dp[0] = 1;
    for(int bitmask = 0; bitmask < (1 << n) - 1; bitmask++) {
        int man = __builtin_popcount(bitmask);
        for(int woman = 0; woman < n; woman++) {
            if(compatible[man][woman] && !(bitmask & (1 << woman))) {
                int m2 = bitmask ^ (1 << woman);
                dp[m2] = add(dp[bitmask], dp[m2]);
            }
        }
    }

    cout << dp[(1 << n) - 1] << endl;
    return 0;
}


Measured memory_bytes: 11388
n = int(input())
p = tuple(map(float, input().split()))

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
# dp[投][裏]

for i, prob in enumerate(p, 1):
    for j in range(i + 1):
        dp[i][j] = dp[i - 1][j] * prob + dp[i - 1][j - 1] * (1 - prob)

res = sum(dp[n][j] for j in range(n // 2 + 1))
print(res)


Measured memory_bytes: 262408
while True:
    m, f, r = [int(s) for s in input().split()]
    if m == f == r == -1:
        break
    
    if m == -1 or f == -1:
        print('F')
        continue
    
    st = m + f
    if 80 <= st:
        print('A')
        continue
    if 65 <= st:
        print('B')
        continue
    if 50 <= st:
        print('C')
        continue
    if st < 30:
        print('F')
        continue
        
    if 50 <= r:
        print('C')
        continue
    
    print('D')

Measured memory_bytes: 7768
S = input()
_ans = 0
_S = len(S)
for s in range(0,_S):
  X = (s) % 2
  if X == 1 :
    if S[s] == 'R':
      _ans += 1
     
  if X == 0 :
    if S[s] == 'L' :
      _ans += 1
  
  
if _ans >= 1:
  print ('No')
elif _ans ==0:
  print ('Yes')

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	string t;
	cin >> t;
	FOR(i, 0, SZ(t) - 1) {
		if (t[i] == '?') {
			t[i] = 'D';
		}
	}
	pv(t)
	return(0);
}

Measured memory_bytes: 3756