akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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


int main() {
	int a, b;
	cin >> a >> b;

	if (a >= 13) {
		ANS(b);
	}
	else if (a <= 5) {
		ANS(0);
	}
	else {
		ANS(b/2)
	}
	
	return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    long sum = 0;
    for (int i=1;i<=k;i++){
      int a = i;
      int b = k-i;
      if ((((2*b) % k) != 0) || (b > n) || (b < 0)){
        continue;
      }
      if (b == 0){
        b = a;
      }

      sum += (long) ((long) find(a,n,k)) *((long) find(b,n,k))*((long) find(b,n,k));
    }

    System.out.println(sum);


  }

  static int find(int start, int n, int k){

    int count = 0;
    while(start <= n){
      start += k;
      count += 1;
    }
    return count;
  }
}


Measured memory_bytes: 35784
function Main(s){
  s = s.split(" ").map(a=>+a);
  var n = s[0];
  var a = s[1];
  var b = s[2];
  var k = s[3];
  var ans = 0;
  for(var i = 0; i <= n; i++){
    var x = k - i * a;
    if(x < 0)break;
    if(x % b === 0 && x / b <= n){
      ans += abmod(nCrmod(n, i), nCrmod(n, x / b));
      ans %= mod;
    }
  }
  console.log(ans);
}
function abmod(){
  var rt = arguments[0];
  for(var i = 1; i < arguments.length; i++){
    rt = (rt >>> 16) * arguments[i] % mod * 0x10000 + (rt & 0xFFFF) * arguments[i];
    rt %= mod;
  }
  return rt;
}
function powmod(a,n){
  var rt = 1;
  while(n){
    if(n & 1) rt = abmod(a, rt);
    a = abmod(a, a);
    n >>>= 1;
  }
  return rt;
}
var mod = 998244353;
var fact = [1,1];
var factinv = [1,1];
function factmod(n){
  for(var i = fact.length; i <= n; i++){
    fact[i] = abmod(fact[i-1], i);
  }
  return fact[n];
}
function factinvmod(n){
  if(!fact[n]) factmod(n);
  factinv[n] = powmod(fact[n], mod-2);
  while(!factinv[n-1]){
    factinv[n-1] = abmod(factinv[n], n--);
  }
}
function nCrmod(n, r){
  if(!factinv[n]) factinvmod(n);
  return abmod(fact[n], factinv[r], factinv[n-r]);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool W = 1;
  if(S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)){
    cout <<"Yes" << endl;
    W = 0;
  }
  if(S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(3)){
    cout << "Yes" << endl;
  W = 0;
  }
  if(S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1)){
    cout << "Yes" << endl;
  W = 0;
  }
  if(W)cout << "No" << endl;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int n2 = 1; n2 <= n; n2++){
        int lim = sqrt(n2) + 1;
        int ans = 0;
        for(int i = 1; i <= lim; i++){
            for(int j = 1; j <= lim; j++){
                for(int k = 1; k <= lim; k++){
                    ans += i * i + j * j + k * k + i * j + j * k + k * i == n2;
                }
            }
        }
        cout << ans << '\n';
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

string S, T;

bool solve() {
    REP (i, S.size()) {
        if (S[i] != T[i]) return false;
    }
    return true;
}

int main() {
    cin >> S >> T;
    Yes(solve());
}

Measured memory_bytes: 3628
import math
if __name__=='__main__':
    flag=0
    n=int(input())
    for i in range((int(math.sqrt(n)))):
        if n%(i+1)==0:
            if len(str(i+1))==1 and len(str(n//(i+1)))==1:
                flag=1
                break
    if flag==1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  long long int n,w,temp1,temp2;
  cin>>n>>w;
  long long int arr[n][2];
  for(int i=0;i<n;i++){
      cin>>temp1>>temp2;
      arr[i][0]=temp1;
      arr[i][1]=temp2;
  }
  long long dp[n][w+1];
  for(int i=0;i<n;i++){
      for(int j=0;j<=w;j++){
          if(arr[i][0]<=j){
              if(i<1){
                  dp[i][j]=arr[i][1];
                  continue;
              }
              dp[i][j] = max(dp[i-1][j-arr[i][0]]+arr[i][1], dp[i-1][j]);
          }else{
              if(i<1){
                dp[i][j]=0;
                continue;
              }
              dp[i][j]=dp[i-1][j];
          }
      }
  }
//   int max=0;
//   for(int i=0;i<=w;i++){
//       //cout<<dp[n-1][i]<<" ";
//       if(dp[n-1][i]>max){
//           max=dp[n-1][i];
//       }
//   }
  cout<<dp[n-1][w]<<endl;
}


Measured memory_bytes: 78336
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
a = [ A[i] - (i+1) for i in range(N)]
c = Counter(a)
count = 0
for i in range(N-1):
  count += c[-1*(A[i] + (i+1))]
  c[A[i]-(i+1)] -= 1
print(count)
  

        


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

using namespace std;

int main() {
	int A, B, T;
	cin >> A >> B >> T;
	int count = T / A * B;
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int n;
char s[maxn];
int ans;

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n-2;i++)
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double ax = scn.nextDouble();
        double ay = scn.nextDouble();
        double bx = scn.nextDouble();
        double by = scn.nextDouble();

        double A = Math.abs(ax-bx);
        double B = Math.abs(ay-by);
        double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2));

        System.out.printf("%.8f%n",C);


        scn.close();

    }

}


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

