akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}
set<int>res;
void dfs(string p)
{
  if ((int)p.length() >= 11)
    return;
  int last = p.back() - '0';
  string temp = p;
  temp += (char)(last + '0');
    res.insert(stoll(temp));
    dfs(temp);
  temp = p;
  if (last > 0)
  {
    temp += (char)(last - 1 + '0');
    res.insert(stoll(temp));
    dfs(temp);
  }
  temp = p;
  if (last < 9)
  {
    temp += (char)(last + 1 + '0');
    res.insert(stoll(temp));
    dfs(temp);
  }
  return;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (int i = 1; i <= 9; i++)
    res.insert(i);
  for (int i = 1; i < 10; i++)
  {
    string t;
    t += (char)(i + '0');
    dfs(t);
  }
  int k;
  cin >> k;
  int count = 0;
  for (auto &x : res)
  {
    count++;
    if (count == k)
    {
      cout << x << endl;
      time();
      return 0;
    }
  }
  time();
  return 0;
}

Measured memory_bytes: 27636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n; cin>>n;
  int ans{};
  for(int i=1; i<=n; i++){
    int a; cin>>a;
    if(i%2>0&&a%2>0) ans++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a%(2*b+1)==0) {
    cout << a/(2*b+1) << endl;
  }
  else {
    cout << a/(2*b+1)+1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,t;
	cin >> s >> t;
	if(s.length()!=t.length())
		cout << "No\n";
	else if(s==t)
		cout << "Yes\n"; 
	else
	{		
		string ss;
		int flag=0;
		for(int i=0;i<s.length()-1;i++)
		{
			ss.clear();
			ss=s[s.length()-1]+s.substr(0,s.length()-1);
			if(ss==t)
			{
				cout << "Yes\n";
				flag=1;
				break;
			}
			s=ss;
		}
		if(!flag)
			cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){

	int n, m, l;
  	cin >> n >> m >> l;
  
  	vector<vector<int> > A(n, vector<int>(m));
  	for(int j=0; j<n; j++){
  		for(int i=0; i<m; i++){
    		cin >> A.at(j).at(i);
    	}
    }
  
  	vector<vector<int> > B(m, vector<int>(l));
  	for(int j=0; j<m; j++){
  		for(int i=0; i<l; i++){
    		cin >> B.at(j).at(i);
    	}
    }

  	vector<vector<int64_t> > C(n, vector<int64_t>(l,0));

  for(int k=0; k<n; k++){
  	for(int j=0; j<l; j++){
  		for(int i=0; i<m; i++){
	  		C.at(k).at(j) += A.at(k).at(i)*B.at(i).at(j);
        }
      cout << C.at(k).at(j);
      if(j!=l-1)
        cout << " ";
    }
      cout << endl;

  }

  return 0;
}


Measured memory_bytes: 3268
class MinorChange
  def solve(s, t)
    s.chars.zip(t.chars).map{|x, y| if x == y then 0 else 1 end}.sum
  end

  def run
    s = gets.chomp
    t = gets.chomp
    puts solve(s, t)
  end
end

if $0 == __FILE__
  MinorChange.new.run
end


Measured memory_bytes: 46060
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<ll> a(3*n);
  for (auto &v : a) cin >> v;
  sort(a.begin(), a.end());
  ll sum = 0;
  for (int i = n; i < 3*n; i+=2) {
    sum += a[i];
  }
  dump(sum);
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include<stdio.h>
#include <climits>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	int n, a, b;
	int i = 1, j = 0 ;
	int pass_a = 0,pass_b = 1;

	cin >> n >> a >> b >> s;

	int c = a + b;

	for (i; i <= n; i++) {
		//国内学生
		if (s[i-1] == 'a') {
			if (pass_a < c) {
				cout << "Yes" << endl;
				pass_a++;
			}
			else cout << "No" << endl;
		}
		//海外学生
		else if (s[i - 1] == 'b') {
			if (pass_a < c and pass_b <= b) {
				cout << "Yes" << endl;
				pass_a++;
				pass_b++;
			}
			else cout << "No" << endl;
		}else cout << "No" << endl;//それ以外
	}
}


