akhauriyash/Code-Regression huggingface dataset:
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const ll INF = 1e18L + 5;
const ll siz = 1e6 + 5;
#define deb(x) cout << #x << " = " << x << endl;

void solve()
{
		int n;
		cin >> n;
		int a[n];
		for(int &i:a)
			cin >> i;
		int sum = 0;
		for(int i = 0; i<n-1; i++){
			for(int j = i+1; j<n; j++)
				sum += (a[i] * a[j]);
		}
			
	cout << sum << endl;
}

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


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			// 整数配列の入力
			var abk = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long a = abk[0];
			long b = abk[1];
			long k = abk[2];

			List<long> listA = new List<long>();
			for (long i = a; i < a + k && i <= b; ++i) {
				listA.Add(i);
			}

			foreach (var item in listA) {
				Console.WriteLine(item.ToString());
			}

			List<long> listB = new List<long>();
			for (long i = b; i >= b - k + 1 && i > listA.Last(); --i) {
				listB.Add(i);
			}

			listB.Reverse();
			foreach (var item in listB) {
				Console.WriteLine(item.ToString());
			}

			//Console.WriteLine(remain.ToString());

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13396
ab = input().split()

repetitionA = ""
repetitionB = ""

for i in range(int(ab[1])):
    repetitionA += ab[0]

for j in range(int(ab[0])):
    repetitionB += ab[1]

if (int(repetitionA) > int(repetitionB)):
    print(repetitionA)
else:
    print(repetitionB)


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

int main() {
  vector<int>ans;
  int N,M; cin >> N >> M;
  int a[51],b[51],c[51],d[51];
  for ( int i = 1; i <= N; i++ ) cin >> a[i] >> b[i];
  for ( int i = 1; i <= M; i++ ) cin >> c[i] >> d[i];

  int tmp;
  int index;
  for ( int i = 1; i <=N; i++ ) {
    int mind = 1000000000;
    for ( int j = 1; j <=M; j++ ) {
      tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if( tmp < mind ) {
      mind = min(mind,tmp);
      index = j;
      }
    }
    ans.push_back(index);
  }
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll dfs(int sum,int cou);
int n;
int num[101];
ll dp[30][110];

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> num[i];
	for(int i=0;i<30;i++){
		for(int j=0;j<110;j++){
			dp[i][j] = -1;
		}
	}
	cout << dfs(num[0],1) << endl;
}

ll dfs(int sum,int cou){
	if(cou == n-1){
		if(sum == num[cou]) return 1;
		else return 0;
	}
	if(dp[sum][cou] != -1) return dp[sum][cou];
	ll ret = 0;
	if(sum-num[cou] >= 0) ret += dfs(sum-num[cou],cou+1);
	if(sum+num[cou] <= 20) ret += dfs(sum+num[cou],cou+1);
	return dp[sum][cou] = ret;
}

Measured memory_bytes: 1180
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  double D, E;
  while (cin >> D >> E) {
    if (D == 0 && E == 0)
      break;
    double ans = 100000000000000;
    for (int i = 0; i < D; i++) {
      ans = min(ans, abs(pow(pow(i, 2) + pow(D - i, 2), 0.5) - E));
    }
    cout << shosu(12) << ans << endl;
  }
  return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;

  int cnt0 = 0, cnt1 = 0;
  for (char c : s) {
    if (c == '0') {
      ++cnt0;
    } else {
      ++cnt1;
    }
  }

  cout << min(cnt0, cnt1) * 2 << '\n';

  return 0;
}


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

int main(){
	int N,K;
	cin >> N >> K;
	int B[100]={0};
	//for(int i=0;i<100;i++) B[i]=i+1;

	for(int i=0;i<K;i++){
		int d;
		cin >> d;
		for(int k=0;k<d;k++){
			int a;
			cin >> a;
			for(int j=0;j<100;j++){
				if(a==j+1) B[j]++;
			}
		}
	}
	int sum=0;
	for(int i=0;i<N;i++){
		if(B[i]==0) sum++;
	}
	cout << sum << endl;
}



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

