akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int kRem = 1000000007;

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int64_t pow_remdiv(int64_t val, int64_t rem)
{
	return pow_rem(val, rem - 2, rem);
}

int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = pow_remdiv(dividor, rem);
	ret *= divident;
	ret %= rem;

	return ret;
}


vector<int64_t> factors;
vector<int64_t> finvs;
void precalc_nCr(int n, int64_t rem) {
	factors = vector<int64_t>(n + 1);
	finvs = vector<int64_t>(n + 1);

	{
		int64_t f = 1;
		factors[0] = 1;
		FOR_LE(i, 1, n) {
			f *= i;
			f %= rem;
			factors[i] = f;
		}
	}
	{
		int64_t inv = divide_rem(1, factors[n], rem);
		finvs[n] = inv;
		FOR_DW(i, n - 1, 0) {
			inv *= i + 1;
			inv %= rem;
			finvs[i] = inv;
		}
	}
}

int64_t nCr_postcalc(int n, int k, int64_t rem) {
	int64_t val = factors[n];
	val *= finvs[n - k];
	val %= rem;
	val *= finvs[k];
	val %= rem;
	return val;
}

uint64_t nCr(uint64_t n, uint64_t r) {
	if (n == 0) return 0;
	if (r > n) return 0;

	uint64_t ret = 1;
	for (uint64_t i = 0; i < r; i++) {
		ret = ret * (n - i) / (i + 1);
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n; cin >> n;
	vector<int64_t> cs(n);
	for (auto& c : cs) {
		cin >> c;
	}

	sort(cs.begin(), cs.end(), std::greater<int64_t>());

	int64_t ans = 0;
	int64_t val = pow_rem(2, n, kRem);
	int64_t val2 = divide_rem(1, 2, kRem);
	int64_t val3 = pow_rem(2, n - 1, kRem);
	FOR_LT(i, 0, n) {
		int64_t j = i + 1;
		int64_t cv = (j + 1);
		cv %= kRem;
		cv *= val2;
		cv %= kRem;
		cv *= cs[i];
		cv %= kRem;
		cv *= val3;
		cv %= kRem;
		cv *= val;
		cv %= kRem;
		ans += cv;
		ans %= kRem;
		val2 *= 2;
		val2 %= kRem;
		val3 = divide_rem(val3, 2, kRem);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import numpy as np
import sys

n = int(input())
aList = input().split(" ")

aList = np.array(aList, dtype=np.int)
aList = aList[aList % 2 == 0]

a = list(aList[aList % 5 == 0])
b = list(aList[aList % 3 == 0])

aList = set(list(aList))

if len(aList) == len(set(a + b)):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 12484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> PLL;


signed main(void) {
  ll N, K;
  cin>>N>>K;

  // 0 <= K <= (N-1)(N-2)/2 ( = N(N-1)/2 - (N-1) )
  // うにを作る
  if (K< 0 || K > (N-1)*(N-2)/2) {
    cout<<-1<<endl;
    return 0;
  }

  ll t = (N-1)*(N-2)/2 - K;
  cout<<t+(N-1)<<endl;
  for (int i=1; i<=N-1; i++) {
    cout<<N<<" "<<i<<endl;
  }

  vector<PLL> v;
  for (int i=1; i<=N-1; i++) {
    for (int j=i+1; j<=N-1; j++) {
      v.push_back(PLL(i, j));
    }
  }
  for (int i=0; i<t; i++){
    cout<<v[i].first<<" "<<v[i].second<<endl;
  }
  return 0;
}


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

typedef long long ll;
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 = 2000000000;
constexpr auto MOD = 1000000007;

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

	vi ans = {};

	rep1(i, 55555) {
		if (i == 1||i%5!=1)continue;
		bool prime=true;

		rep1(j,(int)sqrt(i)) {
			if (j == 1)continue;
			if (i % j==0)prime = false;
		}

		if (prime)ans.push_back(i);
	}

	rep(i, n)cout << ans[i] << " " << endl;
	cout << endl;
}

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

int main(void)
{
    float x1, x2, x3, x4, y1, y2, y3, y4;
    float res1, res2;
    int k, i;

    scanf("%d", &k);

    for (i = 0; i < k; i++){
        scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        res1 = (y2 - y1) / (x2 - x1);
        res2 = (y4 - y3) / (x4 - x3);
        if (res1 == res2){
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
    return (0);
}

Measured memory_bytes: 616
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
 double a,b,c,d,e,f,y,x;
 int i=0,n;
while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){
  y=((c*d)-(a*f))/((b*d)-(a*e));
  x=((c*e)-(b*f))/((a*e)-(b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3lf %.3lf\n", x,y);
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>

using namespace std;

int main() {
	int k; cin >> k;
	if (!(k & 1)) {
		cout << -1 << endl;
		return 0;
	}
	int t = 7;
	for (int i = 1; i < 10000000; ++i) {
		if (t % k == 0) {
			cout << i << endl;
			return 0;
		}
		t = (t * 10 + 7) % k;
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> P, vector<ll> Q){
    P.pop_back(); Q.pop_back();
    ll a = factorial(N - 1) * (P.at(0) - 1), b = factorial(N - 1) * (Q.at(0) - 1);
    rep(i, N - 1) {
        if (i != 0) {
            a += factorial(N - i - 1) * (P.at(i) - 1);
            b += factorial(N - i - 1) * (Q.at(i) - 1);
            }
        rep2(j, i + 1, N - 2) if (P.at(j) > P.at(i)) P.at(j)--;
        rep2(j, i + 1, N - 2) if (Q.at(j) > Q.at(i)) Q.at(j)--;
        }
    cout << abs(a - b) << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> P(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&P[i]));
    }
    vector<ll> Q(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&Q[i]));
    }
    solve(N, move(P), move(Q));
    return 0;
}

Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

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

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef long double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

template <class T>
void ms_erase_one(multiset<T>& ms, const T value) {
  ms.erase(ms.find(value));
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int x, y;
  cin >> x >> y;
  // a + b == x
  // 2 * a + 4 * b == y
  // 2 * a + 2 * b == 2 * x
  // 2 * b == y - 2 * x
  // b == (y - 2 * x) / 2
  // a == x - b

  int b = (y - 2 * x) / 2;
  int a = x - b;

  if (a >= 0 && b >= 0 && 2 * a + 4 * b == y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;


int m(int a, int b) {
	if (a < b) { return a; }
	else { return b; }
}

int main(void) {
	int N, len[10000];
	char s[10000][11];
	int ans, a, b, c;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s", &s[i]);
		len[i] = strlen(s[i]);
	}

	ans = 0;
	a = 0;
	b = 0;
	c = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < len[i] - 1; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
				ans += 1;
			}
		}
		if (s[i][0] != 'B' && s[i][len[i] - 1] == 'A') {
			a += 1;
		}
		if (s[i][0] == 'B' && s[i][len[i] - 1] != 'A') {
			b += 1;
		}
		if (s[i][0] == 'B' && s[i][len[i] - 1] == 'A') {
			c += 1;
		}

	}
	if(c==0){
		ans += m(a, b);
	}
	else {
		if (a == 0 && b == 0) { ans += c - 1; }
		if (a > 0 && b == 0) { ans += c; }
		if (a == 0 && b > 0) { ans += c; }
		if (a > 0 && b > 0) { ans += c + m(a, b); }
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
		bool isMSN[300000];
		bool isMSP[300000];
		for(int i=0;i<300000;i++){
			isMSN[i]=false;
			isMSP[i]=true;
		}
		for(int i=6;i<300000;i++)
			if(i%7==1||i%7==6)
				isMSN[i]=true;
		for(int i=6;i<300000;i++)
			if(isMSN[i] && isMSP[i])
				for(int j=2*i;j<300000;j+=i)
					isMSP[j]=false;
        int n;
        while(cin >> n ,n!=1){
				cout << n <<":";
                for(int i=6; i<=n; i++){
                	if(isMSP[i] && isMSN[i] && n%i==0)
						cout << ' '<< i;
				}
				
                cout << endl;
        }
 		return 0;
}

Measured memory_bytes: 1744
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

count = 0
n = int(input())
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if i==j==k:
                count += gcd(i, j, k)
            elif i==j or j==k:
                count += 3*gcd(i, j, k)
            else:
                count += 6*gcd(i, j, k)

print(count)

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

string S;
int Q;

int main()
{
    cin >> S >> Q;

    bool flag = false;
    for(int i = 0; i < Q; i++)
    {
        int q;
        cin >> q;
        if(q == 1)
        {
            flag = !flag;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if(flag && f == 1) f = 2;
            else if(flag && f == 2) f = 1;
            if(f == 1) S.insert(0,1,c);
            else S.push_back(c);
        }
    }
    if(!flag) cout << S << endl;
    else
    {
        for(int i = S.size() - 1; 0 <= i; i--) cout << S[i];
        cout << endl;
    }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
void solve(){
    int n,a[1010];
    cin>>n;
    bool f=true;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=0)f=false;
    }
    vector<int>ans;
    if(f){
        int ma=-INF,mapos=-1;
        rep(i,n){
            if(ma<a[i]){
                ma=a[i];
                mapos=i;
            }
        }
        cout<<ma<<endl;
        rep(i,mapos)ans.pb(1);
        for(int i=n-1;i>mapos;i--)ans.pb(i+1-mapos);
        cout<<ans.size()<<endl;
        for(int i:ans)cout<<i<<endl;
        return;
    }
    int sum[2]={0,0};
    rep(i,n)sum[i%2]+=max(0ll,a[i]);
    int m2=(sum[0]>=sum[1]?0:1);
    cout<<max(sum[0],sum[1])<<endl;
    vector<int>v;
    rep(i,n)if(i%2==m2&&a[i]>0)v.pb(i);
    rep(i,v[0])ans.pb(1);
    for(int i=n-1;i>v.back();i--)ans.pb(i+1-v[0]);
    rep(i,v.size()-1){
        rep(j,(v[i+1]-v[i])/2-1)ans.pb(3);
        ans.pb(2);
    }
    cout<<ans.size()<<endl;
    for(int i:ans)cout<<i<<endl;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, X, M = map(int, input().split())
table = [0] * M
c = [0] * M
c[X] = 1
x = X
while table[x] <= 1:
  table[x] += 1
  if c[x ** 2 % M] == 0: c[x ** 2 % M] = c[x] + 1
  x = x ** 2 % M
loop = table.count(2)
#print(loop)
res = 0
for x in range(M):
  if c[x] in range(1, N + 1):
    res += x
    if c[x] + loop in range(1, N + 1) and (table[x] >= 2): res += x * ((N - c[x]) // loop)
print(res)

Measured memory_bytes: 69588
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}

vecp v[N];
int p[N];
signed main(){
  fast;
  
 int n , x , y , a , b;
 cin >> n;
 for(int i = 0 ; i < n ; i++){
 	    cin >> x;
 	    while(x--){
 	    	    cin >> a >> b;
 	    	    a--;
 	    	    v[i].pb({a , b});
 	    }
 }
 int ans = 0;
 for(int i = 0 ; i < (1ll << n) ; i++){
 	    for(int j = 0 ; j < n ; j++){
 	    	    if((i&(1<<j))) p[j] = 1;
 	    	    else p[j] = 0;
 	    }
 	    int f = 0;
 	    for(int j = 0 ; j < n ; j++){
 	    	    if(p[j] == 0) continue;
 	    	    for(int c = 0 ; c < v[j].size() ; c++){
 	    	    	   x = v[j][c].ff;
 	    	    	   y = v[j][c].ss;
 	    	    	   if(p[x] == y) continue;
 	    	    	   else {
 	    	    	   	    f = 1;
 	    	    	   	    break;
 	    	    	   }
 	    	    }
 	    	    if(f == 1) break;
 	    }
 	    if(f == 0){
 	    	   ans = max(ans, 1ll*bitcnt(i));
 	    }

 }
 cout << ans << endl;

 }

Measured memory_bytes: 7552
/*
    Flowers, wake up like the sea!
*/
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x7fffffff
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
typedef vector<int> VI;
typedef map<int,int> MII;
const int N = 2e5 + 10, MOD = 7+1e9;
int suml[N], sumr[N];
int main()
{
#ifdef YUUKILP
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int n;
    cin >> n;
    cin >> s;
    bool flag = false;
    suml[0] = (s[0] == '#');
    for(int i = 1;i < n;i ++) suml[i] = suml[i-1] + (s[i] == '#');
    sumr[0] = suml[n-1];
    for(int i = 1;i < n;i ++) sumr[i] = suml[n-1] - suml[i-1];
    int ans = min(sumr[0], n - sumr[0]);
    for(int i = 1;i < n;i ++)
    {
        ans = min(ans, suml[i-1] + (n - i - sumr[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2196
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    bool flag=false;
    for(int i=0;i<s.length();++i)
    {
    	if(i%2==0)
    	{
    		if(s[i]=='L')
    		{
    			flag=true;break;
    		}
    	}
    	else
    	{
    		if(s[i]=='R')
    		{
    			flag=true;break;
    		}
    	}
    }
    cout<<(flag?"No":"Yes")<<endl;
}

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

int main() {
	long long int N, D;
	cin >> N >> D;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		long long int x, y;
		cin >> x >> y;
		if (x * x + y * y <= D * D) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main()
{
    int c[3][3];
    int i,j;
    char buf[16];
    int a[3], b[3];
    int flag;

    for(i = 0; i < 3; i++) for(j = 0; j < 3; j++)
        scanf("%d", &c[i][j]);

    for(a[0] = 0; a[0] <= 100; a[0]++){
        for(i = 0; i < 3; i++) b[i] = c[0][i] - a[0];
        for(i = 1; i < 3; i++) a[i] = c[i][0] - b[0];

        flag = 1;
        for(i = 1; i < 3; i++) for(j = 1; j < 3; j++)
            if(c[i][j] != a[i] + b[j]) flag = 0;

        if(flag){
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
    	 Scanner sc = new Scanner(System.in);
    	 sc.useDelimiter("\\n");//
    	 
         while(sc.hasNext()) {
        	 String str = sc.nextLine();
        	 String[] splitted = str.split(" ");// 空白で文字列を分割する
        	 System.out.println(getDigit(getSum(splitted)));
         }
    	if (sc.ioException() != null) {
    	    throw sc.ioException();
    	}
    	
    }
    
    /** 文字列から、和を求めるメソッド */
    public static int getSum(String[] string) {
    	int x = Integer.valueOf(string[0]);
    	int y = Integer.valueOf(string[1]);
    	
    	return x+y;
    }
    
    /** 与えられた整数の桁数を取得するメソッド */
    public static int getDigit(int num) {
    	String str = String.valueOf(num);
    	return str.length();
    }
}

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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
T next_combination(T sub) {
    T x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    ll enda = 0ll, beginb = 0ll, ba = 0ll;
    ll ab = 0ll;

    rep(i, n){
        string s;
        cin >> s;
        int l = s.size();

        if(s[0] == 'B' and s[l-1] == 'A') ++ba;
        if(s[0] == 'B' and s[l-1] != 'A') ++beginb;
        if(s[0] != 'B' and s[l-1] == 'A') ++enda;

        char prev = s[0];
        for(int i = 1; i < l; ++i){
            if(prev == 'A' and s[i] == 'B') ++ab;
            prev = s[i];
        }
    }

    if(ba > 0){
        ppp(ab+ba-1 + (enda!=0) + (beginb!=0) + min(enda-(enda!=0), beginb-(beginb!=0)));
    }
    else{
        ppp(ab+min(enda, beginb));
    }
    // cerr << ab << sp << max(ba-1, 0ll) << sp << (enda!=0) << sp << (beginb!=0) << sp << enda << sp << beginb << endl;
    // cerr << ab << sp << enda << sp << beginb << endl;


    return 0;
}


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

ll n, a, b;

int main() {                

cin >> n >> a >> b;
     
ll d = abs(b - a);
if (d % 2 == 0) {
    cout << d / 2ll;
}
else {
    cout << min(a - 1, n - b) + 1 + ((d - 1) / 2);
}

return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<string> vec(n);

  rep(i, n) { cin >> vec[i]; }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  cout << vec.size();
}

Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	vector<bool> a(n,false);
	vector<int> b(n,1);
	a[0] = true;
	for(int i = 0; i < m; i++) {
		int x,y;cin>>x>>y;
		x--;y--;
		if (a[x] == true){
			a[y] = true;
			b[x] --;
			b[y]++;
			if(b[x] == 0){
				a[x] = false;
			}
		}
		else{
			b[x]--;
			b[y]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if (a[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

N = input()
A = list(map(int, input().split()))

for a in A:
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      print("DENIED")
      exit()
    
print("APPROVED")


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int n, m;
int G[10][10];

int main() {
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a][b] = G[b][a] = 1;
	}

	vector<int> v(n - 1);

	for (int i = 1; i < n; i++)v[i - 1] = i;
	sort(v.begin(), v.end());
	int ans = 0;

	//必ず0からスタート。
	do {
		int now = 0;
		for (int i = 0; i < v.size(); i++) {
			if (G[now][v[i]] == 0)break;

			//つながってたら。更新。
			now = v[i];
			if (i == v.size() - 1)ans++;
		}
	
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main() {
	int n;
	ll int ans = 0;
	cin >> n;
	llint Asum = 0, Bsum = 0, x = 0;
	hei(int) a(n), b(n),s(n,0);
	rep(i, 0, n) {
		cin >> a[i];
		Asum += a[i];
	}
	rep(i, 0, n) {
		int s;
		cin >> s;
		Bsum += s;
		b[i] = a[i] - s;
	}
	if (Bsum > Asum)ans = -1;
	else {
		rep(i, 0, n) {
			if (b[i] < 0)x += -1 * b[i], ans++;
			else s[i] = b[i];
		}
		sort(s);
		for (int i = n - 1;; i--) {
			if (x < 1)break;
			x -= s[i];
			ans++;
		}

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
no = [0]*4
while True:
    try:
        bt = input().split(",")[1]
        if bt=="A": no[0] += 1
        if bt=="B": no[1] += 1
        if bt=="AB": no[2] += 1
        if bt=="O": no[3] += 1
    except EOFError: break
print(no[0])
print(no[1])
print(no[2])
print(no[3])

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

int main(void) {

    string S; cin >> S;
    int K; cin >> K;

    vector<string> substrs;
    for (int k = 1; k <= K; k++) {
        for (int i = 0; i < S.size()-k+1; i++) {
            string tS = S.substr(i, k);
            substrs.push_back(tS);
        }
    }
    sort(substrs.begin(), substrs.end());
    unique(substrs.begin(), substrs.end());

    cout << substrs[K-1] << endl;

    return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a[110000],l,r,mi,f[220000];
long long m;
inline void add(int x){
	while (x<=n+n){
		f[x]++;
		x+=x&(-x);
	}
}
inline long long ask(int x){
	long long ans=0;
	while (x){
		ans+=f[x];
		x-=x&(-x);
	}
	return ans;
}
inline bool che(int x){
	int s=n+1;long long ans=0;//s=n TLE
	fo(i,0,n+n) f[i]=0;
	add(s);
	fo(i,1,n){
		if (a[i]>=x) s++;else s--;
		ans+=ask(s);
		add(s);
	}
	return ans>=m;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	m=n*1ll*(n+1)/2;
	m=(m+1)/2;
	l=0x7fffffff;r=0;
	fo(i,1,n){
		if (a[i]<l) l=a[i];
		if (a[i]>r) r=a[i];
	}
	l--;r++;
	while (l+3<r){
		mi=(l+r)>>1;
		if (che(mi)) l=mi+1;else r=mi-1;
	}
	fd(i,r+1,l-1) if (che(i)){//che(mi)!!!
		printf("%d\n",i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1280
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (0 until h).map { readLine()!! }.toTypedArray()
    val hs = (0 until h).toMutableSet()
    val ws = (0 until w).toMutableSet()

    for (i in 0 until h) {
        if (grid[i].all { it == '.' }) {
            hs.remove(i)
        }
    }

    for (i in 0 until w) {
        if (grid.map { it[i] }.all { it == '.' }) {
            ws.remove(i)
        }
    }

    grid.slice(hs.asIterable()).forEach { println(it.slice(ws.asIterable())) }
}


Measured memory_bytes: 38044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n;
	cin>>n;
	if(n%1000)
		cout<<1000-n%1000;
	else cout<<0;
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  ll M; cin >> M;
  vector<ll> b(M);
  rep(i,M) cin >> b[i];

  map<ll,ll> m;
  rep(i,N) m[a[i]]++;
  ll ans = 0;
  rep(i,M) if(m[b[i]]) ans++;

  cout << ans << endl;
}



Measured memory_bytes: 13332
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let (n, m) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let res = n - m + 1;
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
//const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n, r;
	while (cin >> n >> r, n) {
		vi st(n);
		REP(i, n)
			st[i] = n-i ;

		REP(i, r) {
			vi sw(n);
			REP(i, n)
				sw[i] = st[i];
			int p, c;
			cin >> p >> c;
			REP(j, c)
				sw[j] = st[p-1  + j];
			REP(j, p-1)
				sw[j + c] = st[j];


			REP(i, n)
				st[i] = sw[i];

		}

		cout << st[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3052
#!/bin/sh
read
N_NOT=${REPLY//N/}
W_NOT=${REPLY//W/}
NS=${W_NOT//E/}
WE=${N_NOT//S/}
N=${NS//S/}
W=${WE//E/}
E=${WE//W/}
S=${NS//N/}
N=${#N}
W=${#W}
E=${#E}
S=${#S}
if [ $N -eq 0 -a $S -eq 0 -a $W -eq 0 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -eq 0 -a $S -eq 0 -a $W -ge 1 -a $E -eq 0 ]
then
	echo No
	exit
elif [ $N -eq 0 -a $S -ge 1 -a $W -eq 0 -a $E -eq 0 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -eq 0 -a $W -eq 0 -a $E -eq 0 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -ge 1 -a $W -ge 1 -a $E -eq 0 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -ge 1 -a $W -eq 0 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -eq 0 -a $W -ge 1 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -eq 0 -a $S -ge 1 -a $W -ge 1 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -eq 0 -a $W -ge 1 -a $E -eq 0 ]
then
	echo No
	exit
elif [ $N -ge 1 -a $S -eq 0 -a $W -eq 0 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -eq 0 -a $S -ge 1 -a $W -eq 0 -a $E -ge 1 ]
then
	echo No
	exit
elif [ $N -eq 0 -a $S -ge 1 -a $W -ge 1 -a $E -eq 0 ]
then
	echo No
	exit
fi
echo Yes


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


int main(){
	std::vector<int> c(9);
    for(int i=0;i<9;i++){
        cin >> c[i];
    }

    if((c[0]+c[4]==c[1]+c[3]) && (c[0]+c[8]==c[2]+c[6]) && (c[4]+c[8]==c[5]+c[7]) && (c[2]+c[4]==c[1]+c[5]) && (c[2]+c[6]==c[0]+c[8]) && (c[4]+c[6]==c[3]+c[7])) cout << "Yes" << endl;
    else    cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> temp = new ArrayList<>();
		ArrayList<Integer> temp2 = new ArrayList<>();
		int N = sc.nextInt();
		int[] D = new int[N];
		for(int i = 0;i<N;i++){
			D[i] = sc.nextInt();
			temp.add(D[i]);
		}
		Collections.sort(temp);
		int M = sc.nextInt();
		int[] T = new int[M];
		for(int j = 0;j<M;j++){
			T[j] = sc.nextInt();
			temp2.add(T[j]);
		}
		Collections.sort(temp2);
		//int m = M;
		int c =0;
		int ans=0;
		for(int k=0;k<M;k++){
			for(int a=c;a<N;a++){
				if(temp2.get(k).equals(temp.get(a))){
				    c=a+1;
					ans++;
					break;
				}
			}

		}
		

		if(ans==M){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}
}

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

int main(){
  long long n,k;	cin >> n >> k;
  if(n/k>0){
      n-=n/k*k;
    }
  while(1){
    if(n>abs(n-k)){
      n=abs(n-k);
    }else{
      cout << n;
      return 0;
    }
  } 
}

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

int main(){
  int N_0;
  int a;
  cin >> N_0;
  int N = N_0;
  for(int i = 100000000; i>0; i/=10){
    a += N/i;
    N -= N/i*i;
  }
  a += N;
  if(N_0%a == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
using namespace std;
long long s[200001];
long long ab(long long a){
	return a>0?a:-a; 
} 
int main(){
	int n,i,j,k,l,m;
	long long p=-1,p1,p2,p3,p4,mn,mx;
	scanf("%d",&n);
	for(i=1;i<=n;i++){scanf("%lld",&s[i]);s[i]+=s[i-1];} 
	j=1;
	k=3;
	for(i=3;i<n;i++){
	  while(ab(s[i-1]-s[j]-s[j])>ab(s[i-1]-s[j+1]-s[j+1]))j++;
	p1=s[j];
	p2=s[i-1]-s[j];
	  while(ab(s[n]-s[k]-s[k]+s[i-1])>ab(s[n]-s[k+1]-s[k+1]+s[i-1]))k++;
	  p3=s[n]-s[k];
	  p4=s[k]-s[i-1];
	  mn=p1; 
	  if(mn>p2)mn=p2;
	   if(mn>p3)mn=p3;
	    if(mn>p4)mn=p4;
	    mx=p1;
	     if(mx<p2)mx=p2;
	   if(mx<p3)mx=p3;
	    if(mx<p4)mx=p4;
	    if((mx-mn<p)||(p==-1))p=mx-mn;
	  
	}
	printf("%lld",p);
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=52;
int n,k;
int a[maxn],sum[maxn];
LL dp[3][maxn][maxn*maxn];

int main() {
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=dp[1][0][0]=1;
    int now=0;
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=i;j++)
            for (int k=0;k<=sum[i];k++) {
                dp[now][j][k]=dp[now^1][j][k];
                if (k>=a[i]) dp[now][j][k]+=dp[now^1][j-1][k-a[i]];
            }
        now^=1;
    }

    LL ans=0;
    for (int i=1;i<=n;i++) ans+=dp[now^1][i][i*k];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int q = cin.nextInt();
        String s = cin.next();
        int cnt[] = new int[n];
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                cnt[i + 1]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            cnt[i + 1] = cnt[i] + cnt[i + 1];
        }
        for (int i = 0; i < q; i++) {
            int l = cin.nextInt();
            int r = cin.nextInt();
            l--; r--;
            out.println(cnt[r] - cnt[l]);
        }
    }
}


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

int main() {
	// your code goes here
	long long int n,d;
	scanf("%lld %lld", &n,&d);
	int count=0;
	for(int a=1;a<=n;a++)
	{
		long long int x,y;
		scanf("%lld %lld", &x,&y);
		if((x*x)+(y*y)<=d*d)
		count++;
	}
	printf("%d", count);
	return 0;
}

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

using namespace std;

typedef long long LL;
#define N 3005

const LL mod=1000000007;
LL ans,n,m,C[N][N],f[N],g[N],a[N];
char s[N];

void upd(LL &x,LL y){x=(x+y)%mod;}

int main(){
	scanf("%lld%lld%s",&n,&m,s+1);
	for (LL i=0;i<=n;++i){
		C[i][0]=1;
		for (LL j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for (LL i=1;i<=n;++i) a[i]=s[i]-'0';
	f[0]=1;
	ans=1;
	LL l=1,r=0;
	for (LL i=1;i<=m;++i){
		LL x,y; scanf("%lld%lld",&x,&y);
		if (y<=r) continue;
		if (x>r){
			LL sum=0;
			for (LL j=0;j<=r-l+1;++j){
				upd(sum,f[j]*C[r-l+1][j]);
			}
			ans=ans*sum%mod;
			memset(f,0,sizeof f);
			f[0]=1;
			l=x; r=x-1;
		}
		LL tmp=0;
		for (LL j=r+1;j<=y;++j){
			tmp+=a[j];
		}
		LL len=x-l;
		memset(g,0,sizeof g);
		for (LL j=0;j<=n;++j){
			for (LL k=0;k<=len&&k<=j;++k){
				if (j-k<=r-l+1-len) upd(g[j-k+tmp],f[j]*C[len][k]);
			}
		}
		memcpy(f,g,sizeof f);
		l=x; r=y;
	}
	LL sum=0;
	for (LL j=0;j<=r-l+1;++j){
		upd(sum,f[j]*C[r-l+1][j]);
	}
	ans=ans*sum%mod;
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
int main() {
          
        int n;
        cin>>n;
        vector<int>A(n);int check=0;
        REP(i,0,n)
        {
            cin>>A[i];
            if(A[i]%2==0)
            {
                if(A[i]%3==0 ||A[i]%5==0){}
                else{check=1;}
            }
        }
        if(check==1){cout<<"DENIED";}
        else{cout<<"APPROVED";}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;


public class Main{
   
   

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int min=100000;
        for(int i=1;i<N;i++){
            int sum=0;
            int a=N-i;
            String aa=String.valueOf(a);
            String bb=String.valueOf(i);
            for(int j=0;j<aa.length();j++){
                sum+=Integer.parseInt(""+aa.charAt(j));
            }
            for(int j=0;j<bb.length();j++){
                sum+=Integer.parseInt(""+bb.charAt(j));
            }
            if(sum<min){
                min=sum;
            }
            


        }
        System.out.println(min);


        
        

    }

        
        
    }


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define INF 1000000000000000000
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

int main()
{
    FAST_IO;

    ll r, d, x;
    cin >> r >> d >> x;
    FOR(i, 1, 10) {
        x = r*x-d;
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

taro = 0
hanako = 0

n.times do |i|
   line = gets.chomp.split
   if line[0] == line[1]
      taro += 1
      hanako += 1
   elsif line[0] < line[1]
      hanako += 3
   elsif line[0] > line[1]
      taro += 3
   end
end

puts "#{taro} #{hanako}"

Measured memory_bytes: 8748
def examA():
    A, B, C = LI()
    S = A+B+C
    cur = 0
    for i in range(32):
        if A%2==1 or B%2==1 or C%2==1:
            break
        A = (S-A)//2
        B = (S-B)//2
        C = (S-C)//2
        cur +=1
    if cur==32:
        ans = -1
    else:
        ans = cur
    print(ans)

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3440
#include<stdio.h>

int main(void){
    int n, m, a[100], s, i;

    s = 0;
    scanf("%d%d",&n,&m);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        s = s + a[i];
    }
    
    int index, max, j;
    for(i=0; i<n-1; i++){
        index = i;  max = a[i];
        for(j=i+1; j<n; j++){
            if(max < a[j]){
                max = a[j];
                index = j;
            }
        }
        a[index] = a[i];
        a[i] = max;
    }

    int min = s / (4*m);  /*  printf("%d %d\n",min,s);
    for(i=0; i<n; i++){
        printf("%d ",a[i]); 
    } */
    if(s%(4*m) == 0){
        if(a[m-1] >= min)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else{
        if(a[m-1] > min){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
use List::Util qw(max min);
my @S;
foreach (split(//o, <STDIN>)) {
    chomp($_);
    push(@S, $_) if ($_ ne '');
}
my $i = 0;
my $word = '';
my $wt = '';
foreach my $w (@S) {
    if ($wt eq '') {
        $wt = $w;
    }
    if ($word eq $wt) {
        $wt .= $w;
    } else {
        $word = $wt;
        $wt = '';
        $i++;
    }
}
my $j = 0;
$word = '';
$wt = '';
foreach my $w (reverse @S) {
    if ($wt eq '') {
        $wt = $w;
    }
    if ($word eq $wt) {
        $wt .= $w;
    } else {
        $word = $wt;
        $wt = '';
        $j++;
    }
}
print max($i, $j);

Measured memory_bytes: 35968