akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int i = 1; i < S.length(); i++) {
    if (S[i] == S[i-1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


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

int main(){
	int N, K; cin >> N >> K;
	string S; cin >> S;


	char s = S[0];
	int cnt = 0, ans = 0;
	int add = 0;
	for(int i=1; i<S.size(); ++i){
		if(s != S[i]){
			s = S[i];
			if(K>0){
				++ans;
				++cnt;
				if(cnt % 2 == 0) {
					cnt = 0;
					--K;
				}
			}
		}else ++add;
	}
	
	ans += add;
	cout << ans << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();
            var a = ReadLongArray();

            Array.Sort(a);

            long ans = 0;
            for (int i = 3 * n - 1; i > n; i -= 2) {
                ans += a[i - 1];
            }

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 39756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	string s[]={
		"","Man","Oku","Cho","Kei",
		"Gai","Jo","Jou","Ko","Kan",
		"Sei","Sai","Gok","Ggs","Asg",
		"Nyt","Fks","Mts"
	};
	int n,m;
	while(cin>>n>>m,n+m){
		ll out[100]={0};
		out[99]=1;
		while(m--){
			ll tmp=0;
			for(int j=99;j>=1;j--){
				out[j]=out[j]*n+tmp;
				tmp=out[j]/(int)1e4;
				out[j]%=(int)1e4;
			}
		}
		bool h=false;
		rep(i,100){
			if(out[i]){
				cout<<out[i];
				h=true;		
				cout<<s[99-i];
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1204
/*
 * The idea is to simulate the proccess, the data structure needed is Treap for its log n
 * properties, and then it's a matter of "Optimization"
 */

#include <bits/stdc++.h>
#include <complex>

using namespace std;
typedef long long int ll;

const double PI = acos(-1);
const int N = 7e2 + 10, MOD = 1e9 + 7, LOG = 21;

int dp[N][N], n, res, m, fr, to, c[N], cs[N], sz, cmp[N], in[N];
bool mtrx[N][N], vis[N];
vector<vector<int> > g(N), org(N);
vector<int> items;

int DFS(int u, int p, int clr, int comp) {
	cmp[u] = comp;
	vis[u] = true;
	c[u] = clr;
	sz++;
	int cur = clr;
	for (int i = 0; i < g[u].size(); i++) {
		if (!vis[g[u][i]]) {
			cur += DFS(g[u][i], u, !clr, comp);
		} else {
			if (clr == c[g[u][i]] && p != g[u][i]) {
				printf("-1");
				exit(0);
			}
		}
	}
	return cur;
}

int calc(int ind, int sum1) {
	if (ind == items.size())
		return 0;
	int &ret = dp[ind][sum1];
	if (ret != -1)
		return ret;
	int prevNodes = cs[ind];
	int prev1 = sum1;
	int prev0 = prevNodes - prev1;
	int oneCnt1 = items[ind];
	int zeroCnt1 = cs[ind + 1] - cs[ind] - items[ind];
	int oneCnt2 = zeroCnt1;
	int zeroCnt2 = oneCnt1;

	return ret = (in[ind + 1] / 2)
			+ max(
					zeroCnt1 * prev1 + oneCnt1 * prev0
							+ calc(ind + 1, oneCnt1 + sum1),
					zeroCnt2 * prev1 + oneCnt2 * prev0
							+ calc(ind + 1, oneCnt2 + sum1));
}

int main() {
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &fr, &to);
		fr--, to--;
		mtrx[fr][to] = mtrx[to][fr] = true;
		org[fr].push_back(to);
		org[to].push_back(fr);
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			if (!mtrx[i][j] && i != j)
				g[i].push_back(j);
		}
	int ind = 1;
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			res = 0;
			sz = 0;
			items.push_back(DFS(i, -1, 0, ind));
			cs[ind] = cs[ind - 1] + sz;
			ind++;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < org[i].size(); j++) {
			if (cmp[i] == cmp[org[i][j]])
				in[cmp[i]] += (c[org[i][j]] != c[i]);
		}
	}
	cout << m - calc(0, 0);
	return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (1000000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int c[101];
priority_queue<pi> S;
int main()
{
//	freopen("B.in","r",stdin);
//	freopen(".out","w",stdout);
	int k=read(),t=read();
	For(i,t) c[i]=read();
	For(i,t) S.push(mp(c[i],i));
	
	int las=0,ans=0;
	while(k--) {
		pi p=S.top();S.pop();
		if (!S.empty()&&p.se==las) {
			pi p2=S.top();S.pop();
			S.push(p);
			p=p2;
		}
		if (p.se==las) ++ans;
		las=p.se;
		p.fi--;	
		if (p.fi) S.push(p);
	}
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;
#define ll long long
const int N = 15 + 5;
int n ,m, x;
int skill[N], a[N][N], c[N], ans = 1e9;
void solve(int idx, int cost) {
    if (idx == n) {
        bool bo = 1;
        for(int i = 0 ; i < m ; i++) if (skill[i] < x) bo = 0;
        if (bo) ans = min(ans, cost);
        return;
    }
    for(int i = 0 ; i < m ; i++) {
        skill[i] += a[idx][i];
    }
    solve(idx + 1, cost + c[idx]);
    for(int i = 0 ; i < m ; i++) {
        skill[i] -= a[idx][i];
    }
    solve(idx + 1, cost);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> x;
    for(int i = 0 ; i < n ; i++) {
        cin >> c[i];
        for(int j = 0 ; j < m ; j++) {
            cin >> a[i][j];
        }
    }
    solve(0, 0);
    if (ans == 1e9) cout << -1;
    else cout << ans;
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


const int INF = 1 << 30;

int W, H, N;
vector<P> xy;
int main() {
	cin >> W >> H >> N;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		xy.emplace_back(x, y);
	}
	xy.emplace_back(0, 0);
	sort(xy.begin(), xy.end());

	int ans = INF;
	int mxy = 0;
	for (int i = xy.size() - 1; i >= 0; i--) {
		ans = min(ans, xy[i].first + mxy);
		mxy = max(mxy, xy[i].second);
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3784
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		int x = sc.nextInt();
		int a = sc.nextInt();

			System.out.println(x<a?0:10);

 
	}
}


Measured memory_bytes: 21844
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e6;
string S;
int ar[26 + 10];

int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len;

	cin >> S;
	len = S.length();

	for(I = 0; I < len; I++)
		ar[S[I] - 'a']++;


	for(I = 0; I < 26; I++)
	{
		if(ar[I] == 0)
		{
			cout << char(I + 'a');
			return 0;
		}
	}


	cout << "None\n";


	return 0;
}






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

int main()
{
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    vector<int> ban;
    vector<int> sw;
    ban.push_back(0);
    rep(i, n - 2)
    {
        if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
        {
            sw.push_back(i + 1);
        }
    }
    rep(i, n - 1)
    {
        if (s[i] == '#' && s[i + 1] == '#')
        {
            ban.push_back(i + 1);
            ban.push_back(i + 2);
        }
    }
    ban.push_back(1000000);
    int ar = *lower_bound(ban.begin(), ban.end(), a);
    int br = *lower_bound(ban.begin(), ban.end(), b);
    bool fl = true;
    if (d >= br)
    {
        fl = false;
    }
    if (c >= ar)
    {
        fl = false;
    }
    if (d < c && fl)
    {
        rep(i, sw.size())
        {
            if (sw[i] +2<= max(a, b) || sw[i] >= min(c, d))
                continue;
            cout << "Yes" << endl;
            return 0;
        }
        fl = false;
    }
    if (fl)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> d(N);
  for (int i = 0; i < N; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = 0;
  int len = 0;
  for (int i = 0; i < N; i++) {
    if (len >= d[i]) continue;
    len = d[i];
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

    vector<int> d(N);
    for (int i = 0; i < N; i++)
        cin >> d[i];

    sort(d.begin(), d.end());

    cout << d[N / 2] - d[N / 2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    long long a,b,c,d,n;
    scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&n);
    a *= 4LL;
    b *= 2LL;
    c = min({a,b,c});
    if(c*2LL < d) printf("%lld", c*n);
    else printf("%lld\n", d*(n/2LL) + c*(n%2LL));
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！
		// APPROVED
		// DENIED

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		String re = "APPROVED";

		int chk = 0;
		for (int i = 0; i < n; i++) {
			chk = sc.nextInt();
			if (chk % 2 == 0) {
				if (chk % 3 == 0 || chk % 5 == 0) {
					// no action
				} else {
					re = "DENIED";
				}
			}
		}

		System.out.println(re);
	}

}

Measured memory_bytes: 21972
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(std::string T) {
  REP(i, T.size()) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  cout << T << endl;
}

int main() {
  std::string T;
  std::cin >> T;
  solve(T);
  return 0;
}


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

int main()
{
    int coun=0,n,N;
    string S;
    cin>>N>>S;
    n=S.find("ABC");
    for(;n!=-1;n=S.find("ABC")){
        coun+=1;
        S[n]='v';
    }
    cout<<coun;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(0);
	int N;
	bool ans=false;
	int a[100005];

	cin >> N;
	rep(i,N) cin >> a[i];

	int mx=0, mn=INF;
	rep(i,N){
		chmax( mx, a[i] );
		chmin( mn, a[i] );
	}
	if( mx - mn > 1 ) ans = false;

	if( mx-mn == 1 ){
		int cnt = 0;
		rep(i,N) if( a[i] == mn ) cnt++;
		int mcnt = N - cnt;
		if( cnt <= mn && mcnt / 2 >= mx-cnt ) ans = true;
	}else if( mx-mn == 0 ){
		if( mn == N-1 ) ans = true;
		if( N / 2 >= mx ) ans = true;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << a * b << "\n";   
    
    return 0;
}

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

int func(int x) {
  int ans = 0;
  for (int i = 2; i <= sqrt(x); i++) {
    int n = i;
    while (n <= x) {
      n *= i;
    }
    ans = max(ans, n / i);
  }
  return ans;
}

int main() {
  int X;
  cin >> X;

  int ans;
  if (X < 4) ans = 1;
  else ans = func(X);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()

{
	int N,M;

	cin >> N >> M;
	vector<int> data(N + 1,0);
	bool flg = false;

	

	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		data[a]++;
		data[b]++;
	}
	for (int i = 1; i < N + 1; i++)
	{
		cout << data[i] << endl;
	}

	return 0;
	
}

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

using namespace std;

int main(int argc,char* argv[])
{
    int N;
    map<string,int> mp;
    string str;
    scanf("%d",&N);
   
    for(int i=0;i<N;i++)
    {
        cin>>str;
        if(mp[str]==0)
          mp[str] = 1;
        else
          mp[str] = 0;
    }
    
    map<string,int>::iterator it = mp.begin();
    int cnt = 0;
    for( ;it!=mp.end();it++)
    {
    	if(it->second!=0)
    	  cnt++;
    }
    
    printf("%d",cnt);
	return 0;
}



Measured memory_bytes: 8064
n, m = gets.to_s.split.map{|t|t.to_i}

edges = Array.new(n){ []}
m.times do
  u, v = gets.to_s.split.map{|t|t.to_i-1}
  edges[u] << v
end

s, t = gets.to_s.split.map{|i|i.to_i-1}

inf = 10 ** 9
dist = Array.new(n){ Array.new(3){ inf } }
dist[s][0] = 0

q = [[s,0]]
while q.any?
  
  u, x = q.shift
  y = (x+1) % 3
  edges[u].each do |v|
    next if dist[v][y] != inf || dist[u][x] == inf
    dist[v][y] = dist[u][x] + 1
    # if v == t && y == 0
    #   puts dist[v][y] / 3
    #   exit
    # end
    q.push([v, y])
  end
end

puts dist[t][0] == inf ? -1 : dist[t][0] / 3

Measured memory_bytes: 18428
# -*- coding: utf-8 -*-
S = int(input())

X = int(S / 100) #上2桁
Z = S % 100      #下2桁
if 1 <= X <= 12 and 1 <= Z <= 12:
    print("AMBIGUOUS")
elif (X == 0 or 13 <= X) and 1 <= Z <= 12:
    print("YYMM")
elif 1 <= X <= 12 and (Z == 0 or 13 <= Z):
    print("MMYY")
elif (X == 0 or 13 <= X) and (Z == 0 or 13 <= Z):
    print("NA")


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

using namespace std;
#define pb push_back

typedef long long ll;

//O(n^2logn) atmost => try to build up some state and transition
//try to consider the first i numbers end with j(with j <= i)
//dp[i+1][j] = {
// if(s[i+1] == '>') sigma dp[i][j..i] (use j => all the front >= j +=1)
// else sigma dp[i][1...j-1]
//}
//O(n^3) => O(n^2) by prefix sum

int n, k;
string str;
const int maxn = 3000+5;
const ll MOD = 1e9+7;
ll dp[maxn][maxn];
ll s[maxn][maxn]; //no roll

inline void add(ll& a, ll b){ a+=b; a%=MOD;};

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

  cin >> str;
  memset(dp, 0ll, sizeof(dp));
  dp[0][0] = s[0][0] = 0ll;
  dp[0][1] = s[0][1] = 1ll;
  for(int i = 2; i <= n; i++) s[0][i] = (s[0][i-1]+dp[0][i])%MOD;

  for(int i = 1; i <= n-1 ; i++)
  {
    s[i][0] = 0ll;
    for(int j = 1; j <= i+1; j++) //satisfy i ><, using 1-i+1
    {
      if(str[i-1] == '<') add(dp[i][j], s[i-1][j-1]); // dp[i-1][k], j< j
      else add(dp[i][j], s[i-1][i]-s[i-1][j-1]); // dp[i-1][k], j>= j
      s[i][j] = s[i][j-1] + dp[i][j];
    }
  }
  //for(int i = 0; i <= n-1 ; i++, cout << endl)for(int j = 1; j <= i+1; j++) cout << dp[i][j];
  //for(int j = 0; j <= 3; j++, cout<<endl) cout << s[j];

  ll sum = 0ll;
  for(int i = 1; i <= n; i++) add(sum, dp[n-1][i]);
  cout <<  sum << endl;

  return 0;
}


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

using int64 = long long int;
using Vint = vector<int>;
using Vint64 = vector<int64>;
using Wint = vector<Vint>;
using pii = pair<int, int>;

const int MOD = 1e9 + 7;

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


class Solve{
  private:
    const int SUB_MOD = 1e9 + 5;
    int h, w, a, b;
    int for_A, for_B1, for_B2;
    Vint64 S, T;
    /* S(n) := n!を10^9 + 7 で割った余り
    *  T(n) := T(n)^(-1) = S(n)^(10^9 + 5);
    */
    int64 power(int64 n, int index){ // n^(index)を10^9 + 7で割った余りを求める
      if(index == 0) return 1;
      if(index % 2 == 0) return power((n * n) % MOD, index / 2);
      else return (n * power((n * n) % MOD, index / 2)) % MOD;
    }
    int64 calculate_inv(int n){ // n^(-1)を計算する
      return power(n, SUB_MOD);
    }
    void init_S(int k){ // Sの計算を実行する関数
      S.at(0) = 1;
      FOR(i, 1, k + 1) S.at(i) = (S.at(i - 1) * i) % MOD;
    }
    void init_T(int k){ // Tの計算を実行する関数
      T.at(0) = 1;
      FOR(i, 1, k + 1) T.at(i) = calculate_inv(S.at(i));
    }
    int64 nCr(int n, int r){ // 計算済みのS, Tを用いてnCrを10^9+7で割った余りを計算
      return ((S.at(n) * T.at(r) % MOD) * T.at(n - r)) % MOD;
    }
    int64 A(int i){ // main関数内部のコメントで定義したA(i)を計算する
      return nCr(for_A+ i, i);
    }
    int64 B(int i){ // main関数内部のコメントで定義したB(i)を計算する
      return nCr(for_B1 - i, for_B2 - i);
    }
  public:
    // コンストラクタ : 初期化および計算用のS, Tを計算しておく
    Solve(int hin, int win, int ain, int bin){
      h = hin; w = win; a = ain; b = bin;
      for_A = b-1; for_B1 = h + w - b - 2; for_B2 = h - 1;
      S.resize(h + w + 1);
      T.resize(h + w + 1);
      init_S(h + w);
      init_T(h + w);
    }
    ~Solve(){};
    int64 solve_promblem(void){ // 求める答え本体
      int64 res = 0;
      REP(i, h - a) res = (res + A(i) * B(i)) % MOD;
      return res;
    }
};

int main(void){
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  /* 座標を(0, 0) -> (H-1, W-1)へ移動する方法を考える
  * A(i) := 座標(i, B-1)を通る方法 = (B+i-1)_C_i
  * B(i) := 座標(i, B)から(H-1, W-1)へ移動する方法 = (H+W-2-B-i)_C_(H-1-i)
  * C(i) := 座標(i, B-1)を通り, その直後に右に移動して(H-1, W-1)に移動する方法
  *       = A(i) * B(i)
  * 求める値 = Σ(i = 0 -> H-A-1) C(i)
  */
  Solve mn(h, w, a, b);
  cout << mn.solve_promblem() << "\n";
  return 0;
}

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

int main(){
  double x, h;
  while (cin >> x >> h) {
    if (x == 0 && h == 0) break;
    double y = sqrt(h * h + (x * 0.5) * (x * 0.5));
    double ans = x * x + x * y * 0.5 * 4;
    cout << fixed << setprecision(6) << ans << endl;
  }
}



Measured memory_bytes: 3192
import java.util.Scanner;
public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);

       for(int i=0;;i++){
            int a = sc.nextInt();
            if(a==0) break;
           System.out.printf("Case %d: %d\n",i+1,a);
       }
           sc.close();
    }
}
        




Measured memory_bytes: 68144
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

flag = 0
for i in range(1,10):
    for j in range(1,10):
        if(i * j == n):
            flag = 1

if(flag == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12416
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        String str = String.valueOf(num);
        boolean flage = false;
      
        for(int i = 0; i < 2; ++i) {
            if(((str.charAt(i) == str.charAt(i + 1))) && (str.charAt(i + 1) == str.charAt(i + 2))) {
               flage = true;
               break;
            }
        }
       
        if(flage) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
    }
}

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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int dp[100001];

int main()
{
    dp[100] = 1;
    dp[101]=1;
    dp[102]=1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;
    for (size_t i = 106; i <= 100000; i++)
    {
        dp[i] = (dp[i - 100] | dp[i - 101] | dp[i - 102] | dp[i - 103] | dp[i - 104] | dp[i - 105]);
        /* code */
    }
    int x;
    cin>>x;
    cout << dp[x] << endl;
    return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc151/tasks/abc151_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main() {
  long long num;
  string str;
  cin >> num;
  int one = 0;
  int kurisage = 0;
  int other = 0;
  
  str = to_string(num);
  int len = str.size();
  
  if(len == 1){
    cout << num;
  }else{
    int cnt = 0;
    for(int i = 0; i < len; i++){
      if(str.at(i) == '9') cnt++;
      else break;
    }
    
    bool chk2 = true;
    for(int i = 1; i < len; i++){
      if(str.at(i) != '9') chk2 = false;
    }
    
    if(cnt == 0){
      if(chk2 == true){
        // 199999
        one = stoi(str.substr(0,1));
        other = (len - 1) * 9;
        cout << one + other; 
      }else{
        // 11111
        one = stoi(str.substr(0,1)) - 1;
        other = (len - 1) * 9;
        cout << one + other; 
      }
    }else if(cnt == 1){
      // 911111
      one = stoi(str.substr(0,1)) - 1;
      cout << one + ((len - 1) * 9);
    }else if(cnt == len){
      cout << len * 9;
    }else{
      // 991111
      one = (cnt - 1) * 9;
      kurisage = 8;
      other = (len - cnt) * 9;
      cout << one + kurisage + other; 
    }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
    int n,i,j,temp=0;
    cin>>n;
    char a[100]="2",b[100]="1",c[100]={0};
    n++;
    for(i=0;i<n-2;i++){
        int len=max(strlen(a),strlen(b));
        for(j=0;j<len;j++){   //模拟乘法
            temp=0;
            if(a[j]>='0'){    //短的数不加
                temp+=a[j]-'0';
            }
            if(b[j]>='0'){
                temp+=b[j]-'0';
            }
            if(temp>=10){      //判断进位
                if(c[j]>='0'){
                    c[j]+=temp-10;
                }
                else{
                    c[j]+=temp-10+'0';
                }
                //c[j+1]-='0';
                c[j+1]=1+'0';
            }
            else{
                if(c[j]>='0'){
                    if(temp==9){   //最坑的地方,若是前位进位了,而且加上的数字是9,那么还要进位!!!
                        c[j]='0';
                        c[j+1]='1';
                    }
                    else{
                        c[j]+=temp;
                    }
                }
                else{
                    c[j]+=temp+'0';
                }
            }
        }
        strcpy(a, b);//把数字倒过去
        strcpy(b, c);
        memset(c, 0, sizeof(c));
    }
    int len=strlen(b);
    for(i=len-1;i>=0;i--){  //因为反着算的,倒着输出
        printf("%c",b[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const int inf = 1145141919810931;
typedef pair<int, int> P;
typedef pair<P, int>PP;
typedef pair<int, char>PC;
struct edge { int to, cost; };
int t[100006], x[100006], y[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> t[i+1] >> x[i+1] >> y[i+1];
	rep(i, n) {
		int dt = t[i + 1] - t[i], dx = x[i + 1] - x[i], dy = y[i + 1] - y[i];
		if ((dt & 1) != ((dx + dy) & 1)) {
			puts("No");
			return 0;
		}
		else if (dt < dx + dy) {
			puts("No"); return 0;
		}
	}puts("Yes");
}


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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a = in();

	cout << (a < 1200 ? "ABC" : "ARC") << endl;
}



Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
dict_a = defaultdict(int)
for i in range(n):
    dict_a[a[i]] += 1
q = int(input())
s = [sum(a)] + [0] * q
for i in range(q):
    b, c = map(int, input().split())
    try:
        cnt_b = dict_a.pop(b)
        dict_a[c] += cnt_b
        s[i + 1] = s[i] + (c - b)*cnt_b
    except KeyError:
        s[i + 1] = s[i]
print(*s[1:], sep='\n')

Measured memory_bytes: 22440
from itertools import groupby

n = int(input())
C = [key for key, _ in groupby([int(input()) for _ in range(n)])]

N = len(C)

MOD = 10 ** 9 + 7

dp = [0 for _ in range(N)]
dp[0] = 1

T = {}
T[C[0]] = 0

for i in range(1, N):
  if i == 0 or C[i - 1] == C[i] or C[i] not in T:
    dp[i] = dp[i - 1]
  else:
    j = T[C[i]]
    dp[i] = dp[i - 1] + dp[j]
  dp[i] %= MOD
  T[C[i]] = i

print(dp[N - 1])

Measured memory_bytes: 41592
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,m,a,b,c[1 << 17],ans,vizited;
vector<pair<int,int>>vec[1 << 17];
int viz[1 << 17];

void dfs(int nod)
{
	viz[nod] = 1;
	vizited--;
	for(auto it : vec[nod])
	{
		if(!viz[it.first] && !c[it.second]) dfs(it.first);
	}
}

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> m;
	for(int i = 1;i <= m;i++)
	{
		cin >> a >> b;
		vec[a].pb(mp(b,i));
		vec[b].pb(mp(a,i));
	}
	for(int i = 1;i <= m;i++)
	{
		c[i] = 1;
		vizited = n;
		memset(viz,0,sizeof(viz));
		dfs(1);
		if(vizited != 0) ans++;
		c[i] = 0;
	}
	rc(ans);	
}



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

int main() {
  string s; cin >> s;
  int K; cin >> K;
  vector<string> v;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= K; j++) {
      string tmp = s.substr(i, j);
      v.push_back(tmp);
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end() ), v.end());
  cout << v.at(K-1) << endl;
}

Measured memory_bytes: 1660
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    s = input().rstrip()

    r = [i for i, x in enumerate(s) if x == "R"]
    b = [i for i, x in enumerate(s) if x == "B"]
    g = [i for i, x in enumerate(s) if x == "G"]

    c = 0
    for d in range(1, int((n - 3) / 2) + 2):
        for i in range(n):
            tmp = i + d * 2
            if tmp == n:
                break
            if s[i] != s[i + d] and s[i + d] != s[tmp] and s[i] != s[tmp]:
                c += 1

    print(len(r) * len(b) * len(g) - c)


if __name__ == "__main__":
    main()


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s, t; std::cin >> s >> t;
    bool ok = false;
    rep(i, s.size()) {
        string c;
        c += s.back();
        s.pop_back();
        s = c + s;
        if (s == t) ok = true;
    }
    std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
#include <stdlib.h>
 
int main(){
  int X, N;
  std::cin>>X>>N;
  
  std::vector<int> v(100, 1);
  int ans;
  int ansdiff = 100;
  
  if(N==0){
  	std::cout<<X;
  }
  else if(N ==100){
    if(101 - X < X){
  		std::cout<<"101";
    }
    else{
      std::cout<<"0";
    }
  }
  else{
    for(int i=0; i<N; i++){
      int k;
      std::cin>>k;
      v[k-1] = 0;
    }
 
    for(int i0=0; i0<100; i0++){
    
      if(v[i0]==1 & abs(i0 - X +1) < ansdiff){
        //std::cout<<abs(i0 - X +1)<<std::endl;
      	ansdiff = abs(i0 - X +1);
        ans = i0+1;
      }
      
    }
    
    if(X <= ansdiff){
    	std::cout<<"0";
    }else if(101 - X < ansdiff){
    	std::cout<<"101";
    }
    else{
    	std::cout<<ans;
    }
  }
  
  
 
}

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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int k; cin >> k;
        for(int i = 0; i < k; ++i){
            int a; cin >> a;
            ++mp[a];
        }
    }
    int ans = 0;
    for(auto itr : mp){
        if(itr.second == n){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, com, j;
	int a[1000];

	cin >> n;

	for (int i = 0; i < n; i++){
		cin	>> a[i];
	}
	cout << a[0];
	for (int i = 1; i < n; i++){
		cout << " " << a[i];
	}
	cout << "\n";

	for (int i = 1; i <= n - 1; i++){
		com = a[i];
		j = i - 1;
		
		while (j >= 0 && a[j] > com){
			a[j + 1] = a[j];
			j--;
		a[j + 1] = com;
		}

		for (int k = 0; k < n; k++){
			if (k == n - 1 ){
				cout << a[k] << endl;
			}
			else {
				cout << a[k] << " ";
			}
		}
	}		
}

Measured memory_bytes: 3076
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    ll n;
    cin >> n;
    ll a[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll now = 1048576 * 512 - 1;
    ll mid = 1048576 * 256;
    while(mid){
        int b[100002]{0};
        for(int i = 0; i < n; i++){
            if(a[i] >= now) b[i]++;
            else b[i]--;
            b[i + 1] += b[i];
        }
        ll s[200002]{0};
        for(int i = 0; i < n; i++) s[b[i] + 100000]++;
        SegmentTree<ll> seg(200001, [](ll a, ll b){return a + b;}, 0ll);
        for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);
        seg.build();
        int k = 0;
        ll sum = 0;
        for(int i = 0; i < n; i++){
            sum += seg.query(k + 100000, 200001);
            seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);
            if(a[i] < now) k--;
            else k++;
        }
        if(sum >= (n * (n + 1) / 2 + 1) / 2) now += mid;
        else now -= mid;
        mid /= 2;
    }
    int b[100002]{0};
    for(int i = 0; i < n; i++){
        if(a[i] >= now) b[i]++;
        else b[i]--;
        b[i + 1] += b[i];
    }
    ll s[200002]{0};
    for(int i = 0; i < n; i++) s[b[i] + 100000]++;
    SegmentTree<ll> seg(200001, [](ll a, ll b){return a + b;}, 0ll);
    for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);
    seg.build();
    int k = 0;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += seg.query(k + 100000, 200001);
        seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);
        if(a[i] < now) k--;
        else k++;
    }
    if(sum < (n * (n + 1) / 2 + 1) / 2) now--;
    cout << now << endl;
}