const int INF = 100100100;

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

    vector<int> c(n), t(n);
    rep (i, n)
        cin >> c[i] >> t[i];

    int ans = INF;
    rep (i, n)
        if (t[i] <= l)
            ans = min(c[i], ans);

    if (ans == INF)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
#define mod 1000000007
ll binpow(ll a, ll b){
	ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a  % mod;
        b >>= 1;
    }
    return res;
    
}
ll func( ll n, ll r){
    ll res = 1;
    for(ll i = n; i > n-r ; i--){
        res *= i;
        res %= mod;
    }
    ll den = 1;
    for(ll i = 1; i<= r; i++){
		den *= i;
		den %= mod;
	}
	den = binpow(den, mod-2);
	res = res*den;
	res = res%mod;
    return res;
}

int main() {
    fastio
    ll n, a, b; cin >> n >> a >> b;
    ll res = binpow(2ll, n); 
    
    ll ak = func(n, a);
    ll bk = func(n, b);
    
    res--; res += mod; res += mod;
    cout<<(res-(ak+bk))%mod<<endl;
	return 0;
}






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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0, c - (a - b)) << endl;

    return 0;
}

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

int main(){
  int a[5];
  for(int i=0;i<5;i++) cin >> a[i];
  sort(a,a+5);
  reverse(a,a+5);
  for(int i=0;i<5;i++){ 
	cout << a[i];
	if(i==4) cout << endl;
	else cout << ' ';
  }
  return 0;
}

Measured memory_bytes: 1172
from collections import defaultdict
inf = 10**10
A = list(map(lambda x:ord(x)-ord('a'), list(input())))
N = len(A)
abc = 'abcdefghijklmbopqrstuvwxyz'
s_to_i = [[N]*26 for _ in range(N+1)]
for i in range(N)[::-1]:
    for x in range(26):
        s_to_i[i][x] = s_to_i[i+1][x]
    s_to_i[i][A[i]] = i
dp = [0]*(N+2)
dp[-2] = 1
for i in range(N)[::-1]:
    now = max(s_to_i[i])+1
    dp[i] = dp[now]+1
n = dp[0]
now = 0
ans = []
for i in range(n):
    for x in range(26):
        tmp = s_to_i[now][x]+1
        if dp[tmp] <= n-i-1:
            ans.append(chr(x+ord('a')))
            now = tmp
            break
print(*ans, sep = '')



    
        





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

