akhauriyash/Code-Regression huggingface dataset:
/// 11:57 AM 04/04/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    ll s = 0;
    vector<ll> v(n);
    for (auto &x:v) {
        cin >> x;
        s += x;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll maxLimit = s/(4*m);
    if(s%(4*m) !=0) {
        maxLimit++;
    }
    if(v[m-1] < maxLimit) {
        cout<<"No";
    }
    else {
        cout<<"Yes";
    }
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

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



Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define crap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll solve(ll arr[],ll n,ll k){
    if( n == 2 ){
        return abs(arr[1]-arr[0]);
    }
    ll dp[n];
	memset(dp,0,sizeof(dp));
    //dp[1] = 0;
     dp[1] = abs(arr[1]-arr[0]);
    for( ll i=2; i<n; i++ ){
        ll ans = INT_MAX;
        for( int j=1; j<=k;j++ ){
            if( i-j >=0 ){
              ll op1 = abs(arr[i]-arr[i-j]) + dp[i-j];
              ans = min(op1,ans);
            }
        }
        dp[i] = ans;
    }
    return dp[n-1];
}

int main() {
	crap;
	ll n,k;
	cin >> n >> k;
	ll arr[n];
	for( int i=0; i<n; i++ ){
	    cin >> arr[i];
	}
	cout << solve(arr,n,k);
	
	return 0;
}

Measured memory_bytes: 5104
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int cnt = 0;
    rep(i, N) if (h[i] >= K) cnt++;

    cout << cnt << endl;

	return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
/* Atcoder abc171b
 * See tasks at: https://atcoder.jp/contests/abc171/tasks/abc171_b
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int n, k;
    cin >> n >> k;
    
    vector<int> p(n);
    until(i, n)
    {
        int val;
        cin >> val;
        p[i] = val;
    }
    
    sort(p.begin(), p.end());
    p.resize(k);
    cout << accumulate(p.begin(), p.end(), 0);
    return 0;
}


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

  int N;  cin >> N;
  long long ave = 0;
  int a[100];
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
    ave += a[i];
  }

  ave /= N;
  long long keep = 0;
  for(int i = 0 ; i < N ; i++)
    keep += (a[i] - ave) * (a[i] - ave);

  long long ans = keep;
  keep = 0;
  for(int i = 0 ; i < N ; i++)
    keep += (a[i] - (ave + 1)) * (a[i] - (ave + 1));

  ans = min(ans, keep);
  cout << ans << endl;

  return 0;
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=2e5+10;
int pre[maxn][2],suf[maxn][2];
char a[maxn];
int n;

int main(){
	io;
	cin>>n;
	cin>>(a+1);
	for(int i=1;i<=n;i++){
		pre[i][0]=pre[i-1][0];
		pre[i][1]=pre[i-1][1];
		if(a[i]=='R')pre[i][0]++;
		else pre[i][1]++;
	}
	for(int i=n;i>=1;i--){
		suf[i][0]=suf[i+1][0];
		suf[i][1]=suf[i+1][1];
		if(a[i]=='R')suf[i][0]++;
		else suf[i][1]++;
	}
	int ans=n;
	for(int i=0;i<=n;i++){
		int x=pre[i][1],y=suf[i+1][0];
		// dbg(x);dbg(y);
		ans=min(max(x,y),ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using ll = unsigned long long;
const ll mod = 1000000007;
const int M_MAX = 10000;
string al = "abcdefghijklmnopqrstuvwxyz";
//bool less_sec(const pair<int, int>&a, const pair<int, int>&b) {
//	return a.second > b.second;
//}
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	ll sum = 0;
	ll minV = 1000000000;
	if (a + b >= 2 * c) {
		minV = (x >= y ? 2 * c*x : 2 * c*y);
		while (true) {
			sum += 2 * c;
			x--;
			y--;
			if (x == 0 || y == 0) break;
		}
		if (x == 0) sum += y * b;
		else sum += x * a;
		minV = min(minV, sum);
	}
	else {
		while (true) {
			sum += a + b;
			x--;
			y--;
			if (x == 0 || y == 0) break;
		}
		if(x == 0) sum += y * b;
		else sum += x * a;
		minV = min(minV, sum);
	}
	cout << minV << endl;
	return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;++i)cin>>vec[i];
    sort(vec.begin(),vec.end());
    int ans=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<i;++j){
            for(int k=0;k<j;++k){
                if(vec[k]!=vec[j]&&vec[i]!=vec[j]&&vec[k]+vec[j]>vec[i])ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
def main():
    import sys
    from collections import deque
    input=sys.stdin.readline

    h,w,k=map(int,input().split())
    sy,sx,gy,gx=map(int,input().split())

    #maze=[]
    #for _ in range(h):
    #    maze.append(tuple(input()))

    maze=[tuple(input()) for _ in range(h)]

    sy-=1
    sx-=1
    gy-=1
    gx-=1

    #maze[sy][sx]="S"

    dis=[[-1]*w for _ in range(h)]



    dis[sy][sx]=0



    d = deque([(sx,sy)])
    while len(d)>0:
        (x,y)=d.popleft()
        if x==gx and y==gy:
            print(dis[gy][gx])
            #maze[gy][gx]="G"

            #pri(dis)
            #pri(maze)

            exit()

        for (mx,my) in ((0,1),(1,0),(-1,0),(0,-1)):
            #print(mx,my,d)
            for j in range(1,k+1):
                nx=x+mx*j
                ny=y+my*j
                #print(y,x,">>",ny,nx)
                if 0<=nx<w and 0<=ny<h:
                    if maze[ny][nx]=="." and (dis[ny][nx]==-1 or dis[ny][nx]==dis[y][x]+1):
                        if dis[ny][nx]==-1:
                            d.append((nx,ny))
                        dis[ny][nx]=dis[y][x]+1
                        
                        #pri(dis)
                    else:
                        break
                else:
                    break

    print(-1)
        
if __name__ == '__main__':
    main()


                










Measured memory_bytes: 162812
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i&&v[i] && v[i - 1]) {
			ans++;
			v[i] --;
		}
		ans += v[i] / 2;
		v[i] &= 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*

fun main() {
    val l = readLine()!!.split(' ').map { it.toInt() }
    val a = Array(l[2]) { 0 }
    val b = Array(l[2]) { 0 }
    val c = Array(l[2]) { 0 }
    val d = Array(l[2]) { 0 }
    for (i in 0 until l[2]) {
        val line = readLine()!!.split(' ').map { it.toInt() }
        a[i] = line[0]-1
        b[i] = line[1]-1
        c[i] = line[2]
        d[i] = line[3]
    }

    fun eval(list: List<Int>): Int {
        var res = 0
        for (x in 0 until a.size) {
            if (list[b[x]]-list[a[x]] == c[x]) {
                res += d[x]
            }
        }
        return res
    }

    var max = 0
    fun dfs(list: List<Int>) {
        if (list.size < l[0]) return (list.last()..l[1]).forEach { dfs(list + it) }
        max = Math.max(max, eval(list))
    }

    dfs(listOf(1))
    println(max)
}



Measured memory_bytes: 55176
#include <bits/stdc++.h>
using namespace std;
using p_int = pair<int, int>;

int H, W;
char field[1000][1000];
p_int direction[4] = { make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0), make_pair(0, -1) };
vector<p_int> blacks;

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

    cin >> H >> W;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cin >> field[y][x];
            if (field[y][x] == '#') {
                blacks.emplace_back(y, x);
            }
        }
    }

    int total = 0;
    while (true) {
        bool reverse = false;
        vector<p_int > next_blacks;
        for (auto b: blacks) {
            int y = b.first;
            int x = b.second;
            for (auto d: direction) {
                int ny = y + d.first;
                int nx = x + d.second;
                if (0 <= ny && ny < H && 0 <= nx && nx < W && field[ny][nx] == '.') {
                    next_blacks.emplace_back(ny, nx);
                    field[ny][nx] = '#';
                    reverse = true;
                }
            }
        }
        if (!reverse) {
            break;
        }

        blacks = next_blacks;
        
        total++;
    }

    cout << total << '\n';

    return 0;
}


Measured memory_bytes: 15848
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  int cu = 0;
  vector<vector<int>> ans(H, vector<int>(W));
  for (int y=0; y<H; y++) {
    for (int x=0; x<W; x++) {
      ans[y][x] = cu+1;
      a[cu]--;
      if (!a[cu]) cu++;
    }
  }
  for (int y=0; y<H; y++) {
    for (int _x=0; _x<W; _x++) {
      int x;
      if (y%2==0) x = _x;
      else x = W-1-_x;
      if (_x) cout << " ";
      cout << ans[y][x];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int N;
	int i;
	int ayaseharuka = 9999;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		int odagirizyoo = 0;
		if (scanf("%d", &A) != 1) return 1;
		while (A % 2 == 0) {
			A >>= 1;
			odagirizyoo++;
		}
		if (odagirizyoo < ayaseharuka) ayaseharuka = odagirizyoo;
	}
	printf("%d\n", ayaseharuka);
	return 0;
}


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

#define rep(i,a,b)     for(int i=a;i<(b);i++)
#define lop(n)         for(int i=0;i<n;i++)
#define revlop(n)      for(int i=n-1;i>=0;i--)
#define trav(a,x)      for(auto & a :x)
#define all(x)         begin(x),end(x)
#define pb             push_back
#define pii            pair<int,int>
#define vpii           vector<pii>
#define F              first
#define S              second
#define mod            1000000007
#define inf            1e18
#define ps(x,y)        fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x)           int x; cin>>x; 

typedef long long ll;
typedef vector<int> vi;

// functions
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b,a%b);}
ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}
ll power(ll x,ll y,ll p ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int setbits(ll x)  {  return __builtin_popcount(x);  }
ll factorial(ll n) {  ll f = 1; if (n == 0|| n == 1)  return 1;  for (ll i = 2; i <= n; i++)  f = f * i; return f; }

void solve()
{ int temp;
  cin>>temp;
  if(temp>=30)
    cout<<"Yes";
  else
    cout<<"No";
}

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

  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

   int test=1;
   //cin>>test;
   while(test--)
     solve();

  return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 30;
const int inf = 1<<20;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int rev[]={1,0,3,2};
bool edge[N][N][4];

int cost[N][N];
int bfs(int r,int c,int sy,int sx){
  rep(i,r)rep(j,c)cost[i][j]=inf;
  cost[sy][sx]=0;
  queue<int> Q;
  Q.push(sy*c+sx);
  while(!Q.empty()){
    int y=Q.front()/c,x=Q.front()%c;Q.pop();
    if (y == r-1 && x == c-1)return cost[r-1][c-1];
    rep(i,4){
      int nex=x+dx[i],ney=y+dy[i];
      if (nex == -1 || ney == -1 || nex == c || ney == r || !edge[y][x][i] || cost[ney][nex] != inf)continue;
      cost[ney][nex] = cost[y][x] + 1;
      Q.push(ney*c+nex);
    }
  }
  return inf;
}

bool vis[N][N];
int opt[N][N];
int solve(int r,int c){
  rep(i,r)rep(j,c)opt[i][j]=inf,vis[i][j]=false;
  opt[r-1][c-1]=0;
  while(true){
    bool fg=false;
    rep(i,r){
      rep(j,c){
	int tmp = opt[i][j];
	rep(k,4){
	  int nex=j+dx[k],ney=i+dy[k];
	  if (ney == -1 || nex == -1 || ney == r || nex == c || !edge[i][j][k] || opt[ney][nex] >= opt[i][j])continue;
	  edge[i][j][k]=false;
	  int a=bfs(r,c,i,j);
	  edge[i][j][k]=true;
	  opt[i][j]=min(opt[i][j],max(1+opt[ney][nex],a));
	}
	if (opt[i][j] != tmp)fg=true;
      }
    }
    if (!fg)break;
  }
  return opt[0][0]==inf?-1:opt[0][0];
}

main(){
  int r,c;
  while(cin>>r>>c && r){
    rep(i,r)rep(j,c)rep(k,4)edge[i][j][k]=true;
    rep(i,r){
      rep(j,c-1){
	cin>>edge[i][j][0];edge[i][j][0]=1-edge[i][j][0];edge[i][j+1][1]=edge[i][j][0];
      }
      if (i == r-1)break;
      rep(j,c){
	cin>>edge[i][j][2];edge[i][j][2]=1-edge[i][j][2];edge[i+1][j][3]=edge[i][j][2];
      }
    }
    cout << solve(r,c) << endl;
  }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9

int main() {
    string S;
    cin >> S;
    int count=0;
    int max=0;
    bool flag = false;
    for (int i=0; i<S.size(); i++){
        if (S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            flag = true;
            count++;
        }
        else{
            flag = false;
            if(max < count){
                max = count;
            }
            count = 0;
        }

    }
    if(max < count){
                max = count;
    }
    cout << max << endl;

}


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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

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

    int num[4001] = {0};
    for(int i=1; i<=K; i++) for(int j=1; j<=i; j++) num[i+j]++;
    for(int s=2; s<=2*K; s++){
        int ps = num[s];
        int64_t ans = 0;
        for(int p=0; p<=ps && 2*p<=N; p++){
            int64_t res = comb_mod(ps, p) * comb_mod(N-2*p+K-1, K-1) % MOD;
            add(ans, MOD + res * (p%2 ? -1 : 1));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
def main():
    N = int(input())
    H = list(map(int, input().split()))

    h0 = 0
    h1 = abs(H[1] - H[0])

    for i in range(2, N):
        h0, h1 = h1, min(
            h0 + abs(H[i] - H[i-2]),
            h1 + abs(H[i] - H[i-1]))

    print(h1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13928
N,M=gets.split.map(&:to_i)
S=gets.chomp
T=gets.chomp
L=N.lcm(M)

i=j=0
while i<L && j<L
    if i == j
        if S[i/(L/N)] != T[j/(L/M)]
            puts -1
            exit 0
        end
        i += L/N
        j += L/M
    elsif i < j
        i += L/N
    else
        j += L/M
    end
end

puts L


Measured memory_bytes: 2044
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      String a=sc.nextLine();
      String []b=a.split(" ",0);
      System.out.println((b[0].substring(b[0].length()-1,b[0].length()).equals(b[1].substring(0,1))&&b[1].substring(b[1].length()-1,b[1].length()).equals(b[2].substring(0,1)))?"YES":"NO");
    }
}


Measured memory_bytes: 21972
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int n,q,a,sum=0;
scanf("%d", &n);
bool check;
vector<int> A(n);
for(int i=0;i<n;i++){scanf("%d", &A[i]);sum+=A[i];}
scanf("%d", &q);
vector<int> M(q);
for(int i=0;i<q;i++)scanf("%d", &M[i]);
for(int i=0;i<q;i++)
{
check=false;
if(sum>M[i])
{
for(int bit=0;bit<(1 << n);bit++)
{
a=0;
for(int j=0;j<n;j++){if(bit & (1 << j)){a+=A[j];if(a>M[i])break;if(a==M[i]){check=true;break;}}}
if(check)break;
}
}else if(sum==M[i]) check=true;
if(check)printf("yes\n");
else printf("no\n");
}
}



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

struct data{int t,s,d;};
bool compare(const data& a, const data& b){return a.t < b.t;}

int main(){

  for(int n,m;cin>>n>>m,n;){
    vector<int> flags(n,0);flags[0]=1;
    vector<data> logs(m);

    for(int i=0;i<m;++i)
      cin >> logs[i].t >> logs[i].s >> logs[i].d;

    sort(logs.begin(), logs.end(), compare);

    for(int i=0;i<m;++i)
      flags[logs[i].d-1] |= flags[logs[i].s-1];

    int ans=0;
    for(int i=0;i<n;++i)
      ans += flags[i];

    cout << ans << endl;
  }

  return EXIT_SUCCESS;
}

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

class Program
{
    static void Main(string[] args)
    {
        //入力処理
        int[] IN = Console.ReadLine().Split(' ').Select((s) => int.Parse(s)).ToArray();
        int D = IN[0];
        int Goal = IN[1];
        List<int[]> PC = new List<int[]>();
        for(int i = 0; i < D; i++)
        {
            PC.Add(Console.ReadLine().Split(' ').Select((s) => int.Parse(s)).ToArray());
        }

        int min = int.MaxValue;

        //コンプリートボーナスの狙い方で全探索
        for(int i=0; i < (1 << D); i++)
        {
            int score = 0;
            int solve = 0;
            int untouched = 0;

            for(int j = 0; j < D; j++)
            {
                //100j点問題をコンプリートしたか
                if ((i & (1 << j)) != 0)
                {
                    score += PC[j][0] * (j+1) * 100 + PC[j][1];
                    solve += PC[j][0];
                }else
                {
                    untouched = j;
                }
            }

            //ゴールに達したか
            int more = Goal - score;
            if (more > 0)
            {
                int utunit = (untouched + 1) * 100;
                if (score + PC[untouched][0] * utunit < Goal)
                {
                    //この作戦は最良たり得ない場合はスキップ
                    continue;
                }
                //ゴールに達していないなら追加で解く
                solve += (more / utunit) + ((more % utunit != 0) ? 1 : 0);
            }

            //最良回答数更新
            if (solve < min)
            {
                min = solve;
            }
        }

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13396
N, M = map(int, input().split())
a = [list(map(int, input().split())) for i in range(M)]
r = [0]*N
for i in range(M):
    r[a[i][0] - 1] += 1
    r[a[i][1] - 1] += 1
for i in range(N):
    print(r[i])


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
  class Program
  {
    static void Main(string[] args)
    {
      var h = new int[10];
      for(int i=0;i < 10;i++){
        h[i] = int.Parse(Console.ReadLine());
      }
      Array.Sort(h, (x,y) => {return y- x;});
      Console.WriteLine(h[0]);
      Console.WriteLine(h[1]);
      Console.WriteLine(h[2]);

    }
  }
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 110, M = 1010;

int n, m;
char s[N];

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res *= i;
	for (int i = 1; i <= b; i ++ ) res /= i;
	return res;
}

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int f(int n)
{
	vector<int> nums;
	for (int i = 1; i <= n; i ++ ) nums.PB(s[i] - '0');
	
	int res = 0;
	int last = 0;
	for (int i = 0; i < n; i ++ )
	{
		int x = nums[i];
		// cout << x << ' ';
		if (x)
		{
			res += qp(9, m - last) * C(n - i - 1, m - last);
		// cout << res << endl;
			res += (x - 1) * qp(9, m - last - 1) * C(n - i - 1, m - last - 1);
			last ++ ;
		}
		
		// if (i == n - 1) res ++ ;
		if (last == m)
		{
			res ++ ;
			break;
		}
	}
	
	return res;
}

int main()
{
	cin >> s + 1 >> m;
	n = strlen(s + 1);
	cout << f(n) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 出力
		int sum=a+b;
		if(b>=a&&b>=c)
			sum = a+c;
		else if(a>=b&&a>=c)
			sum=b+c;
		System.out.println(sum);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	vector<int> v1,v2;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v1.push_back(a);
		v2.push_back(b);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	if(n%2==1)a=v1[n/2],b=v2[n/2];
	else a=v1[n/2-1]+v1[n/2],b=v2[n/2-1]+v2[n/2];
	cout<<b-a+1<<endl;
}

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

using namespace std;

const int N = (int) 1e5 + 7;
int n, u[N];

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

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        u[x] = i;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << u[i] << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int A[200001]={};
int t[200001] ={};
int bit[200001][2] = {};

int main(){
    int N,j=0,i,a,c;
    long long int K,first=0,count=1;
    cin >> N;
    cin >> K;
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    for(i=0;i<N+1;i++){
        t[i]=0;
        bit[i][0]=0;
        bit[i][1]=0;
    }
    t[0]=1;
    bit[1][0]=1;
    bit[1][1]=0;
    for(i=1;i<N+1;i++){
        c = A[j];
        t[i]= c;
        if(bit[c][0]==1){
            first = bit[c][1];
            count = i-bit[c][1];
            break;
        }
        bit[c][0]=1;
        bit[c][1]=i;
        j=t[i]-1;
    }
  	if(K>=first){
    	a=(K-first)%count+first;
     	cout << t[a] << endl;
    }else{
      cout << t[K] << endl;
    }
     //for(i=0;i<count+first+1;i++){
       // cout << "t:"<< t[i] << endl;
     //}
}

Measured memory_bytes: 6756
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 1; i < N; i++) {
		long long int sum = 0;
		for (int j = 1; j *i < N; j++) {
			R = N - 1 - i * j;
			L = R - i;
			sum += v[R];
			sum += v[i*j];
			if (L >= R || L <= 0)continue;
			if (R%i == 0 && i*j >= R)break;
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,a;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i,n){
        cin >> a;
        q.push(a);
    }
    rep(i,m){
        ll tmp=q.top();
        tmp/=2;
        q.pop();
        q.push(tmp);
    }
    ll sum=0;
    rep(i,n){
        ll tmp=q.top();
        sum+=tmp;
        q.pop();
    }
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[(1<<21)+3];
bool A[23][23];

int main(){
  ll N;
  cin >> N;
  rep(i,N){
    rep(j,N){
      cin >> A[i][j];
    }
  }
  dp[0]=1;
  Rep(S,1,1<<N){
    ll i=__builtin_popcount(S);
    rep(j,N){
      if(S&1<<j && A[i-1][j]==1){
        dp[S]=(dp[S]+dp[S^(1<<j)])%MOD;
      }
    }
  }
  cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n;
		int a[];
		long sum,max;
		
		while(true){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			max=-100000000;
			a=new int[n];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt();
			}
			
			for(int i=0;i<n;i++){
				sum=0;
				for(int j=i;j<n;j++){
					sum+=a[j];
					if(max<sum){
						max=sum;
					}
				}
			}
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 26464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int A, B;
	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		co("Possible");
	}
	else co("Impossible");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;


int main(){
  int h,w,a,b;
  cin >> h >> w >> a >>b;
  int ans=(h*w)-(a*w)-(b*h)+(a*b);
  cout << ans << endl;
}
  
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   int n;
   cin >> n;
   bool ok = true;
   for(int i = 1; i <= n; i++)
   {
       int tem;
       cin >> tem;
       if(tem % 2 == 0)
       {
           if(tem % 3 != 0 && tem % 5 != 0)
           {
               ok = false;
           }
       }
   }
   if(ok == true)
   {
       cout << "APPROVED" << endl;
   }
   else
   {
       cout << "DENIED" << endl;
   }
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int n, m, i, j;
        int subTotal = 0;
        int total = 0;

        //整数受け取り
        string[] str = Console.ReadLine().Split(' ');
        n = int.Parse(str[0]);
        m = int.Parse(str[1]);

        //2次元配列数値受け取り
        int[,] array1 = new int[n, m];
            
        for (i = 0; i < n; i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');

            for (j = 0; j < m; j++)
            { 
                array1[i, j] = int.Parse(str2[j]);
            }
        }

        //配列数値受け取り
        int[] array2 = new int[m];
            
        for (j = 0; j < m; j++)
        {
            string str3 = Console.ReadLine();
            array2[j] = int.Parse(str3);
        }

        //計算
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < m; j++)
            {
                subTotal = array1[i, j] * array2[j];
                total += subTotal;
                subTotal = 0;
            }
            Console.WriteLine(total);
            total = 0;
        }
    }
}


Measured memory_bytes: 9276
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2){
      if(s[i]=='R'){cout<<"No"<<endl;return 0;}
    }else{
      if(s[i]=='L'){cout<<"No"<<endl;return 0;}
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

 

public class Main {

 

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int flowerNum = scan.nextInt();                        // 花の総本数
        int[] flowerHeightList = new int[flowerNum];             // 花の高さを入れる配列
        int count = 0;                                             // 水やり回数

 

        /* データ入力 */
        for (int i = 0; i < flowerNum; i++) {
            flowerHeightList[i] = scan.nextInt();
        }

 

        int tmp = 0;
        int head = 0;
        

 

        while(head < flowerNum) {
            // 先頭の高さが0だった場合、次の要素を先頭とする
            if(flowerHeightList[head] == 0) {
                tmp = ++head;
                continue;
            }
            // 水やりの範囲を決定する
            for(int tail = head; tail < flowerNum; tail++) {
                if(flowerHeightList[tail] == 0) {
                    head = tmp;
                    break;
                }
                flowerHeightList[tail]--;
            }
            count++;
        }

 

        System.out.println(count);
        scan.close();
    }

 

}

