akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var abc = ReadSplit();
            Println($"{abc[0][0]}{abc[1][0]}{abc[2][0]}");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    string t;
    map<string, bool> mp;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;

        if(mp[s])
            return cout << "No\n", 0;
        if(i && s[0] != t[t.size() - 1])
            return cout << "No\n", 0;
        mp[s] = true;
        t = s;
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;


int main(){
    
    int n, s[1000], sum;
    double mean, std;
    while(true){
        cin >> n;
        if(n==0){
            break;
        }
        sum=0;
        for(int i=0; i<n; i++){
            cin >> s[i];
            sum += s[i];
        }
        mean = (double)sum / n;
        double temp_sum=0;
        for(int j=0; j<n; j++){
            temp_sum += pow((s[j] - mean), 2);
        }
        std = sqrt(temp_sum / n);

        printf("%lf\n", std);
    }

    return 0;
}




Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[5];
signed main()
{
	scanf("%lld",&n);
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")
			a[1]++;
		if(s=="WA")
			a[2]++;
		if(s=="TLE")
			a[3]++;
		if(s=="RE")
			a[4]++;
	}
	cout<<"AC x "<<a[1]<<endl<<"WA x "<<a[2]<<endl<<"TLE x "<<a[3]<<endl<<"RE x "<<a[4];
	return 0;
}

Measured memory_bytes: 3700
def calc(str,prev)
  	cnt = 0
	str.chars {|c| c.match(/[ATCG]/) ? cnt +=1 : break}
    cnt = [prev, str.length > 1 ? calc(str.split("").drop(1).join, cnt) : cnt].max
end

puts calc(gets.chomp, 0)

Measured memory_bytes: 1788
N,M = map(int,input().split())
xyz = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for n in range(8):
    n = bin(n)[2:]
    n = (3-len(n))*'0' + n
    n = [1-2*int(s) for s in n]
    S = [0]*N
    for i in range(N):
        S[i] = n[0]*xyz[i][0]+n[1]*xyz[i][1]+n[2]*xyz[i][2]
    S.sort()
    ans = max(ans,sum(S[N-M:]))

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double x,y,a,b,c,d,e,f;

    while (scanf ("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)==6)
    {
        y=(f*a-d*c)/((a*e-b*d)*1.0);
        x=(c-b*y)/a;

        printf ("%0.3lf %0.3lf\n",x,y);
    }
}


Measured memory_bytes: 3192
a = [input().split() for _ in range(3)]
n = int(input())
b = [input() for _ in range(n)]

c = 0
for i in range(3):
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        print("Yes")
        c = 1
        break
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        print("Yes")
        c = 1
        break
if a[1][1] in b:
    if a[0][0] in b and a[2][2]in b and c==0:
        print("Yes")
        c = 1
    if a[0][2] in b and a[2][0]in b and c==0:
        print("Yes")
        c = 1 
if c == 0:
    print("No")

Measured memory_bytes: 3064
require 'set'
require 'matrix'

def d2(x1, y1, z1, x2, y2, z2)
	(x1 - x2) ** 2 + (y1 - y2) ** 2 + (z1 - z2) ** 2
end

loop do
	n, m, removable = gets.split.map(&:to_i)
	break if n == 0
	baloons = (1..n).map {gets.split.map(&:to_i)}
	lights = (1..m).map {gets.split.map(&:to_i)}
	x0, y0, z0 = gets.split.map(&:to_i)
	intensity = lights.map do |x, y, z, b|
		b.to_f / d2(x, y, z, x0, y0, z0)
	end
	cost = lights.map do |xl, yl, zl, _|
		u = Vector[xl - x0, yl - y0, zl - z0]
		set = 0
		(0..n-1).each do |i|
			xb, yb, zb, r = baloons[i]
			v = Vector[xb - x0, yb - y0, zb - z0]
			w = v - u
			if (v.r < r) ^ (w.r < r)
				set |= (1 << i)
			else
				a = v.inner_product(u) / u.r
				if 0 < a && a < u.r && (v.r >= r) && (w.r >= r) && v.r ** 2 - a ** 2 < r ** 2
					set |= (1 << i)
				end
			end
		end
		set
	end

	max = 0
	total_cost = [0]
	total_value = [0]
	(1..2**m-1).each do |x|
		y = (x & -x)
		i = y.to_s(2).size-1
		total_cost[x] = total_cost[x - y] | cost[i]
		total_value[x] = total_value[x - y] + intensity[i]
		next if total_cost[x].to_s(2).count(?1) > removable
		max = total_value[x] if total_value[x] > max
	end
	p max
end

Measured memory_bytes: 68056
#include<bits/stdc++.h>
using namespace std;
int n;
int t[3];
int u[3];
int func(int k){
  if(t[k]==0)return 0;
    
  for(int i=0;i<3;i++)u[i]=t[i];
    
  int sum=k,cnt=t[0]+1;
  t[k]--;
  while(1){
    if(sum==2){
      if(t[2]==0){
        if(t[1]>0)cnt++;
        break;
      }
        
      t[2]--;
      cnt++;
      sum=1;
    }else if(sum==1){
      if(t[1]==0){
        if(t[2]>0)cnt++;
        break;
      }
        
      t[1]--;
      cnt++;
      sum=2;
    }
  }
  for(int i=0;i<3;i++)t[i]=u[i];
  return cnt;
}
  
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    a%=3;
    t[a]++;
  }
  
  if(t[0]==n){
    printf("1\n");
  }else{
    printf("%d\n",max(func(1),func(2)));
  }
  return 0;
}

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