int main(){
    int a, b;
    cin >> a >> b;
    
    string ans = "Impossible";
    
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        ans = "Possible";
    }
    
    cout << ans << endl;
    return 0;
}


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

//?????????????????¨????§???????
typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P ret = Q[head];
	head = (head + 1) % LEN;
	return ret;
}

int main()
{
	//??????????????°
	int n;

	//???????????????
	int q;

	cin >> n;
	cin >> q;

	for (int i = 1; i <= n; i++){
		cin >> Q[i].name;
		cin >> Q[i].t;
	}

	head = 1;
	tail = n + 1;

	//????????????
	int elaps = 0;

	//sim
	while (tail != head){
		P u = dequeue();

		//??°????°?????????????????????¨
		int c = min(u.t, q);

		//?????????????¨????
		u.t -= c;

		//?????????????????????
		elaps += c;

		if (u.t > 0){
			enqueue(u);
		}
		else {
			cout << u.name << ' ' << elaps << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 13248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        var mojis = new List<char>() { 'A', 'C', 'G', 'T' };
        var ls = new List<int>();
        var count = 0;
        for (var i = 0; s.Length > i; i++)
        {
            if (mojis.Contains(s[i])) count++;
            else
            {
                ls.Add(count);
                count = 0;
            }
        }
        ls.Add(count);
        Console.WriteLine(ls.Max());
    }
}

Measured memory_bytes: 26508
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,l;
    cin>>n>>l;
    vec a(n);
    int ok=0;
    int sum=0;
    int idx;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        if(i!=0){
            if(a[i-1]+a[i]>=l){
                ok++;
                idx=i;
            }
        }
    }
    if(ok==0){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    vec ans;
    for(int i=idx;i<n;i++){
        ans.pb(i);
    }
    for(int i=idx-1;i>=1;i--){
        ans.pb(i);
    }
    reverse(all(ans));
    for(auto x:ans){
        cout<<x<<" ";
    }cout<<endl;

    
}

Measured memory_bytes: 2548
N,M = map(int,input().split())
 
s = []
g = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)
    
ans = set(s) & set(g)
 
if len(ans) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 21956
#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;
main(){
	int i=0,n,a,b,s=0;
	vector<pair<int,int> >v;
	for(scanf("%d",&n);i<n;i++)scanf("%d%d",&a,&b),v.push_back(make_pair(b,a));
	sort(v.begin(),v.end());
	priority_queue<int>q;
	for(i=0;i<n;i++){
		s+=v[i].second;
		q.push(v[i].second);
		if(s>v[i].first)s-=q.top(),q.pop();
	}
	printf("%d\n",q.size());
}

Measured memory_bytes: 1052
//0614 B問題
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {

  int x, y, i=0, k;

  scanf("%d%d", &x, &y);

  if ((x<1)||(100<x)||(y<1)||(100<y)) {
    return -1;
  }

  while (i<=x) {
    k = y-i*2;
    if (k-(4*(x-i))==0) {
      printf("Yes\n");
      return 0;
    } else {
      i++;
    }
  }
  printf("No\n");

  return 0;
}


Measured memory_bytes: 1656
N, P = map(int, input().split())
S = input()
ans = 0
C = [0] * P
C[0] = 1
a = 0
if P in (2, 5):
    print(sum([i+1 for i, s in enumerate(S) if int(s) % P == 0]))
    exit()
    
