akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

int  count_digits(int n) 
{ 
    string num = to_string(n); 
    return num.size() ;
} 
void solve() {
    int i,j;
    string s;
    cin>>s;
    string temp="s";
    string temp1="es";
    int n=s.length();
    if(s[n-1]!='s'){s=s+temp;}
    else{s=s+temp1;}
    cout<<s;
    return;

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
   // cin >> t;
    while(t--) {
      solve();
      //solve()?  cout << "Yes" : cout << "No "; 
      cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 50496
s=str(input())
t=''
len1=0
flag=0
l=len(s)
while len1<=len(s):
    if s[l-(len1+7):]=='dreamer'+t:
        t='dreamer'+t
        flag+=1
        len1+=7
    else:
        if s[l-(len1+5):]=='dream'+t:
            t='dream'+t
            flag+=1
            len1+=5
        else:
            if s[l-(len1+6):]=='eraser'+t:
                t='eraser'+t
                flag+=1
                len1+=6
            else:
                if s[l-(len1+5):]=='erase'+t:
                    t='erase'+t
                    flag+=1
                    len1+=5
                else:
                    pass
 
    if flag==0:
        break
    else:
        if s==t:
            print('YES')
            break
        else:
            flag=0
if s==t:
    pass
else:
    print('NO')

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;


int main(){
  ll fac[100001];
  fac[1] = 1;
  for(int i = 1; i<= 100000; i++) fac[i+1] = (i+1) * fac[i]%MOD;
  int n,m; cin >> n >> m;
  if(abs(n-m) >= 2){
    std::cout << 0 << '\n';
    return 0;
  }
  ll ans;
  if(n == m) ans = (2*fac[n]*fac[n]%MOD);
  else ans = fac[n]*fac[m]%MOD;

  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val a = (1..n).map { readLine()!!.toInt() }.toTypedArray()

  val b = a.copyOf()
  b.sortDescending()

  for (i in 0 until n) {
    if (a[i] == b[0]) {
      println(b[1])
    } else {
      println(b[0])
    }
  }
}


Measured memory_bytes: 64092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int n,m,ans=0;
  cin >> n >> m;
  vector<int> table(m+1);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int x; cin >> x;
      table.at(x)++;
    }
  }
  for (int i = 0; i < m+1; i++) {
    if (table.at(i) == n) ans++;
  }
  cout << ans << endl;
}

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

