akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n;
    cin>>n;
    pair<int,int>p[n+1];
    set<pair<int,int> >s1;
    set<pair<int,int>,greater<pair<int,int> > >s2;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].first>>p[i].second;
        s2.insert({p[i].first,i});
        s1.insert({p[i].second,i});
    }
    int tot=0;
    int x=0;
    int mx=0;
    while (!s1.empty())
    {
        auto j=s1.begin();
        int ind=j->second;
        if(!(p[ind].first<=x && p[ind].second>=x))
        {
            tot+=abs(j->first-x);
            x=j->first;
        }
        s2.erase({p[j->second].first,j->second});
        s1.erase(j);
        if(!s2.empty())
        {
            j=s2.begin();
            int ind=j->second;
            if(!(p[ind].first<=x && p[ind].second>=x))
            {
                tot+=abs(j->first-x);
                x=j->first;
            }
            s1.erase({p[j->second].second,j->second});
            s2.erase(j);
        }
    }

    tot+=abs(x);
    mx=max(mx,tot);
    tot=0;
    s1.clear();
    s2.clear();
    for(int i=1;i<=n;i++)
    {
        s2.insert({p[i].first,i});
        s1.insert({p[i].second,i});
    }
    x=0;
    while (!s2.empty())
    {
        auto j=s2.begin();
        int ind=j->second;
        if(!(p[ind].first<=x && p[ind].second>=x))
        {
            tot+=abs(j->first-x);
            x=j->first;
        }
        s1.erase({p[j->second].second,j->second});
        s2.erase(j);
        if(!s1.empty())
        {
            j=s1.begin();
            int ind=j->second;
            if(!(p[ind].first<=x && p[ind].second>=x))
            {
                tot+=abs(j->first-x);
                x=j->first;
            }
            s2.erase({p[j->second].first,j->second});
            s1.erase(j);
        }
    }
    tot+=abs(x);
    mx=max(mx,tot);
    cout<<mx;

} 
    


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

using namespace std;

#define MAX_R 50
#define MAX_C 50
#define INF (1<<29)
typedef pair<int, int> pii;

bool inField(int x, int y, int C, int R)
{
    return (0 <= x && x < C && 0 <= y && y < R);
}

