akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    ll diff = 2 * D;
    vector<pll> XH(N);
    rep(i, N)
        cin >> XH[i].first >> XH[i].second;
    sort(XH.begin(), XH.end(), less<pll>());
    vl X(N);
    vl H(N);
    rep(i, N) {
        X[i] = XH[i].first;
        H[i] = XH[i].second;
        H[i] = (H[i] + A - 1) / A;
    }
    ll j = 0; // 爆撃範囲の右端の1つ次
    ll ans = 0;
    vector<pii> bomblist(N); // first : 爆撃範囲の右端の1つ次, second : 爆弾の量
    ll L = 0; // bomblistのうち爆撃範囲に含まれるものの最小値
    ll bombsum = 0;
    rep(i, N) {
        while (1) {
            if (j == N)
                break;
            if (X[j] - X[i] > diff)
                break;
            j++;
        }
        bomblist[i].first = j;

        while (1) {
            if (L == i) // この場合、直前(i-1)の爆撃範囲と完全分離
                break;
            if (bomblist[L].first > i)
                break;
            bombsum -= bomblist[L].second;
            L++;
        }
        ll bombneed = H[i] - bombsum;
        bombneed = max(bombneed, 0LL);
        ans += bombneed;
        //cout << i << " " << j << " " << L << " " << bombneed << " " << bombsum << endl;

        bomblist[i].second = bombneed;
        bombsum += bombneed;
    }
    cout << ans << endl;
    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

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

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3648
h, w = map(int, input().split())
S = [input() for _ in range(h)]
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
    for j in reversed(range(w)):
        if S[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
for j in range(w):
    for i in range(h):
        if S[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1
    for i in reversed(range(h)):
        if S[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print(ans)


Measured memory_bytes: 179844
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect
def main():
    n,k=map(int,input().split())
    X=list(map(int,input().split()))
    zero=bisect(X,0)
    ans=10**9
    for i in range(k+1):
        if zero-i<0 or zero+k-i-1>=n:
            continue
        if i==0:
            ans=min(ans,X[zero+k-i-1])
        elif i==k:
            ans=min(ans,-X[zero-i])
        else:
            kyori_m=2*-X[zero-i]+X[zero+k-i-1]
            kyori_p=-X[zero-i]+2*X[zero+k-i-1]
            ans=min(ans,kyori_m,kyori_p)  
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 14448
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

int go(int x)
{
    if(x<=1)
    return 0;
    return x*(x-1)/2;
}

 
signed main()
{
    haha
     int n;
     cin>>n;
     int arr[n];
     map<int,int> m;
     for(int i=0;i<n;i++)
     {
     cin>>arr[i];
     m[arr[i]]++;
}
int s=0;
for(auto x:m)
{
    s+=go(x.second);
}
//cout<<s<<endl;
for(int i=0;i<n;i++)
{
    cout<<s-m[arr[i]]+1<<endl;
}


    
   
 
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

class Main
{
	public static void main(String[] args) throws Exception
	{
		invoke(System.in);
//		invoke(new FileInputStream("/tmp/test.txt"));
	}

	public static void	invoke(InputStream is) throws IOException
	{
		// input
		BufferedReader	reader = new BufferedReader(new InputStreamReader(is));
		String	line = reader.readLine();

		String[]	va = line.split(" ");
		long	x = Long.parseLong(va[0]);
		long	x2 = x * 2;
		long	y = Long.parseLong(va[1]);


		long	sumMax = 0;
		for (long i = x; i < x2; ++i)
		{
			long	sum = 0;

			while (i <= y)
			{
				sum += 1;
				i *= 2;
			}

			if (sum > sumMax)
			{
				sumMax = sum;
			}
		}

		System.out.println(sumMax);
	}
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  cout << (n * (n + 1)) / 2LL << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = 2000*1000*150;

vector< vector<P> > field;
//dp[y][x][残りジャンプ回数]
vector <vector< vector<int> > > dp;
int n, m;

void solve(){
    rep(i, field[0].size()) dp[0][i][m] = 0;
    if(m > 0) rep(i, field[1].size()) dp[1][i][m - 1] = 0;

    for(int i = 1; i < n; i++){
        int now = i, b = i - 1, bb = i - 2;

        if(i > 1){
            rep(j, field[i].size()) rep(k, dp[i][j].size()) dp[i][j][k] = INF;
            //bbからbへ
            rep(j, field[bb].size()){
                int nx = field[bb][j].first, nj = field[bb][j].second;
                rep(k, field[b].size()){
                    int nnx = field[b][k].first, nnj = field[b][k].second;
                    int c = (nj + nnj) * abs(nx - nnx);
                    rep(o, m + 1) dp[b][k][o] = min(dp[b][k][o], dp[bb][j][o] + c);
                }
                //bbからnowへ
                rep(k, field[now].size()){
                    int nnx = field[now][k].first, nnj = field[now][k].second;
                    int c = (nj + nnj) * abs(nx - nnx);
                    rep(o, m) dp[now][k][o] = min(dp[now][k][o], dp[bb][j][o + 1] + c);
                }
            }

            //bからnowへ
            rep(j, field[b].size()){
                int nx = field[b][j].first, nj = field[b][j].second;
                rep(k, field[now].size()){
                    int nnx = field[now][k].first, nnj = field[now][k].second;
                    int c = (nj + nnj) * abs(nx - nnx);
                    rep(o, m + 1) dp[now][k][o] = min(dp[now][k][o], dp[b][j][o] + c);
                }
            }
        }
    }
}

int main(){
    while(cin >>n >>m){
        if(n == 0 && m == 0) break;
        field.clear(); dp.clear();
        field = vector< vector<P> >(n);
        rep(i, n){
            int tmp; cin >>tmp;
            //first = 石のx座標, second = すべりやすさ
            field[i] = vector<P>(tmp);
            rep(j, tmp){
                cin >>field[i][j].first >>field[i][j].second;
                field[i][j].first--;
            }
        }

        dp = vector< vector< vector<int> > >(n);
        rep(i, n){
            dp[i] = vector< vector<int> >(10);
            rep(j, 10) dp[i][j] = vector<int>(m + 1, INF);
        }

        solve();
        int ans = INT_MAX;
        rep(i, m + 1){
            rep(j, field[n - 1].size()) ans = min(ans, dp[n - 1][j][i]);
            if(i > 0) rep(k, field[n - 2].size()) ans = min(ans, dp[n - 2][k][i]);
        }
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1632
H, W = map(int, input().split())
S = [input() for i in range(H)]
l = [[0 for j in range(W)] for i in range(H)]
r = [[0 for j in range(W)] for i in range(H)]
u = [[0 for j in range(W)] for i in range(H)]
d = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        l[i][j] = 0 if S[i][j] == '#' else 1 + (0 if j == 0 else l[i][j-1])
    for j in range(W-1, -1, -1):
        r[i][j] = 0 if S[i][j] == '#' else 1 + (0 if j == W-1 else r[i][j+1])
for j in range(W):
    for i in range(H):
        u[i][j] = 0 if S[i][j] == '#' else 1 + (0 if i == 0 else u[i-1][j])
    for i in range(H-1, -1, -1):
        d[i][j] = 0 if S[i][j] == '#' else 1 + (0 if i == H-1 else d[i+1][j])
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
print(ans)


Measured memory_bytes: 184580
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn = 2e5 + 7;
int n, k, sum[maxn], val[maxn], ans;
map<int, int> mp;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n >> k;
    mp[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        sum[i] = (sum[i - 1] + x) % k;
        val[i] = ((sum[i] - i) % k + k) % k;
        if(i - k >= 0)
        {
            mp[val[i - k]]--;
        }
        ans += mp[val[i]];
        mp[val[i]]++;
    }
    cout << ans;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MAXN 100000
#define ll long long
using namespace std;

int A[MAXN+2];
int B[MAXN+2];

int main() {
    ll H,W,N;
    cin>>H>>W>>N;
    
    set<pair<int,int> > top_left_corners;
    set<pair<int,int> > all_xy;
    
    for(int i=1;i<=N;i++) {
        cin>>A[i]>>B[i];

        for(int x=A[i]-2;x<=A[i];x++)
            for(int y=B[i]-2;y<=B[i];y++) {
                if (x >= 1 && y >= 1 && x+2 <= H && y+2 <= W)
                    top_left_corners.insert(make_pair(x,y));
            }
        
        all_xy.insert(make_pair(A[i],B[i]));
    }
    
    ll answers[10];
    for(int i=0;i<10;i++)
        answers[i]=0;
    for (set<pair<int,int> >::iterator it = top_left_corners.begin();
         it != top_left_corners.end();
         ++it) {
        
        int x = it->first;
        int y = it->second;
        
        int count = 0;
        for(int dx=0;dx<3;dx++)
            for(int dy=0;dy<3;dy++)
            {
                int nx = x+dx;
                int ny = y+dy;
                if (all_xy.find(make_pair(nx,ny)) != all_xy.end()) {
                    count++;
                }
            }
        answers[count]++;
    }
    
    
    answers[0] = (H-2)*(W-2);
    
    for(int i=1;i<10;i++)
        answers[0]-=answers[i];
    
    
    for(int i=0;i<10;i++)
        cout << answers[i] << endl;

}

Measured memory_bytes: 47872
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int a = 0;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == '1')
      a++;
  }
  cout << a << endl;
  return 0;
}

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

static const int MAX_NUM = 25;
static const int NOELEM  = -1;

struct stNode {
    int parent;
    int left;
    int right;
};

int SerchHight(stNode elem[], int key)
{
    int ret = 0;
    int h1 = 0;
    int h2 = 0;

    if (key != NOELEM) {
        h1 += SerchHight(elem, elem[key].left)  + 1;
        h2 += SerchHight(elem, elem[key].right) + 1;
        ret = (h1 >= h2) ? h1 : h2;
    }

    return ret;
}

int main(void)
{
    int i;
    int num;
    int tmp;
    stNode elem[MAX_NUM];
    int key, left, right;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        elem[i].parent = NOELEM;
        elem[i].left   = NOELEM;
        elem[i].right  = NOELEM;
    }

    for (i = 0; i < num; i++) {
        scanf("%d %d %d", &key, &left, &right);
        elem[key].left  = left;
        elem[key].right = right;
        elem[left].parent  = key;
        elem[right].parent = key;
    }

    for (i = 0; i < num; i++) {
        key = elem[i].parent;
        printf("node %d: parent = %d, ", i, key);
        /* ?????????ID */
        if (key != NOELEM) {
            tmp = (elem[key].left != i) ? elem[key].left : elem[key].right;
            printf("sibling = %d, ", tmp);
        }
        else {
            printf("sibling = -1, ");
        }
        /* ????????° */
        tmp = 0;
        if (elem[i].left != NOELEM) {
            ++tmp;
        }
        if (elem[i].right != NOELEM) {
            ++tmp;
        }
        printf("degree = %d, ", tmp);
        /* ??±??? */
        tmp = 0;
        while (key != NOELEM) {
            ++tmp;
            key = elem[key].parent;
        }
        printf("depth = %d, ", tmp);
        /* ?????? */
        tmp = SerchHight(elem, i);
        printf("height = %d, ", tmp-1);
        /* ????????? */
        if (elem[i].parent == NOELEM) {
            printf("root\n");
        }
        else if ((elem[i].left != NOELEM) || (elem[i].right != NOELEM)) {
            printf("internal node\n");
        }
        else {
            printf("leaf\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

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

  if (s[len(s) - 1] == '1') {
    cout << -1 << '\n';
    return 0;
  }

  s.pop_back();
  int n = len(s);

  if (s[0] == '0' || s[n - 1] == '0') {
    cout << -1 << '\n';
    return 0;
  }

  repp(i, 1, n - 2) {
    if (s[i] != s[n - 1 - i]) {
      cout << -1 << '\n';
      return 0;
    }
  }

  int l = 1, r;
  rep(i, n) {
    int r = i + 2;
    cout << l << ' ' << r << endl;
    if (s[i] == '1')
      l = r;
  }
}

Measured memory_bytes: 1616
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;

ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main() {
	ll x, y, k, a, b;
	cin >> x >> y;
	k = (x + y) / 3;
	a = x - k, b = y - k;
	if ((x % 3 + y % 3) % 3 || a < 0 || b < 0) {
		puts("0");
		return 0;
	}
	printf("%lld\n", mc(k, a));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int k;
   cin >> k;
   vector<string> ans = {"1","2","3","4","5","6","7","8","9","10"};
   string cur = "10";
   while(ans.size()<k){
      int sz = cur.size();
      int st = sz-1;
      while(st!=0){
         if(cur[st] == '9'){
            st--;
            continue;
         }
         cur[st]++;
         if(abs(cur[st-1]-cur[st])<=1){
            break;
         }
         st--;
      }
      if(st == 0){
         if(cur[0] == '9'){
            cur = "1"+cur;
            f(i,1,cur.size()){
               cur[i] = '0';
            }
         }else{
            cur[0]++;
            f(i,1,cur.size()){
               cur[i] = max('0',char(cur[i-1]-1));
            }
         }
      }else{
         f(i,st+1,cur.size()){
            cur[i] = max('0',char(cur[i-1]-1));
         }
      }
      ans.pb(cur);
   }
   cout << ans[k-1] << '\n';
   return 0;
}

Measured memory_bytes: 5780
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

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


signed main(){
  int n,k;
  cin>>n>>k;
  map<int,int> m;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    m[a]+=b;
  } 
  int ch=0; 
  for(auto p:m){
    ch+=p.second;
    if(ch>=k) {
      cout<<p.first<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4224
using System;

class Program
{
    static void Main(string[] args)
    {
        var xa = Console.ReadLine().Split();
        var x = int.Parse(xa[0]);
        var a = int.Parse(xa[1]);
        if (x < a)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(10);
        }
    }
}


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

int64_t mod = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool> broken(N + 1, true);
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        broken[tmp] = false;
    }
    vector<int64_t> list(N + 1, 0);
    list[0] = 1;
    if(broken[1])
        list[1] = 1;
    for (int now = 2; now <= N; now++)
    {
        if(broken[now])
            list[now] = (list[now - 1] + list[now - 2]) % mod;
    }
    cout << list[N] % mod;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<long long,int>> H(n+1);

    for(int i = 1; i <= n; i++) {
        cin >> H[i].first;
    }

    vector<pair<int, int>> v(m+1);
    for(int i = 1; i <= m; i++) {
        cin >> v[i].first >> v[i].second;
    }

    //cout << v[5].second << endl; // 5
    for(int j = 1; j <= m; j++) {
        long long a = v[j].first;
        long long b = v[j].second;
        //cout <<  "loop" << a << " " << b << endl;

        if(H[a].first <= H[b].first) {
            H[a].second = 1;
        } else {
            H[b].second = 1;
        }
        if(H[b].first == H[a].first) {
            H[b].second = 1;
        }
        //if(H[b].second <= H[a].first) {
        //    H[b].second = 1;
        //}
    }

    int ret = n;
    for(int i = 1; i <= n; i++) {
        //cout << i << " " << H[i].second << endl;
        if(H[i].second == 1) {
            ret--;
        }
    }

    cout << ret << endl;

}

Measured memory_bytes: 5636
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	int v[N];
	for(int i=0;i<N;i++){
		cin >>v[i];
	}
	sort(v,v+N);
	double sum=(double)v[0]/(double)pow(2.0,(double)(N-1));
	for(int i=1;i<N;i++){
		sum=sum+((double)v[i]/(double)pow((double)2.0,(double)(N-i)));
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;
int main(void){
    int find,flg=0;
    char c=(int)0;
    string str;

    cin >> str;

    for(int i=0;i<26;i++){
        find=str.find((char)((int)'a'+i));
        if(find<=-1){
            flg=1;
            c = (char)((int)'a'+i);
            break;
        }
    }

    if(flg)cout << c << endl;
    else cout << "None" << endl;

}

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

#define int long long

signed main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      cnt++;
    }
  }

  puts(cnt == N ? "second" : "first");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int k,a[510][510];
int main()
{
	k = read();
	if(k <= 500){cout << k << "\n";for(int i = 1;i <= k;i ++,cout << "\n") for(int j = 1;j <= k;j ++) cout << i << " ";}
	else
	{
		cout << 500 <<"\n";
		for(int i = 1;i <= 500;i ++) for(int j = 1;j <= 500;j ++) a[i][j] = (i + j - 2) % 500 + 1;
		for(int i = 501;i <= k;i ++) for(int j = 1;j <= 500;j ++) if(j & 1) a[(i - j - 2 + 500) % 500 + 1][j] = i;
		for(int i = 1;i <= 500;i ++,cout << "\n") for(int j = 1;j <= 500;j ++) cout << a[i][j] << " ";
	}
}

Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int H, W; cin >> H >> W;
  vector<string> s(H);
  vector<pair<int, int>> ds = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  for (int i = 0; i < H; ++i) cin >> s[i];
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      if (s[r][c] == '.') continue;
      bool ok = false;
      for (auto [dr, dc] : ds) {
        int nr = r + dr;
        int nc = c + dc;
        if (nr < 0 || H <= nr || nc < 0 || W <= nc) continue;
        if (s[nr][nc] == '#') {
          ok = true;
          break;
        }
      }

      if (!ok) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <set>
#include <queue>
#include <map>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.size(),aite=0;
	for(int i=0;i<len;i++){
		if(s[i]=='g'){
			aite++;
		}
		else{
			aite--;
		}
	}
	int k=aite/2;
	cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 print([['null','straight'][e[4]-e[0]==4 or e[0]*10==e[1]],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])


Measured memory_bytes: 5612
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A = sc.nextFloat()
  val B = sc.nextFloat()
  val C = sc.nextFloat()
  val D = sc.nextFloat()

  println(if (math.ceil(C / B) <= math.ceil(A / D)) "Yes" else "No")
}


Measured memory_bytes: 55384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <assert.h>
#include <cstdlib>
#include <climits>
#define ll long long
#define x first
#define y second
#define vec vector
#define pb push_back
#define sz(v) (int)v.size()
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define repb(i, b, a) for(ll i = b - 1; i >= a; --i)
#define vin(v) {for(ll i = 0; i < sz(v); ++i) cin >> v[i];}
#define endl '\n'
using namespace std;

int main()
{
    int n;
    cin >> n;
    vec<int> v(n + 2);
    rep(i, 1, n + 1)
        cin >> v[i];
    v[0] = v.back() = 0;
    map<pair<int, int>, int> path;
    for(int i = 0; i < n - 1; ++i)
    {
        path[{i, i + 1}] = abs(v[i] - v[i + 1]);
        path[{i, i + 2}] = abs(v[i] - v[i + 2]);
    }
    path[{n - 1, n}] = abs(v[n] - v[n - 1]);
    path[{n - 1, 0}] = abs(v[n - 1]);
    path[{n, 0}] = abs(v[n]);
    ll sum = 0;
    rep(i, 0, sz(v))
    {
        sum += abs(v[i] - v[i + 1]);
    }
    rep(i, 1, n)
    {
        cout << sum - path[{i - 1, i}] - path[{i, i + 1}] + path[{i - 1, i + 1}] << endl;
    }
    cout << sum - path[{n - 1, n}] - path[{n, 0}] + path[{n - 1, 0}];
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  int start[26]; int goal[26];
  for (int i = 0; i < 26; i++) {
    start[i] = -1; goal[i] = -1;
  }
  for (int i = 0; i < S.length(); i++) {
    int a = S[i] - 'a'; int b = T[i] - 'a';
    if (!(start[a] == b && goal[b] == a) && (start[a] != -1 || goal[b] != -1)) {
      cout << "No" << endl;
      return 0;
    }
    start[a] = b; goal[b] = a;
  }
  cout << "Yes" << endl;
}


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

#define reint register int
#define coint const int

using namespace std;

coint SIZE = 100 + 5;

int mp[SIZE][SIZE];

int main(void) {
    int n, k;
    scanf("%d%d", &n, &k);

    int maxi = ((n - 1) * (n - 2)) / 2;
    if (maxi < k) { printf("-1\n"); return 0; }
    for (reint i = 2; i <= n; ++i) mp[1][i] = mp[i][1] = 1;

    for (reint i = 1; i <= n; ++i)
        for (reint j = i + 1; j <= n; ++j)
            if (!mp[i][j] && maxi > k)
                mp[i][j] = mp[j][i] = 1, --maxi;

    int ecnt = 0;
    for (reint i = 1; i <= n; ++i)
        for (reint j = i + 1; j <= n; ++j) ecnt += mp[i][j];
    printf("%d\n", ecnt);
    for (reint i = 1; i <= n; ++i)
        for (reint j = i + 1; j <= n; ++j)
            if (mp[i][j]) printf("%d %d\n", i, j);

    return 0;
}



Measured memory_bytes: 256
def mapint_inp():
    return map(int, input().split())

A, B, C = mapint_inp()

ans = 0
while(1):
    if A%2==1 or B%2==1 or C%2==1:
        break
    if A == B and B == C:
        ans = -1
        break
    halvedA = A//2
    halvedB = B//2
    halvedC = C//2
    A = halvedB+halvedC
    B = halvedA+halvedC
    C = halvedA+halvedB
    ans+=1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;
const int H = 10;
bool tab[H][H];
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h, w, k;
	cin>>h>>w>>k;
	for(int i=0; i<h; ++i) {
		string s;
		cin>>s;
		for(int j=0; j<w; ++j) {
			if(s[j]=='#') tab[i][j] = 1;
		}
	}
	int ans = 0;
	for(int m1=0; m1<(1<<h); ++m1) {
		for(int m2=0; m2<(1<<w); ++m2) {
			int cnt=0;
			for(int i=0; i<h; ++i) {
				for(int j=0; j<w; ++j) {
					if(tab[i][j] && !(((1<<i) & m1) != 0) && !(((1<<j) & m2) != 0)) {
						cnt++;
					}
				}
			}
			if(cnt==k) ans++;
		}
	}
	cout<<ans;
}


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


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        LL n;
        cin >> n;
        n--;
        cout << n/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N = int(input())
    D = list(map(int,input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans += D[i]*D[j]
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
object Main extends App {
  import scala.io.StdIn._
  readLine.trim.scanLeft(Empty: Per){
    case (per, char) ⇒ per.addLast(char)
  }.tail.foreach(p ⇒ println(p.countBalancedSubstring))
}
sealed trait BalancedSubstring {
  def countInner: Long
  def length: Long
  def +(that: BalancedSubstring): BalancedSubstring = Balanced(countInner + that.countInner + length * that.length, length + that.length)
}
case object EmptySubstring extends BalancedSubstring {
  override def countInner: Long = 0
  override def length: Long = 0
}
case class Balanced(override val countInner: Long, override val length: Long) extends BalancedSubstring
sealed trait Per {
  def addLast(char: Char): Per
  def countBalancedSubstring: Long
  def addLast(substring: BalancedSubstring, prevState: Per): Per
}
case object Empty extends Per{
  override def addLast(char: Char): Per = {
    char match {
      case '(' ⇒ Positive(1, EmptySubstring, this, this)
      case ')' ⇒ Negative(0, this)
      case _ ⇒ ???
    }
  }
  override def countBalancedSubstring: Long = 0
  override def addLast(substring: BalancedSubstring, prevState: Per): Per = Zero(substring, prevState)
}
case class Zero(balanced: BalancedSubstring, prev: Per) extends Per {
  override def addLast(char: Char): Per = {
    char match {
      case '(' ⇒ Positive(1, EmptySubstring, this, this)
      case ')' ⇒ Negative(balanced.countInner, this)
      case '-' ⇒ prev
      case _ ⇒ ???
    }
  }
  override def countBalancedSubstring: Long = balanced.countInner
  override def addLast(substring: BalancedSubstring, prevState: Per): Per = Zero(balanced + substring, prevState)
}
case class Positive(potential: Int, mid: BalancedSubstring, left: Per, prev: Per) extends Per {
  override def addLast(char: Char): Per = {
    char match {
      case '(' ⇒ Positive(potential + 1, EmptySubstring, this, this)
      case ')' ⇒ left.addLast(Balanced(mid.countInner + 1, 1), this)
      case '-' ⇒ prev
      case _ ⇒ ???
    }
  }
  override val countBalancedSubstring: Long = mid.countInner + left.countBalancedSubstring
  override def addLast(substring: BalancedSubstring, prevState: Per): Per = Positive(potential, mid + substring, left, prevState)
}
case class Negative(count: Long, prev: Per) extends Per {
  override def addLast(char: Char): Per = {
    char match {
      case '(' ⇒ Positive(1, EmptySubstring, this, this)
      case ')' ⇒ Negative(count, this)
      case '-' ⇒ prev
      case _ ⇒ ???
    }
  }
  override def addLast(substring: BalancedSubstring, prevState: Per): Per = Zero(Balanced(count + substring.countInner, substring.length), prevState)
  override def countBalancedSubstring: Long = count
}


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

int main() {
    int N;
    std::string S;
    std::cin >> N >> S;

    int cnt = 0;
    char prev = ' ';
    for (std::size_t i = 0; i < S.size(); ++i) {
        if (i == 0) {
            prev = S[i];
            ++cnt;
        } else {
            if (S[i] != prev) {
                ++cnt;
            }
            prev = S[i];
        }
    }

    std::cout <<  cnt << std::endl;

    return 0;
}


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

int main(){
  long long n,nm=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  vector<int>c(n);
  for(int i=0;i<n-1;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    a[i]--;
  }
  for(int i=0;i<n;i++){
    nm+=b[a[i]];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1]){
      nm+=c[a[i]];
    }
  }
  cout<<nm<<endl;
}
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	private static void solve(int n, int k,int[] h) {
		
		int[] dp = new int[n];
		for (int i=0; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		dp[0] = 0;
		
		for (int i=1; i<n; i++) {
			for (int j=1; j<=k && (i-j) >= 0; j++) {
				dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
			}
		}
 
		System.out.println(dp[n-1]);
	}
 
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		
		int[] h = new int[n];
		
		for (int i=0; i<n; i++) {
			h[i] = scanner.nextInt();
		}
		
		solve(n, k, h);
		
		scanner.close();
	}
}

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const int MAX = (int)1e6;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//main関数にCOMinit();を忘れない

int main() {
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }

    int moves=(x+y)/3;
    int xmove2=x-moves;
    if(xmove2>moves){
        cout<<0<<endl;
        return 0;
    }

    COMinit();

    cout<<COM(moves,xmove2)<<endl;

    

    return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <algorithm>

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

	std::vector<int> hp(n);
	for (auto&& e : hp)
		std::cin >> e;

	int updated = -1;
	while (updated != 0) {
		updated = 0;
		std::sort(hp.begin(), hp.end());

		if (hp[0] == hp.back())
			break;

		for (int i = 1; i < n; ++i) {
			if (hp[0] == hp[i])
				continue;

			++updated;
			if (hp[i] % hp[0] == 0)
				hp[i] = hp[0];
			else
				hp[i] %= hp[0];
		}
	}

	std::sort(hp.begin(), hp.end());

	std::cout << hp[0] << std::endl;
}

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

