akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string aaa = "abcdefghijklmnopqrstuvwxyz";
		string str = Console.ReadLine();
		string str2 = Console.ReadLine();
		long[] A = new long[26];
		long[] B = new long[26];
		string ans = "Yes";
		for(var i=0;i<str.Length;i++){
			if(A[aaa.IndexOf(str.Substring(i,1))] == 0){
				A[aaa.IndexOf(str.Substring(i,1))] = aaa.IndexOf(str2.Substring(i,1))+1;
			} else if(A[aaa.IndexOf(str.Substring(i,1))] != aaa.IndexOf(str2.Substring(i,1))+1){
				ans = "No";
				break;
			}
		}
		if(ans == "Yes"){
			for(var i=0;i<26;i++){
				if(A[i] > 0){
					for(var j=0;j<26;j++){
						if(A[i] == A[j] && i!=j){
							ans = "No";
							break;
						}
					}
				}
				if(ans == "No"){
					break;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 19040
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace Template
{
    public static class Scan
    {
        public static string NextLine => Console.ReadLine();
        public static int NextInt => int.Parse(NextLine);
        public static long NextLong => long.Parse(NextLine);
        public static double NextDouble => double.Parse(NextLine);
 
        public static string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public static long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public static double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }
 
    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }
 
        static void Solve() 
        {            
            var str = Scan.StrAry();
            int A = int.Parse(str[0]), B = int.Parse(str[2]);
            if (str[1][0] == '+')
            {
                Console.WriteLine(A + B);
            }else
            {
                Console.WriteLine(A - B);
            }
        }
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;


int main(void) {
	long long N;
	long long ans;

	scanf("%lld", &N);
	ans = 0;
	for (long long i = 1; i*i < N; i++) {
		if (N%i == 0) {
			if (N / i - 1 > i) {
				ans += (N / i) - 1;
			}
		}
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <typeinfo>
#include <vector> //動的配列

#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;

int main() {
  unsigned int A, B, K;
  cin >> A >> B >> K;
  if (2 * K > B - A) {
    for (int i = A; i < B + 1; i++) {
      cout << i << endl;
    }
  } else {
    for (int i = A; i < A + K; i++) {
      cout << i << endl;
    }
    for (int i = B - K + 1; i < B + 1; i++) {
      cout << i << endl;
    }
  }

  return 0;
}
// return 1するとエラー出るから気をつけよう


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean num[][] = new boolean[4][13];

		for (int i = 0; i < n; i++) {
			String tempSuit = sc.next();
			int tempNum = sc.nextInt();
			if (tempSuit.equals("S")) {
				num[0][tempNum - 1] = true;
			} else if (tempSuit.equals("H")) {
				num[1][tempNum - 1] = true;
			} else if (tempSuit.equals("C")) {
				num[2][tempNum - 1] = true;
			} else if (tempSuit.equals("D")) {
				num[3][tempNum - 1] = true;
			}
		}

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (i == 0 && !num[i][j]) {
					System.out.println("S " + (j + 1));
				} else if (i == 1 && !num[i][j]) {
					System.out.println("H " + (j + 1));
				} else if (i == 2 && !num[i][j]) {
					System.out.println("C " + (j + 1));
				} else if (i == 3 && !num[i][j]) {
					System.out.println("D " + (j + 1));
				}
			}
		}
	}

}

Measured memory_bytes: 26312
i = input().split()

W,H,x,y,r = int(i[0]),int(i[1]),int(i[2]),int(i[3]),int(i[4])

if ((x-r >= 0) and (x+r <= W) and (y-r >= 0) and (y+r <= H)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5600
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    struct Student {
        ll idx;
        ll a;
    };
    vector<Student> students;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        students.push_back(Student{i+1, Ai});
    }
    sort(students.begin(), students.end(), [](Student lhs, Student rhs){ return lhs.a < rhs.a; });
    for (ll i = 0; i < N; i++) {
        cout << students[i].idx;
        if (i < N - 1) {
            cout << " ";
        }
    }
    cout << endl;
}



Measured memory_bytes: 2544
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$q = trim(fgets(STDIN));
$sum = array_sum($a);

foreach($a as $val) {
    @++$cnt_ary[$val];
}

