akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int l[1000000 + 10], r[1000000 + 10];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	rep(i, 0, n ){
		cin >> l[i] >> r[i];
	}
	sort(l, l + n);
	sort(r, r+ n);
	if(n % 2 == 1){
		cout << r[n / 2] - l[n / 2] + 1<< endl;
	}
	else{
		int x1 = l[n / 2] + l[n / 2 - 1];
		int y1 = r[n / 2] + r[n / 2 - 1];
		//cout << ans << endl;
		cout << y1 - x1 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int n, m, total = 0;
    scan2Int(n, m);
    int as[n];
    rep(i, n) {
        cin >> as[i];
        total += as[i];
    }
    double border = (double) total / (4 * m);
    rep(i, n) {
        if (as[i] >= border)
            m -= 1;
        if (m <= 0) break;
    }
    if (m <= 0)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
    for(k=j+1;k<=n;k++){
      if(i+j+k==x) o++;
    }
      }
    }
  
    cout << o << endl;
  
    cin >> n >> x;
  }
  
  
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int sz=2005;
long long c[sz][sz];
int n,k;
int r,b;
long long m=1e9+7;
long long add(long long a,long long b){return (a%m+b%m)%m;}
long long mul(long long a,long long b){return (a%m*b%m)%m;}


int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d",&n,&k);
    b=k;
    r=n-k;
    int av=r+1;
    for(int i=0;i<sz;i++) c[i][0]=c[i][i]=1;
    for(int i=1;i<sz;i++){
        for(int j=1;j<=i;j++) c[i][j]=add(c[i-1][j],c[i-1][j-1]);
    }
    for(int i=1;i<=b;i++) printf("%I64d\n",mul(c[av][i],c[b-1][i-1]));
    return 0;
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"
 
const double PI = acos(-1.0);
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //#define int ll
  
  double a, b, h, m;
  cin >> a >> b >> h >> m;
 
  double angle = (60*h - 11*m)/2;
 
  angle *= PI;
  angle /= 180;
 
  cout << fixed << setprecision(12);
  double ans = a*a + b*b - 2*a*b*cos(angle);
  cout << sqrt(ans) << endl;
 
  return 0;
  
}

Measured memory_bytes: 4192
N = int(input())
K = int(input())

def c(n,k):
	if k == 0:
		return 1
	elif k == 1:
		return n
	elif k == 2:
		return n*(n-1)//2
	else:
		return n*(n-1)*(n-2)//6
def f(N, K):
	if N == 0 and K > 0:
		return 0

	if K == 0:
		return 1
	digit = len(str(N))
	ret = 0
	if digit > K:
		ret += c(digit-1, K) * (9 ** K)
	a = 10**(digit-1)
	d = N // a
	ret += (d-1) * c(digit-1, K-1) * (9 ** (K-1))
	ret += f(N - d*a, K-1)

	return ret

print(f(N,K))


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

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

string str1, str2;
int dp[1001][1001];

void solve()
{
  REP(i, str1.size())
    if(str1[i] == str2[str2.size() - 1])
      dp[i][str2.size() - 1] = 1;
    else
      dp[i][str2.size() - 1] = 0;
  for(int i = str2.size() - 2; i >= 0; i--)
    if(str1[str1.size() - 1] == str2[i])
      dp[str1.size() - 1][i] = 1;
    else
      dp[str1.size() - 1][i] = dp[str1.size() - 1][i + 1];
  for(int i = str1.size() - 2; i >= 0; i--){
    for(int j = str2.size() - 2; j >= 0; j--){
      if(str1[i] == str2[j])
	dp[i][j] = dp[i + 1][j + 1] + 1;
      else
	dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
    }
  }
}
  
int main()
{
  int q, m;
  cin >> q;
  cin.ignore();
  REP(i, q){
    getline(cin, str1);
    getline(cin, str2);
    fill(&dp[0][0], &dp[1001][0], -1);
    solve();
    m = dp[0][0];
    swap(str1, str2);
    fill(&dp[0][0], &dp[1001][0], -1);
    solve();
    cout << ((m > dp[0][0]) ? m : dp[0][0]) << endl;
  }
}

