akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <cstdio>
using namespace std;
int main(){
    int A,B,C;
    while(scanf("%d%d%d",&A,&B,&C)!=EOF){
        int i5 = 0;
        int i7 = 0;
        if(A == 5) i5 ++;
        if(A == 7) i7 ++;

        if(B == 5) i5 ++;
        if(B == 7) i7 ++;

        if(C == 5) i5 ++;
        if(C == 7) i7 ++;
        if(i5 == 2&&i7 == 1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


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

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

    std::vector<int> foods(m);

    for (int i = 0; i < n; i++) {
        int k;
        std::cin >> k;

        for (int j = 0; j < k; j++) {
            int temp;
            std::cin >> temp;
            temp--;

            foods[temp]++;
        }
    }

    int ans = 0;
    for (auto elem : foods) {
        if (elem == n) {
            ans++;
        }
    }

    std::cout << ans << std::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 a =sc.nextInt();
       String s =sc.next();
      
      if(a>=3200){
      System.out.print(s);
      }
      else if(a<3200){
      System.out.print("red");
      }
    }
}

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

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size()-1; i<=N; i++) if(i!=N) cout << v[i] << ' '; else cout << v[i] << endl; }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	ll N;
	cin>>N;
	vector<ll> a(N,0);
	rep(i,N)cin>>a[i];

	if([&]{
		rep(i,N){
			if(a[i]!=i+1)return false;
		}
		return true;
	}()){
		cout<<0<<endl;
		return 0;
	}

	vector<ll> v(N+1,0);
	rep(i,N){
		v[a[i]]=v[a[i]-1]+1;
	}

	ll maxval=0;
	rep(i,N+1){
		chmax(maxval,v[i]);
	}
	cout<<N-maxval<<endl;
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	string g = s;
	reverse(g.begin(), g.end());
	int cnt = 0;
	int n = s.size();
	for (int i = 0; i < n; i++) cnt += s[i] != g[i];
	cout << cnt / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define For(i,u) for(int i=hed[u],v=e[i].to;i;i=e[i].nex,v=e[i].to)