int main(){
	int h = 0,m = 0,l = 0,tmp,i;

	for(i = 0;i < 10;i++){
		cin>>tmp;
		if(tmp >= h){
			l = m;
			m = h;
			h = tmp;
		}else if(tmp >= m){
			l = m;
			m = tmp;
		}else if(tmp >= l){
			l = tmp;
		}
	}
	cout<<h<<endl;
	cout<<m<<endl;
	cout<<l<<endl;
	return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    vector<int> p(N);

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

    int ans = 0;

    for(int i = 0; i < K; i ++){
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll g = __gcd(a,b);//最大公約数
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;

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

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n,m;
    cin>>n>>m;
    ll dist[n][m][n][m];
    rep(a,0,n)
		rep(b,0,m)
			rep(c,0,n)
				rep(d,0,m)
					dist[a][b][c][d]=mod;
	char grid[n][m];
	rep(a,0,n)
		rep(b,0,m)
		{
			cin>>grid[a][b];
			if(grid[a][b]=='.'){
				dist[a][b][a][b]=0;
				if(a and grid[a-1][b]=='.')
				{
					dist[a][b][a-1][b]=1;
					dist[a-1][b][a][b]=1;
				}
				if(b and grid[a][b-1]=='.')
				{
					dist[a][b][a][b-1]=1;
					dist[a][b-1][a][b]=1;
				}
			}
		}
	rep(a,0,n)
		rep(b,0,m)
			rep(c,0,n)
				rep(d,0,m)
					rep(e,0,n)
						rep(f,0,m)
							dist[c][d][e][f]=min(dist[c][d][a][b]+dist[a][b][e][f],dist[c][d][e][f]);
	ll ans=0;
	rep(a,0,n)
		rep(b,0,m)
			rep(c,0,n)
				rep(d,0,m)
				{
					if(dist[a][b][c][d]==mod)
						dist[a][b][c][d]=-1;
					ans=max(ans,dist[a][b][c][d]);
				}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  string s,t;cin>>s;int n=s.size();int ans;
  for(int i=0;i<(n-1)/2;i++){
    t+=s.at(i);
    if(s.find(t+t)!=-1) ans=(i+1)*2;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int N,i,k=1;
    scanf("%d",&N);
    char S[N];
    scanf("%s",S);
    for(i=0;i<=N-2;i++){
        if(S[i]!=S[i+1])k++;
    }
    printf("%d",k);
    return 0;
}

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

#define SENTINEL 1000000000




void merge(int A[],int left,int mid,int right){
  int count=0;
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
    int N,ch,count=0;;
    scanf("%d",&N);
    int d[N];
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
    }
    mergeSort(d,0,N);
    if(d[N/2-1]==d[N/2]){
        printf("0");
    }else{
        printf("%d",d[N/2]-d[N/2-1]);
    }
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env pypy3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a1, a2, a3 = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print('bust' if a1 + a2 + a3 >= 22 else 'win')


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

void solv() {
    string str;
    cin >> str;
    if(str.size()%2 != 0){
        cout << "No" << endl;
        return;
    }
    rep(i,str.size()/2){
        if(str[i] != 'h'  || str[i+1] != 'i'){
            cout << "No" << endl;
            return;
        }
        i++;
    }
    cout << "Yes" << endl;

}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256
def bubble_sort(arr, n)
  result = arr.dup
  flag = true
  count = 0
  while flag do
    flag = false

    j = n - 1
    while j > 0 do
      if result[j] < result[j - 1]
        tmp = result[j]
        result[j] = result[j - 1]
        result[j - 1] = tmp
        
        flag = true
        count += 1
      end

      j -= 1
    end
  end

  [result, count]
end

n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)

result, count = bubble_sort(arr, n)

puts result.join(' ')
puts count


Measured memory_bytes: 6876
import numpy as np
def main():
    nm = list(map(int, input().split()))
    p = np.zeros(nm[0], dtype=int)
    ac = np.zeros_like(p)
    for i in range(nm[1]):
        ps = input().split()
        if ac[int(ps[0])-1] == 0:
            if ps[1] == "WA":
                p[int(ps[0])-1] += 1
            elif ps[1] == "AC":
                ac[int(ps[0])-1] += 1

    print(np.sum(ac), np.sum(p[ac == 1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 15260
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main() {
    int ans = 10000000;
    string str; cin >> str;
    for (int i = 0; i < str.length()-2; i++) {
        string tmp = str.substr(i, 3);
        //cout << tmp << endl;
        int tmp2 = atoi(tmp.c_str() );
        if ( abs(tmp2 - 753) < abs(ans - 753) ) {
            //cout << abs(tmp2 - 753) << " " << abs(ans - 753) << endl;
            ans = tmp2;
            //cout << "ans " << ans << endl;
        }
    }
    cout << abs(ans - 753) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n ,t,i,j,x,y,k,flag =0;
    cin>>n>>t;
    for(i = 0 ;i<=n ;i++)
    {
        for (j = 0 ;i+j <= n ;j++)
        {
             k =n-i-j;
            x = 10000*i + 5000*j + 1000*k;
            if(x == t)
            {
                flag =1 ;
                break;
            }
        }
        if(flag == 1)
            break;
    }
    if(flag == 0)
        cout<<-1<<" "<<-1<<" "<<-1<<endl;
    else
        cout<<i<<" "<<j<<" " << k <<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, M;
  long long mod = 1000000007;
  scanf("%d",&N);
  scanf("%d",&M);
  std::vector<int > a(M);
  std::vector<long long > fibonatti(100000+5);
  for (int i=0; i<M; i++){
    scanf("%d",&a[i]);
  }
  fibonatti[0] = 1;
  fibonatti[1] = 1;
  fibonatti[2] = 2;
  for (int i=3; i<=N; i++){
    fibonatti[i] = fibonatti[i-1]+fibonatti[i-2];
    fibonatti[i] %= mod;
  }
  if (M==0){
    printf("%lld\n",fibonatti[N]);
    return 0;
  }
  
  long long ans = 1;
  ans *= fibonatti[a[0]-1];
  ans %= mod;
  //printf("ans1=%lld\n",ans);
  for (int i=1; i<M; i++){
    if (a[i]-a[i-1]==1){
      //printf("ooops\n");
      printf("0\n");
      return 0;
    }
    //printf("*=%lld\n",fibonatti[a[i]-a[i-1]-2]);
    ans*=fibonatti[a[i]-a[i-1]-2];
    ans%=mod;
    //printf("ans=%lld\n",ans);
  }
  ans*=fibonatti[N-a[M-1]-1];
  ans%=mod;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i =a; i<n; i++) 
#define ll long long
#define MOD 1000000007
using namespace std;
  
int main() {
  int N; cin >> N;
  bool check = false; int S;
  rep(i,0,100001) {
    if (i * (i+1) == 2*N) {
      check = true; S = i+1;
    }
  }
  

  if (!check) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl << S << endl;
    vector<vector<int>> d(S);
    int x =0;
    rep(i,0,S) {
      rep(j,i+1,S) {
        x++;
        d[i].push_back(x);
        d[j].push_back(x);
      }
    }
    rep(i,0,S) {
      cout << S-1;
      rep(j,0,S-1) {
        cout << " " << d[i][j];
      }
      cout << endl;
    }
  }
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	string s;
	cin>>s;
	if(s[0]=='S')cout<<"Cloudy\n";
	else if(s[0]=='C')cout<<"Rainy\n";
	else if(s[0]=='R')cout<<"Sunny\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3532
#include <algorithm>
#include <cstdio>
const int N = 12;
const int x = 0x7fffffff;
const int y = 0x7ffffffe;
int d[N][N];
bool v[N][N];
int X[1000], Y[1000], S, T, cnt, m;
int from[1000000], to[1000000], cost[1000000];
inline void addEdge(int x, int y, int z) {
  cost[m] = z;
  from[m] = x;
  to[m++] = y;
}
int main() {
  int A, B;
  scanf("%d%d", &A, &B);
  int xx = 0, yy = 0;
  for (int i = 1; i <= A; ++i)
    for (int j = 1; j <= B; ++j) {
      scanf("%d", &d[i][j]);
      xx = std::max(xx, d[i][j] / i);
      yy = std::max(yy, d[i][j] / j);
      v[i][j] = 0;
    }
  cnt = 0;
  m = 0;
  for (int i = 0; i <= xx; ++i) X[i] = cnt++;
  for (int i = 0; i <= yy; ++i) Y[i] = cnt++;
  S = X[0];
  T = Y[0];
  for (int i = 0; i < xx; ++i) addEdge(X[i], X[i + 1], x);
  for (int i = 0; i < yy; ++i) addEdge(Y[i + 1], Y[i], y);
  for (int i = 0; i <= xx; ++i)
    for (int j = 0; j <= yy; ++j) {
      int ans = 0;
      for (int a = 1; a <= A; ++a)
        for (int b = 1; b <= B; ++b)
          ans = std::max(ans, d[a][b] - i * a - j * b);
      if (ans < 0 || ans > 100) continue;
      addEdge(X[i], Y[j], ans);
      for (int a = 1; a <= A; ++a)
        for (int b = 1; b <= B; ++b)
          if (d[a][b] == i * a + j * b + ans)
            v[a][b] = true;
    }
  for (int a = 1; a <= A; ++a)
    for (int b = 1; b <= B; ++b)
      if (!v[a][b]) return puts("Impossible") & 0;
  puts("Possible");
  printf("%d %d\n", cnt, m);
  for (int i = 0; i < m; ++i) {
    printf("%d %d ", 1 + from[i], 1 + to[i]);
    if (cost[i] == x) printf("X");
    else if (cost[i] == y) printf("Y");
    else printf("%d", cost[i]);
    printf("\n");
  }
  printf("%d %d\n", 1 + S, 1 + T);
  return 0;
}


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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[][] map = new int[3][3];
            int[][] subMap = new int[3][3];
            String ans = "Yes";
            for (int i = 0; i < 3; i++) {
                map[i][0] = in.nextInt();
                map[i][1] = in.nextInt();
                map[i][2] = in.nextInt();
            }

            for (int i = 0; i < 3; i++) {
                subMap[i][0] = map[i][0] - map[0][0];
                subMap[i][1] = map[i][1] - map[0][1];
                subMap[i][2] = map[i][2] - map[0][2];
                if (subMap[i][0] == subMap[i][1] && subMap[i][0] == subMap[i][2]) {
                } else {
                    ans = "No";
                }
            }

            out.print(ans);

        }

    }
}



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

int main(){
    
string s ;
int n;
cin>>n>>s;
for(int i = 0 ; i < s.length() ; i++){
    int x = ((int)(s[i]-65)+n) %26;
    
    cout<<(char)(x+65);
}
return 0;

}



Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B) = nextIntList()
    println(if (A * B % 2 != 0) "Yes" else "No")
}