int main()
{
    

    int N,X,T,ans;
    cin>>N>>X>>T;

    if(N%X==0)
        ans=(N/X)*T;
    else ans = (N/X+1)*T;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  
  char s[n];
  scanf("%s",&s);
  
  int i=0;
  int cnt=0;
  for(i=0;i<n;i++){
    if((s[i] == 'A')&&(s[i+1] == 'B')&&(s[i+2] == 'C')){
      cnt++;
    }
  }
  
  printf("%d\n",cnt);
  
  return 0;
}

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

int main(void){
	long long int N;
	long long int a,b;
	cin>>N>>a>>b;
	long long int tmp;
	long long int ans = 0;
	if(a < b){
		tmp = a; a = b; b = tmp;
	}
	if((a-b)%2 == 0){
		ans = (a-b)/2;
	}
	else if(b-1<N-a){
		//printf("a-1\n");
		ans+=b-1;
		a = a - b + 1;
		a--;
		ans++;
		ans = ans+(a-1)/2;
	}
	else if(b-1>=N-a){
		//printf("N-b\n");
		ans+= N - a;
		b = b + N-a;
		ans++;
		b++;
		ans = ans + (N-b)/2;
	}
	printf("%lld\n",ans);
	return 0;
}



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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

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

const int maxn = 2*(int)1e6+1000;
int n, k, c, lf[maxn], rt[maxn];
char s[maxn];

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

	cin >> n >> k >> c;
	cin >> (s+1);
	int tot = 0;
	ms(lf, 0);
	ms(rt, 0);
	int flag = 0;
	for (int i = 1; i <= n; ++i) {
		if (tot == k) {
			flag = 1;
			break;
		}	
		else {
			if (s[i] != 'x') {
				lf[i] = 1;
				i += c;
				++tot;
			}
		}
	}
	if (flag) return 0;
	tot = 0;
	for (int i = n; i >= 1; --i) {
		if (tot == k) break;
		else {
			if (s[i] != 'x') {
				rt[i] = 1;
				i -= c;
				++tot;
			}
		}
	}
	vi ans;
	for (int i = 1; i <= n; ++i) {
		if (lf[i] && rt[i]) ans.eb(i);
	}
	for (int x : ans) cout << x << '\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 18292