Measured memory_bytes: 21204
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int n = s.length();
    char[] array = s.toCharArray();
    boolean flag = false;

    if(array[0]=='A'){
      int large_count = 0;
      int small_count = 0;
      for(int i =2; i<n-1;i++){
        if(array[i]=='C'){large_count += 1;}
      }
      if(large_count ==1){
        for(int j=0; j<n;j++){
          if(Character.isLowerCase(array[j])){
            small_count += 1;
          }
        }
        if(small_count == s.length()-2){
          flag = true;
        }
      }

    }

    if(flag){System.out.println("AC");}else{
      System.out.println("WA");
    }
  }
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = a * 2 + b * 2;
		System.out.println(area + " " + length);
	}
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0);}

ll N;

signed main(){
    cin>>N;
    string S[N];
    char s;
    rep(i,N){
        cin>>S[i];
        if(i){
            if(s!=S[i][0]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        rep(j,N){
            if(i!=j&&S[i]==S[j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        s=S[i][S[i].length()-1];
    }
    cout<<"Yes"<<endl;
}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


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

int main(void)
{
    ll x;
    cin >> x;
    ll n = x / 11;
    ll mod = x % 11;
    if(mod == 0){
        cout << 2 * n << endl;
    } else if(mod <= 6){
        cout << 2 * n + 1 << endl;
    } else {
        cout << 2 * n + 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stack>
#include <cctype>

using namespace std;


int main(){

	while(1){
		int n,s,sum,max,min;

		cin>>n;
		if(n==0) break;

		sum=0;
		for(int i=0;i<n;i++){
			cin>>s;
			if(i==0){
				max=s,min=s;
			}
			if(s<min) min=s;
			if(s>max) max=s;
			sum+=s;
		}
		cout<<(sum-max-min)/(n-2)<<endl;
	}	

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   int n;
   cin >> n;
   long long a[n];
   for (int i = 0; i < n; i++) cin >> a[i];
   sort(a, a+n);
   cout << abs(a[n-1]-a[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll 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*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int a[10];	

int main(){
	int n,cnt=0;
	cin >> n;
	for(int i=1; i<=n; i++){
		int x; cin>>x;
		if(x>=1 && x<=399) a[1]=1;
		else if(x>=400 && x<=799) a[2]=1;
		else if(x>=800 && x<=1199) a[3]=1;
		else if(x>=1200 && x<=1599) a[4]=1;
		else if(x>=1600 && x<=1999) a[5]=1;
		else if(x>=2000 && x<=2399) a[6]=1;
		else if(x>=2400 && x<=2799) a[7]=1;
		else if(x>=2800 && x<=3199) a[8]=1;
		else cnt++;
	}
	int k = 0;
	for(int i=1; i<=8; i++)
		if(a[i] == 1) k++;
	int ansl,ansr;
	if(k==0 && cnt!=0) ansl=1, ansr=cnt;
	else {
		ansl = k; ansr = cnt+k;
	}
	cout << ansl << " " << ansr << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int Adj[101][101] = {{0}};
	for (int i = 0;i < n;i++) {
		int th;
		cin >> th;
		int k;
		cin >> k;
		int adj;
		if(k>0)
		for (int j = 0;j < k;j++) {
			cin >> adj;
			Adj[th-1][adj-1] = 1;
		}
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (j) cout << " ";
			cout << Adj[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, buf;

int main(){
	cin >> n;
	
	ll cnt4 = 0;
	ll cnt2 = 0;
	for(ll i = 1; i <= n; i++){
		cin >> buf;
		if(buf%4 == 0){cnt4++;}
		if(buf%2 == 0){cnt2++;}
	}
	
	string ans = "No";
	if(n-2*cnt4 <= max(cnt2-cnt4, 1LL)){
		ans = "Yes";
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        int numOfFourMultiple = 0;
        int numOfTwoMultiple = 0;
        for (int i = 0; i < n; i++) {
            final int a = scanner.nextInt();
            if (a % 4 == 0) {
                numOfFourMultiple++;
            } else if (a % 2 == 0) {
                numOfTwoMultiple++;
            }
        }

        final int notFour = n - numOfFourMultiple - (numOfTwoMultiple >= 2 ? numOfTwoMultiple - 1 : 0);
        if (numOfFourMultiple >= notFour - 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 49064
s = gets.chomp
n = s.size

ans = Array.new(n, 0)

even_c = 0
odd_c = 0

(0..n-2).each do |i|
  if s[i] == 'R'
    if i.even?
      even_c += 1
    else
      odd_c += 1
    end
  end

  if s[i] == 'R' && s[i+1] == 'L'
    if i.even?
      ans[i] += even_c
      ans[i+1] += odd_c
    else
      ans[i] += odd_c
      ans[i+1] += even_c
    end
    even_c = 0
    odd_c = 0
  end
end

even_c = 0
odd_c = 0
j = 0
(n-1).downto(1) do |i|
  if s[i] == 'L'
    if j.even?
      even_c += 1
    else
      odd_c += 1
    end
  end

  if s[i] == 'L' && s[i-1] == 'R'
    if j.even?
      ans[i] += even_c
      ans[i-1] += odd_c
    else
      ans[i] += odd_c
      ans[i-1] += even_c
    end
    even_c = 0
    odd_c = 0
  end
  j += 1
end

puts ans.join(" ")

Measured memory_bytes: 3196
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

int ans=0;

signed main(){
    SPEED;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)
    {
        cin >> a[i];
    }

    vi b(n);
    b = a;
    RSORT(b);
    rep(i,n)
    {
        int ans;
        if(b[0]==a[i])ans=b[1];
        else ans = b[0];
        cout << ans << endl;
    }
}


Measured memory_bytes: 4736