akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;

    int cnt[3];
    rep (i, 3) cnt[i] = 0;

    bool ans;
    int n = s.size();

    rep (i, n)
    {
        ++cnt[s[i] - 'a'];
    }

    if (n == 1)
    {
        ans = true;
    }
    else if (n == 2)
    {
        ans = true;
        rep (i, 3) ans &= cnt[i] != 2;
    }
    else
    {
        int cM = MAX(cnt[0], MAX(cnt[1], cnt[2]));
        int cm = MIN(cnt[0], MIN(cnt[1], cnt[2]));
        ans = (cM - cm) <= 1;
    }

    cout << (ans ? "YES\n" : "NO\n");
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 52;

int n, m, s;

vector<int> dist[N];
vector<bool> vis[N];
   
vector<vector<int>> convert;
vector<vector<int>> v[N];

int32_t main(){_
   
   cin>>n>>m>>s;
   const int M = 50 * n;
   
   for (int i = 0; i < N; ++i)
   {
      dist[i].resize(M+10, inf);
      vis[i].resize(M+10, 0);
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y, silver, time;
      cin >> x >> y >> silver >> time;
      v[x].push_back({y, silver, time});
      v[y].push_back({x, silver, time});
   }

   convert.resize(n+1);
   for (int i = 1; i <= n; ++i)
   {
      int c, d;
      cin >> c >> d;
      convert[i] = {c, d};
   }

   s = min(s, M);
   dist[1][s] = 0;

   set<vector<int>> ms;//function of time
   ms.insert({0, s, 1}); // inserted time, silver coins, vertex

   vector<int> ans(n+1, inf);
   while(!ms.empty()){
      vector<int> f = *ms.begin();
      ms.erase(ms.begin());

      int time = f[0], vertex = f[2], silvers = f[1];

      if (vis[vertex][silvers]){
         continue;
      }

      tr(f);//2500*50
      vis[vertex][silvers] = 1;
      smin(ans[vertex], time);

      int i = silvers + convert[vertex][0];
      if (i <= M){
         if (dist[vertex][i] > time + convert[vertex][1]){
            dist[vertex][i] = time + convert[vertex][1];
            ms.insert({time + convert[vertex][1], i, vertex});
         }
      }

      for(auto it: v[vertex]){
         int nxt_vertex = it[0];
         int required_silver = it[1];
         int update_time = it[2];
         if (silvers >= required_silver){
            if (dist[nxt_vertex][silvers - required_silver] > dist[vertex][silvers] + update_time){
               dist[nxt_vertex][silvers - required_silver] = dist[vertex][silvers] + update_time;
               ms.insert({dist[vertex][silvers] + update_time, silvers - required_silver, nxt_vertex});
            }
         }
      }

   }

   for (int i = 2; i <= n; ++i)
   {
      cout<<ans[i]<<endl;
   }

   return 0;
}


