akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI gcd(LLI a, LLI b) { return b ? gcd(b, a % b) : a; }
LLI lcm(LLI a, LLI b) { return a * b / gcd(a, b); }

int main()
{
	cout << fixed << setprecision(10);
	LLI n, m;
	cin >> n >> m;
	vector<LLI> a(n);
	REP(i, n)
	{
		cin >> a[i];
		a[i] /= 2;
	}
	LLI l = a[0];
	FOR(i, 1, a.size())
	{
		l = lcm(l, a[i]);
		if (m < l)
		{
			cout << 0;
			return 0;
		}
	}
	REP(i, n)
	{
		if (l / a[i] % 2 == 0)
		{
			cout << 0;
			return 0;
		}
	}
	cout << (m - l) / (l * 2) + 1;
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    cur = 0
    counts = {0 : 1}
    for a in A:
        cur = (cur + a) % M
        if cur in counts:
            counts[cur] += 1
        else:
            counts[cur] = 1
    ret = 0
    #print(counts)
    for val in counts.values():
        #print(val)
        ret += val * (val - 1) // 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19896
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
// #pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    ll ans=-1;
    for(i=0;i<=70000LL;i++)
    {
        if(((ll)(1.08 * i) )== n)
            {   ans=i;
                break;
            }
    }
    if(ans!=-1)
        cout<<ans;
    else
        cout<<":(";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
ll dp[3030];

int main(){
	int s;
	cin>>s;
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = 0;
	dp[3] = 1;
	dp[4] = 1;
	dp[5] = 1;
	for(int i=6;i<=s;i++){
		dp[i] = dp[i-1] + dp[i-3];
		dp[i]%=mod;
	}
	cout<<dp[s]<<Endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,l;
  cin>>n>>l;
  int sum=(2*l+n-1)*n/2;
  int ate=0;
  int a=l,b=l+n-1;
  if(a>=0) ate=a;
  else if(b<=0) ate=b;
  cout<<sum-ate<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int S = Integer.parseInt(br.readLine());
		System.out.print(S/3600);
		System.out.print(":");
		System.out.print(S%3600/60);
		System.out.print(":");
		System.out.println(S%3600%60);

	}
}

Measured memory_bytes: 24260
#include<iostream>
#include<string>

using namespace std;


int main() {
	string str;
	int str_length;
	cin >> str;
	str_length = str.length();
	str.replace(1, str_length - 2, to_string(str_length - 2));
	cout << str << endl;

	return 0;
}


Measured memory_bytes: 3016
n = int(input())
slime = [int(x) for x in input().split()]
border = [0] + [i+1 for i in range(n-1) if slime[i] != slime[i+1]]