Measured memory_bytes: 37896
#include<stdio.h>

#define N 100
#define Gard 100000001
#define Nothing -1
#define Initial 0
#define Medium 1
#define End 2

int main(){
  int loop,Min=0,judge;
  int i,j;
  int Graph[N][N];
  int Ver[N];
  int Pdisc[N];
  int Fin[N];
  int ver,list;
  int insert,adja;
  
  scanf("%d",&loop);

  for(i=0;i<loop;i++){
    for(j=0;j<loop;j++){
      Graph[i][j]=Gard;
    }
  }
  
  for(i=0;i<loop;i++){
    scanf("%d %d",&ver,&list);

    for(j=0;j<list;j++){
      scanf("%d %d",&adja,&insert);

      Graph[ver][adja]=insert;
    }
  }

  
  for(i=0;i<loop;i++){
    Ver[i]=Gard;
    Pdisc[i]=Nothing;
    Fin[i]=Initial;
  }

  Ver[0]=0;

  while(1){
    Min=Gard;
    judge=Nothing;
    
    for(i=0;i<loop;i++){

      if((Fin[i]!=End) && (Ver[i]<Min)){
	Min=Ver[i];
	judge=i;
      }
    }

    if(judge==Nothing){
      break;
    }

    Fin[judge]=End;

    for(i=0;i<loop;i++){

      if((Fin[i]!=End) && (Graph[judge][i]!=Nothing)){
	
	if(Graph[judge][i]+Ver[judge]<Ver[i]){
	  
	  Ver[i]=Graph[judge][i]+Ver[judge];
	  Pdisc[i]=judge;
	  
	}
      }
    }
    
  }


  for(i=0;i<loop;i++){
    
    printf("%d %d\n",i,Ver[i]);
    
  }
  
  return 0;
}



