akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	vector<string> field(h);
	for(int i = 0; i < h; ++i){ cin >> field[i]; }
	bool answer = false;
	for(int i = 0; !answer && i < h; ++i){
		for(int j = 0; !answer && j < w - 1; ++j){
			if(field[i][j] == field[i][j + 1]){ continue; }
			vector<string> tmp(field);
			swap(tmp[i][j], tmp[i][j + 1]);
			bool modified = true;
			while(modified){
				modified = false;
				for(int x = 0; x < w; ++x){
					for(int y = h - 1, z = h - 1; y >= 0; --y){
						if(tmp[y][x] != '.'){
							char c = tmp[y][x];
							tmp[y][x] = '.';
							tmp[z][x] = c;
							--z;
						}
					}
				}
				vector<string> fallen(tmp);
				for(int y = 0; y < h; ++y){
					for(int x = 0; x <= w - n; ++x){
						if(fallen[y][x] == '.'){ continue; }
						bool erase = true;
						for(int z = 0; z < n; ++z){
							if(fallen[y][x + z] != fallen[y][x]){ erase = false; break; }
						}
						if(erase){
							modified = true;
							for(int z = 0; z < n; ++z){ tmp[y][x + z] = '.'; }
						}
					}
				}
				for(int y = 0; y <= h - n; ++y){
					for(int x = 0; x < w; ++x){
						if(fallen[y][x] == '.'){ continue; }
						bool erase = true;
						for(int z = 0; z < n; ++z){
							if(fallen[y + z][x] != fallen[y][x]){ erase = false; break; }
						}
						if(erase){
							modified = true;
							for(int z = 0; z < n; ++z){ tmp[y + z][x] = '.'; }
						}
					}
				}
			}
			bool hasBlock = false;
			for(int y = 0; !hasBlock && y < h; ++y){
				for(int x = 0; !hasBlock && x < w; ++x){
					if(tmp[y][x] != '.'){ hasBlock = true; }
				}
			}
			answer = !hasBlock;
		}
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
const int MOD = 1e9 + 7;
 
ll dp[100001][13];
 
signed main(){
    string S;
    cin >> S;
    dp[0][0] = 1;
    REP(i,S.size()){
        REP(j,10){
            int c = S[i] - '0';
            if(S[i] == '?' || c == j){
                REP(k,13){
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + j) % 13] %= MOD;
                }
            }
        }
    }
    cout << dp[S.size()][5] << endl;
}

Measured memory_bytes: 10624
#include<iostream>
int main(){
  int A,B,C;
  std::cin>>A>>B>>C;
  for(int i=1;i<=B;i++){
    if(A*i%B==C){
      std::cout<<"YES"<<std::endl;
      return 0;
    }
  }
  std::cout<<"NO"<<std::endl;
  return 0;
}

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll a = 1;a < n;++a) {
        ll Min = 1;
        ll Max = 1e10;
        while (Max - Min > 1) {
            ll Mid = (Min + Max) / 2;
            if (a * Mid >= n)Max = Mid;
            else Min = Mid;
        }
        ans += Min;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

int main(int argc, char **argv)
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::vector<char>> M(H+2, std::vector<char>(W+2, '.'));
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            std::cin >> M.at(i).at(j);
        }
    }
    
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            if(M.at(i).at(j) == '.'){
                int cnt = 0;
                if(M.at(i-1).at(j-1) == '#') cnt++;
                if(M.at(i-1).at(j  ) == '#') cnt++;
                if(M.at(i-1).at(j+1) == '#') cnt++;
                if(M.at(i  ).at(j-1) == '#') cnt++;
                if(M.at(i  ).at(j+1) == '#') cnt++;
                if(M.at(i+1).at(j-1) == '#') cnt++;
                if(M.at(i+1).at(j  ) == '#') cnt++;
                if(M.at(i+1).at(j+1) == '#') cnt++;
                M.at(i).at(j) = cnt+'0';
            }
        }
    }
    
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            std::cout << M.at(i).at(j);
        }
        std::cout << std::endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
L=[[0 for i in range(2)]for i in range(N)]
for i in range(N):
    L[i][0]=A[i]
    L[i][1]=i+1
L=sorted(L)