class UnionFind {
  vector<int>par, sz;
public:
  UnionFind() {}
  UnionFind(int n) {
    par = sz = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      sz[i] = 1;
    }
  }
  int find(int x) {
    if (par[x] == x)return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y)return;
    if (sz[x] > sz[y]) {
      par[y] = x;
      sz[x] += sz[y];
    }
    else {
      par[x] = y;
      sz[y] += sz[x];
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sz[find(x)];
  }
};

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

  vector<int> a(m+1),b(m+1);
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
  }

  UnionFind u(n);
  vector<ll> res(m+1);
  res[m] = (ll)n*(n-1)/2;
  for (int i = m; 1 < i; i--) {
    if(u.same(a[i]-1,b[i]-1)){
      res[i-1] = res[i];
    } else {
      res[i-1] = res[i]-(ll)u.size(a[i]-1)*u.size(b[i]-1);
      u.unite(a[i]-1,b[i]-1);
    }
  }

  for (int i = 1; i <= m; i++) {
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;

int solve(vi v,int k){
    int ans = 0;
    for(int i=0; i<k; i++){
        ans+=v[i];
        v[i+1]^=1;
    }
    for(int i=v.size()-1; i>k; i--){
        ans+=v[i];
        v[i-1]^=1;
    }
    return ans+v[k];
}

int main(){
    // vi v(100,0);
    // rep(i,100)rep(j,100)dp[i][j]=-1;
    // cout << solve(v,0,v.size()-1) << endl;
    // return 0;

    int h,w;
    while(cin >> h>>w){
        vvi c(h,vi(w));
        rep(i,h)rep(j,w){
            cin >> c[i][j];
            if(i) c[i][j]^=1;
        }

        int ans = 0;
        rep(i,h){
            int t = 0;
            rep(j,w) t = max(t, solve(c[i],j));
            ans += t;
        }
        cout << ans << endl;
    }
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

string qtr,str;

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

	ll n,i,j,k,ans = 0,r = 0,g = 0,b = 0;

	cin >> n;
	cin >> str;

	for(i=0;i<n;++i)
	{
		if(str[i] == 'R')
			r++;
		else if(str[i] == 'G')
			g++;
		else
			b++;
	}

	ans = r*g*b;

	for(i=0;i<n;++i)
	{
		for(j=i+1;j<n;++j)
		{
			k = j+j-i;
			if(k<n)
			{
				qtr.clear();
				qtr.pb(str[i]);
				qtr.pb(str[j]);
				qtr.pb(str[k]);
				sort(all(qtr));
				if(qtr == "BGR")
					ans--;
			}
		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int c[110000];
vector<int>g[110000];
bool dame=false;
long long dfs(int a,int b){
	long long rem=c[a];
	if(g[a].size()>1)rem*=2;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		long long v=dfs(g[a][i],a);
		if(v>c[a])dame=true;
		rem-=v;
	}
	if(rem>c[a])dame=true;
	if(rem<0)dame=true;
	if(b==-1&&rem)dame=true;
	return rem;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	if(a==2){
		if(c[0]==c[1])printf("YES\n");else printf("NO\n");return 0;
	}
	int at=-1;
	for(int i=0;i<a;i++){
		if(g[i].size()>1){
			at=i;break;
		}
	}
	if(at==-1)return 1;
	dfs(at,-1);
	if(dame)printf("NO\n");else printf("YES\n");
}


Measured memory_bytes: 13056
#include<iostream>
#include<cstdlib>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long *p = (long long *)malloc(sizeof(long long)*n);
    for(int i=0; i<n; i++)
        cin >> p[i];
    long long min,max,sum;
    min = max = sum = p[0];
    for(int i=1; i<n; i++){
        if(min > p[i]) min=p[i];
        if(max < p[i]) max=p[i];
        sum+=p[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<algorithm>
using namespace std;
long long f[200001];
int main()
{
	long long n,p,q,r,s,P,Q,R,S,m,ans=1e15;
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&f[i]),f[i]+=f[i-1];
	for (int i=2;i<n-1;i++)
	{
		p=1;  q=i;
		while (p+1<q)
		{
			m=((q-p)>>1)+p;
			if ((f[m]<<1)>f[i]) q=m;
			else p=m;
		}
		r=0;  s=i-1;
		while (r+1<s)
		{
			m=((s-r)>>1)+r;
			if ((f[m]<<1)>=f[i]) s=m;
			else r=m;
		}
		if (f[p]>f[i]-f[s]) P=f[p],Q=f[i]-f[p];
		else P=f[i]-f[s],Q=f[s];
		p=i+1;  q=n;
		while (p+1<q)
		{
			m=((q-p)>>1)+p;
			if (((f[m]-f[i])<<1)>f[n]-f[i]) q=m;
			else p=m;
		}
		r=i;  s=n-1;
		while (r+1<s)
		{
			m=((s-r)>>1)+r;
			if (((f[m]-f[i])<<1)>=f[n]-f[i]) s=m;
			else r=m;
		}
		if (f[p]-f[i]>f[n]-f[s]) R=f[p]-f[i],S=f[n]-f[p];
		else R=f[n]-f[s],S=f[s]-f[i];
		ans=min(max(P,max(Q,max(R,S)))-min(P,min(Q,min(R,S))),ans);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void){
    int n,h[20],res=1;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    for(int i=1;i<n;i++){
        int flag = 1;
        for(int j=0;j<i;j++){
            if(h[j] > h[i])flag = 0;
        }
        if(flag)res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int a,b,c;
signed main(){
    cin>>a>>b>>c;
    int d=(c-a-b);
    if(d>0){
        if(4*a*b<d*d)puts("Yes");
        else puts("No");
    }
    else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 17500001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



 
#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


     

    int n, x, m;
    cin >> n >> x >> m;
    int cnt = 1, prev = 0, ans = x, ok = 0, ind = -1;

    vector<int>v(N, 0);
    map<int, int>mapi;

    v[cnt] = x, mapi[x] = cnt;
    while(cnt < n){
        int cur = (x * x) % m;
        //deb(cur)
        if(mapi[cur]){ 
            ind = mapi[cur];
            ok = 1;
            break;
        }
        ans += cur;
        x = cur;
        cnt++;
        //deb(x)
        mapi[x] = cnt;
        v[cnt] = x;
    }

    if(ok){
        int s = 0;
        for(int i = ind; i <= cnt; i++)
            s += v[i];
        int period = cnt - ind + 1, left = n - cnt;
        ans += (left / period) * s;
        for(int i = ind; i < ind + (left % period); i++)
            ans += v[i];

        cout << ans << endl;
    }else{
        cout << ans << endl;
    }



    
return 0;  
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5
ll ceil(ll a,ll b){
    if(a >= 0) return a/b+(a%b!=0);
    else if(a < 0) ret a/b;
    ret0;
}

void solve(){
    ll n, d;
    cin>>n>>d;
    ll a[n];
    loop(i,0,n) a[i]=i+1;
    print(ceil(n, 2*d+1));
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
   
}



Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
  a = int(input())
  A.append(a)

A_max = max(A)
max_index = A.index(A_max)
A.pop(max_index)
A_second = max(A)
for i in range(N):
  if i == max_index:
    print(A_second)
  else:
    print(A_max)

Measured memory_bytes: 12532
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();

	        long[][] ans=new long[1000][1000];
	        long t=1;
	        int cnt=0;
	        for(int i=1;N>0;i++) {
	        	N=N-i;
	        	for(int j=0;j<i;j++) {
	        		ans[i][j]=t+j;
	        		ans[j][i-1]=t+j;
	        	}
	        	t=t+i;
	        	cnt++;
	        }
	        
	        StringBuffer str = new StringBuffer();
	        if(N<0) {
	        	System.out.println("No");
	        } else {
	        	System.out.println("Yes");
	        	System.out.println(cnt+1);
	        	for(int i=0;i<cnt+1;i++) {
	        		str.append(cnt);
	        		str.append(" ");
	        		for(int j=0;j<cnt;j++) {
		        		str.append(ans[i][j]);
		        		str.append(" ");	        			
	        		}
	        		str.append("\n");	        				        		
	        	}
	        }
	        System.out.println(str);
		 }
	}

Measured memory_bytes: 49396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5+5;
pair<ll, ll>p[maxn];
ll par[maxn];
ll ans[maxn];
ll sz[maxn];

ll find(ll x)
{
	return par[x] == x ? x : par[x] = find(par[x]);
}


int n , m;	
	
int main()
{
	cin >> n >> m;
	
	for(int i = 1 ;i <=n ;i++)
	par[i] = i , sz[i] = 1;
	
	for(int i = 0 ;i<m ; i++)
	cin >> p[i].first >>  p[i].second;
	
	ll sum = 1LL *n*(n-1)/2;
	
	for(int i = m - 1 ;i >=0 ;i--)
	{
		ans[i] = sum;
		int x = find(p[i].first);
		int y = find(p[i].second);
		if(x!=y)
		{
			par[y] = x;
			sum -= sz[x]*sz[y];
			sz[x]+=sz[y];
		}
	}
	
	for(int i = 0 ;i<m;i++)
	cout << ans[i]<<endl;

	
	
}

Measured memory_bytes: 7504
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    ll cnt = 0;
    FOR(i, 0, N - 1) {
        if (S[i] != S[i + 1]) {
            cnt++;
        }
    }
    cout << min(N - 1, N - cnt + 2 * K - 1) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define make_pair MP
#define MOD 1000000007
#define MAXM 100005
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;

}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

int gcd(int a, int b, int& x, int& y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return d;
}

int arr[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string g;
    cin>>g;
    int flag=0;
    REP(i,g.length())
    {
        if((i+1)%2==0)
            {if(g[i]=='R')
            {flag=1;
            break;
            }
            }
        else
        {
            if(g[i]=='L'){
                flag=1;
                break;}
        }
    }
    if(flag==1)
        cout<<"No";
    else
        cout<<"Yes";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	
      	int res = Math.max(Math.max(a + b, a -b), a * b);
        System.out.println(res);
		
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23124
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let c = io.chars();
    let d = io.chars();
    let mut ans = true;
    for i in 0..3 {
        if c[i] != d[2 - i] {
            ans = false;
        }
    }
    io.writeln(if ans { "YES" } else { "NO" });
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2192
#include<iostream>
#include <stdio.h>

using namespace std;

int main(){

  int in_h,in_m,in_s;
  int out_h,out_m,out_s;
  int time_h,time_m,time_s;
  int time;

  while(cin >> in_h >> in_m >> in_s >> out_h >> out_m >> out_s){

    time = out_h*3600 + out_m*60 + out_s - in_h*3600 - in_m*60 - in_s;
    
    time_h=time/3600;
    time_m=time%3600/60;
    time_s=time%60;

    printf("%d %d %d\n", time_h,time_m, time_s);
    
  }
}



Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int primeCnt = 0;
		for (int i = 0; i < n; i++) {
			if (checkPrimeNumber(Integer.parseInt(br.readLine()))) primeCnt++;
		}
		System.out.println(primeCnt);
	}

	public static boolean checkPrimeNumber(int target) {
		if (target < 2) return false;
		if (target == 2) return true;
		if (target % 2 == 0) return false;

		for (int i = 3; i <= Math.sqrt(target); i++) {
			if (target % i == 0) return false;
		}
		return true;
	}
}

Measured memory_bytes: 30708
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		System.out.println((A-1)*(B-1));
		
		
	}
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;



int main(){
#ifdef LOCAL
	freopen("A_input.txt", "r", stdin);
	//freopen("A_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	ll cnt = 0;
	int i;
	for (i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			cnt++;
			i++;
		}
	}
	if (i > n - 1 || s[0] != s[n - 1]) {
		cout << cnt * k << "\n";
		return 0;
	}
	int d = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[0]) {
			d++;
		} else break;
	}
	if (d == n) {
		cout << d * (ll) k / 2 << "\n";
		return 0;
	}
	ll res = cnt * k;
	if (d % 2 == 1) {
		res += k - 1;
	}
	cout << res << "\n"; 

}