Measured memory_bytes: 2040
import sys
input = sys.stdin.readline

n, m = [int(i) for i in input().split()]

submits = [0] * m
for i in range(m):
    p, s = input().split()
    submits[i] = (int(p), s.strip())

answer = [0] * (n+1)
for i in range(n):
    answer[i+1] = {'AC':0, 'WA':0}

for submit in submits:
    p, s = submit[0], submit[1]
    if s == 'WA' and answer[p]['AC'] == 0:
        answer[p]['WA'] += 1
        continue
    if s == 'AC':
        answer[p]['AC'] = 1
        continue

ac_num = 0
wa_num = 0
for a in answer[1:]:
    ac_num += a['AC']
    if a['AC'] == 1:
        wa_num += a['WA']
print(ac_num, wa_num)


Measured memory_bytes: 84304
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	
	int t = 0;
	for (int i = 0; i < n; i++) t = __gcd(t, A[i]);
	
	if (k % t == 0 && k <= *max_element(A.begin(), A.end())) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

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

using namespace std;

typedef struct{
    int par;
    int dep;
    int size;
}node;

node uft[524288];

void resuf(){
    int i;
    for(i=0;i<524288;i++){
        uft[i].par=i;uft[i].dep=0;uft[i].size=1;
    }
    return;
}

