akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, s;
    long long sum, sqsum;
    while (true) {
        scanf("%d",&n);
        if (n == 0) break;
        sum = 0;
        sqsum = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%d",&s);
            sum += s;
            sqsum += s * s;
        }
        double avg = double(sum) / n, a2 = double(sqsum) / n - avg * avg, a = sqrt(a2);
        printf("%lf\n",a);
    }
    return 0;
}



Measured memory_bytes: 2612
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        int n = yomi.nextInt();
        int m = yomi.nextInt();
        int a = 0;
        for (int i =0;i<m;i++){
            a += yomi.nextInt();
        }
        System.out.println(n-a>=0 ? n-a : -1);

    }
}

Measured memory_bytes: 46424
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r * g * b

for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            continue
        k = 2*j - i
        if k >= n or s[k] == s[i] or s[k] == s[j]:
            continue
        ans -= 1
        
print(ans)

Measured memory_bytes: 9120
#include <stdio.h>
int main() {char *ans[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};int i,j,today[12]={4,0,1,4,6,2,4,0,3,5,1,3};while (1) {scanf("%d %d",&i,&j);if (!i && !j) return 0;puts(ans[(today[i-1]+j-1)%7]);}return 0;}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	int N; cin >> N;
    vec a(N);
    rep(i, N){
        cin >> a[i];
    }
    vec b = a;
    sort(all(b), greater<int>());
    rep(i, N){
        if(a[i] == b[0]){
            cout << b[1] << endl;
        }else{
            cout << b[0] << endl;
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	IOS;
	string s,t;
	cin >> s >> t;
	int flag = 0;
	for(int i = 0; i < 110; i++){
		for(int j = 0; j < 110; j++){
			if(s[(i+j)%s.size()] != t[j%t.size()]) break;
			if(j == 100) flag = 1;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int r, g, b, n, ans=0; cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i += r) {
		for (int j = 0; i+j <= n; j += b) {
			if ((n - i - j) % g == 0)ans++;
		}
	}cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int amari = N % 10;
  if(amari == 3) {
  	cout << "bon" << endl;
  }else if (amari == 0 || amari == 1 || amari == 6 || amari == 8) {
  	cout << "pon" << endl;
  }else {
  	cout << "hon" << endl;
  } 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll a, b;    cin >> a >> b;
    cout << a*b << endl;

}


Measured memory_bytes: 3568
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

#define spc " "
#define com ", "

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;

//------

int main(){
    int n;
    cin >> n;
    
    int tp, tc, cnt = 0, ans = 0;
    cin >> tc;
    for(int i = 1; i < n; i++){
        tp = tc;
        cin >> tc;
        cnt = (tc == tp ? cnt + 1 : 0);
        if(cnt % 2 == 1) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

int main(){
	fast_io();
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s;
	cin >> s;
	for(int i = a+1; i <= c; i++){
		if(s[i] == '#' and s[i-1] == '#'){
			cout << "No";
			return  0;
		}
	}
	for(int i = b+1; i <= d; i++){
		if(s[i] == '#' and s[i-1] == '#'){
			cout << "No";
			return  0;
		}	
	}
	if(c < d){
		cout << "Yes";
		return  0;
	}
	for(int i = b; i <= d; i++){
		if(s[i] == '#') continue;
		if(i == 0 or i == n-1)	continue;
		if(s[i-1] == '#' or s[i+1] == '#')	continue;
		cout << "Yes";
		return  0;
	}
	cout << "No";
	return  0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int a[114514];
int ans[114514];
signed main(){
	ic(n)
	ic(a) ic(b)
	if((a-b)%2==0)c(abs(a-b)/2)
	else{
		int s=min(min(a,b)-1,n-max(a,b));
		if(s==a-1)c(s+(b+1-s)/2)
		else if(s==b-1)c(s+(a+1-s)/2)
		else if(s==n-a)c(s+(n-(s+b)+1)/2)
		else c(s+(n-(s+a)+1)/2)
	}	
}	

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define deb(x) cout<<#x <<" = "<<x<<"\n";
using namespace std; 

signed main() 
{
	//freopen("input.txt", "r", stdin);
	
	int n, k; cin>>n>>k;
	string s; cin>>s;
	s[k-1] += 26 + 6;
	cout<<s<<"\n";
	
	
	
	
	
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    String[] gs = new String[6];
    for (int ii = 0; ii < gs.length; ii++) {
      gs[ii] = String.format("%d:", ii + 1);
    }
    for (int ii = 0; ii < n; ii++) {
      double h = scanner.nextDouble();
      if (h < 165) {
        gs[0] += "*";
      } else if (165 <= h && h < 170) {
        gs[1] += "*";
      } else if (170 <= h && h < 175) {
        gs[2] += "*";
      } else if (175 <= h && h < 180) {
        gs[3] += "*";
      } else if (180 <= h && h < 185) {
        gs[4] += "*";
      } else if (185 <= h) {
        gs[5] += "*";
      }
    }
    for (int ii = 0; ii < gs.length; ii++) {
      System.out.println(gs[ii]);
    }
  }
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        swap(a,b);
        swap(a,c);
        d3(a,b,c);
    }
    return 0;
}


















Measured memory_bytes: 256
using System;

class P{
public static void Main()
{

            //????????????????????????
            int second = Int32.Parse(Console.ReadLine());

            //?????°??£?¨?
            int H;          //??????
            int M;          //???
            int S;          //?§?

            H = second / 3600;
            M = (second - (H * 3600)) / 60;
            S = second - (H * 3600 + M * 60);

            //??¨???
            Console.WriteLine(H + ":" + M + ":" + S);
}
}

Measured memory_bytes: 9200
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}


int main() {

	ll num;
	int cnt = 0;
	cin >> num;
	
	while (1) {
		if (IsPrime(num + 1 * cnt)) {
			cout << num + 1 * cnt << endl;
			break;
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int W , H, x , y, r;
cin >> W >> H >> x >> y >> r ;
if(0 <= x - r &&  x + r <= H && 0 <= y - r && y + r <= H)
cout << "Yes" << endl ;
else cout << "No" << endl ;


return 0;}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int n, a[100];
	cin >> n;
	int sum = 0;
	FORI(0, n) {
		cin >> a[i];
		sum += a[i];
	}
	int ans;
	sort(a, a + n);
	if(sum%10!=0)
		ans = sum;
	else {
		bool flg = false;
		FORI(0, n) {
			if (a[i] % 10 != 0) {
				sum -= a[i];
				flg = true;
				break;
			}
		}
		if (flg)
			ans = sum;
		else
			ans = 0;
	
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter


def same_group():
    class UnionFind(object):
        def __init__(self, n):
            self.par = [i for i in range(n)]
            self.rank = [0 for _ in range(n)]

        def find(self, x):
            if self.par[x] != x:
                self.par[x] = self.find(self.par[x])
            return self.par[x]

        def unite(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

        def is_same_group(self, x, y):
            return self.find(x) == self.find(y)

    N, M, K = map(int, input().split())

    uf = UnionFind(N)
    friends = {i: 0 for i in range(N)}
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if uf.find(a) != uf.find(b):
            uf.unite(a, b)

        friends[a] += 1
        friends[b] += 1

    for i in range(N):
        uf.find(i)

    num_per_group = Counter(uf.par)

    blocks = {i: 0 for i in range(N)}
    for _ in range(K):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        if uf.par[c] == uf.par[d]:
            blocks[c] += 1
            blocks[d] += 1

    print(*[max(num_per_group[uf.par[i]] - friends[i] - blocks[i] - 1, 0) for i in range(N)])


same_group()


Measured memory_bytes: 119468
x,y = map(int,input().split())

t = list(map(int,input().split()))

if x-y <= 0:
    print(1)
    exit()
else:
    x -= y

if x%(y-1)!=0:
    print(2+x//(y-1))
else:
    print(1+x//(y-1))

Measured memory_bytes: 52652
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    int W[N];
    int S[N];
    for(int i=0; i<N; ++i){
        std::cin >> W[i];
        if(i==0){
            S[i] = W[i];
            continue;
        }
        S[i] = S[i-1] + W[i];
    }

    std::vector<int> R(N);
    for(int i=0; i<N; ++i){
        R[i] = std::abs( (S[N-1]-S[i]) - S[i] );
    }
    std::cout << *std::min_element(R.begin(),R.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
struct A {
	int w, v;
};
bool operator<(A a, A b) {
	if (a.w != b.w) return a.w < b.w;
	return a.v > b.v;
}
A a[40], b[2][1100000];
int n, w, sum[2];
void solve(int i, int v, int w, int end, int c) {
	if (i == end) {
		b[c][sum[c]] = A{ w,v };
		sum[c]++;
		return;
	}
	solve(i + 1, v + a[i].v, w + a[i].w, end, c);
	solve(i + 1, v, w, end, c);
}
signed main() {
	cin >> n >> w;
	for (int i = 0; i < n; i++)
		cin >> a[i].v >> a[i].w;
	solve(0, 0, 0, n / 2, 0);
	solve(n / 2, 0, 0, n, 1);
	sort(b[0], b[0] + sum[0]);
	sort(b[1], b[1] + sum[1]);
	int r = -1, y = sum[0];
	for (int i = 0; i < sum[0]; i++) {
		if (r >= b[0][i].v) {
			b[0][i].w = inf;
			y--;
		}
		else
			r = b[0][i].v;
	}
	sort(b[0], b[0] + sum[0]);
	int ans = 0;
	for (int i = 0; i < sum[1]; i++) {
		int k = lower_bound(b[0], b[0] + y, A{ w - b[1][i].w,0 }) - b[0];
		if (k > 0) k--;
		if (b[0][k].w + b[1][i].w <= w) 
			ans = max(ans, b[0][k].v + b[1][i].v);
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 35948
import numpy as np
n=int(input())
s=[chr(i) for i in range(97, 97+26)]
 
aa_cij=np.array([[s.index(i)+1  for i in list(input())] for _ in range(n)],dtype='int8')
z=np.zeros((n,n),dtype='int8')
ans=0
for i in range(n):
  aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)
  if np.allclose(aa_cij - aa_cij.T, z ):
    ans+=1 
print(ans*n)

Measured memory_bytes: 15240
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;

int a[maxn];

int main()
{
    fast;
    int n , co = 0;
    cin >> n;

    for(int i = 1; i<=n; i++)cin >> a[i];

    int cur = 1;
    for(int i = 1; i<=n; i++){
        if(a[i] == cur)cur++;
    }
    if(cur == 1) cout << -1 << endl;
    else cout << (n-(cur-1)) << endl;
    return 0;
}
/*



*/



Measured memory_bytes: 1024
#include<stdio.h>
int N=100;
int main(){
  int n,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  int i,l,k;
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
for(i=1;i<=n;i++)m[i][i]=0;
for(l=2;l<=n;l++){
  for(i=1;i<=n-l+1;i++){
    int j=i+l-1;
    m[i][j]=(1<<21);
    for(k=i;k<=j-1;k++){
      if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
  }
}
printf("%d\n",m[1][n]);
return 0;
}



Measured memory_bytes: 2116
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
const int MAXN=int(2e6+5);
#define INF LL(1e18)
typedef long long LL;
int n;
LL k;
int a[MAXN];
int cnt[MAXN];
int st[MAXN],ed[MAXN];
struct node {
    int last,nxt;
    int l;
}t[MAXN];
int main()
{
    //freopen("dnd.in","r",stdin);
    //freopen("dnd.out","w",stdout);
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
        ed[a[i]]=i;
        if(!st[a[i]])
            st[a[i]]=i;
    }
    if(n==1) {
        if(k%2)
            printf("%d",a[1]);
        else
            puts("");
        return 0;
    }
    for(int i=1;i<=n;i++) {
        if(t[a[i]].last) {
            t[t[a[i]].last].nxt=(i+1)%n;
            if(!t[t[a[i]].last].nxt)
                t[t[a[i]].last].nxt=n;
        }
        t[a[i]].last=i;
    }
    for(int i=1;i<=n;i++) {
        if(!t[i].nxt) {
            if(st[a[i]]!=i)
                t[i].nxt=st[a[i]]+1;
            else {
                if(i==n)
                    t[i].nxt=1;
                else
                    t[i].nxt=i+1;
            }
        }
    }
    for(int i=1;i<=n;i++) {
        int q=t[i].nxt;
        if(q-i>=2)
            t[i].l=q-i;
        else
            t[i].l=n+(q-i);
    }
    if(t[n].nxt==1)
        t[n].l=n+1;
    LL nmzl=0;
    int x=1;
    do {
        nmzl+=(LL)t[x].l;
        x=t[x].nxt;
    }while(x!=1);
    LL S=nmzl/n;
    k%=S;
    if(!k) {
        puts("");
        return 0;
    }
    int ncnt=1;x=1;
    do {
        if(t[x].nxt>=x+2) {
            x=t[x].nxt;
            continue;
        }
        if(ncnt==k) {
            if(t[x].nxt==1&&x!=n)
                return 0;
			printf("%d ",a[x]);
			if (x==n)
				return 0;
			x++;
        }
        else {
            ncnt++;
            x=t[x].nxt;
        }
    }while(1);
}

Measured memory_bytes: 15744
#include <stdio.h>
int main(void){
  int i=0;
  int s=0;
  char num[5];
  scanf("%s",num);
  while(num[i]){
    if(num[i]=='7') s=1;
    i++;
  }
  if(s==1) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <set>
using namespace std;

#define INF 1e9


bool solve( set<int> x, vector<vector<int> > &g, int from ){
	if(x.size() == 4) return true;
	if(x.size() > 4) return false;
	bool flag = false;
	for(int to=0; to<4; ++to){
		if( 1 == g[from][to] ){
			if( x.find(from) != x.end() && x.find(to) == x.end()){
				set<int> bakX = x;
				x.insert(to);
				flag |= solve( x, g, to );
				x = bakX;
			}
		}
	}
	return flag;
}

int main(void){
	int a[3],b[3];
	

	vector<vector<int> > g(4);
	
	for(int i=0;i<4;++i){
		g[i].reserve(4);
		for(int j=0;j<4;++j) g[i][j] = INF;
	}
	
	cin >> a[0] >> b[0];
	cin >> a[1] >> b[1];
	cin >> a[2] >> b[2];
	g[ a[0] - 1 ][ b[0] - 1 ] = 1;
	g[ a[1] - 1 ][ b[1] - 1 ] = 1;
	g[ a[2] - 1 ][ b[2] - 1 ] = 1;
	g[ b[0] - 1 ][ a[0] - 1 ] = 1;
	g[ b[1] - 1 ][ a[1] - 1 ] = 1;
	g[ b[2] - 1 ][ a[2] - 1 ] = 1;
	
	

	
	bool ans = false;
	set<int> x0,x1,x2,x3;
	x0.insert(0);
	x1.insert(1);
	x2.insert(2);
	x3.insert(3);
	ans |= solve( x0, g, 0 );
	ans |= solve( x1, g, 1 );
	ans |= solve( x2, g, 2 );
	ans |= solve( x3, g, 3 );
	
	cout << (ans ? "YES" : "NO") << endl;
	
	
	return 0;
}


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

using namespace std;

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

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

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, d;
  cin >> n >> d;
  int X[20][20];
  rep(i, n) rep(j, d) cin >> X[i][j];

  int ans = 0;
  rep(i, n - 1) {
    FOR(j, i + 1, n) {
      int dist = 0;
      rep(p, d) { dist += pow(X[i][p] - X[j][p], 2); }
      rep(p, 17000) {
        if (dist == p * p) {
          ans++;
          break;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int mod = 1e9 + 7;
struct mint {
  // https://github.com/atcoder-live/library/blob/master/mint.cpp
  ll x;
  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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 inv
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> A(27);
  REP(i, S.size()) { A[S[i] - 'a']++; }
  struct mint m(1);
  REP(i, 26) { m.x = (m * (A[i] + 1)).x; }
  cout << (m - 1).x << endl;
}

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

using namespace std;

int N, M;
bool like[30]; // 全員が好き

int main()
{
    cin >> N >> M;
    for(int i=0; i<M; i++){
        like[i] = true;
    }

    for(int i=0; i<N; i++){
        int k;
        int a;
        bool flag[30];
        for(int j=0; j<M; j++) flag[j] = false;
        cin >> k;
        for(int j=0; j<k; j++){
            cin >> a;
            flag[a-1] = true;
        }
        for(int j=0; j<M; j++){
            if(flag[j] == false) like[j] = false;
        }
    }

    int cnt = 0;
    for(int j=0; j<M; j++) {
        if(like[j]) cnt++;
    }

    cout << cnt;
}

Measured memory_bytes: 256
c = [list(map(int,input().split())) for i in range(3)]
ans = "No"
if all([all([c[i][j]-c[i][j+1]==c[i+1][j]-c[i+1][j+1] for i in range(2)]) for j in range(2)]):
    if all([all([c[i][j]-c[i+1][j]==c[i][j+1]-c[i+1][j+1] for i in range(2)]) for j in range(2)]):
        ans = "Yes"
print(ans)

Measured memory_bytes: 3064
n = int(input())

dp=[0]
#dp[n]を求める

for i in range(1,n+1):
    c = []
    c.append(dp[i-1]+1)
    p6=1
    while i >=6**p6:
        c.append(dp[i-6**p6]+1)
        p6 +=1

    p9=1
    while i >=9**p9:
        c.append(dp[i-9**p9]+1)
        p9 +=1

    dp.append(min(c))

print(dp[n])

Measured memory_bytes: 9696
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x) make_pair(x)

using namespace std;
using ll=long long;

int main() {
  int n;char s;
  cin >> n >> s;
  deque<char> col;

  col.pb(s);
  reps(i,n-1){
    char c;cin >> c;
    if(col.back()!=c)col.pb(c);
  }
  cout << col.size();
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vi a(n);
	ll curxor = 0;
	f(i, 0, n - 1) {
		cin >> a[i];
		curxor ^= a[i];
	}
	f(i, 0, n - 1) {
		cout << (curxor ^ a[i]) << " ";
	}
	//cout << sum << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 4764
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define INF 1e18
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6],dp[10009][109];
ll power(ll x,ll n)
{   if(n==0||x==0) return 1;
    else if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=MAX;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll pred(ll i,ll a,ll b){
    return (i/a)+(i/b)-(i/(a*b));
}
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,n,a,b,l,r,ans,test,sum;
    test=1;
    while(test--){
        cin>>n;
        ans=0;
        for(i=1;i<=n;i++){
            cin>>l>>r;
            ans+=r-l+1;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,q,z;
    string s;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            vector<vector<int>> vec(21,vector<int>(21,0));
            for (int i=0;i<n;i++) {
                cin>>a>>b;
                vec.at(b).at(a)=1;
            }
            int count=0,x=10,y=10;
            cin>>q;
            for (int j=0;j<q;j++) {
                cin>>s;
                if (s=="N") {
                    cin>>z;
                    for (int k=0;k<z;k++) {
                        y++;
                        if (vec.at(y).at(x)==1) {
                            count++;
                            vec.at(y).at(x)=0;
                        }
                    }
                } else if (s=="E") {
                    cin>>z;
                    for (int l=0;l<z;l++) {
                        x++;
                        if (vec.at(y).at(x)==1) {
                            count++;
                            vec.at(y).at(x)=0;
                        }
                    }
                } else if (s=="W") {
                    cin>>z;
                    for (int m=0;m<z;m++) {
                        x--;
                        if (vec.at(y).at(x)==1) {
                            count++;
                            vec.at(y).at(x)=0;
                        }
                    }
                } else if (s=="S") {
                    cin>>z;
                    for (int o=0;o<z;o++) {
                        y--;
                        if (vec.at(y).at(x)==1) {
                            count++;
                            vec.at(y).at(x)=0;
                        }
                    }
                }
            }
            if (count==n) {
                cout<<"Yes"<<endl;
            } else {
                cout<<"No"<<endl;
            }
        }
    }
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  ll a, b, k;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++){
    if (!(i%k)) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

const u_int64_t R = 1'000'000'007LL;
u_int64_t perm[200'000];
vector<u_int64_t> factors;

u_int64_t expWrap(u_int64_t x, u_int64_t y)
{
    if (y == 0)
    {
        return 1;
    }
    if (y % 2 == 0)
    {
        return expWrap(x * x % R, y / 2);
    }
    return x * expWrap(x, y - 1) % R;
}

u_int64_t inv(u_int64_t x)
{
    return expWrap(x, R - 2LL);
}

u_int64_t dexp(u_int64_t x, u_int64_t y)
{
    if (y == 0)
    {
        return 1;
    }
    if (y % 2 == 0)
    {
        return dexp(x * x, y / 2);
    }
    return x * dexp(x, y - 1);
}

int main()
{
    u_int64_t N;
    u_int64_t M;
    u_int64_t result = 1;

    cin >> N >> M;

    u_int64_t lim = 100'000 + (u_int64_t)ceil(log2(M)) + 1;
    perm[0] = 1;
    for (u_int64_t i = 1; i < lim; i++)
    {
        perm[i] = i * perm[i - 1] % R;
    }

    for (u_int64_t i = 2; i <= (u_int64_t)floor(sqrt(M)); i++)
    {
        bool isPrime = true;
        for (u_int64_t j = 2; j <= (u_int64_t)floor(sqrt(i)); j++)
        {
            if (i % j == 0)
            {
                isPrime = false;
            }
        }

        if (!isPrime)
        {
            continue;
        }

        u_int64_t ub = ceil(log2(M) / log2(i)) + 1;
        u_int64_t lb = 0;

        while (lb + 1 < ub)
        {
            u_int64_t mid = (ub + lb) / 2LL;

            if (M % dexp(i, mid) == 0)
            {
                lb = mid;
            }
            else
            {
                ub = mid;
            }
        }
        u_int64_t pNum = lb;
        M /= dexp(i, pNum);

        if (pNum != 0)
        {
            factors.push_back(pNum);
        }
    }
    if (M != 1)
    {
        factors.push_back(1);
    }

    for (const u_int64_t &f : factors)
    {
        u_int64_t p = perm[f + N - 1] * inv(perm[f]) % R * inv(perm[N - 1]) % R;
        result = result * p % R;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        for(int j = i; j < S.length(); j++){
            string tmp = S;
            tmp.erase(tmp.begin() + i, tmp.begin() + j);
            if(tmp == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <vector <ll>> v(n, vector <ll> (n, 0));
  vector <pair <ll, ll>> u(m, pair <ll, ll> ());
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    v.at(a).at(b) = 1; v.at(b).at(a) = 1;
    u.at(i) = make_pair(a, b);
  }
  ll res = 0;
  rep(i, m) {
    ll a = u.at(i).first, b = u.at(i).second;
    vector <vector <ll>> tmp = v;
    tmp.at(a).at(b) = 0; tmp.at(b).at(a) = 0;
    vector <ll> d(n, INF);
    queue <ll> q;
    q.push(a);
    d.at(a) = 0;
    while (q.size()) {
      ll l = q.front(); q.pop();
      if (l == b) break;
      rep(j, n) {
        if (tmp.at(l).at(j) && d.at(j)==INF) {
          d.at(j) = d.at(l)+1;
          q.push(j);
        }
      }
    }
    if (d.at(b) == INF) res++;
  }
  cout << res << endl;
}

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

using namespace std;

int main(void) {
	int D[1001][1001] = {};
	string s1, s2;
	cin >> s1 >> s2;

	for (int i = 0; i <= s1.length(); i++) {
		for (int j = 0; j <= s2.length(); j++) {
			if (i + j == 0)
				continue;
			else if (i == 0)
				D[i][j] = D[i][j - 1] + 1;
			else if (j == 0)
				D[i][j] = D[i - 1][j] + 1;
			else
				D[i][j] = min(D[i - 1][j - 1] + ((s1.at(i - 1) != s2.at(j - 1)) ? 1 : 0), min(D[i - 1][j] + 1, D[i][j - 1] + 1));
		}
	}
	cout << D[s1.length()][s2.length()] << endl;
}

Measured memory_bytes: 5108
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int h, w;

	while(1) {
		cin >> h >> w;
		if(h == 0 && w == 0) break;

		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
    // Your code here!
    long int n,k;
    scanf("%ld %ld", &n,&k);
    long int a =0;
    for (int i=0;i<n+2-k;i++) {
        a+=((n-(k+i-1))*(k+i))+1;
    }
        printf("%ld",a%1000000007);
    }


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = -INF;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lines = in.readLine().split(" ");
      int x = Integer.parseInt(lines[0]);
      int y = Integer.parseInt(lines[1]);

      int ans = x + (y>>1);
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 21332
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int W=in.nextInt();
		int H=in.nextInt();
		int x=in.nextInt();
		int y =in.nextInt();
		int r=in.nextInt();
		int A=W-x-r;
		int B=H-y-r;
		if((A>=0)&&(B>=0)&&(x>=r)&&(y>=r)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

}
}



Measured memory_bytes: 26368
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, ans = 0;
	cin >> n;
	vector<int> v(n);
	map<int,int> mp;
	for (int i = 0; i < n; i++){
        cin >> v[i];
        mp[v[i] - (i + 1)]++;
	}
	for (int i = 0; i < n; i++){
        ans += mp[-(v[i] + i + 1)];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 27344
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num;
  bool flag;

  num = 0;
  flag = false;

  int a, b, c; cin >> a >> b >> c;

  if (a <= c && c <= b) flag = true;
  
  // cout << num << endl;
  cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;
ll n,m,k;
int main()
{
    
    cin >> n >> m >> k;
    vll a(n+2),b(m+2);
    for(int i=1;i<=n;i++){
        cin >> a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++){
        cin >> b[i];
        b[i]+=b[i-1];
    }
    int j=m;
    int res=0;
    for(int i=0;i<=n;i++){
        while(j>=0 && a[i]+b[j]>k) j--;
        if(a[i]+b[j]<=k) res=max(res,i+j);
    }
    cout << res <<"\n";
}


Measured memory_bytes: 6360
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, a, b, c, d;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b>>c>>d>>s;
    a--;
    b--;
    c--;
    d--;
    s=s.c_str();
    bool t=false;
    if(n==4){
        yes;
        return 0;
    }
    int min1=min(c,d);
    int max1=max(c,d);
    for(int i=b-1;i<min1-1;i++){
        if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
            t=true;
        }
    }
        bool d1=false;
        for(int i=a;i<max1;i++){
            if(s[i]=='#'&&s[i+1]=='#') d1=true;
        }
        
        if(t==false&&c>d){
            if(s[min1+1]=='#'||s[min1-1]=='#'){
                no;
                return 0;
            }
        }
        if(d1==true) no;
        else yes;
}

Measured memory_bytes: 592
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int A, B;

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

  if (A <= 8 && B <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
w = []
for i in range(n):
    a,b = map(int, input().split())
    w.append([b,a])
w.sort()
time = 0
for i in range(n):
    time+=w[i][1]
    if time > w[i][0]:
        print("No")
        exit()
    else:
        continue
print("Yes")

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  int d[] = {'A','C','G','T'};
  int ans = 0;
  int x = 0;
  rep(i,s.size()){
    rep(j,4){
      if(s[i]==d[j]){
        x++;
        break;
      }
    }
    if(s[i]!=d[0]&&s[i]!=d[1]&&s[i]!=d[2]&&s[i]!=d[3]||i==s.size()-1){
      ans = max(x,ans);
      x = 0;
    }
  }
  cout << ans << endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{

    ll N,M;
    cin >> N >> M;

    if(M < 3)
    {
        if(N == 1 && M == 1) cout << 1 << endl;
        else if(M == 1)
        {
            cout << (N-2) << endl;
        }
        else cout << 0 << endl;
    }
    else
    {
        if(N==1) cout << (M-2) << endl;
        else cout << (M-2) * (N-2) << endl;

    }

}


Measured memory_bytes: 256