for i, s in enumerate(S[::-1]):
    a = (a + int(s) * pow(10, i, P)) % P
    ans += C[a]
    C[a] += 1
print(ans)

Measured memory_bytes: 48076
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 2e5+10;
int a[N];

int main(){
	int n;
	scanf("%d", &n);
	LL sum2 = 0, sum1 = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum2 += a[i];
	}
	LL ans = 1e18;
	for(int i = 1; i < n; i++){
		sum1 += a[i];
		sum2 -= a[i];
		ans = min(ans, abs(sum1 - sum2));
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] lr = new int[m][2];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < 2; j++){
                lr[i][j] = scan.nextInt();
            }
        }
        boolean b = true;
        int out = 0;
        int min = lr[0][0];
        int max = lr[0][1];
        for(int i = 1; i < m; i++){
            if(lr[i][0] > min){
                min = lr[i][0];
            }
        }
        for(int i = 1; i < m; i++){
            if(lr[i][1] < max){
                max = lr[i][1];
            }
        }
        for(int i = 1; i <= n; i++){
            a : for(int j = 0; j < m; j++){
                if(min > i || max < i){
                    b = false;
                    break a;
                }
            }
            if(b){
                out++;
            }
            b = true;
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 87060
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int a;
	int b;
	int c;
}GROUP;

int cmp( const void *p, const void *q ) {
    return ((GROUP*)q)->c - ((GROUP*)p)->c;
}

int main(void){

	int n, i;
	long ans = 0;

	scanf("%d", &n);

	GROUP group[n];
	
	for(i = 0; i < n; i++){
		scanf("%d %d", &group[i].a, &group[i].b);
		group[i].c = group[i].a + group[i].b;
	}

	qsort(group, n, sizeof(GROUP), cmp);

	for(i = 0; i < n; i++){
		if(i % 2 == 0){
			ans += group[i].a;
		}else{
			ans -= group[i].b;
		}
	}

	printf("%ld",ans);

	return 0;
}

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

int main(){
  int x,y;
  cin>>x>>y;
  vector<int>A={1,3,5,7,8,10,12};
  vector<int>B={4,6,9,11};
  bool f=false;
  
  for(int i=0;i<5;i++){
      for(int j=i+1;j<6;j++){
        if(A[i]==x&&A[j]==y)
          f=true;
      }
  }
  for(int i=0;i<3;i++){
      for(int j=i+1;j<4;j++){
        if(B[i]==x&&B[j]==y)
          f=true;
      }
  }
  if(f)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>

using namespace std;

#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define LOG(log) cout<<#log<<" : "<<log<<endl;
#define DEBUG() {cout<<"DEBUG "<<num_debug<<endl; num_debug++;}
char num_debug = 0;

int compare_int(void* a, void* b);
class Math {
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};

int main(void) {
	srand((unsigned)time(NULL));

	int D;
	int** s, * t, * v;
	int c[26];
	int last[26];
	cin >> D;

	//alloc
	t = (int*)calloc(D, sizeof(int));
	s = (int**)calloc(D, sizeof(int*));
	for (int i = 0; i < D; i++) {
		s[i] = (int*)calloc(26, sizeof(int));
	}
	v = (int*)calloc(D, sizeof(int));

	//ini
	for (int i = 0; i < D; i++) {
		v[i] = 0;
	}
	for (int i = 0; i < 26; i++) {
		last[i] = 0;
	}
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	for (int i = 0; i < D; i++) {
		scanf("%d", &t[i]);
	}

	//ope
	for (int i = 0; i < D; i++) {
		if (i != 0)
			v[i] = v[i - 1];

		v[i] += s[i][t[i] - 1];
		last[t[i] - 1] = i + 1;
		//LOG(t[i] - 1);
		for (int j = 0; j < 26; j++) {
			v[i] -= c[j] * (i + 1 - last[j]);
			//LOG(j);
		}
		cout << v[i] << '\n';
	}

	free(t);
	free(v);
	for (int i = 0; i < D; i++)
		free(s[i]);
	free(s);
	return 0;
}

int compare_int(void* a, void* b) {
	return *(int*)a;
}


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

using namespace std;

template <typename T>
T lcs(T s, T t) {
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  for (int i = 0; i < (int)s.size(); i++) {
    for (int j = 0; j < (int)t.size(); j++) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
    }
  }
  T res;
  int i = (int)s.size(), j = (int)t.size();
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else {
      i--, j--;
      res.push_back(s[i]);
    }
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T;
  cin >> S >> T;
  cout << lcs(S, T) << '\n';
  return 0;
}