Measured memory_bytes: 7164
from collections import*
n=int(input())
s=[input() for _ in range(n)]
e=[[]for _ in range(n)]
INF=10**18
for i,x in enumerate(s):
  for j,y in enumerate(x):
    if y=='1':e[i]+=[j]
ans=0
for i in range(n):
  d=[INF]*n
  q=deque([i])
  d[i]=1
  while q:
    now=q.popleft()
    for to in e[now]:
      if d[to]==INF:
        q+=[to]
        d[to]=d[now]+1
      elif d[to]!=d[now]+1 and d[to]!=d[now]-1:
        print(-1)
        exit()
  ans=max(max(d),ans)
print(ans)

Measured memory_bytes: 69024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e3+7;
int a[N];
ll sum[N], f[N][N];
int main()
{
	int n;
	ll ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		sum[i] = sum[i-1]+a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		f[i][i] = a[i];
	}
	for(int i = 2; i <= n; i++)
	{
		for(int l = 1, r = i; r <= n; l++, r++)
		{
			f[l][r] = max(sum[r]-sum[l-1]-f[l+1][r], sum[r]-sum[l-1]-f[l][r-1]);
		}
	}
	printf("%lld\n", 2*f[1][n]-sum[n]);
	return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <utility>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
int cost(int a,int b,int c) {
    return abs(a-b) + abs(b-c);
}
int main(void) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int res = 10000;
    res = min(res,cost(a[0],a[1],a[2]));
    res = min(res,cost(a[0],a[2],a[1]));
    res = min(res,cost(a[1],a[0],a[2]));
    res = min(res,cost(a[1],a[2],a[0]));
    res = min(res,cost(a[2],a[1],a[0]));
    res = min(res,cost(a[2],a[0],a[1]));
    cout << res << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,M;
    cin >> N >> M;
    vector<llong> A(M);
    vector<llong> dp(N+1, 0);
    map<llong, llong> dict;
    for(int i=0; i<A.size(); i++){
        cin >> A[i];
        dict[A[i]] = 1;
    }
    if(dict[1]==0){
        dp[1] = 1;
    }
    if(dict[0]==0){
        dp[0] = 1;
    }
    for(int i=2; i<dp.size(); i++){
        if(dict[i]){
            continue;
        }
        dp[i] = dp[i-1]%INF + dp[i-2]%INF;
    }
    cout << dp[dp.size()-1]%INF << endl;
    return 0;
}





Measured memory_bytes: 10636