akhauriyash/Code-Regression huggingface dataset:
a,b,h,m = gets.split.map(&:to_f)

c = (6 * m) - (30 * h + 0.5 * m)

c = c.abs
if c.abs > 180
  c = 360 - c.abs 
end

puts Math.sqrt(a**2 + b**2 - ( 2 * a * b * Math.cos(c * Math::PI / 180)))

Measured memory_bytes: 14736
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007

int main(){
  ll a;
  cin>>a;
  if(a>=30){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[3][3],b,c;
	for (int i=0;i<3;i++)
		for (int n=0;n<3;n++)
			cin>>a[i][n];
	cin>>b;
	for (int i=0;i<b;i++)
	{
		cin>>c;
		for (int n=0;n<3;n++)
			for (int m=0;m<3;m++)
				if (a[n][m]==c)
					a[n][m]=1000;
	}
	for (int i=0;i<3;i++)
		if (a[i][0]==1000&&a[i][1]==1000&&a[i][2]==1000)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else if (a[0][i]==1000&&a[1][i]==1000&&a[2][i]==1000)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else;
	if (a[0][0]==1000&&a[1][1]==1000&&a[2][2]==1000||a[2][0]==1000&&a[1][1]==1000&&a[0][2]==1000)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		return 0;		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int h, w, arr[23][23], visited[24][24], level[24][24];

int check(int i, int j){
    if(i < 0 || j < 0 || i >= h || j >= w || arr[i][j] == 0) return 0;
    return 1;
}

int r[4] = {0, 1, -1, 0};
int c[4] = {1, 0, 0, -1};

int dfs(int x, int y){
    fill(visited, 0); fill(level, 0);
    queue<int> q;
    q.push(x); q.push(y);
    visited[x][y] = 1;
    int k = 0;
    while(!q.empty()){
        int a = q.front(); q.pop();
        int b = q.front(); q.pop();
        for(int i=0; i < 4; i++){
            int new_x = a + r[i];
            int new_y = b + c[i];
            if(check(new_x, new_y) && !visited[new_x][new_y]){
                visited[new_x][new_y] = 1;
                q.push(new_x); q.push(new_y);
                level[new_x][new_y] = level[a][b] + 1;
                k = max(k, level[new_x][new_y]);
            }
        }
    }
    return k;
}

int run_test(){
    int k;
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char t;
            cin >> t;
            if(t == '#') arr[i][j] = 0;
            else{
                arr[i][j] = 1;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j < w; j++){
            if(arr[i][j] == 1){
                k = dfs(i, j);
                ans = max(k, ans);
            }
        }
    }
    cout << ans ;
    return 0;
}

int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3556
import sys
import bisect

N = int(sys.stdin.readline().rstrip())
S = list(sys.stdin.readline().rstrip())
Q = int(sys.stdin.readline().rstrip())

idx = {chr(ord("a") + i): [] for i in range(26)}

for i, s in enumerate(S):
    idx[s].append(i + 1)

for _ in range(Q):
    t, i, c = sys.stdin.readline().rstrip().split()
    i = int(i)
    if t == "1":
        if S[i - 1] != c:
            idx[S[i - 1]].remove(i)
            bisect.insort(idx[c], i)
            S[i - 1] = c
    else:
        c = int(c)
        ans = 0
        for a, id in idx.items():
            x = bisect.bisect_left(id, i)
            y = bisect.bisect_right(id, c)
            if y - x:
                ans += 1
        print(ans)

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

int main(){
	int n,m,temp,ans=0;
 //青いカード
  	cin>>n;
  	vector<string> s1(n);
  	map<string,int> mp1;

  	for(int i=0;i<n;i++){
    	cin>>s1[i];
        mp1[s1[i]]=0;
    }
               
    for(int i=0;i<n;i++){
    	mp1[s1[i]]++;
    }
  
 //赤いカード
  	cin>>m;
  	vector<string> s2(m);
	map<string,int> mp2;
  	for(int i=0;i<m;i++){
    	cin>>s2[i];
        mp2[s2[i]]=0;
    }
  
  	
    for(int i=0;i<m;i++){
    	mp2[s2[i]]++;
    }
//青いカードの数-赤いカードの数
  for(auto itr=mp1.begin();itr!=mp1.end();++itr){
  	temp=mp1[itr->first]-mp2[itr->first];
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
}    


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, x;
    int cnt = 0;
    while (1) {
        cin >> n >> x;
        if (!n && !x) break;
        cnt = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    if (i != j && j != k && k != i && i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt / 6 << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
static const lint MOD9 = (lint)1e9+7;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


lint Sum(const vector<lint>& v, int p)
{
    lint sum = 0;
    for (cauto& it : v)
    {
        sum += (it - p)*(it - p);
    }

    return sum;
}

int main()
{
    int N; cin >> N;
    vector<lint> X(N); rep (i, N) { cin >> X[i]; }

    lint ans = LONG_LONG_MAX;
    range_for (i, 1, 100)
    {
        chmin(ans, Sum(X, i));
    }

    cout << ans << "\n";

    return 0;
}



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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >
#define is pair < double , int >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define x first
#define y second

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 3e3 + 5;
const int VAL = 2e5 + 5;
int n , m , k , mod = 1e9 + 7;
int dp[N];
int fact[VAL] , rfact[VAL];
ii a[N];

int mul(int a , int b)
{
    return (a * b) % mod;
}

int add(int a , int b)
{
    return (a + b) % mod;
}

int sub(int a , int b)
{
    return ((a - b) % mod + mod) % mod;
}

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

int C(int n , int k)
{
    return mul(fact[n] , mul(rfact[k] , rfact[n - k]));
}

main()
{
    //freopen("Y.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    FOR(i , 1 , k)
        cin >> a[i].fi >> a[i].se;
    sort(a + 1 , a + 1 + k);
    fact[0] = 1;
    FOR(i , 1 , n + m)
        fact[i] = mul(fact[i - 1] , i);
    rfact[n + m] = powmod(fact[n + m] , mod - 2);
    FORD(i , n + m - 1 , 0)
        rfact[i] = mul(rfact[i + 1] , i + 1);
    FOR(i , 1 , k)
    {
        dp[i] = C(a[i].fi + a[i].se - 2 , a[i].fi - 1);
        FOR(j , 1 , i - 1)
            if(a[j].se <= a[i].se)
                dp[i] = sub(dp[i] , mul(dp[j] , C(a[i].fi - a[j].fi + a[i].se - a[j].se , a[i].fi - a[j].fi)));
    }
    int res = C(n + m - 2 , n - 1);
    FOR(i , 1 , k)
        res = sub(res , mul(dp[i] , C(n + m - a[i].fi - a[i].se , n - a[i].fi)));
    cout << res;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 1e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

bool f(ll m,int N,ll K,vector<int> &A,vector<int> &F){
    ll cnt = 0;
    rep(i,N){
        ll d = m/F[i];
        if(A[i] > d) cnt += A[i]-d;
    }
    if(cnt <= K) return true;
    else return false;
}

int main(){
    int N; cin >> N;
    ll K; cin >> K;
    vector<int> A(N),F(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    if(sum <= K){
        cout << 0 << endl;
        return 0;
    }
    sort(A.begin(),A.end(),greater<int>());
    rep(i,N) cin >> F[i];
    sort(F.begin(),F.end());

    ll ok = LINF,ng = 0;
    while(ok - ng > 1){
        ll mid = (ng+ok)/2;
        if(f(mid,N,K,A,F)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

}
   


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int R = sc.nextInt();
		String ans = "AGC";
		if (R < 2800) ans = "ARC";
		if (R < 1200) ans = "ABC";
		System.out.println(ans);
	}

	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
bool necessary(int K, const vector<int>& A, int i)
{
    if (A[i] >= K) return true;
    bitset<5001> bits;
    bits.set(0);
    REP(j, A.size()) {
        if (i == j) continue;
        bits |= bits << A[j];
        bits.set(0);
    }
    for (int j = max(0, K - A[i]); j < K; j++) {
        if (bits[j]) {
            return true;
        }
    }
    return false;
}
int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    if (necessary(K, A, 0)) {
        cout << 0 << endl;
        return 0;
    }
    if (!necessary(K, A, N-1)) {
        cout << N << endl;
        return 0;
    }
    int lo = 0, hi = N-1;
    while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        if (necessary(K, A, mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << hi << endl;
    return 0;
}

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

int main()
{
  typedef long long ll;
  ll x;
  cin >> x;
  auto turn = (x - 1)/11;
  auto mod = (x - 1)%11;
  cout << 2*turn + ((mod < 6) ? 1 : 2);
  return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

n,m = map(int,input().split())
byte = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in byte:
        byte[a] = []
    heappush(byte[a], [-b,a])

ans = 0
res = []
for i in range(1, m+1):
    if i in byte:
        heappush(res, heappop(byte[i]))
    if not res:
        continue
    b,a = heappop(res)
    ans -= b
    if byte[a]:
        heappush(res, heappop(byte[a]))
     
print(ans)

Measured memory_bytes: 35784
#include <iostream>

using namespace std;

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

	int x;
	cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
   int n;
   cin >> n;
   int ans=180*n-360;
    cout << ans << endl;
} 
    

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    unordered_map<ll, ll> mp, mp2;
    for(int i=0; i<N; i++){
        ll a, b;
        cin >> a >> b; a--; b--;
        mp2[a*W+b];
        for(ll j=0; j<3; j++){
            for(ll k=0; k<3; k++){
                ll x = a - j;
                ll y = b - k;
                if(0<=x && x<H-2 && 0<=y && y<W-2) mp[x*W+y];
            }
        }
    }

    vector<ll> ans(10, 0);
    for(auto& p: mp){
        ll a = p.first / W;
        ll b = p.first % W;
        ll num = 0;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(mp2.find((a+i)*W+(b+j)) != mp2.end()) num++;
            }
        }
        ans[num]++;
    }

    ans[0] = (H-2)*(W-2);
    for(int i=1; i<10; i++) ans[0] -= ans[i];

    for(ll& x: ans) cout << x << endl;
}

Measured memory_bytes: 40720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

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

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int t,int p,int r){
	vvi vv(t,vi(p));
	vector<tlll> score(t);
	rep(i,t)get<0>(score[i])=i;
	rep(i,r){
		int tid,pid,ti;
		string s;
		cin>>tid>>pid>>ti>>s;
		tid--;pid--;
		if(s=="CORRECT"){
			get<1>(score[tid])++;
			get<2>(score[tid])+=ti+vv[tid][pid]*1200;
		}
		else vv[tid][pid]++;
	}
	sort(all(score),[](auto &a,auto &b){
		if(get<1>(a)!=get<1>(b))return get<1>(a)>get<1>(b);
		else if(get<2>(a)!=get<2>(b))return get<2>(a)<get<2>(b);
		else return get<0>(a)<get<0>(b);
	});
	rep(i,t){
		cout<<get<0>(score[i])+1<<" "<<get<1>(score[i])<<" "<<get<2>(score[i])<<"\n";
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t,p,r;
	while(cin>>t>>p>>r,t){
		solve(t,p,r);
	}
}


Measured memory_bytes: 3224
n = int(input())
a = [0]*(n+1)
b = [0]*(n+1)
for i in range(1,n+1):
	a[i],b[i] = map(int,input().split())
a.sort()
b.sort()

if n%2 == 1:
	print(b[(n+1)//2]-a[(n+1)//2]+1)
else:
	print(b[n//2]-a[n//2]+b[n//2+1]-a[n//2+1]+1)

Measured memory_bytes: 25368
N = int(input())
flag = 1
t_,x_,y_ = [0,0,0]
for _ in range(N):
    t,x,y = list(map(int,input().split()))
    if ((t-t_)-abs(x-x_)-abs(y-y_))%2 == 1 or ((t-t_)-abs(x-x_)-abs(y-y_)) < 0:
        flag = 0
    t_,x_,y_ = [t,x,y]

if flag == 1:
    print('Yes')
else:
    print('No')

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

int main(){
  int n, k;
  cin >> n >> k;
  ll a = n/k, b = (n + k/2)/k;
  if ( k % 2 == 0){
    cout << a * a * a  + b * b * b << endl;
  } else {
    cout << a * a * a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

	int ch;

	for(;;){		
		ch = getchar();
	if( ch == EOF ){
		break;
	}		

		if(isupper(ch)){
			ch = tolower(ch);
		} else if( islower(ch) ){
			ch = toupper(ch);
		}

		putchar(ch);
	}
	return 0;
}

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

int main() 
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
 
 int n;
 cin>>n;
 set <string> v;
 // int count=0;
 for(int i=0;i<n;i++)
 {string s;
  cin>>s;
  v.insert(s);
 }
 cout<<v.size();
  return 0; 
}

Measured memory_bytes: 19108
#include <cstdio>
#include <map>
#define mod 1000000007
#define LL long long
using namespace std;
map< pair<LL,LL>,pair<int,int> > mp;
LL gcd(LL a,LL b){
	return b?gcd(b,a%b):a;
}
LL quick_pow(LL a,LL b){
	LL ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret%mod;
}
int main(){
	int n,i;
	LL a,b,d,zero=0,sum=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		if(!a&&!b){zero++;continue;}
		d=gcd(a,b);
		a/=d,b/=d;
		if(b<0)a=-a,b=-b;
		if(a<=0)mp[make_pair(b,-a)].second++;
		else mp[make_pair(a,b)].first++;
	}
	for(map< pair<LL,LL>,pair<int,int> >::iterator it=mp.begin();it!=mp.end();it++)
		sum=(quick_pow((LL)2,(LL)it->second.first)-1+quick_pow((LL)2,(LL)it->second.second)-1+1)%mod*sum%mod;
	sum=(sum+zero-1)%mod;
	sum=(sum%mod+mod)%mod;
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 15684
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+20;
int main()
{
	int k,s;
	while(cin>>k>>s)
	{
		int ans=0;
		//x+y+z=s的方法数
		//0<=x,y,z<=k  k<=2500;
		for(int x=0;x<=k;x++)
		{
			for(int y=0;y<=k;y++)
			{
				int z=s-x-y;
				if(z>=0&&z<=k)
				ans++;
			}
		}
		cout<<ans<<endl;			
			
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll N , K;
    cin >> N >> K;
    string S;
    cin>>S;
    ll base = 0;
    for(int i=1; i<N; i++){
        if(S[i]==S[i-1]) base++;
    }
    // Case L
    ll lcnt = 0;
    ll l = 0, r = 0;
    ll lk = K;
    while(lk and r<N){
        if(S[l]=='L') {
            l++, r++;
            continue;
        } else {
            r = l;
            while(r<N and S[r]!='L'){
                r++;
            }
            if(l==0){
                l = r;
                continue;
            }
            if(r==N) lcnt++;
            else lcnt += 2;
            l = r;
            lk--;
        }
    }
    if(lk and S[0]=='R' and S[N-1]=='L'){
        lcnt++;
    }
    ll rcnt = 0;
    l = 0, r = 0;
    lk = K;
    while(lk and r<N){
        if(S[l]=='R') {
            l++, r++;
            continue;
        } else {
            r = l;
            while(r<N and S[r]!='R'){
                r++;
            }
            if(l==0){
                l = r;
                continue;
            }
            if(r==N) rcnt++;
            else rcnt += 2;
            l = r;
            lk--;
        }
    }
    if(lk and S[0]=='L' and S[N-1]=='R'){
        rcnt++;
    }
    cerr << base << " " << lcnt << " " << rcnt << endl;
    cout << base + max(lcnt, rcnt) << endl;
    // Case R
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double x=30.0*(h+m/60.0),y=m*6.0;
	x=fabs(x-y);
//	printf("%.20lf\n",x);
	printf("%.20lf\n",sqrt(pow(a,2.0)+pow(b,2.0)-2*a*b*pow(cos(M_PI*(x/180)),1.0)));
	return 0;
}


Measured memory_bytes: 4156
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define ceil(a,b) (a%b?a/b+1:a/b)
#define all(v) v.begin(), v.end()

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
#define dump2(v) for(auto i:v) { for(auto j:i) std::cout << j << ' '; std::cout << "\n"; }
signed main() {
	std::string s;
	std::cin >> s;
	char last;
	int count = 0;
	rep(i,s.size()) {
		if(i==0) {
			last = s[i];
			count++;
			continue;
		}
		if(last==s[i]) {
			last = '?';
			i++;
			if(i<s.size()) count++;
			continue;
		}
		count++;
		last = s[i];
	}
	print(count);
	return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    int four = (H / 2) * (W / 2);
    int two = (H / 2) * (W % 2) + (H % 2) * (W / 2);
    int one = (H % 2) * (W % 2);

    string a;
    vector<int> count(26, 0);
    for (int i = 0; i < H; i++)
    {
        cin >> a;
        for (char c : a)
        {
            count[c - 'a']++;
        }
    }

    for (int c : count)
    {
        int n;
        if (four > 0)
        {
            n = min(c / 4, four);
            four -= n;
            c -= 4 * n;
        }
        if (two > 0)
        {
            n = min(c / 2, two);
            two -= n;
            c -= 2 * n;
        }
        if (one > 0)
        {
            n = min(c / 1, one);
            one -= n;
            c -= 1 * n;
        }
        if (c > 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
        cout<<"hon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>

//M adalah bilangan Maks
void CountingSort(int N, int M, int *input, int *freq) {
	int x;
	for(int i=0;i<=M;i++) {
		freq[i]=0;
	}
	for(int i=1;i<=N;i++) {
		x=input[i];
		freq[x] = freq[x] +1;	
	}
	int index=1;
	for(int i=0;i<=M;i++) {
		for(int j=1;j<=freq[i];j++) {
			input[index] = i;
			index++;
		}
	}
}

int main() {
	int N;
	scanf("%d",&N);
	int input[N+1];
	int M=0;
	for(int i=1;i<=N;i++) {
		scanf("%d",&input[i]);
		if(input[i]>M) {
			M=input[i];
		}
	}
	int freq[M+1];
	CountingSort(N,M,input,freq);
	for(int i=1;i<=N;i++) {
		printf("%d",input[i]);
		if(i<N) {
			printf(" ");
		} 
		if(i==N) {
			printf("\n");
		}
	}
}
	


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int n, a[100000];

int sign(int x) {
	return x > 0 ? 1 : x < 0 ? -1 : 0;
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> a[i];
	int d = 0, res = 1;
	REP(i, n - 1) {
		int e = sign(a[i + 1] - a[i]);
		if (e != 0 && d != 0 && e != d) {
			++res;
			d = 0;
		} else if (e != 0) {
			d = e;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

int main(){

    int n;
    cin >> n;

    int odd_count = 0;
    int even_count = 0;

    long long val;
    for(int i = 0; i < n; i++){
        cin >> val;
        if(val % 2 == 1){
            odd_count ++;
        }
        else{
            even_count ++;
        }
    }

    if(odd_count % 2 == 1){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }

}

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

int main() {
    int n;
    cin >> n;
    int c[n-1], s[n-1], f[n-1];
    for (int i = 0; i < n - 1; i++) {
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    for (int i = 0; i < n; i++) {
        int time = 0;
        for (int j = i; j < n - 1; j++) {
            if (time <= s[j]) {
                time = s[j];
            } else if (!(time % f[j] == 0)) {
                time = time + f[j] - time % f[j];
            }
            time += c[j];
        }
        cout << time << endl;
    }

    return 0;
}

Measured memory_bytes: 256
main = do
    input <- getContents --ここ間違ってた
    let [a, b, c, d, e, f] = map read $ words input
        mymin = \r l -> if r<l then r else l
    putStrLn $ show $ a + b + c + d + e + f - (mymin (mymin a b) (mymin c d)) - (mymin e f)


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

 int main(){
  int x, y;
  cin >> x >> y;

  if (x==2 && y==2) cout << "Yes" << endl;
  
  else if ((x==4 || x==6 || x==9 || x==11)           
       &&  (y==4 || y==6 || y==9 || y==11))
       cout << "Yes" << endl;


  else if ((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12)
       &&  (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12))       
       cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
 return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String str = in.next();
            if (str.length() == 1)
            {
                out.print(0);
                return;
            }
            out.print(count(str));
        }

        private int count(String str)
        {
            int i, j;
            if (str.length() % 2 == 0)
            {
                j = str.length() / 2;
                i = j - 1;
            } else
            {
                i = (str.length() / 2) - 1;
                j = (str.length() / 2) + 1;
            }
            int count = 0;
            for (; i >= 0 & j < str.length(); i--, j++)
            {
                if (str.charAt(i) != str.charAt(j)) count++;
            }
            return count;
        }

    }
}



Measured memory_bytes: 21972
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>inline T lcm(T a,T b){return a*b/gcd(b,a%b);}

int N,M,i,j,K,a,ans;
map<int,int> cnt;
inline void solve(){
  IN2(N,M);
  REP(i,N){
    IN(K);
    REP(j,K){
      IN(a);
      cnt[a]++;
    }
  }
  for(map<int,int>::iterator it=cnt.begin();it!=cnt.end();it++){
    if(it->second==N)ans++;
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

struct RevPolElement
{
	RevPolElement(int type, int n) : type(type), n(n) { }
	int type;
	int n;
};

deque<RevPolElement> make_revpol(char* s)
{
	map<char, int> pr;
	pr['w'] = -1;
	pr['('] = 0;

	pr['+'] = pr['-'] = 1;
	pr['*'] = pr['/'] = 2;
	pr['@'] = 3;

	char* before_unary = "+-*/(";

	deque<RevPolElement> res;
	stack<char> t;
	t.push('w');
	for (int i = 0; s[i] != '='; ++i)
	{
		if (isdigit(s[i]))
		{
			int t = s[i] - '0';
			while (isdigit(s[i+1]))
				t = t*10 + s[++i] - '0';

			res.push_back(RevPolElement(0, t));
		}
		else
		{
			char op = s[i];
			if (op == '-' && (i == 0 || strchr(before_unary, s[i-1])))
				op = '@';

			if (op == ')')
			{
				while (true)
				{
					char topOp = t.top();
					t.pop();
					if (topOp == '(')
						break;
					res.push_back(RevPolElement(1, topOp));
				}
			}
			else if (op == '(')
				t.push(op);
			else
			{
				while (pr[op] <= pr[t.top()])
				{
					res.push_back(RevPolElement(1, t.top()));
					t.pop();
				}
				t.push(op);
			}
		}
	}
	while (t.size() > 1)
	{
		res.push_back(RevPolElement(1, t.top()));
		t.pop();
	}

	return res;
}

int calculate_revpol(deque<RevPolElement> revpol)
{
	stack<int> t;
	while (!revpol.empty())
	{
		if (revpol.front().type)
		{
			char op = revpol.front().n;
			int res;
			if (op == '@')
			{
				res = -t.top();
				t.pop();
			}
			else
			{
				int a, b;
				b = t.top(); t.pop();
				a = t.top(); t.pop();
				if (op == '+')
					res = a + b;
				else if (op == '-')
					res = a - b;
				else if (op == '*')
					res = a * b;
				else if (op == '/')
					res = a / b;
			}

			t.push(res);
		}
		else
			t.push(revpol.front().n);

		revpol.pop_front();
	}

	return t.top();
}

int main()
{
	int n;
	while (cin >> n)
	{
		cin.get();
		while (n--)
		{
			char buf[256];
			cin.getline(buf, sizeof(buf));
			printf("%d\n", calculate_revpol(make_revpol(buf)));
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i % 3 == 0 || i % 5 == 0) {
                continue;
            }
            ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 27228
n = int(input())
count = 0

for i in range(1,n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        count += i
print(count)

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

int main(){
	string s;
	cin>>s;
	if((s[0]==s[1] && s[2]==s[3]) || (s[0]==s[2] && s[1]==s[3]) || (s[0]==s[3] && s[1]==s[2])){
		if((s[0]==s[1]) && (s[2]==s[3]) && (s[1]==s[2]) && (s[0]==s[3])){
			cout<<"No";
			return 0;
		}
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())

cnt = 0
for i in range(N-1, -1, -1):
    for j in range(i):
        if A[j] > A[j+1]:
            A[j], A[j+1] = A[j+1], A[j]
            cnt += 1

print(*A)
print(cnt)



Measured memory_bytes: 5612
n = int(input())
nums = list(map(int, input().split()))
ans = []

for _ in range(n):
  ans.append(-1)

for i in range(1, n + 1)[::-1]:
  C = i * 2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ball = []
for i in range(n):
  if ans[i] == 1:
    ball.append(i+1)
print(*ball)

Measured memory_bytes: 14132
#include<stdio.h>

int main(){
  int A[100], tmp, N, i, j, v;
  
  scanf("%d", &N);
  for (i=0; i<N; i++) {
    scanf("%d", &A[i]);
  }

  for (i=1; i<N; i++) {
    
    for (j=0; j<N-1; j++) {
      printf("%d ", A[j]);
    }
    printf("%d\n", A[N-1]);
    
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }

  for (j=0; j<N-1; j++) {
    printf("%d ", A[j]);
  }
  printf("%d\n", A[N-1]);
  return 0;
}

Measured memory_bytes: 600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,c = LI()

    if sorted([a,b,c])[1] == c:
        return 'Yes'

    return 'No'


print(main())



Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        int n,k,c;
        int i;
        string s;
        vector<int>l,r;
        cin>>n>>k>>c>>s;
        i=0;
        while(l.size()<k&&i<n)
        {
            if(s[i]=='o')
            {
                l.push_back(i);
                i+=(c+1);
            }else i++;
        }
        i=n-1;
        while(r.size()<k&&i>=0)
        {
            if(s[i]=='o')
            {
                r.push_back(i);
                i-=(c+1);
            }else i--;
        }
        reverse(r.begin(),r.end());
        int j;
        for(i=0,j=0;i<l.size()&&j<r.size();i++,j++)
        {
            if(l[i]==r[i])
            {
                cout<<l[i]+1<<endl;
            }
        }
    }
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  string s;
  cin >> s;
  const ll n = (int)s.size();
/*
  int count = 0;
  int i = n-1;
  while(true) {
    if (i > 0) {
      if (s[i] == 'W' && s[i-1] == 'B') {
        s[i-1] = 'W';
        s[i] = 'B';
        i = min(i+2,n-1);
        ++count;
      } else {
        --i;
      }
    } else {
      break;
    }
  }
  cout << count << endl;
  */
  ll count = 0;
  ll nextwpos = 0;
  rep(i,n) {
    if (s[i] == 'W') {
      count += i-nextwpos;
      nextwpos++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	n=n%k;
	if(n>k-n) n=k-n;
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $h, $w);
$h = (int)$h;
$w = (int)$w;
$strArr = [];
for ($i = 0; $i < $h; $i++) {
    fscanf(STDIN, "%s", $strArr[]);
}

$resultStrArr = [];

for ($k = 0; $k <= $h + 1; $k++) {
    if ($k == 0 || $k == $h + 1) {
        $resultStrArr[] = str_repeat("#", $w + 2);
    } else {
        $resultStrArr[] = '#'.$strArr[$k-1].'#';
    }
}

foreach($resultStrArr as $row) {
    echo $row."\n";
}

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

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {
	int h,w;
	cin >> h >> w;

	ll ans = 5000000000000000;

	if (h % 3 && w % 3) {
		ll a, b, c;


		rep1(i, h - 1) {
			a = (ll)i * w;
			b = ((ll)h * w - a) * (w / 2) / w;
			c = (ll)h * w - a - b;

			ll mx = max(a, b);
			mx = max(mx, c);
			ll mn = min(a, b);
			mn = min(mn, c);
			ans = min(ans, mx - mn);
		}

		rep1(i, w - 1) {
			a = (ll)i * h;
			b = ((ll)h * w - a) * (h / 2) / h;
			c = (ll)h * w - a - b;

			ll mx = max(a, b);
			mx = max(mx, c);
			ll mn = min(a, b);
			mn = min(mn, c);
			ans = min(ans, mx - mn);
		}

		rep1(i, h - 1) {
			a = (ll)i * w;
			b = ((ll)h * w - a) * ((h-i) / 2) / (h-i);
			c = (ll)h * w - a - b;

			ll mx = max(a, b);
			mx = max(mx, c);
			ll mn = min(a, b);
			mn = min(mn, c);
			ans = min(ans, mx - mn);
		}

		rep1(i, w - 1) {
			a = (ll)i * h;
			b = ((ll)h * w - a) * ((w-i) / 2) / (w-i);
			c = (ll)h * w - a - b;

			ll mx = max(a, b);
			mx = max(mx, c);
			ll mn = min(a, b);
			mn = min(mn, c);
			ans = min(ans, mx - mn);
		}



	}

	else ans = 0;

	cout << ans << endl;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	_ = sc.NextInt()
	line := sc.NextLine()
	mp := map[string]bool{}
	for _, v := range strings.Split(line, " ") {
		mp[v] = true
	}
	if len(mp) == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n;
i64 cnt[11][11];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		int f = i%10, t = i;
		while(t/10) t/=10;
		cnt[t][f]++;
	}
	
	i64 ans = 0;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			ans += cnt[i][j]*cnt[j][i];
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256