if len(border):
  border.append(n)
  count = sum([(border[i+1] - border[i]) // 2 for i in range(len(border) - 1)])
else:
  count = n // 2

print(count)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;main(){int n,a[105],ans=0,tot=1;cin>>n;for(int i=1;i<=n;i++)cin>>a[i];for(int i=2;i<=n;i++){if(a[i]==a[i-1]) tot++;else{ans+=tot/2;tot=1;}}ans+=tot/2;cout<<ans;return 0;}

Measured memory_bytes: 256
N,M = list(map(int, input().split()))
H = list(map(int, input().split()))

P = [1] * N
for m in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] > H[B-1]:
        P[B-1] = 0
    elif H[A-1] < H[B-1]:
        P[A-1] = 0
    else:
        P[A-1]=0
        P[B-1]=0

ans = sum(P)
print(ans)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int Cnt(int x){
  int cnt = 0;
  while((x & 1) == 0){
    x >>= 1;
    cnt++;
  }
  return cnt;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int ans = 0;
  for(auto e:v){
    ans += Cnt(e);
  }
  cout << ans << endl;
}


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

using namespace std;

void FAST_IO() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string format(const string& s, ...) {
    va_list args;
    va_start (args, s);
    size_t len = vsnprintf(NULL, 0, s.c_str(), args);
    va_end (args);
    std::vector<char> vec(len + 1);
    va_start (args, s);
    vsnprintf(&vec[0], len + 1, s.c_str(), args);
    va_end (args);
    return &vec[0];
}

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 2e9;

int N;
vi arr;
vi cnt;

void read() {
	cin >> N;
	arr.resize(N+1);
	cnt.resize(N+1);
	FOR(i,  1,  N) {
		cin >> arr[i];
		cnt[i] = 0;
		int temp = arr[i];
		while (temp % 2 == 0) {
			++cnt[i];
			temp /= 2;
		}
	}
}

void solve() {
	int sum = 0;
	FOR(i, 1, N) {
		sum += cnt[i];
	}
	cout << sum << endl;
}

int main() {
	FAST_IO();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 384
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    As = list(map(int, input().split()))
    buka_graph = [[] for _ in range(n)]

    for i in range(n):
        if i==0:
            continue
        ai = As[i-1]

        buka_graph[ai-1].append(i)

    for i in range(n):
        print(len(buka_graph[i]))
        # print(buka_graph[i])
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 45248
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();

		int nc = n * (n - 1) / 2;
		int mc = m * (m - 1) / 2;

		System.out.println(nc + mc);
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(void)
{
  int n,m,i;
  scanf("%d %d",&n,&m);
  if(n>=m)
  {
    for(i=1;i<=n;i++)
    {
      printf("%d",m);
    }
  }
  else
    for(i=1;i<=m;i++)
    {
      printf("%d",n);
    }
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# coding: utf-8
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    N = int(input())
    c = set()
    for i in range(0, N):
        c.add(input())
    print(len(c))

if __name__ == "__main__":
    main()

Measured memory_bytes: 31160
N = int(input())
S = []
for i in range(N):
    s = sorted(list(input()))
    S.append(''.join(s))
S.sort()
cnt = 1
ans = 0
for i in range(1, N):
    if S[i] == S[i-1]:
        cnt+=1
    else:
        ans+=cnt*(cnt-1)//2
        cnt = 1
ans+=cnt*(cnt-1)//2
print(ans)

        

Measured memory_bytes: 57176
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

using P = pair<ll, ll>;

int main(void){
  ll n;
  cin >> n;
  ll zero = 0;
  map<P, P> mp;
  REP(i, n){
    ll a, b;
    cin >> a >> b;
    if(a == 0 && b == 0){
      zero++;
      continue;
    }
    ll g = gcd(a, b);
    a /= g;
    b /= g;
    if(b < 0){
      a = -a;
      b = -b;
    }
    if(b == 0 && a < 0) a = -a;
    bool rot = (a <= 0);
    if(rot){
      ll tmp = a;
      a = b;
      b = -tmp;
    }
    if(rot) mp[{a, b}].first++;
    else mp[{a, b}].second++;
  }
  mint ans = 1;
  for(auto p : mp){
    ll s = p.second.first;
    ll t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s)-1;
    now += mint(2).pow(t)-1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19228
N = int(input())
a = list(map(int, input().split()))

cnt = [0] * 9

for i in range(N):
    if a[i] >= 3200:
        cnt[8] += 1
    else:
        cnt[ a[i] // 400 ] = 1

subMin = sum(cnt[:-1])
Min = max(subMin, 1)
Max = subMin + cnt[-1]

print(Min, Max)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

const int mod = 1000000007;
struct mint {
  ll x;
  // コンストラクタ。引数のxが負でもxは正になるようにしている
  mint(ll x = 0) : x((x % mod + mod) % mod) {
  }
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const {
    return mint(*this) *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod - 2);
  }
  mint& operator/=(const mint a) {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

signed main() {
  ll N;
  cin >> N;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
  }

  mint ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, N) {
      if (A[j] >> i & 1) {
        x++;
      }
    }
    mint now = x * (N - x);
    rep(j, i) {
      now *= 2;
    }
    ans += now;
  }

  COUT(ans);
  return 0;
}

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

using namespace std ; 

long long int n , a[201] ; 
long long int sum  = 0  ; 
int main (){
	cin >> n ;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
		sum += a[i];
	}
	if (sum%10!=0){
		cout << sum ;
		return 0 ; 
	}
	sort(a+1 , a+1+n);
		for(int i = 1 ; i <= n ; i++){
		if((sum-a[i])%10!=0){
				cout << sum-a[i] ; 
				return 0; 
			}
			
			
		}
		cout << 0 ; 
	}
	
	
	

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

int top, A[1000];

void push(int x){
  top++;
  A[top]=x;
}
int pop(){
  top--;
  return A[top+1];
}

int main(){
int a,b;
top=0;
char s[100];
while (scanf("%s",s)!=EOF) {
  if(s[0]=='+'){
    a=pop();
    b=pop();
    push(a+b);
  }
  else if(s[0]=='-'){
    b=pop();
    a=pop();
    push(a-b);
  }
  else if(s[0]=='*'){
    a=pop();
    b=pop();
    push(a*b);
  }
  else {push(atoi(s));}
}
printf("%d\n",pop());
  return 0;
}



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

int main(){
    int A,B,C,D,E,a,b,c,d,e,k,T;
    cin >> A >> B >> C >> D >> E;
    a = A%10;
    b = B%10;
    c = C%10;
    d = D%10;
    e = E%10;
    if(a==0) a = 10;
    if(b==0) b = 10;
    if(c==0) c = 10;
    if(d==0) d = 10;
    if(e==0) e = 10;
    k = min(a,min(b,min(c,min(d,e))));
    if(a!=10){
        A = A - A%10 + 10;
    }
    if(b!=10){
        B = B - B%10 + 10;
    }
    if(c!=10){
        C = C - C%10 + 10;
    }
    if(d!=10){
        D = D - D%10 + 10;
    }
    if(e!=10){
        E = E - E%10 + 10;
    }    
    T = A + B + C + D + E -10 + k;
    cout << T;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, k;
  int x, y;
  int flg = 0;
  cin >> n >> m >> k;
  for(x = 0; x <= n; x++){
    for(y = 0; y <= m; y++){
      if((n - x) * y + (m - y) * x == k){
        flg = 1;
        break;
      }
    }
  }
  if(flg == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::Chars;

fn to_index(x: &char) -> Option<usize> {
    match x {
        'A' => Some(0),
        'B' => Some(1),
        'C' => Some(2),
        _ => None,
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        mut abc: [usize; 3],
        sss: [Chars; n],
    }

    let mut history: Vec<char> = vec![];

    for (i, xy) in sss.iter().enumerate() {
        let cx = &xy[0];
        let cy = &xy[1];
        let x = to_index(cx).unwrap();
        let y = to_index(cy).unwrap();
        if abc[x] == 0 && abc[y] == 0 {
            println!("No");
            return;
        }
        if abc[x] == 1 && abc[y] == 1 {
            if i == n - 1 || sss[i + 1].contains(cx) {
                abc[x] += 1;
                abc[y] -= 1;
                history.push(*cx);
            } else {
                abc[x] -= 1;
                abc[y] += 1;
                history.push(*cy);
            }
        } else {
            if abc[x] < abc[y] {
                abc[x] += 1;
                abc[y] -= 1;
                history.push(*cx);
            } else {
                abc[x] -= 1;
                abc[y] += 1;
                history.push(*cy);
            }
        }
    }

    println!("Yes");
    for c in history {
        println!("{}", c);
    }
}


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

int main(void) {
      int n, p;
      int bowl, turn, stones;


      while(1) {
          cin >> n >> p;
          if( (n+p) == 0 ) break;


          int* candidate = new int[n];
          for(int i=0; i < n; i++) {
            candidate[i] = 0;
          }
          turn = 0;
          stones = p;
          while(1) {

              if(stones > 0) { //?¢????????°???????????????????
                  stones--;
                  if(++candidate[turn%n] == p) break;
                  turn++;
              } else if(stones == 0) {  //?¢?????°?????????\??????
                  stones += candidate[turn%n];
                  candidate[turn%n] = 0;
                  turn++;
              }
          }
          cout << turn%n << endl;

      }




}

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

const int MAXN = 100;
bool open[10];
long long  answer=-100000000,N;
long long F[MAXN][10];
long long P[MAXN][11];

void BruteForce(int x, bool open_close){
  open[x] = open_close;
  if(x == 9){
    long long benefit = 0;
    int total_open = 0;
    for(int store = 0; store < N; ++store){
      int num_open = 0;
      for(int time = 0; time < 10; ++time){
        if(open[time]){
          num_open += F[store][time];
          ++total_open;
        }
      }
      benefit += P[store][num_open];
    }
    if(answer < benefit && total_open > 0) answer = benefit;
  }
  else{
    BruteForce(x+1,true);
    BruteForce(x+1,false);
  }
}


int main() {
  cin >> N;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < 10; ++j){
      cin >> F[i][j];
    }
  }
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < 11; ++j){
      cin >> P[i][j];
    }
  }
  answer = -1e+7 * N;
  for(int i = 0 ; i < 10; ++i) open[i] = true;
  BruteForce(0,true);
  BruteForce(0,false);
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    string s;cin>>s;
    int i=0,j=s.size()-1,c=0;
    while(i<=j)
    {
    	if(s[i]!=s[j])c++;
    	i++,j--;
    }
    cout<<c;
    return 0;
}


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