int main()
{
    int Grid[3][3];

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

    // row
    int row[3] = {0, 0, 0};
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            row[i] += Grid[i][j];
        }
    }

    // col
    int col[3] = {0, 0, 0};
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            col[j] += Grid[i][j];
        }
    }

    if (abs(row[2] - row[1]) % 3 != 0 || abs(row[1] - row[0]) % 3 != 0 || abs(col[2] - col[1]) % 3 != 0 || abs(col[1] - col[0]) % 3 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        cout << "Yes" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

ll gcd(ll A,ll B){
  while(A%B!=0){
    ll tmp=A%B;
    A=B;
    B=tmp;
  }
  return B;
}

int main(){
  ll N,M;
  string S,T;
  cin>>N>>M>>S>>T;
  ll x=gcd(N,M);
  ll length=N*M/x;
  bool flag=true;
  for(int i=0;i<x;i++){
    if(S.at(N/x*i)!=T.at(M/x*i)){
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<length<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 512
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define int ll
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int dp[101][1000001];
    signed main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,w;
            cin>>n>>w;
            int ar[n+1],ar2[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i]>>ar2[i];
            
            for(i=0;i<=n;++i)
                for(j=0;j<=1000000;++j)
                    dp[i][j]=1e18;
            for(i=0;i<=n;++i)
                dp[i][0]=0;
            for(i=1;i<=n;++i)
            {
                for(j=1000000;j>=1;--j)
                {
                    if(j-ar2[i]>=0 && dp[i-1][j-ar2[i]]!=1e18)
                    {
                        dp[i][j]=min(dp[i][j],dp[i-1][j-ar2[i]]+ar[i]);
                        //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
                    }
                    dp[i][j]=min(dp[i][j],dp[i-1][j]);
                }
            }
 
            int ans=0;
            for(i=0;i<=1000000;++i)
            {
                if(dp[n][i]<=w)
                ans=max(ans,i);
            }
            cout<<ans<<endl;
        }
        return 0;
    }

Measured memory_bytes: 789376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

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

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 5e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int a,b;
void work(){
    scanf("%d%d",&a,&b);
    if(b>=a) printf("unsafe\n");
    else printf("safe\n");
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        int res = 0;
        int avg = 0;
        for(int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
            avg += A[i];
        }
        avg = (int)Math.round((double)avg / n);
        for(int i = 0; i < n; i++) res += (int)Math.pow(A[i] - avg, 2);
        System.out.println(res);
    }
}


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

namespace aojpro
{
    class Program
    {
        static int[,] a;
        const int inf = int.MaxValue;
        static int e;
        static int n;

        static void froid()
        {

            for (int k = 0; k < n; k++)
            {
                for(int i = 0; i < n; i++)
                {
                    if(a[i, k] == inf)
                    {
                        continue;
                    }

                    for(int j = 0; j < n; j++)
                    {
                        if(a[k, j] == inf)
                        {
                            continue;
                        }
                        a[i, j] = Math.Min(a[i, j], a[i, k] + a[k, j]);
                    }
                }
            }


        }

        
        static void Main(string[] args)
        {

            string[] str = Console.ReadLine().Split(' ');

            n = int.Parse(str[0]);
            e = int.Parse(str[1]);

            a = new int[n, n];

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if(i == j)
                    {
                        a[i, j] = 0;
                    }
                    else
                    {
                        a[i, j] = inf;
                    }
                }
            }

            int s;
            int t;
            int w;

            for(int i = 0; i < e; i++)
            {
                string[] input = Console.ReadLine().Split();
                s = int.Parse(input[0]);
                t = int.Parse(input[1]);
                w = int.Parse(input[2]);
                a[s, t] = w;
            }

            froid();

            for (int j = 0; j < n; j++)
            {
                if (a[j, j] < 0)
                {
                    Console.WriteLine("NEGATIVE CYCLE");
                    return;
                }
            }

            for (int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if(a[i, j] == inf)
                    {
                        Console.Write("INF");
                    }
                    else
                    {
                        Console.Write(a[i, j]);
                    }
                    if(j != n - 1)
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }

        }
    }
}



Measured memory_bytes: 18080
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N, M = map(int, readline().split())
    G = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, readline().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    col = [-1]*N
    C = {}
    L0 = 0
    L = 0
    for i in range(N):
        if col[i] != -1:
            continue
        que = deque([i])
        col[i] = 0
        cs = [1, 0]
        while que:
            v = que.popleft()
            c = col[v]^1
            for w in G[v]:
                if col[w] != -1:
                    if col[w] != c:
                        write("-1\n")
                        return
                else:
                    col[w] = c
                    cs[c] += 1
                    que.append(w)
        e = abs(cs[1] - cs[0])
        L += e
        if e > 0:
            C[e] = C.get(e, 0) + 1
    W = L//2
    dp = [0]*(W+1)
    dp[0] = 1
    for v, c in C.items():
        for b in range(v):
            s = 0
            k0 = (W - b) // v * v + b
            for i in range(c):
                if k0-v*i >= 0:
                    s += dp[k0-v*i]
            for k in range(k0, -1, -v):
                s -= dp[k]
                if k-c*v >= 0:
                    s += dp[k-c*v]
                if s:
                    dp[k] = 1
    k = 0
    for i in range(W, -1, -1):
        if dp[i]:
            k = i
            break
    A = (N - L) // 2 + k
    B = (N - L) // 2 + L - k
    write("%d\n" % (A*B - M))
solve()