Measured memory_bytes: 848
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
#中央が空いている
if A[1][1]==-1:
  #ななめ
  if A[0][0] == A[2][2] or A[0][2]==A[2][0]:
    print("Yes")
  #たてよこ
  elif A[0][1]==A[2][1] or A[1][0]==A[1][2]:
    print("Yes")
#中央が空いていない
else:
  #たて
  if A[0][0]==A[1][0] and A[1][0]==A[2][0] or A[0][2]==A[1][2]and A[1][2]==A[2][2]:
    print("Yes")
   #よこ
  elif len(Counter(A[0]))==1or len(Counter(A[2]))==1:
    print("Yes")
  else:
    print("No")
    
 

Measured memory_bytes: 3316
K, X = map(int, input().split())
result1 = [i for i in range(X, X-K, -1)]
result2 = [i for i in range(X, X+K)]
result1.extend(result2)
result1 = list(set(result1))
for i in sorted(result1):
  if i == len(result1)-1:
    print(str(i))
  else:
    print(str(i) + ' ', end='')

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_088_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] a = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                int[] l = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    a[i, j] = l[j];
                }
            }
            if (a[0, 0] - a[0, 1] == a[1, 0] - a[1, 1] && a[0, 0] - a[0, 1] == a[2, 0] - a[2, 1]&& a[0, 0] - a[0, 2
                ] == a[1, 0] - a[1, 2] && a[0, 0] - a[0, 2] == a[2, 0] - a[2, 2])
            {

                if (a[0, 1] - a[1,1] == a[0, 0] - a[1,0] && a[0, 2] - a[1,2] == a[0, 1] - a[1, 1]&& a[0, 1] - a[2, 1] == a[0, 0] - a[2, 0]&&a[0, 2] - a[2, 2] == a[0, 1] - a[2, 1])
                {
                    Console.WriteLine("Yes");
                }
                else { Console.WriteLine("No"); }
            }else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}

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

int main()
{
  string c1, c2;
  cin >> c1 >> c2;

  if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]){
    cout << "YES" << endl;
  }

  else cout << "NO" << endl;

  return 0;

}


Measured memory_bytes: 256
def main():
    A,B = map(int,input().split())
    S = input()

    if not (len(S) == A+B+1):
        print("No")
        return
    
    An = S[:A]
    Bn = S[-B:]
    c = S[A:-B]

    if not (An.isdecimal() and Bn.isdecimal() and c=="-"):
        print("No")
        return
    print("Yes")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
X, N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))
pset = set(p)

