akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define f first
#define sec second
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll k;
	cin>>k;
	ll res=7%k;
	for(ll i=1;i<1e7;i++)
	{
		if(res==0)
		{
			cout<<i<<endl;
			return 0;
		}
		res=(res*10+7)%k;
	}
	cout<<-1<<endl;

}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int n; cin >> n;
    cin.ignore();
        for(int i=0; i<n; ++i){
            string s; getline(cin, s);
            int m=s.size();
            for(int i=0; i<m; ++i){
                if(s[i]=='H'&&s[i+1]=='o'&&s[i+2]=='s'&&s[i+3]=='h'&&s[i+4]=='i'&&
                   s[i+5]=='n'&&s[i+6]=='o'){
                    s[i+6] ='a';
                }
            }
            cout << s <<  endl;
        }
    
    
    
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main(void){
  int n,M;
  cin >>n>>M;
  int X[M];
  for (int i=0;i<M;i++) {
    cin >> X[i];
  }
  sort(X,X+M);
  int D[M-1];
  for (int i=0;i<M-1;i++){
    D[i]=X[i+1]-X[i];
  }
  sort(D,D+M-1);
  int res=X[M-1]-X[0];
  if (n>=M){
    res=0;
  }else{
    for (int i=0;i<n-1;i++) {
      res=res-D[M-2-i];
    }
  }
  
  cout <<res<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m),suma(n+1),sumb(m+1);
    for(auto &i:a) cin>>i;
    for(auto &i:b) cin>>i;
    suma[0]=0;
    sumb[0]=0;
    ll ans = 0;
    for(int i=0; i<n; i++) suma[i+1] = suma[i] + a[i];
    for(int i=0; i<m; i++) sumb[i+1] = sumb[i] + b[i];
    for(ll i=0; i<=n; i++){
        ll tmp = k - suma[i];
        if(tmp < 0) break;
        auto border = upper_bound(sumb.begin(), sumb.end(), tmp);
        ans = max(i+(border-sumb.begin())-1,ans);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 9588
N, K = list(map(int,input().split()))
k = K - 1
H = list(map(int,input().split()))
Hs = sorted(H,reverse = True)
if K <= N:
  for i in range(0,K):
    Hs[i] = 0
  print(sum(Hs))
if K > N:
  print(0)

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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> c){
  vector<long long> as(3, LLONG_MAX);
  vector<long long> bs(3, LLONG_MAX);

  for(int i = 0; i < 3; i++){
    long long mymin = LLONG_MAX;
    for(int j = 0; j < 3; j++){
      mymin = min(mymin, c[i][j]);
      bs[j] = min(bs[j], c[i][j]);
    }

    as[i] = mymin;
  }

  long long myabs = abs((as[0] + bs[0]) - c[0][0]);
  bool isall = true;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(abs((as[i] + bs[j]) - c[i][j]) != myabs) isall = false;
    }
  }

  cout << (isall ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<std::vector<long long>> c(3, std::vector<long long>(3));
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      scanf("%lld",&c[i][j]);
    }
  }
    solve(std::move(c));
    return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

w,h,x,y = iim()
area = w*h/2

f = 1 if w/2 == x and h/2 == y else 0
print(area,f)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    string S;
  	cin>>S;
  	ll K;
  	cin>>K;
  	K--;
  	ll Sz=S.size();
  	ll F;
  	ll FF;
    rep(i, Sz){
      if(S.at(i)!='1'){
        	F=i;
        	FF=S.at(i)-'0';
        	break;
      }
    }	
  	if(K>=F){
		cout<<FF<<endl;
    }else{
  		cout<<1<<endl;
    } 
}

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