Measured memory_bytes: 24672
#include <stdio.h>

int main (){

  int N,A,B;
  scanf("%d",&N);
  scanf("%d",&A);
  scanf("%d",&B);
  if(N==1){printf("Hello World");}
  else if(N==2){
  printf("%d",A+B);
  }
  else{ return 1;}
  return 0; 
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

const ll M = 924844033;

int main(){
	ll N,K;
	cin >> N >> K;
	
	/*int per[10];
	for(int i = 0 ; i < N ; i ++){
		per[i] = i;
	}
	int ret = 0;
	do {
		bool t = true;
		for(int i = 0 ; i < N ; i ++){
			if(abs(per[i]-i) == K){
				t = false;
				break;
			}
		}
		if(t)ret ++;
	}while(next_permutation(per,per+N));
	cout << ret << endl;*/
	
	ll dp[2][1005][4] = {};
	ll cnt = 0;
	int t = 0, t_ = 1;
	dp[t][0][0] = 1;
	for(int i = 1 ; i <= K ; i ++){
		for(int s = 0 ; s <= min(N/2,cnt+1) ; s ++){
			for(int p = 0 ; p < 4 ; p ++)dp[t_][s][p] = 0;
		}
		for(int s = 0 ; s <= min(N/2,cnt) ; s ++){
			dp[t_][s][0] += (dp[t][s][0]+dp[t][s][1]+dp[t][s][2]+dp[t][s][3])*(cnt-s);
			if(s >= 1)dp[t_][s-1][0] += (dp[t][s][0]+dp[t][s][1]+dp[t][s][2]+dp[t][s][3])*s;
			dp[t_][s][2] += dp[t][s][0]+dp[t][s][1]+dp[t][s][2]+dp[t][s][3];
		}
		for(int s = 0 ; s <= min(N/2,cnt+1) ; s ++){
			for(int p = 0 ; p < 4 ; p ++)dp[t_][s][p] %= M;
		}
		cnt ++;
		swap(t,t_);
		for(int j = K+i ; j <= N ; j += K){
			for(int s = 0 ; s <= min(N/2,cnt+1) ; s ++){
				for(int p = 0 ; p < 4 ; p ++)dp[t_][s][p] = 0;
			}
			for(int s = 0 ; s <= min(N/2,cnt) ; s ++){
				dp[t_][s+1][1] += dp[t][s][0]*2;
				dp[t_][s][0] += dp[t][s][0]*(cnt-2-s);
				if(s >= 1)dp[t_][s-1][0] += dp[t][s][0]*s;
				dp[t_][s][2] += dp[t][s][0];
				
				dp[t_][s+1][1] += dp[t][s][1];
				dp[t_][s][1] += dp[t][s][1];
				dp[t_][s][0] += dp[t][s][1]*(cnt-1-s);
				if(s >= 1)dp[t_][s-1][0] += dp[t][s][1]*(s-1);
				dp[t_][s][2] += dp[t][s][1];
				
				dp[t_][s+2][3] += dp[t][s][2];
				dp[t_][s][0] += dp[t][s][2]*(cnt-1-s);
				if(s >= 1)dp[t_][s-1][0] += dp[t][s][2]*s;
				dp[t_][s][2] += dp[t][s][2];
				
				dp[t_][s][1] += dp[t][s][3]*2;
				dp[t_][s][0] += dp[t][s][3]*(cnt-s);
				if(s >= 1)dp[t_][s-1][0] += dp[t][s][3]*(s-2);
				dp[t_][s][2] += dp[t][s][3];
			}
			for(int s = 0 ; s <= min(N/2,cnt+1) ; s ++){
				for(int p = 0 ; p < 4 ; p ++)dp[t_][s][p] %= M;
			}
			cnt ++;
			swap(t,t_);
		}
	}
	cout << (dp[t][0][0]+dp[t][0][1]+dp[t][0][2]+dp[t][0][3])%M << endl;
	//cout << (dp[t][1][0]+dp[t][1][1]+dp[t][1][2]+dp[t][1][3])%M << endl;
	//cout << (dp[t][2][0]+dp[t][2][1]+dp[t][2][2]+dp[t][2][3])%M << endl;
	//cout << (dp[t][3][0]+dp[t][3][1]+dp[t][3][2]+dp[t][3][3])%M << endl;
}
		



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int H_MAX = 1000;
    constexpr int W_MAX = 1000;
    int H, W;
    string a[H_MAX];
    cin >> H >> W;
    REP(i, H) cin >> a[i];

    int dp[H_MAX][W_MAX];
    dp[0][0] = 1;
    REP(i, H) REP(j, W) {
        if (i == 0 && j == 0) {
            continue;
        }
        dp[i][j] = 0;
        if (i - 1 >= 0 && a[i - 1][j] == '.') {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        }
        if (j - 1 >= 0 && a[i][j - 1] == '.') {
            dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
        }
    }
    cout << dp[H - 1][W - 1] << endl;
    return 0;
}



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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	int x[110];
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> x[i];
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a = x[i] - 0;
		int b = k - x[i];
		ans += (min(a, b)) * 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d;
	cin >> d;
	vector<int> c(27);
	vector<vector<int>> s(d + 1, vector<int>(27));
	vector<int> t(d + 1);
	vector<int> last(27);
	for (int i = 0; i <= 27; i++)
		last[i] = 0;
	for (int i = 1; i <= 26; i++)
		cin >> c[i];
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= 26; j++) {
			cin >> s.at(i).at(j);
		}
	}
	int sum = 0;
	for (int i = 1; i <= d; i++) {
		int ma1 = -1, ma2 = -1;
		for (int j = 1; j <= 26; j++) {
			if (ma1 <= s[i][j]) {
				ma1 = s[i][j];
				ma2 = j;
			}
		}
		cout << ma2 << endl;
		sum += s[i][ma2];
		last[ma2] = i;
		for (int j = 1; j <= 26; j++) {
			sum -= c[j] * (i - last[j]);
		}
	}
	return 0;
}


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

