akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
class Program
    {
        static void Main(string[] args){          
            bool b = new Calu().calu(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
            Console.WriteLine(b ? "YES" : "NO");     
        }
        public class Calu {
            public Calu() { }
            public bool calu(int[] a){      
                if (a[1] - a[0] == a[2] - a[1]) return true;
                return false;      
            }
        } 
    }

Measured memory_bytes: 13268
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  b=list(map(int,input().split()))
  for i in range(b[0]):
    a[b[i+1]-1]+=1
ans=0
for i in a:
  if i==n:
    ans+=1
print(ans)

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

int le[300005],ri[300005];

int main(){
    int n; cin>>n; 
    string s; cin>>s; 
    int ans=INT_MAX;
    for(int i=2;i<=n;++i)le[i]=le[i-1]+(s[i-2]=='W');
    for(int i=n-1;i>=1;--i)ri[i]=ri[i+1]+(s[i]=='E');
    for(int i=1;i<=n;++i)ans=min(ans,le[i]+ri[i]);
    cout<<ans<<endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int dis[256] {};
    for (int i = 0; i < k; i++) {
        char d;
        cin >> d;
        dis[d] = 1;
    }
    for (int i = n; i < 1000000; i++) {
        string s = to_string(i);
        int ok = 1;
        for (char c : s) {
            if (dis[c]) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            cout << s << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
while True:
	n, s = map(int, raw_input().split())
	if n == 0: break
	cnt = 0
	queue = [[0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]
	while queue != []:
		now = queue.pop(0)
		newlist = []
		for i in range(0, len(now[2])):
			newlist.append(now[2][i])
		if now[0] == n:
			if now[1] == s: cnt += 1
		elif n - now[0] <= len(now[2]):
			a = newlist.pop(0)
			queue.append([now[0]+1, now[1]+a, newlist])
			queue.append([now[0], now[1], newlist])
	print cnt


Measured memory_bytes: 4684
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int c=0;
    erep(i,a){
        if(i%2==1)c++;
    }
    if(c%2==0)std::cout << YES << std::endl;
    else std::cout << NO << std::endl;
}

Measured memory_bytes: 640
#include <stdio.h>
 #include <string.h>

 int main(void){
 char s[100 + 1];

 scanf("%s", s);

 int n = strlen(s); 
 for (int i = 0; i < n; i++) {
 if (i % 2 == 0) {

 if (s[i] == 'L') {
puts("No"); return 0;
 }
 } else {

 if (s[i] == 'R') {
puts("No"); return 0;
}}}

 puts("Yes");
 return 0;
 }


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


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












Measured memory_bytes: 3584
#include<iostream>
#include <cstdio>

using namespace std;

void bubblesort(int A[], int N) {

	int i, j, temp, count = 0;
	bool flag = 1;

	for (i = 0; flag; i++) {
		flag = 0;
		for (j = N-1; j >= i+1; j--){
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				count++;
				flag = 1;
			}
		}
	}

	for (i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
}

int main() {
	
	int N, i, A[100];

	cin >> N;
	for (i = 0; i < N; i++)
		cin >> A[i];

	bubblesort(A, N);

	return 0;

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef vector<DVec> TVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi                first
#define se                second
#define pb                push_back
#define INF               LLONG_MAX/3
#define MOD               1000000007
#define bcnt              __builtin_popcount
#define all(x)            (x).begin(),(x).end()
#define srt(x)            sort(all(x))
#define rvs(x)            reverse(all(x))
#define uni(x)            x.erase(unique(all(x)),x.end())
#define ub(x,y)           (upper_bound(all(x),y)-x.begin())
#define lb(x,y)           (lower_bound(all(x),y)-x.begin())
#define rep(i,n)          repl(i,0,n-1)
#define mkp(x,y)          make_pair(x,y)
#define mmax(x,y)         (x>y?x:y)
#define mmin(x,y)         (x<y?x:y)
#define maxch(x,y)        x=mmax(x,y)
#define minch(x,y)        x=mmin(x,y)
#define exist(x,y)        (find(all(x),y)!=x.end())
#define each(itr,v)       for(auto itr:v)
#define repl(i,a,b)       for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)     DVec(n1,Vec(n2,i))
#define tvec(n1,n2,n3,i)  TVec(n1,dvec(n2,n3,i))

int main() {
  cin.sync_with_stdio(false);
  ll n;
  cin >> n;
  Vec a(n);
  rep(i,n)cin >> a[i], a[i]-=i+1;
  srt(a);
  ll b = a[(a.size()-1)/2];
  ll sum = 0;
  rep(i,n)sum += abs(a[i] - b);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    sort(a.rbegin(), a.rend());
    auto r = irange(0L, n);
    auto ans = partition_point(r.begin(), r.end(),
                               [&](int64_t idx) {
                                   if (idx < p) {
                                       return true;
                                   }

                                   auto aa = a[idx];

                                   auto b = aa + m;
                                   int64_t j =
                                           lower_bound(a.begin(), a.end(), b,
                                                       greater<int64_t>()) -
                                           a.begin();
                                   if (j >= p) {
                                       return false;
                                   }

                                   auto d = m * v;
                                   d -= m * p;

                                   for (int64_t k = p - 1; k < n; ++k) {
                                       if (k == idx) {
                                           continue;
                                       }

                                       d -= min(b - a[k], m);
                                   }

                                   return d <= 0;
                               }) -
               r.begin();

    cout << ans << endl;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	int ans = 0;
	rep(i, 1, 30) {
		int t = 1 << i;
		vector<int> c=a;
		rep(j, 0, n) c[j]%= t;
		sort(c.begin(), c.end());
		int cnt = 0;
		rep(j,0,n){
			int d = b[j] % t;
			cnt += lower_bound(c.begin(), c.end(), 2 * t/2 - d)-c.begin();
			cnt += lower_bound(c.begin(), c.end(), 4 * t/2 - d) - c.begin();
			cnt -= lower_bound(c.begin(), c.end(), 1 * t/2 - d) - c.begin();
			cnt -= lower_bound(c.begin(), c.end(), 3 * t/2 - d) - c.begin();
		}
		if (cnt % 2) {
			ans += t/2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    S = input()
    ans = ""
    for i in range(N):
        if i == K - 1:
            ans += S[i].lower()
        else:
            ans += S[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

bool check(ll n, vi a)
{
	ll fir = 0, sec = 0;
	ll cnt = 0;
	for(ll i = 1; i < n; ++i)
	{
		if(a[i] < a[i - 1])
		{
			cnt++;
			if(fir == 0)
				fir = i;
			else
				sec = i;
		}
	}
	if(cnt > 2)
		return false;
	else if(cnt == 0)
		return true;
	if(cnt == 2)
		swap(a[fir - 1], a[sec]);
	else if(cnt == 1)
		swap(a[fir - 1], a[fir]);
	for(ll i = 1; i < n; ++i)
	{
		if(a[i] < a[i - 1])
			return false;
	}
	return true;
}

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

	ll n = 0;
	cin >> n;
	vi a(n);
	rep(i, n)	cin >> a[i];
	bool ans = check(n, a);
	if(ans)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	#ifdef LOCAL_DEFINE
		cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}



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

int comp(const void *p1, const void *p2);

int main(void){
		int n,i,size,count,tmp,index;
		unsigned long long pattern,*mul;
		int *array, *sortArr,*kind,*num;
			
		scanf("%d",&n);
		array=(int *)calloc(n,sizeof(int));
		sortArr=(int *)calloc(n,sizeof(int));
		for(i=0;i<n;i++){
			scanf("%d",&array[i]);
			sortArr[i]=array[i];
		}
		qsort(sortArr,n,sizeof(int),comp);
		/*
		for(i=0;i<n;i++){
			printf("%d%c",sortArr[i],(i<n-1)?' ':'\n');
		}*/
		size=0;
		tmp=0;
		for(i=0;i<n;i++){
			if(tmp!=sortArr[i]){
				size++;
				tmp=sortArr[i];
			}
		}
		kind=(int *)calloc(size,sizeof(int));
		num=(int *)calloc(size,sizeof(int));
		mul=(unsigned long long *)calloc(size,sizeof(unsigned long long));
		index=0;
		tmp=sortArr[0];
		count=0;
		pattern=0;
		for(i=0;i<=n;i++){
			if(i<n && tmp==sortArr[i]){
				count++;
			}else{
				kind[index]=tmp;
				num[index]=count;
				mul[index]=(unsigned long long)count*(count-1)/2;
				//fprintf(stderr,"count: %d, mul: %llu\n", count,mul[index]);
				pattern+=mul[index];
				index++;
				count=1;
				if(i<n) tmp=sortArr[i];
			}
		}
		/*
		for(i=0;i<size;i++){
			printf("%d%c",kind[i],(i<size-1)?' ':'\n');
		}
		*/
		int diff;
		for(i=0;i<n;i++){
			diff=(int *)bsearch(array+i,kind,size,sizeof(int),comp)-kind;
			//printf("%p %p\n",sIndex,kind);
			printf("%llu\n",pattern-mul[diff]+(unsigned long long)(num[diff]-1)*(num[diff]-2)/2);
		}
		free(array);
		free(sortArr);
		free(kind);
		free(num);
		free(mul);
		return 0;
	}
	
	int comp(const void *p1, const void *p2){
		int n1,n2;
		n1=*((const int *)p1);
		n2=*((const int *)p2);
		return n1-n2;
	}
	
			


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

constexpr int64_t M = 1000000007;

int64_t mpow(int64_t x, int64_t n) {
  int64_t ans = 1;
  while (n != 0) {
    if (n & 1) {
      ans = ans * x % M;
    }
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}


int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n, -1);

  int64_t first, second;
  for (int64_t i = 0; i <= n; i++) {
    int64_t t;
    std::cin >> t;
    if (a[t - 1] == -1) {
      a[t - 1] = i;
    } else {
      first = a[t - 1];
      second = i;
    }
  }
  int64_t l = first + n - second;

  int64_t v1 = 1, v2 = 1;
  for (int64_t i = 0; i <= n; i++) {
    v1 *= n + 1 - i;
    v1 %= M;
    v1 *= mpow(i + 1, M - 2);
    v1 %= M;
    if (i == 0) {
      v2 = 1;
    } else if (i <= l) {
      v2 *= l - (i - 1);
      v2 %= M;
      v2 *= mpow(i, M - 2);
      v2 %= M;
    } else {
      v2 = 0;
    }
    if (v1 < v2) {
      std::cout << v1 - v2 + M << std::endl;
    } else {
      std::cout << v1 - v2 << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2048
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
            else:
                ans += 0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define MAX_N 10000000
#define ll int64_t
#define all(v) (v).begin(),(v).end()
using namespace std;

int main() {
    //入力
    int n,count=0; cin>>n;
    vector<int> b(n-1);
    rep(i,n-1) cin>>b[i];
    vector<int> a(n);
    a[0]=b[0];
    for(int i=1;i<=n-2;i++) {
        a[i]=min(b[i],b[i-1]);
    }
    a[n-1]=b[n-2];
    rep(i,n)  count+=a[i];
    cout<<count<<endl;
    return 0;
} 

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   map<string,int> c;
   int n;
   cin >> n;
   while(n--){
      string s;
      cin >> s;
      c[s]++;
   }
   cout << "AC x " << c["AC"] << '\n';
   cout << "WA x " << c["WA"] << '\n';
   cout << "TLE x " << c["TLE"] << '\n';
   cout << "RE x " << c["RE"] << '\n';
   return 0;
} 

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int ans = 0;
  if( A == B && B == C && A % 2 == 0 ){
    cout << -1 << endl;
    return 0;
  }else if( A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ){
    cout << 0 << endl;
    return 0;
  }else{
    int a, b, c;
    while( A % 2 == 0 && B % 2 == 0 && C % 2 == 0 ){
      ans++;
      a = (B+C)/2;
      b = (A+C)/2;
      c = (A+B)/2;
      A = a;
      B = b;
      C = c;
    }
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
li1 = list(map(int,input().split()))
li1.extend(list(map(int,input().split())))
li1.extend(list(map(int,input().split())))
n = int(input())
for i in range(n):
  p = int(input())
  li1 = [0 if j == p else j for j in li1]
if ( li1[0] + li1[1] + li1[2] ) == 0:
  print('Yes')
elif ( li1[3] + li1[4] + li1[5] ) == 0:
  print('Yes')
elif ( li1[6] + li1[7] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[3] + li1[6] ) == 0:
  print('Yes')
elif ( li1[1] + li1[4] + li1[7] ) == 0:
  print('Yes')
elif ( li1[2] + li1[5] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[4] + li1[8] ) == 0:
  print('Yes')
elif ( li1[2] + li1[4] + li1[6] ) == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
s=set
def f(n):
 a=2;t=[]
 while a*a<=n:
  while n%a==0:
   n//=a;t.append(a)
  a+=1
 if n>1:
  t.append(n)
 return t
a,b=map(int,input().split())
print(len(s(f(a))&s(f(b)))+1)

Measured memory_bytes: 3060
/* Filename: ABC043C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int N = input.nextInt();
			int[] a = new int[N];
			
			int sumA = 0;
			for(int i = 0; i < a.length; ++i){
				a[i] = input.nextInt();
				sumA += a[i];
			}
			
			int avgA = (int)Math.round(sumA / (double)N);
			int cost = 0;
			
			for(int i = 0; i < a.length; ++i){
				cost += (avgA - a[i]) * (avgA - a[i]);
			}
			
			System.out.println(cost);
		}
	}

}


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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int XMAX = X, YMIN = Y;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		XMAX = max(x, XMAX);
	}
	for (int i = 0; i < M; i++) {
		int y;
		cin >> y;
		YMIN = min(y, YMIN);
	}
	cout << (XMAX < YMIN ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<int> find_all(string str, string subStr){
    vector<int> ret(0);

    int subStrSize=subStr.size();
    int pos = str.find(subStr);

    while (pos != string::npos){
        ret.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }

    return ret;
}

string str;
vector<string> strs={"dreamer", "eraser", "dream", "erase"};
bool search(int n){
    if (n==(int) str.size()){
        return true;
    }
    for(int i=0; i<4; i++){
        int size=strs[i].size();
        if(str.substr(n,size)==strs[i]){
            if(search(n+size)){
                return true;
            }
        }
    }
    return false;
}

int main(){
    cin >> str;

    string t;
    string ans="NO";
    
    if(search(0)){
        ans="YES";
    }

    cout << ans << endl;

}

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

int main(void) {
    string S, T;
    cin >> S >> T;
    int size, count = 0;
    size = S.length();
    for (int i = 0; i < size; i++) {
        if (S[i] != T[i]) {
            ++count;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 3848
// ConsoleApplication95.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

// ConsoleApplication94.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<set>
using namespace std;
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
long long exgcd(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1, y = 0;
		return a;
	}
	long long d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int main()
{
	set<int>la;
	bool aa = false;
	int n,a[3][3],qq;
	for (int i = 0; i < 3; i++)
	{
		for (int p = 0; p < 3; p++)
		{
			cin >> a[i][p];
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> qq;
		la.insert(qq);
	}
	for (int i = 0; i < 3; i++)
	{
		if (la.count(a[i][1]) && la.count(a[i][0]) && la.count(a[i][2]))
		{
			aa = true;
		}
		if (la.count(a[0][i]) && la.count(a[1][i]) && la.count(a[2][i]))
		{
			aa = true;
		}
	}
	if (la.count(a[0][0]) && la.count(a[1][1]) && la.count(a[2][2]))
	{
		aa = true;
	}
	if (la.count(a[0][2]) && la.count(a[1][1]) && la.count(a[2][0]))
	{
		aa = true;
	}
	if (aa)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long 
using namespace std;

ll dp[100000];
ll h[100000];
int n, k;

ll solve(int p){
  if(p == n - 1)
    return 0;
  
  if(p >= n)
    return 10000000000ll;
  
  if(dp[p] != -1)
    return dp[p];
  
  ll res = 10000000000ll;
  for(int i = 1; i <= k; i++){
    res = min(res, abs(h[p] - h[p + i]) + solve(p+i));
  }
  return dp[p] = res;
}

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

    memset(dp, -1, sizeof dp);

    for(int i = 0; i < n; i++)
      cin >> h[i];

    cout << solve(0) << endl;

    return 0;
}

Measured memory_bytes: 12932
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n;
int bio[55560];
vector<int> v;

int main () {

	cin >> n;
	for (int i = 2; i <= 55555; i ++) {
		if (bio[i] == 1) continue;
		if (v.size() < n && i % 5 == 1) v.push_back(i);
		for (int j = i+i; j <= 55555; j += i) bio[j] = 1;
	}
	
	for (int i = 0; i < n; i ++) cout << v[i] << " ";

	return 0;
}

Measured memory_bytes: 512
object Main {

  val MAX = 1000000007L

  case class State(patterns: Long, lastBlock: Int) {
    def process(top: Char, bottom: Char): State =
      lastBlock match {
        case 1 if top == bottom => copy(patterns = (patterns * 2L) % MAX)
        case 1 if top != bottom => copy(patterns = (patterns * 2L) % MAX, lastBlock = 3)
        case 2 if top == bottom => copy(lastBlock = 1)
        case 2 if top != bottom => copy(patterns = (patterns * 3L) % MAX, lastBlock = 3)
        case 3 => copy(lastBlock = 2)
      }
  }
  object State {
    def init(top: Char, bottom: Char): State =
      if (top == bottom) State(3, 1) else State(6, 3)
  }

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val _ = sc.nextInt(); sc.nextLine()
    val S1, S2: Array[Char] = sc.nextLine().toCharArray

    // ブロックの並びは固定なので, 色を並び替えた場合の通りのみを考える
    // 決める時に左から決めていけばいい
    // 一個左のブロックの状況で,次おけるブロックの色が定まる
    // * 縦r
    // * 縦g
    // * 縦b
    // * 横rg
    // * 横rb
    // * 横gr
    // * 横gb
    // * 横br
    // * 横bg
    // (横に並ぶブロック x 2) => (横に並ぶブロック x 2) が現れた際には, 最初の2つのブロックの色が決定した時, 3通りの配置が可能
    // r,g r,b r,g
    // g,r g,r g,b
    // (横に並ぶブロック x 2) => (縦のブロック) が現れた際には, 最初の2つのブロックの色が決定した時, 1通りの配置が可能
    // r,b
    // g,b
    // (縦のブロック) => (横に並ぶブロック x 2) が現れた際には, 縦のブロックの色が決定した時, 4通りの配置が可能
    // r,
    // r,
    // (縦のブロック) => (縦のブロック) が現れた際には, 縦のブロックの色が決定したあと, 2通りの配置が可能
    // r,b r,g
    // 初回のやつだけ条件が異なる
    // 初回の縦ブロックは, 3通り置ける
    // 初回の横2つブロックは, 6通り置ける
    // 以降は, 前述の条件にしたがって掛け算で増えていく
    // なので, 左から見ていって, reduceしていけばいい

    val S = (S1 zip S2)
    val state = State.init(S.head._1, S.head._2)
    val result = S.tail.foldLeft(state)((state, next) => state.process(next._1, next._2)).patterns
    println(result)
  }

}


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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
	int a, b;
	cin >> a >> b;
	if ((b - a) % 2 == 0) {
		int ans = (a + b) / 2;
		cout << ans << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

ans = []
for s in list(S):
    if s != "B":
        ans.append(s)
    elif len(ans)==0:
        pass
    else:
        ans.pop()

print(*ans,sep="")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.PriorityQueue;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    PriorityQueue pq = new PriorityQueue();
    int A = sc.nextInt();
    pq.add(sc.nextInt()/A);
    pq.add(sc.nextInt());
    System.out.println(pq.poll());
  }
}

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

int main()
{
    string s;
    cin >> s;

    int len = s.size();
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            cnt++;
        }
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>	// require sort next_permutation etc.
#include <numeric>	// require accumulate
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.icpc", "r", stdin );
	int n;

	while (cin >> n ) {
		vector <int> p (n, 0 );
		int i;

		for (i = 0; i < n; ++i){
			cin >> p[i];
		} // end for
		sort (p.begin(), p.end() );

		int res = 0;
		for (i = 0; i < n; ++i){
 			res += accumulate (p.begin(), p.begin() + i + 1, 0 );
		} // end for

		cout << res << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int partition(vector<int> &a,int p,int r){
    int x,i,j,t;
    x = a[r];
    i = p-1;
    for(j=p;j<r;j++){
        if(a[j]<=x){
            i++;
            t = a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    t = a[i+1];
    a[i+1] = a[r];
    a[r] = t;
    return i+1;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    int q = partition(a,0,n-1);
    REP(i,n){
        if(i) cout<<" ";
        if(i==q) cout<<"[";
        cout<<a[i];
        if(i==q) cout<<"]";
    }
    cout<<endl;
}


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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int cnt=0;
    for(int i=0;i<k;i++){
        if(a<b){
            break;
        }
        cnt++;
        b*=2;
    }
    for(int j=0;j<k-cnt;j++){
        if(b<c){
            break;
        }
        c*=2;
    }
    if(a<b && b<c){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
const int N = 200;

int main()
{
    int r, c, a[N][N];

    scanf("%d %d", &r, &c);

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            a[i][c] += a[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            a[r][j] += a[i][j];
        }
    }
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            printf("%d", a[i][j]);
            if (j != c)
                printf(" ");
        }
        puts("");
    }
}


Measured memory_bytes: 2692
#include<stdio.h> 
#include<string.h>
int main(){
	char c,s[30];
	int len,i,j,n,flag;
	len=i=j=n=flag=0;
	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++){
		c=s[i];
		for(j=0;j<len;j++){
			if(c==s[j] && j!=i){
				flag=1;
				break;
			}
		}
	}
	if(flag==0){
		printf("yes");
	}
	else{
		printf("no");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n,m;
	while(~scanf("%d",&n)){
		if(n==0) break;
		scanf("%d",&m);
		int* mincost = new int[n];
		bool* used = new bool[n];
		fill((bool*)used,(bool*)used + n,false);
		fill((int*)mincost,(int*)mincost + n,numeric_limits<int>::max());
		int** cost = new int*[n];
		for(int i=0;i<n;i++){
			cost[i] = new int[n];
			for(int j=0;j<n;j++)cost[i][j]=numeric_limits<int>::max();
		}
		for(int i=0;i<m;i++){
			int from,to,dist;
			scanf("%d,%d,%d",&from,&to,&dist);
			cost[from][to] = min(cost[from][to],dist / 100 - 1);
			cost[to][from] = min(cost[to][from],dist / 100 - 1);
		}
		mincost[0]=0;
		int res=0;
		while(1){
			int v=-1;
			for(int u=0;u<n;u++)
				if(!used[u] && (v==-1 || mincost[u] < mincost[v]))
					v = u;
			if(v==-1) break;
			used[v] = true;
			res+=mincost[v];
			for(int u=0;u<n;u++)mincost[u] = min(mincost[u],cost[v][u]);
		}
		cout << res << endl;
		for(int i=0;i<n;i++)delete[] cost[i];
		delete[] cost;
	}
}

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


int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    int s=0;

    for(int i=0;i<n;i++){
        cin>>v[i];
    }

    int sum;

    int ans=INT_MAX;
    for(int j=1;j<=100;j++){
            sum=0;
          for(int i=0;i<n;i++){
          sum+=(v[i]-j)*(v[i]-j);
    }
          ans=min(ans,sum);
    }
    cout<<ans<<endl;




      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//  #include <boost/multiprecision/cpp_int.hpp>
//  namespace mp = boost::multiprecision;
 #define mod 1000000007
using namespace std;

typedef long long int  ll;

int main()
{
    ll n,k;
    cin>>n>>k;
    if(k==1){ cout<<0<<endl; return 0; }
    cout<<n-k<<endl;
    
    
    
}

Measured memory_bytes: 256
D,N =map(int,input().split())
if D ==0 and N <100:
    print(N)
elif D ==0 and N ==100:
    print(N+1)
elif D == 1 and N <100:
    print(N*100)
elif D ==1 and N ==100:
    print((N+1)*100)

elif D == 2 and N <100:
    print(10000*N)
elif D == 2 and N==100:
    print((N+1)*10000)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll& O)
{
	cout << O;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

int main()
{
	str S;
	in(S);

	ll A, B;

	A = (S[0] - '0') * 10 + S[1] - '0';
	B = (S[2] - '0') * 10 + S[3] - '0';

	bool YYMM = false;
	bool MMYY = false;

	if (0 <= A&&A <= 99 && 0 < B&&B <= 12)
	{
		YYMM = true;
	}
	if (0 < A&&A <= 12 && 0 <= B&&B <= 99)
	{
		MMYY = true;
	}

	if (YYMM&&MMYY)
	{
		cout << "AMBIGUOUS";
		return 0;
	}
	if (YYMM)
	{
		cout << "YYMM";
		return 0;
	}
	if (MMYY)
	{
		cout << "MMYY";
		return 0;
	}

	cout << "NA";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

vi st[100005], en[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<pi> a(m);
	vector<pair<int, pi>> p;
	rep(i, m){
		cin >> a[i].fi >> a[i].se;
		p.pb(mp(a[i].fi, mp(i, 1)));
		p.pb(mp(a[i].se, mp(i, 0)));
		st[a[i].fi].pb(i);
		en[a[i].se].pb(i);
	}
	int ans = 0;
	int need = 1; //need to find a new base segment
	int mn = 1e9;
	sort(all(p)); //all endpoints
	rep(i, 2 * m){
		if(mn == p[i].fi && !need){
			ans++;
			need = 1;
		}
		if(need){
			if(p[i].se.se){
				need = 0;
				mn = a[p[i].se.fi].se; //found that segment
			}
		}
		else{
			if(p[i].se.se){
				mn = min(mn, a[p[i].se.fi].se);
			}
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 14128
n,k=map(int,input().split())
a=list(map(int,input().split()))
rcount=0
lcount=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      rcount+=1

for i in range(n-1):
  for j in range(i+1,n):
    if a[i]<a[j]:
      lcount+=1

mod=10**9+7

print((k*(k+1)*rcount+k*(k-1)*lcount)//2%mod)


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)
        cout<<"Left"<<endl;
    else if (a+b==c+d)
        cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,G;
  cin>>D>>G;
  vector<pair<int,int>> vec(D);
  for(int i=0;i<D;i++){
    cin>>vec.at(i).first>>vec.at(i).second;
  }
  int ans=0;
  for(int i=0;i<(1<<D);i++){
    bitset<10> bit(i);
    int point=0,ans_=0;
    for(int j=0;j<D;j++){
      if(bit.test(j)){
        point+=100*(j+1)*vec.at(j).first+vec.at(j).second;
        ans_+=vec.at(j).first;  
      } 
    }
    int de=D;
    while(point<G&&de>=1){
      if(de*100<=G-point&&!bit.test(de-1)){
        ans_+=min((G-point)/(de*100),vec.at(de-1).first-1);
        point+=(min((G-point)/(de*100),vec.at(de-1).first-1))*(de*100); 
      }
      de--;
    }
    if(point>=G&&ans==0){
      ans=ans_;
    }
    if(point>=G&&ans_<ans) {
      ans=ans_;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define eb emplace_back
using ll = long long;

const int nax = 3005;
lli dp[nax][nax];

int main() {
    //freopen("input.txt","r",stdin);
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    // dp[0][n-1]
    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = a[L];
            }
            else {
                dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
            }
        }
    }
    printf("%lld\n", dp[0][n-1]);
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if (a>b) swap(a, b);
    ll ans = 0;
    if ((b-a)%2==0) {
        ans = (b-a)/2;
    }
    else {
        ans = a + (b-a-1)/2;
        chmin(ans, n-b+1+(b-a-1)/2);
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
a = gets.split(' ').map(&:to_i)
ans = ""
def s(a, count)
  for i in 0..a.length-2
    v = i
    for j in i+1..a.length-1
      if a[j] < a[v]
        v = j
      end
    end
    if i != v
      a[i],a[v] = a[v],a[i]
      count += 1
    end
  end
  count
end
count = 0
count = s(a,count)
cnt = 0
a.each do |i|
  ans += "#{i}"
  if cnt != a.length-1
    ans += " "
  end
  cnt += 1
end
puts ans
puts count

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A),b(B);
  for(int i=0;i<A;i++) cin >> a[i];
  for(int i=0;i<B;i++) cin >> b[i];
  int ans=*min_element(a.begin(),a.end())+*min_element(b.begin(),b.end());
  int x,y,c;
  rep(i,M){
    cin >> x >> y >> c;
    if(ans>(a[x-1]+b[y-1]-c)){
      ans = a[x-1]+b[y-1]-c;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C>
void chmax(T &a, C b)
{
    a > b ?: a = b;
}
template <class T, class C>
void chmin(T &a, C b) { a < b ?: a = b; }

int main()
{
    int K, N;
    cin >> K >> N;
    cout << K - N + 1 << endl;
}

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

using namespace std;

int main() {
    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;

    for (int i=0; i<n; i++) {
        bool pass = false;
        if (s[i] == 'b' && b > 0) {
            b--;
            pass = true;
        }

        if (s[i] == 'a' && a+b > 0) {
            pass = true;
            if (a > 0) a--;
            else b--;
        }

        cout << (pass? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1336
import java.util.*;
import java.io.*;
public class Main {
	static int n = 0;
	
	public static void selection_sort(int[] a) {
		
		// init swap count
		int swapCount = 0;
		
		// start from left to right
		for (int i = 0; i < n; i++) {
			
			// find the ith minimum element
			
				// assume that a[i] is the minimum value
				int min_index = i;
				
				// search for values that are smaller than minimum value
				for (int j = i+1; j < n; j++) {
					if (a[j] < a[min_index])
						min_index = j;
				}
				
			// put that element in the right place (ith position) & increase swapCount
			int tmp = a[min_index];
			a[min_index] = a[i];
			a[i] = tmp;
			
			if (min_index != i) swapCount++;
				
			// print sorted elements
			if (i < n-1) System.out.print(a[i] + " "); 
			else
				System.out.println(a[i]);
		}
		System.out.println(swapCount);
	}
	
	public static void main (String args[]) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) 
			a[i] = sc.nextInt();
		selection_sort(a);
	}
}

Measured memory_bytes: 19104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var count = 0;
            switch (S)
            {
                case "SUN":
                    count = 7;
                    break;
                case "MON":
                    count = 6;
                    break;
                case "TUE":
                    count = 5;
                    break;
                case "WED":
                    count = 4;
                    break;
                case "THU":
                    count = 3;
                    break;
                case "FRI":
                    count = 2;
                    break;
                case "SAT":
                    count = 1;
                    break;
                default:
                    break;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13152
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int mat[][] = new int[9][9];
    
    for (int i = 0; i < 9; i++){
      for (int j = 0; j < 9; j++){
        mat[i][j] = (i+1) * (j+1);
      }
    }
    int n = sc.nextInt();
    boolean band = false;

    for (int i = 0; i < 9; i++){
      for (int j = 0; j < 9; j++){
        if(n == mat[i][j]){
          band = true;
        }
      }
    }

    if (band == true){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35548
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long MODULO = (long) ((1e+9) + 7);
            int n = in.nextInt();
            long k = in.nextInt();
            long[] ar = new long[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                long add = fr(ar[i], i, ar, n) * k;
                add %= MODULO;
                long prog = (k * (k - 1)) / 2;
                prog %= MODULO;
                add += f(ar[i], i, ar, n) * prog;
                add %= MODULO;
                ans += add;
                ans %= MODULO;
            }
            out.println(ans);
        }

        private static long f(long v, int j, long[] ar, int n) {
            int c = 0;
            for (int i = 0; i < n; i++)
                if (i != j && v > ar[i])
                    c++;
            return c;
        }

        private static long fr(long v, int j, long[] ar, int n) {
            int c = 0;
            for (int i = j + 1; i < n; i++)
                if (v > ar[i])
                    c++;
            return c;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int x[3]={};

int main(){
	int a,b,c;
	for (int i=0;i<3;i++)cin>>x[i];
	sort(x,x+3);
	cout<<x[0];
	for (int i=1;i<3;i++)cout<<" "<<x[i];
	cout<<endl;
	
}


Measured memory_bytes: 3140
use std::io::stdin;
use std::f64::consts::PI;

fn main() {
    let (a, b, x) = {
        let mut s = String::new();
        stdin().read_line(&mut s).unwrap();
        let mut ws = s.trim_right().split_whitespace();
        let a: f64 = ws.next().unwrap().parse().unwrap();
        let b: f64 = ws.next().unwrap().parse().unwrap();
        let x: f64 = ws.next().unwrap().parse().unwrap();
        (a, b, x)
    };

    let n = a*a*b/2.0;
    let mut res = 0_f64;
    if x < n {
        let c = 2.0*x/(a*b);
        res = (b).atan2(c).to_degrees()
    } else if x == n {
        res = (b/a).atan().to_degrees();
    } else {
        let c = 2.0*(b- x/a/a);
        res = c.atan2(a).to_degrees()
    }
    println!("{}", res)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int n, const vector<int64_t> & a) {
    int64_t ans = 0;
    map<int64_t, int> cnt;
    REP (i, n) {
        ans += cnt[i - a[i]];
        ++ cnt[i + a[i]];
    }
    return ans;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N;
    cin >> N;
    vector<int64_t> A(N);
    REP (i, N) {
        cin >> A[i];
    }
    auto ans = solve(N, A);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27332
def digitSum(n):
  #数値を文字列に変換
  s = str(n)
  #1文字ずつ数値化し配列にする
  array = list(map(int,s))
  #合計値を返す
  return sum(array)


N,A,B = map(int,input().split())
a = 0
for i in range(N+1):
  if digitSum(i) <= B and digitSum(i) >= A:
    a +=i
print(a)

Measured memory_bytes: 3060