Measured memory_bytes: 256
N = int(input())
a=[]
ca =0
cb =0
cc =0
cd=0
for i in range(N):
  a.append(input())
ca = a.count('AC')
cb = a.count('WA')
cc = a.count('TLE')
cd = a.count('RE')
print('AC','x',ca)
print('WA','x',cb)
print('TLE','x',cc)
print('RE','x',cd)

Measured memory_bytes: 16188
N, A, B = [int(n) for n in input().split()]
if (B-A)%2==0:
    print((B-A)//2)
else:
    if (A-1) < (N-B):
        print(A+(B-A)//2)
    else:
        print((N-B+1)+(B-A)//2)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	string s,t,ans;
	set<int> s1;
	cin>>s>>t;
	int n1=s.length(),n2=t.length();
	int dp[n1+1][n2+1]={0};
	for(int i=0;i<=n1;i++)
	{
		for(int j=0;j<=n2;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1]){
			dp[i][j]=dp[i-1][j-1]+1;
			s1.insert(i-1);}
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n1,j=n2;
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1]){
		ans.push_back(s[i-1]);
		i--;j--;}
		else if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}
		else
		j--;
		
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
}

Measured memory_bytes: 35584
#include<iostream>
#include<stdio.h>

void Range(int a, int b, int c);