const int MOD = 1000000007;

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

int fact_mod(int n, int m) {
	long long res = 1;
	for (int i=n; i>0; --i)
		res = (res * i)%m;
	return (int)res;
}

int comb_mod(int n, int r) {
	long long res = 1;
	for (int i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

int main() {
  // 入力
  ll N, M, K;
  cin >> N >> M >> K;

  ll R = comb_mod(N * M - 2, K - 2);

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
        ll u = (N - i + 1);
        ll d = i;
        ll l = j;
        ll r = (M - j + 1);
        ll D = 0;
        D += u * l * (u + l - 2) / 2;
        D += u * r * (u + r - 2) / 2;
        D += d * l * (d + l - 2) / 2;
        D += d * r * (d + r - 2) / 2;
        D -= u * (u - 1) / 2;
        D -= d * (d - 1) / 2;
        D -= l * (l - 1) / 2;
        D -= r * (r - 1) / 2;
        ans = (ans + D) % MOD;
    }
  }
  ans = (ans * exp_mod(2, MOD-2, MOD)) % MOD;
  ans = (ans * R) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N, M;
ll x[1010], y[1010], z[1010];

int main()
{
  scanf( "%lld%lld", &N, &M );

  rep( i, N )
    scanf( "%lld%lld%lld", x+i, y+i, z+i );

  ll ans = 0;

  rep( S, 1<<3 )
  {
    ll s1 = S&1 ? 1 : -1, s2 = S>>1&1 ? 1 : -1, s3 = S>>2&1 ? 1 : -1;

    std::vector<ll> vs;

    rep( i, N )
      vs.emplace_back( s1*x[i]+s2*y[i]+s3*z[i] );

    std::sort( all(vs) );

    ll sum = 0;
    for( int i = N-1; i >= N-M; --i )
      sum += vs[i];

    chmax( ans, sum );
  }

  printf( "%lld\n", ans );

  return 0;
}

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


// 2011/10/21

//@0140 oXâ 
public class Main {

	/*
	 *  x²ªo0xûü
	 *  y²ªo90xûü
	 *  z²ªkÜ90x(kÉ)ûü
	 */
	
	// kÜÆo©ç »Ìûüðw·PÊxNgðßé
	double[] calc(double hokui, double toukei) {
		
		double z = Math.sin(hokui / 180 * Math.PI);
		double xy = Math.cos(hokui / 180 * Math.PI);
		double x = xy * Math.sin(toukei / 180 * Math.PI);
		double y = xy * Math.cos(toukei / 180 * Math.PI);
		return new double[] { x, y, z };
	}
	
	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int[] ir = readIntArray();
		
		int start = ir[0];
		int goal = ir[1];
		
		int x = start; // »ÝÊu
		int v = 1; // ü« 1 or -1
		
		if (start <= 5 && goal < start) {
			v = -1;
		}
		
		
		String kai = "";
		for(int i = 0;; i++) {
			if (i != 0)
				kai += " ";
			kai += x;
			
			if (x == goal)
				break;

			x += v;
			if (x == 10) {
				x = 5;
				v = -1;
			}
			else if (x < 0) {
				x = 1;
				v = 1;
			}
		}
		
		
		// ðÌ\¦
		System.out.printf("%s\n", kai);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
//			String inputStr = "1,2 4,";
			String inputStr = "1,4 2,";

			inputStr = inputStr.replace(",", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		if (s == null)
			return null;
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 0
H,W=map(int,input().split())
cnt=0
import  sys
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

for i in range(H):
    cnt+=1
    row=list(map(str,input().split()))
    if row.count('snuke') !=0:
        f=row.index('snuke')+1
        ff=num2alpha(f)
        print(ff,cnt,sep='')
        sys.exit()
print('No')


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

using namespace std;

inline int read(){
    int w=1,s=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

int main(){
    string s;
    int flag=0,num=0;
    cin>>s;
    if (s[0]!='A') flag=1;
    if ((s[1]>='A'&&s[1]<='Z')) flag=1;
    if ((s[s.size()-1]>='A'&&s[s.size()-1]<='Z'))  flag=1;
    for(int i=2;i<s.size()-1;i++)
    if (s[i]>='A'&&s[i]<='Z') {
        if(s[i]=='C') num++;
        else flag=1;
    }
    if (flag==1||num>=2||num==0) cout<<"WA";
    else cout<<"AC";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
char str[8][21];
string name[8];
int perm[8];
int h[6][8]={
{0,1,2,3,4,5,6,7},
{1,5,6,2,0,4,7,3},
{5,4,7,6,1,0,3,2},
{4,0,3,7,5,1,2,6},
{4,5,1,0,7,6,2,3},
{3,2,6,7,0,1,5,4},
};
int main(){
	while(~scanf("%s",str[0])){
		for(int i=1;i<8;i++)scanf("%s",str[i]);
		for(int i=0;i<8;i++)name[i]=str[i];
		std::sort(name,name+8);
		set<int>S;
		int sz=0;
		for(int i=0;i<8;i++){
			perm[i]=sz;
			if(i<7&&name[i]!=name[i+1]){
				sz++;
			}
		}
		do{
			int t=0;
			for(int i=0;i<8;i++){
				t*=8;t+=perm[i];
			}
			bool ok=true;
			for(int i=0;i<6;i++)for(int j=0;j<4;j++){
				int tmp=0;
				for(int k=0;k<8;k++){
					tmp*=8;
					tmp+=perm[h[i][k/4*4+(j+k)%4]];
				}
				if(S.count(tmp)){ok=false;break;}
			}
			if(ok){
				S.insert(t);
			}
		}while(next_permutation(perm,perm+8));
		printf("%d\n",(int)S.size());
	}
}

Measured memory_bytes: 1136
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	char c;
	cin >> c;
	cout << ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "vowel" : "consonant") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int IsPrime(int n)
{
  int i;

  if(n < 2)
    return 0;
  else if(n == 2)
    return 1;

  if(n % 2 == 0)
    return 0;

  for(i = 3 ; i <= n / i ; i += 2)
    {
      if(n % i == 0)
	return 0;
    }  
  return 1;
}

int main()
{
  int a,b,i,count = 0;

  scanf("%d",&a);

  for(i = 0 ; i < a ; i++)
    {
      scanf("%d",&b);
      if(IsPrime(b) == 1)
	{
	  count += 1;
	}
    }

  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2056
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if p[i-1] <= p[i] < p[i+1]:
        cnt += 1
    elif p[i-1] > p[i] >= p[i+1]:
        cnt +=1
print(cnt)

Measured memory_bytes: 3060
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)

max_distance = a[1] - a[0]
for i in range(n):
    if a[i + 1] - a[i] > max_distance:
        max_distance = a[i + 1] - a[i]
        
print(k - max_distance)


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


const double PI=3.14159265358979323846;

int main() {
    double a,b,x; cin >> a >> b >> x;

    double suitou = a*a*b;
    double motomeru = suitou - x;

    if(x > suitou/2) {
        auto ans = (atan((2.0*motomeru)/(a*a*a))*180)/PI;
        cout << setprecision(10) << ans << endl;
    } else {
        auto ans = 90.0 - ((atan((2.0*x)/(a*b*b))*180)/PI);
        cout << setprecision(10) << ans << endl;
    }


    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
#define x first
#define y second
const int INF = 1000000000, MAXN = 105;

int N, A[MAXN], res;

int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; ++i) scanf("%d", &A[i]);
	for(int i=2; i<=N; ++i)
		if(A[i] == A[i - 1]){
			for(int x=1; x<=10000; ++x)
				if(A[i - 1] != x && A[i + 1] != x) A[i] = x;
			res++;
		}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    const lines = input.split("\n");
    const [N, R] = lines[0].split(' ').map(v => +v);
    let rating;

    if (N >= 10) {
        rating = R;
    } else {
        rating = R + 1000 - 100*N;
    }

    console.log(rating);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <set>
#include <queue>

struct Worm {
	std::string body;
	int step;
	Worm() {}
	Worm(std::string body, int step) : body(body), step(step) {}
};

bool meetColor(std::string body)
{
	char c = body[0];
	for (int i=1; i<body.length(); i++) {
		if (body[i] != c) return false;
	}
	return true;
}

int getMinStep(std::queue<Worm> que, std::set<std::string>& checked)
{
	while (!que.empty()) {
		Worm worm = que.front(); que.pop();
		if (meetColor(worm.body)) return worm.step;
		if (checked.find(worm.body) != checked.end()) continue;
		checked.insert(worm.body);
		for (int i=0; i<worm.body.length()-1; i++) {
			if (worm.body[i] == worm.body[i+1]) continue;
			std::string new_body = worm.body;
			if (new_body[i] == 'r' && new_body[i+1] == 'g') new_body[i] = new_body[i+1] = 'b';
			else if (new_body[i] == 'r' && new_body[i+1] == 'b') new_body[i] = new_body[i+1] = 'g';
			else if (new_body[i] == 'g' && new_body[i+1] == 'r') new_body[i] = new_body[i+1] = 'b';
			else if (new_body[i] == 'g' && new_body[i+1] == 'b') new_body[i] = new_body[i+1] = 'r';
			else if (new_body[i] == 'b' && new_body[i+1] == 'r') new_body[i] = new_body[i+1] = 'g';
			else new_body[i] = new_body[i+1] = 'r';
			que.push(Worm(new_body, worm.step+1));
		}
	}
	return -1;
}

int main()
{
	std::string worm;
	while (true) {
		std::cin >> worm;
		if (worm=="0") break;
		std::queue<Worm> que;
		que.push(Worm(worm,0));
		std::set<std::string> checked;
		int res = getMinStep(que, checked);
		if (res >= 0) std::cout << res << std::endl;
		else std::cout << "NA" << std::endl;
	}
	return 0;
}



Measured memory_bytes: 4804
using System;
using System.Linq;
using System.Collections.Generic;

class Plogram
{
    static void Main()
    {
        var array = new List<int>();
        for (int i = 0; i < 5; i++)
        {
            array.Add(int.Parse(Console.ReadLine()));
        }

        var order = array.OrderByDescending(x => (x-1) % 10).ToArray();

        int total = 0;

        for(int i =0; i<5; i++)
        {
            if(total % 10 != 0)
            {
                total += order[i] + (10 - total % 10);
            }
            else
            {
                total += order[i];
            }
        }
        Console.WriteLine(total);
    }
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
v_ll A;
int main(){
  cin >> N;
  A.assign(N+10,0);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  sort(A.begin()+1,A.begin()+N+1);
  if (N%3==0){
    for (ll i=2;i<=N/3;i++){
      if (A[i]!=A[i-1]){
        cout << "No" << endl;
        return 0;
      }
    }
    for (ll i=N/3+2;i<=2*N/3;i++){
      if (A[i]!=A[i-1]){
        cout << "No" << endl;
        return 0;
      }
    }for (ll i=2*N/3+2;i<=N;i++){
      if (A[i]!=A[i-1]){
        cout << "No" << endl;
        return 0;
      }
    }
    if ((A[N/3]^A[N*2/3])==A[N]){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  else
  {
    for (ll i=1;i<=N;i++){
      if (A[i]!=0){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int min, max, num, count=0;
    scanf("%d %d %d", &min, &max, &num);
    for(int i=min; i<=max; i++){
        if(num%i == 0){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2112
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

template <typename T>
struct FenwickTree {
  vector<T> v;
  int n;
  FenwickTree(int n) : n(n) {
    v = vector<T>(n);
  }
  void update(int i, T x) {
    for (i++; i <= n; i += i & -i) v[i - 1] += x;
  }
  T query(int i) {
    T r = 0;
    for (; i >= 1; i -= i & -i) r += v[i - 1];
    return r;
  }
};

void solve() {
  int n, q;
  cin >> n >> q;
  vi32 c(n);
  cin >> c;
  rep(i, n) c[i]--;
  FenwickTree<int> ft(n);
  vi32 indices(n, -1);
  vi32 next(n, n);
  rep(i, n) {
    if (indices[c[i]] != -1) {
      int x = indices[c[i]];
      next[x] = i;
    } else {
      ft.update(i, 1);
    }
    indices[c[i]] = i;
  }
  using T = int;
  vector<vector<T>> events(n);
  vi32 l(q), r(q);
  rep(i, q) {
    cin >> l[i] >> r[i];
    l[i]--;
    events[l[i]].emplace_back(i);
  }
  vi32 ans(q);
  rep(i, n) {
    for (auto x : events[i]) {
      ans[x] = ft.query(r[x]) - ft.query(l[x]);
    }
    ft.update(i, -1);
    if (next[i] < n) ft.update(next[i], 1);
  }
  rep(i, q) {
    cout << ans[i] << endl;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 38140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);

       String str_A = scan.next();
       String str_B = scan.next();
       String str_C = scan.next();
       check_input(str_A);
       check_input(str_B);
       check_input(str_C);

       int pos_A = 0;
       int pos_B = 0;
       int pos_C = 0;

       char ch = str_A.charAt(pos_A);
       pos_A++;

       while (pos_A <= str_A.length() ||
              pos_B <= str_B.length() ||
              pos_C <= str_C.length() ) {
           if (ch == 'a') {
              if ( pos_A == str_A.length() ) {
                 System.out.println('A');
                 break;
              } else {
                 ch = str_A.charAt(pos_A);
                 pos_A++;
              }
           } else if (ch == 'b') {
              if ( pos_B == str_B.length() ) {
                 System.out.println('B');
                 break;
              } else {
                 ch = str_B.charAt(pos_B);
                 pos_B++;
              }
           } else if (ch == 'c') {
              if ( pos_C == str_C.length() ) {
                 System.out.println('C');
                 break;
              } else {
                 ch = str_C.charAt(pos_C);
                 pos_C++;
              }
           } else {
              System.exit(-1);
           }
       }
   }
   public static void check_input(String str) {
       if ((str.length() < 1) || (str.length() > 100)) {
           System.exit(-1);
       }
   }
}

Measured memory_bytes: 9552
#include <iostream>

using namespace std;

int main(void){
    int k,a,b;
    cin >> k >> a >> b;
    for(;a<=b;a++)
        if(a%k==0)
            break;
    if(a==b+1)
        cout << "NG";
    else
        cout << "OK";
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define mod 998244353
const ll N =30005 ;
ll dp[2*N] ;


int main ()
{
    ll n , t ;
    cin>> n >> t ;
    ll i ,j,x,y;
    dp[0] = 1 ;
    vector<pair<ll,ll> > v(n) ;
    for(i = 0 ; i< n ;i++) cin >> v[i].first >> v[i].second ;
    sort(v.begin(),v.end()) ;
    for(i = 1 ; i<= n ; i++) {
        x = v[i-1].first , y = v[i-1].second ;
        for (j = t-1 ; j>=0 ; j--) if (dp[j]) dp[j+x] = max(dp[j+x],dp[j]+y) ;

    }
    ll ans = 0 ;
    for (i = 0 ; i<2*N ; i++) ans = max(ans,dp[i]) ;
    cout << ans -1 << endl ;
    return 0 ;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[5][5],B[200005],fix[5][5];
int main() {
    for(long long i=1;i<=3;i++) {
        for(long long j=1;j<=3;j++) {
            cin>>A[i][j];
        }
    }
    cin>>n;
    for(long long a=1;a<=n;a++) {
    cin>>B[a];
        for(long long i=1;i<=3;i++)
            for(long long j=1;j<=3;j++)
            if(B[a]==A[i][j]) fix[i][j]=1;
    }
    for(long long i=1;i<=3;i++) {
        if(fix[1][i]==0) a=1;
        if(fix[i][1]==0) b=1;
        if(fix[2][i]==0) e=1;
        if(fix[i][2]==0) f=1;
        if(fix[3][i]==0) g=1;
        if(fix[i][3]==0) l=1;
        if(fix[i][i]==0) c=1;
        if(fix[3-i+1][i]==0) d=1;
    }
    if(a==1 && b==1 && c==1 && d==1 && e==1 && f==1 && g==1 && l==1) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    t = input()

    res = len(t)
    for i in range(len(s) - len(t) + 1):
        tmp = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                tmp += 1
        res = min(res, tmp)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9116
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define MAX 100000

int main(){
    char s[200000];
    int start, fin;
    bool b=1;
    scanf("%s", s);
    rep(i,strlen(s)){
        if(s[i]=='A' && b){
            start = i;
            b = 0;
        }
        else if (s[i] == 'Z'){
            fin = i;
        }
    }
    cout << fin - start + 1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 200009;
const double pi = acos(-1.0);
int r;
int main(){
    scanf("%d",&r);
    printf("%.8lf",2*pi*r);
    return 0;
}

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

const int maxn = 2e5+5;
typedef long long ll;
char s[maxn];
const ll p = 1e9+7;
ll n, qk[maxn], jc[maxn];

signed main(){
    scanf("%lld %s", &n, (s+1));
    jc[0] = 1;
    for(int i = 1; i <= n; i++) jc[i] = jc[i-1] * i % p;
    int tot = 0, valid = 1;
    for(int  i =1; i <= n*2; i++) {
        if(s[i] == 'B') {
            if(tot % 2 == 0) qk[i] = 1, tot++;
            else qk[i] = -1, tot--;
        } else {
            if(tot % 2 == 0) qk[i] = -1, tot--;
            else qk[i] = 1,  tot++;
        }
        if(tot < 0) valid = 0;
    }
    if(tot > 0) valid = 0;
    if(valid == 0) {
        puts("0"); 
        return 0; 
    }

    ll ans = 1, sum = 0;
    for(int i = 1; i <= 2*n; i++) {
        if(qk[i] == -1) ans = ans * sum % p;
        sum += qk[i];
        // printf("%lld ", qk[i]);
    }
    ans = ans * jc[n] % p;

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int a,n[100005],ans;
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		cin>>n[i];
		ans+=n[i];
	}
	if((ans%2)==0)	cout<<"YES"<<endl;
	else	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 640