for i in range(N):
    print(L[i][1],end=" ")

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int Alice = 0, Bob = 0;
    for (int i = 0; i < N; i++){
        if (i % 2 == 0){
            Alice += a.at(i);
        }
        else{
            Bob += a.at(i);
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public int type;
            public string Type { get { switch (type) { case 0: return "root"; case 1: return "internal node"; case 2: return "leaf"; default: return null; } } }
        }

        static void SetDepth(Node[] nodes, int id, int depth)
        {
            nodes[id].depth = depth;
            for (int i = 0; i < nodes[id].childlen.Length; i++)
                SetDepth(nodes, nodes[id].childlen[i], depth + 1);
        }

        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = 2;
                else nodes[id].type = 1;
                nodes[id].childlen = new int[k];
                for (int j = 0; j < k; j++)
                {
                    nodes[id].childlen[j] = token[2 + j];
                    nodes[token[2 + j]].parent = id;
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = 0;
                    SetDepth(nodes, i, 0);
                    break;
                }

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: parent = {1}, depth = {2}, {3}, [", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].Type);
                var l = nodes[i].childlen.Length;
                if (l != 0)
                {
                    for (int j = 0; j < l - 1; j++)
                        Console.Write(nodes[i].childlen[j] + ", ");
                    Console.Write(nodes[i].childlen.Last());
                }
                Console.WriteLine("]");
            }

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 22872
package main

import (
	"container/heap"
	"fmt"
	"sort"
)

// Job is ...
type Job struct {
	A int
	B int
}

// AscABy is ...
type AscABy []Job

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

// A PriorityQueue implements heap.Interface and holds Jobs.
type PriorityQueue []int

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i] > pq[j]
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

// Push is ...
func (pq *PriorityQueue) Push(x interface{}) {
	// n := len(*pq)
	// job := x.(*jobs)
	job := x.(int)
	*pq = append(*pq, job)
}

// Pop is ...
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	job := old[n-1]
	// job.index = -1 // for safety
	*pq = old[0 : n-1]
	return job
}

// main is ...
func main() {
	var n, m, a, b int

	fmt.Scanln(&n, &m)

	jobList := make([]Job, n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&a, &b)
		if m < a {
			continue
		}
		jobList[i] = Job{a, b}
	}

	// A Asc JobList sort
	sort.Sort(AscABy(jobList))

	ret, j := 0, 1

	pq := make(PriorityQueue, len(jobList))
	heap.Init(&pq)
	for i := m - 1; i >= 0; i-- {
		for ; len(jobList) >= j; j++ {
			if jobList[j-1].A > m-i {
				break
			}
			heap.Push(&pq, jobList[j-1].B)
		}

		if 0 == len(pq) {
			continue
		}
		ret += heap.Pop(&pq).(int)
	}
	fmt.Print(ret)
}



Measured memory_bytes: 10112
N, Q = map(int, input().split())
S = input()
lr = []
for _ in range(Q):
	lr.append(list(map(int, input().split())))

total = 0
cnt = [0] * N
for i in range(N-1):
	if S[i] == 'A' and S[i+1] == 'C':
		total += 1
	cnt[i+1] = total

for l, r in lr:
	print(cnt[r-1] - cnt[l-1])


Measured memory_bytes: 68824
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;





int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int w, h;
	scanf("%d%d", &w, &h);
	long long ans = 0;
	int cnth = 0, cntw = 0;

	vector <int> vw, vh;
	for (int i = 0; i < w; i++)
	{
		int x;
		scanf("%d", &x);
		vw.push_back(x);
	}
	for (int i = 0; i < h; i++)
	{
		int x;
		scanf("%d", &x);
		vh.push_back(x);
	}
	sort(vw.begin(), vw.end() );
	sort(vh.begin(), vh.end() );

	int pw = 0, ph = 0;
	while (pw != (int) vw.size() || ph != (int) vh.size() )
	{
		if (pw == (int) vw.size() || (ph != (int) vh.size() && vh[ph] < vw[pw] ) )
		{
			int cnt = cnt = w + 1 - cntw;
			cnth++;
			ans += vh[ph++] * 1LL * cnt;
		}
		else
		{
			int cnt = h + 1 - cnth;
			cntw++;
			ans += vw[pw++] * 1LL * cnt;
		}
	}



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

	return 0;
}