int main(){
    int H, W;
    while (1){
        cin >> H >> W;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << '#';
                }
            cout << endl;
        }
    if (H==0 && W==0) break;
    cout << endl;
    }
}


Measured memory_bytes: 3080
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int q;
  cin>>q;
  
  vector<int> A(100010),B(100010);
  for(int i=3;i<100000;i+=2) A[i]=1;
  for(int i=3;i<1000;i+=2){
    if(A[i]==1){
      for(int j=3*i;j<100000;j+=2*i) A[j]=0;
    }
  }
  A[2]=1;
  
  for(int i=3;i<100000;i+=2){
    if(A[i]==1 && A[(i+1)/2]==1) B[i]=1;
  }
  
  vector<int> s(100010);
  s[0]=0;
  rep(i,100000){
    s[i+1]=s[i]+B[i];
  }
  
  int l,r;
  rep(i,q){
    cin>>l>>r;
    cout<<s[r+1]-s[l]<<endl;
  }

  return 0;
}

Measured memory_bytes: 4500
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<char, ll>map;

	string m = "MARCH";
	int n;
	cin >> n;
	vector<char> p(n);
	rep(i, 0, n) {
		cin >> p[i];
		if (p[i] == 'Y') {
			cout << "Four" << endl;
 return 0;
		}
	}
		
	cout << "Three" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int answer = 0;
	    String S = sc.next();

		for(int i=0; i<4; i++){
			if(S.substring(i,i+1).equals("+")) answer++;
			if(S.substring(i,i+1).equals("-")) answer--;
		}
		
		

		sc.close();

	    System.out.println(answer);
    }
}


Measured memory_bytes: 21844
N = int(input())
red = list()
blue = list()
for i in range(N):
  red.append(list(map(int, input().split())))
for i in range(N):
  blue.append(list(map(int, input().split())))