Measured memory_bytes: 11288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
int main() {
	ll h, n;
	cin >> h >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	cout << (h > accumulate(all(a), 0LL) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <stack>
using namespace std;


int main() {
  int total_area = 0;

  stack<int> s1;
  stack<pair<int, int> > s2;

  char c;
  int i = 0;
  int ip, area;
  for (scanf("%c", &c); c != '\n'; scanf("%c", &c), ++i) {
    switch(c) {
      case '\\':
        s1.push(i);
        break;
      case '_':
        break;
      case '/':
        if (s1.empty()) break;
        ip = s1.top();
        s1.pop();
        area = i - ip;
        total_area += area;
        while (s2.empty() == false && s2.top().first > ip) {
          area += s2.top().second;
          s2.pop();
        }
        s2.push(make_pair(ip, area));
        break;
    }
  }

  int s = s2.size();
  int a[s];
  for (int i = s - 1; i >= 0; --i) {
    a[i] = s2.top().second;
    s2.pop();
  }

  printf("%d\n", total_area);
  printf("%d", s);
  for (int i = 0; i < s; ++i)
    printf(" %d", a[i]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 2764
#include<stdio.h>
#include<algorithm>
#include<string.h>

using namespace std;

main()
{
    int height[10];
    int i,j;

    for(i=0;i<10;i++)
    {
        scanf("%d",&height[i]);
    }
    sort(height, height+10);

    for(j=0;j<3;j++)
    {
        printf("%d\n",height[9-j]);
    }
    return 0;
}

Measured memory_bytes: 1044
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e5+5;
const int MOD=1e9+7;
int n;
char s[N];
int a[N];
int dp[N][13];

inline void add(int &x,int y){
	x=(x+y)%MOD;
}

int main(){
	scanf("%s",s);
	n=strlen(s);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		int x=((s[i-1]=='?')?-1:s[i-1]-'0');
		if(x==-1){
			for(int j=0;j<=9;j++) for(int k=0;k<13;k++) add(dp[i][(k*10+j)%13],dp[i-1][k]);
		}else{
			for(int j=0;j<13;j++) add(dp[i][(j*10+x)%13],dp[i-1][j]);
		}
	}
	printf("%d\n",dp[n][5]);
	return 0;
}

Measured memory_bytes: 5376
n = int(input())
ssl = list(map(int, input().split()))
le = n
#sl = set(l)
#ssl = sorted(list(sl))
#le = len(ssl)
ans = 0
for i in range(le):
  a = ssl[i]
  for j in range(le-1):
    if i+j+1 < le and a != ssl[i+j+1]:
      b = ssl[i+j+1]
      for k in range(le-2):
        if i+j+k+2 < le and b != ssl[i+j+k+2] and a != ssl[i+j+k+2]:
          c = ssl[i+j+k+2]
          if a + b > c and b + c > a and c + a > b:
            #print(a, b, c)
            ans += 1

print(ans)

Measured memory_bytes: 9208
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n-1):
  if a[i] +1 == a[i+1] :
    ans += c[a[i]-1]
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	a=min(a, b);
	a=min(a, c);
	a=min(a, d);
	a=min(a, e);
	cout << (n+a-1)/a+4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n+1];
    h[0]=0;
    for(int i=1;i<n+1;i++) cin>>h[i];
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<n+1;i++)
    {
    	int ans=INT_MAX;
    	for(int j=1;j<=k;j++)
    	{
    		if((i-j)>0)            // for example you are on step 4 and k=5 implies -1 doesnt make any sense
    		{
    			ans=min(ans,dp[i-j]+abs(h[i]-h[i-j]));
    		}
    	}
    	dp[i]=ans;
    }
    cout<<dp[n]<<endl;
	return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    string s;
    cin >> s;
    irep(i, s.size()) {
        if(s[i] != ',') {
            cout << s[i];
        } else {
            cout << " ";
        }
    }
    return 0;
}   
/** atcoder **/


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	char c;
	deque<char> s;
	while(cin >> c) {
		s.push_back(c);
	}
	int ans = 0;
	while(s.size() > 1) {
		if(s.front() == s.back()) {
			s.pop_front();
			s.pop_back();
		} else {
			if(s.front() != 'x' && s.back() != 'x') {
				cout << -1 << endl;
				return 0;
			}
			if(s.front() == 'x') {
				s.push_back('x');
			} else {
				s.push_front('x');
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int a[] = new int[n];
      	int s = 0;
      	for (int i = 0; i < n; i++){
          	a[i] = sc.nextInt();
        }
        for (int i = 0; i < n-2; i++){
        	if (a[i] < a[i+1] && a[i+1] < a[i+2]){
        		s += 1;
        	}
        	if (a[i] > a[i+1] && a[i+1] > a[i+2]){
        		s += 1;
        	}
        }
        System.out.println(s);
    }
}

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

const long MOD = 1'000'000'007;

int main() {
	long n; cin >> n;
	vector<long> a(n);
	for (auto& item: a) cin >> item;
	long ans = 0;
	long min = a[0];
	for (long i = 1; i < n; i++) {
		if (a[i] <= min) {
			ans += min - a[i];
		}
		else {
			min = a[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B, C;
        cin >> A >> B >> C;
        ll ans = min(A+B, C) + B;
        if (A+B < C) ++ans;
        cout << ans << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
    long int n,a[2000001],i,sum = 0;
    scanf("%ld",&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%ld",&a[i]);
    }
    for(i = 1 ; i < n ; i++)
    {
        if(a[i] > a[i + 1])
        {
            sum += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n; cin>>n;
    vector<int> color(9);
    int a;
    rep(i,n){
        cin>>a;
        if(a<3200) color[a/400]++;
        else color[8]++;
    }
    int cnt=0;
    rep(i,8) if(color[i]!=0) cnt++;
    cout<<max(1,cnt)<<" "<<cnt+color[8];
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);
  int N;
  ll K;
  cin >> N >> K;
  vector<int> A(N+1);
  vector<ll> steps(N+1,-1);
  bool after_loop=false;
  for(int i=1; i<N+1; i++){
    cin >> A[i];
  }
  int result = 0;
  int next_town = 1;
  for(ll i=1; i<K+1; i++){
    if(!after_loop && steps[next_town]!=-1){
      ll loop_length = i-steps[next_town];
      i=K-(K-steps[next_town])%loop_length;
      after_loop=true;
    }
    steps[next_town]=i;
    next_town = A[next_town];
  }
  cout << next_town << endl;

  return 0;
}

Measured memory_bytes: 5548
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100000];
int res;
int ress;
int resx[100000];
int resy[100000];
inline int doit(int x, int y){
  resx[ress] = x;
  resy[ress++] = y;
  return x - y;
}
int main(){
  int i, j, k, mi, mx;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS=0, RZTsC2BF, cTE1_r3A, e98WHCEY;
    for(KL2GvlyY=0;KL2GvlyY<(N-1)+1;KL2GvlyY++){
      cTE1_r3A = A[KL2GvlyY];
      if(Q5VJL1cS==0 || e98WHCEY>cTE1_r3A){
        e98WHCEY = cTE1_r3A;
        Q5VJL1cS = 1;
        RZTsC2BF = KL2GvlyY;
      }
    }
    mi =RZTsC2BF;
  }
  {
    int FmcKpFmN, KrdatlYV, WYIGIcGE, t_ynMSdg, xr20shxY=0;
    for(FmcKpFmN=0;FmcKpFmN<(N-1)+1;FmcKpFmN++){
      t_ynMSdg = A[FmcKpFmN];
      if(xr20shxY==0 || WYIGIcGE<t_ynMSdg){
        WYIGIcGE = t_ynMSdg;
        xr20shxY = 1;
        KrdatlYV = FmcKpFmN;
      }
    }
    mx =KrdatlYV;
  }
  if(mi==mx){
    mx++;
  }
  for(i=0;i<N;i++){
    if(i==mi || i==mx){
      continue;
    }
    if(A[i] >= 0){
      A[mi] = doit(A[mi], A[i]);
    }
    else{
      A[mx] = doit(A[mx], A[i]);
    }
  }
  res = doit(A[mx], A[mi]);
  wt_L(res);
  wt_L('\n');
  for(i=0;i<ress;i++){
    wt_L(resx[i]);
    wt_L(' ');
    wt_L(resy[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190609-2 [beta]

// --- original code ---
// int N, A[1d5];
// 
// int res, ress, resx[1d5], resy[1d5];
// 
// inline int doit(int x, int y){
//   resx[ress] = x;
//   resy[ress++] = y;
//   return x - y;
// }
// 
// {
//   int i, j, k, mi, mx;
//   rd(N,A(N));
// 
//   mi = argmin[k=0---N-1](A[k]);
//   mx = argmax[k=0---N-1](A[k]);
//   if(mi==mx) mx++;
// 
//   rep(i,N){
//     if(i==mi || i==mx) continue;
//     if(A[i] >= 0) A[mi] = doit(A[mi], A[i]);
//     else          A[mx] = doit(A[mx], A[i]);
//   }
//   res = doit(A[mx], A[mi]);
// 
//   wt(res);
//   rep(i,ress) wt(resx[i], resy[i]);
// }


Measured memory_bytes: 3072
module Main where
import Control.Monad

myPrint :: [String] -> String -> String
myPrint s p = unwords [p, "x", show $ sum [1 | x<-s, x==p]]

main :: IO ()
main = do
    n <- readLn
    s <- replicateM n getLine
    putStrLn $ myPrint s "AC"
    putStrLn $ myPrint s "WA"
    putStrLn $ myPrint s "TLE"
    putStrLn $ myPrint s "RE"

Measured memory_bytes: 36388
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1];
            
            var ab = new List<List<int>>();
            for (var i = 0; i < M; i++) {
                ab.Add(Console.ReadLine().Split().Select(int.Parse).ToList());
            }
            
            ab = ab.OrderBy(z => z[1]).ToList();
            
            var ans = 0;
            var cur = 0;
            for (var i = 0; i < M; i++) {
                if (cur < ab[i][0]) {
                    cur = ab[i][1]-1;
                    ans++;
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 33204
n = int(input())
l = list(map(int,input().split()))
step = 0
for i in range(n-1):
    # print(l[i],l[i+1])
    if l[i] > l[i+1]:
        step += (l[i]-l[i+1])
        l[i+1] = l[i]
        
    # print(step)
print(step)

Measured memory_bytes: 94168
import java.util.Scanner;

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

	public static void main(String[] args) {
		int R = sc.nextInt();
		double X = sc.nextInt();
		double Y = sc.nextInt();
		int N = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < N; ++i) {
			int P = sc.nextInt();
			double x1 = R * Math.cos(Math.PI / 2 - sum / 100.0 * Math.PI * 2);
			double y1 = R * Math.sin(Math.PI / 2 - sum / 100.0 * Math.PI * 2);
			sum += P;
			double x2 = R * Math.cos(Math.PI / 2 - sum / 100.0 * Math.PI * 2);
			double y2 = R * Math.sin(Math.PI / 2 - sum / 100.0 * Math.PI * 2);
			double SO = Math.PI * R * R * P / 100.0;
			double DS1 = area(0, 0, x2, y2, X, Y);
			double DS2 = area(0, 0, X, Y, x1, y1);
			double SN = SO + DS1 + DS2;
			if (i != 0) System.out.print(" ");
			System.out.print((int) (100 * SN / SO));
		}
		System.out.println();
	}

	static double area(double x0, double y0, double x1, double y1, double x2, double y2) {
		double dx1 = x1 - x0;
		double dy1 = y1 - y0;
		double dx2 = x2 - x0;
		double dy2 = y2 - y0;
		return (-dy2 * dx1 + dy1 * dx2) / 2;
	}

}

Measured memory_bytes: 17372
#include <stdio.h>

int abs(int a, int b){
  if(a > b) return a - b;
  else return b - a;
}

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  int h[100000];
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  int dp[100000];
  int dps[101];
  dp[0] = 0;
  int i,j,m;
  int count;
  int min;
  for(i=1;i<n;i++){
    count = 0;
    for(j=1;j<=k;j++){
      if(i - j >= 0){
        dps[j] = dp[i-j] + abs(h[i],h[i-j]);
        //printf("dps[%d]=%d\n",j,dps[j]);
        count++; 
      }
    }
    min = dps[1];
    for(int a=1;a<=count;a++){
      if(dps[a] < min){
        min = dps[a];
      }
    }
    dp[i] = min;
    //printf("%d\n",min);
  }
  printf("%d\n",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c; cin >> a >> b >> c;
    if (a == b+c || b == a+c || c == a+b) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, m = Is()
X = LI()
X.sort()
D = []
for i in range(1, m):
    D.append(X[i]-X[i-1])
D.sort(reverse=True)
print(X[-1]-X[0]-sum(D[:n-1]))


Measured memory_bytes: 82212
#include <stdio.h>
int main(void){
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int a,b,c,a2,b2,c2;
		scanf("%d %d %d",&a,&b,&c);
		a2=a*a;
		b2=b*b;
		c2=c*c;
		if(a2==b2+c2||b2==a2+c2||c2==b2+a2)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 1924
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999
int main() {
	int a = 0, b = 0, c = 0, n = 0;
	int some = 0;
	std::vector<int> v;
	std::string str;
	for (int i = 0; i < 3; i++) {
		std::cin >> some;
		v.push_back(some);
	}
	std::cin >> n;
	std::sort(v.begin(),v.end());
	for (int i = 0; i < n; i++) {
		v[2] *= 2;
	}	
	std::cout << v[0]+v[1]+v[2] << std::endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
main = do
  [n,m]<-map (read::String->Int) . words <$> getLine
  rows <-  map (map (read::String->Int) .words) <$> (replicateM n getLine)
  putStr $ unlines $ map (unwords . map show) $ extendR $ extendC rows

extendC:: Num a => [[a]]->[[a]]
extendC = map (\r-> r ++ [sum r])


extendR:: Num a => [[a]]->[[a]]
extendR mat = mat ++ [(foldl1 (zipWith (+)) mat)]

Measured memory_bytes: 6488
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

mod = 10**9 +7
ans = 1
for i in range(1,n+1):
    ans *= i
    ans = ans % mod

print(ans)

Measured memory_bytes: 12488
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],4)[0];
  var K = myconv(input[0],4)[1];
  var list = myconv(input[1],4);
  myout(Math.ceil((N-1)/(K-1)));
}
Main(myin());

Measured memory_bytes: 16716
#include<bits/stdc++.h>
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 num = 0b0000'0000'0000;
  int stop = int(pow(2,n));

  int ans=1200008;
  int nowAns=0;
  vector<int> ar(m,0);
  int okCount=0;


  for(int bit=num;bit<stop;bit++){
    okCount=0;
    nowAns=0;
    for(int t=0;t<m;t++) ar[t]=0;
    for(int j=0;j<n;j++){
      if(bit & (1<<j)){
        nowAns+=c[j];
        for(int k=0;k<m;k++) ar[k]+=a[j][k];
      }
    }
    for(int f=0;f<m;f++) if(ar[f]>=x) okCount++;
    if(okCount==m) ans = min(ans,nowAns);
  }

  if(ans==1200008) cout << "-1" << endl;
  else cout << ans << endl;
}

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

int main()
{
    int a,b,x;
    cin >> a >> b >> x;
    if((a+b>=x)&&(a<=x)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S, T;

int main()
{
	in >> S >> T;
	std::vector<char>cngS(30, '\0'), cngT(30, '\0');
	rep(i, S.length())
	{
		if (cngS[S[i] - 'a'] == '\0') cngS[S[i] - 'a'] = T[i];
		if (cngT[T[i] - 'a'] == '\0') cngT[T[i] - 'a'] = S[i];
		if (cngS[S[i] - 'a'] != T[i])
		{
			out << "No" << std::endl;
			return 0;
		}
		if (cngT[T[i] - 'a'] != S[i])
		{
			out << "No" << std::endl;
			return 0;
		}
	}
	out << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;

int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
    int a,b;
    cin>>a>>b;
    if (a*b%2==0)
    {
        cout<<"Even\n";
    }
    else
    {
        cout<<"Odd\n";
    }
re 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 1,  1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1,  1, -1};

/*************** using variables ***************/
int h, w;
string s[55];
/**********************************************/

int main(){
    cin >> h >> w;
    REP(i, h){
        cin >> s[i];
    }

    REP(i, h){
        REP(j, w){
            if(s[i][j] == '.'){
                int num = 0;
                REP(k, 8){
                    int y = dy[k] + i;
                    int x = dx[k] + j;
                    if(y >= 0 && x >= 0 && y < h && x < w){
                        if(s[y][x] == '#') num++;
                    }
                }

                s[i][j] = (char)(num-1 + '1');
            }
        }
    }

    REP(i, h){
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// 素因数
set<int> getPrimeFactors(int a) {
    set<int> s;
    for (int i = 2; i * i <= a; i++) {
        if (a % i != 0) continue;
        s.insert(i);
        while (a % i == 0) a /= i;
    }
    if (a > 1) s.insert(a);
    return s;
}

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

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

template<typename T>
set<T> factolization(T x, vector<T>& spf) {
    set<T> ret;
    while (x != 1) {
        ret.insert(spf[x]);
        x /= spf[x];
    }
    return ret;
}

class ECoprime {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        vector<int> spf = smallest_prime_factors(1000005LL);

        set<int> s;
        bool ok = true;
        REP(i, N) {
            auto t = factolization(A[i], spf);
            for (auto n : t) {
                if (s.count(n)) {
                    ok = false;
                }
                s.insert(n);
            }
        }
        if (ok) {
            cout << "pairwise coprime" << endl;
            return;
        }

        int g = A[0];
        REP(i, N) {
            g = gcd(g, A[i]);
        }
        cout << (g == 1 ? "setwise coprime" : "not coprime") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ECoprime solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int n, k, r, s, p;
char y[100000], t[100000];

char w(char v) {
    switch (v) {
        case 'r':
            return 'p';
        case 'p':
            return 's';
        case 's':
            return 'r';
        default:
            return 'x';
    }
}

int main() {
    scanf("%d %d", &n, &k);
    scanf("%d %d %d", &r, &s, &p);
    scanf("%100000s", t);
    int res = 0;
    for (int i = 0; i < n; i++) {
        char z = w(t[i]);
        if (i >= k && y[i - k] == z) {
            z = 'x';
        } else {
            switch (z) {
                case 'r':
                    res += r;
                    break;
                case 'p':
                    res += p;
                    break;
                case 's':
                    res += s;
                    break;
            }
        }
        y[i] = z;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include <vector>

struct union_find {
    using size_type = std::size_t;
private :
    size_type _size;
    std::vector<int> node;
public :
    union_find (int n) : node(n, -1), _size(n) { }

    bool unite (int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (node[x] > node[y]) std::swap(x, y);
        node[x] += node[y];
        node[y] = x;
        _size--;
        return true;
    }

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

    int root (int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    size_type size (size_type x) {
        return (size_type(-node[root(x)]));
    }

    constexpr const size_type &size () const noexcept {
        return _size;
    }

};


#include <iostream>
#include <cstddef>

int main() {
	std::size_t n, q;
	std::cin >> n >> q;
	
	union_find uf(n);
	for (std::size_t i = 0; i < q; i++) {
		std::size_t type, u, v;
		std::cin >> type >> u >> v;
		if (type == 0) {
			uf.unite(u, v);
		} else {
			std::cout << uf.same(u, v) << '\n';
		}
	}
	
	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

const int N = 2e3 + 50;
const int mod = 998244353 ;

int main(){
    io();

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int odd = 0;
    while(1) {
        odd = odd ^ 1;
        if(odd & 1) {
            c -= b;
        }
        else {
            a -= d;
        }

        if(c <= 0) {
            cout << "Yes";
            return 0;
        }
        if(a <= 0) {
            cout << "No";
            return 0;
        }
    }

}



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

void solve(){
    int k, a, b;
    cin >> k >> a >> b;
    string achieve = "NG";
    for(int i=a; i<=b; ++i){
        if(i % k == 0) achieve = "OK";
    }
    cout << achieve << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


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



void solve(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

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

Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.max

data class Query(val a: Int, val b: Int, val c: Int, val d: Int)

fun main() {
    val pw = PrintWriter(System.out)

    val (n, m, q) = readInputLine().split(" ").map { it.toInt() }

    val query = Array(q) { Query(0, 0, 0, 0) }

    repeat(q) {
        val input = readInputLine().split(" ").map { it.toInt() }
        query[it] = Query(input[0] - 1, input[1] - 1, input[2], input[3])
    }

    val arr = IntArray(n) { 1 }

    fun dfs(index: Int, min: Int): Int {
        if (index == n) {
            var ret = 0
            for (qe in query) {
                if (arr[qe.b] - arr[qe.a] == qe.c) {
                    ret += qe.d
                }
            }
            return ret
        }

        var ret = 0

        for (i in min..m) {
            arr[index] = i
            ret = max(ret, dfs(index + 1, i))
        }

        return ret
    }

    pw.println(dfs(1, 1))

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}

// これが全探索で計算量的に問題ないと見抜けないの、数学的素養がなさすぎてつらい
// 競プロ向いていない つらい


Measured memory_bytes: 38808
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [a,b] = lines[0].split(" ").map(v=>v-0);
    if(a*b<=0) console.log("Zero");
    else if(b<0){
        console.log((b-a+1)%2===0?"Positive":"Negative");
    }else{
        console.log("Positive");
    }
    
});


Measured memory_bytes: 30068
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    rand::Rng,
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

const K: usize = 41;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n]
    }
    let mut nums = vec![0; K];
    for &a in a.iter() {
        for i in 0..K {
            if (a >> i) & 1 == 1 {
                nums[i] += 1;
            }
        }
    }
    let mut dp = vec![vec![0; 2]; K + 1];
    for i in (0..K).rev() {
        if k >> i & 1 == 0 {
            if dp[i + 1][0] != 0 {
                if k >> i == 0 {
                    dp[i][0] = dp[i + 1][0] + nums[i] * (1 << i);
                } else {
                    dp[i][0] = dp[i + 1][0] + max(nums[i], n - nums[i]) * (1 << i);
                }
            }
            dp[i][1] = dp[i + 1][1] + nums[i] * (1 << i);
        } else {
            if dp[i + 1][0] == 0 {
                dp[i][0] = dp[i + 1][0] + nums[i] * (1 << i);
            } else {
                dp[i][0] = dp[i + 1][0] + max(nums[i], n - nums[i]) * (1 << i);
            }
            dp[i][0] = max(dp[i][0], dp[i + 1][1] + nums[i] * (1 << i));
            dp[i][1] = dp[i + 1][1] + (n - nums[i]) * (1 << i);
        }
    }
    let ans = max(dp[0][0], dp[0][1]);
    println!("{}", ans);
}


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

int main()
{
    string s;
    int i = 0, num[20] = {0};
    cin >> s;
    for(i = 0; i < s.size(); i++)
    {
        if(s[i] == 'B')
        {
            num[i] = 1;
            int a = 1;
            while(a <= i)
            {
                if(num[i - a] == 0)
                {
                num[i - a] = 1;
                    break;

                }
                a++;
            }
        }
    }
    for(i = 0; i < s.size(); i++)
    {
        if(num[i] == 0)
        {
            cout << s[i];
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const int mxN = 2e5 + 6;
vector<int> G[mxN];
int dist[mxN][3];
const int INF = 1e9;


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

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
	}

	int s, t;
	cin >> s >> t;
	s--, t--;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			dist[i][j] = INF;
		}
	}
	dist[s][0] = 0;

	queue<P> Q;
	Q.push(P(s, 0));

	while (!Q.empty()) {
		P p = Q.front();
		Q.pop();
		int nv = p.first;
		int mod = p.second;
		int nextm = (mod + 1) % 3;
		for (auto e : G[nv]) {
			if (dist[e][nextm] == INF) {
				dist[e][nextm] = dist[nv][mod] + 1;
				Q.push(P(e, nextm));
			}
		}
	}

	int ans;
	if (dist[t][0] != INF) {
		ans = dist[t][0] / 3;
	}
	else {
		ans = -1;
	}
	cout << ans << endl;

}

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(A>0 && C>0){
    	C -= B;
    	A -= D;
    }
    if(C<=0){
    	cout<<"Yes";
    }
    else{cout<<"No";}
}

Measured memory_bytes: 3636
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()
    l = len(S)
    S2 = S * 2

    ans = 'No'
    for i in range(l):
        if S2[i:i+l] == T:
            ans = 'Yes'
            break

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9964
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }



main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    int y = (a + k - 1) / k;
    y *= k;
    if (y <= b) {
        cout << "OK\n";
    }
    else {
        cout << "NG\n";
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b;
    std::cin>>a>>b;

    std::cout<<(a <= b ? a : a - 1)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
let af a b c = if c >= 'a' && c <= 'z' then char_of_int (((a * (int_of_char c - 97) + b) mod 26) + 97) else c

let rec seq s t = if s > t then [] else s :: seq (s + 1) t

let rec make_fs ps = function
  | [] -> []
  | f :: rest -> List.map (fun x -> f x) ps @ make_fs ps rest

let elem s1 s2 =
  let l1 = String.length s1
  and l2 = String.length s2 in
  let rec iter s t =
    if s > t then false 
    else if String.sub s2 s l1 = s1 then true 
    else iter (s+1) t in
  iter 0 (l2 - l1)

let rec decrypt s = function
  | [] -> s
  | f :: fs -> 
     let decs = String.map f s in
     if elem "this" decs || elem "that" decs then decs else decrypt s fs

let _ = 
  let fs = make_fs (seq 0 25) (List.map (fun x -> af x) [1;3;5;7;9;11;15;17;19;21;23;25]) in
  let n = read_int () in
  for i = 1 to n do
    let str = read_line () in
    print_endline (decrypt str fs)
  done

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<ll> ans(4);
    ans[0]=a*c;
    ans[1]=a*d;
    ans[2]=b*c;
    ans[3]=b*d;
    sort(all(ans));
    cout << ans[3] << endl;
}

Measured memory_bytes: 3636
# gets.chomp.to_i
# gets.chomp.split(" ").map(&:to_i)
# gets.chomp.split(" ").map{|x| x.to_i}

while true
  n, t, l_, b_ = gets.chomp.split(" ").map{|x| x.to_i}
  if n==0
    break
  end
  p = Array.new(n+1) { Array.new(t+2, Rational(0, 1)) }

  l = Array.new(n, 0)
  for i in 1..l_
    tmp = gets.chomp.to_i
    l[tmp] = 1
  #  p[tmp] = Array.new(t+1) { Array.new(2, Rational(0, 1)) }
  end

  b = Array.new(n, 0)
  for i in 1..b_
    tmp = gets.chomp.to_i
    b[tmp] = 1
  end


  p[0][0] = Rational(1, 1)
  for time in 0..t-1
    for square in 0..n-1
      for dice in 1..6
        if square+dice > n
          dice = 2*n - (square+dice) - square
        end
        if l[square+dice] == 1
          p[square+dice][time+2] += p[square][time] / 6
          next
        end
        if b[square+dice] == 1
          p[0][time+1] += p[square][time] / 6
          next
        end
     #   if square+dice > n
     #     p[2*n - (square+dice)][time+1] += p[square][time] / 6
     #     next
     #   end
        p[square+dice][time+1] += p[square][time] / 6
      end
    end
  end

  pr = Rational(0, 1)
  for time in 1..t
    pr += p[n][time]
  end
  printf("%f\n", Float(pr))

end

Measured memory_bytes: 9852
import sys
from collections import deque
from copy import copy
from bisect import bisect_right, bisect_left


N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
A = deque(A)
BC=[]
for m in range(M):
    b,c = list(map(int, input().split()))
    BC.append([b,c])

BC.sort(key=lambda bc: bc[1], reverse=True)

_sum = 0

for b,c in BC:
    i = bisect_left(A, c)
    if i == 0:
        break
    nrof_replace = min(i,b)
    _sum += c * nrof_replace
    #A = A[nrof_replace:]
    for i in range(nrof_replace):
        A.popleft()
    
print(_sum + sum(A))


Measured memory_bytes: 87788