for ($i = 0;$i < $q;++$i) {
    fscanf(STDIN,"%d %d",$b,$c);
    $sum -= $b * @$cnt_ary[$b];
    $sum += $c * @$cnt_ary[$b];
    @$cnt_ary[$c] += $cnt_ary[$b];
    unset($cnt_ary[$b]);
    echo $sum.PHP_EOL;
}

Measured memory_bytes: 26244
#include <cstdio>

int x[4],y[4];
int fie[4][4];
int cnt;

void dfs(int v){
	if(v==8){
		cnt++;
		return;
	}
	for(int j=0;j<4;j++){
		for(int k=0;k<4;k++){
			if(fie[k][j]==0){
				for(int i=0;i<4;i++){
					int ny=j+y[i],nx=k+x[i];
					if(nx>=0 && nx<4 && ny>=0 && ny<4){
						if(fie[nx][ny]==0){
							fie[nx][ny]=1;
							fie[k][j]=1;
							dfs(v+1);
							fie[nx][ny]=0;
							fie[k][j]=0;
						}
					}
				}
				return;
			}
		}
	}
}
int main(void){
	while(1){
		scanf("%d",&x[0]);
		if(x[0]>=5)break;
		scanf("%d",&y[0]);
		for(int i=1;i<4;i++){
			scanf("%d %d",&x[i],&y[i]);
		}
		cnt=0;
		dfs(0);
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1028
//http://logfiles.hatenablog.com/entry/20160520/1463764819
//勉強させて頂いた記事

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse

/*
数え上げの問題
dp[i]はi桁目までの、?の通りだが、可能かどうかがわからない。
なので、[j]を付け足し、1~9の数を識別可能にする？
要旨としてはi桁目までで?入れ替えで作れる数字を記録し、結果的に足してできる数を出力？

A,B,Cのどれなのか区別がつかないため、dp[i][o][j]とした。

A+B=Cの判定法は、最終的にできた、A,B,Cを用いれば良い

ある桁が出来るかどうかは、一通りでは？
つまりdpの中身にはtrue,falseが出来る
dpの中身がt,fの時は大体無駄が多いので、別のものを持たせられないか考える。
例えば、出来た値とか

dpテーブルは通りを格納する。理由は下述の通り。

そもそもdpというのは、ある時点での計算結果を元に次の結果を出すというものである。
そのため、ある計算結果がそれまでの結果に影響を及ぼさないのはどこかを考える
この時、A+B=Cの過程で、下桁から計算していくと結果を確定させながら答えを求めることができる。
末桁が、A+B=Cとすればもとまっていく？
この時考慮しなければいけないのが繰り上がりだが、繰り上がりは別途管理？
繰り上がりは1だけである。

桁DPを用いて行いたい。でもN以下とかではない

粘ったが、場合分けをうまくできずギブ

*/

int main(){
    vector<string> S(3);

    while(cin>>S[0]){
        if(S[0]=="0")break;
        cin>>S[1]>>S[2];

        rep(i,3)reverse(S[i].begin(),S[i].end());//リバースして、反対側から考える。

        int L=S[0].size();

        vector<vector<int> > va(L),vb(L),vc(L);//条件を満たす数を羅列するための配列？
        //記事内でも場合分けに使うとされているのできっとそう
        //場合分けをある桁のときに使うであろう数をA,B,Cごとに配列を用いて管理するという知見を得た。
        //配列を用いて管理することで、面倒な場合分けを縮こめることができる。楽ができる
        string a=S[0],b=S[1],c=S[2];

        rep(i,L){
            if(a[i]=='?')REP(k,i==L-1,10)va[i].pb(k);
            else va[i].pb(a[i]-'0');

            if(b[i]=='?')REP(k,i==L-1,10)vb[i].pb(k);
            else vb[i].pb(b[i]-'0');

            if(c[i]=='?')REP(k,i==L-1,10)vc[i].pb(k);
            else vc[i].pb(c[i]-'0');
        }

        vector<vector<ll> >dp(52,vector<ll>(3,0));
        dp[0][0]=1;

        rep(i,L)rep(carry,2){//carryは繰り上がり考慮
            for(auto& da:va[i])for(auto& db: vb[i])for(auto& dc: vc[i]){
                int num=(da+db+carry)%10;//ありうる数の下桁を取り出している。
                int ncr=(da+db+carry)/10;//桁上がりの数を取り出している。最大値18+1だと思うので、carryは1上限にしても通る気がするが果たして

                if(num==dc){
                    dp[i+1][ncr]+=dp[i][carry];
                    dp[i+1][ncr]%=INF;
                }
            }
        }
        cout<<dp[L][0]<<endl;
    }
    return 0;
}

//a=97,z=122


Measured memory_bytes: 3036
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int compare_base(const void *b, const void *f) {
  return (*(int *)b - *(int *)f);
}

int main(void) {
  int scan; // scanf result
  int *answer; // to output 
  int n; // to input 
  int k; // to input 
  int *d;
  int **ad;
  int count;

  scan = scanf("%d", &n);
  scan = scanf("%d", &k);

  d = (int *)malloc(sizeof(int) * k);
  ad = (int **)malloc(sizeof(int *) * k);
  for (int i = 0; i < k; i++) {
    scan = scanf("%d", &d[i]);
    ad[i] = (int *)malloc(sizeof(int) * d[i]);
    for (int m = 0; m < d[i]; m++) {
      scan = scanf("%d", &ad[i][m]);
    }
  }

  int dsum = 0;
  for (int i = 0; i < k; i++) {
      dsum += d[i];
  }

//  printf("dsum: %d\n", dsum);

  answer = (int *)malloc(sizeof(int) * k * dsum);
  count = 0; 
  for (int y = 0; y < k; y++) {
    for (int x = 0; x < d[y]; x++) {
      answer[count] = ad[y][x];
      count++;
    }
  }
  
  qsort(answer, k * dsum, sizeof(int), compare_base);

//  for (int i = 0; i < k * dsum; i++) {
//    printf("a: %d\n", answer[i]);
//  }

  int answercount = 0;
  for (int i = 0; i < k * dsum; i++) {
    if ((i == 0 || (i >= 1 && answer[i - 1] != answer[i])) && answer[i] != 0) {
      answercount++;
    }
  }

//  printf("answer count: %d\n", answercount); 

  printf("%d", (n - answercount));
  return (0);
}


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

using namespace std;
#define int long long
signed main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());
    int ans = 0;
    if(n%2 == 0){
        ans = arr[0];
        int ch = (n-2)/2;
        for(i=1;i<=ch;i++)
            ans+=2*arr[i];
        cout << ans;
    }
    else
    {
        ans = arr[0];
        int ch = (n-1)/2;
        for(i=1;i<=ch;i++)
            ans+=2*arr[i];
        ans-=arr[ch];
        cout << ans;
    }
}

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