void solve(long long A, long long B, long long C, long long X){
int ans = 0;
for(int i = 0; i <= A; i++){
for(int j = 0; j <= B; j++){
for(int k = 0; k <= C; k++){
if((i * 500 + j * 100 + k * 50)==X) ans++;
}}}
cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    solve(A, B, C, X);
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <iostream>
using namespace std;
int main()
{	
	long long int n, k, a[200020], b[200020], cnta[200020] = {}, cntb[200020];
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 1) {
			cnta[b[i]] = 1;
		}
	}
	for (int i = 1; i <= k; i++) {
		if (cnta[a[i]]) {
			if (b[i] == n) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int K,X;cin>>K>>X;
  int l,u;
  l=max(-1000000,X-K+1);
  u=min(1000000,X+K-1);
  REP(i,l,u+1){
    cout<<i<<" ";
  }
  cout<<"\n";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll maxn=1e5+4;
vector<ll> g[maxn];
bool seen[maxn];

vector<ll> gres;
void dfs(ll x) {
	if (seen[x]) return;
	gres.PB(x);
	seen[x]=true;
	for (auto &y:g[x]) {
		if (!seen[y]) {
			dfs(y);
			break;
		}
	}
}

void solve(long long N, long long M, vector<long long> A, vector<long long> B){
	for (ll i=0;i<A.size();i++) {
		ll x=A[i],y=B[i];
		g[x].PB(y); g[y].PB(x);
	}
	memset(seen,0,sizeof seen);
	vector<ll> gans;
	ll x=1;
	{
		seen[x]=true;
		gres.clear();
		dfs(g[x][0]);
		reverse(gres.begin(),gres.end());
		for (auto &w:gres) gans.PB(w);
		gans.PB(x);
		gres.clear();
		for (auto &y:g[x]) {
			if (!seen[y]) {
				dfs(y);
				break;
			}
		}
		for (auto &w:gres) gans.PB(w);
	}
	printf("%lld\n",(ll)gans.size());
	for (auto &y:gans) {
		printf("%lld ",y);
	}
	printf("\n");
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> A(M-1+1);
	vector<long long> B(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	solve(N, M, A, B);
	return 0;
}



Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    string s;
    cin >> s;
    int counter[1000] = {};
    rep(i,4){
        counter[(int)s[i]]++;
    }
    int two = 0;
    rep(i,1000){
        if(counter[i]==2)two++;
    }

    if(two==2)yn;
    
    return 0;
}
 
 


Measured memory_bytes: 256
"use strict";
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 x = o.a();
  var dp = xArray(0,x+150);
  dp[0] = 1;
  var a = [100,101,102,103,104,105];
  for(var i = 0; i < x; i++){
    if(dp[i] === 0)continue;
    for(var j = 0; j < a.length; j++){
      dp[i+a[j]] = 1;
    }
  }
  return dp[x] ? 1 : 0;
}

Measured memory_bytes: 21956
n = int(input())
heigt = list(map(int, input().split()))

cost = [0] * n
cost[0] = 0
cost[1] = abs(heigt[1] - heigt[0])
if n == 2:
    print(cost[1])
else:
    cost[2] = abs(heigt[2] - heigt[0])
    if n == 3:
        print(cost[2])
    else:
        for i in range(3,n):
            cost[i] = min(cost[i-1] + abs(heigt[i] - heigt[i-1]),cost[i-2] + abs(heigt[i] - heigt[i-2]))

        print(cost[n-1])

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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  rep(i,n){
    cout << s[i] << (i == n - 1 ? "\n" : "");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int X;
    cin >> X;
    if (X < 600)
    {
        res = 8;
    }
    else if (600 <= X && X < 800)
    {
        res = 7;
    }
    else if (800 <= X && X < 1000)
    {
        res = 6;
    }
    else if (1000 <= X && X < 1200)
    {
        res = 5;
    }
    else if (1200 <= X && X < 1400)
    {
        res = 4;
    }
    else if (1400 <= X && X < 1600)
    {
        res = 3;
    }
    else if (1600 <= X && X < 1800)
    {
        res = 2;
    }
    else if (1800 <= X && X < 2000)
    {
        res = 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
from collections import *

sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += 'R'*(tx-sx)
ans += 'U'*(ty-sy)
ans += 'L'*(tx-sx)
ans += 'D'*(ty-sy)
ans += 'D'
ans += 'R'*(tx-sx+1)
ans += 'U'*(ty-sy+1)
ans += 'L'
ans += 'U'
ans += 'L'*(tx-sx+1)
ans += 'D'*(ty-sy+1)
ans += 'R'
print(ans)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
struct Num
{
	int val;
	int pos;
};

Num a[200010];

bool compare(const Num &a, const Num &b)
{
	if (a.val == b.val)
		return a.pos < b.pos;
	else
		return a.val < b.val;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(a[i].val));		
		a[i].pos = i;
	}

		
	sort(a, a + n, compare);
	int maxN = a[n - 1].val;
	int maxPos = a[n - 1].pos;
	
	if (a[n - 2].val == maxN) {
		for (int i = 0 ; i < n ; i++)
			printf("%d\n", maxN);
	}
	else {
		for (int i = 0 ; i < n ; i++)
		{
			if (i == maxPos)
			{
				printf("%d\n", a[n - 2].val);
			}
			else
			{
				printf("%d\n", maxN);
			}
		}
	}

	return 0;
}
	

Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int m,nmin,nmax;
    while(cin >> m >> nmin >> nmax,m|nmin|nmax){
        vector<int> P(m);
        rep(i,m)cin >> P[i];
        sort(P.begin(),P.end());
        reverse(P.begin(),P.end());
        int res=0,gap_max=0;
        for(int i=nmin;i<=nmax;i++){
            int gap = P[i-1]-P[i];
            if(gap>=gap_max){
                res=i;
                gap_max=gap;
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
bingo = []
sheet = set()
for _ in range(3):
  lst = [int(i) for i in input().split()]
  bingo.append(lst)
n = int(input())
for _ in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == a:
        num = 3 * i + j
        sheet.add(num)
if 0 in sheet and 1 in sheet and 2 in sheet:
  print('Yes')
elif 0 in sheet and 3 in sheet and 6 in sheet:
  print('Yes')
elif 0 in sheet and 4 in sheet and 8 in sheet:
  print('Yes')
elif 1 in sheet and 4 in sheet and 7 in sheet:
  print('Yes')
elif 2 in sheet and 5 in sheet and 8 in sheet:
  print('Yes')
elif 2 in sheet and 4 in sheet and 6 in sheet:
  print('Yes')
elif 3 in sheet and 4 in sheet and 5 in sheet:
  print('Yes')
elif 6 in sheet and 7 in sheet and 8 in sheet:
  print('Yes')
else:
  print('No')

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

int main() {
	long long N;
	long long n = 2001;

	cin >> N;
	vector<long long> x(N);
	rep(i, N) cin >> x[i];
	sort(x.begin(), x.end());
	if(N == 1) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, x[N-1]) {
		long long a = 0;
		rep(j, N) a = max(a, abs(i - x[j]));
		if(a < n) {
			n = a ;

		}
	}
	cout << n << endl;
}



Measured memory_bytes: 3120
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += cnt[a[i]];
        cnt[a[i]]++;
    }
    rep(i,n){
        cout << sum - cnt[a[i]] + 1 << endl;
    }
	return 0;
}

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

signed main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  int results[2000 - 1];
  for(int i = 0; i < n - 1; i++){
    results[i] = 0;
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      int rutePure = abs(i - j);
      int ruteXy = abs(x - i) + 1 + abs(y - j);
      int ruteYx = abs(x - j) + 1 + abs(y - i);
      int minVal = min(min(rutePure, ruteXy), ruteYx);

      results[minVal - 1]++;
    }
  }
  for(int i = 0; i < n - 1; i++){
    cout << results[i] << endl;
  }
}


