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

namespace Program
{
    public class ABC126B
    {
        static public void Main(string[] args)
        {
            var S = NextString;

            var month = new string[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

            var first2 = S.Substring(0, 2);
            var second2 = S.Substring(2, 2);

            var first2Month = month.Contains(first2);
            var second2Month = month.Contains(second2);

            if (first2Month && second2Month)
            {
                Console.WriteLine("AMBIGUOUS");
                return;
            }
            if (!first2Month && second2Month)
            {
                Console.WriteLine("YYMM");
                return;
            }
            if (first2Month && !second2Month)
            {
                Console.WriteLine("MMYY");
                return;
            }
            Console.WriteLine("NA");
            return;
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 13396
//https://atcoder.jp/contests/agc033/tasks/agc033_a
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 1003;
string S[N];
int dis[N][N], inf = 1e9;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

bool clamp(int x, int lo, int hi)
{
  return x >= lo and x <= hi;
}

int main()
{
  int i, n, m, j;
  ios_base::sync_with_stdio(0);

  cin >> n >> m;

  queue<pair<int, int>> q;

  for (i = 0; i < n; i++)
  {
    cin >> S[i];
    for (j = 0; j < m; j++)
    {
      if (S[i][j] == '#')
        dis[i][j] = 0, q.push({i, j});
      else
        dis[i][j] = inf;
    }
  }

  int ans = 0;

  while (!q.empty())
  {
    pair<int, int> cur = q.front();
    q.pop();

    int x = cur.first, y = cur.second;

    for (i = 0; i < 4; i++)
    {
      int nx = x + dx[i];
      int ny = y + dy[i];

      if (clamp(nx, 0, n - 1) and clamp(ny, 0, m - 1) and dis[nx][ny] == inf)
      {
        q.push({nx, ny});
        dis[nx][ny] = 1 + dis[x][y];
        ans = max(ans, dis[nx][ny]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13456
#include<cstdio>
int main()
{
	int a,b,c,d;
	scanf("%01d %01d %01d %01d",&a,&b,&c,&d);
	if(a==b || b==c || c==d)
		printf("Bad\n");
	else
		printf("Good\n");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
bit_num = 30
A_b = [format(a, '0{}b'.format(bit_num)) for a in A]
S = ''
for i in range(bit_num):
    bit = 0
    for a in A_b:
        if a[i] == '1':
            bit += 1
    if bit % 2 == 0:
        S += '0'
    else:
        S += '1'
#print(S)
B = []
for a in A_b:
    b = ''
    for i in range(bit_num):
        if (int(a[i]) + int(S[i])) % 2 == 0:
            b +='0'
        else:
            b += '1'
    #print(b)
    B.append(int(b, 2))
print(*B)

Measured memory_bytes: 128504
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var n = input.ReadLine;
            var a = input.ReadLongArray;
            var count = 0;
            while (a.Count(l => l % 2 != 0) == 0)
            {
                a = a.Select(b => b / 2).ToArray();
                count++;
            }
            Console.WriteLine(count);
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 11476
def is_correct(grids):
    for a1 in range(min(101, grids[0][0]+1)):
        b_list = grids[0][0] - a1, grids[0][1] - a1, grids[0][2] - a1
        a2, a3 = grids[1][0] - b_list[0], grids[2][0] - b_list[0]
        a_list = [a1, a2, a3]
        temp_grids = []
        for an in a_list:
            row = []
            for bn in b_list:
                row.append(an+bn)
            temp_grids.append(row)
        if grids == temp_grids:
            return True

    return False


grids = []
for _ in range(3):
    grids.append(list(map(int, input().split())))

print("Yes" if is_correct(grids) else "No")

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    if 'RRR' in S:
        ret = 3
    elif 'RR' in S:
        ret = 2
    elif 'R' in S:
        ret = 1
    else:
        ret = 0
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61680
def main():
	n = int(input())
	# b = int(input())
	# a = list(map(int,input().split()))
	# A = [list(map(int, input().split())) for _ in range(n)]
	# print(a)
	quit=0
	for i in range(50001):
		if int(i * 1.08) == n:
			print(i)
			quit = 1
			break
	
	if quit == 0:
		print(":(")





if __name__ == '__main__':
	main()

Measured memory_bytes: 38512
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC163D();


#if 1
int main()
{
	ABC163D();
	fflush(stdout);
	return 0;
}
#endif

static void ABC163D()
{
	LLONG N, K;
	getint(N, K);
	
	LLONG ans = 0;
	for (LLONG i = K; i <= (N + 1); i++) {
		LLONG ptnMin = (i - 1) * i / 2LL;
		LLONG ptnMax = (i * (2 * N - (i - 1))) / 2LL;
		ans += (ptnMax - ptnMin) + 1;
		ans %= MOD_NUM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3796
a,b,c=(map(int,input().split()))
if a!=b and a!=c and b!=c:
  print(3)
elif a==b and a==c and b==c:
  print(1)
elif (a==b and a!=c)or(a==c and a!=b)or(b==c and b!=a):
  print(2)

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

int main(){
    ll n, ans = 1, cnt[1001]{};
    cin >> n;
    fill(cnt, cnt+1001, 1);
    for(int i=2;i<=n;i++){
        int m = i;
        for(int j=2;j*j<=m;j++){
            while(m%j == 0){
                m /= j;
                cnt[j]++;
            }
        }
        if(m != 1) cnt[m]++;
    }
    for(int i=2;i<=n;i++){
        ans = ans*cnt[i]%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())

	count := 0
	for i := 4; i < M+1; i++ {
		for j := 2; j < min(10, M+1); j++ {
			if i%j == 0 && i/j < 10 && i/j > 1 && j*10+i/j <= D {
				count++
			}
		}
	}

	fmt.Println(count)
}

func min(s ...int) int {
	minContent := s[0]
	for _, el := range s {
		if el < minContent {
			minContent = el
		}
	}
	return minContent
}


Measured memory_bytes: 640
import java.math.*;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			if(m==n) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
				
	}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
string s;
 
int main(){
  cin >> s;
  int a[4];
  rep(i,4) a[i] = s[i] -'0';
  if(a[0] + a[1] + a[2] + a[3] == 7){
    cout <<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] + a[1] + a[2] - a[3] == 7){
    cout <<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] + a[1] - a[2] + a[3] == 7){
    cout <<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] + a[1] - a[2] - a[3] == 7){
    cout <<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] - a[1] + a[2] + a[3] == 7){
    cout <<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] - a[1] + a[2] - a[3] == 7){
    cout <<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] - a[1] - a[2] + a[3] == 7){
    cout <<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<"=7"<<endl;
  }
  else if(a[0] - a[1] - a[2] - a[3] == 7){
    cout <<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<"=7"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int K;

    cin >> K;

    if(K%2==0){
        cout << (K/2) * (K/2) << endl;
    }

    else{
        cout << (K/2) * (K-K/2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e10;
const int MOD = 1e9+7;

const int MAX_N = 100005;


int main(int argc, char *args[]) {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	int now = p[0];
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (now < p[i]) {
			count++;
			continue;
		}
		now = p[i];
	}
	int res = n - count;
	cout << res << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll dp[20010];  //dp[i]:=体力をi減らすのに必要な魔力のmin
    for (ll i = 0; i < 20010; i++) dp[i] = INF;
    dp[0] = 0;
    for (ll i = 0; i < 20010; i++) {
        for (ll j = 0; j < n;j++){
            if (i - a[j] >= 0) chmin(dp[i], dp[i - a[j]] + b[j]);
        }
    }
    ll ans = INF;
    for (ll i = h; i < 20010; i++) chmin(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int mul = 0;
  if (w / 2 == x && h / 2 == y) mul = 1;
  cout << (w *  h) / 2 << " " << mul << endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
al = list(map(int, input().split()))

amax = -10**7
maxi = -1
amin = 10**7
mini = -1
for i, a in enumerate(al):
    if a > amax: 
        amax = a
        maxi = i
    if a < amin:
        amin = a
        mini = i

ansl = []
if amin >= 0 or amax >= abs(amin):
    print(2*n-1)
    for i in range(n):
        print(maxi+1,i+1)
    for i in range(n-1):
        print(i+1,i+2)

else:
    print(2*n-1)
    for i in range(n):
        print(mini+1, i+1)
    for i in range(n-1,0,-1):
        print(i+1,i)    

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

int main(void){
    int n, h;
    cin >> n >> h;
    
    int a, a_max = 0;
    int b[100000];
    int i;
    for(i = 0; i < n; i++){
        cin >> a >> b[i];
        if(a > a_max){
            a_max = a;
        }
    }
    
    sort(b, b + n, greater<int>());
    
    int cnt = 0;
    i = 0;
    while(b[i] > a_max){
        h -= b[i];
        cnt++;
        i++;
        if(h <= 0 || i >= n){
            break;
        }
    }
    
    if(h > 0){
        cnt += (h - 1) / a_max + 1;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, u, v;
struct pqdata {
    int pnow; int len;
};

int main() {
    cin >> n >> u >> v;
    u--; v--;
    vector< vector<int> > graph(n, vector<int>());
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b; a--; b--;
        graph.at(a).emplace_back(b);
        graph.at(b).emplace_back(a);
    }

    vector<int> Agraph(n, -1);
    vector<int> Tgraph(n, -1);

    queue<pqdata> Aque;
    Agraph.at(v) = 0;
    pqdata Afirst;
    Afirst.pnow = v; Afirst.len = 0;
    Aque.push(Afirst);
    while(!Aque.empty()) {
        pqdata now = Aque.front();
        Aque.pop();
        for(int i = 0; i < (int)graph.at(now.pnow).size(); ++i) {
            int next = graph.at(now.pnow).at(i);
            int nlen = now.len + 1;
            if(Agraph.at(next) == -1) {
                Agraph.at(next) = nlen;
                pqdata Anext;
                Anext.pnow = next; Anext.len = nlen;
                Aque.push(Anext);
            }
        }
    }

    queue<pqdata> Tque;
    pqdata Tfirst;
    Tfirst.pnow = u; Tfirst.len = 0;
    Tgraph.at(u) = 0;
    Tque.push(Tfirst);
    while(!Tque.empty()) {
        pqdata now = Tque.front();
        Tque.pop();
        for(int i = 0; i < (int)graph.at(now.pnow).size(); ++i) {
            int next = graph.at(now.pnow).at(i);
            int nlen = now.len + 1;
            if(Tgraph.at(next) == -1) {
                Tgraph.at(next) = nlen;
                pqdata Tnext;
                Tnext.pnow = next; Tnext.len = nlen;
                Tque.push(Tnext);
            }
        }
    }

    /*for(int i = 0; i < n; ++i) {
        cout << Agraph.at(i) << " ";
    }
    cout << endl;
    for(int i = 0; i < n; ++i) {
        cout << Tgraph.at(i) << " ";
    }*/

    int goal = 0;
    int lenmax = 0;
    for(int i = 0; i < n; ++i) {
        if(Agraph.at(i) > Tgraph.at(i)) {
            if(lenmax < Agraph.at(i)) {
                goal = i;
                lenmax = Agraph.at(i);
            }
        }
    }

    cout << Agraph.at(goal)-1 << endl;
}

Measured memory_bytes: 6784
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int a = s[0].CompareTo(s[1]);
        if (a == 0)
        {
            Console.WriteLine("=");
        }
        else if (a < 0)
        {
            Console.WriteLine("<");
        }
        else
        {
            Console.WriteLine(">");
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())

int main() {
  int N;
  cin >> N;
  set<int> d;
  for (int i = 0; i < N; i++) {
    int di;
    cin >> di;
    d.insert(di);
  }
  cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int used[100010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,x,m;
    cin>>n>>x>>m;
    fill(used,used+m,-1);
    vector<int>v={x};
    used[x]=0;
    while(1){
        int nxt=v.back()*v.back()%m;
        if(used[nxt]!=-1){
            if(used[nxt]<=n){
                int ans=0;
                rep(i,used[nxt])ans+=v[i];
                n-=used[nxt];
                vector<int>a,sum={0};
                for(int i=used[nxt];i<v.size();i++){
                    a.pb(v[i]);
                    sum.pb(sum.back()+a.back());
                }
                cout<<ans+(n/a.size())*sum.back()+sum[n%a.size()]<<endl;
                return 0;
            }
            else{
                int ans=0;
                rep(i,n)ans+=v[i];
                cout<<ans<<endl;
                return 0;
            }
        }
        else{
            v.pb(nxt);
            used[nxt]=v.size()-1;
        }
    }
    return 0;
}


Measured memory_bytes: 5548
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
    
    int pos=-1;
    int n,l;
    cin>>n>>l;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n-1){
        if(v[i]+v[i+1]>=l){
            pos=i;
            break;
        }
    }
    if(pos==-1){
        fin("Impossible");
        return 0;
    }
    pos++;
    cout<<"Possible"<<endl;
    for(int i=1;i<pos;i++){
        fin(i);
    }
    for(int i=n-1;i>pos;i--){
        fin(i);
    }
    cout<<pos<<endl;
}


Measured memory_bytes: 1152
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
def wrong():
	print('No')
	exit()
if c12 - c11 == c22 - c21 == c32 - c31:
	pass
else:wrong()
if c13 - c11 == c23 - c21 == c33 - c31:
	pass
else:wrong()
if c13 - c12 == c23 - c22 == c33 - c32:
	pass
else:wrong()
if c21 - c11 == c22 - c12 == c23 - c13:
	pass
else:wrong()
if c31 - c11 == c32 - c12 == c33 - c13:
	pass
else:wrong()
if c31 - c21 == c32 - c22 == c33 - c23:
	pass
else:wrong()
print('Yes')

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

int main(){
    int n,m;
    cin >> n>>m;
    vector<pair<int,int>> p(m);
    int mx=-1,mn=999999;
    rep(i,m){
        cin >> p[i].first >> p[i].second;
        mx=max(p[i].first,mx);
        mn=min(p[i].second,mn);
    }

    int count = 0;
    rep(i,n){
        if(mx<=i+1 && i+1<=mn) count++;
    }

    cout << count <<endl;


}



Measured memory_bytes: 1024
N = int(input())
LENGTH = 100010
array = [1]*LENGTH
array[0], array[1] = 0, 0
for i in range(320):
    if array[i] == 1:
        cnt = 2
        while i * cnt <= LENGTH - 1:
            array[i*cnt] = 0
            cnt += 1

for i in range(N, LENGTH):
    if array[i] == 1:
        print(i)
        exit()

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function main(lines) {
    const input = lines.split('\n').slice(1)
    const init = Array(11).join(` 0`) + '\n'
    const breakLine = Array(21).join('#') + '\n'

    let output = ''
    for(let i=0; i<4; i++){
        for(let k=0; k<3; k++){
            output += init
        }
        if(i<3){
            output += breakLine
        }
    }

    let outputArray = Array.from(output).map(function(val){return val === '0' ? 0 : val;})

    for(let i=0; i<input.length; i++){
        const inputLines = input[i].split(' ').map(Number)
        const b = inputLines[0]-0
        const f = inputLines[1]-0
        const r = inputLines[2]-0
        const v = inputLines[3]-0
        const changeLine = (b-1) * (21*4) + (f-1)*(10*2+1) + (r*2-1);

        outputArray[changeLine] += v
    }
    console.log(' ' + outputArray.join('').trim())
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 16212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
vector<ll> vec;

void getPrime(int N) {
	for (ll n = 2; n <= N; n++) {
		bool prime = true;
		for (int i = 2; i*i <= n; i++) {
			if (n%i == 0) {
				prime = false;
				break;
			}
		}
		if (prime) vec.push_back(n);
	}
}

int main() {
	int N; cin >> N;
	getPrime(N);

	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	vector<ll> cnt(N);
	fill(cnt.begin(), cnt.end(), 0);
	for (int n = 1; n <= N; n++) {
		ll buf = n;
		for (int i = 0; i < vec.size(); i++) {
			while (buf%vec[i] == 0) {
				cnt[i]++;
				buf /= vec[i];
			}
		}
	}

	ll ans = 1;
	for (int i = 0; i < vec.size(); i++) {
		ans = (ans*(cnt[i] + 1)) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
(*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*)

open System;

let tmp = Console.ReadLine().Split(' ');
let a = int(tmp.[0]);
let b = int(tmp.[1]);
let ans = if (2 * b <= a) then (a - 2 * b) else 0;

Console.WriteLine(ans);

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

int deg[55];

int main( )
{
    int n, m;
    int i, j, a, b;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> a >> b;
        deg[a]++;
        deg[b]++;
    }
    for (i = 1; i <= n; i++) {
        cout << deg[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000;
const ll MOD = 1000000000 + 7;
const int MAX_H = 1000 + 1;
const int MAX_W = 1000 + 1;
ll dp[MAX_H][MAX_W];
char a[MAX_H][MAX_W];

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

  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }

  dp[0][0] = 1;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] == '#') continue;
      
      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: 11996
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

    int ans = 0;
    for(int i = 0; i <= 9; ++i)
    for(int j = 0; j <= 9; ++j)
    for(int z = 0; z <= 9; ++z) {
        bool flag1 = false, flag2 = false, flag3 = false;
        for(int k = 0; k < s.size(); ++k) {
            if(!flag1) {
                if(s[k] - '0' == i) {
                    flag1 = true;
                }
            }else if(!flag2){
                if(s[k] - '0' == j) {
                    flag2 = true;
                }
            }else {
                if(s[k] - '0' == z) {
                    flag3 = true;
                    break;
                }
            }
        }
        if(flag3) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String str = "";

        while(sc.hasNext()) {
        	str += sc.nextLine();
        }
        str = str.toLowerCase();

        char[] alphabet = new char[] {'a','b','c','d','e','f','g','h','i','j','k',
        							  'l','m','n','o','p','q','r','s','t','u','v',
        							  'w','x','y','z'};

        int[] ans = new int[alphabet.length];

        for(int i = 0; i < str.length(); ++i) {
        	for(int j = 0; j < alphabet.length; j++) {
        		if(str.charAt(i) == alphabet[j]) {
        			ans[j]++;
        		}
        	}
        }

        for(int i = 0; i < alphabet.length; i++) {
        	System.out.println(String.format("%s : %d", alphabet[i], ans[i]));
        }

    }
}


Measured memory_bytes: 26456
from collections import Counter

# input
S = list(input())
S = "".join(sorted(S))
T = list(input())
T = "".join(sorted(T))

# check
counter_s = Counter(S).most_common()
counter_t = Counter(T).most_common()

if len(counter_t) != len(counter_s):
    print("No")
elif S == T:
    print("Yes")
else:
    c_match = [True] * len(counter_t)
    for i in range(len(counter_t)):
        co_s = counter_s[i][1]
        co_t = counter_t[i][1]

        if co_s != co_t:
            c_match[i] = False

    if c_match.count(False) == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

set<ll> a, b;

int main()
{
    int n, m;
    cin>>n;
    REP(i,n) {
        ll tmp_a;
        cin>>tmp_a;
        a.insert(tmp_a);
    }
    cin>>m;
    REP(i,m) {
        ll tmp_b;
        cin>>tmp_b;
        b.insert(tmp_b);
    }
    for (auto itr : b) {
        if (a.find(itr) == a.end()) {
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<1<<endl;

    return 0;
}



Measured memory_bytes: 21808
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<lint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
lint mo=1000000007;
map<int,vector<vector<lint> > > me;
vector<vector<lint> > rec(int a){
	if(me[a].size()>0) return me[a];
	vector<vector<lint> > ret(3,vector<lint>(3,0)),mae=rec(a/2),ato=rec(a-a/2);
	rep(i,3) rep(j,3) rep(k,3){
		ret[i][j]+=mae[i][k]*ato[k][j];
		ret[i][j]%=mo;
	}
	return me[a]=ret;
}
vector<lint> cal(vector<lint> a,vector<vector<lint> > b){
	vector<lint> ret(3,0);
	rep(i,3) rep(j,3){
		ret[j]+=a[i]*b[i][j];
		ret[j]%=mo;
	}
	return ret;
}
int x[114514];
int main()
{
	int n,m;
	cin>>n>>m;
	rep(i,m) cin>>x[i+1];
	vector<lint> dp(3,0);dp[0]=1;
	vector<vector<lint> > ze(3,vector<lint>(3,0)),on(3,vector<lint>(3,0)),o2(3,vector<lint>(3,0));
	ze[0][0]=ze[1][1]=ze[2][2]=1;
	on[0][0]=2;on[0][1]=2;on[0][2]=1;on[1][0]=1;on[1][1]=1;on[1][2]=1;on[2][0]=1;on[2][2]=1;
	o2[0][0]=1;o2[0][1]=2;o2[0][2]=1;o2[1][1]=1;o2[1][2]=1;o2[2][2]=1;
	me[0]=ze;me[1]=on;
	rep(i,m){
		dp=cal(dp,rec(x[i+1]-x[i]-1));
		dp=cal(dp,o2);
		//cout<<dp<<endl;
	}
	dp=cal(dp,rec(n-x[m]));
	cout<<dp[2]<<endl;
}


Measured memory_bytes: 8320
A, B = map(int, input().split())


def xor(n):
    m = 0
    if n % 4 == 0:
        m = n
    elif n % 4 == 1:
        m = 1
    elif n % 4 == 2:
        m = n + 1
    return m


p = xor(A-1)
q = xor(B)
print(p ^ q)


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

int main() {
   int N ;
   cin >> N;
  vector<int> a(N);
  for(int i = 0;i<N;i++) cin >> a[i];
  
  int sum = 0;
  int num = 0;
  for(int i =0;i<N;i++){
    if(num < a[i]){
      sum += (a[i]-num);
    }
    num = a[i];
  }
  
    cout << sum <<endl;
  
    
  }
       
   
  
 

   

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char S[10];
  char T[10];
  char U[10];
  int a,b;
  scanf("%s %s",S,T);
  scanf("%d %d",&a,&b);
  scanf("%s",U);
  if(strcmp(S,U)==0)
  {
    a--;
  }
  else if(strcmp(T,U)==0)
  {
    b--;
  }
  printf("%d %d",a,b);
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for (int a = 1; a < n; a++) {
        int b = (n - 1) / a;
        ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, A, B; cin >> N >> A >> B;
	string s; cin >> s;
	int dome = 0, overs = 0;
	string res[N];
	for (int i = 0; i < N; i++)
	{
		if(s[i] == 'c') res[i] = "No";
		else if(s[i] == 'a') {
			if(dome + overs < A + B) {
				res[i] = "Yes";
				dome++;
			}
			else res[i] = "No";
		}
		else if(s[i] == 'b') {
			if(dome + overs < A + B && overs < B) {
				res[i] = "Yes";
				overs++;
			}
			else res[i] = "No";
		}
	}
	
	for (int i = 0; i < N; i++)
	{
		cout << res[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
using namespace std;
#define lp(i,n) for(int i=1;i<=n;i++)
int main(){
    int n;
    while(1){
        cin>>n;
        if(n == 0) break;
        int a=0, count=0;
        string s;
        lp(i,n){
            cin>>s;
            if(s=="lu") a++;
            if(s=="ld") a--;
            if(s=="ru") a++;
            if(s=="rd") a--;
            if(a ==  2 || a == -2) count++;
            if(i % 2 == 0) a=0;
        }
        cout<<count<<endl;
    }
    return 0;
}



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

int main(){
    vector<long long> cnt(6);
    string s;
    int n, x;
    long long ans;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        switch (s[0])
        {
            case 'M':
                x = 0;
                break;
            case 'A':
                x = 1;
                break;
            case 'R':
                x = 2;
                break;
            case 'C':
                x = 3;
                break;
            case 'H':
                x = 4;
                break;
            default:
                x = 5;
                break;
        }
        cnt[x]++;
    }
    ans = 0;
    for(int i=0; i<3; i++){
        for(int j=i+1; j<4; j++){
            for(int k=j+1; k<5; k++){
                ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long

struct vertex
{
    int x, y, v;
};

vector<vertex> vertices;

const int maxN = 200500;
vector<int> e[maxN];
int rDelta[maxN], cDelta[maxN];

int minrd, mincd;

vector<char> used;

bool dfs(int v, bool first = true)
{
    if (first)
        minrd = mincd = 0;

    used[v] = true;

    minrd = min(minrd, rDelta[v]);
    mincd = min(mincd, cDelta[v]);

    for (int u: e[v])
    {
        int rd = rDelta[v], cd = cDelta[v];

        if (vertices[u].x == vertices[v].x)
            rd = rDelta[v] + vertices[u].v - vertices[v].v;
        else
            cd = cDelta[v] + vertices[u].v - vertices[v].v;

        if (!used[u])
        {
            rDelta[u] = rd;
            cDelta[u] = cd;

            if (!dfs(u, false))
                return false;
        }
        else if (rDelta[u] != rd || cDelta[u] != cd)
            return false;
    }

    if (first)
    {
        //printf("minrd %d, mincd %d\n", minrd, mincd);
        if ((-mincd) + (-minrd) > vertices[v].v)
            return false;
    }

    return true;
}

signed main()
{
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif

    int nRows, nColumns, n;
    cin >> nRows >> nColumns >> n;

    nRows++;
    nColumns++;

    vertices.resize(n);

    map<int, vector<int>> xMap, yMap;
    for (int i = 0; i < n; i++)
    {
        cin >> vertices[i].x >> vertices[i].y >> vertices[i].v;

        xMap[vertices[i].x].push_back(i);
        yMap[vertices[i].y].push_back(i);
    }

    for (int t = 0; t < 2; t++)
    {
        map<int, vector<int>>& m = (t == 0) ? xMap : yMap;

        for (auto p: m)
            for (int i = 0; i + 1 < (int)p.second.size(); i++)
            {
                int u = p.second[i];
                int v = p.second[i + 1];

                e[u].push_back(v);
                e[v].push_back(u);
            }
    }

    used.assign(n, false);

    bool fail = false;
    for (int i = 0; i < n; i++)
        if (!used[i])
        {
            if (!dfs(i))
            {
                fail = true;
                break;
            }
        }

    printf("%s\n", fail ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 29312
#include <iostream>
using namespace std;
int main(){
    int v[100];
    v[0]=v[1]=1;
    for(int i=2;i<=44;i++){
        v[i]=v[i-1]+v[i-2];
    }
    int n;
    cin>>n;
    cout<<v[n]<<endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    long n;cin>>n;
    long a[n+1];rep(i,1,n+1)cin>>a[i];
    long fin=1;
    int visited[n+1]={0};
    //visited[1]=1;
    int c=0;
    while(fin!=2 and visited[fin]!=1){
        visited[fin]=1;
        fin=a[fin];
        c++;
    }
    if(fin==2)cout<<c;
    else cout<<-1;


}

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


Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	String S=sc.next();

    	int max=-1;
    	for(int i=0;i<N;i++) {

    		String str1=S.substring(0,i+1);
    		String str2=S.substring(i+1);

    		int buf=getsyurui(str1, str2);

    		if(max<buf) {
    			max=buf;
    		}

    	}

    	System.out.println(max);

    }

    public static int getsyurui(String str1,String str2) {

    	Set<String> set=new TreeSet<String>();

    	for(int i=0;i<str1.length();i++) {
    		set.add(str1.substring(i,i+1));
    	}

    	int counter=0;
    	for(String str:set) {
    		if(str2.contains(str)) {
    			counter++;
    		}
    	}

    	return counter;
    }


}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    rep(i,N) cin >> weight[i] >> value[i];
    
    vector<vector<int>> dp(N+1,vector<int>(W+1));
    dp[0] = vector<int>(W+1,0);
    
    rep(i,N){
        rep(w,W+1){
            int prev = dp[i][w];
            if(w >= weight[i]){
                int newitem = dp[i][w-weight[i]] + value[i];
                dp[i+1][w] = max(prev,newitem);
            }else{
                dp[i+1][w] = prev;
            }
        }
    }
    
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cassert>
#include <map>
#include <bitset>
#include <limits>

using namespace std;

using lint = long long;
using ldouble = long double;

const lint NINF = numeric_limits<lint>::min();

string S;
int itr;

map<char, int> revop = {{'+', 0}, {'-', 1}, {'*', 2}};

bool look[3][3];

lint number() {
    lint ret = 0;
    while (isdigit(S[itr])) {
        (ret *= 10) += S[itr] - '0';
        ++itr;
    }
    return ret;
}

lint expr(int d) {
    lint ret;
    if (d == 3) {
        // 括弧か数をパース
        if (S[itr] == '(') {
            ++itr;
            ret = expr(0);
            assert(S[itr] == ')');
            ++itr;
        } else {
            ret = number();
        }
    } else {
        ret = expr(d + 1);

        while (revop.count(S[itr]) && look[d][revop[S[itr]]]) {
            char op = S[itr];
            ++itr;
            if (op == '+') {
                ret += expr(d + 1);
            } else if (op == '-') {
                ret -= expr(d + 1);
            } else if (op == '*') {
                ret *= expr(d + 1);
            }
        }
    }

    return ret;
}

int main() {
    cin >> S;
    lint ans = NINF;

    int a[3];
    for (a[0] = 0; a[0] < 8; ++a[0]) {
        for (a[1] = 0; a[1] < 8; ++a[1]) {
            if (a[0] & a[1]) continue;
            a[2] = ~(a[0] | a[1]) & 7;

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

            itr = 0;
            ans = max(ans, expr(0));
        }
    }

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



Measured memory_bytes: 3224