int main() {
	string s, t; cin >> s >> t;

	int cs[26] = {}, ct[26] = {};
	for (int i = 0; i < s.size(); i++) {
		cs[s[i] - 'a']++;
		ct[t[i] - 'a']++;
		if (cs[s[i] - 'a'] != ct[t[i] - 'a']) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 776
n,a = map(int, input().split())
xl = list(map(int, input().split()))

offset = 300
dp = [[0]*600 for _ in range(n+1)]
dp[0][offset] = 1
for i in range(1,n+1):
    x = xl[i-1]-a
    for j in range(-300,300):
        dp[i][offset+j] = dp[i-1][offset+j]
        if 600>offset+j-x>=0:
            dp[i][offset+j] += dp[i-1][offset+j-x]

print(dp[n][offset]-1)

Measured memory_bytes: 39536
import java.util.Scanner;


public class Main {
	static boolean[][] board;
	static int[] xx = {1,0,-1,0};
	static int[] yy = {0,1,0,-1};
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			board = new boolean[12][12];
			for(int j=0; j<12; j++){
				String s = sc.next();
				for(int k=0; k<12; k++){
					if(s.charAt(k)=='1')board[j][k]=false;
					else board[j][k]=true;
				}
			}
			int count=0;
			for(int j=0; j<12; j++){
				for(int k=0; k<12; k++){
					if(!board[j][k]){
						count++;
						dfs(k,j);
					}
				}
			}
			System.out.println(count);
		}
	}
	
	static void dfs(int x, int y){
		if(board[y][x])return;
		else{
			board[y][x]=true;
			for(int i=0; i<4; i++){
				int nextx = x+xx[i];
				int nexty = y+yy[i];
				if(nextx>=0 && nextx<12 && nexty>=0 && nexty<12){
					dfs(nextx,nexty);
				}
			}
		}
	}
}