Measured memory_bytes: 256
import numpy as np

def check_prime(t):
    for p in range(2, int(np.sqrt(t))+1):
        if(t % p == 0):
            return False
    return True

X = int(input())

ans = X
while(True):
    if(check_prime(ans)):
        break
    ans += 1
print(ans)

Measured memory_bytes: 19696
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}

main(){
    int n=in();
    vec a,b;
    rep(i,n)a.pb(in()),b.pb(in());
    vec id;
    rep(i,n)id.pb(i);
    sort(all(id),[&](int x,int y){return b[x]<b[y];});
    int now=0;
    for(auto e:id){
        now+=a[e];
        if(now>b[e]){cout<<"No";return 0;}
    }
    cout<<"Yes";
}

    

Measured memory_bytes: 3308
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    string str;
    cin >> n >> k >> str;
    vector<ll> ary;
#if 1
    int now = 1; //今見ている数
    int cnt = 0; //nowがいくつ並んでいるか
    for (int i = 0; i < n; i++)
    {
        if (str[i] == (char)('0' + now)) cnt++;
        else {
            ary.push_back(cnt);
            now = 1 - now; //0と1を切り替える時の計算 now ^= 1;
            cnt = 1; //新しいのをカウントし始める
        }
    }
    if (cnt != 0) ary.push_back(cnt);

    //1-0-1-0-1-0-1って感じの配列が欲しい
    //1-0-1-0みたいに0で終わってたら、適当に１つ足す
    if (ary.size() % 2 == 0) ary.push_back(0);
    if (str[0] == '0') {
        ary.push_back(0);
    }