int find(int x){
    if(uft[x].par==x){return x;}
    else{uft[x].par=find(uft[x].par);return uft[x].par;}
}

void uni(int x,int y){
    int xp,yp;
    xp=find(x);yp=find(y);
    if(xp==yp){return;}
    if(uft[xp].dep>uft[yp].dep){
        uft[yp].par=xp;
        uft[xp].size+=uft[yp].size;
    }
    else{
        uft[xp].par=yp;
        uft[yp].size+=uft[xp].size;
        if(uft[xp].dep==uft[yp].dep){uft[yp].dep++;}
    }
    return;
}

int size(int x){
    x=find(x);
    return uft[x].size;
}

int main(){
  resuf();
  int n;
  scanf("%d",&n);
  set<pair<int,int>> st;
  vector<int> x(n),y(n);
  vector<pair<int,int>> xs(n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&x[i],&y[i]);
    xs[i].first=x[i];
    xs[i].second=i;
  }
  sort(xs.begin(),xs.end());
  priority_queue<pair<int,int>> pq;
  
  for(int i=0;i<n;i++){
    int v=xs[i].second;
    int ch=y[v];
    while(!pq.empty()){
      pair<int,int> ct=pq.top();
      pq.pop();
      //printf("%d %d %d\n",v,ct.first,ct.second);
      ct.first*=-1;
      if(ct.first>y[v]){
        ct.first*=-1;
        pq.push(ct);
        break;
      }
      else{
        //printf("%d %d\n",v,ct.second);
        uni(v,ct.second);
        ch=min(ch,ct.first);
      }
    }
    pq.push(make_pair(-ch,v));
  }
  
  for(int i=0;i<n;i++){
    printf("%d\n",size(i));
  }
  return 0;
}