Measured memory_bytes: 17160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  int ct1 = 0,ct2 = 0;
  while(x >= 500){
    x -= 500;
    ct1++;
  }
  while(x >= 5){
    x -= 5;
    ct2++;
  }
  cout << (ct1 * 1000) + (ct2 * 5) << endl;
  return 0;
}


Measured memory_bytes: 256
//header{{{
//#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    cout << n * (n-1) / 2 + m * (m-1) / 2 << '\n';


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

//-----------------------------------------------

//------------------------------------------------
int main(){
  int a;
  string s;
  cin>>a;
  cin>>s;
  if(a>=3200){
    cout<<s<<endl;
  }
  else{
    cout<<"red"<<endl;
  }
}


Measured memory_bytes: 256
// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========

fn main() {
    input! {
        s: String,
        t: String,
        a: usize,
        b: usize,
        u: String,
    }
    if s == u {
        println!("{} {}", a - 1, b);
    } else if t == u {
        println!("{} {}", a, b - 1);
    } else {
        println!("{} {}", a, b);
    }
}


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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  int ans = 999;
  
  for(int i = 0; i <= N - 3; ++i){
   int num = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
   ans = min(ans, abs(num - 753));
   }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    double a[n+1];
    double dp[n+1][n+1];
    for(int i = 1; i <= n; i++) cin >> a[i];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) dp[0][i] = dp[0][i-1]*(1-a[i]);;
    
    for(int i = 1; i <= n ; i++){
        for(int j = 0; j <= n; j++){
            if(i>j) dp[i][j] = 1;
            else if(i == j) {
                dp[i][j] = dp[i-1][j-1]*a[j];
            } 
            else{
                dp[i][j] = dp[i-1][j-1]*a[j] + dp[i][j-1]*(1-a[j]);
            }
        }
    }

    double ans = 0;
    for(int i = n/2+1; i<=n; i++){
        ans += dp[i][n];
    }
    
    cout << setprecision(10) << ans << endl;
    return 0;
}



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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, ans;

main()
{
	cin >> n;
	forn(1, i, n)
	{
		forn(1, j, n)
		{
			forn(1, k, n)
			{
				ans += __gcd(__gcd(i, j), k);
			}
		}
	}
	cout << ans;
}

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

int main()
{
    string s;
    cin >> s;
    int r = 1, n = 0;
    if (s[0] != 'A')
        r = 0;
    for (int i = 2; i < s.size() - 1; i++)
        if (s[i] == 'C')
            n++;
    if (n != 1)
        r = 0;
    if (r)
    {
        for (int i = 1; i < s.size(); i++)
            if (s[i] != 'C' && (s[i] < 'a' || s[i] > 'z'))
                r = 0;
    }
    cout << (r ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//==============================================================================================


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int r = n % 10;
	if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9  )printf("hon");
	else if (r == 0 || r == 1 || r == 6 || r == 8)printf("pon");
	else printf("bon");
	return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int MAX_N = 200005;
const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP{
    mint dp;
    int t;
    DP(mint dp = 1, int t = 0):dp(dp), t(t){}
    DP& operator+=(const DP& a){
        dp *= a.dp;
        dp *= comb(t+a.t, t);
        t += a.t;
        return *this;
    }
    DP operator-(const DP& a) const{
        DP res(*this);
        res.t -= a.t;
        res.dp /= comb(res.t+a.t, res.t);
        res.dp /= a.dp;
        return res;
    }
    DP addRoot() const{
        DP res(*this);
        res.t++;
        return res;
    }
};

DP dp[MAX_N];

void dfs(int v, int p = -1){
    for(int u : to[v]){
        if(u == p) continue;
        dfs(u, v);
        dp[v] += dp[u].addRoot();
    }
}

void bfs(int v, int p = -1){
    for(int u : to[v]){
        if(u == p) continue;
        DP d = dp[v] - dp[u].addRoot();
        dp[u] += d.addRoot();
        bfs(u, v);
    }
}

// example(abc160_f)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    bfs(0);
    rep(i,n){
        cout << dp[i].addRoot().dp << endl;
    }
    return 0;
}

Measured memory_bytes: 20224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};


