akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
    int N, K;
    cin >> N >> K;
    cout << N-K+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int K, X;
    cin >> K >> X;
    if ((500 * K) >= X)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    // system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,A,B,res=0;
string S,T,U;

int main()
{
    cout << fixed << setprecision(18);
    cin>>S>>T>>A>>B>>U;

    if(S==U){
        cout<<A-1<<" "<<B<<endl;
    }else{
        cout<<A<<" "<<B-1<<endl;
    }
}    


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

typedef long long ll;

int main() {
  vector<ll> d(3);
  cin >> d[0] >> d[1] >> d[2];
  sort(d.begin(), d.end());
  ll ans = d[0]*d[1];
  bool flag = false;
  for (int i = 0; i < 3; i++) {
    if (d[i] % 2 == 0) {
      ans = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (s,t) = readStringList()
    println("$t$s")
}


// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 35952
#include <cstdio>
using namespace std;
const int maxn=101;

int n,h,w,a[maxn*maxn];
int c[maxn][maxn];
int x,y;

int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	x=1;y=1;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		for(int j=1;j<=a[i];j++)
		{
			c[x][y]=i;
			if ((x%2 && y==w)) x++;
			else if (!(x%2) && y==1) x++;
			else if (x%2) y++;
			else y--; 
		}
	}
	
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			printf("%d%c",c[i][j],j==w?'\n':' ');
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define LL long long
#define MX (2000 + 233)
#define chkmx(a ,b) (a = __max(a ,b))

LL __max(LL a ,LL b){return a > b ? a : b;}
LL __abs(LL a){return a > 0 ? a : -a;}
LL dp[MX][MX];

struct P{
	LL id ,A;
	bool operator <(const P &B)const{
		return A > B.A;
	}
}P[MX];

int main(){
	int n; scanf("%d" ,&n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%lld" ,&P[i].A);
		P[i].id = i;
	}std::sort(P + 1 ,P + 1 + n);
	LL Ans = 0;
	for(int i = 0 ; i <= n ; ++i){
		for(int j = 0 ; i + j < n ; ++j){
			int x = i + j + 1;
			chkmx(dp[i + 1][j] ,dp[i][j] + __abs(P[x].id - (i + 1)) * P[x].A);
			chkmx(dp[i][j + 1] ,dp[i][j] + __abs(P[x].id - (n - j)) * P[x].A);
		}
	}
	for(int i = 0 ; i <= n ; ++i)
		chkmx(Ans ,dp[i][n - i]);
	printf("%lld\n" ,Ans);
	return 0;
}

Measured memory_bytes: 25092
length = int(input())
num_li = list(map(int, input().split()))
count = 0
loop = True
while loop == True:
    for i in range(length):
        if num_li[i]%2 == 1:
            loop = False
            break
        else:
            num_li[i] /= 2
    if loop == True:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, t, ans = 0, i = 0;
    scanf("%d%d%d", &n, &m, &t);
    int pre = -m;
    for (; i < n; i++) {
        int a = 0;
        scanf("%d", &a);
        ans += max(a - pre - m * 2, 0);
        pre = a;
    }
    ans += max(t - pre - m, 0);
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
const int maxn=2e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n;
ll quick(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0)
    {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll jiecheng[maxn];
void ini_zuhelogn()
{
    jiecheng[0]=1;
    for(int i=1;i<maxn;i++)
    {
        jiecheng[i]=jiecheng[i-1]*i%mod;
    }
}
ll zuhe_logn(int m,int n)
{
    if(jiecheng[0]!=1)
        ini_zuhelogn();
    ll ans=((jiecheng[m]*quick(jiecheng[n], mod-2, mod))%mod)*quick(jiecheng[m-n], mod-2, mod)%mod;
    return ans;
}
ll ans[maxn],ans_up[maxn],sizet[maxn];
vector<int> G[maxn];
void dfs1(int x,int f)
{
    ll anst=1,sum=0;
    for(int i=0;i<G[x].size();i++)
    {
        int v=G[x][i];
        if(v!=f)
        {
            dfs1(v, x);
//            cout<<v<<" "<<ans[v]<<" "<<sum<<" "<<sizet[v]<<endl;
            anst=anst*(ans[v]*zuhe_logn(sum+sizet[v], sizet[v])%mod)%mod;
            sum+=sizet[v];
        }
    }
    ans[x]=anst;
    sizet[x]=sum+1;
}
void dfs2(int x,int f)
{
    
    ll anst=ans_up[x],sum=n-sizet[x];
    for(int i=0;i<G[x].size();i++)
    {
        int v=G[x][i];
        if(v==f)
            continue;
        anst=anst*(ans[v]*zuhe_logn(sum+sizet[v], sizet[v])%mod)%mod;
        sum+=sizet[v];
    }
    ans[x]=anst;
    for(int i=0;i<G[x].size();i++)
    {
        int v=G[x][i];
        if(v==f)
            continue;
        
        ans_up[v]=ans[x]*quick((ans[v]*zuhe_logn(n-1, sizet[v])%mod),mod-2,mod)%mod;
//        cout<<v<<" "<<ans[x]<<" "<<ans[v]<<" "<<ans_up[v]<<endl;
        dfs2(v, x);
    }
}
int main()
{
    
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(1, 1);
    ans_up[1]=1;
    
    dfs2(1, 1);
    for(int i=0;i<n;i++)
        cout<<ans[i+1]<<endl;
    
}


Measured memory_bytes: 20212
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

class dice {
public:
	dice(int m1, int m2, int m3, int m4, int m5, int m6);
	~dice();
	void roll(string c);
	int getmT();
private:
	int mE, mW, mS, mN;
	int mT, mB;

};

dice::dice(int m1, int m2, int m3, int m4, int m5, int m6) : mT(m1), mS(m2), mE(m3), mW(m4), mN(m5), mB(m6) {

}

dice::~dice() {

}

void dice::roll(string c) {
	for (int i = 0; i < c.length(); i++) {
		switch (c[i]) {
		case 'E':
			int tE;
			tE = mE;
			mE = mT;
			mT = mW;
			mW = mB;
			mB = tE;
			break;
		case 'W':
			int tW;
			tW = mW;
			mW = mT;
			mT = mE;
			mE = mB;
			mB = tW;
			break;
		case 'N':
			int tN;
			tN = mN;
			mN = mT;
			mT = mS;
			mS = mB;
			mB = tN;
			break;
		case 'S':
			int tS;
			tS = mS;
			mS = mT;
			mT = mN;
			mN = mB;
			mB = tS;
			break;
		}
	}
}

int dice::getmT() {
	return mT;
}

int main() {
	int me[6];
	for (int i = 0; i < 6; i++) {
		cin >> me[i];
	}
	dice* mDice;
	mDice = new dice(me[0], me[1], me[2], me[3], me[4], me[5]);
	string meirei;
	cin >> meirei;
	mDice->roll(meirei);
	cout << mDice->getmT() << endl;
	delete mDice;
	mDice = 0;
	return 0;
}


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

const int  maxn=200008;
int n; 
char s[maxn];
int main(){
  scanf("%s",s);
  int l=strlen(s);
  int ans=0;
  for (int i=1;i<=l-1;i++)
    if (s[i] != s[i-1]) ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m; cin >> n >> m;
    VI a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    vector<pair<int,int>> ebi(n);
    rep(i,n) ebi[i] = make_pair(a[i],b[i]);
    SORT(ebi);
    int ans = 0;
    rep(i,n){
        int k = min(m,ebi[i].second);
        ans += k*ebi[i].first;
        m -= k;
    }
    ANS;

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=200001;
	int N,T;
	int t[MAX]={};
	cin>>N>>T;
	ll sum=0;
	for(int i=0;i<N;i++){
		cin>>t[i];
	}
	for(int i=1;i<N;i++){
		if(t[i]-t[i-1]>T){
			sum+=T;
		}
		else{
			sum+=t[i]-t[i-1];
		}
	}
	sum+=T;
	cout<<sum<<endl;
	return 0;
}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Measured memory_bytes: 1024
function Main(input) {
    var result;
    const N = parseInt(input.shift())
    const Vs = input.slice(0, N).map(x => parseInt(x));
    const Cs = input.slice(N).map(x => parseInt(x));

    var result = 0;
    for (var index = 0; index < Vs.length; index++) {
        var value = Vs[index] - Cs[index];
        if (value > 0) {
            result += value;
        }
    }
    console.log(result);
}

// 1行入力の場合
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

// 改行で分割
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7496
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>

const int di[4]={-1, 0, 1, 0};
const int dj[4]={0, -1, 0, 1};

int main() {
  int H, W;
  scanf("%d %d", &H, &W);

  std::vector<std::string> s(H);
  int black=0;
  for (int i=0; i<H; ++i) {
    char buf[64];
    scanf("%s", buf);
    s[i] = buf;
    black += std::count(s[i].begin(), s[i].end(), '#');
  }

  int INF=1e8;
  std::vector<std::vector<int>> dp(H, std::vector<int>(W, INF));
  dp[0][0] = 1;
  std::queue<std::pair<int, int>> q;
  q.emplace(0, 0);
  while (!q.empty()) {
    int i=q.front().first, j=q.front().second;
    q.pop();
    for (int k=0; k<4; ++k) {
      int I=i+di[k], J=j+dj[k];
      if (!(0 <= I && I < H && 0 <= J && J < W)) continue;
      if (s[I][J] != '.') continue;
      if (dp[I][J] < dp[i][j] + 1) continue;

      dp[I][J] = dp[i][j] + 1;
      if (I == H-1 && J == W-1) {
        while (!q.empty()) q.pop();
        break;
      } else {
        q.emplace(I, J);
        s[I][J] = '%';
      }
    }
  }

  if (dp[H-1][W-1] == INF)
    return !printf("-1\n");

  printf("%d\n", H*W-black-dp[H-1][W-1]);
}


Measured memory_bytes: 256
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define lowbit(x) ((x)&-(x))
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=15,p=1e9+7;
bool map[N+10][N+10];
int f[N+10][(1<<N)+10],g[N+10][(1<<N)+10];
int dp[(1<<N)+10],ID[(1<<N)+10];
int mlt(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p)	if (b&1)	res=1ll*res*a%p;
	return res;
}
int main(){
	int n=read(),m=read();
	for (int i=1;i<=n;i++)	ID[1<<(i-1)]=i;
	for (int i=1;i<=m;i++){
		int x=read(),y=read();
		map[x][y]=1;
	}
	for (int i=1;i<=n;i++)
		for (int sta=1;sta<1<<n;sta++)
			f[i][sta]=f[i][sta^lowbit(sta)]+map[i][ID[lowbit(sta)]];
	for (int i=1;i<=n;i++){
		for (int sta=1;sta<1<<n;sta++){
			int k=ID[lowbit(sta)];
			if (!map[i][k])	g[i][sta]=g[i][sta^lowbit(sta)];
			else	g[i][sta]=(2ll*g[i][sta^lowbit(sta)]%p+1)%p;
		}
	}
	for (int sta=1;sta<1<<n;sta++){
		dp[sta]=1;
		for (int sub=(sta-1)&sta;sub;sub=(sub-1)&sta){
			if ((sub&1)&&((sta^sub)&2))	continue;
			if ((sub&2)&&((sta^sub)&1))	continue;
			int res=1,tmp=0;
			for (int i=1;i<=n;i++)	if (sub&(1<<(i-1)))	res=1ll*res*g[i][sta^sub]%p;
			for (int i=1;i<=n;i++)	if ((sta^sub)&(1<<(i-1)))	tmp+=f[i][sub];
			res=1ll*res*mlt(2,tmp)%p;
			dp[sta]=(dp[sta]+1ll*res*dp[sub])%p;
		}
	}
	printf("%d\n",(mlt(2,m)-dp[(1<<n)-1]+p)%p);
	return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>

int main(void){
  int a,b,c;
  int mod;
  int use[11];
  int card;
  int i;

  while(scanf("%d %d %d ",&a,&b,&c)!=EOF){
    for(i=1;i<11;i++){
      if(i == a || i == b || i == c)use[i] = 1;
      use[i] = 0;
    }
    mod = 20 - (a+b);
    card = 0;
    for(i=1;i<=mod;i++){
      if(!use[i])card++;
    }

    if(card<4)printf("NO\n");
    else printf("YES\n");
  }

  return 0;
}

Measured memory_bytes: 0
import numpy as np
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print(0)
else:
    x.sort()
    x=np.array(x)
    L=np.diff(x,1)
    L=np.sort(L)[::-1]
    ans=x[-1]-x[0]-sum(L[:n-1])
    print(ans)

Measured memory_bytes: 22980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

const ll C = 1000000007;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx;
    int y = ty-sy;
    for(int i=0; i<y; i++) cout << "U";
    for(int i=0; i<x; i++) cout << "R";
    for(int i=0; i<y; i++) cout << "D";
    for(int i=0; i<x; i++) cout << "L";

    cout << "L";
    for(int i=0; i<y; i++) cout << "U";
    cout << "U";
    for(int i=0; i<x; i++) cout << "R";
    cout << "R";
    cout << "D";

    cout << "R";
    for(int i=0; i<y; i++) cout << "D";
    cout << "D";
    for(int i=0; i<x; i++) cout << "L";
    cout << "L";
    cout << "U";
}

Measured memory_bytes: 3592
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 a, b, h;
    std::cin >> a >> b >> h;
    std::cout << (a + b) * h / 2 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}