Measured memory_bytes: 5124
// 2012/02/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int p1, p2, p3, j1, j2;
	cin >> p1;
	cin >> p2;
	cin >> p3;
	cin >> j1;
	cin >> j2;

	int p = p1;
	if(p>p2){
		p = p2;
	}
	if(p>p3){
		p = p3;
	}

	int j = j1;
	if(j>j2){
		j = j2;
	}

	cout << p+j-50 << '\n';

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0;bool f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
ll a,b,c;
int main()
{
    a=read(),b=read(),c=read();
    if(a+b>=c) puts("No");
    else
    {
        ll d=(c-a-b)*(c-a-b);
        puts(4*a*b<d?"Yes":"No");
    }
    return 0;
}

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

int main() {
  int N;
  string s,t;
  cin>>N>>s>>t;
  int ans=N*2;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(s[i]==t[j]){
        int id=i,jd=j;
        bool flg=true;
        int minus=0;
        while(id<N){
          if(s[id]==t[jd]){
            flg=true;
            id++,jd++;
            minus++;
          }
          else{
            flg=false;
            break;
          }
        }
        if(flg) ans=min(ans,N*2-minus);
      }
    }
  }

cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;


struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k) {
  while (u != NIL && k != u->key) {
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));  // pointerに対してのメモリの動的な割り当て。zポインタからNodeのポインタへ渡してるっぽい.二重割り当てか?
  // 確保したメモリをNode型ポインタへキャスト。構造体のsizeofは構造体メンバのバイト数
  z->key = k;  // zオブジェクトのポインタに対して参照
  // zはNode型へのポインタ型変数。あるノードへのアドレスが入る
  // 上でzが指すNode用のメモリが確保
  // ここではzつまり確保したノードのアドレスのkeyがさすアドレスに変数を代入
  z->left = NIL;
  z->right = NIL;
  // zに親の情報を入れ込む処理：yが親に相当
  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  // yに子の情報を入れる処理
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
   cin >> com;
   if (com[0] == 'f') {
       scanf("%d", &x);
       Node *t = find(root, x);
       if (t != NIL) printf("yes\n");
       else printf("no\n");
   } else if (com == "insert") {
       scanf("%d", &x);
       insert(x);
   } else if (com == "print") {
       inorder(root);
       printf("\n");
       preorder(root);
       printf("\n");
   }
  }
  return 0;
}  



Measured memory_bytes: 22028
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
struct Pt {
double x, y;
Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double abs() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
	bool operator<(const Pt &a) const { return (x != a.x) ? (x < a.x) : (y < a.y); }
	bool operator==(const Pt &a) const { return (sig(x - a.x) == 0 && sig(y - a.y) == 0); }
};
ostream &operator<<(ostream &os, const Pt &a) { os << "(" << a.x << ", " << a.y << ")"; return os; }
double tri(Pt a, Pt b, Pt c) { return (b - a).det(c - a); }


pair<Pt,Pt> pCC(Pt a, double r, Pt b, double s) {
	double d = (b - a).abs();
	double x = (d * d + r * r - s * s) / (d * 2);
	Pt e = (b - a) / d, w = e * Pt(0, 1) * sqrt(max(r * r - x * x, 0.0));
	return mp(a + e * x - w, a + e * x + w);
}

int main() {
	int n;
	vector<Pt> vp;
	while(n=in()){
		vp.clear();
		int i;
		Pt p;
		for(i=0;i<n;i++){
			scanf("%lf,%lf",&p.x,&p.y);
			vp.push_back(p);
		}
		int j;
		pair<Pt,Pt> pp;
		Pt pt;
		int max=1;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if((vp[i]-vp[j]).abs()>2)continue;
				pp=pCC(vp[i],1,vp[j],1);
				pt=pp.first;
				if(-EPS<=pt.x&&pt.x<=10+EPS&&-EPS<=pt.y&&pt.y<=10+EPS){
					int k,s=0;
					for(k=0;k<n;k++){
						if((pt-vp[k]).abs()<=1+EPS){
							s++;
						}
					}
//cout<<"i "<<i<<endl;
//cout<<"j "<<j<<endl;
//cout<<pt<<endl;
//cout<<s<<endl;
					chmax(max,s);
				}
				pt=pp.second;
				if(-EPS<=pt.x&&pt.x<=10+EPS&&-EPS<=pt.y&&pt.y<=10+EPS){
					int k,s=0;
					for(k=0;k<n;k++){
						if((pt-vp[k]).abs()<=1+EPS){
							s++;
						}
					}
//cout<<"i "<<i<<endl;
//cout<<"j "<<j<<endl;
//cout<<pt<<endl;
//cout<<s<<endl;
					chmax(max,s);
				}
			}
		}
		cout<<max<<endl;
	}
	return 0;
}

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

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