blue.sort()
redflag = [0] * N
for i in range(N):
  [c, d] = blue[i]
  tmp = -1
  maxay = -1
  for j in range(N):
    [a, b] = red[j]
    if(c > a and d > b and redflag[j] == 0 and maxay < b):
      tmp = j
      maxay = b
  if(tmp >= 0):
    redflag[tmp] = 1
print(sum(redflag))

Measured memory_bytes: 39280
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;

int H,W;
int c[1500][1500];
int h[1500][1500];
int l[1500];
int r[1500];
int main() {
  scanf("%d%d", &H, &W);
  for(int i=0;i<H;++i)
    for(int j=0;j<W;++j)
      scanf("%d", &c[i][j]);
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if (c[i][j] == 1) {
        h[i][j] = 0;
      } else if (i==0 || c[i-1][j] == 1) {
        h[i][j] = 1;
      } else {
        h[i][j] = h[i-1][j] + 1;
      }
    }
  }
  
  long long answer = 0;
  for(int i=0;i<H;++i) {
    stack<int> S;
    for(int j=0;j<W;++j) {
      while(!S.empty() && h[i][S.top()] >= h[i][j]) S.pop();
      if (S.empty()) {
        l[j] = 0;
      } else {
        l[j] = S.top() + 1;
      }
      S.push(j);
    }
    S=stack<int>();
    for(int j=W-1;j>=0;--j) {
      while(!S.empty() && h[i][S.top()] >= h[i][j]) S.pop();
      if (S.empty()) {
        r[j] = W-1;
      } else {
        r[j] = S.top() - 1;
      }
      S.push(j);
    }
    
    for(int j=0;j<W;++j) {
      answer = max(answer, 1ll * h[i][j] * (r[j]- l[j] +1));
    }
  }
  
  printf("%lld\n", answer);
  
  return 0;
}

Measured memory_bytes: 19008
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n, m;
int x, y;
char tmp[10];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%s", tmp);
      string s = tmp;
      if (s == "snuke") {
        x = i;
        y = j;
      }
    }
  }
  return true;
}

void solve() {
  printf("%c%d\n", 'A' + y, x + 1);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int K;
  cin >> K;

  int N = s.size();

  REP(i, N){
    if(s[i] == 'a') continue;
    int MIN = 'z'-s[i]+1;
    if(MIN <= K){
      s[i] = 'a';
      K -= MIN;
    }
  }

  K %= 26;
  REP(i, K){
    s.back()++;
  }

  cout << s << "\n";

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int my[] = {0, 0, 1, -1};
int mx[] = {1, -1, 0, 0};

int H, W;

int dfs(int y, int x, vector< vector<int> > &v, int cnt){
  int res = cnt;
  v[y][x] = false;
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && ny < H && nx < W && v[ny][nx]){
      v[ny][nx] = false;
      res = max(res, dfs(ny, nx, v, cnt + 1));
      v[ny][nx] = true;
    }
  }
  v[y][x] = true;
  return res;
}