int main(){
    int a, b, c;
    
    scanf("%d %d %d",&a,&b,&c);
    Range(a, b, c);
    
    return 0;
}

void Range(int a, int b, int c){
    if(a<b && b<c) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
    ans += a.at(i);
  }
  cout << ans - N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;

//-----------------------------------------
int calc_fee(int X, int Y){
    int ans;
    ans = X + Y/2 ;
    return ans;
}

int main() {
    // I/O format
    int X,Y; cin >> X >> Y;
    int out;

    out = calc_fee(X, Y);
    cout << out << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i=0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    answer += Character.toUpperCase(ch);
                }else{
                    answer += Character.toLowerCase(ch);
                }
            }
            System.out.println(answer);
        }
    }

}


Measured memory_bytes: 31468
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int num[26];
main(){
    string s;
    cin >> s;
    for(char c:s)num[c-'a']++;
    for(int i:num)if(i%2){cout << "No" << endl;return 0;}
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def prime_factorize(n):
    n_origin=n+0
    primelist=[]
    a=2
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist
ex={}
mod=10**9+7
for i in range(2,n+1):
    res=prime_factorize(i)
    for p,e in res:
        ex[p]=ex.get(p,0)+e

ans=1
for k, v in ex.items():
    ans=(ans*(v+1))%mod
print(ans)

Measured memory_bytes: 9168
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll x,y,z,k;cin>>x>>y>>z>>k;
    vll a(x),b(y),c(z);
    rep(i,x) cin>>a[i];
    rep(i,y) cin>>b[i];
    rep(i,z) cin>>c[i];

    priority_queue<pair<ll,vll>> q;
    sort(all(a),greater<ll>());
    sort(all(b),greater<ll>());
    sort(all(c),greater<ll>());

    set<pair<ll,vll>> s;
    q.push(pair<ll,vll>(a[0]+b[0]+c[0],vll({0,0,0})));

    rep(i,k){
        auto cur = q.top();
        q.pop();
        cout<<cur.fi<<endl;

        if(cur.se[0] + 1 < x){
            ll sum = cur.fi - a[cur.se[0]] + a[cur.se[0] + 1];
            auto num =cur.se; num[0]++;
            auto d= pair<ll,vll>(sum,num);
            
            //seに同じものがある場合はスルー
            if(!s.count(d)) s.insert(d), q.push(d);
        }

        if(cur.se[1] + 1 < y){
            ll sum = cur.fi - b[cur.se[1]] + b[cur.se[1] + 1];
            auto num =cur.se; num[1]++;
            auto d= pair<ll,vll>(sum,num);
            
            //seに同じものがある場合はスルー
            if(!s.count(d)) s.insert(d), q.push(d);
        }

        if(cur.se[2] + 1 < z){
            ll sum = cur.fi - c[cur.se[2]] + c[cur.se[2] + 1];
            auto num =cur.se; num[2]++;
            auto d= pair<ll,vll>(sum,num);
            
            //seに同じものがある場合はスルー
            if(!s.count(d)) s.insert(d), q.push(d);
        }
    }

}