int getCount(string x_s, char x_op) {
    int cnt = 0;

    REP(i, x_s.length()) {
        if (x_s[i] == x_op) {
            ++cnt;
        }
    }

    return cnt;
}

int main(void) {
    string s;
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << getCount(s, '+') - getCount(s, '-') << "\n";
    return 0;
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[100002] = {};
    bool pt[100002] = {};
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    int f = 0;
    if (a[1] > 0)
        f = 1;
    else
        f = -1;

    for (int i = 1; i <= n; i++)
    {
        if (f == 0)
        {
            if (a[i + 1] > a[i])
                f = 1;
            else if (a[i + 1] < a[i])
                f = -1;
        }
        else if (f > 0)
        {
            if (a[i + 1] < a[i])
            {
                f = -1;
                pt[i] = true;
            }
            else if (a[i + 1] == a[i])
                f = 0;
        }
        else
        {
            if (a[i + 1] > a[i])
            {
                f = 1;
                pt[i] = true;
            }
            else if (a[i + 1] == a[i])
                f = 0;
        }
    }

    int sum = 0;
    for (int i = 0; i <= n; i++)
    {
        // cout << "," << abs(a[i + 1] - a[i]) << endl;
        sum += (abs(a[i + 1] - a[i]));
    }

    // cout << sum << endl;
    for (int i = 1; i <= n; i++)
    {
        if (pt[i] == true)
        {
            cout << sum - abs(abs(a[i - 1] - a[i + 1]) - (abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1]))) << endl;
        }
        else
        {
            cout << sum << endl;
        }
    }
}


Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(1000000)

n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])

Measured memory_bytes: 138832
n = int(input())
H = list(map(int, input().split()))
 
H[0] -= 1
for i in range(1, n):
    if H[i-1] < H[i]:
        H[i] -= 1
print('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
signed main() 
{
	fastio();
	
	int n;
	cin>>n;
	string s[n];
	int t[n];
	for(int i = 0;i<n;i++)
		cin>>s[i]>>t[i];
	string x;
	cin>>x;
	int ans = 0, flag = 0;
	loop(i,0,n)
	{
		if(flag)
			ans+=t[i];
		if(s[i]==x)
			flag = 1;

	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ll a,v,b,w,t,d;
    cin>>a>>v>>b>>w>>t;
    if(a>b)
        d=a-b;
    else
        d=b-a;
    if(w>=v)
        cout<<"NO";
    else if(t*(v-w)<d)
        cout<<"NO";
    else
        cout<<"YES";
	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
 	 int64_t A,B,K;
    cin>>A>>B>>K;
    for(int i=0;i<K;i++){
      if(i%2==0){
        if(A%2!=0){A-=1;}
        A/=2;B+=A;
      }
      if(i%2!=0){
        if(B%2!=0){B-=1;}
        B/=2;A+=B;
      }
    }
    cout<<A<<" "<<B<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc002b()
}

private data class Move(val from: Int, val to: Int)
private data class Box(var balls: Int, var redProb: Boolean)

fun agc002b() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val moves = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Move(it[0] - 1, it[1] - 1) }

    val boxes = listOf(Box(1, true)) + (2..n).map { Box(1, false) }
    for (move in moves) {
        boxes[move.from].balls--
        boxes[move.to].balls++

        if (boxes[move.from].redProb) boxes[move.to].redProb = true
        if (boxes[move.from].balls <= 0) boxes[move.from].redProb = false
    }

    val answer = boxes.count { it.redProb && it.balls > 0 }

    println(answer)
}


Measured memory_bytes: 63568
using System;

namespace B___String_Rotation
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var t = Console.ReadLine ();
            for (var i = 0; i < s.Length ; i++)
            {
                if (s == t)
                {
                    Console.WriteLine ("Yes");
                    return;
                }
                s = s[s.Length - 1] + s.Substring (0, s.Length - 1);   
            }
            Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}
 
const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];
 
void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}
 