int main()
{
    int R, C, M;
    char field[MAX_R][MAX_C];
    cin >> R >> C >> M;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> field[i][j];
        }
    }
    int cost[3][MAX_R][MAX_C];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < R; j++) {
            for (int k = 0; k < C; k++) {
                cin >> cost[i][j][k];
            }
        }
    }
    vector<int> X(M), Y(M);
    for (int i = 0; i < M; i++) {
        cin >> Y[i] >> X[i];
    }

    const int dx[] = {-1, 0, 1, 0};
    const int dy[] = {0, -1, 0, 1};
    
    map<pii, vector<int>> vis;
    int prev_d = 0;
    for (int i = 1; i < M; i++) {
        queue<pii> Q; Q.push(pii(X[i-1], Y[i-1]));
        vector<vector<int>> d(MAX_R, vector<int>(MAX_C, INF));
        vector<vector<int>> prev(MAX_R, vector<int>(MAX_C, INF));
        d[Y[i-1]][X[i-1]] = prev_d;
        while (!Q.empty()) {
            pii p = Q.front(); Q.pop();
            int x = p.first, y = p.second;
            if (x == X[i] && y == Y[i]) {
                prev_d = d[y][x];
                break;
            }
            for (int j = 0; j < 4; j++) {
                int nx = x + dx[j], ny = y + dy[j];
                if (!inField(nx, ny, C, R) ||
                    field[ny][nx] == '#') {
                    continue;
                }
                if (d[y][x] + 1 < d[ny][nx]) {
                    d[ny][nx] = d[y][x] + 1;
                    prev[ny][nx] = y*C + x;
                    Q.push(pii(nx, ny));
                }
            }
        }
        int x = X[i], y = Y[i];
        vis[pii(x, y)].push_back(d[y][x]);           
        while (x != X[i-1] || y != Y[i-1]) {           
            int nx = x, ny = y;
            nx = prev[y][x] % C;
            ny = prev[y][x] / C;
            x = nx; y = ny;
            vis[pii(x, y)].push_back(d[y][x]);           
        }
    }
    int sum = 0;
    for (auto &v : vis) {
        int x = v.first.first;
        int y = v.first.second;
        vector<int> p = v.second;
        sum += cost[1][y][x] + cost[2][y][x];
        if (p.size() > 1) {
            for (int i = 1; i < (int)p.size(); i++) {
                sum += min(cost[2][y][x] + cost[1][y][x], (p[i] - p[i-1]) * cost[0][y][x]);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 8120
n, m = input().split()
n = int(n)
m = int(m)
c=0

a = list(map(int, input().split()))
for i in range(n):
  c += a[i]
v = c/(4*m)
a.sort(reverse = True)
if a[m-1] < v:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

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

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  int a[20005];
  rep(i,n) cin>>a[i];
  if(n-2>=0) cout<<max(abs(w-a[n-1]),abs(a[n-1]-a[n-2]));
  else cout<<abs(w-a[n-1])<<endl;
  return 0;
}



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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int t,n;
  cin>>t>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  vector<Int> s(n+1);
  for(Int i=0;i<n;i++) s[i+1]=s[i]+(b[i]-a[i]);

  Int ans=0;
  for(Int i=0;i<n;i++){
    Int k=lower_bound(b.begin(),b.end(),a[i]+t)-b.begin();
    Int res=s[k]-s[i];
    if(k<n) res+=max((Int)0,(a[i]+t)-a[k]);
    chmax(ans,res);
    //cout<<i<<":"<<k<<":"<<res<<endl;    
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define fr(a,b,c) for(int a=b; a<=c; a++)
 
const int N=1e5+5;
const int mod=1e9+7;
 
void solve(int tt)
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    
    int min=0;
    for(int i=h1;;i++)
    {
        i%=24;
        if(i==h2)
            break;
        min+=60;
    }
    
    min+=m2;
    min-=m1;

    min-=k;
    cout<<min;

}
 
int32_t main()
{
    IOS;

    

    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve(i);
        cout<<endl;
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
#define X 10000

int main(void) {
	int n,i,a[X],min=1000000,max=-1000000;
	long int sum=0;
	scanf("%d",&n);
	if(n>0&&n<=10000){
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			if(a[i]>=-1000000&&a[i]<=1000000){
				if(a[i]<min) min=a[i];
				if(a[i]>max) max=a[i];
				sum+=a[i];
			}
		}
		printf("%d %d %ld\n",min,max,sum);	
	}
	
	
	return 0;
}



Measured memory_bytes: 2128
# -*- coding:utf-8 -*-

def solve():
    A, B = list(map(int, input().split()))

    """解説
    考え方としては、累積和みたいなかんじ
    「4~8までのxor」は、「0~8までのxor」 から 「0~3までのxor」 を引くかんじ

    A xor B = C のとき、
    A xor C = B であることに着目する

    各桁の1の数を数えれば求まる

    ・1~8のxor
    0000 | 0
    0001 | 1
    0010 | 2
    0011 | 3
    0100 | 4
    0101 | 5
    0110 | 6
    0111 | 7
    1000 | 8
    ----
    1001

    ・各桁の01の周期に着目する
    ・0桁目の周期は2
    ・1桁目の周期は4
    ・2桁目の周期は8
    ・3桁目の周期は16
    """

    def calc(a):
        # 10**3 <= 2**10 は
        # 1000  <= 1024 なので
        # 10**12 <= 2**40 (2進数で40桁くらい)
        if a <= 0: return 0

        ans = 0
        for i in range(0, 50):
            # i桁目の周期Tを調べる
            # 0桁目 -> 周期T=2
            # 1桁目 -> 周期T=4
            # 2桁目 -> 周期T=8
            T = 1 << (i+1)

            # 各桁の1の個数は
            # cnt = (ループした回数) * (1が出てくる回数)
            cnt = ((a+1)//T) * (T/2)
            # cnt += あまった1の数を足す
            cnt += max(0, ((a+1)%T) - (T/2))

            # その桁の1の数が奇数だったら足し算する
            if cnt%2 == 1:
                ans += 1 << i
        
        return ans

    ans = calc(B) ^ calc(A-1)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var n = o.a();
  var sr = o.a();
  var sc = o.a();
  var s = o.a(1);
  var t = o.a(1);
  var gr = h-sr, gc = w-sc;
  sr--, sc--;
  var l1 = 0, r1 = 0, u1 = 0, d1 = 0;
  var l2 = 0, r2 = 0, u2 = 0, d2 = 0;
  var Y = "YES", N = "NO";
  for(var i = 0; i < n; i++){
    if(s[i] === "U")u1++;
    else if(s[i] === "R")r1++;
    else if(s[i] === "D")d1++;
    else l1++;
    if(l1-r2 > sc || u1-d2 > sr || r1-l2 > gc || d1-u2 > gr)return N;
    if(t[i] === "U" && sr+d1-u2 > 0)u2++;
    else if(t[i] === "R" && gc+l1-r2 > 0)r2++;
    else if(t[i] === "D" && gr+u1-d2 > 0)d2++;
    else if(t[i] === "L" && sc+r1-l2 > 0)l2++;
  }
  return Y;
}

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

int main() {
  int n, s = 0;
  cin >> n;
  int v[n], c[n];
  REP(i, n) cin >> v[i];
  REP(i, n) {
    cin >> c[i];
    if (v[i] > c[i]) s += v[i] - c[i];
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 500;
ll sum[maxn][maxn], power[maxn][maxn];
ll a[maxn], b[maxn];
ll dp[maxn][maxn];

void init() {
    for(int i = 1; i < maxn; i++) {
        power[i][0] = 1;
        for(int j = 1; j < maxn; j++)
            power[i][j] = (power[i][j - 1] * i) % mod;
    }
    for(int i = 1; i < maxn; i++)
        for(int j = 0; j < maxn; j++) 
            sum[i][j] = (sum[i - 1][j] + power[i][j]) % mod;
}

int main() {
    int n, c;
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        cin >> b[i];
    init();
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) 
        for(int j = 0; j <= c; j++)
            for(int k = 0; k <= j; k++) {
                ll tmp = (sum[b[i]][k] - sum[a[i] - 1][k] + mod) % mod;
                dp[i][j] = (dp[i][j] + (dp[i - 1][j - k] * tmp) % mod) %mod;
            }
    cout << dp[n][c];
}

Measured memory_bytes: 5760
<?php

list($n) = fscanf(STDIN, '%d');
$a = trim(fgets(STDIN));
$a = explode(' ', $a);

foreach ($a as $v) {
    $even = $v % 2 === 0;
    if ($even) {
        if ($v % 3 === 0 || $v % 5 === 0) {
            continue;
        }

        echo 'DENIED';
        return;
    }
}

echo 'APPROVED';


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

int main() {
  int a;
  int b;
  int i;
  cin >> a;
  
  for(i = 0; i < 10; i++)
  {
    b = a - i;
    if(b%10 == 0)
    break;
  }
  
  if(b%111 == 0)
  cout << "Yes" << endl;

  else{
      for(i = 0; i < 10; i++)
      {
        b = a - 1000*i;
        if (b < 1000)
        break;
      }
      if( b%111 == 0)
      cout << "Yes" << endl;
      else
      {
        cout << "No" << endl;
      }
  }
  return 0;
}


Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#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;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("movetofront.in", "r", stdin);
//	freopen("movetofront.out", "w", stdout);
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << (count(begin(s), end(s), 'R') > count(begin(s), end(s), 'B') ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <string>
using namespace std;
double esp=1e-11;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p) memset(p,0,sizeof(p))
#define memf(p) memset(p,0x3f,sizeof(p))
#define memn(p) memset(p,-1,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef long long int LL;
const double PI = acos(-1.0);
const LL INF=0x3f3f3f3f;
const LL MOD =1e9+7;
const int maxn =10100;
int ro[510],rop[510];
int up(int u){return(ro[u]==u)?u:ro[u]=up(ro[u]);}
int p[510][2];
int w,h,n;
bool check(long double d)
{           //printf("%.3f\n",d);
    memcpy(ro,rop,sizeof(rop));
    for(int x=1;x<=n;x++)
    {
        if(p[x][0]*1.0<d)ro[up(501)]=up(x);
        if(w*1.0-p[x][0]<d)ro[up(502)]=up(x);
        if(up(501)==up(502))return 0;
        for(int y=1;y<=n;y++)
            if(x!=y&&((p[x][0]-p[y][0])*1.0*(p[x][0]-p[y][0])+(p[x][1]-p[y][1])*1.0*(p[x][1]-p[y][1]))<4*d*d)
                ro[up(y)]=up(x);
    }
    return up(501)!=up(502);
}
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("trees.in", "r", stdin);
    //freopen("trees.out", "w", stdout);
    //map<long long int,int>ma;                 %I64d
    //vector<int>::iterator iter;
    //memset(m,0,sizeof(int));               for(iter=trtr[rt].begin();iter!=trtr[rt].end();iter++)
    //for(int x=1;x<=n;x++)
    //for(int y=1;y<=n;y++)
    //scanf("%d%d",&a,&b);
    //scanf("%d",&n);
    //printf("%d\n",ans);
    scanf("%d%d%d",&w,&h,&n);
    for(int x=1;x<=n;x++)
        scanf("%d%d",&p[x][0],&p[x][1]);
    long double l=0,r=w,m;
    for(int x=0;x<=505;x++)rop[x]=x;
    for(int x=1;x<=200;x++)
    {
        m=(l+r)/2;
        if(check(m))
            l=m;
        else
            r=m;
    }
    printf("%.3f\n",(double)l);
    return 0;
}

Measured memory_bytes: 3228
#include <vector>
#include <iostream>
#include <stdio.h>


using namespace std;

#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY(byte)  \
  (byte & 0x80 ? '1' : '0'), \
  (byte & 0x40 ? '1' : '0'), \
  (byte & 0x20 ? '1' : '0'), \
  (byte & 0x10 ? '1' : '0'), \
  (byte & 0x08 ? '1' : '0'), \
  (byte & 0x04 ? '1' : '0'), \
  (byte & 0x02 ? '1' : '0'), \
  (byte & 0x01 ? '1' : '0') 

int search(int now, int path, int goal, int n, bool *paths) {
	if ( path == goal )
		return 1;

	int sum = 0;
	for(int i=0; i < n; i++) {
		bool next = paths[now * n + i];
		if (next) {
			int position = 1 << i;
			if ((path & position) == 0){
				sum += search(i, path | position, goal, n, paths);
			}
		}
	}
	return sum;
}

void solv(int n, std::vector<std::vector<int> > pairs) {
	n++;
	int path = 3;
	int goal = 0;
	for(int i=0; i < n; i++) {
		goal += 1 << i;
	}

	bool paths[n][n];
	for(int i=0; i <n; i++){
		for(int j=0; j<n+1; j++) {
			paths[i][j] = false;
}
}

for(int i=0; i < pairs.size(); i++){
	int from = pairs[i][0];
	int to = pairs[i][1];
	paths[from][to] = true;
	paths[to][from] = true;
}
    int now = 1;
	int ret = search(now, path, goal, n, &paths[0][0]);

	std::cout << ret << std::endl;
}

int main(void) {
    int N;
    std::cin >> N;
    int M;
    std::cin >> M;

    std::vector<std::vector<int> >pairs(M, std::vector<int>(2, 0));
    for(int i=0; i<M; i++) {
        std::cin >> pairs[i][0];
        std::cin >> pairs[i][1];        
    }

    solv(N, pairs);

    return 0;
}




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

int main(){
int n,b;
  cin >> n >> b;
string a[n];
for(int i=0;i<n;i++){
cin >> a[i];
}
   string f=a[0];
 for(int i=0;i<n;i++){
 for(int j=i+1;j<n;j++){
  if(a[j]<a[i]){
   f=a[j];
   a[j]=a[i];
   a[i]=f;
  }
 }
 } 
 for(int i=0;i<n;i++){
  cout << a[i];
 } 

}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
string s1,s2,s3;
int main()
{
	getline(cin,s1);
	getline(cin,s2);
	getline(cin,s3);
	int tmp(1),na(-1),nb(-1),nc(-1);
	while(1)
	{
		if(!(s1.length()-na)){putchar(65);break;}
		else if(!(s2.length()-nb)){putchar(66);break;}
		else if(!(s3.length()-nc)){putchar(67);break;}
		switch(tmp)
		{
			case 1:na++;tmp=(s1[na]-96);break;
			case 2:nb++;tmp=(s2[nb]-96);break;
			case 3:nc++;tmp=(s3[nc]-96);break;
		}
	}
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Tests = sc.nextInt();
		for (int test = 0; test < Tests; test ++) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			long l = sc.nextInt();
			long r = sc.nextInt();
			long len = (Math.max(a, b) - 1) / (Math.min(a, b) + 1) + 1;
			long lena, lenb;
			if (a >= len * b) {
				lena = a + b; lenb = 0;
			} else if (b >= len * a) {
				lena = 0; lenb = a + b;
			} else {
				lena = (len * a - b) / (len - 1);
				lenb = (len * b - a) / (len - 1);
			}
			boolean B = a - lena + lena / (len + 1) - lenb / (len + 1) == 0;
			for (long i = l - 1; i < r; ++ i) {
				char pc;
				if (i < lena) {
					if (i % (len + 1) == len) pc = 'B';
					else pc = 'A';
				}
				else if (i >= a + b - lenb) {
					if ((a + b - i - 1) % (len + 1) != len) pc = 'B';
					else pc = 'A';
				}
				else if (B) pc = 'B';
				else pc = 'A';
				System.out.print(pc);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int main() {
    int n; cin >> n;
    vector<P> data(n);
    rep(i,n) {
        int x, y; cin >> x >> y;
        data[i] = P(x,y);
    }
    map<P,int> mp;
    rep(i,n)rep(j,n) {
        if (i == j) continue;
        int x = data[i].first - data[j].first;
        int y = data[i].second - data[j].second;
        mp[P(x,y)]++;
    }
    int mx = 0;
    for (auto p : mp) chmax(mx,p.second);
    cout << n-mx << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
    int n, m, a[100][100], b[100], i, j, ans;

    scanf("%d%d", &n, &m);
    for(i = 0; i < n; i++) {
        scanf("\n");
        for(j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(j = 0; j < m; j++) {
        scanf("\n");
        scanf("%d", &b[j]);
    }

    for(i = 0; i < n; i++) {
        ans = 0;
        for(j = 0; j < m; j++) {
            ans += a[i][j] * b[j];
        }
        printf("%d\n", ans);
    }

    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[100105],a[100105],n,k;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1;i<=n;++i) cin>>a[i];
    memset(dp,0x7f,sizeof(dp));
    dp[1]=0;
    for (int i=1;i<n;++i){
    	for (int j=i+1;j<=i+k&&j<=n;++j){
    		dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
    cout<<dp[n];
    return 0; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  vecint nb(n + 1, 0);
  REP(i, n) {
    nb[i + 1] = nb[i];
    if (s[i] == 'b') nb[i + 1]++;
  }
  // REP(i, n) { cout << nb[i] << endl; }
  vector<string> ans(n, "No");
  int cnt = 0;
  REP(i, n) {
    if (s[i] == 'a') {
      if (cnt < a + b) {
        ans[i] = "Yes";
        cnt++;
      }
    } else if (s[i] == 'b') {
      if (cnt < a + b && nb[i + 1] <= b) {
        ans[i] = "Yes";
        cnt++;
      }
    }
  }
  REPe(e, ans) { cout << e << endl; }
}
////////////////////////////////////////////////


Measured memory_bytes: 6608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>

using namespace std;

using ll = long long;

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

int N;
int n[100];

int main() {
	cin >> N;
	if (N == 3 || N == 5 || N == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,a;
  cin>>n>>d>>a;
  vector<vector<int>> xh(n,vector<int>(2));
  for(int i=0;i<n;i++)
    cin>>xh.at(i).at(0)>>xh.at(i).at(1);
  sort(xh.begin(),xh.end());
  int64_t c=0;
  int64_t sa=0;
  queue<vector<int64_t>> q;
  for(int i=0;i<n;i++){
    int64_t x=xh.at(i).at(0);
    int64_t h=xh.at(i).at(1);
    while(!q.empty()){
      int64_t qx=q.front().at(0);
      int64_t qa=q.front().at(1);
      if(x>qx){
        sa-=qa;
        q.pop();
      }else
        break;
    }
    h=max(h-sa,(int64_t)0);
    c+=(h+a-1)/a;
    sa+=(h+a-1)/a*a;
    q.push({x+d*2,(h+a-1)/a*a});
  }
  cout<<c<<endl;
}

Measured memory_bytes: 25352
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	int a,b;
	string s;
	cin>>a>>b>>s;
	bool y=true;
	for(int i=0;i<a+b+1;i++){
		if(i!=a){
			if(s[i]!='0' and s[i]!='1' and s[i]!='2' and s[i]!='3' and s[i]!='4' and s[i]!='5' and s[i]!='6' and s[i]!='7' and s[i]!='8' and s[i]!='9'){
				y=false;
				break;
			}
		}
		if(s[a]!='-'){
			y=false;
			break;
		}
	}
	if(y){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3632
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
if mini == 0:
    mini = dish[0]
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    string s;
    while( cin >> s, s != "-" ){
        int m;
        cin >> m;
        rep(i, m){
            int h;
            cin >> h;
            s = s.substr(h, s.size()-1) + s.substr(0, h);
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i <= max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll L,R; cin >> L >> R;
  R = min(R, L+2019);
  int ans = 2018;
  for(ll i=L;i<=R;++i) {
    for(ll j=i+1;j<=R;++j) {
      int x = i*j%2019;
      ans = min(ans,x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
vector<ll> adj[200007] ;
ll vis[30003] ;
ll ans[30006] ,lvl[30007] ;


int main() {

    ll x , y , a , b , c ,i,j;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c) ;
    //cin >> x >> y >> a >> b >> c ;

    vector<ll>r(a) , g(b) , l(c) ;

    for(i=0;i<a;i++) scanf("%lld",&r[i]) ; //cin >> r[i] ;
    for(i=0;i<b;i++) scanf("%lld",&g[i]) ; //cin >> g[i] ;
    for(i=0;i<c;i++) scanf("%lld",&l[i]) ; // cin >> l[i] ;
    sort(r.begin(),r.end()) ;
    sort(g.begin(),g.end()) ;
    sort(l.begin(),l.end()) ;
    reverse(r.begin(),r.end()) ;
    reverse(g.begin(),g.end()) ;
    reverse(l.begin(),l.end()) ;

    multiset<ll> st ;


    for(i=0;i<x;i++)
        st.insert(r[i]) ;
     for(i=0;i<y;i++)
        st.insert(g[i]) ;

    for(i=0;i<c;i++) {
        if (*st.begin()<l[i]) {
             st.erase(st.begin()) ;
            st.insert(l[i]) ;
        }
    }
    ll ans = 0 ;

    for(auto it : st) ans+=it  ;

    cout << ans << endl ;




}


Measured memory_bytes: 15744
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#include<cstring>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;



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


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MAX = 100010;

int par[MAX];//親
int Rank[MAX];//木の深さ

			  //n要素で初期化
void init(int n) {
	REP(i, n) {
		par[i] = i;
		Rank[i] = 0;
	}
}

//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);//経路圧縮(根に直接つなぎなおす)もしつつ
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	//低いほうを高いほうにつなげる(効率化)
	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}


struct edge { int u, v, cost; };
struct vertex { int p, x, y; };

//比較関数
bool comp(const edge& e1, const edge&e2) {
	return e1.cost < e2.cost;
}
bool compX(const vertex& v1, const vertex& v2) {
	return v1.x < v2.x;
}
bool compY(const vertex& v1, const vertex& v2) {
	return v1.y < v2.y;
}

edge es[2 * MAX];
vertex ver[MAX];
int N; int E;

ll kruskal() {
	sort(es, es + E, comp);//costでソート
	init(N);
	ll res = 0;
	//コストが小さい辺から順に追加する
	REP(i, E) {
		edge e = es[i];
		//もし閉路ができなければその辺を追加する
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main() {
	cin >> N;
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		ver[i] = {i, x,y };
	}
	E = 2*(N-1);
	sort(ver, ver + N, compX);
	REP(i, N - 1) {
		es[i] = { ver[i].p,ver[i + 1].p,abs(ver[i].x - ver[i + 1].x) };
	}
	sort(ver, ver + N, compY);
	REP(i, N - 1) {
		es[N - 1 + i] = { ver[i].p,ver[i + 1].p,abs(ver[i].y - ver[i + 1].y) };
	}
	ll ans=kruskal();
	cout << ans << endl;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    int N;string S;
    cin>>N>>S;
    int res=0;
    for(int i=0;i<1000;i++){
        ostringstream str;
        str << setw(3) <<setfill('0') << i;
        string str2=str.str();
        int cnt=0;
        bool flag=false;
        for(int ii=0;ii<N;ii++){
            if(cnt==3){
                //cout<<str2<<endl;
                flag=true;
            }
            if(S[ii]==str2[cnt]){
                cnt++;
            }
        }
        if(flag||cnt==3)res++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

string str;

int calc(vector<int> vec) {
    // cout<<"size = "<<vec.size()<<endl;
    // rep(i,vec.size()) cout<<vec[i]<<" ";
    // cout<<endl;
    int res=0;
    sort(all(vec));
    rep(i,(vec.size()+1)/2) res+=(vec[i]);
    return res;
}

int pos;
int dfs() {
    // cout<<"pos = "<<pos<<endl;
    pos++;
    vector<int> vec;
    if(str[pos]!='[' && str[pos]!=']') {
        string t;
        while(str[pos]!=']') t+=str[pos++];
        pos++;
        return atoi(t.c_str())/2+1;
    }
    while(str[pos]!=']') vec.pb(dfs());

    pos++;
    return calc(vec);
}

void solve() {
    pos=0;
    cout<<dfs()<<endl;
}

int main() {
    int n;
    cin>>n;
    while(n-->0) {
        cin>>str;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;

		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] c = new long[n];
			for (int i = 0; i < n; i++) {
				c[i] = long.Parse(Console.ReadLine());
			}

			int max = 200001;
			long[] memo = new long[max];
			long[] dp = new long[n + 1];
			dp[0] = 1;
			for (int i = 0; i < n; i++) {
				if (i != 0 && c[i] == c[i - 1]) {
					dp[i + 1] = dp[i];
				} else {
					dp[i + 1] = (dp[i] + memo[c[i]]) % MOD;
					memo[c[i]] = (memo[c[i]] + dp[i]) % MOD;
				}
			}

			Console.WriteLine(dp[n]);
		}
	}
}


Measured memory_bytes: 19676
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m;
  int n;
  cin >>m >> n;
  int sumn = 0;
  REP(i,n) {
    int x;
    cin >> x;
    sumn += x;
  }
  if( m >= sumn ) {
    int ret = m - sumn;
    cout << ret << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3196
using System;

namespace Ex160425_1{
    public class Program{
        public static void Main(string[] args){
            var i = 0;
            while(true){
                var n = int.Parse(Console.ReadLine());
                if(n == 0) break;
                Console.WriteLine("Case {0}: {1}", ++i, n);
            }
        }
    }
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
int INF = 12*100000+1;

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>>key(m);
  for(int i = 0;i < m;i++){
    int a,b,s = 0;
    cin >> a >> b;
    for(int j = 0;j < b;j++){
      int c;
      cin >> c;
      c--;
      s |= 1<<c;
    }
    key[i].first = a;
    key[i].second = s;
  }
  vector<int>dp(1<<n,INF);
  dp[0] = 0;
  for(int s = 0;s < 1<<n;s++){
    for(int j = 0;j < m;j++){
      int t = s|key[j].second;
      int cost = dp[s]+key[j].first;
      dp[t] = min(dp[t],cost);
    }
  }
  int ans = dp.back();
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M;
	cin >> N >> M;

	char A[N][N];
	char B[M][M];
	string S;
	REP(i, N){
		cin >> S;
		REP(j, N) A[i][j] = S[j];
	}
	REP(i, M){
		cin >> S;
		REP(j, M) B[i][j] = S[j];
	}

	REP(k, N-M+1)REP(l, N-M+1){
		ll flag = true;
		REP(i, M)REP(j, M){
			if(A[i+k][j+l]!=B[i][j]) flag = false;
		}
		if(flag){
			//cout << k << " " << l << endl;
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl; 
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  rep(i, n-m+1) {
    rep(j, n-m+1) {
      bool ok = true;
      rep(x, m) {
        rep(y, m) {
          if(a[i+x][j+y] != b[x][y]) ok = false;
        }
      }
      if(ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3624
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        s: chars,
    }
    let mut a = vec![];
    let mut c = s[0];
    let mut cnt = 1u64;
    for &k in &s[1..] {
        if c == k {
            cnt += 1;
        } else {
            a.push((c, cnt));
            cnt = 1;
            c = k;
        }
    }
    a.push((c, cnt));
    let mut ans = 0u64;
    for &(_, cnt) in &a {
        ans += cnt * (cnt + 1) / 2;
    }
    for i in 1..a.len() {
        if a[i - 1].0 == '<' && a[i].0 == '>' {
            let c = std::cmp::min(a[i - 1].1, a[i].1);
            ans -= c;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

using namespace std;

typedef long long ll;

typedef double T;
typedef pair<int, ll> P;

typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<T> VT; 
typedef vector<VT> VVT;
typedef vector<P> VP;
typedef vector<VP> VVP;

const ll MOD = 1e9+7; // 998244353;
const T EPS = 1e-7;
const int INF = 1e4;

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve_test() {
    int l; 
    cin >> l;
    int n = 20, m = 0;
    VP edges;
    VI w;
    for (int i = 2; i < 20; ++i) {
        edges.push_back({i, i+1});
        edges.push_back({i, i+1});
        w.push_back(0);
        w.push_back(1 << (19-i));
        m += 2;
    }
    int cum = 0;
    if (l % 2) {
        ++cum;
        ++m;
        edges.push_back({1, 20});
        w.push_back(0);
    }
    for (int i = 1; i < 19; ++i) {
        if ( (l & (1 << i)) ) {
            ++m;
            edges.push_back({1, 20-i});
            w.push_back(cum);
            cum += (1 << i);
        }
    }

    if (l & (1 << 19)) {
        m += 2;
        edges.push_back({1, 2});
        edges.push_back({1, 2});
        w.push_back(l - (1 << 19));
        w.push_back(l - (1 << 18));
    }


    cout << n << " " << m << "\n";
    for (int i = 0; i < m; ++i)
        cout << edges[i].first << " " << edges[i].second << " " << w[i] << "\n"; 
}

int main() {
    srand(time(0));
    fast_io();
    solve_test();
}


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

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

int combi(int n, int r)
{
    int num = 1;
    for (int i = 1; i <= r; i++)
    {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main()
{
    int n, m;
    cin >> n >> m;
    cout << combi(n, 2) + combi(m, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,i,j,k,l;
  scanf("%d%d",&h,&w);
  char s[h][w];
  int count[h+2][w+2];
  for(i=0;i<h;i++)
    scanf("%*c%s",s[i]);
  for(i=0;i<h+2;i++)
    for(j=0;j<w+2;j++)
      count[i][j]=0;
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      if(s[i][j]=='#')
        for(k=i;k<=i+2;k++)
          for(l=j;l<=j+2;l++)
            count[k][l]++;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i-1][j-1]=='#')
        printf("#");
      else
        printf("%d",count[i][j]);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll s,func,m=1;
    cin>>s;
    vector<ll> a;
    a.push_back(s);
    while(1)
    {
        if(s%2==0)
            func = s/2;
        else if(s%2!=0)
            func = (3*s)+1;
        if(find(a.begin(), a.end(), func) != a.end())
                break;
            a.push_back(func);
            m++;
            s = func;
    }
    cout<<m+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(abs(a-c) <= d) cout << "Yes" << endl;
    else if(abs(a-b)<=d && abs(b-c)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
l = list(map(int, input().split()))
l = [-x for x in l]
heapq.heapify(l)
for i in range(m):
  a = heapq.heappop(l)
  heapq.heappush(l, a / 2)
print(-sum(int(x) for x in l))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define BR cout<<endl;
#define LEN(s) s.length();
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

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

    if(a != b and a == c )cout << "Yes" << endl;
    else if(a == b and a!=c)cout << "Yes" << endl;
    else if(b == c and b != a)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(void){
  int n,m;
  long a[100],b[100],c[100],d[100],dis[100],ans[100]={};

  scanf("%d %d",&n,&m);

  for(int i=0;i<n;i++){
    scanf("%ld %ld",&a[i],&b[i]);
    dis[i] = 1<<30;
  }
  
  for(int i=0;i<m;i++)
    scanf("%ld %ld",&c[i],&d[i]);

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      int di=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(di<dis[i]){
        dis[i]=di;
        ans[i]=j+1;
     }
    }
  }

  for(int i=0;i<n;i++)
    printf("%ld\n",ans[i]);

  return 0;
}


Measured memory_bytes: 128