#include <iostream>
#include <string>
using namespace std;
#define rep(j,n) for(int j = 0 ; j < 5 ; j++)

int main(){
    string str;
    
    while(getline(cin,str)){
        for(int i = 0 ; i < str.length() ; i++){
            string key = str.substr(i,5),repl;
            if(key == "apple"){
                repl = "peach";
                rep(j,n) str[i+j] = repl[j];
            }
            else if(key == "peach"){
                repl = "apple";
                rep(j,n) str[i+j] = repl[j];
            }
        }
        cout << str << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ll long long

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

  if(a==b+c || b==a+c || c==a+b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
        ll h, w;
        scanf("%lld %lld", &h, &w);

        ll fig[h+2][w+2], x[h*w+1], y[h*w+1];
        for(int j=0; j<w; j++) fig[0][j]=0, fig[h+1][j]=1e11;
        for(int i=0; i<h; i++) fig[i][0]=0, fig[i][w+1]=1e11;

        for(int i=1; i<=h; i++){
                for(int j=1; j<=w; j++){
                        ll tmp;
                        scanf("%lld", &tmp);
                        fig[i][j] = tmp;
                        x[tmp] = i, y[tmp] = j;
                }
        }

        ll ans = 0, chgeIn[h+2][w+2];
        for(int i=0; i<h+2; i++)for(int j=0; j<w+2; j++)chgeIn[i][j]=0;

        ll dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
        for(int i=1; i<=h*w; i++){
                for(int j=0; j<4; j++){
                        ll tx = x[i] + dx[j], ty = y[i] + dy[j];
                        if(fig[tx][ty]<fig[x[i]][y[i]]){
                                if(chgeIn[tx][ty]==0)continue;
                                if(chgeIn[x[i]][y[i]]!=0 and chgeIn[x[i]][y[i]]!=chgeIn[tx][ty]){
                                        chgeIn[x[i]][y[i]] = -1;
                                }else{
                                        chgeIn[x[i]][y[i]] = chgeIn[tx][ty];
                                }
                        }
                }
                if(chgeIn[x[i]][y[i]]==0) chgeIn[x[i]][y[i]] = i;
                else if(chgeIn[x[i]][y[i]]==-1) ans++;
        }

        //for(int i=0; i<h; i++){for(int j=0; j<w; j++)printf("%lld ", chgeIn[i+1][j+1]);puts("");}
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 34496
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
#include<map>
#include<string>
using namespace std;

int main(){
	int L, M, N;
	while(cin >> L, L){
		int sum = 0, ans = -1;
		for(int i = 1; i <= 12; i++){
			cin >> M >> N;
			sum += M - N;
			if(sum >= L && ans == -1) ans = i;
		}
		if(ans == -1) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

void solve(){
	string a,b;
	cin>>a>>b;
	vvi dp(a.size()+1,vi(b.size()+1));
	rep(i,a.size()){
		rep(j,b.size()){
			if(a[i]==b[j])dp[i+1][j+1]=dp[i][j]+1;
			else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
		}
	}
	cout<<dp[a.size()][b.size()]<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	rep(i,n)solve();
}


Measured memory_bytes: 6828
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
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/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long 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;}}
long long 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 llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  ll n,m;
  cin>>n>>m;
  cout<<pow(2,m)*(1900*m+100*(n-m))<<endl;
}

Measured memory_bytes: 4100
#include<stdio.h>
#define NIL -1 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
int main(){
  int n, i, j, e, sum;
  /*your code*/
  int M[MAX][MAX],p[MAX],d[MAX],went[MAX];
  int min,u;
  scanf("%d", &n);
 
  /*表を作る*/
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  /*your code*/
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      d[i] = INFTY;
      went[i] = 0;  //boolean
      p[i] = NIL;
    }
  }
  d[0] = 0;/*最初のコストは０*/

  for(i=0;i<n;i++) { /*すべて連結しているため、n回まわす*/
    u = NIL;
    min = INFTY;

    /*d[u]が最小であるをu求める*/
    for(j=0;j<n;j++) {
      if(min > d[j] && (went[j] == 0)) { /* 最小cost かつ 行っていないとき */
	min = d[j];  /* 最小costの値を保存する */
	u = j;  /* 最小costの場所v[i]を保存する */
      }
    }

    if(u == NIL) break; /*全部行ったらbreak*/
    went[u] = 1; /*行ったことをcheckする*/

    for(j=0;j<n;j++) {
      if(d[j] >= M[u][j] && (went[j] == 0)) {
	p[j] = u;  /*最小costの場所vを保存*/
	d[j] = M[u][j]; 
      }
    }
  }


  sum = 0;
 
  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }
 
  printf("%d\n", sum);
 
  return 0;
}

Measured memory_bytes: 804
from math import ceil
s = input()
l = len(s)
li = [0]*l
st = "R"
cnt = 0

for i in range(l):
    if st == "R":
        if s[i] == "R":
            cnt += 1
        else:
            li[i] += cnt//2
            li[i-1] += ceil(cnt/2)
            st = "L"
            cnt = 1
    else:
        if s[i] == "L":
            cnt += 1
        else:
            li[i-cnt] += ceil(cnt/2)
            li[i-cnt-1] += cnt//2
            st = "R"
            cnt = 1
else:
    li[l-cnt] += ceil(cnt/2)
    li[l-cnt-1] += cnt//2

for i in range(l-1):
    print(li[i],end=" ")
else:
    print(li[l-1])

Measured memory_bytes: 4864