#else
    char prev = 0;
    for (ll i = 0; (i < n); i++) {
        char curr = str[i];
        if (prev != curr) {
            prev = curr;
            ary.push_back(1);
        } else {
            ary[ary.size()-1]++;
        }
    }
    if (str[n-1] == '0') ary.push_back(0);
#endif

#if 1
        vector<int> sum(ary.size() + 1);
        for (int i = 0; i < ary.size(); i++)
        {
                sum[i + 1] = sum[i] + ary[i];
        }
#else
    vector<ll> sum(ary.size()+1, 0);
    for (ll i = 0; (i < ary.size()); ++i) {
        sum[i+1] = sum[i] + ary[i];
    }
#endif

#if 1
        int Add = 2 * k + 1;
        int maxv = 0;
        //1-0-1...の1から始めるので、偶数番目だけ見る
        for (int i = 0; i < ary.size(); i += 2)
        {
                //次のleft, rightを計算する [left, right)
                int left = i;
                int right = min(i + Add, (int)ary.size());
                int tmp = sum[right] - sum[left];

                maxv = max(tmp, maxv);
        }
#else
    ll maxv = 0;
    for(ll i = 1; (i < ary.size()); i+=2) {
        ll left = i - 1;
        ll right = min((ll)(sum.size()-1), i+(k-1)*2+1+1);
        maxv = max(maxv, sum[right] - sum[left]);
    }