Measured memory_bytes: 12884
function main(input) {
	let a = input.split("\n")[0]; 
    a = a[a.length - 1];
  	console.log(
    	a === "3"
      	? "bon"
      	: a === "0" || a === "1" || a === "6" || a === "8"
      	? "pon"
      	: "hon"
    );  
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String r = "";
		if(Character.isUpperCase(a.charAt(0))){
          r = "A";
        }else{
          r = "a";
        }
	  System.out.println(r);
	  sc.close();
	}
}

Measured memory_bytes: 35620
// 2回目の提出
// 1回目の提出は、 n = 200 とか 1000 の 約数が n として入力された時に 0 を出力する為ng
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      // 準備
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      // 解く
      int ans = 10_000 - n;

      if(ans!=0)
        ans = ans % 1000;

      System.out.println(ans);
    }
}

Measured memory_bytes: 35652
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 998244353;
	//static final long MOD = 1000000007;
	static boolean[] visited;
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        int year = Integer.parseInt(s.substring(0,4));
        int month = Integer.parseInt(s.substring(5,7));
        int day = Integer.parseInt(s.substring(8,10));
        if (year < 2019 || (year == 2019 && month < 5)) {
        	System.out.println("Heisei");
        } else {
        	System.out.println("TBD");
        }
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
			  public int compare(int[] arr1, int[] arr2) {
				  //Ascending order
				  if (arr1[0] != arr2[0])
					  return arr1[0]-arr2[0];
				  else
					  return arr2[1]-arr1[1];
			  }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

class Node {
	public HashSet<Node> children;
	public int n;
	
	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}
	
	public void addChild(Node node) {
		children.add(node);
	}
	
	public void removeChild(Node node) {
		children.remove(node);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return n;
	}

	@Override
	public boolean equals(Object obj) {
		if (! (obj instanceof Node)) {
			return false;
		} else {
			Node node = (Node) obj;
			return (n == node.n);
		}
	}
	
	public String toString() {
		return (this.n+1)+"";
	}
}

Measured memory_bytes: 20564
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;