int main() {
  while(cin >>W >>H && H){
    vector< vector<int> > v(H, vector<int>(W, 0));
    REP(i, H) REP(j, W) cin >>v[i][j];
    int ans = 0;
    REP(i, H){
      REP(j, W){
        if(!v[i][j]) continue;
        v[i][j] = false;
        ans = max(ans, dfs(i, j, v, 1));
        v[i][j] = true;
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import math


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


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = 0
if n > 1:
    ans += combinations_count(n, 2)
if m > 1:
    ans += combinations_count(m, 2)

print(ans)


Measured memory_bytes: 3060
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;


int main() {
	int n;
	typedef pair<int, int> P;
	vector<P> a;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int num;
		cin >> num;
		a.push_back(P(num,i));
	}
	sort(a.begin(), a.end());

	rep(i, n) {
		cout << a[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 1780
#include <stdio.h>

struct Data {
    int a;
    char c;
};
typedef struct Data data_t;


void swap(data_t A[], int a, int b)
{
    data_t t = A[a];
    A[a] = A[b];
    A[b] = t;
}

void bubbleSort(data_t A[], int n)
{
    int i, j;
    for (i=1; i<n; i++) {
        for (j=i; j>0; j--) {
            if (A[j-1].a > A[j].a) {
                swap(A, j-1, j);
            }
        }
    }
}

void selectionSort(data_t A[], int n)
{
    int i, j, min;
    for (i=0; i<n; i++) {
        min = i;
        for (j=i; j<n; j++) {
            if (A[j].a < A[min].a) {
                min = j;
            }
        }
        swap(A, i, min);
    }
}

int main()
{
    int i;
    int N;
    data_t A[40], B[40];
    
    scanf("%d", &N);
    getchar();
    for (i=0; i<N; i++) {
        scanf("%c", &A[i].c);
        scanf("%d", &A[i].a);
        getchar();
        B[i] = A[i];
    }
    
    bubbleSort(A, N);
    selectionSort(B, N);
    
    for (i=0; i<N-1; i++) {
        printf("%c", A[i].c);
        printf("%d ", A[i].a);
    }
    printf("%c", A[i].c);
    printf("%d\n", A[i].a);
    puts("Stable");
    

    int isStable = 1;
    for (i=0; i<N-1; i++) {
        printf("%c", B[i].c);
        printf("%d ", B[i].a);
        if (A[i].c != B[i].c) {
            isStable = 0;
        }
    }
    printf("%c", B[i].c);
    printf("%d\n", B[i].a);
    puts(isStable? "Stable" : "Not stable");
    
    return 0;
}

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

int main(){
  int n;
  int a[31]={};
  a[0]=1; a[1]=1; a[2]=2;
  for(int i=3;i<=30;i++) a[i]=a[i-3]+a[i-2]+a[i-1];
  
  while(cin >> n && n>0){
    cout << ((a[n]+9)/10+364)/365 << endl;
  }
}

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

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String[] line = in.readLine().split(" ");
            int x = Integer.parseInt(line[0]);
            int y = Integer.parseInt(line[1]);

            if (x < y) {
                int tmp = x;
                x = y;
                y = tmp;
            }

            while (y > 0) {
                int r = x % y;
                x = y;
                y = r;
            }

            System.out.println(x);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24268
/*
auth - @sportykush
*/

#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;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

string s,t;
cin >> s >> t;
bool check = true;
fr(i,0,s.size())
{
	if(s[i] != t[i])
		check = false;
}
cout << (check ? "Yes" : "No");

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3644
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]


x,y = map(int,input().split())

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
int main()
{
	char a[5]={0};
	while(~scanf("%s",a))
	{
		int vis[1000]={0};
		map<char,int> p;
		p.clear();
		int num=0;
		int flag=0;
		int j=0;
		for(int i=0;i<4;i++)
		{
			if(p[a[i]]==0)
			{
				num++; 
			}
			p[a[i]]++;
		}
		if(num!=2)
		{
			printf("No\n");
		}
		else
		{
			int k=0;
			for(auto i=p.begin();i!=p.end();i++)
			{
				if(i->second!=2)
				k=1;
			}
			if(k==1)
			printf("No\n");
			else
			printf("Yes\n");
		}
	}
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: u64,
        d: [usize; n],
    }
    use std::collections::HashSet;
    let uniq: HashSet<usize> = d.into_iter().collect();
    println!("{}", uniq.len());
}
 

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	ans := 0
	for i := 0; i+2 < N; i++ {
		if S[i:i+3] == "ABC" {
			ans++
		}
	}
	fmt.Println(ans)
}


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

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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second%2 != 0) dfs(e.first, v, 1-c);
        else if(e.second%2 == 0) dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 0);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int A, B, C, D, E, F;

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

    cin >> A >> B >> C >> D >> E >> F;
    set<int> water, sugar;
    int a = 0;
    while (true) {
        int w = a * 100 * A;
        if (w > F) break;
        while (true) {
            if (0 < w && w <= F) {
                water.insert(w);
            } else {
                break;
            }
            w += 100 * B;
        }
        a++;
    }

    int c = 0;
    while (true) {
        int s = c * C;
        if (s > F) break;
        while (true) {
            if (s <= F) {
                sugar.insert(s);
            } else {
                break;
            }
            s += D;
        }
        c++;
    }

    int anssum = 100 * A;
    int anssug = 0;
    double rate = 0;
    for (auto w : water) {
        for (auto s : sugar) {
            if (w + s <= F && s <= w / 100 * E) {
                double nrate = (double)s / (double)(w + s);
                if (nrate > rate) {
                    anssum = w + s;
                    anssug = s;
                    rate = nrate;
                }
            } else {
                break;
            }
        }
    }
    cout << anssum << " " << anssug << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

void swap(int *xp,int *yp){
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

void printArray(int arr[], int n){
    for(int i=0; i < n; i++){
        if(i==n-1){
            cout<<arr[i];
        }
        else{
        cout<<arr[i]<<" ";
        }
    }
    cout<<endl;
}

void bubbleSort(int arr[], int n){
    
    int sCount = 0;
    for(int i=0; i < n; i++){
        for(int j=n-1; j>=i+1; j--){
            if(arr[j] < arr[j-1]){
                swap(&arr[j],&arr[j-1]);
                sCount++;
            }
        }
    }
    printArray(arr,n);
    cout<<sCount<<endl;
}



int main(){
    
    int n;
    cin >> n;
     
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    
    bubbleSort(arr,n);
    return 0;
}


Measured memory_bytes: 3132
#include <cstdio>
#include <queue>
#include <tuple>

using namespace std;

int main(int argc, char const *argv[])
{
    int h, w;
    scanf("%d %d\n", &h, &w);
    char maze[h][w+1];
    for(int i=0; i<h; i++){
        scanf("%s\n", maze[i]);
    }
    int ans = 0;
    queue<tuple<int, int, int>> que;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j]=='#') que.push(make_tuple(i, j, 0));
        }
    }
    int dxy[] = {0, 1, 0, -1, 0};
    while(!que.empty()){
        int x, y, d;
        tie(x, y, d) = que.front(); que.pop();
        for(int i=0; i<4; i++){
            int nx = x + dxy[i];
            int ny = y + dxy[i+1];
            if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
            else if(maze[nx][ny] == '.'){
                maze[nx][ny] = '#';
                que.push(make_tuple(nx, ny, d+1));
                ans = d+1;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y,z;
  cin >> z >> x >> y;
  if(x>y) swap(x,y);
  pr(max(0LL,y-(x+z)));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
from itertools import combinations

def is_achievable(M, X, A):
    result = [0] * M
    for a_row in A:
        for i, a in enumerate(a_row):
            result[i] += a

    for n in result:
        if n < X:
            return False
    return True

def main():
    N, M, X = map(int, input().split())

    C = [0] * N
    A = []

    for i in range(N):
        query = list(map(int, input().split()))
        C[i] = query[0]
        A.append(query[1:])

    if not is_achievable(M, X, A):
        print(-1)
        return
    
    index_C = [ i for i in range(N) ]
    min_cost = 10 ** 10
    for i in range(len(index_C)+1):
        for comb in combinations(index_C, i):
            cur_A = []
            cur_cost = 0
            for i in comb:
                cur_A.append(A[i])
                cur_cost += C[i]
            if is_achievable(M, X, cur_A):
                min_cost = min(min_cost, cur_cost)

    print(min_cost)

main()


Measured memory_bytes: 73724
s = input()
num_list = []
a_list = []
b_list = []
a_count = 0
b_count = 0

for i in range(len(s)):
    num_list.append(s[i])
    if i % 2 == 0:
        a_list.append('0')
        b_list.append('1')
    else:
        a_list.append('1')
        b_list.append('0')

for i in range(len(s)):
    if s[i] != a_list[i]:
        a_count += 1
    if s[i] != b_list[i]:
        b_count += 1

print(min(a_count, b_count))

Measured memory_bytes: 5640