akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int primeNumber(const int n) {
	//上から確認する
	for (int N = n; N >= 1; N--) {

		bool isPrime = true;
		//素数判定 i < sqrt(N)+1
		for (int i = 2; i * i <= N; i++) {
			if (N % i == 0) {
				isPrime = false;
				break;
			}
		}
		//もし素数なら
		if (isPrime) {
			return N;
		}
	}
}


int main() {
	int i, j, k;

	int N, M, K;

	cin >> N;

	if (N % 1000 == 0) {
		cout << 0;
		return 0;
	}
	cout << 1000 - (N % 1000);
	return 0;
}


Measured memory_bytes: 3632
import Control.Monad

makeList n
   |n==1      = [0..9]
   |otherwise = [10^(n-1)..10^n-1]

main = do
   [n,m] <- map read . words <$> getLine
   sc <- replicateM m $ map read . words <$> getLine
   let ans = filter (\x -> if and (map (\y -> x !! (((sc !! y) !! 0)-1) == (toEnum $ 48 + ((sc !! y) !! 1))) [0..m-1]) then True else False) $ map show $ makeList n
   if ans == []
      then putStrLn $ show $ -1
      else putStrLn $ head ans

Measured memory_bytes: 764
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;



int main()
{
    f_io;
    ll n,w;
    cin >> n >> w;
    vector<pair<ll,ll> > arr(n);
    ll total=0;
    foi(0,n)
    {
        cin >> arr[i].first >> arr[i].second;
        total+=arr[i].second;
    }
    vector<ll> dp(total+1,INF);
    dp[0] = 0;
    foi(0,n)
    {
        for(ll j=total+1;j>=0;j--)
        {
            if(j-arr[i].second>=0)
                dp[j] = min(dp[j],dp[j-arr[i].second]+arr[i].first);
        }
    }
    ll res=0;
    foi(0,total+1)
    {
        if(dp[i]<=w)
            res = max(res,i);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;
const int MAX_N = 200001;

int main() {
	string s; cin >> s;
	ll k; cin >> k;
	int e = -1;
	rep(k) { if (s[i] != '1') { e = i; break; } }
	if (e == -1) { cout << 1 << endl; }
	else { cout << s[e] << endl; }
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
a = [list(map(int, input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == -1:
            continue
        ans += c[a[i][j]][1]

print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;

int main(void) {
	int n;
	int count = 0;
	int p = 1;
	int a[100001];
	cin >> n;
	FOR(i, 1, n + 1) {
		cin >> a[i];
	}
	while (count<n+1) {
		p = a[p];
		count++;
		if (p == 2) {
			cout << count << endl;
			break;
		}
	}
	if (count == n + 1) {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
 using namespace std;
 int main()
 {
 long long int s[1000000],str[1000000],i,ct=0,a,b,n;
    cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a;
    cin>>b;
    s[i]=a;
    str[i]=b;
  }
  for(i=0;i<n-2;i++)
  {
    if((s[i]==str[i])&&(s[i+1]==str[i+1])&&(s[i+2]==str[i+2]))
    {
      ct++;
  
    }
  }
  if(ct>=1)
    cout<<"Yes";
  else
    cout<<"No";
}



Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int a[100010]={0};
int b[510][510];
int main()
{
    int i,j,n,k,x;
    x=0;
    cin >> n;
    for(i=1;x<=n;i++)
    {
        x=x+i;
        a[x]=i;
    }
    if(a[n]>0)
    {
        cout << "Yes\n" << a[n]+1 << endl;
        k=0;
        cout << a[n] << " ";
        for(i=0;i<a[n];i++)
        {
            b[0][i]=k+1;
            cout << b[0][i] << " ";
            k++;
        }
        cout << endl;
        for(i=1;i<=a[n];i++)
        {
            int w=0;
            cout << a[n] << " ";
            for(j=0;j<i;j++)
            {
                b[i][j]=b[j][i-1];
                cout << b[i][j] << " ";
                w++;
            }
            for(j=w;j<a[n];j++)
            {
                b[i][j]=k+1;
                cout << b[i][j] << " ";
                k++;
            }
            cout << endl;
        }
    }
    else
        cout << "No\n";
    return 0;
}


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

int main() {
    int ans = INT_MAX;
    string str;
    cin >> str;
    for(char c = 'a'; c <= 'z'; c++) {
        string temp = str;
        int t = 0;
        bool notIn = true;
        while(true) {
            bool flag = true;
            rep(i, temp.length()) if(temp.at(i) != c) flag = false;
            rep(i, temp.length()) if(temp.at(i) == c) notIn = false;
            if(flag || notIn) break;
            string newStr = "";
            rep(i, temp.length() - 1) {
                if(temp.at(i) == c || temp.at(i + 1) == c) newStr += c;
                else newStr += temp.at(i);
            }
            swap(temp, newStr);
            t++;
        }
        if(notIn) continue;
        ans = min(ans, t);
    }
    cout << ans << endl;
}

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 = Integer.parseInt(sc.nextLine());
        String[] an = sc.nextLine().split(" ");

        // 分母の最小公倍数を求める
        long molec = 0L;
        for (String elm : an) {
            int i = Integer.parseInt(elm);

            if (molec == 0L) {
                molec = gcd(i, i);
            } else {
                molec = gcd(i, molec);
            }
        }

        // 分子の計算
        long denom = 0L;
        for (String elm : an) {
            int i = Integer.parseInt(elm);
            long times = molec / i;
            denom += times;
        }

        // 答え
        System.err.println(molec + "/" + denom);
        double ans = (double) molec / (double) denom;
        System.out.println(ans);
    }

    private static long gcd(long a, long b) {
        long tmp;
        long c = a;
        c *= b;
        while ((tmp = a % b) != 0) {
            a = b;
            b = tmp;
        }
        return c / b;
    }

}



Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;


int main() {
	int a[4],N,ans = 0;
	cin >> N;
	
	a[0] = N / 1000;
	a[1] = (N / 100) % 10;
	a[2] = (N / 10) % 10;
	a[3] = N % 10;

	for (int i = 0; i < 2;i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				ans = a[0];
				if (i == 0) {
					ans += a[1];
				}
				else {
					ans -= a[1];
				}
				if (j == 0){
					ans += a[2];
				}
				else {
					ans -= a[2];
				}
				if (k == 0) {
					ans += a[3];
				}
				else {
					ans -= a[3];
				}
				if (ans == 7) {
					cout << a[0];
					if (i == 0) {
						cout << "+";
					}
					else {
						cout << "-";
					}
					cout << a[1];
					if (j == 0) {
						cout << "+";
					}
					else {
						cout << "-";
					}
					cout << a[2];
					if (k == 0) {
						cout << "+";
					}
					else {
						cout << "-";
					}
					cout << a[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}
	
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll N,M,k;
  cin >> N >> M >> k;

  bool ans = false;
  REP(n, N+1){
    REP(m, M+1){
      if(m*N+n*M-2*m*n==k)
        ans = true;
    }
  }

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 207
using namespace std;
int T,n;
long long a[Maxn];
int op[Maxn];
long long r[62];
bool add(long long x)
{
    for (int i=60;i>=0;i--)
        if (x&(1LL<<i))
        {
            if (r[i]) x^=r[i];
            else
            {
                r[i]=x;
                return true;
            }
        }
    return false;
}
void solve()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++)
    {
        char ch=getchar();
        while (ch!='0'&&ch!='1') ch=getchar();
        if (ch=='0') op[i]=0; else op[i]=1;
    }
    memset(r,0,sizeof(r));
    for (int i=n;i;i--)
    {
        if (op[i]==0) add(a[i]);
        else if (op[i]==1&&add(a[i]))
        {
            printf("%d\n",1);
            return;
        }
    }
    printf("%d\n",0);
}
int main()
{
    scanf("%d",&T);
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public string S;

        public void Run()
        {
            S = Console.ReadLine();
            int i = S.Length;
            var C = new List<string>{ "dream", "dreamer", "erase", "eraser"};

            while (i > 0)
            {
                bool flg = false;
                for (int c = 0; c < C.Count; c++)
                {
                    var cs = C[c];
                    if(i >= cs.Length && S.Substring(i - cs.Length, cs.Length) == cs)
                    {
                        flg = true;
                        i -= cs.Length;
                        break;
                    }
                }

                if (!flg)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Console.WriteLine("YES");
        }

    }

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13116
var end = false;

var col_small = new Buffer("#.#.#.#.#.");
var col = new Buffer(300);
for (i = 0; i < 300; i += 10) {
	col_small.copy(col, i, 0);
}
col = col.toString();

require('fs').readFileSync('/dev/stdin', 'ascii').split('\n').forEach(main);
//["2 2", "3 3", "0 0"].forEach(main);

function main(line) {
	if (line === '0 0') {
		end = true;
		return;
	}
	if (end) return;
	var hw = line.split(' ').map(Number);
	var w = hw[1];
	even = col.slice(0, w);
	odd = col.slice(1, w + 1);
	write(hw[0], col.slice(0, w), col.slice(1, w + 1));
	console.log("");
}

function write(h, even, odd) {
	var i;
	for (i = 0; i < h; i++) {
		if (i % 2 === 0) console.log(even);
		else console.log(odd);
	}
}

Measured memory_bytes: 17128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
#define md 1000000007
ll int a,b,i,ans;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> a >> b;
	ll int ar[a];
	for(i=0;i<a;i++){cin>>ar[i];if(ar[i]>=b)ans++;}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/
 
 
bool inside( int x, int y, int &H, int &W ) {
	return ( x >= 1 && y >= 1 && x <= H && y <= W ) ;
} 

const int X[] = { 1, -1, 0, 0 } ;
const int Y[] = { 0, 0, 1, -1 } ;

 
signed main(){
	int H, W ; cin >> H >> W ;
	int sx, sy ; cin >> sx >> sy ;
	int dx, dy ; cin >> dx >> dy ;
	let grid = matrix<char>(H + 1, W + 1 , '.' ) ;
	for( int i = 1 ; i <= H ; i++ ){
		for( int j = 1 ; j <= W ; j++ ) {
			cin >> grid[i][j] ;
		}
	}
	let dist = matrix<int>( H + 1, W + 1, inf ) ;
	dist[sx][sy] = 0 ;
	deque<pair<int,int>> q ;
	q.push_front( {sx, sy} ) ;
	int nx, ny ;
	while( !q.empty() ) {
		let cur = q.front() ;
		q.pop_front() ;
		for( int i = 0 ; i < 4 ; i++ ){
			nx = cur.first + X[i] ;
			ny = cur.second + Y[i] ;
			if( inside( nx, ny, H, W ) && grid[nx][ny] != '#' ){
				if( dist[nx][ny] > dist[cur.first][cur.second] ) {
					q.push_front( { nx, ny } ) ;
					dist[nx][ny] = dist[cur.first][cur.second] ;
				}
			}
		}
		for( int i = -2 ; i <= 2 ; i++ ) {
			for( int j = -2 ; j <= 2 ; j++ ) {
				// may be check for edge case
				nx = cur.first + i ;
				ny = cur.second + j ;
				if( inside( nx, ny, H, W ) && grid[nx][ny] != '#' ){
					if( dist[nx][ny] > dist[cur.first][cur.second] + 1 ){
						dist[nx][ny] = dist[cur.first][cur.second] + 1 ; 
						q.push_back( { nx, ny } ) ;
					}
				}
			}
		}
	}
	if( dist[dx][dy] == inf ) cout << -1 ;
	else cout << dist[dx][dy] ;
	return 0 ;
}
  


Measured memory_bytes: 12548
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

template <class T>
vector<vector<T> > matrixProduct(const vector<vector<T> >& x, const vector<vector<T> >& y)
{
    int a = x.size();
    int b = x[0].size();
    int c = y[0].size();
    vector<vector<T> > z(a, vector<T>(c, 0));
    for(int i=0; i<a; ++i){
        for(int j=0; j<c; ++j){
            for(int k=0; k<b; ++k){
                z[i][j] += x[i][k] * y[k][j];
            }
        }
    }
    return z;
}

template <class T>
vector<vector<T> > matrixPower(const vector<vector<T> >& x, int k)
{
    int n = x.size();
    vector<vector<T> > y(n, vector<T>(n, 0));
    for(int i=0; i<n; ++i)
        y[i][i] = 1;

    vector<vector<T> > z = x;
    while(k > 0){
        if(k & 1)
            y = matrixProduct(y, z);
        z = matrixProduct(z, z);
        k >>= 1;
    }
    return y;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;
        char s, t, b;
        cin >> s >> t >> b;

        vector<vector<double> > mat(9, vector<double>(9, 0.0));
        for(int i=0; i<9; ++i){
            if(i > 2 && i-3 != b-'A'){
                mat[i][i-3] = 0.25;
            }else{
                mat[i][i] += 0.25;
            }
            if(i < 6 && i+3 != b-'A'){
                mat[i][i+3] = 0.25;
            }else{
                mat[i][i] += 0.25;
            }
            if(i % 3 != 0 && i-1 != b-'A'){
                mat[i][i-1] = 0.25;
            }else{
                mat[i][i] += 0.25;
            }
            if(i % 3 != 2 && i+1 != b-'A'){
                mat[i][i+1] = 0.25;
            }else{
                mat[i][i] += 0.25;
            }
        }

        mat = matrixPower(mat, n);
        printf("%.10f\n", mat[s-'A'][t-'A']);
    }
}

Measured memory_bytes: 732
const assert = require("assert");

const isPrime = n => {
  if (n < 2) {
    return false;
  }
  if (n == 2) {
    return true;
  }
  if (n % 2 === 0) {
    return false;
  }
  m = parseInt(Math.sqrt(n), 10);
  for (let i = 3; i <= m; i += 2) {
    if (n % i === 0) {
      return false;
    }
  }

  return true;
};

const countPrime = numbers => {
  let counter = 0;
  numbers.forEach(n => {
    if (isPrime(n)) {
      counter = counter += 1;
    }
  });
  console.log(counter);
  return counter;
};

process.stdin.resume();
process.stdin.setEncoding("utf8");
let input_string = "";

process.stdin.on("data", chunk => {
  input_string += chunk;
});

process.stdin.on("end", () => {
  const lines = input_string.split("\n").filter(v => {
    return v !== "";
  });
  // console.log(lines);
  countPrime(lines);
});



Measured memory_bytes: 18344
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int cnt = 0;
	for(int i = 0; i < 3; i++){
		char c = cin.get();
		if(c == 'o') cnt++;
	}
	cout << 700 + cnt * 100 << "\n";
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MAX_N = 500;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct UnionFind{
    int N;
    int par[MAX_N];

    UnionFind(int N): N(N){
        for (int i=0;i<N;i++){
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        int rx = root(par[x]);
        par[x] = rx;
        return rx;
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

    bool find(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> a(M), b(M);
	REP(i, M) cin >> a[i] >> b[i];

	ll res = 0;
	REP(i, M){
		UnionFind uf(N);
		REP(j, M){
			if(j==i) continue;
			uf.unite(a[j]-1, b[j]-1);
		}
		bool flag = false;
        /*
        REP(j, N){
            cout << uf.root(j) << " ";
        }
        cout << endl;
        */
        ll tmp = uf.root(0);
		REP(j, N){
			if(tmp!=uf.root(j)) flag = true;
		}
		res += flag;
	}
	cout << res << endl;
    return 0;
}

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

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

    int n;
    cin >> n;

    vector<int> A(201, 1);
    A[0] = A[1] = 0;

    for(int i = 2; i <= 200; i++){
        if(A[i]){
            for(int j = i + i; j <= 200; j += i){
                A[j] = 0;
            }
        }
    }

    int ans = 0;
    for(int i = 3; i <= n; i += 2){
        int t = 1, t_i = i;
        for(int j = 2; j <= int(sqrt(i)); j++){
            if(A[j] and !(t_i % j)){
                int cnt = 0;
                while(true){
                    t_i /= j;
                    cnt++;
                    if(t_i % j) break;
                }
                t *= (cnt + 1);
                if(t_i == 1) break;
            }
        }
        if(t == 8){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

long long h, w, dp[1010][1010], mod = 1e9 + 7;
char a[1010][1010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(dp, 0, sizeof(dp));
	cin >> h >> w;
	for(long long i = 1; i <= h; i++) {
		for(long long j = 1; j <= w; j++) {
			cin >> a[i][j];
		}
	}
	for(long long i = 1; i <= h; i++) {
		if(a[i][1] == '.') {
			dp[i][1] = 1;
		}
		else {
			break;
		}
	}
	for(long long j = 1; j <= w; j++) {
		if(a[1][j] == '.') {
			dp[1][j] = 1;
		}
		else {
			break;
		}
	}
	for(long long i = 2; i <= h; i++) {
		for(long long j = 2; j <= w; j++) {
			if(a[i][j] == '.') {
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
				dp[i][j] = dp[i][j] % mod;
			}
		}
	}
	cout << dp[h][w] << endl;
}



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

#define int long long
#define Rap(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pb push_back
#define F first
#define S second
#define Pr(n) cout<<(n)<<endl
#define Pr2(a,b) cout<<(a)<<'\t'<<(b)<<endl
#define vector2(type,a) vector<vector<(type)> > (a)
#define ALL(a) (a).begin(),(a).end()
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define intcin(n) int (n); cin>>(n);

signed main() {
  intcin(n);
  intcin(k);
  vector<pair<int,int> > a(n);
  Rap(i,n){
    cin >> a.at(i).F >> a.at(i).S;
  }
  sort(ALL(a));
int c = 0;
Rap(i, n) {
  c += a[i].S;
  if (c >= k) {
    Pr(a[i].F);
    break;
  }
}
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,y;
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> y;
	for(int i = 0; i <= n; i++)
		for(int j = 0; i + j <= n; j++) {
			int k = y / 1000 - 10 * i - 5 * j;
			if(i + j + k == n) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	cout << "-1 -1 -1\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <array>
#include <string>
#include <map>
#include <cmath>
//#include <iomainp>
using namespace std;

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


int main()
{
    string S,T;
    cin >> S >> T;
    cout << T+S << endl;
    return 0;
}



Measured memory_bytes: 256
program agc018
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,g
    integer(int32), allocatable:: a(:)
    integer(int32):: k

    read*, n,k
    allocate(a(n))
    read*, a(:)
    if (maxval(a) < k) then
        print'(a)', 'IMPOSSIBLE'
        stop
    end if

    g = a(1)

    do i=2,n
        g = gcd(g,a(i))
    end do
    if (mod(k,g) == 0) then
        print'(a)', 'POSSIBLE'
    else
        print'(a)', 'IMPOSSIBLE'
    end if
contains
function lcm(x,y) result(ret)
    integer(int32):: x,y,ret
    ret=x*y/gcd(x,y)
end function

recursive function gcd(x,y) result(ret)
    integer(int32):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        return
    end if

    ret = gcd(y,mod(x,y))
end function
end program agc018

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, s, n) for(int i=s; i<n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

int main(){
    int N; cin >> N;
    int a[N];
    int cnt = 0;
    REP(i, N){
        cin >> a[i];
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	char s[110];
	scanf("%d%s", &N, &s);
	int i = 0, r = 0, b = 0;
	while (s[i] != '\0') {
		if (s[i] == 'R') {
			r++;
		}
		else if (s[i] == 'B') {
			b++;
		}
		i++;
	}
	if (r > b) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
import * as fs from 'fs';

// parameter "input" gets all data
function Main(input: string) {
    const r = parseInt(input);
    // const c = 2 * Math.PI * r;
    const c = 6283 * r;

    //output
    console.log(c / 1000);
}

// Don't edit this line!
Main(fs.readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29632
local n, k, q = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n do t[i] = 0 end
for i = 1, q do
  local a = io.read("*n")
  t[a] = t[a] + 1
end
for i = 1, n do
  if 0 < k - (q - t[i]) then
    print("Yes")
  else
    print("No")
  end
end


Measured memory_bytes: 2808
def decide_turn(card) :
	return card.upper()

# きたない。。。
A = list(reversed(list(input())))
B = list(reversed(list(input())))
C = list(reversed(list(input())))

turn = "A"
while True:
	card = ""
	if (turn == "A") :
		if (len(A) == 0) :
			print("A")
			break
		card = A.pop()
		turn = decide_turn(card)
	elif (turn == "B") :
		if (len(B) == 0) :
			print("B")
			break
		card = B.pop()
		turn = decide_turn(card)
	else :
		if (len(C) == 0) :
			print("C")
			break
		card = C.pop()
		turn = decide_turn(card)


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    string ans = "No";

    if(s.length() % 2 != 0){
        cout << ans << endl;
        return 0;
    }
    
    for(int j =0 ;j < n/2;j++){
        if(s[j] != s[j+n/2]){
            ans = "No";
            break;
        }else{
            ans = "Yes";
        }
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;


/**
 *
 * @author
 *
 *
 *
 */

public class Main {

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        int n = scanner.nextInt();
        int a = 0;
        int b = 0;

        if ( n % 2 == 0 ) {
            a = n/2;
            b = n/2;
        } else {
            a = n/2 + 1;
            b = n/2;
        }

        out.println(a * b);

        scanner.reader.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data  = nextStringArray();
            int[] a  = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data  = nextStringArray();
            Integer[] a  = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data  = nextStringArray();
            long[] a  = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}



Measured memory_bytes: 21204
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
using namespace std;

int main() {
	int m, n;
	map<string, int> mp;
	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		mp[s]++;
	}
	cin >> m;

	for (int i = 0; i < m; i++) {
		cin >> s;
		mp[s]--;
	}
	int mx = 0;
	for (auto mm : mp) {
		if (mx < mm.second) {
			mx = mm.second;
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#define N 10000

using namespace std;

vector<int> MakePrimeNumber(void);

int main(){
  int i, j, n, count, sum;
  vector<int> data;

  data = MakePrimeNumber();

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0, count=0; data[i]<=n && i<data.size(); ++i){
      for(j=i, sum=0; j<data.size(); ++j){
	sum += data[j];
	if(sum == n){
	  ++count;
	  break;
	}else if(sum > n){
	  break;
	}
      }
    }

    cout << count << endl;
  }
  return 0;
}

vector<int> MakePrimeNumber(void){
  int i, j, k;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, k=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
        k = 1;
        break;
      }
    }
    if(k == 0) data.push_back(i);
  }
  return data;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define sp cout<< " ";
#define rep(i, a, b) for(int i=a; i< b; i++)


using namespace std;
int main()
{
    int l;
    string n;
    cin>> n;
    l=n.size();
    rep(i, 0, l)
    {
        if(n[i]=='7')
        {
            cout<<"Yes";
            nl;
            return 0;
        }
    }

    cout<<"No";
            nl;
    return 0;
}


Measured memory_bytes: 3624
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n;cin>>n;
  int a[n]; rep(i, n) {cin>>a[i];}

  int res = INF;
  rep(i, n){
    int c=0;
    int m=2;
    while (1){
      if (a[i]%m==0){
        a[i]/=2;
        c++;
      }
      else{
        break;
      }
    }
    dump(c);
    chmin(res, c);
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int i = 0;
  
  while (A > 0 && C > 0){
    if(i % 2 == 0){
      C -= B;
      i++;
    } else {
      A -= D;
      i++;
    } 
  }
  
  if(A <= 0){
    cout << "No" << endl;
  } else if (C <= 0) {
    cout << "Yes" << endl;
  } 
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        sc.close();

        int ans1 = 0;
        int ans2 = 0;
        if (A + B - C * 2 <= 0) {
            ans1 = A * X + B * Y;
            ans2 = C * (X + Y);
        } else if (X < Y) {
            ans1 = C * X * 2 + B * (Y - X);
            ans2 = C * Y * 2;
        } else {
            ans1 = C * Y * 2 + A * (X - Y);
            ans2 = C * X * 2;
        }

        System.out.println(Math.min(ans1, ans2));
    }
}


Measured memory_bytes: 25172
n, k = map(int, input().split())
A = [int(i) for i in input().split()]

ans = 10 ** 9
for i in range(n - k + 1):
    L = A[i]
    R = A[i + k - 1]
    r1 = abs(L) - L + R
    r2 = abs(R) - L + R
    temp = min(r1, r2)
    ans = min(ans, temp)
    
print(ans)

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double

using namespace std;

int n, m, k;

int main(){
  scanf("%d %d %d", &n, &m, &k);
  FI(i, 0, n) FI(j, 0, m){
    if (i * (m - j) + j * (n - i) == k){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a, b, d, r;
  double f;

  scanf("%d %d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  printf("%d %d %lf\n",d,r,f);

  return 0;
}

  

Measured memory_bytes: 636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) {
		int t = i, sum = 0;
		while (t > 0) {
			sum += t % 10;
			t /= 10;
		}
		if (a <= sum && sum <= b)
			ans += i;
	}
	cout << ans << endl;

	return 0;
}

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

int main(void){
    std::string s;
    std::cin >> s ;
    int counter = 0;
    if(s[0]=='1') counter++;
    if(s[1]=='1') counter++;
    if(s[2]=='1') counter++;
    std::cout << counter << std::endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  char s[202];
  int len, i, j;
  scanf("%s", s);

  len = strlen(s);   
  if(strlen(s) == 2){
    printf("1\n");
    return 0;
  }
  while(1){
    len -= 2;
    j = len/2;
    for(i = 0; i < len/2; i++){
      if(s[i] != s[j]) break;
      if(i == len/2-1){
	printf("%d\n", len);
	return 0;
      }
      j++;
    }
  }
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()


int__ main() {
	fast;
	int n; cin >> n;
	string s; cin >> s;
	string chars = "RGB";
	int ans = 0;
	for(int j=1;j<n-1;j++){
		map<char,int> cnt;

		for(int i=j+1;i<n;i++) cnt[s[i]]++;

		for(int i=j-1,k=1;i>=0;i--,k++){
			
			for(char x:chars){
				if(s[i]!=x and s[j]!=x and s[i]!=s[j]){
					int c=cnt[x];
					if(j+k < n and s[j+k]==x) c--;
					if(c>0) ans += c;
				}
			}
			
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3656
x1, y1, x2, y2 = map(int, input().split())
x = x2
y = y2
dx = x2 - x1
dy = y2 - y1

ans = []
for _ in range(2):
    dx, dy = dy, dx
    dx *= (-1)
    x += dx
    y += dy
    ans.append(x)
    ans.append(y)
print(*ans)

Measured memory_bytes: 3064
S = input()[::-1]
L = len(S)

mod = [0] * (L+1)
mod[0] = 1
for i in range(1, L+1):
  mod[i] = (mod[i-1] * 10) % 13
MOD = 10 ** 9 + 7

dp = [[0]*13 for i in range(L)]
flag = True

if S[0] == '?':
  for i in range(10):
    dp[0][i] = 1
else:
  dp[0][int(S[0])] = 1

for i in range(1, L):
  if S[i] == '?':
    for j in range(10):
      m = (j * mod[i]) % 13
      for k in range(13):
          dp[i][(m+k)%13] += dp[i-1][k]      
  else:
    m = (int(S[i]) * mod[i]) % 13
    for k in range(13):
       dp[i][(m+k)%13] = dp[i-1][k]
        
  for j in range(13):
    dp[i][j] = dp[i][j] % MOD

print(dp[-1][5])

Measured memory_bytes: 62812
#include <bits/stdc++.h>
using namespace std;
long long int a[100050];
long long int YPO(long long int a,long long int b)
{
    long long int i,sum=1;
    for(i=0;i<b;i++)
    {
        sum=(sum*a)%998244353;
    }
    return sum;
}
int main()
{
    long long int n;
    long long int i,k=0,h=1,y;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    if(a[0]!=0)
    {
        printf("0\n");
        return 0;
    }
    sort(a,&a[n]);
    long long int sum=1;
    for(i=1;i<n;i++)
    {
        if(i==1)
        {
            if(k+1!=a[i])
            {
                printf("0\n");
                return 0;
            }
            k=a[i];
            y=1;
        }
        else
        if(k!=a[i])
        {
            sum=(sum*YPO(h,y))%998244353;
            h=y;
            if(k+1!=a[i])
            {
                printf("0\n");
                return 0;
            }
            k=a[i];
            y=1;
        }
        else
        {
            y++;
        }
    }
    sum=(sum*YPO(h,y))%998244353;
    printf("%lld\n",sum);
    return 0;
}


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

int main() {
    int n = 0, y = 0;
    cin >> n >> y;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (n - i - j >= 0 && 10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                cout << i << " " << j << " " <<  n - i - j << endl;
                return 0;
            } 
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
# ==================== gcd   最大公約数
from fractions import gcd

# ==================== gcd   最小公倍数
def lcm(a, b):
    return  a//gcd(a, b) * b


n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
             
if n==1:
    print(t[0])
else:
    tlcm=t[0]
    for i in range(1,n):
        tlcm=lcm(tlcm,t[i])
    print(tlcm)
    

Measured memory_bytes: 5340
def main():
    N = int(input())
    C = [0,0,0,0]
    for _ in range(N):
        S = input()
        if S == 'AC':
            C[0] += 1
        elif S == 'WA':
            C[1] += 1
        elif S == 'TLE':
            C[2] += 1
        else:
            C[3] += 1
    print('AC x ' + str(C[0]))
    print('WA x ' + str(C[1]))
    print('TLE x ' + str(C[2]))
    print('RE x ' + str(C[3]))

if __name__ == "__main__":
    main()

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI v(n);
	rep(i, n) cin >>v[i];
	
	vector<VL> dp(k+3, VL(3, -MD));
	dp[0][0] = 0;
	
	rep(i, n){
		vector<VL> np(k+3, VL(3, -MD));
		rep(j, k+1){
			amax(np[j+1][0], dp[j][0]+v[i]);
			amax(np[j+2][0], dp[j][0]);
			amax(np[j][1], dp[j][0]);
			amax(np[j][2], dp[j][0]);
			amax(np[j][1], dp[j][1]);
			amax(np[j+1][2], dp[j][1]+v[i]);
			amax(np[j+1][2], dp[j][2]+v[i]);
			amax(np[j+2][2], dp[j][2]);
		}
		swap(dp, np);
	}
	ll ans =0;
	rep(i, k+1) rep(j, 3) ans = max(ans, dp[i][j]);
	cout << ans <<"\n";
	return 0;
}


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

void solve() {
  int N;
  long long ans;
  
  cin >> N;
  
  long long L[N+1];
  
  L[0] = 2;
  L[1] = 1;
  
  for (int i=2; i<=N; i++){
    L[i] = L[i-2] + L[i-1];
  }
  
  ans = L[N];
  
  cout << ans <<"\n";

}

signed main() {
    

    solve();

    return 0;
}



Measured memory_bytes: 256
#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;
typedef pair<ll, int> LP;
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; }

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

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

set <int> s;
int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, x; cin >> n >> x;
    if(x == 1 || x == 2*n-1){cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    if(x == 2*n-2){
        for(int i = 1;i <= n-1;i++)cout << i << endl;
        cout << x << endl; cout << x+1 << endl;
        for(int i = n;i <= x-1;i++)cout << i << endl;
    }else{
        int c = 0; int d = 0;
        while(true){
            c++;
            if(c == x-1)c += 4;
            d++; cout << c << endl; if(d == n-2)break;
        }
        cout << x+1 << endl; cout << x << endl; cout << x-1 << endl; cout << x+2 << endl;
        if(n == 3)return 0;
        c = 2*n;
        while(true){
            c--;
            if(c == x+2)c -= 4;
            d++; cout << c << endl; if(d == 2*n-5)break;
        }
    }
 	return 0;
}


Measured memory_bytes: 1536
using System;


    public class MatrixVectorMultiplication
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            int[,] vector = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < m; j++) { vector[i, j] = int.Parse(input[j]); }
            }

            // 計算
            int[] answer = new int[n];
            for (int i = 0; i < m; i++)
            {
                int var = int.Parse(Console.ReadLine());
                for (int j = 0; j < n; j++) { answer[j] += vector[j, i] * var; }
            }

            // 出力
            for (int i = 0; i < n; i++) { Console.WriteLine(answer[i]); }
        }
    }



Measured memory_bytes: 17928