int main() {
    ll N,C;
    cin >> N >> C;
    vvl d(C,vl(200005));
    rep(i,N){
        ll s,t,c;
        cin >> s >> t >> c;
        c--;
        s--;
        t--;
        d[c][2*s]++;
        d[c][2*t+1]--;
    }
    vvl s(C,vl(200006,0));
    rep(i,C){
        rep(j,200005){
            s[i][j+1]=s[i][j]+d[i][j];
            if(s[i][j+1]==2){
                s[i][j+1]=1;
                d[i][j+1]++;
            }
        }
    }
    ll ans=0;
    rep(i,200006){
        ll k=0;
        rep(j,C){
            k+=s[j][i];
        }
        ans=max(ans,k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 98624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,m;cin >> n >> m;
    vector<P> stu(n), che(m);
    rep(i,n) cin >> stu[i].first >> stu[i].second;
    rep(i,m) cin >> che[i].first >> che[i].second;

    rep(i,n){
        int ans = INF;
        int num;
        rep(j,m){
            int dis = abs(stu[i].first - che[j].first) + abs(stu[i].second - che[j].second);
            if(ans > dis){
                num = j;
                ans = dis;
            }
        }
        cout << num+1 << endl;
    }

}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    string s, t;
    int i;
    cin >> s;
    cin >> t;
    for(i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            cout << "No";
            break;
        }
    }
    if(i == s.length()){
        cout << "Yes";
    }

    return 0;
}

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

string s = "0123456789AB";
string goal = "0123456789AB0";

vector<vector<int>> adj = {
    {2},
    {2,5},
    {0,1,3,6},
    {2,7},
    {5},
    {1,4,6,9},
    {2,5,7,10},
    {3,6,8,11},
    {7},
    {5,10},
    {6,9,11,12},
    {7,10},
    {10}
};

int solve(string stat) {
    if (stat == goal) return 0;
    map<string, int> dist;
    dist[stat] = 0;
    queue<string> q;
    q.push(stat);
    while ( ! q.empty()) {
        string s = q.front();
        q.pop();
        for (int i=0; i<13; ++i) {
            if (s[i] != '0') continue;
            for (int j : adj[i]) {
                string next = s;
                next[i] = s[j];
                next[j] = s[i];
                int diff = 0;
                for (int k=0; k<13; ++k) {
                    if (next[k] != '0') {
                        diff += next[k] != goal[k];
                    }
                }
                if ( ! diff) {
                    return dist[s] + 1;
                }
                if (dist.find(next) == dist.end()) {
                    dist[next] = dist[s] + 1;
                    if (dist[next] + diff <= 20) {
                        q.push(next);
                    }
                }
            }
        }
    }
    return 21;
}