void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}
 
int main() {
    solve();
    return 0;
}


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

int main(){
  int n, k;
  int a[200005];
  cin >> n >> k;
  for(int i=0; i<n; ++i){
    cin >> a[i];
  }
  for(int i=k; i<n; ++i){
    if(a[i-k] < a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4416
#include <stdio.h>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

std::vector<int> A;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n){ int a; scanf("%d", &a); A[a-1] = i; }
    int idx = 0, res = 0;
    while(idx < n){
        int cnt = 1;
        while(idx + cnt < n and A[idx + cnt - 1] < A[idx + cnt]) cnt++;
        if(res < cnt) res = cnt;
        idx += cnt;
    }
    printf("%d\n", n - res);
    return 0;
}

Measured memory_bytes: 1024
-- Vicfred
-- https://atcoder.jp/contests/abc179/tasks/abc179_b
-- simulation
n = io.read("*n")

b = {}
d = {}
for i = 1, n do b[i], d[i] = io.read("*n", "*n") end

flag = false

for i = 1, n-2 do
   if b[i] == d[i] and
       b[i + 1] == d[i + 1] and
       b[i + 2] == d[i + 2] then
       flag = true
   end
end

if flag then
    print("Yes")
else
    print("No")
end



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

int main() {
    vector<vector<int>> c(3, vector<int>(3));

    for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
            cin >> c.at(k).at(l);
        }
    }
    int w = 0;
    int a1 = min (min (c.at(0).at(0), c.at(0).at(1)), c.at(0).at(2));
    int b1 = c.at(0).at(0) - a1;
    int b2 = c.at(0).at(1) - a1;
    int b3 = c.at(0).at(2) - a1;
    if (c.at(1).at(0) - b1 != c.at(1).at(1) - b2 || c.at(1).at(0) - b1 != c.at(1).at(2) - b3 ) {
        w++;
    }
    if (c.at(2).at(0) - b1 != c.at(2).at(1) - b2 || c.at(2).at(0) - b1 != c.at(2).at(2) - b3 ) {
        w++;
    }

    if (w != 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string s;
    cin >> s;

    int y = (s[0]-48)*1000 + (s[1]-48)*100 + (s[2]-48)*10 + s[3]-48;
    int m = (s[5]-48)*10 + (s[6]-48);
    int d = (s[8]-48)*10 + (s[9]-48);

    if (y<=2019 && m <=4 && d<=31)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;

    return 0;
}


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

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

void solve(int x , int y, int cnt, int m[100][100] ){
	ans = max( ans , cnt );
	for(int i=0 ; i < 4 ; i++ ){
		int mx = x + dx[i];
		int my = y + dy[i];
		if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
		if( m[my][mx] == 1 ){
			m[my][mx] = 0;
			solve( mx , my , cnt+1 , m );
			m[my][mx] = 1;
		}
	}
}

int main(){
	while( cin >> w >> h , w||h ){
		int m[100][100] = {0};
		ans = 0;
		
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> m[y][x];
			}
		}
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				solve( x , y , 0 , m );
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 908
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926
#define sec setprecision　
const long long mod = 998244353;
const int  MAX = 510000;

using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll p = sqrt(b);
	ll k = b % p, h = b / p, s = 1;
	rip(i,p)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
ll fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return (fac[n] * (finv[k] * finv[n - k] % mod) % mod);
}
ll fanc(ll h) {
	if (h == 1)return(1);
	else return (2 * (fanc((h / 2))) + 1);
}
int main() {
	ll h;
	cin >> h;
	cout << fanc(h) << endl;
}

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