using namespace std;
const int maxn=2e5+10;
int n,p[maxn],hed[maxn],cnt,f[maxn],sg[maxn],a[maxn],vis[maxn],ed;
struct edge{
	int to,nex;
	edge(int _=0,int __=0):to(_),nex(__){}
}e[maxn];
inline void add(int u,int v){e[++ed]=edge(v,hed[u]);hed[u]=ed;}
void get_cir(){
	int u=1;
	while(!vis[u]) vis[u]=1,u=p[u];
	memset(vis,0,sizeof(vis));
	while(!vis[u]) vis[u]=1,f[++cnt]=u,u=p[u];
}
void dfs(int u){
	For(i,u) if(!vis[v]) dfs(v);
	For(i,u) if(!vis[v]) a[sg[v]]=u;
	for(;a[sg[u]]==u;++sg[u]);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&p[i]),add(p[i],i);
	get_cir();int mx=-1e9,mn=1e9;
	rep(i,1,cnt)
		dfs(f[i]),mx=max(sg[f[i]],mx),mn=min(sg[f[i]],mn);
	if(mx==mn&&(cnt&1)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  /*bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };*/
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[100100];
int l[101];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[11];

P u[100111];
queue<int> q;
//stack<int> s;
set<long long> s[2][333333];
map<int,long long> p[333333];
map<long long ,int> p1;

vector<long long> v1,v[2][333333];


bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

int f(int i1,int i2,long long n,long long m)
{
  if(v[i1][i2].size()==0||v[i1][i2].back()<n||v[i1][i2][0]>m) return 0;
  //puts("#");
  //printf("$$%lld %lld\n",n,m);
  int a=0,b=v[i1][i2].size()-1,c=0,d=v[i1][i2].size()-1;
  for(;a<b;)
  {
    int h=(a+b)/2;
    if(v[i1][i2][h]<n) a=h+1;
    else b=h;
  }
  for(;c<d;)
  {
    int h=(c+d)/2+1;
    if(v[i1][i2][h]>m) d=h-1;
    else c=h;
  }
  int k=max(0,c-a+1);
  set<long long>::iterator e=s[i1][i2].lower_bound(n);
  for(;e!=s[i1][i2].end()&&(*e)<=m;)
  {
    set<long long>::iterator e1=e;
    e++;
    if(!i1) q.push(p[i2][*e1]);
    else q.push(p[p1[*e1]][v1[i2]]);
    s[i1][i2].erase(e1);
  }
  return k;
}

int main()
{
  scanf("%d %d %d",&a,&b,&c);
  for(int t=1;t<=a;t++)
  {
    scanf("%d %d",&n,&m);
    //printf("!%d %d\n",n+m,n-m);
    u[t]={n+m,n-m};
    v1.push_back(n+m);
    v1.push_back(n-m);
  }
  v1.push_back(-mod*mod);
  sort(v1.begin(),v1.end());
  v1.resize(unique(v1.begin(),v1.end())-v1.begin());
  for(int h=1;h<v1.size();h++)
    p1[v1[h]]=h;
  for(int t=1;t<=a;t++)
  {
    p[p1[u[t].x]][u[t].y]=t;
    v[0][p1[u[t].x]].push_back(u[t].y);
    v[1][p1[u[t].y]].push_back(u[t].x);
    s[0][p1[u[t].x]].insert(u[t].y);
    s[1][p1[u[t].y]].insert(u[t].x);
  }
  for(int t=1;t<v1.size();t++)
  {
    sort(v[0][t].begin(),v[0][t].end());
    sort(v[1][t].begin(),v[1][t].end());
  }
  x=max(abs(u[b].x-u[c].x),abs(u[b].y-u[c].y));
  q.push(b);
  for(;q.size();q.pop())
  if(!o[q.front()])
  {
    o[q.front()]=1;
    if(p1[u[q.front()].x+x])
      y+=f(0,p1[u[q.front()].x+x],u[q.front()].y-x,u[q.front()].y+x);
    if(p1[u[q.front()].x-x])
      y+=f(0,p1[u[q.front()].x-x],u[q.front()].y-x,u[q.front()].y+x);
    if(p1[u[q.front()].y+x])
      y+=f(1,p1[u[q.front()].y+x],u[q.front()].x-x+1,u[q.front()].x+x-1);
    //
    if(p1[u[q.front()].y-x])
      y+=f(1,p1[u[q.front()].y-x],u[q.front()].x-x+1,u[q.front()].x+x-1);
    //printf("%d %lld\n",q.front(),y);
  }
  //else printf("%d\n",q.front());
  printf("%lld",y/2);
}
//4
//21




Measured memory_bytes: 107632
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	a = (a / b) + (a % b != 0);
	cout << c * a;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

using namespace std;
int main(){
    int n,p;
    while(cin >> n >> p && n){
        vector<int> stone(n , 0);
        int cup=p;
        bool flag=true;
        while(flag){
            for(int i =0; i<n;i++){
                if (stone[i]==p)
                {
                    cout << i <<endl;
                    flag =false ;
                    break;
                }

                if(cup>0){
                    stone[i]++;
                    cup--;
                }else if(cup==0){
                    cup+=stone[i];
                    stone[i]=0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <climits>
#include <string>
class City;
struct Path {
	int cost;
	City *to;
};
class City {
public:
	City() {};
	void add_path(const Path &path) {
		route[idx++] = path;
	}
	int cost{ INT_MAX };
	void go_next() {
		reach_flag = true;
		for (auto i = 0; i < idx; ++i) {
			route[i].to->arrive_at(cost + route[i].cost);
		}
	}
	bool is_reached() const { return reach_flag; };
	void reset() { reach_flag = false; cost = INT_MAX; }
private:
	int idx{ 0 };
	Path route[20];
	bool reach_flag{ false };
	void arrive_at(const int &c) {
		if (c < cost) cost = c;
	}
};
void read_sub(std::string &str, int &a) {
	auto idx = str.find(',');
	a = std::stoi(str.substr(0, idx));
	str = str.substr(idx + 1);
}
void read(std::string str, int &a, int &b, int &c, int &d) {
	read_sub(str, a); read_sub(str, b); read_sub(str, c); d = std::stoi(str);
}
int cul_cost(City city[], int n, int start, int goal) {
	for (auto i = 1; i <= n; ++i) {
		city[i].reset();
	}
	city[start].cost = 0;
	auto min = start;
	while (min != goal){
		city[min].go_next();
		auto min_cost = INT_MAX;
		for (auto i = 1; i <= n; ++i) {
			if (!city[i].is_reached() && city[i].cost < min_cost) {
				min_cost = city[i].cost;
				min = i;
			}
		}
	}
	return city[goal].cost;
}
int main() {
	City city[21];
	int n;
	std::cin >> n;
	for (auto i = 1; i <= n; ++i) {
		city[i] = City();
	}
	int m;
	std::cin >> m;
	for (auto i = 0; i < m; ++i) {
		int a, b, c, d;
		std::string str;
		std::cin >> str;
		read(str, a, b, c, d);
		city[a].add_path({ c, &city[b] });
		city[b].add_path({ d, &city[a] });
	}
	int start, goal, reward, pillar_cost;
	std::string str;
	std::cin >> str;
	read(str, start, goal, reward, pillar_cost);
	auto all_cost = cul_cost(city, n, start, goal) + cul_cost(city, n, goal, start);
	std::cout << reward - pillar_cost - all_cost << std::endl;
	return 0;
}

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

using namespace std;

int main(){
	string str;
	cin >> str;
	bool flag = false;
	for(int i = 0, smax = str.length(); i < smax; ++i){
		if(str[i] == '9'){
			flag = true;
			break;
		}
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



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

int coin[4];
int coin_value[4] = {10,50,100,500};
int p;
int ans[4];
int ans_num;

void rec(int k) {
  static int i[4];
  if(k == 0) ans_num = 100000;

  if(k == 4) {
    int sum = 0;
    for(int j = 0; j < 4; j++) sum += coin_value[j] * i[j];
    if(sum < p) return;
    int otsuri_sum = sum - p;
    int otsuri[4];
    for(int j = 3; j >= 0; j--) {
      otsuri[j] = otsuri_sum / coin_value[j];
      otsuri_sum %= coin_value[j];
      if(i[j] > 0 && otsuri[j] > 0) return;
    }
    int num = 0;
    for(int j = 0; j < 4; j++) {
      num += (coin_value[j] - i[j]) + otsuri[j];
    }
    if(num < ans_num) {
      ans_num = num;
      for(int j = 0; j < 4; j++) {
	ans[j] = i[j];
      }
    }
    return;
  }

  for(i[k] = 0; i[k] <= coin[k]; i[k]++) {
    rec(k+1);
  }
}

main() {
  bool fFlag = false;
  while(1) {
    cin >> p;
    if(p == 0) break;

    for(int i = 0; i < 4; i++) cin >> coin[i];

    if(!fFlag) fFlag = true;
    else       cout << endl;

    rec(0);

    for(int i = 0; i < 4; i++) {
      if(ans[i] == 0) continue;
      cout << coin_value[i] << ' ' << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 868
int main(void){
	int a = 0;
	int b = 0;
	int i = 0;
	int j = 0;

	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0){
			break;
		}
		for (i = 0; i < a; i++){
			if (i % 2 == 1){
				for (j = 0; j < b; j++){
					if (j % 2 == 1){
						printf("%c", '#');
					}
					else{
						printf("%c", '.');
					}
				}
				printf("\n");
			}
			else if (i % 2 == 0){
				for (j = 0; j < b; j++){
					if (j % 2 == 1){
						printf("%c", '.');
					}
					else{
						printf("%c", '#');
					}
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<cmath>

using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M){
  ullong tmp = 1;

  if ( n > 0 ){
    tmp = power(x, n/2, M);
    if ( n%2 == 0 ) tmp = (tmp*tmp)%M;
    else tmp = (((tmp*tmp)%M)*x)%M;
  }
  return tmp;
}

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

  cout << power(m, n, 1000000007) << endl;

  return 0;
}

Measured memory_bytes: 3096
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in zip(PS[::2], PS[1::2]):
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[i] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[i]
print(*ans)


Measured memory_bytes: 26040
N = int(input())

a = [int(x) for x in input().split()]

colors = {}

l=[1 for _ in range(N)]

i=0
prev=0
flag=False
for n in a:
    if n==prev:
        flag=True
        l[i]+=1
    else:
        if flag:
            i+=1
            flag=False
    prev=n
    

count=0

for x in l:
    if x <= 1:
        break
    else:
        count+=x//2

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;
const ll INF=1e15;

//char buf[size],*p1=buf,*p2=buf;
TP void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
TP void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
TP void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
TP void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

//math
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
    ll c=1;
    while(b) {
        if(b&1) c=c*a%mod;
        b /= 2; a=a*a%mod;
    }
    return c;
}

TP void cmax(o &x,o y) {if(x < y) x=y;}
TP void cmin(o &x,o y) {if(x > y) x=y;}

//dbinom

//ll jc[N],inv[N];
//void init(int n) {
//	jc[0]=1; for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
//	inv[n]=power(jc[n]); for(int i=n;i;i--) inv[i-1]=inv[i]*i%mod;
//}
//ll C(int x,int y) {
//	if(x<y || y<0) return 0;
//	return jc[x]*inv[y]%mod*inv[x-y]%mod;
//}

int n,a[N];

void solve() {
	qr(n);
	while(n--) printf("ACL"); 
}

int main() {
	int T=1;
//	qr(T);
	while(T--)
		solve();
}





Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

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

    int a, b;
    cin>>a>>b;

    if (a > b)  swap(a, b);
    for (int i=0; i<b; i++) cout<<a;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 1e4+5;

string s;

int main()
{
	cin >> s;
	rep(i, 0, s.length()){
		putchar('x');
	}
	return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  	ll a,b;
  cin>>k>>a>>b;
  ll nearest;
  if(a%k==0)
  {
      cout<<"OK";
      return;
  }
  nearest=a+k-a%k;
  if(nearest<=b)
  {
      cout<<"OK";
  }
  else
    {
        cout<<"NG";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3608
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  n<-getLine
  let m=group $ sort n in if length n == length m then putStrLn "yes" else putStrLn "no"

Measured memory_bytes: 508
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private int N;
    private int[] arr;
    private int cnt;
    private List<Integer> G;

    public Main(Scanner sc) {
        N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        cnt = 0;
    }

    private void insertionSort(int g) {
        for (int i = g; i < N; i++) {
            int j = i - g;
            int val = arr[i];
            while (j >= 0 && arr[j] > val) {
                arr[j+g] = arr[j];
                cnt++;
                j = j-g;
            }
            arr[j+g] = val;
        }
    }

    private void shellSort() {
        G = new ArrayList<>();
        for (int i = 1; ; i = i*3+1) {
            if (i <= N) {
                G.add(i);
            } else {
                break;
            }
        }

        for (int ix = G.size()-1; ix >= 0; ix--) {
            insertionSort(G.get(ix));
        }
    }

    private void printArray() {
        for (int i = 0; i < N; i++) {
            System.out.println(arr[i]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.shellSort();

        System.out.println(m.G.size());
        for (int ix = m.G.size()-1; ix > 0; ix--) {
            System.out.print(m.G.get(ix) + " ");
        }
        System.out.println(m.G.get(0));
        System.out.println(m.cnt);
        m.printArray();
    }
}


Measured memory_bytes: 307660
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int n,x,sum=0;
    vector<int> v;
    double p;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
        sum+=x;
    }
    p=(double)sum/(double)n;
    if((p-floor(p))>=0.5){
        p=floor(p)+1;
    }
    else{
        p=floor(p);
    }
    sum=0;
    for(int i=0;i<n;i++){
        sum+=pow((v[i]-p),2);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
int main()
{
    ll n,p;
    cin>>n>>p;
    cout<<n-p+1<<endl;
}


Measured memory_bytes: 256
N = int(input())

vac = []
for i in range(N):
    vac.append(list(map(int, input().split())))
    
DP = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            DP[i+1][k] = max(DP[i+1][k], DP[i][j]+vac[i][k])
ans = 0
for i in DP[N]:
    ans = max(ans, i)
print(ans)

Measured memory_bytes: 50036
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
using ll = long long;

const int maxn = 100101;
ll n, a[maxn], s[maxn], L, R, f[maxn * 2 + 10], b[maxn], c[maxn * 2 + 10];

void add(ll x) {
	while (x <= 2 * maxn)f[x]++, x += x & -x;
}
ll query(ll x) {
	ll tot = 0;
	while (x > 0)tot += f[x], x -= x & -x;
	return tot;
}

bool check(ll x) {
	memset(f, 0, sizeof f);
	for (ll i = 1; i <= n; i++) {
		if (a[i] >= x)c[i] = 1; else c[i] = -1;
		c[i] += c[i - 1];
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++)ans += (query(c[i] + maxn)), add(c[i] + maxn);
	return ans >= n * (n + 1) / 4 ? true : false;
}

int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++)cin >> a[i], s[i] = a[i];
	sort(s + 1, s + n + 1);
	L = 1, R = n;
	while (L <= R) {
		ll mid = L + R >> 1;
		if (check(s[mid]))L = mid + 1; else R = mid - 1;
	}
	cout << s[R] << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
using namespace std;


int main() {
    int n, a;
    set<int> s;
    cin>>n;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin>>a;
        if (s.find(a) == s.end()) s.insert(a);
        else s.erase(a);
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 4864
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define INF INT_MAX/3

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define MAX_N 800

long long rt_mem[MAX_N];
int N;

struct Edge {
  int dest;
  int length;
};

vector<Edge> Graph[MAX_N];

long long round_trip(int start, int from) {
  if( rt_mem[start] >= 0 ) {
    return rt_mem[start];
  }
  long long ret = 0;
  int sz = Graph[start].size();
  REP(i, sz) {
    Edge e = Graph[start][i];
    if( e.dest == from ) {
      continue;
    }


    if( Graph[e.dest].size() == 1 ) {
      ret += e.length;
      continue;
    }

    long long rt = round_trip(e.dest, start);
    ret += e.length + rt + e.length + e.length;
  }

  rt_mem[start] = ret;
  return ret;
}

long long one_way(int start, int from) {
  long long delta = 0;
  int sz = Graph[start].size();
  REP(i, sz) {
    Edge e = Graph[start][i];
    if( e.dest == from ) {
      continue;
    }

    if( Graph[e.dest].size() == 1 ) {
      continue;
    }

    long long ow = one_way(e.dest, start);
    long long rt = round_trip(e.dest, start);
    delta = min(delta, - rt - e.length + ow);
  }
  long long ret = round_trip(start, from) + delta;
  return ret;
}

long long solve1() {
  long long ans = 100000 * 800 * 3;
  REP(i, N) {
    memset(rt_mem, -1, sizeof(rt_mem));
    ans = min(ans, one_way(i, -1));
  }
  return ans;
}

int load() {
  scanf("%d", &N);
  if( !N ) return 0;

  int Ps[MAX_N];
  int Ds[MAX_N];

  FOR(i, 1, N) {
    scanf("%d", &Ps[i]);
    --Ps[i];
  }
  FOR(i, 1, N) {
    scanf("%d", &Ds[i]);
  }

  REP(i, N) {
    Graph[i].clear();
  }

  FOR(i, 1, N) {
    int p = Ps[i];
    int d = Ds[i];
    Edge e;
    e.dest = p;
    e.length = d;
    Graph[i].push_back(e);
    e.dest = i;
    Graph[p].push_back(e);
  }
  return 1;
}


int main() {
  while(load()) {
    long long ans = solve1();
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1376
line = list(map(int,input().split()))
a,b,c=line[0],line[1],line[2]
if a>b:
    a,b = b,a

if b>c:
    b,c = c,b
        
if b < a:
    a,b=b,a
    
    
print(str(a)+" "+str(b)+" "+ str(c))


Measured memory_bytes: 5600
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public long gcd(long a,long b){
		return b==0?a:gcd(b,a%b);
	}
	
	public void run() {
		while(sc.hasNext()){
			long a=sc.nextInt(),b=sc.nextInt();
			long g=gcd(a,b);
			ln(g+" "+ a*b/g);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

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

    if (n > m) {
        std::swap(n, m);
    }

    if (n == 1) {
        if (m == 1) {
            cout << 1;
        } else {
            cout << m - 2;
        }
    } else {
        cout << (n - 2) * (m - 2);
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int f[8][8];
int dx[] = { 1,1,0,-1,-1,-1,0,1 };
int dy[] = { 0,-1,-1,-1,0,1,1,1 };

int queen(int y) {
	if (y == 8)
		return 1;
	for (int x = 0; x < 8; ++x) {
		if (f[y][x]) {
			return queen(y + 1);
		}
		int flag = 0;
		for (int k = 0; k < 8; ++k) {
			int nx = x, ny = y;
			while (!flag) {
				nx += dx[k];
				ny += dy[k];
				if (nx < 0 || nx > 7 || ny < 0 || ny > 7)
					break;
				if (f[ny][nx])
					flag = 1;
			}
			if (flag)
				break;
		}
		if (!flag) {
			f[y][x] = 1;
			if (queen(y + 1))
				return 1;
			f[y][x] = 0;
		}
	}
	return 0;
}

int main() {
	int k, r, c;
	cin >> k;
	while (k--) {
		cin >> r >> c;
		f[r][c] = 1;
	}
	queen(0);
	for (int i = 0; i < 8; ++i) {
		for (int j = 0; j < 8; ++j) {
			cout << (f[i][j] ? 'Q' : '.');
		}
		cout << endl;
	}

	return 0;
}


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

void Main()
{
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

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

void solve() {
  int N, K;
  cin >> N;
  cin >> K;
  vector<int> D(K);
  int mask = (1 << 10) - 1;
  for (int i = 0; i < K; i++) {
    cin >> D[i];
    mask ^= (1 << D[i]);
  }
  vector<int> valid;
  for (int i = 0; i < 10; i++) {
    if ((mask >> i) & 1) valid.push_back(i);
  }
  vector<int> ans;
  function<void(int, int)> dfs = [&](int depth, int val) {
    if (val >= N) ans.push_back(val);
    if (depth >= 5) { return; }
    for (int v : valid) { dfs(depth + 1, val * 10 + v); }
  };
  dfs(0, 0);
  sort(all(ans));
  cout << ans.front() << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 640
function main(arg) {
  var sum = arg.split(' ').reduce(function(a, b) {
    a = a + Number(b)
    return a
  }, 0)

  if (sum > 21) {
    console.log('bust')
  } else {
    console.log('win')
  }
}

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

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

using namespace std;

string S;

void input()
{
  cin >> S;
}

int main()
{
  input();
  int ans = 0;
  for (size_t i = 0; i < S.length(); i++) {
    if(ans == 0 && S[i] == 'C'){
      ans++;
    }
    else if(ans == 1 && S[i] == 'F'){
      ans++;
    }
  }
  if(ans == 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    int k = K -1;
    int y = N - 1;
    int ans = (y - y % k) / k;
    if (y % k != 0) {
        ans++;
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
N, M = map(int, input().split())
ks = []
k_max = 0
for i in range(M):
	ks_in = list(map(int, input().split()))
	k_max = max(k_max, max(ks_in[1:]))
	ks.append(ks_in)
p = list(map(int, input().split()))

A = [0, 1]
lt = list(itertools.product(A, repeat=N))
count = 0
for elem in lt:
	for i in range(M):
		sum = 0
		for j in range(len(ks[i])-1):
			sum += elem[ks[i][j+1]-1]
		if sum % 2 != p[i]:
			break
	else:
		count += 1
print(count)

Measured memory_bytes: 3188
#include "bits/stdc++.h"

#define INF 99999999
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

struct Edge
{
	int s, t, w;
	Edge(int s,int t,int w):s(s),t(t),w(w){}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return w != e.w ? w < e.w : (s != e.s ? s < e.s : t < e.t);
	}
};


struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

int mat[1400][1400];
int dp[1400][1400];

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

	int H, W;
	cin >> H >> W;

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

	int ans = 0;
	for (int i = 0; i < W; i++)
	{
		dp[0][i] = mat[0][i] ? 0 : 1;
		ans = max(ans, dp[0][i]);
	}
	for (int i = 0; i < H; i++)
	{
		dp[i][0] = mat[i][0] ? 0 : 1;
		ans = max(ans, dp[i][0]);
	}

	for (int i = 1; i < H; i++)for (int j = 1; j < W; j++)
	{
		if (mat[i][j] == 1)
		{
			dp[i][j] = 0;
		}
		else
		{
			dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1;
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans*ans << endl;

	return 0;
}


Measured memory_bytes: 18416
n, k = map(int, raw_input().split())
d = {}
for _ in xrange(n):
    s = raw_input().strip()
    d[s[0]] = d.get(s[0], 0) + 1
for i in xrange(n / k, 0, -1):
    c = t = 0
    for _, j in d.viewitems():
        j = min(j, i)
        c += j
        if c >= i:
            t += 1
            c -= i
    if t >= k:
        print i
        break
else:
    print 0


Measured memory_bytes: 2568
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> A, B;


  return A * B;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <array>
#include <utility>

typedef long long ll;
using namespace std;

const int MAX=100000;

typedef pair<int, int> P;

int X(int dist, int player) {
    return dist * 4 + player;
}

int getDist(int x) {
    return x / 4;
}

int getPlayer(int x) {
    return x % 4;
}


bool comp(P a, P b) {
    if (getDist(a.second) == getDist(b.second)) {
        return getPlayer(a.second) > getPlayer(b.second);
    }
    return getDist(a.second) > getDist(b.second);
};

vector<int> edges[MAX];

int main() {
    int N;
    priority_queue<P, vector<P>, decltype(&comp)> q(&comp);
	scanf("%d", &N);
    for (int i = 0; i < N - 1; i ++) {
        int a, b;
        scanf("%d %d", &a, &b);
        edges[a - 1].push_back(b - 1);
        edges[b - 1].push_back(a - 1);
    }
    vector<int> dist(N, 0);
    q.push(P(0, X(0, 1)));
    q.push(P(N - 1, X(0, 2)));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.first;
        int x = p.second;
        int d = getDist(x);
        int player = getPlayer(x);
        if (dist[v] == 0 || d < getDist(dist[v])) {
            //cerr  << getDist(dist[v]) << endl;
            dist[v] = x;
            //cerr  << "dist[" << v << "]={" << d << ", " << player << "}" << " (" << x << ")" << endl;
            for (auto w : edges[v]) {
                q.push(P(w, X(d + 1, player)));
            }
        }
    }
    int player1_num = 0;
    int player2_num = 0;
    for (int i = 0; i < N; i ++) {
        if (getPlayer(dist[i]) == 1) {
            player1_num ++;
        } else {
            player2_num ++;
        }
    }
    if (player1_num > player2_num) {
        printf("Fennec\n");
    } else {
        printf("Snuke\n");
    }
    //cerr << player1_num << "," << player2_num << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        dist[si][sj] = 0;
        q.emplace(si,sj);
        while (!q.empty()) {
            int i = q.front().first, j = q.front().second;
            q.pop();
            rep(dir,4) {
                int ni = i+di[dir], nj = j+dj[dir];
                if (ni<0||ni>=h||nj<0||nj>=w) continue;
                if (s[ni][nj] == '#') continue;
                if (dist[ni][nj] != INF) continue;
                dist[ni][nj] = dist[i][j] + 1;
                q.emplace(ni,nj);
            }
        } 
        rep(i,h)rep(j,w) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    } 
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;
const double EPS = 1e-8;

inline pair<double, double> rotate(pair<double, double> ori, double alpha) {
	pair<double, double> ans;

	ans.fi = cos(alpha) * ori.fi - sin(alpha) * ori.se;
	ans.se = sin(alpha) * ori.fi + cos(alpha) * ori.se;

	return ans;
}

int main() {
	int x; rd(x);
	double alpha = x * acos(-1) / 180.0;

	int ans = 0;

	pair<double, double> pos{0, 0}, vec{0, 1};

	do {
		pos.fi += vec.fi;
		pos.se += vec.se;
		vec = rotate(vec, alpha);
		ans++;
	} while(abs(pos.fi) > EPS or abs(pos.se) > EPS);

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

Measured memory_bytes: 4088
/*
これは結構発想問題で難しい
何回もの思考の結果として生まれるものであると思う。
最初の考え方だと、l,rが入れ替わる瞬間をメモっておく。そして、それの外側通しを変化させる。
→文字列の大きさがでかすぎるのでreverseさせると計算量が死ぬので他の考え方はないかを模索するというのが良さそう。

*/

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

int main()
{
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int count = 0;

    for (int i = 1; i < n; i++)
    {
        if (s[i] == 'L' && s[i - 1] == 'L')
        {
            count += 1;
        }
        if (s[i] == 'R' && s[i - 1] == 'R')
        {
            count += 1;
        }
    }

    cout << min(count + k * 2, n - 1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int par[52];
int sz[52];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        sz[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x)
        return x;
    else 
        return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x), y = find(y);

    if (x == y) 
        return ;
    else if (sz[x] < sz[y])
        par[x] = y;
    else {
        par[y] = x;
        if (sz[x] == sz[y])
            sz[x]++;
    }
}

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

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

    int ans = 0;

    for (int i = 0; i < m; i++) {
        init(n);
        for (int j = 0; j < m; j++) {
            if (i != j) 
                unite(a[j]-1, b[j]-1);
        }
        for (int j = 0; j < n-1; j++) {
            if (!same(j, j+1)) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 45

int F[MAX],i;

int fibonacci(n){
  F[0] =1;
  F[1] =1;
  if(n==0 || n==1){
    return 1;
  }
  else{
    for(i=2;i<=n;i++){
      F[i] = F[i-2] + F[i-1];
    }
    return F[n];
  }

}


int main(){
  int num;
  scanf("%d",&num);
  printf("%d\n",fibonacci(num));
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
  int n,m;cin>>n>>m;
  vector<int> v[n+1];
  int a[m],b[m];
  map<pii,int> mp;
  rep(i,0,m){
    cin>>a[i]>>b[i];
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
    mp[{a[i],b[i]}]=i;
    mp[{b[i],a[i]}]=i;
  }
  bool used[n+1],usedm[m];
  fill(used,used+n+1,false);
  fill(usedm,usedm+m,false);
  ll num[3];
  fill(num,num+3,0);
  int col[n+1];
  fill(col,col+n+1,-1);
  rep(i,1,n+1){
    if(used[i])continue;
    queue<int> q;q.push(i);
    used[i]=true;
    col[i]=0;
    int c=0;
int cnt=0;
    while(q.size()>0){
      int now=q.front();q.pop();
      cnt++;
      rep(j,0,v[now].size()){
        int ne=v[now][j];
        int nec=col[now]^1;
        if(col[ne]>=0){
          if(col[ne]!=nec){
            c=1;
          }
        }
        else{
          col[ne]=nec;
          q.push(ne);
          used[ne]=true;
        }
      }
    }
    if(cnt==1)num[0]++;
    else if(c==1)num[1]++;
    else num[2]++;
  }
  ll ans=2*num[2]*num[2];
  ans+=num[1]*num[1]+2*num[1]*num[2];
  ans+=2*n*num[0]-num[0]*num[0];
  cout<<ans<<endl;
}


Measured memory_bytes: 34304
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
  ll n,x;
  cin >>n>>x;
  ll a[n];
  ll ans=0;
  for(int i=0;i<n;i++) cin >>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      int k=a[i]+a[i+1]-x;
      ans+=k;
      if(a[i+1]>=k)  a[i+1]-=k;
      else a[i+1]=0;
    }
  }
  cout << ans<<endl;
}


Measured memory_bytes: 1024
f = gets.to_i
a = gets.split.map(&:to_i)
ans = []
(a.min..a.max).each do |x|
   count = a.inject(0){ |sum, n| sum + (n-x)** 2 } #sumの初期値を0で初期化
   ans.push count
end

puts ans.min

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  vector<int> fromOne, toN, inter;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) fromOne.push_back(b);
    if (b == n) toN.push_back(a);
  }
  sort(fromOne.begin(), fromOne.end());
  sort(toN.begin(), toN.end());
  set_intersection(fromOne.begin(), fromOne.end(), toN.begin(), toN.end(), back_inserter(inter));
  cout << (inter.size() > 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int co_4 = 0, co_2 = 0, co_1 = 0;
    for (int i = 0; i < N; i++){
        if (a.at(i)%4 == 0) co_4++;
        else if (a.at(i)%2 == 0) co_2++;
        else co_1++;
    }
    
    bool can = false;
    if ((co_4 >= co_1) || (co_4 == co_1 - 1 && co_2 == 0)) can = true;
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640