int main() {
	int N;
	scanf("%d", &N);
	if (N < 10) {
		printf("%d", N);
	}
	else if (N < 100) {
		printf("9");
	}
	else if (N < 1000) {
		printf("%d", 9 + N - 99);
	}
	else if (N < 10000) {
		printf("909");
	}
	else if (N < 100000) {
		printf("%d", 909 + N - 9999);
	}
	else {
		printf("90909");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int i, j, k;
	int a[3][3];
	for (i = 0; i < 3; i++)
		for (j = 0; j < 3; j++)
			scanf("%d", &a[i][j]);
	int c[3][3];
	for (i = 0; i < 3; i++)
		for (j = 0; j < 3; j++)
			c[i][j] = 0;
	int n;
	scanf("%d", &n);
	int b;
	for (k = 0; k < n; k++)
	{
		scanf("%d", &b);
		for (i = 0; i < 3; i++)
			for (j = 0; j < 3; j++)
				if (a[i][j] == b)
					c[i][j] = 1;
	}
	for (i = 0; i < 3; i++)
	{
		if (c[i][0] > 0 && c[i][1] > 0 && c[i][2] > 0)
		{
			printf("Yes\n");
			return 0;
		}
	}
	for (j = 0; j < 3; j++)
	{
		if (c[0][j] > 0 && c[1][j] > 0 && c[2][j] > 0)
		{
			printf("Yes\n");
			return 0;
		}
	}
	if (c[0][0] > 0 && c[1][1] > 0 && c[2][2] > 0)
	{
		printf("Yes\n");
		return 0;
	}
	if (c[0][2] > 0 && c[1][1] > 0 && c[2][0] > 0)
	{
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, i, j, k, l, m, n, ans, tmp, hoge;

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

    cin >> k >> n;
    vl A(n);
    rep(i, n) cin >> A[i];

    ll max_dist = A[0] + (k - A[n - 1]);
    rep(i, n - 1) max_dist = max(A[i + 1] - A[i], max_dist);

    cout << k - max_dist << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}

const ll N = 2e5+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;

ll height[N], dp[N];

ll get_height(int i){
	if(i < 0) return INF;
	
	return height[i];
}

int k;

ll solve(int n){
	if(n <= 0) return 0;
	
	if(dp[n] != -1) return dp[n];
	
	ll ans = INF;
	
	for(int i = 1; i <= k; i++){
		ans = min(ans, solve(n - i) + abs(get_height(n) - get_height(n - i)));
	}
	
	return dp[n] = ans;
}

void testcase(){
	int n;
	cin>>n>>k;
	
	for(int i = 0; i < n; i++){
		cin>>height[i];
	}
	
	memset(dp, -1, sizeof(dp));
	
	ll ans = solve(n - 1);
	
	cout<<ans<<'\n';
	
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 7296
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      long a = sc.nextLong();
      while (a > 0) {
        if (a % 2 != 0) {
          break;
        }
        count++;
        a /= 2;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 47768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

string str,qtr;
ll cal[3005][3005],dp[3005][3005];
pi st[3005][3005];

int lcs(ll s,ll t)
{
	if(s<0 || t<0)
		return 0;
	if(cal[s][t] == 1)
		return dp[s][t];
	cal[s][t] = 1;
	//dp[s][t] = max((str[s]==qtr[t])+lcs(s-1,t-1),max(lcs(s-1,t),lcs(s,t-1)));
	ll a = lcs(s-1,t-1);
	ll b = lcs(s-1,t);
	ll c = lcs(s,t-1);
	if(a+(str[s]==qtr[t])>=max(b,c))
	{
		dp[s][t] = a+(str[s]==qtr[t]);
		st[s][t] = pi(s-1,t-1); 
	}
	else if(b>=c)
	{
		dp[s][t] = b;
		st[s][t] = pi(s-1,t);
	}
	else
	{
		dp[s][t] = c;
		st[s][t] = pi(s,t-1);
	}
	return dp[s][t];
}

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

	string adj;

	cin >> str;
	cin >> qtr;

	lcs(str.size()-1,qtr.size()-1);

	ll a = str.size()-1;
	ll b = qtr.size()-1;
	//cout << dp[a][b] << "\n";
	while(a>=0 && b>=0)
	{
		if(str[a] == qtr[b])
			adj.pb(str[a]);
		ll a1 = st[a][b].ff;
		ll b1 = st[a][b].ss;
		a = a1;
		b = b1;
	}

	reverse(adj.begin(),adj.end());

	cout << adj << endl;
	return 0;
}

	


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

using namespace std;

const int infI=1e9+5;
const long long infL=1e18;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vl vector<vector<ll> >
#define vi vector<vector<int> >
#define eb emplace_back
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back();
#define se second
#define fi first

vi adj;
int n,m,s,d;
/*
    we create 3 copies of this graph and for every vertex u, we create u1,u2,u3 and for every edge (u,v), we create
    (u1,v2),(u2,v3), and (u3,v1). Look at this as if we have 3 layers and we move from one layer to another.
    If we can move from s to t through the other layers and this is the shortest path , then this path is also divisible 
    by 3, as we move through 3 edges to get back to same layer.In this implementation,we
    have a directed edge from layer 1->2, 2->3 and 3->1.we can also connect layers 1->3,3->2 and 2->1.
    We just can't connect a layer with itself.
*/
int main(){
    cin>>n>>m;
    adj.resize(3*n+1);
    forn(i,0,m){
        int s,d;
        cin>>s>>d;
        adj[s].pb(d+n);
        adj[s+n].pb(d+2*n);
        adj[s+2*n].pb(d);
    }
    int s,d;
    cin>>s>>d;
    ll dist[3*n+1];
    bool vis[3*n+1]={};
    dist[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        vis[u]=true;
        for(auto it:adj[u]){
            if(!vis[it]){
                dist[it]=dist[u]+1;
                vis[it]=true;
                q.push(it);
            }
        }
    }
    if(vis[d]){
        cout<<dist[d]/3;
    }
    else{
        cout<<-1;
    }
    return 0;
}

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

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

    bitset<100> sunuke;
    rep(i, k)
    {
        int d = 0;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int t = 0;
            cin >> t;
            sunuke.set(t-1,1);
        }
    }

    cout << n - sunuke.count() << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<vector<int>> x(n), y(n);
  rep(i,n) {
    int a; cin >> a;
    x[i].resize(a);
    y[i].resize(a);
    rep(j,a) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  int ans = 0;
  rep(bit,1<<n) {
    vector<bool> honest(n);
    rep(i,n) honest[i] = bit >> i & 1;
    bool ok = true;
    rep(i,n) if (honest[i]) {
      rep(j,x[i].size()) {
        if (honest[x[i][j]] && y[i][j] == 0) ok = false; 
        if (!honest[x[i][j]] && y[i][j] == 1) ok = false; 
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(bit));
  }
  cout << ans << endl;
}

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

int a[4][4];
int main()
{
    

    for(int i=1; i<=3; i++)
    {
        for(int j=1; j<=3; j++)
        {
            cin >> a[i][j];
        }
    }

    int n,k;
    cin >> n;
    for(int z=0; z<n; z++)
    {
        cin >> k;
        for(int i=1; i<=3; i++)
        {
            for(int j=1; j<=3; j++)
            {
                if(a[i][j] == k)
                {
                    a[i][j] = 0;
                 
                }
            }
        }
    }

    int flag = 1;
    for(int i=1; i<=3; i++)
    {
        flag = 1;
        for(int j=1; j<=3; j++)
        {
            if(a[i][j]!=0)
            {   
                flag = 0;
            }
        }

        if(flag)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    
    for(int i=1; i<=3; i++)
    {
        flag =1;
        for(int j=1; j<=3; j++)
        {
            if(a[j][i]!=0)
            {   
                flag = 0;
            }
        }

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

    if( a[1][1] == 0 && a[2][2] == 0 && a[3][3] == 0)
        cout << "Yes";
    else if(a[1][3] == 0 && a[2][2] == 0 && a[3][1] == 0)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    
    

    

    return 0;    

}


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

int main(void) {
  int N, A[100];
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  for (int j=0; j<N; j++) {
    if ((A[j]%2==0) && (A[j]%3!=0 && A[j]%5!=0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 10010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

ll h[MAXN];

ll myabs(ll a)
{
	return a >= 0 ? a : -a;
}

int main()
{
	
	ll n, t, a;
	cin >> n >> t >> a;
	t *= 1000;
	a *= 1000;
	ll ans = 1, close = 10000000000000000LL;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> h[i];
		ll cur = t-h[i]*6;
		if (myabs(cur-a) < close)
		{
			close = myabs(cur-a);
			ans = i;
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}



int main() {
  string s; cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
int n;
long long a[N], ans[N][N][2], sum[N][N];
long long solve(int l, int r, int f)
{
	if (l > r)
		return 0;
	if (l == r)
		return ans[l][r][f] = a[l];
	if (ans[l][r][f] != -1)
		return ans[l][r][f];
	long long left = a[l] + sum[l + 1][r] - solve(l + 1, r, 1 - f);
	long long right = a[r] + sum[l][r - 1] - solve(l, r - 1, 1 - f);
	return ans[l][r][f] = max(left, right);
}
int main(int argc, char const *argv[])
{
	memset(ans, -1, sizeof(ans));
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		long long s = 0;
		for (int j = i; j < n; ++j)
		{
			s += a[j];
			sum[i][j] = s;
		}
	}
	solve(0, n - 1, 0);
	printf("%lld", 2 * ans[0][n - 1][0] - sum[0][n - 1]);

	return 0;
}

Measured memory_bytes: 211840