int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x - k + 1; i < x + k; i++){
        if(i == x + k - 1) cout << i;
        else cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{
	int i, j, r, c;
	int a[101][101];

	for (i = 0;i < 101; i++) {
		for (j = 0; j < 101; j++)
			a[i][j] = 0;
	}

	scanf("%d %d", &r, &c);
	for (i = 0;i <= r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &a[i][j]);
			printf("%d ",a[i][j]);
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
		printf("%d\n", a[i][c]);
	}
	return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(all(a));
  	ll k = n, l = 0;
	if(a[n-1] >= 0){
    	k = lower_bound(all(a),0) - a.begin(); // k<0
    	l = n-k; // l>=0
    }
  
    if(k == 0){ k++; l--; }
    else if(l == 0){ k--; l++; }

    vector<vector<ll>> ans(n,vector<ll>(2,0));
  
    ans[0][0] = a[0]; // min
  
    rep(i,l-1){
        ans[i][1] = a[n-2-i];
        ans[i+1][0] = ans[i][0] - ans[i][1];
    }
  	
    	ans[l-1][0] = a[n-1]; // max
    	if(l > 1) ans[l-1][1] = ans[l-2][0] - ans[l-2][1];
  		else ans[l-1][1] = a[0];
    	ans[l][0] = ans[l-1][0] - ans[l-1][1];
  
    rep(i,k-1){
        ans[l+i][1] = a[1+i];
        ans[l+i+1][0] = ans[l+i][0] - ans[l+i][1];
    }

    cout << ans[n-1][0] << endl;
    rep(i,n-1) cout << ans[i][0] << " " << ans[i][1] << endl;
  return 0;
}

Measured memory_bytes: 9584
import sys
n = int(input())
A = list(map(int, input().split()))
money = 1000
stock = 0

B = []

def buy(m, s, a):
    t = m//a
    return m-t*a, s+t

def sell(m, s, a):
    return m+s*a, 0

for i in range(n-1):
    if A[i+1] > A[i]:
        B.append(1)
    elif A[i+1] == A[i]:
        B.append(0)
    else:
        B.append(-1)

B.append(1)

flag = True

MAX = 1000

for i in range(n-1):
    if flag and B[i] == 1:
        money, stock = buy(money, stock, A[i])
        flag = False
        MAX = max(money, MAX)
        # print('buy', i, stock, money)
    elif not flag and B[i] == -1:
        money, stock = sell(money, stock, A[i])
        flag = True
        MAX = max(money, MAX)
        # print('sell', i, stock, money)

money, stock = sell(money, stock, A[n-1])
MAX = max(money, MAX)
# print('sell', i, stock, money)

print(MAX)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
main(){
    //OJ;
    int n,k;
    cin>>n>>k;
    vi v(n);
    for(int &x:v)
        cin>>x;
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=v[i];
    cout<<sum;
}

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int n;
  const int max_n = 100;
  int x[max_n + 1];
  const int INF = 1e9;

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

  int sum = 0;
  int ans = INF;
  for(int i = 1; i <= 100; i++){
    sum = 0;
    for(int j = 0; j < n; j++){
      sum += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, sum);
  }

  cout << ans << endl;


  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> AC(pow(10, 5)+1);
  vector<int> penalty(pow(10, 5)+1);

  int ACnum = 0;
  int WAnum = 0;

  for(int i=0;i<m;i++) {
    int a;
    string s;
    cin >> a >> s;
    if(AC[a]) continue;
    if(s == "AC") {
      AC[a] = true;
      ACnum++;
      WAnum += penalty[a];
    }
    if(s == "WA") penalty[a]++;
  }

  cout << ACnum << " " << WAnum << endl;
}

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

using namespace std;

int main() {
	string s;
	string t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) if (s[i] == t[i]) ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    long d = sc.nextLong();
    
    int cnt = 0;
    for(int i = 0; i<n; i++){
      long x = sc.nextLong();
      long y = sc.nextLong();
      
      if((x*x + y*y) <= d*d){
        cnt++;
      }
    }
    
    System.out.println(cnt);
  }
}


Measured memory_bytes: 48960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

//		long[] li = new long[n];
//		for (int i=0; i < n; i++) {
//			li[i] = sc.nextLong();
//		}

		int count = 0;
		for (int i=0; i < n; i++) {
			int x = sc.nextInt();
			if ( isPrime(x) ) count++;
		}

		System.out.println(count);

	}

	static boolean isPrime(int n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else {
			if (n % 2 == 0) return false;
			else {

				int i = 2;
				while (i*i <= n) {
					if (n % i == 0) return false;
					i++;
				}
				return true;

			}
		}
	}

}

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