int main() {
    while (1) {
        string stat = "";
        int k;
        for (int i=0; i<13; ++i) {
            if (cin >> k && !~k) return 0;
            stat += s[k];
        }
        int ans = solve(stat);
        if (ans <= 20) {
            cout << ans << endl;
            continue;
        }
        cout << "NA" << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
 
   string ans = "No";
 
  for (int i = 0; i < 25; i++){
    	 for (int j = 0; j < 25; j++){
              	if (N == 4 * i + 7 * j){
                  ans = "Yes";
                    break;
                }
            }
  }
   cout << ans << endl;
  return 0;
 
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll a,b;
ll dp[65]={};

ll mask(int n){
    ll ret=0;
    rep(i,n){
        ret<<=1;
        ret++;
    }
    return ret;
}

void dfs_b(bool smaller, int n, int m){
    // DEBUG{printf("%d %d %d\n",smaller,n,m);}
    if(n==0)return;
    if(smaller){
        dp[n]+=(1LL<<m-1)%2;
        dfs_b(true, n-1,m);
    }else{
        if(((b>>n-1)&1)==1){
            dp[n]+=((b&mask(n-1))+1)%2;
            dfs_b(false,n-1,0);
            dfs_b(true,n-1,n-1);
        }else{
            dfs_b(false,n-1,0);
        }
    }
    return;
}

void dfs_a(bool smaller, int n, int m){
    if(n==0)return;
    if(smaller){
        dp[n]+=(1LL<<m-1)%2;
        dfs_a(true, n-1,m);
    }else{
        if(((a>>n-1)&1)==1){
            dp[n]+=((a&mask(n-1))+1)%2;
            dfs_a(false,n-1,0);
            dfs_a(true,n-1,n-1);
        }else{
            dfs_a(false,n-1,0);
        }
    }
    return;
}

int main(void) {
    cin >> a >> b;
    a--;
    dfs_b(false,63,0);
    DEBUG{
        cout << dp[3] << dp[2] << dp[1] << endl;
    }
    dfs_a(false,63,0);
    ll res=0;
    DEBUG{
        cout << dp[3] << dp[2] << dp[1] << endl;
    }
    for(int i=63;i>=1;i--){
        res<<=1;
        res += dp[i]%2;
    }
    cout << res << endl;
    return 0;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

bool is_in(const vector<int> &v, int val) {
    return find(v.begin(), v.end(), val) != v.end();
}

bool is_continue(const int * C, int N, int V) {
    REP(i, N) {
        if (C[i] < V) {
            return true;
        }
    }
    return false;
}

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

    int N;
    cin >> N;

    int S[N][N-1];

    REP(i, N) REP(j, N-1) cin >> S[i][j];

    int C[N];
    REP(i, N) C[i] = 0;

    int d = 0;
    while (is_continue(C, N, N - 1)) {
        bool no_game = true;
        bool open[N];
        memset(open, false, sizeof(bool) * N);
        REP(i, N) {
            if (C[i] > N - 2) continue;

            int p = S[i][C[i]] - 1;

            if (open[i] || open[p]) continue;

            if (S[p][C[p]] == i + 1) {
                no_game = false;
                ++C[i];
                ++C[p];
                open[i] = true;
                open[p] = true;
            }
        }

        if (no_game) {
            d = -1;
            break;
        }

        ++d;
    }

    cout << d << endl;
}


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


int main() {

  string s;
  cin>>s;

  string year=s.substr(0,4);
  string month=s.substr(5,2);
  string day=s.substr(8,2);

  if(year<="2019"&&month<="04"&&day<="30")
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;

  return 0;
}



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

int main(){
  int n, m, a[1005], sum=0;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }

  sort(a, a+n);
  // cout << a[n-m] << endl;
  if(a[n-m]*4*m>=sum)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int x;
  cin>>x;
  for(int i=x;i<=x+10000;i++){
    bool ok=true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0){ok=false;}
    }
    if(ok){cout<<i<<endl;return 0;}
  }
  return 0;  
}

Measured memory_bytes: 3648
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
struct angka
{
    long long int time;
    long long int finish;
};
struct angka node[200200];
bool desc(struct angka a, struct angka b)
{
    if(a.finish == b.finish)
        return a.time < b.time;
    return a.finish < b.finish;
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        long long int a,b;
        scanf("%lld %lld",&a,&b);
        node[i].time = a;
        node[i].finish = b;
    }
    sort(node,node+n,desc);
    bool can = 1;
    long long int timeSpent = 0;
    for(i=0;i<n;i++)
    {
        timeSpent += node[i].time;
        if(timeSpent > node[i].finish)
        {
            can = 0;
            break;
        }
    }
    if(can)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main() {
	int  i, n, m=0, x;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x % 2) m++;
	}
	if (m % 2) printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 128
num = input()

num_123 = num[0:3]
num_234 = num[1:4]

num_123_count = num_123.count(num_123[0])
num_234_count = num_234.count(num_234[0])

if num_123_count == 3 or num_234_count == 3:
    print('Yes')
else:
    print('No')


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

int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<vector<int>> next(60,vector<int>(N));
  for(int j=0;j<N;j++){
    cin >> next.at(0).at(j);
    next.at(0).at(j)--;
  }
  for(int i=0;i<59;i++){
    for(int j=0;j<N;j++){
      next.at(i+1).at(j)=next.at(i).at(next.at(i).at(j));
    }
  }
  int j=0;
  for(int i=0;i<60;i++){
    if(K & (1LL<<i)){
      j=next.at(i).at(j);
    }
  }
  cout << j+1 << endl;
} 

Measured memory_bytes: 51052
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n;
    cin >> s;
    int ans=0;
    // cout << s[2] << s[3] << endl;
    rep(i,n){
        int cnt=0;
        string y="";
        bool w=false;
        for(int j=0;j<i+1;j++){
            // cout << y << endl;
            // cout << j << endl;

            for(int k=i+1;k<n;k++){
                // cout <<j<< k << endl;
                if(s[j]==s[k]){
                    for(int m=0;m<y.size();m++){
                        if(s[j]==y[m]){
                            w=true;
                            break;
                        }
                    }
                    if(w){
                        // cout << "Td" << endl;
                        w = false;
                        break;
                    }
                    else{
                        cnt+=1;
                        // cout << i << j << s[j] << endl; 
                        y+=s[j];
                        break;
                    }
                }
            }
        }
        ans=max(ans,cnt);
    }

    cout << ans;


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