#endif
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 1652
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int n, m;
int x[MAX_N], y[MAX_N];
bool need[405][405], bad[405];

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++)
        scanf("%d%d", &x[i], &y[i]);
    for (int i = 1; i <= n; i++) {
        need[i][i] = 1;
        for (int j = m; j > 0; j--) {
            if (need[i][x[j]] && need[i][y[j]]) {
                bad[i] = 1;
                break;
            } else if (need[i][x[j]]) {
                need[i][y[j]] = 1;
            } else if (need[i][y[j]]) {
                need[i][x[j]] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            if (bad[i] || bad[j])
                continue;
            bool bad = 0;
            for (int k = 1; k <= n; k++)
                if (need[i][k] && need[j][k]) {
                    bad = 1;
                    break;
                }
            if (bad)
                continue;
            ans++;
        }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P k=P(bx-ax,by-ay)*P(dx-cx,cy-dy);
    if(k.imag()==0)printf("2\n");
    else if(k.real()==0)printf("1\n");
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(){
int n,a,b,i;
scanf("%d",&n);
while(n-->0){
scanf("%d %d",&a,&b);
if(a>=0&&5>=a){
if(b>a){
for(i=a;i<b;i++)
printf("%d ",i);
printf("%d\n",b);
}
else {
for(i=a;i>b;i--)
printf("%d ",i);
printf("%d\n",b);
}
}
else {
if(b>5&&10>b&&b>a){
for(i=a;i<b;i++)
printf("%d ",i);
printf("%d\n",b);
}
else
if(b>=0&&5>=b){
for(i=a;i<10;i++)
printf("%d ",i);
for(i=5;i>b;i--)
printf("%d ",i);
printf("%d\n",b);
}
else
if(b>=6&&9>=b&&b<a){
for(i=a;i<10;i++)
printf("%d ",i);
for(i=5;i>0;i--)
printf("%d ",i);
for(i=0;i<b;i++)
printf("%d ",i);
printf("%d\n",b);
}
}
}
return 0;
}

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

int main() {

    int N, K, Q; cin >> N >> K >> Q;
    vector <int> candidates(N,0);

    if (Q >= K) {

        int winner;
        while (cin >> winner) {
                candidates[winner-1]++;
        }

        // 解答の出力
        for (int i = 0; i < N; i++) {
            if (candidates[i] > Q - K) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }

    else {
        // 解答の出力
        for (int i = 0; i < N; i++) cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}
//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(9);
    }
} All_init;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>p(n);
    vector<double>a(n,0);
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    for(ll i=0;i<n;i++){
        a[i]=(p[i]+1)/2.0; //p[i]面あるサイコロの期待値
    }
    double q=0;
    double ans=0.0;
    vector<double>sum(n+1,0.0);
    for(ll i=1;i<=n;i++){
        //cout<<a[i]<<endl;
        q+=a[i-1];
        sum[i]=q;
        //cout<<sum[i]<<endl;
    }
    for(ll i=0;i<=n-k;i++){
        ans=max(ans,(double)(sum[i+k]-sum[i]));
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 4992
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


k,q = map(int, input().split())
d = list(map(int, input().split()))

def sub(n,x,m):
    X = 0
    init = x%m
    x%=m
    if n<=k:
        for i in range(n-1):
            if x<(x+d[i])%m:
                X += 1
            x = (x+d[i])%m
        ans = X
    else:
        for i in range(k):
            if x<(x+d[i])%m:
                X += 1
            x = (x+d[i])%m
        diff = (x-init)
        ans = ((n-1)//k) * X - (init + (diff*((n-1)//k))) // m
        nn = n-((n-1)//k)*k
        xx = (init + (diff*((n-1)//k))) % m
#         if xx<init:
#             ans -= 1
        for i in range(nn-1):
            if xx<(xx+d[i])%m:
                ans += 1
            xx = (xx+d[i])%m
    return ans
#         else:
#             ans = (n//k) * X + (init + (diff*(n//k)))
ans = [None]*q
for i in range(q):
    n,x,m = map(int, input().split())
    ans[i] = sub(n,x,m)
write("\n".join(map(str, ans)))

Measured memory_bytes: 74596
import sys
X, N = map(int,input().split())
P = list(map(int,input().split()))
ans = X
d = 1
if not ans in P:
    print(ans)
    sys.exit()
while True:
    if not ans - d in P:
        print(ans - d)
        break
    if not ans + d in P:
        print(ans + d)
        break
    d += 1

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  vector<int> va;
  int a;
  long long lall=0;
  int tmp=0;
  for (long long i=0;i<N;i++){
    cin>>a;
    va.push_back(a);
    lall+=abs(a-tmp);
    tmp=a;
  }
  lall+=abs(tmp);
  cout<<lall-abs(va[0])-abs(va[1]-va[0])+abs(va[1])<<endl;
  for (long long i=1;i<N-1;i++){
    cout<<lall-abs(va[i]-va[i-1])-abs(va[i+1]-va[i])+abs(va[i+1]-va[i-1])<<endl;;
  }
  cout<<lall-abs(va[N-1]-va[N-2])-abs(va[N-1])+abs(va[N-2])<<endl;

}


Measured memory_bytes: 1784
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len();
    if s[0] != '1' || s[n - 1] != '0' || s[n - 2] != '1' {
        println!("-1");
        return;
    }
    let mut cnts = vec![0; n];
    let mut parents = vec![0; n];
    let mut p = 0;
    for t in 1..n {
        parents[t] = p;
        cnts[p] += 1;
        if s[t - 1] == '1' {
            p = t;
        } else {
            //
        }
    }
    let mut visits = vec!['0'; n];
    let mut cnt = 0;
    let mut pos = n - 1;
    while pos != 0 {
        cnt += cnts[pos];
        visits[cnt] = '1';
        pos = parents[pos];
    }
    // println!("{:?}", parents);
    // println!("{:?}", visits);
    if s == visits {
        for i in 1..n {
            println!("{} {}", parents[i] + 1, i + 1);
        }
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 7548
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(5e10 + 1)


def generate_adj_matrix(v_info):
    for each in v_info:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_matrix[v_index][pair[0]] = pair[1]

    return init_adj_matrix


def dijkstra_path():
    # path search init
    path_list[init_vertex_index] = 0
    path_heap = []
    # heapq: rank by tuple[0], here ranked by d[u]
    hp.heappush(path_heap, (0, init_vertex_index))
    while len(path_heap) >= 1:
        current_vertex_index = hp.heappop(path_heap)[1]

        color[current_vertex_index] = BLACK

        current_vertex_index_info = adj_table[current_vertex_index]
        for adj_vertex_index in current_vertex_index_info.keys():
            current_adj_weight = current_vertex_index_info.get(adj_vertex_index)
            if color[adj_vertex_index] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = path_list[current_vertex_index] + current_adj_weight
                if alt_path < path_list[adj_vertex_index]:
                    # update path_list
                    path_list[adj_vertex_index] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex_index))
                    parent_list[adj_vertex_index] = current_vertex_index
                    color[adj_vertex_index] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    init_vertex_index = 0

    adj_table = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 62864
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

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

int w, h;

void fill( vector<char> &f, char c, char ch, int x, int y ){
	f[y*w+x] = ch;
	if( x>0   && f[y*w+(x-1)]==c )	fill( f, c, ch, x-1, y );
	if( x+1<w && f[y*w+(x+1)]==c )	fill( f, c, ch, x+1, y );
	if( y>0   && f[(y-1)*w+x]==c )	fill( f, c, ch, x, y-1 );
	if( y+1<h && f[(y+1)*w+x]==c )	fill( f, c, ch, x, y+1 );
}

int main(){
	vector<char> field;
	queue< vector<char> > que;
	while( cin >> w >> h, w||h ){
		while(!que.empty())	que.pop();
		field.resize(w*h+1);
		rep(y,h)  rep(x,w)	cin >> field[y*w+x];
		field[w*h] = 0;
		que.push(field);

		while(!que.empty()){
			field = que.front();
			que.pop();

			int i=1;
			for(; i<w*h; i++)
				if(field[i]!=field[0])	break;
			if(i==w*h){
				cout << (int)field[w*h] << endl;
				break;
			}
			
			if( field[0] != 'R' ){
				vector<char> f = field;
				fill( f, field[0], 'R', 0, 0 );
				f[w*h]++;
				que.push(f);
			}
			if( field[0] != 'G' ){
				vector<char> f = field;
				fill( f, field[0], 'G', 0, 0 );
				f[w*h]++;
				que.push(f);
			}
			if( field[0] != 'B' ){
				vector<char> f = field;
				fill( f, field[0], 'B', 0, 0 );
				f[w*h]++;
				que.push(f);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 33480
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define rep(i, m) for(int i = 0; i < (int)(m); i++)
#define rep2(j, n) for(int j = 0; j < (int)(n); j++)

int main()
{
    INIT;

    int m;
    cin >> m;

    cout << 24 - m + 24 << endl;
    return 0;
}

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

int main(){
    long long n,ansx,ansy,ansh;
    cin >> n;
    long long x[n+10],y[n+10],h[n+10];
    long long maxh=1;

    //入力
    for(int i =0;i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
        maxh = max(maxh,h[i]);
    }

    for(long long nx = 0;nx<=100;nx++){
        bool flagx = false;
        for(long long ny = 0;ny<=100;ny++){
            bool flagy = false;
            for(long long nh = maxh;nh <= maxh + 100;nh++){
                bool correct = true;
                for(int i = 0;i<n;i++){
                    if(h[i] != max(nh-abs(x[i]-nx)-abs(y[i]-ny),(long long)0)) correct = false;
                }
                if(correct){
                    flagy = true;
                    ansx = nx;
                    ansy = ny;
                    ansh = nh;
                }
            }
            if(flagy) flagx = true;
        }
        if(flagx) break;
    }

    cout << ansx << " " << ansy << " " << ansh <<endl;
}

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

int main() {
  long N=0,i,j,k,l,tmp=0,tmpcount=0,max=10000000000;
  scanf("%ld", &N);
  //  long numdistance = N*(N-1)/2;
  long numdistance = N*N;
  long x[N],y[N],distance[numdistance][2],p,q;
  for(i=0;i<N;i++){
    scanf("%ld%ld", &x[i], &y[i]);    
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(i!=j){
	//	distance[tmp][0]=abs(x[i]-x[j]);
	//	distance[tmp][1]=abs(y[i]-y[j]);
	//      printf("  %ld %ld\n",distance[tmp][0],distance[tmp][1]);
	p=x[i]-x[j];
	q=y[i]-y[j];
	tmp++;
	tmpcount=N;
	for(k=0;k<N;k++){
	  for(l=0;l<N;l++){
	    if(x[k]-p==x[l] && y[k]-q==y[l]){
	      tmpcount--;
	    }
	  }
	}
	if(tmpcount<max){
	  max=tmpcount;
	}
      }
    }
  }
  /*
  for(i=0;i<numdistance-1;i++){
    tmpcount=0;
    for(j=i+1;j<numdistance;j++){
      if(i!=j){
	if(distance[i][0]==distance[j][0]&&distance[i][1]==distance[j][1]){
	  tmpcount++;
	}
      }
    }
    if(tmpcount>max){
      max=tmpcount;
    }
  }
  */
  if(N==1){
    printf("%ld\n",N);
  }
  else{
    printf("%ld\n",max);
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string one, two;
    cin >> one >> two;
    int dp[1002][1002];
    rep(i, one.size()) {
      rep(j, two.size()) {
        if (one[i] == two[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
      }
    }

    cout << dp[one.size()][two.size()] << endl;
  }

  return 0;
}


Measured memory_bytes: 7120
#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++)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep(i, n) {
        s[i] = (s[i] != s[k - 1]) ? '*' : s[i];
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

import static java.lang.Long.parseLong;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(in.readLine());
        long a = parseLong(st.nextToken()), b = parseLong(st.nextToken());
        long c = parseLong(st.nextToken()), d = parseLong(st.nextToken());

        pw.println(solve(a,b,c,d));
        pw.close();

    }

    static long solve(long a, long b, long c, long d) {
        ArrayList<Long> list = new ArrayList<>();

        list.add((a * c));
        list.add((b * d));
        list.add((a * d));
        list.add((b * c));

        return Collections.max(list);
    }
}

Measured memory_bytes: 32764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef complex<int> ci;
typedef complex<double> cd;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define ins insert
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define FORI(a, b) for (auto(a) = (b).begin(); (a) != (b).end(); ++(a))
#define ROFI(a, b) for (auto(a) = (b).rbegin(); (a) != (b).rend(); ++(a))
#define CEIL(a, b) ((a) + (b)-1) / (b)
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

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

    int n;
    cin >> n;
    vi digits(10, 0);
    int hdigit = 0;
    while (n--) {
        int changeDigit = -1;
        for (int i = 0; i < hdigit; ++i) {
            if (digits[i] < 9 && abs(digits[i + 1] - digits[i] - 1) <= 1) {
                changeDigit = i;
                break;
            }
        }
        if (changeDigit == -1) {
            if (digits[hdigit] < 9)
                changeDigit = hdigit;
            else
                changeDigit = ++hdigit;
        }
        ++digits[changeDigit];
        for (int i = changeDigit - 1; ~i; --i)
            digits[i] = max(0, digits[i + 1] - 1);
    }
    int first = 9;
    while (digits[first] == 0) --first;
    R0F (i, first)
        cout << digits[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
cnt=0
d=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
    if cnt>=3:
        break
    else:
        if i==0:
            if d[i][0]==d[i][1]:
                cnt+=1
        else:
            if d[i-1][0]!=d[i-1][1]:
                cnt=0
                if d[i][0]==d[i][1]:
                    cnt+=1
            else:
                if d[i][0]==d[i][1]:
                    cnt+=1
if cnt>=3:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main ()
{
    int K, N;
    cin >> K;
    cin >> N;
    vector<int> A;
    for (int n = 0; n < N;n++){
        int a;
        cin >> a;
        A.push_back(a);
    }

    sort(A.begin(), A.end());
    int minpath;
    minpath = min(A.at(N - 1) - A.at(0), K - (A.at(1) - A.at(0)));
    for (int n = 1; n < N - 1; n++)
    {
        int path = min(K - (A.at(n) - A.at(n - 1)), K - (A.at(n + 1) - A.at(n)));
        if(path<minpath){
            minpath = path;
        }
    }
    cout << minpath << endl;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

struct Card {
    char suit;
    int value;
};

bool operator==(const Card& lhs, const Card& rhs) {
    return (lhs.suit == rhs.suit && lhs.value == rhs.value);
}

bool isStable(Card in[], Card out[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            for (int a = 0; a < N; a++) {
                for (int b = a+1; b < N; b++) {
                    if (in[i].value == in[j].value && in[i] == out[b] && in[j] == out[a]) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

void trace(Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

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

    Card in[N], out1[N], out2[N];
    for (int i = 0; i < N; i++) {
        cin >> in[i].suit >> in[i].value;
    }

    for (int i = 0; i < N; i++) {
        out1[i] = in[i];
        out2[i] = in[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = N-1; j >= i + 1; j--) {
            if (out1[j].value < out1[j-1].value) {
                swap(out1[j], out1[j-1]);
            }
        }
    }

    trace(out1, N);
    if (isStable(in, out1, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (out2[j].value < out2[minj].value) {
                minj = j;
            }
        }
        swap(out2[i], out2[minj]);
    }

    trace(out2, N);
    if (isStable(in, out2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if (A == B && B != C){
    cout << "Yes";
  } else if (B == C && C != A){
    cout << "Yes";
  } else if (C == A && A != B){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        a[i]-=i+1;
    }
    sort(a.begin(),a.end());
    int k = a[n/2];
    ll ans = 0;
    rep(i,n){
        ans += abs(a[i]-k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range (N):
  a = input()
  if a == 'AC':
    AC += 1
  elif a == 'WA':
    WA += 1
  elif a == 'TLE':
    TLE += 1
  elif a == 'RE':
    RE += 1
print('AC','x',AC)
print('WA','x',WA)
print('TLE','x',TLE)
print('RE','x',RE)

Measured memory_bytes: 9208
#include <stdio.h>
#define M 100
int main(void)
{
    int A, B;
    (void)scanf("%d %d", &A, &B);
    A--;
    B--;
 printf("%d %d\n", M, M);
 for (int h = 0; h < M / 2; h++)
    {
        for (int w = 0; w < M; w++)
        {
            if (A > 0 && h % 2 == 0 && w % 2 == 0)
            {
                printf(".");
                A--;
            }
            else
            {
                printf("#");
            }
        }
        puts("");
    }
    for (int w = 0; w < M; w++)
        printf(".");
    puts("");
    for (int h = M / 2 + 1; h < M; h++)
    {
        for (int w = 0; w < M; w++)
        {
            if (B > 0 && h % 2 == 0 && w % 2 == 0)
            {
                printf("#");
                B--;
            }
            else
            {
                printf(".");
            }
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include<cstdio>
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 pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

bool A[200001];

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

	//かしこいなぁ
	int N = getint(), M = getint();
	int ikeru = 0;
	rep(i, M) {
		int a = getint(), b = getint();
		if (a == 1) {
			if (A[b]) ikeru = 1;
			else A[b] = 1;
		}
		if (b == N) {
			if (A[a]) ikeru = 1;
			else A[a] = 1;
		}
	}

	if (ikeru) printf("POSSIBLE");
	else printf("IMPOSSIBLE");

	Would you please return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>

int main() {
    int N;
    std::cin >> N;
    std::set<int> s;
    for (int i = 0; i < N; ++i) {
        int e;
        std::cin >> e;
        s.insert(e);
    }

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        std::cout << s.count(k) << std::endl;
    }
}



Measured memory_bytes: 7752
#include<iostream>
using namespace std;
int main() {
	char s[7];
	bool flag = false;
	cin >> s;
	if (s[2] == s[3])
		if (s[4] == s[5])
			flag = true;
	if (flag == true)
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#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

vector<pair<int, int>> A[100001];
ll zahyou[100001];
int dame;

void sagasu(int i, ll X) {
	if (zahyou[i] == 0) {
		zahyou[i] = X;
		for (pair<int, int> P : A[i]) {
			sagasu(P.first, X + P.second);
		}
	}
	else if (zahyou[i] != X) {
		dame = 1;
	}
}



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

	int N, M;
	cin >> N >> M;


	rep(i, M) {
		int L, R, D;
		cin >> L >> R >> D;
		A[L].push_back(make_pair(R, D));
		A[R].push_back(make_pair(L, -D));
	}


	rep1(i, N) {
		if(zahyou[i] == 0) sagasu(i, 2000000000);
	}
	if (dame) co("No");
	else co("Yes");

	Would you please return 0;
}

Measured memory_bytes: 11520
# Here your code !
i=0

n=gets.to_i
h=Hash.new(0)
a=gets.split(" ")

n.times{
    h[a[i]]+=1
    i+=1
}

i=0

m=gets.to_i
hh=Hash.new(0)
a=gets.split(" ")

m.times{
    hh[a[i]]+=1
    i+=1
}

i=0

m.times{
    if hh[a[i]]>h[a[i]]
        print("NO")
        exit
    else
        i+=1
    end
}


print("YES")




Measured memory_bytes: 66580