int main()
{
	int S;
	cin >> S;
	
	int h, m, s;
	s = S % 60;
	S /= 60;
	m = S % 60;
	S /= 60;
	h = S;
	
	cout << h << ":" << m << ":" << s << endl;

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
		if (x1 == 0) {
			cout << "1";
		}
		else if (x2 == 0) {
			cout << "2";
		}
		else if (x3 == 0) {
			cout << "3";
		}
		else if (x4 == 0) {
			cout << "4";
		}
		else {
			cout << "5";
		}
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int a,b,c;

int main(){
	cin>>a>>b>>c;
	int d = max(a,max(b,c));
	if(a == d) puts("A");
	if(b == d) puts("B");
	if(c == d) puts("C");
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
int f[1000000];

void solve() {
   int n;
   string s;
   cin>>n;
   cin>>s;
   int ans=0,c=0;
   fo(i,n)
   {
       if(s[i]=='R') c++;
   }
   fo(i,c)
   {
        if(s[i]!='R') ans++;
   }
   cout<<ans<<endl;
}




int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
   /* int t;
    cin>>t;
    while(t--)
    {
      solve();
    } */
    solve();
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}


void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


Measured memory_bytes: 10732
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
const int INF2=1e9+5;
int main()
{
    int n,k;
   cin>>n>>k;
    vector<int> h(n),dp(n,INF2);
    rep(i,0,n)cin>>h[i];
   dp[0]=0;
    rep(i,0,n)
    {
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll M1,M2,D1,D2;
    scanf("%lld %lld", &M1, &D1);
    scanf("%lld %lld", &M2, &D2);
    if ( D2 - D1 == 1 ) printf("0\n");
    else printf("1\n");
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
h=list(map(int,input().split()))
k=[0]*n
for i in range(n):
  k[i]=b-(a-(0.006*h[i]))
  if k[i]<0:
    k[i]=-1*k[i]
print(k.index(min(k))+1)

Measured memory_bytes: 9044
//#include<atcoder/all>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
//using namespace atcoder;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,ans=0;
	cin >> n;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			if(i*j<n){
				ans++;
			}else{
				break;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    long n, k, r, s, p;
    cin >> n >> k;
    cin >> r >> s >> p;
    vector<char> t(1000000);
    for(int i=n; i<1000000; i++){
        t.at(i) = 'a';
    }
    for(int i=0; i<n; i++){
        cin >> t.at(i);
    }
    long score=0;
    long count;
    for(int i=0; i<n; i++){
        if(t.at(i) == 'r' && t.at(i+k) != 'r'){
            score += p;
        }
        else if(t.at(i) == 's' && t.at(i+k) != 's'){
            score += r;
        }
        else if(t.at(i) == 'p' && t.at(i+k) != 'p'){
            score += s;
        }
        else if(t.at(i) == t.at(i+k)){
            t.at(i+k) = 'a';
            if(t.at(i) == 'r'){
                score += p;
            }
            else if(t.at(i) == 's'){
                score += r;
            }
            else if(t.at(i) == 'p'){
                score += s;
            }
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279
 
 
void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}
 
int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main(void){	
	long long int w, h;
	long long int x, y;
	scanf("%lld %lld %lld %lld",&w,&h,&x,&y);
	
	if( w%2==0 && h%2==0 && x!=0 && y!=0 && w==2*x && h==2*y){
        printf("%llf 1", (long double)w*(long double)h/2.0 );
    }
	else	printf("%llf 0", (long double)w * (long double)h / 2.0);
	
			
	return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
lia = [input() for i in range(n)]
lib = [input() for i in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(m):
      if lia[i+k][j:j+m] != lib[k]:
        break
    else:
      print("Yes")
      exit()
print("No")

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

int co[4];

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) {
    int in = 0;
    ll a;
    cin >> a;
    if (a % 2 == 0) in = 1;
    if (a % 4 == 0) in = 2;
    co[in]++;
  }
  if (co[1] == 0) {
    co[2]++;
  }
  if (co[0] > co[2]) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";

  return 0;
}


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

int main()
{
  int a, b, k;
  cin >> a >> b >> k;

  int cnt = 0;

  for (int i = min(a,b); i>=1 ; i--)
  {
    if (a % i == 0 && b % i == 0)
    {
      cnt++;
      if (cnt == k)
      {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(D)]
T = [int(input()) for i in range(D)]

last = [0] * 26
score = 0
for i,(s,a) in enumerate(zip(S,T)):
    score += s[a-1]
    last[a-1] = i+1
    for j,c in enumerate(C):
        score -= c * (i+1 - last[j])
    print(score)

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  // ifstream in("in.txt");
  // cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, k;cin >> n >> k;
  vector<int> hoge(n);
  int ind;
  int tmp;
  rep_i(i, n){
    cin >> tmp;
    if(tmp == 1){
      ind = i;
    }
    hoge[i] = tmp;
  }
  if(n == k){
    cout << 1 << endl;
    return 0;
  }

  int r = ind;
  int l = n - 1 - ind;
  int sum = 0;
  int m = 100000000;
  for (int i = 0; i <= k - 1; i++){
    sum += 1;
    if((r - ((k - 1) - i))%(k - 1) != 0){
      sum += (r - ((k - 1) - i))/(k - 1) + 1;
    }else{
      sum += (r - ((k - 1) - i))/(k - 1);
    }
    if((l - i)%(k - 1) != 0){
      sum += (l - i)/(k - 1) + 1;
    }else{
      sum += (l - i)/(k - 1);
    }
    if(sum <= m){
      m = sum;
    }
    sum = 0;
  }
  cout << m << endl;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{h:i64, n:usize, a:[i64;n]};
    println!("{}", if a.iter().sum::<i64>() >= h {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    bool x =true;
    vector<int> A(N);

    for (int i = 0; i < N; i++) {
       		cin >> A.at(i);
    }

    for (int i = 0; i < N; i++) {
  
    	if (A.at(i) %2 ==0) {
            if(A.at(i) %3 !=0 && A.at(i) %5 != 0){
    		    x = false;
        	    break;
            }
        }
    }
 
    if (x == true) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
   	}
 
}

Measured memory_bytes: 256
import collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
import scala.language.implicitConversions

trait Graph { 
    case class Edge[T:Numeric](from : Int, to : Int, cost : T)

    class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {
        def size = data.size
    }
    object Edges {
        def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))
        implicit def toUnderLying[T](x:Edges[T]) = x.data
    }

    class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(Edges()))
    }
    object WeightedGraph {
        // def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)
        implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data
    }

    class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))
    }
    object UnWeightedGraph {
        // def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)
        implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data
    }
   
    class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {
        def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))
        def this(size : Int) = this(size, size)
    }
    object Matrix {
        implicit def toUnderLying[T](x:Matrix[T]) = x.data
    }
}