Measured memory_bytes: 1400
#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 k,t;
    cin >> k >> t;
    vector <int> a(t);
    rep(i,t){
        cin >> a[i];
    } 

    sort(a.begin(),a.end());
    int ans;
    ans=a[t-1]-1-(k-a[t-1]);
    if(ans<0){
        ans=0;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll a[n * n + 1] = {}, b[n + 1], m[n + 1];
	vector<pair<ll, ll>> v;
	for(ll i = 0; i < n; i++){
		ll po; cin >> po;
		a[po] = i + 1;
		b[i + 1] = n - 1;
		v.push_back(pair<ll, ll>(po, i + 1));
		m[i + 1] = po;
	}
	sort(v.begin(), v.end());
	queue<ll> q;
	for(ll i = 0; i < n; ++i) q.push(v[i].second);
	ll flag = 1;
	for(ll i = 1; i <= n * n; i++){
		if(!a[i]) continue;
		ll po = a[i] - 1;
		for(; flag < i && po; flag++){
			if(a[flag]) continue;
			a[flag] = a[i];
			b[a[i]]--;
			po--;
		}
		if(po){
			cout << "No\n";
			return 0;
		}
	}
	for(ll i = 1; i <= n * n; i++){
		if(a[i]) continue;
		while(!b[q.front()]) q.pop();
		if(m[q.front()] > i){
			cout << "No\n";
			return 0;
		}
		a[i] = q.front();
		b[q.front()]--;
	}
	cout << "Yes\n";
	for(ll i = 1; i <= n * n; i++) cout << a[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3200
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b,c,d;

signed main(){
    io();

    in(a,b,c,d);
    if(abs(c-a)<=d || (abs(b-a) <= d && abs(c-b)<=d)){
        yes;
        return 0;
    }

    no;

    return 0;
}


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

int main(){

  int a,b,c,tmp;

  cin >> a >> b >> c;

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  if(b > c){
    tmp = b;
    b = c;
    c = tmp;
  }

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  cout << a << " " << b << " " << c << endl;

  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  long long n, m, d;
  cin >> n >> m >> d;
  if (d == 0){
    cout << (double) (n - d) / (n * n) * (m - 1) << endl;
  } else {
    cout << (double) (n - d) * 2 / (n * n) * (m - 1) << endl;
  }
}

Measured memory_bytes: 3744
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A, B, C;

int main(){
    cin >> A >> B >> C;

    cout << min(B/A,C) << endl;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc129/tasks/abc129_c
N,M = map(int,input().split())
dp = [[] for i in range(N)]
for i in range(M):
    dp[int(input())-1] = 0

for i in range(N):
    if dp[i] != 0:
        if i == 0:
            dp[i] = 1
        elif i == 1:
            dp[i] = dp[i-1] + 1
        else:
            dp[i] = dp[i-1] + dp[i-2]
        
print(dp[-1] % 1000000007)     

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


int main(){
  string str="";
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(i==x)str+='o';
    else str+='x';
  }
  int ans=0;
  for(int i=0;i<(int)str.size();i++){
    if(str[i]=='o'){
      ans++;
      str[i]='x';
      if(i+1<(int)str.size())str[i+1]='x';
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(2*n);
  for(int i=0; i<2*n; i++){
    cin >> v[i];
  }
  
  int max=0;
  int b=0;
  for(int i=0; i<=2*n-2; i+=2){
    if(v[i] >= max){
      max = v[i];
      b = i;
    }
  }
  
  cout << v[b] + v[b+1] << endl;
	return 0;
}


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

int main()
{
	vector<vector<int>> card(3, vector<int>(3));
	for (auto& i : card) {
		for (auto& j : i) {
			cin >> j;
		}
	}

	int n;
	cin >> n;

	vector<vector<bool>> check(3, vector<bool>(3,false));
	for (int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (card[j][k] == b) {
					check[j][k] = true;
				}
			}
		}
	}

	bool ret = false;
	if ((check[0][0] && check[0][1] && check[0][2]) ||
		(check[1][0] && check[1][1] && check[1][2]) ||
		(check[2][0] && check[2][1] && check[2][2]) ||
		(check[0][0] && check[1][0] && check[2][0]) ||
		(check[0][1] && check[1][1] && check[2][1]) ||
		(check[0][2] && check[1][2] && check[2][2]) ||
		(check[0][0] && check[1][1] && check[2][2]) ||
		(check[2][0] && check[1][1] && check[0][2])) {
		ret = true;
	}

	if (ret) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0] != 'A' || s[1] < 'a' || s[s.size()-1] < 'a'){
        cout << "WA";
        return 0;
    }
        
    int count = 0;
    for(int i = 2 ; i < s.size()-1; i++){
        if(count > 1 || (s[i] < 'a' &&  s[i] != 'C')){
            cout << "WA";
            return 0;
        }
        if(s[i] == 'C')
            count++;
    }
    if(count == 1)
        cout << "AC";
    else
        cout << "WA";
    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
nums = []
m.times do
  nums << gets.split.map(&:to_i)
end

i = 0
answer = -1

while i.to_s.size <= n do
  str = i.to_s
  
  if i.to_s.size == n && nums.all? {|s,c| str[s-1] && str[s-1].to_i == c}
    answer = i
    break
  end
  i += 1
end

puts answer

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


int main() {

    string target_s = "AC";

    int n,q;
    cin>>n>>q;

    string s;
    cin>>s;


    //ACの数を保存するベクトルを作成する。
    vector<int> count_ac(n,0);
    int cnt=0;
    int pos = s.find(target_s);
     while(pos != string::npos){
       cnt++;
       count_ac.at(pos+1)=cnt;
       pos=s.find(target_s,pos+target_s.size());
     }

    int wk2=0;
     for(int i=0;i<n;i++){
       int wk=count_ac.at(i);
       if(wk != 0){
          wk2=wk;
       }else{
          count_ac.at(i)=wk2;
       }
     }


    for(int i=0;i<q;i++){
      int l,r;
      cin>>l>>r;
      l--;
      r--;
      cout<<count_ac.at(r)-count_ac.at(l)<<endl;
      
    }
 
    return 0;
}


Measured memory_bytes: 1408
import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

# get num
num = int(raw_input())

p_dbg('num : ' + str(num))

array = []

# set to array by 10
dig = 4
while dig > 0:
    array.append((num % 10))
    num = num / 10
    dig = dig -1

p_dbg('array : ' + str(array))

# judge array
#array.sort()
count = 0
head = array[0]
while len(array) > 0:
    item = array.pop(0)
    p_dbg('head:' + str(head))
    p_dbg('item:' + str(item))
    if(head == item):
        count = count + 1
    else:
        count = 1
        head = item

    if(count >= 3):
        break

if(count >= 3):
    sys.stdout.flush()
    print 'Yes'
else:
    sys.stdout.flush()
    print 'No'


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

class Cube{
	public:
		int f[6];
		Cube(){}
		void roll_z(){ roll(1, 2, 4, 3);}
		void roll_y(){ roll(0, 2, 5, 3);}
		void roll_x(){ roll(0, 1, 5, 4);}
		void roll(int i, int j, int k, int l){
			int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
		}
};

bool eq(Cube c1, Cube c2){
	for(int i=0;i<6;i++)
		if(c1.f[i] != c2.f[i]) return false;
	return true;
}

bool equal(Cube c1, Cube c2){
	for(int i=0;i<6;i++){
		for(int j=0;j<4;j++){
			if(eq(c1,c2)) return true;
			c1.roll_z();
		}
		if(i%2==0) c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

Cube C[100]; int n;

bool check(){
	for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++) if(equal(C[i],C[j])) return false;
	return true;
}

int main(){
	cin >> n;

	for(int j=0;j<n;j++)
		for(int i=0;i<6;i++) cin >> C[j].f[i];

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

	return 0;
}

Measured memory_bytes: 3088
#include <iostream>

using i64 = long long;

int n;
i64 x, k, p;

i64 sg(i64 x, i64 k) {
	if (x < k) return 0;
	if (x % k == 0) return x / k;
	if (k * k <= x) return sg(x - 1 - x / k, k);
	return sg(x - std::max(1ll, (x % k / (1 + x / k))) * (1 + x / k), k);
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	while (n--)
		scanf("%lld%lld", &x, &k), p ^= sg(x, k);
	printf(p ? "Takahashi" : "Aoki");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値を取得する
    String input = sc.nextLine();
    String result = "0";

    int result1 = input.indexOf("RRR");
    if (result1 > -1) {
      result = "3";
    } else {
	    int result2 = input.indexOf("RR");
        if (result2 > -1) {
          result = "2";
        } else {
          int result3 = input.indexOf("R");
          if (result3 > -1) {
            result = "1";
          }
        }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35820
s = input()
t = s[1:]+" "
r = s[2:]+"  "
for n,(i,j,k) in enumerate(zip(s,t,r)):
    if i == j :
        print(n+1,n+2)
        exit()
    elif i == k:
        print(n+1,n+3)
        exit()
print(-1,-1)


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

int main(){
  int n, x;
  cin >> n >> x;
  int a[n];
  for ( int i = 0; i < n; i++) cin >> a[i];

  long long ans = 0;
  for ( int i = 1; i < n; i++){
    if(a[i-1] + a[i] > x){
      ans += (a[i-1] + a[i] - x);
      a[i] = max(x - a[i-1], 0);
      if ( a[i] == 0){
        a[i-1] = x;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int x,y,gx,gy;
int main(){
    cin>>x>>y;
    if(x==2)
       gx=1;
    else if((x==4)||(x==6)||(x==9)||(x==11))
       gx=2;
    else
       gx=3;

    if(y==2)
       gy=1;
    else if((y==4)||(y==6)||(y==9)||(y==11))
       gy=2;
    else
       gy=3;
       
    if(gx==gy)
       cout<<"Yes"<<endl;
    else
       cout<<"No"<<endl;

}

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

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(int argc, const char * argv[]) {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> s = vector<int>(N, 0);
    int x;
    for (int i = 0; i < Q; i++) {
        cin >> x;
        s[x - 1]++;
    }
    
    for (int i = 0; i < N; i++) {
        if (K - Q + s[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int k;
int a[105000];


int main()
{
	cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}

	ll mn = 0, mx = 0;

	if (a[k - 1] == 2) { mn = 2; mx = 3; }
	else { mn = 2; mx = 2; }

	for (int i = k - 1; i >= 0; i--) {
		if(( mx - mn + 1)/a[i] == 0 && mn % a[i] != 0 && mx % a[i] != 0 && (mx/a[i]-mn/a[i]) == 0){
			cout << -1 << endl;
			return 0;
		}
		else {
			ll b;
			ll c;
			if (mn%a[i] == 0) {
				b = mn;
			}
			else {
				b = (mn / a[i] + 1)*a[i];
			}
			c = mx / a[i] + 1;

			mn = b;
			mx = c*a[i] - 1;
		}
		//cout << mn << " " << mx << endl;
	}
	cout << mn << " " << mx << endl;

	return 0;
}


Measured memory_bytes: 640
import itertools
import collections


N = int(input())
L = list(map(int, input().split()))

C = list(itertools.combinations(L, 3))
c = len(C)

ans = 0
for i in range(c):
    if C[i][0] == C[i][1] or C[i][1] == C[i][2] or C[i][0] == C[i][2]:
        continue
    else:
        if C[i][2] < C[i][0] + C[i][1]:
            if C[i][1] < C[i][0] + C[i][2]:
                if C[i][0] < C[i][1] + C[i][2]:
                    ans += 1
print(ans)


Measured memory_bytes: 20892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long X = cin.nextLong();
        long[] l = new long[N + 1];
        long[] p = new long[N + 1];

        l[0] = 1;
        p[0] = 1;
        for (int i = 1; i <= N; i++)
        {
            l[i] = 2 * l[i - 1] + 3;
            p[i] = 2 * p[i - 1] + 1;
        }

        long ans = 0;
        for (int i = N; i >= 0; i--)
        {
            if (X >= l[i] / 2 + 1)
            {
                ans += p[i] / 2 + 1;
                X -= l[i] / 2 + 1;
            }
            else
            {
                X--;
            }
        }
        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
main(i){int s[9000],n,m,t,f;while(scanf("%d%d",&n,&m),i=0,t=f=1,n)while(++i<=n+m)if(scanf("%d",&s[i]),i>n)if(t+=s[t+=s[i]],f==t>=n)printf("%d\n",i-n,f=0);}

Measured memory_bytes: 0
s = gets.chomp
left = s.slice(0, 2).to_i
right = s.slice(2, 2).to_i
f1 = 1 <= left && left <= 12
f2 = 1 <= right && right <= 12

if f1 && f2
  puts "AMBIGUOUS"
elsif f1 && !f2
  puts "MMYY"
elsif !f1 && f2
  puts "YYMM"
else
  puts "NA"
end

Measured memory_bytes: 1916
import itertools
import math

 
N = int(input())
ls2 = []
for i in range(N):
    ls1 = list(map(int,input().split()))
    ls2.append(ls1)

lis = [x for x in range(N)]
permutations_lis = itertools.permutations(lis)

dis = 0
for one_case in permutations_lis:
    for i in range(1,N):
        dis += ((ls2[one_case[i]][0]-ls2[one_case[i-1]][0])**2+(ls2[one_case[i]][1]-ls2[one_case[i-1]][1])**2)**(1/2)
    
print(dis/(math.factorial(N)))

Measured memory_bytes: 74232
#include <bits/stdc++.h>
#define re register
#define SIZE 100005
using namespace std;
template <typename T>
inline void read(T &x)
{
	int f;char c;
	x=0,f=0,c=getchar();
	while(c<'0' && '9'<c)	f|=(c=='-'),c=getchar();
	while('0'<=c && c<='9')	x=(x<<3)+(x<<1)+c-48,c=getchar();
	x=f?-x:x;
}
int n;
int a[SIZE][5];
int dp[SIZE][5];
int main()
{
	read(n);
	for(re int i=1;i<=n;++i)
		read(a[i][1]),read(a[i][2]),read(a[i][3]);
	for(re int i=1;i<=n;++i)
	{
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i][2];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+a[i][3];
	}
	printf("%d\n",max(max(dp[n][1],dp[n][2]),dp[n][3]));
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    ll num[5] = {};
    rep(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') num[0]++;
        if (s[0] == 'A') num[1]++;
        if (s[0] == 'R') num[2]++;
        if (s[0] == 'C') num[3]++;
        if (s[0] == 'H') num[4]++;
    }
    ll ans = 0;
    rep(i, 5)repl(j, i + 1, 5)repl(k, j + 1, 5) {
        ans += num[i] * num[j] * num[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;


ll i,j,k;

int main(){
   ll N,M;
   cin>>N>>M;
   V A(M),B(M);
   rep(i,M)cin>>A[i]>>B[i];
   vector<V> rinsetu(N);
   rep(i,M){
      rinsetu.at(A[i]-1).push_back(B[i]-1);
      rinsetu.at(B[i]-1).push_back(A[i]-1);
   }
   V tyokuzen(N,-1);
   queue<ll> path;
   path.push(0);
   tyokuzen[0]=0;
   while(!path.empty()){
      ll f=path.front();
      path.pop();
      for(ll x:rinsetu[f]){
         if(tyokuzen[x]==-1){
            path.push(x);
            tyokuzen[x]=f;
         }
      }
   }
   cout<<"Yes"<<endl;
   for(int c=1;c<N;c++){
      cout<<tyokuzen[c]+1<<endl;
   }
    


}

Measured memory_bytes: 16200
N, K = list(map(int, input().split()))
A = list(map(lambda x: int(x) - 1, input().split()))

now = 0
route = []
seen = set()
while not now in seen:
    route.append(now)
    seen.add(now)
    now = A[now]

loop_start = route.index(now)
loop_size = len(route) - loop_start

n_for_loop = min(K, loop_start)
n_in_loop = (K - n_for_loop) % loop_size

print(route[n_for_loop + n_in_loop] + 1)


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

int main() {
  int n, l;
  cin >> n >> l;
  
  int sum = 0;
  int mi = 1e18;
  for (int i = 0; i < n; i++) {
    int t = l + i;
    sum += t;
    if (abs(t) < abs(mi)) {
      mi = t;
    }
  }
  cout << sum - mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)cin >> a[i] >> b[i] >> c[i];
	int dp[n][3];
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	for(int i=1;i<n;i++){
	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
	dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
import numpy as np
def main():
    n = int(input())
    count = np.zeros((10, 10))
    for i in range(1, n + 1):
        i = str(i)
        s = int(i[0])
        e = int(i[-1])
        count[s, e] += 1
    print(np.sum(count * count.T, dtype = np.int))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12396
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]

cnt_S = Counter(S)
cnt_T = Counter(T)
values, counts = zip(*cnt_S.most_common())

ans = 0
for i in range(len(values)):
    ans = max(ans, counts[i] - cnt_T[values[i]])
print(ans)

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 300 + 5;
char mapp[maxn][maxn];
int n,cnt;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%s", mapp[i] + 1);
    for (int k = 0; k < n; ++k)
    {
        int flag = 1;
        for (int i = 1; i <= n; ++i)
        {
            for (int j = i + 1; j <= n; ++j)
            {
                int x = i;
                int y = j - k;
                if (y <= 0)
                    y += n;
                int yy = i - k;
                int xx = j;
                if (yy <= 0)
                    yy += n;
                if (mapp[x][y] != mapp[xx][yy])
                {
                    flag = 0;
                    break;
                }
            }
            if (!flag)
                break;
        }
        if (flag)
            cnt += n;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 384
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b;


    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vvint m(h,vint(w,0));
    int black = 0;
    vector<pair<int, int> > pre;
    vector<pair<int, int> > next;
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            if(s[j]=='#'){
                m[i][j]=1;
                black++;
                pre.pb(make_pair(i,j));
            }else{
                m[i][j]=0;
            }
        }
    }
    int ans = 0;
    while(black<h*w){
        ans++;
        for(pair<int,int> p : pre){
            int x = p.first;
            int y = p.second;
            REP(i,4){
                if(x+dx[i]>=0&&x+dx[i]<h&&(y+dy[i])>=0&&(y+dy[i])<w&&m[x+dx[i]][y+dy[i]]==0){
                    next.pb(make_pair(x+dx[i],y+dy[i]));
                    m[x+dx[i]][y+dy[i]]=1;
                    black++;
                }
            }
        }
        pre.clear();
        for(pair<int,int> p : next){
            pre.pb(p);
        }
        next.clear();
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,l;
  cin >> n>>l;
  int a=0;
    for(int i=1;i<=n;i++){
      a+=l+i-1;
    }
    if(l>=0){
    cout <<a-l<<endl;
  }
  else if(l+n-1>=0){
    cout << a << endl;
  }
  else{
    cout << a-l-n+1 << endl;
  }
}


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

using namespace std;

int m,n;
char map[110][110];
int ans;
int way[4][2]={-1,0,0,1,1,0,0,-1};

int ok(int x,int y)
{
    if(x>=0&&x<m&&y>=0&&y<n)
    return 1;
    else
    return 0;
}

void dfs1(int x,int y)
{
    map[x][y]='.';
    for(int i=0;i<4;i++)
    {
        int xx=x+way[i][0];
        int yy=y+way[i][1];
        if(ok(xx,yy)&&map[xx][yy]!='.'&&map[xx][yy]!='#'&&map[xx][yy]!='@')
        dfs1(xx,yy);
    }
    return;
}

void dfs2(int x,int y)
{
    map[x][y]='.';
    for(int i=0;i<4;i++)
    {
        int xx=x+way[i][0];
        int yy=y+way[i][1];
        if(ok(xx,yy)&&map[xx][yy]!='.'&&map[xx][yy]!='#'&&map[xx][yy]!='*')
        dfs2(xx,yy);
    }
    return;
}

void dfs3(int x,int y)
{
     map[x][y]='.';
    for(int i=0;i<4;i++)
    {
        int xx=x+way[i][0];
        int yy=y+way[i][1];
        if(ok(xx,yy)&&map[xx][yy]!='.'&&map[xx][yy]!='@'&&map[xx][yy]!='*')
        dfs3(xx,yy);
    }
    return;
}


int main()
{
    while(cin>>m>>n)
    {
        if(m==0&&n==0)
        break;
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                cin>>map[i][j];
            }
        }
        ans=0;
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(map[i][j]=='#')
                {
                    dfs3(i,j);
                    ans++;
                }
                if(map[i][j]=='@')
                {
                    dfs2(i,j);
                    ans++;
                }
                if(map[i][j]=='*')
                {
                    dfs1(i,j);
                    ans++;
                }
            }
        }
        cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
		char a;
		int b, c;
	scanf("%c",&a);
	if(a=='a' || a=='i' || a=='u' || a=='e' || a=='o'){
			printf("vowel\n");
		}
	else{
			printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64, int64>;

void diviser(int num, int n, vector<bool>& u) {
    for (int i=num; i<=n; i+=num) {
//        if (u[i]) return;
        u[i] = true;
    }
}

int main() {
    int n;
    cin >> n;
    vector a(n,0);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    vector<P> len;
    len.emplace_back(a[0], 0);
    for (int i=0; i<n; i++) {
        if (len.back().first == a[i]) len.back().second++;
        else len.emplace_back(a[i], 1);
    }

    vector<bool> u(a.back()+1, false);
    int64 ans = 0;
    for (auto [ai,c] : len) {
        if (c<=1 && !u[ai]) ans++;
        diviser(ai, a.back(), u);
    }


    cout << ans << endl;
}

Measured memory_bytes: 7724
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	int x[n], y[n];
	double p[4], f;
	p[0] = 0;
	p[1] = 0;
	p[2] = 0;
	p[3] = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &y[i]);
	}
	for (int i = 0; i < n; i++) {
		f = (double)abs(x[i] - y[i]);
		p[0] += f;
		p[1] += pow(f, 2.0);
		p[2] += pow(f, 3.0);
		if (p[3] < f) {
			p[3] = f;
		}
	}
	printf("%lf\n", p[0]);
	printf("%lf\n", sqrt(p[1]));
	printf("%lf\n", cbrt(p[2]));
	printf("%lf\n", p[3]);
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n;
	cin>>n;
int v[100005][3];
			for(int i=1;i<=n;i++)
			cin>>v[i][0]>>v[i][1]>>v[i][2];
			//dp[i][j] max points he can gain upto such that he does task j on this day
		ll dp[100005][3];
		
		for(int i=1;i<=n;i++){
			for(int j=0;j<3;j++){
				dp[i][j]=0;
				for(int k=0;k<3;k++){
					if(k!=j)
					dp[i][j]=max(dp[i][j], dp[i-1][k]+v[i][j]);
				}
			}
		}
    cout<<max(dp[n][0],max(dp[n][1], dp[n][2]));
	
	
}

Measured memory_bytes: 7124
parse_Int(x) = parse(Int,x)
read_Str() = strip(readline())
read_IntList(x) = parse_Int.(split(readline(x)))
read_strList(x) = split(read_Str())

day = read_Str()
if day == "SUN"
    println(7)
elseif day == "MON"
    println(6)
elseif day == "TUE"
    println(5)
elseif day == "WED"
    println(4)
elseif day == "THU"
    println(3)
elseif day == "FRI"
    println(2)
elseif day == "SAT"
    println(1)
end

Measured memory_bytes: 167396
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (100001)

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<vector<int>> v(n, vector<int>(0));
	vector<int> is_visit(n, 0);
	vector<int> pre_visit(1,0);
	is_visit[0] = -1;
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	while (pre_visit.size() != 0) {
		vector<int> now_visit(0);
		for (auto a : pre_visit) {
			for (auto b : v[a]) {
				if (is_visit[b]==0) {
					is_visit[b] = a + 1;
					now_visit.emplace_back(b);
				}
			}
		}
		pre_visit = now_visit;
	}
	cout << "Yes" << endl;
	for (auto a : is_visit)if(a!=-1) {
		cout << a << endl;
	}
}


Measured memory_bytes: 13560
MOD = 1000000007

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return a//gcd(a,b)*b

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	vector<P> p(M);
	rep(i,M){
		ll A,B; cin>>A>>B;
		p[i]=mp(B,A);
	}
	sort(p.bg,p.ed);
	ll cut=p[0].a-1;
	ll cnt=1;
	rep1(i,M-1){
		if(p[i].b>cut){
			cut=p[i].a-1;
			cnt++;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	
	int* sum = new int[n];
	sum[0] = 0;
	REP(i, 1, n) {
		sum[i] = sum[i - 1];
		
		if (s[i - 1] == 'A' && s[i] == 'C') {
			++sum[i];
		}
	}

	int l, r;
	rep(i, q) {
		cin >> l >> r;
		--l;
		--r;

		cout << sum[r] - sum[l] << "\n";
	}

	return 0;
}



Measured memory_bytes: 1488
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	int a = 0;
	int b = 0;
	double A = 0;
	double B = 0;
	cin >> a >> b;
	A = a;
	B = b;
	cout << a / b << " " << a % b << " ";
	cout << fixed <<setprecision(7)<< A / B << endl;
	return 0;
}


Measured memory_bytes: 3280