Measured memory_bytes: 4548
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < (limit); counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

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

}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
 
static const int N = 1000;
 
void trace(int A[], int n){
  for ( int i = 1; i <= n; i++ ){
    if ( i >1 ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}
 
main(){
  int n;
  int A[N+1];
  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> A[i];
   
  trace(A, n);
  for ( int j = 2; j <= n; j++ ){
    int key = A[j];
    int i = j - 1;
    while( i > 0 && A[i] > key ){
      A[i+1] = A[i];
      i--;
    }
    A[i+1] = key;
 
    trace(A, n);
  }
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<pair<int, int>> x(100), y(100);
	int i;
	int n, m, o, t, h ;
	o = t = h = 10;
	cin >> n >> m;
	vector<int> s(m), c(m);
	for(i = 0; i < m; ++i) {
		cin >> s.at(i) >> c.at(i);
		if(n == 1 && c.at(i) == 0) {
			cout << 0 << endl;
			return 0;
		}
		(s.at(i) == 1 ? o = min(o, c.at(i)) : 
			(s.at(i) == 2 ? t = min(t, c.at(i)) : h = min(h, c.at(i))));
		x.at(s.at(i)).first += 1;
		if(x.at(s.at(i)).first > 0 && c.at(i) == x.at(s.at(i)).second) {
			x.at(s.at(i)).first -= 1;
			x.at(s.at(i)).second = c.at(i);
		}
		if(x.at(s.at(i)).second == 0)
			x.at(s.at(i)).second = c.at(i);
		else if(x.at(s.at(i)).second != c.at(i)) {
			cout << "-1" << endl;
			return 0;
		}
		if(s.at(i) == 1 && c.at(i) == 0||(x.at(s.at(i)).first != 0 && x.at(s.at(i)).second != c.at(i))) {
			cout << "-1" << endl;
			return 0;
		}
		if(x.at(s.at(i)).second == c.at(i))
			x.at(s.at(i)).first = 1;
	}
	if(o == 10) {
		o = 1;
		if(n == 1)
			o = 0;
	}
	if(t == 10)
		t = 0;
	if(h == 10)
		h = 0;
	cout << o;
	if(n == 2)
		cout << t;
	if(n == 3)
		cout << t << h;
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	if (S=="Sunny")
	{
		cout << "Cloudy";
	}
	else if (S=="Cloudy")
	{
		cout << "Rainy";
	}
	else
	{
		cout << "Sunny";
	}
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

vector <LL> G[200005];
LL n,m,mxd = 0,cnt = 0,c1 = 0,c2 = 0,flg = 0;
LL deg[200005] = {0};
LL vis[200005] = {0};

void dfs(LL u,LL f){
	vis[u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		if(v == c1 && f != c1) flg = 1;
		if(v == c2 || vis[v]) continue;
		dfs(v,u);
	}
}

int main(){
	ios::sync_with_stdio(false);
	LL u,v;
	cin >> n >> m;
	for(LL i = 1;i <= m;i ++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
		deg[u] ++; deg[v] ++;
	}
	for(LL i = 1;i <= n;i ++){
		if(deg[i] & 1){
			cout << "No" << endl;
			return 0;
		} 
		if(deg[i] == 4){
			cnt ++;
			if(!c1) c1 = i;
			else c2 = i;
		}
		mxd = max(mxd,deg[i]);
	}
	if(mxd >= 6){ cout << "Yes" << endl; return 0; }
	if(mxd <= 2){ cout << "No" << endl; return 0; }
	if(cnt >= 3){ cout << "Yes" << endl; return 0; }
	if(cnt <= 1){ cout << "No" << endl; return 0; }
	
	dfs(c1,0);
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 11648
package main

import "fmt"

func main() {

	var N int
	var S, T string
	fmt.Scanf("%d", &N)
	fmt.Scanf("%s %s", &S, &T)

	for i := 0; i < N; i++ {

		fmt.Printf("%c%c", S[i], T[i])
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
typedef long long ll;

int main()
{
    int S, W;
    cin >> S >> W;
    if (S <= W)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<climits>
#define req(i,n) for(int i=0; i<(n); i++)
using namespace std;

int count=0;


void merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];


	//cout << n1 << ' ' << n2 << endl;
	req(i,n1)
		L[i] = A[left + i];
	req(i,n2)
		R[i] = A[mid + i];
		
	L[n1] = R[n2] = INT_MAX;
	
	int i,j;
	i = j = 0;
	for(int k=left; k<right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
			count++;
		}	
		else{
			A[k] = R[j];
			j++;
			count++;
		}
	}
}

void mergesort(int A[],int left, int right)
//分割する役割(mergeにより結合)
{
	if(left + 1 < right){
		int mid = (left + right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A, left, mid, right);
	}			
}

int main()
{
	int n;
	cin >> n;
	int S[n];
	req(i,n)
		cin >> S[i];
	/*req(i,n)
		cout << S[i];
	cout << endl;
	*/
	mergesort(S,0,n);

	req(i,n){
		if(i==n-1)
			cout << S[i];
		else
			cout << S[i] << ' ';
	}
	cout << endl;
	cout << count << endl;
}


Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

vector <pair<ll, ll>> prime_factorize(ll n){
    vector <pair<ll,ll>> res;
    for(ll i=2;i*i<n;++i) {
        if(n%i!=0) continue;
        ll sum=0;
        while(n%i==0) {
            ++sum;
            n/=i;
        }
        res.push_back(make_pair(i,sum));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

ll gcd(ll x, ll y) {
    if(x%y==0) return y;
    else return gcd(y,x%y);
}

int main() {
    ll a,b;
    cin >> a>> b;
    ll x=gcd(a,b);
    auto pf=prime_factorize(x);
    cout << pf.size()+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

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

    string s;
    int p;
    vector<tuple<string, int, int>> l;
    for(int i = 0; i < n; i++){
        cin >> s >> p;
        l.emplace_back(s, p, i+1);
    }
    sort(l.begin(), l.end(), [](tuple<string, int, int> const& el, tuple<string, int, int> const& er){
        if(get<0>(el) != get<0>(er)) return get<0>(el) < get<0>(er);
        else return get<1>(el) > get<1>(er);
    });
    for(auto a : l){
        cout << get<2>(a) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
## for use in beginner level questions where speed is key
## and also for single test case code
## mastercopy for x,y,z

import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict

# read line as a string
# strr = input()

# read line as an integer
k = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer
# arr = list(map(int,input().split()))

if k == 1:
    print(0)
    sys.exit()

# if k == 2:
#     print(2)
#     sys.exit()

res = 0
MOD = 10**9 + 7

have_all = pow(10,k,MOD)
dont_have_0 = pow(9,k,MOD)
dont_have_9 = pow(9,k,MOD)
dont_have_09 = pow(8,k,MOD)

print((have_all - dont_have_0 - dont_have_9 + dont_have_09) % MOD)


Measured memory_bytes: 76772
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int sum=700;
    for (int i=0;i<3;i++) {
        if (s.at(i)=='o') {
            sum+=100;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    ll n;
    cin>>n;
    vector<pair<ll,ll>> a;

    for(ll i=0;i<n;i++){
        ll b=0;
        cin>>b;
        a.push_back(make_pair(b,i));
    }

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

    ll count=0;
    ll all=0;

    vector<ll> num;

    for(ll i=0;i<n-1;++i){
        count++;
        if(a[i].first!=a[i+1].first){
            num.push_back(count-1);
            all+=(count*(count-1))/2;
            count=0;
        }
    }
    all+=(count*(count+1))/2;
    num.push_back(count);

    vector<pair<ll,ll>> ans;
    ll z=0;
    ll c=0;
    for(ll i=0;i<n;i++){
        ans.push_back(make_pair(a[i].second,all-num[z]));
        c++;
        if(c==num[z]+1){
            z++;
            c=0;
        }
    }

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

    for(ll i=0;i<n;i++){
        cout<<ans[i].second<<endl;
    }


    
  
    return 0;
}


Measured memory_bytes: 14700
import Control.Monad
import Data.Bool
import Data.List
import Data.Maybe

main = sol <$> get >>= print

get = map (map read . words) . lines <$> getContents

sol ([w,h,_]:ps) = maybe 0 area $ foldl' f (Just (0,w,0,h)) ps

area (l,r,b,t) = (r-l)*(t-b)

f Nothing _ = Nothing
f (Just (l,r,b,t)) [x,y,a]
  | a == 1    = bool Nothing (Just (max l x,r,b,t)) (x < r)
  | a == 2    = bool Nothing (Just (l,min r x,b,t)) (l < x)
  | a == 3    = bool Nothing (Just (l,r,max b y,t)) (y < t)
  | a == 4    = bool Nothing (Just (l,r,b,min t y)) (b < y)
  | otherwise = Nothing

Measured memory_bytes: 1020
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

struct item{
    long long value;
    int weight;
};

int n, k;
item meh[105];
long long DP[100005];

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d %lld", &meh[i].weight, &meh[i].value);
    for(int i = 1; i <= n; i++){
        for(int j = k; j >= meh[i].weight; j--){
            DP[j] = max(DP[j], DP[j - meh[i].weight] + meh[i].value);
        }
    }
    long long ans = 0;
    for(int i = 0; i <= k; i++) ans = max(ans, DP[i]);
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
	char s[4];
	cin>>s;
	int sb[4]={0,1,2,3};
	for(int i=0;i<3;i++) {
		if(i!=0){
			if(sb[i]>sb[i-1]+1){
				sb[i]=sb[i-1]+1;
			}
		}
		for(int j=i+1;j<4;j++){
			if(s[i]==s[j]) sb[j]=sb[i];
		}
	}
	int a=0,b=0;
	for(int i=0;i<4;i++) {
		if(sb[i]==0) a++;
		else if(sb[i]==1) b++;
	}
	if(a==2&&b==2) cout<<"Yes";
	else cout<<"No";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    while (1) {
        int N,M; cin >> N >> M;
        if (N == 0) return 0;
        vector<P> DP(N);
        rep(i,N) cin >> DP[i].first >> DP[i].second;
        sort(DP.begin(),DP.end(),[](P x,P y){return x.second > y.second;});
        int ans = 0;
        rep(i,N) {
            if (M == 0) ans += DP[i].first * DP[i].second;
            else if (M - DP[i].first >= 0) M -= DP[i].first;
            else {
                DP[i].first -= M;
                M = 0;
                ans += DP[i].second * DP[i].first;
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 3192