object BellmanFord extends Graph {
    import Edges._

    // return ArrayBuffer() when find a negative cycle
    def bellmanFord[T:ClassTag](edges : Edges[T], V : Int, s : Int, INF : T)(implicit num : Numeric[T]) : Array[T] = {
        val dist = Array.fill[T](V)(INF)
        dist(s) = num.zero
        for (i <- 1 to V) {
            for (Edge(from, to, cost)  <- edges) {
                if(dist(from) != INF 
                    && num.lt(num.plus(dist(from), cost), dist(to))) {
                        dist(to) = num.plus(dist(from), cost)
                        if (i == V && to == V-1) return Array.empty
                    }
            }
        }
        dist
    }
}

import BellmanFord._

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val N, M = sc.nextInt
        val edges = Edges[Long]()
        for (_ <- 1 to M) {
            val s, t = sc.nextInt
            val c = sc.nextLong
            edges += Edge(s-1, t-1, -c)
        }
        // println(edges.toList)
        val res = bellmanFord[Long](edges, N, 0, Long.MaxValue)
        // println(res.toList)
        if (res.isEmpty) println("inf")
        else {
            println(-res(N-1))
        }
    }
}

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

#define endl '\n'
#define sz(x) ((int)(x.size()))

int n, m, k;
long long a[3000][3000];
long long dp[3000][3000][4];

long long memo(int x, int y, int r) {
	if(x < 0 || y < 0) return 0;
	if(dp[x][y][r] != -1) return dp[x][y][r];
	long long res = memo(x-1, y, 3);
	res = max(res, memo(x, y-1, r));
	if(r > 0) res = max(res, a[x][y] + max(memo(x, y-1, r-1), memo(x-1, y, 3)));
	return dp[x][y][r] = res;
}

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

	cin >> n >> m >> k;
	for(int i=0; i<k; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		a[x-1][y-1] = c;
	}
	memset(dp, -1, sizeof dp);
	cout << memo(n-1, m-1, 3) << endl;

	return 0;
}

Measured memory_bytes: 355648