string x, y;

const int N = 3005;

int memo[N][N];

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

	cin >> x >> y;

	int n = x.size(), m = y.size();

	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = m - 1; j >= 0; j--)
		{
			// transitions
			// solve(i + 1, j)
			// solve(i, j + 1)
			// 1 + solve(i + 1, j + 1) --> law el 2 zaii ba3d
			memo[i][j] = max(memo[i][j], memo[i + 1][j]);
			memo[i][j] = max(memo[i][j], memo[i][j + 1]);

			if (x[i] == y[j])
				memo[i][j] = 1 + memo[i + 1][j + 1];
		}
	}

	string build = "";

	int i = 0, j = 0;

	while(i < n && j < m)
	{
		if (x[i] == y[j])
		{
			build.push_back(x[i]);
			i++, j++;
		}
		else if (memo[i][j] == memo[i + 1][j])
			i++;
		else
			j++;
	}
	cout << build << endl;

	return 0;
}


Measured memory_bytes: 35456
//this code is created by Neel11
//YEET!
#include<bits/stdc++.h>
using namespace std;

#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long 
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define elif else if
#define flush cout<<endl;
#define mod 1000000007


int main() 
{ 
	long n;
	string s;
	cin>>n>>s;
	vector<char> a,b;

	loop(i,0,n/2)
		a.push_back(s[i]);
	loop(i,n/2,n)
		b.push_back(s[i]);
	if(a==b)
		cout<<"Yes";
	else
		cout<<"No";
	flush;
}


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