for i in range(200):
  MIN = X-i
  MAX = X+i
  if MIN not in pset:
    print(MIN)
    exit()
  elif MAX not in pset:
    print(MAX)
    exit()
  

Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define reps(i,n,k) for((i)=0;(i)<(n);(i)+=(k))
#define MOD ((int)1e9+7)
#define INF INFINITY
typedef long long ll;
typedef unsigned long long ull;
typedef struct pair_{int x,y;}pair_t;
typedef struct{
    int x;
    int i;
    int cnt;
}pair2_t;
void swap(int *x, int *y){int t=*x;*x=*y;*y=t;}
void debug(char *f, ...){va_list a;va_start(a,f);vfprintf(stderr,f,a);va_end(a);}
int asc_cmp(const void *x, const void *y){int X=((pair2_t*)x)->x,Y=((pair2_t*)y)->x;if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int asc2_cmp(const void *x, const void *y){int X=((pair2_t*)x)->i,Y=((pair2_t*)y)->i;if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int desc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return 1;else if(X>Y)return -1;else return 0;}


int main(){
    int n;scanf("%d",&n);
    int a[200001];
    for(int i=0;i<n-1;i++){
        scanf("%d",&a[i]);
    }
    int cnt[200000]={};
    for(int i=0;i<n-1;i++){
        cnt[a[i]]++;
    }
    int b[200000],b_i=0;
    for(int i=0;i<=200000;i++){
        if(cnt[i])b[b_i++]=cnt[i];
    }
    for(int i=0;i<n-1;i++){
        printf("%d\n",cnt[i+1]);
    }
    printf("0\n");
}

Measured memory_bytes: 3296
import java.util.Scanner;

public class Main {

    static long inf = Long.MAX_VALUE;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(scan.next());
        }
        scan.close();

        for (int i = 0; i < n; i++) {
            if (a[i] == 0) {
                System.out.println(0);
                return;
            }
        }

        long ans = 1;

        for (int i = 0; i < n; i++) {
            if (a[i] > inf / ans) {
                System.out.println(-1);
                return;
            }

            ans *= a[i];
            if (ans > 1000000000000000000L) {
                System.out.println(-1);
                return;
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 60512
def main():
  n = int(input()) + 1
  a = [int(x) for x in input().split()]
  q = [0] * n
  for i in range(n):
    q[i] = (q[i - 1] - a[i - 1]) * 2 if i != 0 else 1
    # print(q[i])
    if q[i] <= 0:
      print(-1)
      return
  
  if q[n - 1] < a[n - 1]:
    print(-1)
    return
  q[n - 1] = a[n - 1]
  s = q[n - 1]
  # print('--')
  # print(q[n - 1])
  for i in range(n - 2, -1, -1):
    q[i] = min(q[i], q[i + 1] + a[i])
    if q[i] == 0:
      print(-1)
      return
    # print(q[i])
    s += q[i]
  print(s)

main()

Measured memory_bytes: 674532
#include <bits/stdc++.h> 
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}
 
 
int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll n;
    cin>>n;
    string s;
    cin>>s;
    while(n!=0){
    	n--;
    	ll k=n%26;
    	char x='a'+k;
    	s=x+s;
    	n/=26;
    }
    cout<<s<<endl;
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  int cnt = 0, p, q, s, t;
  for(int i = a; i <= b; i++){
      p = i/10000, q = (i/1000) % 10,
      s = (i/10) % 10, t = i % 10;
      if((p == t) && (q == s)) cnt++;
  }
 
  cout << cnt << endl;
  return 0;
}

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

int main()
{
    int N,flag=0;
    cin >> N;

    for(int i=0 ; i <= 25 ; i++){
        for(int j=0 ; j <= 12 ; j++){
            if(4*i+7*j <= 100 && 4*i+7*j == N){
                flag = 1;
                break;
            }
        }
    }

    if(flag == 1)
        cout << "Yes" <<endl;
    else
        cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long A, long long B)
{
    if ((B - A) % 2 == 0)
    {
        cout << (B - A) / 2 << endl;
    }
    else
    {
        ll left = A - 1;
        left++;
        left += (B - A - 1) / 2;
        ll right = N - B;
        right++;
        right += (B - A - 1) / 2;
        cout << min(left, right) << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
A, B, C = map(int,input().split())
list = [A,B,C]
if 5 in list:
    d = list.index(5)
    list[d] = 0

    if 5 in list:
        e = list.index(5)
        list[e] = 0

        if 7 in list:
            print("YES")

        else:
            print("NO")

    else:
        print("NO")

else:
    print("NO")


Measured memory_bytes: 2940
def main():
    N, M = (int(i) for i in input().split())
    PS = [[i for i in input().split()] for j in range(M)]
    dic = {i: ["?", 0] for i in range(1, N+1)}
    for p, s in PS:
        p = int(p)
        if dic[p][0] != "AC" and s == "WA":
            dic[p][1] += 1
        elif s == "AC":
            dic[p][0] = "AC"
    ans = [0, 0]
    for k, v in dic.values():
        if k == "AC":
            ans[0] += 1
            ans[1] += v
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86488
#include<iostream>
using namespace std;
int main(void)
{
    char b;
    cin >> b;
    if(b=='A')
        cout << 'T';
    if(b=='C')
        cout << 'G';
    if(b=='G')
        cout << 'C';
    if(b=='T')
        cout << 'A';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	ll N, A;
	cin >> N >> A;
	// ll ans = 0;

	cout << N*N - A << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N], n;
vector <ll> v[N];
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
ll solve(ll sum, ll k, ll ans)
{
    for(int i = 1; i < n; i ++)
    {
        sum += a[i];cout << sum << " ";
        if(k == 1)
        {
            if(sum >= 0){
                ans += sum + 1;
                sum = -1;
            }
        }
        else
        {
            if(sum <= 0){
                ans += (-1 * sum) + 1;
                sum = 1;
            }
        }
        if(k == 0) k = 1;
        else k = 0;
        cout << k << endl;
    }
    return ans;
}
int main()
{
    fast;
    ll n, m;
    cin >> n >> m;
    if(abs(n - m) <= 1){
        cout << "Brown" << endl;
    }
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 24832
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

static void AGC033_A();
#if 1
int main()
{
	AGC033_A();
	
	fflush(stdout);
	return 0;
}
#endif

typedef struct _AGC033_A_point
{
	int row = 0;
	int col = 0;
	bool isOperated = false;
}
AGC033_A_point;

const int AGC033_A_Max = 1000;

static void AGC033_A()
{
	int H, W;
	static char field[AGC033_A_Max][AGC033_A_Max] = { 0 };

	scanf(" %d %d", &H, &W);

	AGC033_A_point blkPoint;
	std::vector<AGC033_A_point> vBlk;
	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {
			scanf(" %c", &field[row][col]);
			if (field[row][col] == '#') {
				blkPoint.row = row;
				blkPoint.col = col;
				vBlk.push_back(blkPoint);
			}
		}
	}

	int moveRow[] = { -1, 0, 1, 0 };
	int moveCol[] = { 0, -1, 0, 1 };
	std::vector<AGC033_A_point> vBlkNew;
	int blackPoint = vBlk.size();
	int opeCount = 0;
	while (blackPoint != (H * W)) {
		for (auto it = vBlk.begin(); it != vBlk.end(); it++) {
			if (it->isOperated) continue;

			for (int i = 0; i < 4; i++) {
				int mvCol = it->col + moveCol[i];
				int mvRow = it->row + moveRow[i];

				if ((mvCol >= 0) && (mvCol < W) && (mvRow >= 0) && (mvRow < H)) {
					if (field[mvRow][mvCol] != '#') {
						field[mvRow][mvCol] = '#';
						blkPoint.row = mvRow;
						blkPoint.col = mvCol;
						vBlkNew.push_back(blkPoint);
					}
				}
			}
			it->isOperated = true;
		}
		blackPoint += vBlkNew.size();
		vBlk = vBlkNew;
		//vBlk.assign(vBlkNew.begin(), vBlkNew.end());
		vBlkNew.erase(vBlkNew.begin(), vBlkNew.end());

		opeCount++;
	}
	printf("%d\n", opeCount);
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, x;
	cin >> n >> x;
	if(x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(n == 2) {
		cout << "1 2 3" << endl;
		return 0;
	}
	vector<int> ans(2 * n - 1);
	set<int> st;
	int a[4];
	if(x == 2) {
		a[0] = x + 1;
		a[1] = x;
		a[2] = x - 1;
		a[3] = x + 2;
	} else {
		a[0] = x - 2;
		a[1] = x + 1;
		a[2] = x;
		a[3] = x - 1;
	}
	for(int i = 0; i < 4; i++) {
		ans[n - 2 + i] = a[i];
		st.insert(a[i]);
	}
	int j = 1;
	for(int i = 0; i < 2 * n - 1; i++) {
		if(i >= n - 2 && i <= n + 1) continue;
		while(st.count(j)) {
			j++;
		}
		ans[i] = j;
		st.insert(j);
	}
	for(int i = 0; i < 2 * n - 1; i++) {
		cout << ans[i] << '\n';
	}
	return 0;	
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,n;
    cin>>a>>b>>n;
    if(n<b)
    	cout<<a*n/b;
	else if(n==b)
		cout<<max(a*(n-1)/b,a*n/b-a);
	else{
		cout<<a*(b-1)/b;
	}
    return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    int ans = 0;
    int cnt = 0;
    bool eq = false;
    for (int i = 0; i < n; i++) {
        if (eq) {
            if (p[i] == i) {
                cnt++;
            } else {
                ans += (cnt + 1) / 2;
                cnt = 0;
                eq = false;
            }
        } else {
            if (p[i] == i) {
                cnt = 1;
                eq = true;
            }
        }
    }
    if (eq) {
        ans += (cnt + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <set>

using namespace std;

int main() {
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);

  set<int> s;

  int aa = a;
  int bb = b;
  for (int i = 0; i < k; ++i) {
    if (aa <= b) s.insert(aa);
    if (bb >= a) s.insert(bb);
    ++aa;
    --bb;
  }

  for (int i : s) {
    printf("%d\n", i);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  ll a[n],b[n];
  ll ans=0;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      b[i]=a[i]-i-1;
    }
  sort(b,b+n);
  if(n%2!=0)
    {
      for(int i=0;i<n;i++)
	{
	  ans+=abs(b[i]-b[n/2]);
	}
      cout << ans << endl;
    }
  else
    {
      ll check1=0,check2=0;
      for(int i=0;i<n;i++)
	{
	  check1+=abs(b[i]-b[n/2]);
	  check2+=abs(b[i]-b[n/2 -1]);
	}
      if(check1<check2)
	{
	  cout << check1 << endl;
	  return 0;
	}
      else
	{
	  cout << check2 << endl;
	  return 0;
	}
    }
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;
set<string> SE[MAX];
vector<int> G[MAX];
int seen[MAX];

void DFS(int u,int p){
    seen[u]=1;
    for(int to:G[u]){
        if(to==p) continue;
        if(seen[to]==0) DFS(to,u);
        for(auto it=SE[to].begin();it!=SE[to].end();it++){
            SE[u].insert(*it);
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        memset(seen,0,sizeof(seen));
        
        map<string,int> MA;
        vector<vector<string>> S(N,vector<string>());
        
        for(int i=0;i<N;i++){
            string now;
            while(1){
                char c;cin>>c;
                if(c==':'){
                    S[i].push_back(now);
                    now="";
                }else if(c==','){
                    S[i].push_back(now);
                    now="";
                }else if(c=='.'){
                    S[i].push_back(now);
                    break;
                }else now+=c;
            }
            
            MA[S[i][0]]=i+1;
            
            SE[i+1].clear();
            G[i+1].clear();
        }
        
        for(int i=0;i<N;i++){
            for(int j=1;j<S[i].size();j++){
                if(MA[S[i][j]]) G[i+1].push_back(MA[S[i][j]]);
                else SE[i+1].insert(S[i][j]);
            }
        }
        
        //for(int i=0;i<N;i++) cout<<SE[i+1].size()<<endl;
        
        DFS(1,-1);
        
        cout<<SE[1].size()<<endl;
        
        /*for(auto it=SE[1].begin();it!=SE[1].end();it++) cout<<*it<<" ";
        
        cout<<endl;*/
        
    }
}






Measured memory_bytes: 3432
def main():
    n=int(input())
    v=list(map(int,input().split()))
    l1=[0]*(10**5+1)
    l2=[0]*(10**5+1)
    for i,vn in enumerate(v):
        if i%2==0:
            l1[vn]+=1
        else:
            l2[vn]+=1
    f1,f2,s1,s2,m1,m2=0,0,0,0,0,0
    for i,ln in enumerate(l1):
        s1=max(s1,min(ln,f1))
        if f1<ln:
            m1=i
        f1=max(f1,ln)
    for i,ln in enumerate(l2):
        s2=max(s2,min(ln,f2))
        if f2<ln:
            m2=i
        f2=max(f2,ln)
    if m1==m2:
        print(min(n-f1-s2,n-f2-s1))
    else:
        print(n-f1-f2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14404
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

typedef long long ll;

ll br;
int k;

ll rek(int x, int y){
	br*=10;
	br+=x;
	if(!y){
		k--;
		if(k){
			br/=10;
			return 0;
		}
		return br;
	}
	ll z;
	if(x){
		z=rek(x-1, y-1);
		if(z){
			return z;
		}
	}
	z=rek(x, y-1);
	if(z){
		return z;
	}
	if(x<9){
		z=rek(x+1, y-1);
		if(z){
			return z;
		}
	}
	br/=10;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> k;
	int b=0;
	ll x;
	while(k){
		for(int i=1; i<=9; i++){
//			cout << b << " " << i << endl;
			br=0;
			x=rek(i, b);
			if(x){
				cout << x << '\n';
				return 0;
			}
		}
		b++;
	}
	return 0;
}

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

//https://atcoder.jp/contests/dp/tasks

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> s,t;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] >= 0) s.push_back(a[i]);
        else t.push_back(a[i]);
    }
    
    int S = s.size();
    int T = t.size();

    bool ok = false;
    if(S > 0){
        if(n == k) ok = (T%2 == 0);
        else ok = true;
    }else{
        ok = (k%2 == 0);
    }

    mint ans = 1;
    if(!ok){
        sort(a.begin(),a.end(),[](int i,int j) -> bool{
            return abs(i) < abs(j);
        } );
        rep(i,k) ans *= a[i];
    }else{
        sort(s.begin(),s.end());
        sort(t.rbegin(),t.rend());
        if(k%2==1){
            ans *= s.back();
            s.pop_back();
        }

        vector<ll> p;
        while(s.size() >=2){
            ll x = s.back(); s.pop_back();
            x *= s.back(); s.pop_back();
            p.push_back(x);
        }
        while(t.size() >=2){
            ll x = t.back(); t.pop_back();
            x *= t.back(); t.pop_back();
            p.push_back(x);
        }

        sort(p.rbegin(),p.rend());
        rep(i,k/2) ans *= p[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 6336
#include<stdio.h>

 int main(void){
 

    int a,b,c;

    scanf("%d %d %d", &a,&b,&c);
 
    if(1<a<10000 && 1<b<10000 && 1<c<10000){
       if(a<c && b<c){
           printf("%d",a+b);
       } 
       else if(a<b && c<b){
           printf("%d",a+c);
       }
       else if(b<a && c<a){
           printf("%d",b+c);
       }
       else if(a == b && b == c){
           printf("%d",a+b);
       }
     
    }else{
         printf("error");
     }

    
    








 }

Measured memory_bytes: 128
import statistics
from fractions import *
import math

def cntTwo(n):
    i = 0
    while n % 2 == 0:
        i += 1
        n //= 2
    return i

lcm = lambda a, b: a * b // gcd(a, b)

n,m = map(int,input().split())

l = set(map(int,input().split()))
l = list(l)
l = [i//2 for i in l]
lc = 1
gc =1
two = cntTwo(l[0])
for i in l:
    if cntTwo(i)!=two:
        print(0)
        exit()
    lc = lc*i//gcd(lc,i)
    

print((m//lc +1)//2)


Measured memory_bytes: 13288
#include<stdio.h>
int main(){
    int n,k,i,j,sum=0;
    scanf("%d %d",&n,&k);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(i=0;i<k;i++){
        sum=sum+a[i];
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 1720
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

const int INF = 10000;

long N;

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

  int ans = INF;
  for (long i = 1; i <= sqrt(N); i++) {
    if (N % i != 0) continue;

    long j = N / i;
    int i_len = to_string(i).length();
    int j_len = to_string(j).length();
    int len = max(i_len, j_len);
    ans = min(ans, len);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 150

int main(){
	
	int i;
	int j;
	int k;
	int n;
	int num;
	int point;
	int str[N][N];
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
	 for(j=1;j<=n;j++){
	 str[i][j] = 0;
	 }
	}
	
	
	for(i=1;i<=n;i++){
	scanf("%d%d",&num,&k);
	 for(j=1;j<=k;j++){
	 scanf("%d",&point);
	 str[i][point] = 1;
	}
   }
   
   for(i=1;i<=n;i++){
   	for(j=1;j<n;j++){
   printf("%d ",str[i][j]);
   	}
   printf("%d\n",str[i][j]);
   }
   
   return 0;
}

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

int main(){
int N,M,A;
  cin>>N>>M;
  
  vector<int>list(40);
  for(int i=0; i<N; i++){
    int K;
    cin>>K;
   for(int j=0; j<K; j++){
    cin>>A;
    list[A]++;}}
  
  int ans=0;
  for(int i=1; i<=M; i++){
    if(list[i]==N){ans++;} 
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == 0) cnt++;
    }
    if(n % 3 != 0 && cnt != n){
        cout << "No";
        return 0;
    }
    else{
        for(int j = 0;j <= 30;j++){
            int cnt0 = 0, cnt1 = 0;
            for(int i = 0;i < n;i++){
                if(a[i] % 2 == 0){
                    cnt0++;
                }
                else{
                    cnt1++;
                }
                a[i] = a[i] >> 1;
            }
            //cout << a[0] << a[1] << a[2];
            if(cnt0 != n / 3 && cnt0 != n){
                cout << "No";
                return 0;
            }
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++){
    int cur = i;
    double num = 1;
    while(cur < k){
      cur <<= 1;
      num /= 2;
    }
    ans += num;
  }
  ans /= n;
  printf("%.10lf\n", ans);
}

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

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

int main() {
	
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	
	int MAX = max(a, max(b, max(c, max(d, e))));
	int MIN = -max(-a, max(-b, max(-c, max(-d, -e))));

	if (MAX - MIN > k) {
		cout << ":(" << endl;
	}
	else{
		cout << "Yay!" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
H=list(map(int,input().split()))
if(N<K):
    K=N
C=[10**9]*N
C[0]=0
C[1]=abs(H[1]-H[0])
for i in range(2,K):
    for j in range(1,i+1):
        C[i]=min(C[i-j]+abs(H[i]-H[i-j]),C[i])
for i in range(K,N):
    for j in range(1,K+1):
        C[i]=min(C[i-j]+abs(H[i]-H[i-j]),C[i])
print(C[N-1])


Measured memory_bytes: 52448
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t k,s;
  cin >> k >> s;
  int t = 0;
  vector<int> xy((k+1)*(k+1));
  REP(i,k+1){
    REP(j,k+1){
      if((s - (i + j)) <= k && (s - (i + j)) >= 0){
        t++;
      }
    }
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 24704
#include <iostream>
#include<vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
typedef long long int lld;
typedef unsigned long long int llu;
using namespace std;
const int m=1e9+7;
int main()
{
	int h,w,i,j;
	cin>>h>>w;
	char in[h][w],temp;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>temp;
			in[i][j]=temp;
		}
	}
	lld k[h][w];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(i==0 &&j==0) k[i][j]=1;
			else if(i==0)
			{
				if(in[i][j]=='.') k[i][j]=k[i][j-1];
				else k[i][j]=0;
			}
			else if(j==0)
			{
				if(in[i][j]=='.') k[i][j]=k[i-1][j];
				else k[i][j]=0;
			}
			else if(in[i][j]=='#')
			{
				k[i][j]=0;
			}
			else k[i][j]=(k[i-1][j]+k[i][j-1])%(1000000007);
		}
	}
	lld res=k[h-1][w-1]%(1000000007);
	cout<<res;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(G.at(i).size()==0){
      count++;
    }
    else{
      bool a=true;
      for(int b:G.at(i)){
        if(H.at(i)<=H.at(b)){
          a=false;
        }
      }
      if(a){
        count++;
      }
    }
  }
  cout << count << endl;
}
        

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

    int main(){
        ll n , a , b;
        string s;
        cin >> s ;
        long ans = 0;
        bool flg = false;
        if(s[0] == s[1] || s[1] ==  s[2] || s[2] == s[3]){
            cout << "Bad" << endl;
        }else{
            cout << "Good" << endl;
        }
        
        
        
        
        return 0;
        
    }

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        a.add(s);
        int len = 1000000;
        for (int i = 1; i <= len; i++) {
            int f;
            if (a.get(i - 1) % 2 == 0) {
                f = a.get(i - 1) / 2;
            } else {
                f = 3 * a.get(i - 1) + 1;
            }
            a.add(f);
        }
        int ans = 0;
        for (int i = 0; i <= len; i++) {
            for (int j = i + 1; j <= len; j++) {
                if (a.get(i) == a.get(j)) {
                    // System.out.printf("i = %d,j = %d %n", i, j);
                    // System.out.printf("a = %d,a = %d %n", a.get(i), a.get(j));
                    ans = j + 1;
                    System.out.println(ans);
                    return;
                }
            }
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    int group = 1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) group++;
    }
    
    int unhappy = max(1,group-2*k);
    cout << n - unhappy << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll i,j,a,b;
    cin>>a>>b;
    cout<<(b-a)*(b-a+1)/2-b<<endl;;



    return 0;
}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

string Rotation(string s){
	return s.substr(1,s.length() - 1) + s[0];
}

int main() {
	string s,t; cin >> s >> t;
	bool isAns = false;
	for (int i = 0; i < 120; ++i)
	{
		if(Rotation(s) == t) isAns = true;
		s = Rotation(s);
	}

	if(isAns) cout << "Yes" << endl;
	else cout << "No" << endl;


}

Measured memory_bytes: 256
INF = 10 ** 12

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    for j in range(N):
        for k in range(N):
            if a[i][j] > a[i][k] + a[k][j]:
                print(-1)
                exit()

res = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            if i != k and j != k and a[i][j] == a[i][k] + a[k][j]:
                break
        else:
            res += a[i][j]

print(res)


Measured memory_bytes: 44124
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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




int main(){
    
    int N,K;
    cin >> N >> K;
    ll cnt=0;
    cnt += pow(N/K,3);
    if(K % 2 == 0) {
        cnt += pow(N/(K/2) - N/K , 3);
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
char a[5];

int i,j;
	for(i=0;i<4;++i){
				scanf("%c",&a[i]);		
	}

int count=0;
for(i=0;i<4;++i){
	for(j=i+1;j<4;++j){
		if(a[i]==a[j])
			count ++;
	}
}
if (count==2)
	puts("Yes");
else
	puts("No");
return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;


int main() {

#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int N; cin >> N;
	vector<int> T(N);
	int sum = 0;
	for (auto& it : T){
		cin >> it;
		sum += it;
	}
	vector<vector<int>> dp(1000, vector<int>(1000, 0));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++){
		auto tmp = dp;
		for (int j = 0; j < 1000-T[i]; j++){
			for (int k = 0; k < 1000-T[i]; k++){
				tmp[j + T[i]][k] |= dp[j][k];
				tmp[j][k+T[i]] |= dp[j][k];
			}
		}
		swap(dp, tmp);
	}
	int res = 114514;
	for (int i = 0; i < 1000; i++){
		for (int j = 0; j < 1000; j++){
			if(dp[i][j])res = min(res, max(i, max(j, sum - i - j)));
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10752
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    x = C
    for j in range(M):
        x += A[i][j]*B[j]
    if x > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

S = sum(A)
cnt = 0
for a in A:
    if a * 4 * M >= S:
        cnt += 1
print("Yes" if cnt >= M else "No")


Measured memory_bytes: 3808
package main

import (
	"fmt"
	"math"
)

var W, a, b int

func main() {
	fmt.Scan(&W, &a, &b)
	if a+W < b {
		fmt.Println(b - (a + W))
	} else if b+W < a {
		fmt.Println(a - (b + W))
	} else {
		fmt.Println(0)
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }
func ceil(x int) int      { return int(math.Ceil(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    //  文字列の入力
    string a, b, c;
    cin >> a >> b >> c;
    // しりとり判定と出力
    if( a.back() == b.front() ){
        if( b.back() == c.front() )
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq

n, K = map(int, input().split())
A = list(map(int, input().split()))

from operator import mul
from functools import reduce

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

p = 10 ** 9 + 7
N = n  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

A.sort()

# cmb_list = {}
# cmb_list[(K - 1, K - 1)] = cmb(K - 1, K - 1)
# for i in range(K, n):
#     cmb_list[(i, K-1)] = cmb_list[(i-1, K-1)] * i // (i - (K - 1))

max_f = 0
min_f = 0

for idx in range(n):
    a = heapq.heappop(A)
    if idx >= K - 1:
        max_f += cmb(idx, K - 1, p) * a
        # print("max", cmb(idx, K-1), idx, K-1, a)

    if n - (idx + 1) >= K - 1:
        min_f += cmb(n - (idx + 1), K - 1, p) * a
        # print("min", cmb(N-(idx+1), K-1), N-(idx+1), K-1, a)

print((max_f - min_f) % (10**9+7))

Measured memory_bytes: 78632