Measured memory_bytes: 35584
while true do
  n = gets.to_i
  exit if n == 0
  as = 0
  bs = 0
  for i in 1..n do
    a, b = gets.split.map {|item| item.to_i}
    if a > b then
      as += a + b
    elsif a < b then
      bs += a + b
    else
      as += a
      bs += b
    end
  end
  puts as.to_s + " " + bs.to_s
end

Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();

        if (S.equals(T.substring(0,S.length()))) {
            String ID = T.substring(S.length());
            if (ID.length() != 1) {
                System.out.println("No");
                System.exit(0);
            }
            System.out.println("Yes");
         } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  string s;
  cin >> s;
  int red = 0;
  for(auto au : s)if(au == 'R')red++;
  int cnt = 0;
  rep(i,red)if(s[i] == 'W')cnt++;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3744
#include<stdio.h>
int main(void){
	int a,b,cnt,i;

	while(scanf("%d %d",&a,&b)!=EOF){
	a+=b;
	cnt=0;
	for(i=1;;i*=10){
		if(a-i<0){
			printf("%d\n",cnt);
			break;
		}
		cnt++;
		
	}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int n,t[300010];
void update(int x){while(x<=n)++t[x],x+=x&-x;}
int query(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
ll getinv(std::vector<int>&A){
	memset(t,0,sizeof t);
	ll ret=0;
	for(int i=A.size()-1;~i;--i)ret+=query(A[i]),update(A[i]);
	return ret;
}
void myassert(bool o){if(!o)puts("No"),exit(0);}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi();
	std::vector<int>A(n),B,C;for(int i=0;i<n;++i)A[i]=gi();
	for(int i=0;i<n;++i)myassert(A[i]+i&1);
	for(int i=0;i<n;++i)(i&1?B:C).push_back(A[i]);
	myassert((getinv(B)+getinv(C))*3==getinv(A));
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s;
    cin>>n>>s;
    int a=0,b=0;
    rep(i,n){
        if(s[i]=='(')a++;
        if(s[i]==')'&&a>0){a--;}
        else if(s[i]==')'&&a==0)b++;
    }
    string t,u;
    if(a>0)t=string(a,')');
    if(b>0)u=string(b,'(');
    if(a>0)s+=t;
    if(b>0)s=u+s;
    cout<<s<<endl;
}

Measured memory_bytes: 384
//config = {input: 'tmp', newline: '\r\n'}; // win
config = {input: '/dev/stdin', newline: '\n'}; //linux

stack = [];
require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(' ')
  .forEach(function (symbol) {
    if (symbol === '+') stack.push(stack.pop() + stack.pop());
    else if (symbol === '-') stack.push(-stack.pop() + stack.pop());
    else if (symbol === '*') stack.push(stack.pop() * stack.pop());
    else stack.push(parseInt(symbol, 10));
});

console.log(stack[0]);

Measured memory_bytes: 15756
#include <iostream>

using namespace std;
char m[55][55];

bool isok(int x, int y) {
	if (m[x][y + 1] == '#' || m[x][y - 1] == '#' || m[x + 1][y] == '#' || m[x - 1][y] == '#')
		return true;
	return false;
}

int main()
{
	int h, w;
	memset(m, 0, sizeof(m));
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> m[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!isok(i, j) && m[i][j] == '#') {
				cout << "No" << endl;
				//cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

count = 0

for i in range(N):
    for j in range(i+1,N):
        d = 0
        for x, y in zip(X[i], X[j]):
            d += (x-y)**2
        d = math.sqrt(d)
        if d - int(d) == 0:
            count += 1
        d = 0

print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    H, W, K = Scanner.map_int()
    S = Scanner.string_list(H)
    ans = int(1e15)
    for i in range(1 << (H - 1)):
        cut = 0
        pc = 1
        whites = [[0 for _ in range(W)] for _ in range(H)]
        for j in range(H - 1):
            for w in range(W):
                whites[cut][w] += S[j][w] == '1'
            if i >> j & 1:
                cut += 1
                pc += 1
        for w in range(W):
            whites[cut][w] += S[-1][w] == '1'
        flag = True
        for line in whites:
            for cnt in line:
                if cnt > K:
                    flag = False
        if not flag:
            continue
        cnt = [0 for _ in range(pc)]
        for w in range(W):
            flag = True
            for j in range(pc):
                if cnt[j] + whites[j][w] > K:
                    flag = False
            if not flag:
                cnt = [0 for _ in range(pc)]
                cut += 1
            for j in range(pc):
                cnt[j] += whites[j][w]
        ans = min(ans, cut)
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

bool check(string s)
{
    if(s.length()%2!=0)
        return false;
    ll m=s.length()/2;
    string s1,s2;
    for(int i=0;i<m;i++)
        s1+=s[i];
    for(int i=m;i<s.length();i++)
        s2+=s[i];
    if(s1==s2)
        return true;
    else
        return false;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll x=s.length();
    while(x--)
    {
        s=s.substr(0,s.length()-1);
        if(check(s)==true)
        {
            cout<<s.length()<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, K, dp[301][301][301];
string s;

int rec(int i, int j, int k){
	int &res = dp[i][j][k];
	if(res >= 0) return res;
	res = 0;
	
	if(i > 0) res = max(res, rec(i - 1, j, k));
	if(j < n) res = max(res, rec(i, j + 1, k));
	if(i > 0 && j < n){
		int nk = k - (s[i - 1] != s[j]);
		if(nk >= 0) res = max(res, 1 + rec(i - 1, j + 1, nk));
	}
	return res;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> s >> K;
	n = s.size();
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	rep(i, n + 1) ans = max(ans, 2 * rec(i, i, K));
	rep(i, n) ans = max(ans, 2 * rec(i, i + 1, K) + 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 106752
def factorial(n, mod=10**9+7):
    a = 1
    for i in range(1,n+1):
        a = a * i % mod
    return a

def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod=10**9+7):
    if n < k or k < 0:
        result = 0
    else:
        a = factorial(n, mod=mod)
        b = factorial(k, mod=mod)
        c = factorial(n-k, mod=mod)
        result = (a * power(b, mod-2, mod=mod) * power(c, mod-2, mod=mod)) % mod
    return result

n, k = map(int, input().split())
k = min(n, k)
MOD = 10**9 + 7
fl = [-1]*(n+1)
fl[0] = 1
def f(i):
  global fl
  if fl[i] > 0: return fl[i]
  else:
    res = f(i-1)*(n-i+1)*(n-i)
    t = power(i, MOD-2)
    res *= t**2
    res %= MOD
    fl[i] = res
    return res

if k <= n//2:
  ans = 0
  for i in range(k+1):
    ans += f(i)
    ans %= MOD
else:
  fl[k] = comb(n, k) * comb(n-1, k) % MOD
  ans = 0
  for i in range(k+1, n+1):
    ans += f(i)
    ans %= MOD
  ans = comb(2*n-1, n) - ans
  ans %= MOD

print(ans % MOD)

Measured memory_bytes: 6188
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

int A[100];
int main(void) {
 
    int n,x;
    scanf("%d %d",&n,&x);
    int i = 0;
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    int count =0;
    int now =0;
    for(i=0;i<n;i++){
        if((now+A[i])<=x){
            now+=A[i];
            count++;
        }
        else
            i = n;
    }
    printf("%d",count+1);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	char x,y; cin>>x>>y;
	if(x>y){
		cout<<">"<<endl;
	}
	else if(x<y){
		cout<<"<"<<endl;
	}
	else if(x==y){
		cout<<"="<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B, C, K = MI()
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(A - (K - (A + B)))

Measured memory_bytes: 61864
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let a: Vec<f64> = (0..n).map(|_| read()).collect();

    let mut ans: f64 = 0.0;
    for i in a {
        ans += 1.0 / i;
    }

    println!("{}", 1.0 / ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    int input;
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int N;
    cin>>N;
    ll* arr = new ll[N];
    ll ans=0;
    for(int i=0;i<N;i++){
        cin>>arr[i];
    }
    sort(arr,arr+N);
    ans+=arr[N-1];
    for(int i=1,j=N-2;i<=N-2;i++){
        ans+=arr[j];
        if(i%2==0)
            j--;
    }
    cout<<ans<<endl;
}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1e9;

vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vector<string> maze;
int h, w;

int solve(int sx, int sy) {
  if(maze[sx][sy]=='#')
    return -1;
  vector<vector<int>> d(h, vector<int>(w, INF));
  queue<P> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      d[i][j] = -INF;
    }
  }
  que.push(P(sx, sy));
  d[sx][sy] = 0;
  while (que.size()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#' &&
          d[nx][ny] == -INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  int maxi = -INF;
  for (int i = 0; i < h; i++) {
    maxi = max(maxi, *max_element(all(d[i])));
  }
  return maxi;
}

int main() {
  cin >> h >> w;
  maze.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> maze[i];
  }
  int ans = -INF;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
listA = list(map(int,input().split()))

S = Counter(listA)

##key##
key = S.keys()
out = 0
for i in key:
  out = out + S[i] * (S[i]-1) /2

for i in listA:
  test = out - S[i] * (S[i]-1) /2 + (S[i] -1) * (S[i]-2) /2
  print(int(test))

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000

int main() {
  
  int N;
  string S, T;
  char ans[300] = {0,};

  cin >> N;
  cin >> S >> T;

  REP(i, N){
      ans[2*i] = S[i];
      ans[2*i+1] = T[i];
  }
  REP(i, 2*N){
        cout << ans[i];
  }

  cout << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
	long long H,N;
	cin >> H >> N;
	long long sum = 0;
	int A;
	rep(i,N){
		cin >> A;
		sum += A;
	}
	cout << (H <= sum ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll D, N;
  std::cin >> D >> N;

  ll x = std::pow(100, D);
  ll n = N;
  ll cnt = 0;
  while (n > 0) {
    cnt++;
    x = std::pow(100, D) * cnt;
    if (cnt % 100 == 0) continue;
    n--;
  }

  print(x);

  return 0;
}


Measured memory_bytes: 256
import sys


if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                print(k, j, i)
                sys.exit()
    print(-1, -1, -1)

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,taro=0,hanako=0;
    char t[100],h[100];
    string tarostr,hanakostr;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",&t,&h);
        tarostr=t;
        hanakostr=h;
        if(tarostr==hanakostr){
            taro++;
            hanako++;
        }else if(tarostr<hanakostr){
            hanako+=3;
        }else{
            taro+=3;
        }
    }
    printf("%d %d\n",taro,hanako);
    return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n, m, dgr[N], S=0, T=0, cnt=0;
struct edge{
	int v, nxt;
}g[N<<1];
int tot=0, head[N];
inline void add(int u, int v){
	g[++tot]=edge{v,head[u]}; head[u]=tot;
	g[++tot]=edge{u,head[v]}; head[v]=tot;
}
inline void dfs(int u, int fa){
	if(u==S&&fa)return;
	if(u==T){
		++cnt; return;
	}
	for(int i=head[u]; i; i=g[i].nxt)if(g[i].v!=fa)dfs(g[i].v,u);
}
int main(){
	scanf("%d%d", &n, &m);
	if(m<n+2){
		puts("No"); return 0;
	}
	for(int i=1; i<=m; ++i){
		int u, v; scanf("%d%d", &u, &v);
		add(u,v); dgr[u]++; dgr[v]++;
	}
	for(int i=1; i<=n; ++i)
		if(dgr[i]&1){
			puts("No"); return 0;
		} 
	for(int i=1; i<=n; ++i)
		if(dgr[i]>=6){
			puts("Yes"); return 0;
		} else if(dgr[i]==4){
			if(!S)S=i;else if(!T)T=i;else{
				puts("Yes"); return 0;
			}
		}
	dfs(S,0);
	puts(cnt==4?"No":cnt==2?"Yes":"");
	return 0;
}
/*
6 8
1 3
3 2
1 4
4 2
1 5
5 2
1 6
6 2
*/

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,m;

int main(void){
	cin>>n>>m;
	if(n%2==1){
		rep(i,m)cout<<i+1<<" "<<n-i<<endl;
	}else{
		rep(i,min(m,n/4))cout<<i+1<<" "<<n/2-i<<endl;
		m-=n/4;
		if(m>0){
			rep(i,m)cout<<i+n/2+2<<" "<<n-i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int mod =1000000007;

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

	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<int> nums(n);
	long long ans = 1;
	for (auto x: a) {
		if (nums[x] >= 3) {
			ans = 0;
			break;
		}

		if (x == 0) {
			ans = ans * (3 - nums[x]) % mod;
			nums[x]++;
			continue;
		}

		if (nums[x-1] == 0) {
			ans = 0;
			break;
		}

		ans = ans * (nums[x-1] - nums[x]) % mod;
		nums[x]++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 T;
  cin >> T;
  while (T--)
  {
    i64 N;
    cin >> N;
    vector<i64> A(N);
    for (i64 i = 0; i < N; i++)
      cin >> A[i];
    string S;
    cin >> S;
    vector<i64> b;
    for (i64 i = N; 0 <= i; i--)
    {
      i64 x = A[i];
      for (i64 j : b)
        x = min(x, j ^ x);
      if (x != 0)
      {
        if (S[i] == '1')
        {
          cout << "1" << endl;
          goto fin;
        }
        b.push_back(x);
      }
    }
    cout << "0" << endl;
  fin:;
  }
  return 0;
}


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


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

  int N, M;
  cin >> N >> M;
  int A[N];
  rep(i,N) cin >> A[i];
  rep(i,N) A[i] = A[i]/2;

  int ans = 1;
  rep(i,N){
    ans = ans * A[i] / __gcd(ans,A[i]);
    if(ans > M){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=0;i<N;i++){
    if((ans/A[i]) % 2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  cout << ((M/ans)+1)/2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  string ret;
  if (S == "Sunny") {
	ret = "Cloudy";
  } else if (S == "Cloudy")  {
    ret = "Rainy";
  } else if (S == "Rainy") {
    ret = "Sunny";
  }
  cout << ret << endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    string s;
    cin >> s;
    rep(i, 3) {
        if(s[i] == '1') cout << 9;
        else cout << 1;
    }
    cout << endl;
    
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

int main() {
	int ans = 0, sum = 0;
	size_t N, right = 0;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) cin >> x;
	sort(a.begin(), a.end());
	for (size_t left = 0; left < N; ++left) {
		while (right < N && a[right] - a[left] < 3) {
			++sum;
			++right;
		}
		ans = max(ans, sum);
		if (left == right) ++right;
		else --sum;
	}
	cout << ans;
}

Measured memory_bytes: 640
#n = int(input())
n,m = map(int,input().split())
#a_L = list(map(int,input().split()))
s_L,c_L = [],[]

for _ in range(m):
    s,c = map(int,input().split())
    s_L.append(s-1)
    c_L.append(c)

ans = 10000
for i in range(0,703):
    tmp =list(str(i)) 
    flag = []
    for j in range(m):
        
        try:
            if tmp[s_L[j]] == str(c_L[j]):
                flag.append(True)
            else:
                flag.append(False)
        except:
            pass
    if all(flag) and len(tmp)==n:
        ans = min(i,ans)

if ans == 10000:
    print(-1)
else:
    print(ans)

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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      A-=A%2;
      B+=A/2;
      A/=2;
    }else{
      B-=B%2;
      A+=B/2;
      B/=2;
    }
  }
  cout<<A<<' '<<B<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,d; 
int main(){
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;++i){
		if(s[i]=='W')a++;
		if(s[i]=='E')b++;
		if(s[i]=='N')c++;
		if(s[i]=='S')d++;
	}
	if((a==0&&b!=0)||(a!=0&&b==0)||(c==0&&d!=0)||(c!=0&&d==0))cout<<"No";
	else cout<<"Yes";
} 

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define inf 6000000000000000000
#define norm 0
#define mod 1000000007
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
int main()
{
    IO
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    ll res=inf;
    for(int i=0;(i+k-1)<n;i++)
    {

        ll a=arr[i];
        ll b=arr[i+k-1];
        if(a>=0&&b>=0)
        {
            res=min(res,b);
        }
        else if(a<0&&b<0)
        {
            res=min(res,(a*-1));
        }
        else
        {
            res=min(res,((ll)(a*-1*2))+b);
            res=min(res,2*b+-1*a);
        }
       // res=min(res,tmp+(arr[i+(k-1)]-arr[i]));
    }
    cout<<(ll)res<<endl;
    return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

int main()
{
	long long int N;
	cin >> N;
	if (N == 1||N==2)
	{
		cout << 0;
		return 0;
	}

	long long int ans=0;

	long long int s = sqrt(N);

	for (long long int i = 1;i <= s;i++)
	{
		if (N%i == 0 && i*i != N && i*(i+1)!=N) ans += N / i - 1;
	}

	cout << ans;

	return 0;
}


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

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

  int i = 0;

  if (s[0] == t[0]) {
    i++;
  }

  if (s[1] == t[1]) {
    i++;
  }

  if (s[2] == t[2]) {
    i++;
  }

  cout << i;
}

Measured memory_bytes: 256