int main(){
  
    long long int N,no1=0,no2=0;
    cin>>N;
    map<long long int,int> A;
    for(int i=0;i<N;i++){
        long long int k;cin>>k;
        A[k]++;
        if(A[k]==2){
            if(k>=no1){
                no2=no1;
                no1=k;
            }
            else if(k>no2) no2=k;
            A[k]-=2;
        }
    }
    cout<<no1*no2<<endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    int K;
    cin >> K >> S;
    if(S.size()<=K)
        cout<<S;
    else{
        int sabun = S.size() - K;
        cout<<S.substr(0,K)<<"...";
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, MOD = 1000000007, a, b, c, d, ans;
	cin >> n;
	long long dp[1000][5][5][5];
	memset(dp, 0, sizeof dp);
	dp[1][4][4][0] = 1;
	dp[1][4][4][1] = 1;
	dp[1][4][4][2] = 1;
	dp[1][4][4][3] = 1;

	// 0 - A, 1 - G, 2 - C, 3 - T, 4 - dummy

	for (i = 1; i <= n; i++) {
		for (a = 0; a < 5; a++) {
			for (b = 0; b < 5; b++) 
				for (c = 0; c < 5; c++) {
					for (d = 0; d < 4; d++) {
						if ((b == 0) && (c == 1) && (d == 2)) continue;
						if ((b == 0) && (c == 2) && (d == 1)) continue;
						if ((b == 1) && (c == 0) && (d == 2)) continue;

						if ((a == 0) && (b == 1) && (d == 2)) continue;
						if ((a == 0) && (c == 1) && (d == 2)) continue;

						dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % MOD;
					}
				}
		}
	}

	ans = 0;
	for (a = 0; a < 5; a++) {
		for (b = 0; b < 5; b++)
			for (c = 0; c < 5; c++) ans = (ans + dp[n][a][b][c]) % MOD;
	}

	cout << ans << "\n";



	return 0;
}

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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n; cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	int b[100001] = {};
	rep(i, n){
		b[a[i]] += 1;
	}
	int ans = 0;
	frep(i, 1, 100000){
		ans = max(b[i-1] + b[i] + b[i+1], ans);
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_N (200000L)

int main(int argc, char *argv[]) {
  // read inputs
  char cs[MAX_N + 1];
  scanf("%s", cs);
  const long N = strlen(cs);
  // printf("N = %ld, cs = %s\n", N, cs);

  // solve
  long ans = 0, cnt = 0;
  for (long i = N - 1; i >= 0; i--) {
    if (cs[i] == 'A') {
      ans += cnt;
      // printf("A at i = %ld, cnt = %ld, ans = %ld\n", i, cnt, ans);
    } else if (i - 1 >= 0 && cs[i - 1] == 'B' && cs[i] == 'C') {
      cnt++;
      // printf("BC from i = %ld, cnt = %ld\n", i, cnt);
      i--;  // want to move i by 2 spaces
    } else {
      cnt = 0;
      // printf("something else at i = %ld reset count\n", i);
    }
  }
  printf("%ld\n", ans);

  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  string a;
  
  for(int i=0; i<h; i++){
    string s;
    cin >> s;
    a += s;
  }
  
  for(int i=0; i<a.size(); i++){
    
    if(a.at(i) == '.'){
      int sum = 0;
      if(i%w != 0 && a.at(i-1) == '#' ){
        sum++;
      }
 	  
      if(i%w != (w-1) && a.at(i+1) == '#'){
        sum++;
      }
 
      
      if(i%w != 0 && i>=w && a.at(i-w-1) == '#'){
        sum++;
      }
      if(i>=w && a.at(i-w) == '#' ){
        sum++;
      }
      if(i%w != w-1 && i>=w && a.at(i-w+1) == '#'){
        sum++;
      }
      
      if(i%w != 0 && i<w*(h-1) && a.at(i+w-1) == '#'){
        sum++;
      }
      if(i<w*(h-1) && a.at(i+w) == '#'){
        sum++;
      }
      if(i%w != (w-1) && i<w*(h-1) && a.at(i+w+1) == '#'){
        sum++;
      }
      cout << sum;
    }else{
      cout << "#";
    }
    
    if((i+1)%w == 0){
      cout << endl;
    }
 
  }
  cout << endl;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for _ in range(m):
        a,b=map(int,readline().split())
        G[a].append(b)
        G[b].append(a)

    s=set(G[1])
    ans=False
    while len(s)>0:
        now=s.pop()
        for nex in G[now]:
            if nex==n:
                ans=True
                break

    print("POSSIBLE" if ans else "IMPOSSIBLE")

if __name__=="__main__":
    main()

Measured memory_bytes: 43920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;


int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size();
	if (n%2) {
		cout<<"No";
		return 0;
	}
	bool ok=true;
	for (int i=0; i<n; i++){
		if(i%2) {
			if(s[i]!='i') ok=false;
		} else {
			if (s[i]!='h') ok=false;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e5+5;

int main() {
    int n, m; cin >> n >> m;
    vector<P> q(m);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        q[i].first = b; q[i].second = a;
    }
    int ans = 0;
    vector<bool> check(m,true);
    while (true) {
        bool ok = false;
        rep(i,m) if (check[i]) ok = true;
        if (!ok) break;
        vector<P> x;
        rep(i,m) if (check[i]) x.push_back(q[i]);
        sort(all(x));
        rep(i,m) if (q[i].second <= x[0].first-1) check[i] = false;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2908
#include<stdio.h>
#include<string.h>
#define N 105
#define M 100010
int n,lim;
int weight[N];
long long value[N];
long long dp[M];
void zeroOnePack(int weight,long long value)
{
	for (int i = lim; i >= weight; i--)
		dp[i] = (dp[i - weight] + value > dp[i]) ? dp[i - weight] + value : dp[i];
}
int main()
{
	while (scanf("%d %d", &n, &lim) != EOF)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d %lld", &weight[i], &value[i]);
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i <= n; i++)
			zeroOnePack(weight[i], value[i]);
		printf("%lld\n", dp[lim]);
	}
	return 0;
}

Measured memory_bytes: 896
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        mut relations: [(usize, usize); m],
    }

    let mut union_found = vec![0; n + 1];
    let mut count = vec![1; n + 1];
    for item in relations {
        let (mut x, mut y) = item;
        while union_found[x] != 0 {
            x = union_found[x];
        }
        while union_found[y] != 0 {
            y = union_found[y];
        }
        if x == y {
            continue;
        } else if x < y {
            union_found[y] = x;
            count[x] += count[y];
        } else {
            union_found[x] = y;
            count[y] += count[x];
        }
    }

    let mut max = 0;
    for item in count {
        max = std::cmp::max(max, item);
    }
    println!("{}", max);
}


Measured memory_bytes: 10044