int main() {
    char str[10] = { 0 };
    char s[10] = "Sunny", c[10] = "Cloudy", r[10] = "Rainy";
    scanf("%s", str);
    if (strcmp(str, s) == 0)printf("Cloudy");
    else if (strcmp(str, c) == 0)printf("Rainy");
    else printf("Sunny");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}




int dp[101][100001];
void solve()
{
  
  int n,w;
  cin >> n >> w;

  int an = -1;

  forf(i,1,n+1)
  {
    int cw,cv;
    cin >> cw >> cv;
    
    forf(j,1,w+1)
    {
     dp[i][j] = dp[i-1][j]; 
     if(j>=cw) dp[i][j] = max(dp[i][j] , dp[i-1][j-cw]+cv);
    }

  }


  forf(i,1,w+1)
  {
    an = max(an , dp[n][i]);
  }

  cout<<an<<"\n";
 
}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 81720
import java.util.Scanner;

public class Main {

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

        sc.close();

        if (a <= c && b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main(){

    int h,w;
    int a,b;
    cin >> h >> w >> a >> b;

    cout << h*w-(a*w+b*h)+a*b <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=1;i<=n;i++)
#define fs first
#define sc second
#define MAXN 100005
#define LIMIT 1500
#define LOGN 1048575
#define ll long long
#define pb push_back
#define ld long double
#define eps 1e-6
#define endl '\n'
#define lc 2*pos
#define rc 2*pos+1
using namespace std;
int n,m;
int arr[MAXN];
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>n>>m;
	rep(i,m){
		int l,r;
		cin>>l>>r;
		arr[l]++;arr[r+1]--;
	}
	int cnt=0,diff=0;
	rep(i,n){
		diff+=arr[i];
		arr[i]=diff;
		if(diff==m)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    long st = 1, sa = 1;
    for (int i = 0; i < n; i++) {
        long t, a;
        cin >> t >> a;
        long x = (st - 1) / t + 1;
        if (sa > x * a) {
            x = (sa - 1) / a + 1;
        }
        sa = x * a;
        st = x * t;
    }
    cout << (st + sa) << endl;
    return 0;
}


Measured memory_bytes: 256
#D
n = int(input())
s = list(input())
r = g = b = 0
for i in s:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    elif i == "B":
        b += 1
# print(r, g, b)
ans = r * g * b
for i in range(n - 2):
    si = s[i]
    for j in range(i + 1, i + 1 +((n - 1 - i) // 2)):
        if si != s[j]:
            sj = s[j]
            k = 2 * j - i
            if si != s[k] and sj != s[k]:
                ans -= 1
print(ans)

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

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

int main(){
    int n,h[25];
    cin>>n;
    rep(i,n) cin>>h[i];
    int count=0;
    rep(i,n){
        int a=1;
        rep(j,i+1){
            if(h[i]<h[j]) a=0;
        }
        if(a) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k = m()
a = l()

po = n - sum(a)

if po >= 0:
    print(po)
else:
    print(-1)



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

int main() {
  int K,N;
  cin >> K >>N;
  vector <int> vec(N);
  for (int i=0; i<N;i++){
    cin >> vec.at(i);
  }
  //最初がスタートのときだけ分ける
  vector <int> kyori(N);
  kyori.at(0) = K-vec.at(N-1)+vec.at(0);
  for (int i=1;i<N;i++){
    int keisan =0;
    kyori.at(i) =vec.at(i)-vec.at(i-1);
  }
  int A = 0;
  for (int i=1;i<N;i++){
    if (kyori.at(i) >kyori.at(A)){
      A = i;
    }
  }
  cout << K-kyori.at(A)<<endl;
      
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

int main()
{
    ll a, b;
    cin >> a>>b;
    cout << lcm(a, b) <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int arr[100];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    long long ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < i; j++)
            ans += arr[i] * arr[j];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 MAX_H = 100;
const int MAX_W = 100;
int H, W;
char a[MAX_H][MAX_W];
bool is_comp_h[MAX_H];
bool is_comp_w[MAX_W];

void _main() {
  cin >> H >> W;
  rep(i, 0, H) rep(j, 0, W) cin >> a[i][j];

  rep(i, 0, H) {
    bool f = true;
    rep(j, 0, W) if (a[i][j] == '#') f = false;
    is_comp_w[i] = f;
  }

  rep(j, 0, W) {
    bool f = true;
    rep(i, 0, H) if (a[i][j] == '#') f = false;
    is_comp_h[j] = f;
  }

  rep(i, 0, H) {
    if (is_comp_w[i]) continue;
    rep(j, 0, W) if (!is_comp_h[j]) cout << a[i][j];
    cout << "\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        long res = 0;

        int mode = 0;
        int a = 0;
        for(char c : sc.next().toCharArray()) {
            switch(mode) {
                case 0:
                    if(c == 'A') {
                        a++;
                    } else if(c == 'B') {
                        mode = 1;
                    } else if(c == 'C') {
                        a = 0;
                    }
                    break;
                case 1:
                    if(c == 'A') {
                        a = 1;
                        mode = 0;
                    } else if(c == 'B') {
                        a = 0;
                        mode = 0;
                    } else if(c == 'C') {
                        res += a;
                        mode = 0;
                    }
                    break;
            }
        }
        System.out.println(res);

    }


}


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

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    int a[100][100] = {};
    int b[100][100] = {};
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++){
        for (int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i ++){
        for (int j = 0; j < l; j++){
            long c = 0;
            for (int k = 0; k < m; k++){
                c += a[i][k] * b[k][j];
            }
            cout << c;
            if (j != l-1) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) != t.at(i)) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
#define mp make_pair

ll a[3];


int main(){

cin >> a[0] >> a[1] >> a[2];

sort(a, a+3);

if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0)cout << 0;


else cout << 1LL*a[1]*a[0] << endl;



return 0;}


Measured memory_bytes: 256
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = []
    for _ in range(N):
        a.append(input().rstrip())
    M = int(input())
    b = []
    for _ in range(M):
        b.append(input().rstrip())
    s = set(a)
    res = 0
    for i in s:
        res = max(res, a.count(i)-b.count(i))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.*;

class Main{
  
  	public static long gcd(long a,long b){
    	if(b==0)
          return a;
      	else
          return gcd(b,a%b);
    }
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      long a=sc.nextLong();
      long b=sc.nextLong();
      long c=sc.nextLong();
      long d=sc.nextLong();
      
      long e=c*d/gcd(c,d);
      long sa=(b/c)-((a-1)/c);
      long sb=(b/d)-((a-1)/d);
      long sab=(b/e)-((a-1)/e);
      long diff=b-a+1-sa-sb+sab;
      System.out.print(diff);
      
    }
}

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

int main(){
  int a,i,j,hantei=0;
  cin>>a;
  if(a==2){
    cout<<2;
    return 0;
  }
  if(a%2==0){
    a++;
  }
  for(;;a+=2){
    hantei=0;
    for(j=3;j<=sqrt(a);j+=2){
      if(a%j==0){
        hantei=1;
      }
    }
    if(hantei==0){
      break;
    }
  }
  cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const double PI = acos(-1);
int main() {
    double A, B, H, M; cin >> A >> B >> H >> M;
    double T = H * 60 + M;
    double a = 2 * PI * T / (60 * 12);
    double b = 2 * PI * T / 60;
    complex<double> h = polar(A, a);
    complex<double> m = polar(B, b);
    cout << abs(h - m) << endl;
    return 0;
}


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

int main() {
	
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	y += z;
	cout << x/y << endl;
	
	return 0;
}


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

/*inline void fastRead_int(int &x)
{
	register int c = getchar_unlocked();
	x=0;
	int neg = 0;
	for(;((c<48 || c>57) && c!='-'); c=getchar_unlocked());
	
	if(c=='-'){
		neg = 1;
		c = getchar_unlocked();
	}
	for(; c>47 && c<58;c=getchar_unlocked())
		x = (x<<1)+(x<<3)+c-48;
	if(neg)	x = -x;
	
}
*/
int min_cost(int a[], int n, int k)
{
	int cost[n];
	cost[n-1] = 0;
	cost[n-2] =abs(a[n-2]-a[n-1]);
	for(int i=n-3;i>=0;i--){
		cost[i] = (abs(a[i]-a[i+1]))+cost[i+1];
		for(int j = i+2;j<n && j<=i+k;j++)
			cost[i] = min(abs(a[i]-a[j])+cost[j],cost[i]);
	}
	return cost[0];
}

int main()
{
	int n,k; cin>>n>>k;
	//fastRead_int(n);	fastRead_int(k);
	int a[n];for(int i=0;i<n;i++)	cin>>a[i];//fastRead_int(a[i]);
	cout<<min_cost(a,n,k)<<endl;
	return 0;
}

Measured memory_bytes: 1024
/* winners never quit and quitters never win.
      #swap                                 */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define inf 100000000000000000
#define rk 256
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)
/*ll ncr[5001][5001];
void coeff()
{
    for(ll a=0;a<5001;a++)
    {
        for(ll b=0;b<5001;b++)
        {
            ncr[a][b]=0;
        }
        ncr[a][0]=1;
    }
    for(ll a=1;a<5001;a++)
    {
        for(ll b=1;b<=a;b++)
        {
            ncr[a][b]=(ncr[a-1][b]+ncr[a-1][b-1])%mod;
        }
    }
}*/
ll fast_exp(ll base, ll exp1) {
    ll res=1;
    while(exp1>0) {
       if(exp1&1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp1/=2;
    }
    return res%mod;
} 
ll pr[1000001]={0};
void isprime()
{
    pr[0]=1;
    pr[1]=1;
    for(ll a=2;a<1000001;a++)
    {
        if(!pr[a])
        {
            for(ll b=a*2;b<1000001;b+=a)
            {
                pr[b]=1;
            }
        }
    }
}
ll comp=1,tim=0;
struct vertex
{
    vc<ll> adj;
    ll vis=0;
    ll parent=-1;
    ll dist=0;
    ll component=0;
    ll in=0;
    ll out=0;
    ll low=0;
    ll child=0;
    ll indeg=0;
    ll outdeg=0;
    bool AP=false;
};
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n;
    cin>>n;
    ll dp[n][3];
    for(ll a=0;a<n;a++)
    {
        cin>>dp[a][0]>>dp[a][1]>>dp[a][2];
        if(a)
        {
            dp[a][0]+=max(dp[a-1][1],dp[a-1][2]);
            dp[a][1]+=max(dp[a-1][0],dp[a-1][2]);
            dp[a][2]+=max(dp[a-1][0],dp[a-1][1]);
        }
        //cout<<dp[a][0]<<" "<<dp[a][1]<<" "<<dp[a][2]<<endl;
    }
    cout<<*max_element(dp[n-1],dp[n-1]+3)<<endl;
	return 0;
}

Measured memory_bytes: 2560
#input
#S = input()
#N = int(input())
Anum, Bnum, Mnum = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
M = []
for _ in range(Mnum):
    M.append(list(map(int, input().split())))
    
# process
ans = min(A)+min(B)
for x, y, c in M:
    cost = A[x-1]+B[y-1]-c
    if cost < ans:
        ans = cost

# output
print(ans)


Measured memory_bytes: 38444
#include<stdio.h>
#include<algorithm>
int main()
{
	int N,M,T[100],L[100],i,j,s,e;
	while(scanf("%d",&N),N)
	{
		for(i=0;i<N;++i)
		{
			scanf("%d%d",&M,L+i);
			for(T[i]=0;M--;)
				for(scanf("%d%d",&s,&e);s-e;++s)
					T[i]|=1<<(s-6);
		}
		int dp[1<<16]={};
		for(i=0;i<(1<<16);++i)
		{
			for(j=0;j<N;++j)
			{
				if(i&T[j])continue;
				int&r=dp[i|T[j]];
				r=std::max(r,dp[i]+L[j]);
			}
		}
		printf("%d\n",*std::max_element(dp,dp+(1<<16)));
	}
	return 0;
}

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

#define x first
#define y second
#define sz(x) ((int)x.size())
using ll = long long;

int n;
int d[501][501];
int Dx[] = {-1, 1, 0, 0};
int Dy[] = {0, 0, -1, 1};
int occupee[501][501];

bool in(int x, int y) {
	return (x >= 0 && y >= 0 && x < n && y < n);
}

pair<int, int> toCoord(int id) {
	id--;
	return {id / n, id % n};
}

int toId(int x, int y) {
	return 1 + n * x + y;
}

void bfs(int sx, int sy) {
	queue<pair<int, int>> q;
	q.push({sx, sy});
	while(!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();
		int x = p.x, y = p.y;
		for(int dir = 0; dir < 4; dir++) {
			int dx = Dx[dir], dy = Dy[dir];
			if(in(x + dx, y + dy) && d[x + dx][y + dy] > d[x][y] + occupee[x][y]) {
				d[x + dx][y + dy] = d[x][y] + occupee[x][y];
				q.push({x + dx, y + dy});
			}
		}
	}
}

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

	cin >> n;
	for(int x = 0; x < n; x++) for(int y = 0; y < n; y++) {
		occupee[x][y] = 1;
		d[x][y] = min(min(x, n - 1 - x), min(y, n - 1 - y));
	}

	int ans = 0;

	for(int i = 0; i < n * n; i++) {
		int id;
		cin >> id;
		pair<int, int> pos = toCoord(id);
		ans += d[pos.x][pos.y];
		occupee[pos.x][pos.y] = 0;
		bfs(pos.x, pos.y);
	}

	cout << ans << endl;
	
	return 0;
}





































Measured memory_bytes: 5576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    int m = 30000;

    int p[] = { 1,7,11,13,17,19,23,29 };
    int q[30] = {};
    for (int i = 0; i < 8; i++) {
        q[p[i]]++;
    }

    if (n == 3) {
        cout << "2 5 63" << endl;
    } else if (n == 4) {
        cout << "2 5 20 63" << endl;
    } else {
        int64_t s = 0;
        int l = n - 2;
        for (int i = 2; i <= m; i++) {
            int b = 0;
            for (int j = 0; j < 8; j++) {
                if (i % 30 == p[j]) b = 1;
            }
            if (b) continue;

            s += i;
            l--;
            cout << i << ' ';
            if (l == 0) break;
        }
        for (int i = 0; i < 30; i++) {
            for (int j = 0; j < 30; j++) {
                if (q[i] + q[j]) continue;
                if ((s - i - j) % 30 == 0) {
                    cout << m - i << ' ' << m - 30 - j << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

int minCostFrom(int curr, const vector<int>& h, int K, vector<int>& memo) {
    int N = h.size();
    if (curr == N - 1) {
        return 0;
    }
    if (memo[curr] >= 0) {
        return memo[curr];
    }

    int minTemp = 1e9;
    for (int k = 1; k <= K; ++k) {
        if (curr + k >= N) {
            break;
        }
        int temp = minCostFrom(curr + k, h, K, memo) + abs(h[curr] - h[curr + k]);
        minTemp = min(temp, minTemp);
    }
    memo[curr] = minTemp;
    return minTemp;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    vector<int> memo(N, -1);
    int ans = minCostFrom(0, h, K, memo);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8832
#include<stdio.h>
#include<string.h>
 
#define N 36
 
struct Card{
  char pattern;
  int value;
};
typedef struct Card card;
 
void BubbleSort(card *, int);
void SelectionSort(card *, int);
int IsStable(card *, card *, int);
void PrintState(card *, int);
 
void BubbleSort(card *C1, int n){
  int i,j;
  card tmp;
 
  for(i=0;i<N;i++){
    for(j=n-1;j>=1;j--){
      if(C1[j].value < C1[j-1].value){
        tmp=C1[j];
        C1[j]=C1[j-1];
        C1[j-1]=tmp;
      }
    }
  }
  return;
}
 
void SelectionSort(card *C2, int n){
  int i,j,minj;
  card tmp;
  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++) if(C2[j].value < C2[minj].value) minj=j;
    tmp=C2[i];
    C2[i]=C2[minj];
    C2[minj]=tmp;
  }
  return;
}
 
int IsStable(card *C1, card *C2, int n){
  int i;
  for(i=0;i<n;i++) if(C1[i].pattern != C2[i].pattern) return 0;
  return 1;
}
 
void PrintState(card *C, int n){
  int i;
  for(i=0;i<n;i++){
    printf("%c%d",C[i].pattern,C[i].value);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  return;
}
 
int main(void){
  int n,i,j;
  card C1[N], C2[N],data[N];
  char space;
 
  //input
  scanf("%d%c",&n,&space);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&data[i].pattern,&data[i].value,&space);
    C1[i]=data[i];
    C2[i]=data[i];
  }
 
  BubbleSort(C1,n);
  PrintState(C1,n);
  printf("Stable\n");
 
  SelectionSort(C2,n);
  PrintState(C2,n);
  if(IsStable(C1, C2, n)) printf("Stable\n");
  else printf("Not stable\n");
 
  return 0;
}

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

int main(){
    long long int n,d;
    cin>>n>>d;
    if(d==1){
        cout<<n*(n-1)/2<<endl;
    }else{
        cout<<(d-2)+(n-d)*(n-d+3)/2<<endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
typedef long long ll;

int main()
{
	ll H, W;
	ll h, w;

	scanf("%lld %lld", &H, &W);
	scanf("%lld %lld", &h, &w);

	printf("%lld\n", (H - h) * (W - w));

	return 0;
}


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

class Edge {
  public:
    long long to;
    long long cost;
    Edge() {}
    Edge(long long _to, long long _cost) {
      to = _to;
      cost = _cost;
    }
};

class Mov {
  public:
    long long id;
    long long cost;
    Mov(long long _id, long long _cost) {
      id = _id;
      cost = _cost;
    }
    Mov(const Mov& m) {
      id = m.id;
      cost = m.cost;
    }
};

class Node {
  public:
    long long cost;
    vector<Edge> edge;
    Node() {
      cost = LLONG_MAX / 2;
    }
};

bool has_larger_cost(const Mov& a, const Mov& b)
{
  return a.cost > b.cost;
}

int main()
{
  long long nnode, nedge;
  cin >> nnode >> nedge;
  vector<Node> node(nnode);
  for (long long x = 1; x < nnode; x++) {
    node.at(x).edge.emplace_back(x-1, 0);
  }
  for (long long i = 0; i < nedge; i++) {
    long long from, to, cost;
    cin >> from >> to >> cost;
    from--;
    to--;
    node.at(from).edge.emplace_back(to, cost);
  }
  priority_queue<Mov, vector<Mov>, decltype(&has_larger_cost)> pq(&has_larger_cost);
  pq.emplace(0LL, 0LL);
  while (!pq.empty()) {
    auto mov = pq.top();
    pq.pop();
    if (node.at(mov.id).cost <= mov.cost) {
      continue;
    }
    node.at(mov.id).cost = mov.cost;
    for (const auto& e : node.at(mov.id).edge) {
      pq.emplace(e.to, e.cost + mov.cost);
    }
  }
  if (node.back().cost == LLONG_MAX / 2) {
    cout << "-1\n";
  } else {
    cout << node.back().cost << '\n';
  }
  return 0;
}


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

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

bool check(int time, int nextx, int nexty){
  if(nextx+nexty<=time && (nextx+nexty)%2==time%2) return true;
  else return false;
}

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

  vector<tuple<int,int,int>> trip;
  trip.push_back(make_tuple(0,0,0));
  rep(i,n){
    int t,x,y;
    cin >> t >> x >> y;
    trip.push_back(make_tuple(t,x,y));
  }
  
  //rep(i,n+1) cout << get<0>(trip.at(i)) << " " << get<1>(trip.at(i)) << " " << get<2>(trip.at(i)) << endl;

  rep(i,n){
    int dt = get<0>(trip.at(i+1)) - get<0>(trip.at(i));
    int dx = abs(get<1>(trip.at(i)) - get<1>(trip.at(i+1)));
    int dy = abs(get<2>(trip.at(i)) - get<2>(trip.at(i+1)));
    if(!check(dt, dx, dy)){cout<<"No"; return 0;}
    //cout << dt << " " << dx << " " << dy << endl;
  }

  cout<<"Yes";
  
}

Measured memory_bytes: 4896
import numpy as np
import sys
line = sys.stdin.readlines()

N, M, Q = map(int, line[0].split())
city = np.zeros((N + 1, N + 1), dtype='int32')
L, R = np.array(list(map(str.split, line[1:M + 1])), np.int32).T
p, q = np.array(list(map(str.split, line[M + 1:])), np.int32).T

np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print('\n'.join(answer.astype(str)))

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

#include <iostream>


#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<ull,ull> PUll;
typedef pair<int,int> Pii;
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a*b)/__gcd(a,b)

auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};


int main()
{
	f();
	int n;cin>>n;
	vector<int> arr(n,0);
	int i=0;
	while(i<n)
	{
		cin>>arr[i];
		i++;
	}
	
	sort(arr.begin(),arr.end());
	cout<<arr[n/2]-arr[(n/2)-1]<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)

typedef int64_t ll;

const ll linf = 1LL << 31;
int q;
ll query[2][100];

int main()
{
	cin >> q;
	REP(i, q)
		cin >> query[0][i] >> query[1][i];

	REP(i, q)
	{
		ll a = query[0][i], b = query[1][i];

		if (a == b)
		{
			cout << 2 * a - 2 << endl;
			continue;
		}

		ll ok = 0, ng = linf;
		while (ng - ok > 1)
		{
			ll mid = (ng + ok) / 2;
			ll x = (mid + 1) / 2;
			ll y = 1 + mid - x;
			
			if (x * y < a * b)
				ok = mid;
			else
				ng = mid;
		}

		ll ans = ok - 1;

		cout << ans << endl;
	}
}


Measured memory_bytes: 256