akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using ll = long long;
int main(){
    int k;
    cin >> k;
    rep(i, k){
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3664
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		String s;
		int w;
		int todayfee;
		try{
			while((s=r.readLine())!=null){
				w=Integer.parseInt(s);
				if(w==-1){
					break;
				}
				if(w<=10){
					todayfee=1150;
				}else if(w>10 &&w<=20){
							todayfee=1150+125*(w-10);
						}else if(w>20 &&w<=30){
							todayfee=1150+125*10+140*(w-20);
								}else{
									todayfee=1150+1250+1400+160*(w-30);
				}
				System.out.println(4280-todayfee);
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 16876
import math
X = int(input())

def isPrime(x):
  if x==2: return True
  for i in range(2, int(math.sqrt(x))):
    if x%i==0:
      return False
  return True

def main(x):
  dx = 0
  while(True):
    if(isPrime(x+dx)):
      return x+dx
    dx+=1

result = main(X)
print(result)

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

int main(){
  int h, w; cin >> h >> w;
  vector<vector<char>> data(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> data[i][j];
    }
  }
  
   vector<vector<char>> ans(h+2, vector<char>(w+2));
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      ans[0][j] = '#';
      ans[i][0] = '#';
      ans[h+1][j] = '#';
      ans[i][w+1] = '#';
    }
  }
  
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      ans[i][j] = data[i-1][j-1];
    }
  }
  
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      cout << ans[i][j];
      if(j==w+1) cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
sx,sy,tx,ty=map(int,input().split())

ans=""

for i in range(tx-sx):
    ans+="R"
for i in range(ty-sy):
    ans+="U"
for i in range(tx-sx):
    ans+="L"
for i in range(ty-sy+1):
    ans+="D"
for i in range(tx-sx+1):
    ans+="R"
for i in range(ty-sy+1):
    ans+="U"
ans+="L"
ans+="U"
for i in range(tx-sx+1):
    ans+="L"
for i in range(ty-sy+1):
    ans+="D"
ans+="R"

print(ans)

Measured memory_bytes: 3064
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
    string S;
    cin >> S;
    bool ok = 0;
    for(int i=0;i<S.length();i+=3)
    {
        if(S[i]=='A' && S[i+1]=='R' && S[i+2]=='C') ok=1;
        else ok=0;
    }
    if(ok) cout << "ABC";
        else cout << "ARC";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 200000
int main() {

        int a,b,c,maxx,ans=0;
        cin>>a>>b>>c;
        int a2=a%2,b2=b%2,c2=c%2;
        if((a2==c2)&&(a2==b2)){
        }else{
            ans++;
            if(a2==b2){
                a++;
                b++;
            }else if(a2==c2){
                a++;
                c++;
            }else{
                b++;
                c++;
            }
        }
        maxx=max(a,b);
        maxx=max(c,maxx);
        ans+=(maxx*3-(a+b+c))/2;

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


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

int main() {
  int N, l, r, total = 0;
  cin >> N;

  for(int i = 0; i < N; ++i) {
    cin >> l >> r;
    total += r - l + 1;
  }
  
  cout << total << endl;
}

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

int main(){
 int N; cin >> N;
  
  if( N % 2){ cout << fixed << setprecision(10) <<  ((double)(N+1)/(2*N)) << endl;}
  else{ cout << fixed << setprecision(10) <<  0.5 << endl;}
  
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    char a,b;
    IN(a,b);
    if(a>=b)
        rep(i,a-'0') cout << b;
    else
        rep(i,b-'0') cout << a;
    cout << endl;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  char head1 = s1.at(0);
  char head2 = s2.at(0);
  char head3 = s3.at(0);
  cout << head1 << head2 << head3 << endl;
}

Measured memory_bytes: 256
[N, K, Q] = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [0 for i in range(N)]
for i in range(Q):
    B[A[i]-1] += 1
for i in range(N):
    if K + B[i] - Q > 0:
        print('Yes')
    else:
        print('No')


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

inline P operator-(const P &a, const P &b) { return P(a.first-b.first, a.second-b.second); }

inline ll cross(P a, P b) { return a.first*b.second - a.second*b.first; }

inline vector<ll> lower_convex_area(vector<P> v){
  int n = v.size(), k = 0;

  vector<ll> area(n+1,0);
  vector<P> a(n);

  // lower convex
  rep(i,n){
    area[i+1] = area[i];

    while(k>1 && cross(a[k-1]-a[k-2], v[i]-a[k-1]) < 0){
      if(k >= 3) area[i+1] -= cross(a[k-2]-a[0], a[k-1]-a[0]);
      k--;
    }
    a[k++] = v[i];
    if(k >= 3) area[i+1] += cross(a[k-2]-a[0], a[k-1]-a[0]);
  }

  return area;
}

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

  vector<P> p(n);
  rep(i,n){
    cin >> p[i].first >> p[i].second;
  }

  sort(all(p));
  vector<ll> lowerleft = lower_convex_area(p);

  rep(i,n) p[i].second *= -1;
  vector<ll> upperleft = lower_convex_area(p);

  rep(i,n) p[i].first *= -1;
  sort(all(p));
  vector<ll> upperright = lower_convex_area(p);

  rep(i,n) p[i].second *= -1;
  vector<ll> lowerright = lower_convex_area(p);

  rep(i,n) p[i].first *= -1;
  sort(all(p));
  ll ans = lowerleft[n] + upperleft[n] + lowerright[0] + upperright[0];
  for(int i=1;i<n;i++){
    if(p[i].first != p[i-1].first) ans = min(ans, lowerleft[i] + upperleft[i] + lowerright[n-i] + upperright[n-i]);
  }
  cout << (ans+1)/2 << endl;
}

Measured memory_bytes: 10564
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int x,y;

	cin >> x >> y;
	while ( !( (x == 0) && (y == 0)) ) {
		using std::swap;
		if ( x > y ) swap(x,y);
		cout << x << " " << y << endl;
		cin >> x >> y;
	}
}



Measured memory_bytes: 3000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;

void dfs(ll cur, int used, ll &counter)
{
    if (cur > N)
        return;

    if (used == 0b111)
        counter++;

    dfs(cur * 10 + 3, used | 0b001, counter);
    dfs(cur * 10 + 5, used | 0b010, counter);
    dfs(cur * 10 + 7, used | 0b100, counter);
}

int main()
{
    cin >> N;
    ll counter = 0;
    dfs(0, 0, counter);
    cout << counter << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{

   
    @SuppressWarnings("unchecked")
      public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));	
	while(true)
	    {
		int n;
		n = Integer.parseInt(in.readLine());
		if(n == 0)
		    break;

		List<Integer>[] list = new ArrayList[n+3];
		for(int i=0;i<=n;i++)
		    list[i] = new ArrayList<Integer>();

		for(int i=0;i<n;i++)
		    {
			String[] line = in.readLine().split(" ");
			int t = Integer.parseInt(line[0]);
			for(int j=1;j<=t;j++)
			    {
				list[i].add(Integer.parseInt(line[j]));
			    }

		    }

		String[] elements = in.readLine().split(" ");
		int K = Integer.parseInt(elements[0]);
		LinkedList<Integer> l = new LinkedList<Integer>();
		for(int i=1;i<=K;i++)
		    {
			l.add(Integer.parseInt(elements[i]));
		    }
	

		int cnt = 0,pos = -1;
		for(int i=0;i<n;i++)
		    {
			HashMap<Integer,Boolean> map = new HashMap<Integer,Boolean>();
			for(int j=0;j<l.size();j++)
			    map.put(l.get(j),true);

			int cnt2 = 0;
			for(int j=0;j<list[i].size();j++)
			    {
				if(map.containsKey(list[i].get(j)) && map.get(list[i].get(j)))
				    cnt2++;
			    }
			if(cnt2 == K)
			    {
			
				cnt++;
				pos = i;
			    }

		    }



		if(cnt == 1)
		    System.out.println((pos+1));
		else
		    System.out.println(-1);
	    }
    }

}

Measured memory_bytes: 12000
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine().toInt
    println(solve(n))
  }

  def solve(n: Int): Int = {
    only(List("3", "5", "7"), n) -
    only(List("3", "5"), n) -
    only(List("3", "7"), n) -
    only(List("5", "7"), n) +
    only(List("7"), n) + only(List("5"), n) + only(List("3"), n)
  }

  def only(digitSet: List[String], n: Int): Int = {
    (1 to 9).foldLeft(Nil: List[String])((x, _) => digitSet ++: x.flatMap(
      s => digitSet.map(c => c + s))).foldLeft(0)((acc, y) =>
      if (y.toInt <= n) {
        acc + 1
      } else {
        acc
      })
  }

}


Measured memory_bytes: 40668
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n; string a[36], b[36];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
	for(int i = 0; i < n; i++) {
		for(int j = n - 1; j > i; j--) {
			if(b[j - 1][1] > b[j][1]) swap(b[j - 1], b[j]);
		}
	}
	for(int i = 0; i < n; i++) cout << (i ? " " : "") << b[i]; cout << endl;
	cout << "Stable" << endl;
	for(int i = 0; i < n; i++) {
		int r = i;
		for(int j = i + 1; j < n; j++) {
			if(a[j][1] < a[r][1]) r = j;
		}
		swap(a[i], a[r]);
	}
	for(int i = 0; i < n; i++) cout << (i ? " " : "") << a[i]; cout << endl;
	cout << (equal(a, a + n, b) ? "Stable" : "Not stable") << endl;
}

Measured memory_bytes: 3188
N,M = map(int,input().split())

A = [[] for i in range(N)]

for i in range(M) :
    l,r,d = map(int,input().split())
    
    l -= 1
    r -= 1
    
    A[l].append([r,d])
    A[r].append([l,-d])
    
ans = "Yes"

distance = ["#" for i in range(N)]

flg = 0

for i in range(N) :
    if flg :
        break
    
    if distance[i] != "#" :
        continue
    
    distance[i] = 0
    stack = [i]
    
    while stack :
        now = stack.pop()
        
        for to,d in A[now] :
            if distance[to] == "#" :
                distance[to] = distance[now] + d
                stack.append(to)
            
            elif distance[to] != distance[now] + d :
                ans = "No"
                stack = []
                flg = 1
                break
            
print(ans)


Measured memory_bytes: 112288
#include <iostream>
#include <cmath>
using namespace std;
int knapsackA(int w,int wt[],int val[],int n){
    if(w==0 || n==0){
        return 0;
    }
    if(wt[n-1]>w){
        return knapsackA(w,wt,val,n-1);
    }
    return max(knapsackA(w-wt[n-1],wt,val,n-1)+val[n-1],knapsackA(w,wt,val,n-1));
}
long int knapsackADP(int w,long int wt[],long int val[],int n){
    long int dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(wt[i-1]<=j){
                dp[i][j]=max((dp[i-1][j-wt[i-1]]+val[i-1]),dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][w];
}
int main() {
    int n,w;
    cin>>n>>w;
    long int wt[n];
    long int val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    cout<<knapsackADP(w,wt,val,n)<<endl;

    
}


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

#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res=((res%mod)*((n-i)%mod))%mod;res=((res%mod)*(power(i+1,mod-2))%mod)%mod;}return res;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
////////////////////////////////////////////////////
int main()
{
   bolt;
   string s;
   cin>>s;
   if (s=="SUN")
      cout<<7;
   else if (s=="MON")
      cout<<6;
   else if (s=="TUE")
      cout<<5;
   else if (s=="WED")
      cout<<4;
   else if (s=="THU")
      cout<<3;
   else if (s=="FRI")
      cout<<2;
   else if (s=="SAT")
      cout<<1;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, a[100055], x, y, ans, deg[100055];
bool vis[100055];
vector<int> e[100055];

void GG() {
	printf("NO\n");
	exit(0);
}

int dfs(int x) {
//	printf(">> dfs %d\n", x);
	
	vis[x] = 1;
	
	vector<int> w;
	LL sum = 0;
	
	FOR(i, 0, e[x].size()) {
		int to = e[x][i];
		if (vis[to]) continue;
		int res = dfs(to);
		sum += res;
		w.pb(res);
	}
	
	if (w.size() == 0) return a[x];
	
	if (sum > a[x] * 2) GG();
	
	LL left = sum - a[x];
	if (left < 0) GG();
	
	if (a[x] < left) GG();
	
	if (w.size() == 1 && left != 0) GG();
	
	LL extra = 0;
	
	FOR(i, 0, w.size()) {
		if (w[i] > left) extra += w[i] - left;
	}
	
	if (extra > a[x] - left) GG();
	
//	printf(">> dfs %d returns %d - %lld = %lld\n", x, a[x], left, a[x] - left);
	
	return a[x] - left;
	
}

int main () {
	
	scanf("%d", &n);
	
	FOE(i, 1, n) scanf("%d", a + i);
	
	if (n == 2) {
		printf("%s\n", (a[1] == a[2]) ? "YES" : "NO");
		return 0;
	}
	
	FOR(i, 1, n) {
		scanf("%d%d", &x, &y);
		e[x].pb(y);
		e[y].pb(x);
		deg[x]++;
		deg[y]++;
	}
	
	int rt = 1;
	FOE(i, 1, n) if (deg[i] > 1) rt = i;
	
	ans = dfs(rt);
	
	printf("%s\n", (ans == 0) ? "YES" : "NO");
	
	return 0;
	
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

vector<int> face(6), face2(6);

void rotate(char d) {
  vector<int> newFace(6);
  newFace = face;
  if (d == 'N') {
    newFace[0] = face[1];
    newFace[1] = face[5];
    newFace[5] = face[4];
    newFace[4] = face[0];
  } else if (d == 'S') {
    newFace[0] = face[4];
    newFace[1] = face[0];
    newFace[5] = face[1];
    newFace[4] = face[5];
  } else if (d == 'E') {
    newFace[0] = face[3];
    newFace[2] = face[0];
    newFace[5] = face[2];
    newFace[3] = face[5];
  } else if (d == 'W') {
    newFace[0] = face[2];
    newFace[2] = face[5];
    newFace[5] = face[3];
    newFace[3] = face[0];
  }
  face = newFace;
}

int main() {
  int n; cin >> n;
  vector<vector<int>> faces(n, vector<int>(6));

  rep0(i, n) rep0(j, 6) cin >> faces[i][j];

  string s = "NEWS";

  rep0(i, n) {
    rep(j, i + 1, n) {
      face = faces[i];
      face2 = faces[j];

      rep0 (k, 1000) {

        char c = s[rand() % 4];
        rotate(c);
        bool check = true;
        rep0 (l, 6) {
          if (face[l] != face2[l]) check = false;
        }
        if (check) {
          cout << "No" << BR;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << BR;
  return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

int main(void){
    ll N, Q;
    std::string S;
    std::cin >> N >> Q >> S;
    ll *L = new ll[Q];
    ll *R = new ll[Q];

    ll max = 0;
    for(ll i = 0; i < Q; ++i){
        std::cin >> L[i] >> R[i];
        if(R[i] > max) max = R[i];
    }

    ll count = 0;
    bool isFirstA = false;
    std::vector<ll> substr;

    for(int i = 0; i < max; ++i){
        if(!isFirstA){
            if(S[i] == 'A') isFirstA = true;
        }
        else{
            if(S[i] == 'C'){
                ++count;
                isFirstA = false;
            }
            else if(S[i] != 'A'){
                isFirstA = false;
            }
        }
        substr.push_back(count);
    }

    for(ll i = 0; i < Q; ++i){
        std::cout << substr[R[i]-1] - substr[L[i]-1] << std::endl;
    }    

    delete[] L;
    L = nullptr;
    delete[] R;
    R = nullptr;

    return 0;
}

Measured memory_bytes: 3444
implicit none
integer :: n,x
integer :: l(100)
integer :: i,d,ans
read *,n,x
read *,(l(i),i=1,n)

ans = 0
d = 0
do i = 1, n+1
   if (d <= x) ans = ans + 1
   d = d + l(i)
enddo

print '(i0)',ans
end

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int K;
    cin >> K;

    long long sol = 0;
    for( int i = 1; i <= K; i++ )
        for( int j = 1; j <= K; j++ )
            for( int k = 1; k <= K; k++ )
                sol += __gcd(__gcd(i,j), k);

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


Measured memory_bytes: 3652
from collections import defaultdict

s = input()

rests = [0]
n = 0
a = 0
m = 1
c = defaultdict(int)
c[0] += 1
for i in list(s)[::-1]:
    n = n + int(i)*m

    c[n % 2019] += 1
    m = m * 10 % 2019

for v in c.values():
    a += v * (v-1) // 2
print(a)






Measured memory_bytes: 12200
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut wv = vec!["".to_owned(); n];
    for i in 0..n {
        wv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }
    let mut pc = wv[0].chars().last().unwrap();
    let mut ans = true;
    for i in 1..n {
        if !wv[i].starts_with(pc) {
            ans = false;
        }
        for j in 0..i {
            if &wv[j] == &wv[i] {
                ans = false;
            }
        }
        pc = wv[i].chars().last().unwrap();
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4476
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  int out[101]={0};
  int in;
  while(cin>>in)out[in]++;
  int max1=0;
  rep(i,101)max1=max(max1,out[i]);
  rep(i,101)if(max1==out[i])cout<<i<<endl;
} 

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int n;
    cin >> n;
    int p[n],q[n];
    rep(i,n){
        cin >> p[i];
        q[i]=p[i];
    }
    sort(p,p+n);
    int c=0;
    rep(i,n){
        if(p[i]!=q[i]){
            c++;
        }
    }
    if(c==2||c==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
string s,t;
int n,m,res;
void provera(int i){
	int res1=0;
	for(int j=i;j<i+m;j++)
		res1+=(s[j]!=t[j-i]);
	//cout<<i<<"  "<<res1<<endl;
	res=min(res,res1);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>s>>t;
	n=s.length();m=t.length();
	res=m;
	for(int i=0;i<=n-m;i++)
		provera(i);
	cout<<res;
	return 0;
}

Measured memory_bytes: 3656
import math                                             
from decimal import Decimal                             
                                                        
N = input()                                             
t = []                                                  
a = []                                                  
for i in range(int(N)):                                 
    t_n, a_n = input().split()                          
    t.append(Decimal(t_n))                              
    a.append(Decimal(a_n))                              
                                                        
t_ans = 0                                               
a_ans = 0                                               
for t_n, a_n in zip(t, a):                              
    k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n)) 
    if not k:                                           
        k = 1                                           
    t_ans = Decimal(k*t_n)                              
    a_ans = Decimal(k*a_n)                              
print(t_ans+a_ans)                                      
                                                        


Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll MOD = 998244353;
//const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;

ll dp[3001][3001];


int main() {
    ll N, S;
    cin >> N >> S;
    vector<ll> A(N + 1);
    rep(i, N)cin >> A[i + 1];
    
    ll ans = 0;
    reps(i, 1, N + 1){
        (dp[i][A[i]] += i) %= MOD;
        rep(j, S + 1){
            if (j != S)
                (dp[i][j] += dp[i - 1][j])%=MOD;
            if (j > A[i])
                (dp[i][j] += dp[i - 1][j - A[i]])%=MOD;
        }
        (ans += dp[i][S] * (N - i + 1))%=MOD;
        //rep(j, S + 1){
        //    fprintf(stderr, "dp[%d][%d] = %d\n", i, j, dp[i][j]);
        //}
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 70656
#include<stdio.h>
 
int main(){
	int a, b, i, ans = 0;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		a = 1000 - a;
		ans += a / 500;
		a = a % 500;
		ans += a / 100;
		a = a % 100;
		ans += a / 50;
		a = a % 50;
		ans += a / 10;
		a = a % 10;
		ans += a / 5;
		ans += a % 5;
		printf("%d\n", ans);
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int X = inputVal<int>();
	const int A = inputVal<int>();
	outputVal((X < A) ? 0 : 10);
}

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

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a;
  int b;
  int x;

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

  if(a <= x){
    if(a + b >= x){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }else{
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    int ans = INF;
    int n = s.size();
    int m = t.size();
    rep(i, 0, n - m + 1) {
        string sub = s.substr(i, m);
        int cnt = 0;
        rep(i, 0, m) {
            if (sub[i] != t[i]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<vector<ll>> dp(n, vector<ll>(n, INF));
  vector<vector<ll>> slime(n, vector<ll>(n, 0));
  REP(i, n) {
    cin >> slime[i][i];
    dp[i][i] = 0;
  }
  REP(i, n) {
    FOR(j, 1, n - i - 1) {
      slime[i][i + j] = slime[i][i + j - 1] + slime[i + j][i + j];
    }
  }
  FOR(i, 1, n - 1) {
    REP(j, n - i) {
      FOR(k, j, j + i - 1) {
        dp[j][j + i] = min(dp[j][j + i], dp[j][k] + dp[k + 1][j + i] + slime[j][j + i]);
      }
    }
  }
  cout << dp[0][n - 1] << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 2816
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[j+k][i:i+m]!=b[k]:
                break
        else:
            flag = 1
print("Yes" if flag else "No")

Measured memory_bytes: 3064
program kadai
   implicit none

integer(8)  ::  n,m,i,j,a,b
integer(8),allocatable  ::  s(:),t(:)
integer(8),allocatable  ::  dp(:,:),sum(:,:)



read(*,*) n,m

allocate(s(n))
allocate(t(m))
allocate(dp(n,m))
allocate(sum(n,m))
read(*,*) s
read(*,*) t

sum=0
dp=0
do i=1,n
    do j=1,m
        if (s(i)==t(j)) then
            if (i>1 .and. j>1) then
                dp(i,j)=sum(i-1,j-1)
            end if
            dp(i,j)=dp(i,j)+1
        else
            dp(i,j)=0
        end if
        if (i>1 .and. j>1) then
            sum(i,j)=sum(i-1,j)+sum(i,j-1)-sum(i-1,j-1)+dp(i,j)
        elseif (i==1 .and. j>1) then
            sum(1,j)=sum(1,j-1)+dp(1,j)
        elseif (i>1 .and. j==1) then
            sum(i,1)=sum(i-1,1)+dp(i,1)
        else
            sum(1,1)=dp(1,1)
        end if
        sum(i,j)=mod(10**9+7+sum(i,j),10**9+7)
    end do
end do


write(*,*) mod(sum(n,m)+1,10**9+7)


stop
contains

end program kadai

Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
int ai[N], bi[N];
int check(int t)
{
    for (int i = 1; i < 2 * n; ++ i) bi[i] = ai[i] >= t;
    int mid = 1e9, res = bi[n] ^ !(n & 1);
    for (int i = n - 1; i >= 1; -- i)
        if (bi[i] == bi[i + 1] && n - i < mid)
        {
            mid = n - i;
            res = bi[i];
        }
    for (int i = n + 1; i < n * 2; ++ i)
        if (bi[i] == bi[i - 1] && i - n < mid)
        {
            mid = i - n;
            res = bi[i];
        }
    return res
;}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n * 2; ++ i) scanf("%d", &ai[i]);
    int l = 1, r = n * 2 - 1;
    while (l < r)
    {
        int m = (l + r + 1) / 2;
        // cerr << l << " " << r << " " << m << endl;
        if (check(m)) l = m; else r = m - 1;
    }
    printf("%d\n", r);
}


Measured memory_bytes: 1792
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

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

  int a, b; cin >> a >> b;
  int cnt = 1;
  int cur = a;

  if (b == 1) {
    cout << 0 << endl; return 0;
  }

  if (cur >= b) {
    print(cnt); return 0;
  }

  while (cur < b) {
    cur += (a - 1);
    ++cnt;
  }

  print(cnt);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N, T;
  int res = 0;
  cin >> N >> T;
  vector<vector<int>> A(N, vector<int> (2));
  for (int i = 0; i < N; i++) {
    cin >> A[i][0] >> A[i][1];
  }
  sort(A.begin(), A.end());
  vector<int> dp(T, 0);
  for (int i = 0; i < N; i++) {
    vector<int> new_dp = dp;
    for (int j = 0; j <= T - 1; j++) {
      res = max(res, dp[j] + A[i][1]);
      if (j + A[i][0] <= T - 1) {
        new_dp[j + A[i][0]] = max(dp[j] + A[i][1], new_dp[j + A[i][0]]);
      }
    }
    swap(dp, new_dp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
    #include <string.h>

    int main(void)
    {
        int n,h;
        scanf("%d %d",&h,&n);
        int a[n];
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            h=h-a[i];
            //printf("%d\n",h);
        }
        if(h <= 0){printf("Yes\n");}
        else{printf("No\n");}
        return 0;
    }

Measured memory_bytes: 2016
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int X,Y,Z;
    cin >> X>>Y>>Z;
    int ans = 0;
   for(int i = 1;i < X+1;i++){
       if((X - Z) - (Y+Z)*i >= 0) ans++;
       else break;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<array>
#include<string>

using namespace std;
int main(int argc, char const *argv[]) {
  char a[2];
  std::cin >> a;
  for (size_t i = 1; i < 3; i++) {
    if (a[0]==a[i] || a[i-1]==a[i]) {
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 256
// 171

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;

int main(){
    long long int n, sum=0, buf=0;
    cin >> n;

    for(long long int j=1; j<=n; j++){
        buf = j;
        while(buf <= n){
            sum += buf;
            buf += j;
        }
    }
    cout << sum << endl;
}


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

vector<bool> getPrimeVec(ll max)
{
	vector<bool> v(max, true);
	v[0] = false; v[1] = false;

	for (ll i = 2; i < max; ++i)
	{
		if (v[i])
		{
			for (ll j = i * 2; j < max; j += i)
				v[j] = false;
		}
	}
	return v;
}

int main(int argc, char **argv)
{
	int MAX = 100010;
	int x; cin >> x;
	vector<bool> v = getPrimeVec(MAX);

	for (int i = x; i < MAX; ++i)
	{
		if (v[i])
		{
			std::cout << i << std::endl;
			return 0;
		}
	}		
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>


using namespace std;

int main(void){
	long long int n,s;
	scanf("%lld",&n);
	for(int a=1;a<=n;a++){
		scanf("%lld",&s);
		printf("Case %d:\n",a);
		for(int i=0;i<10;i++){
			char ss[8],sss[4];
			s=s*s;
			sprintf(ss,"%08lld",s);
			int sk=0;
			for(int j=0;j<4;j++){
				if(j>=0){
					sss[j]=ss[2+j];
				}
			}
			s=atoi(sss);
			printf("%lld\n",s);
		}
	}
    return 0;
}

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

int main() {
  int N;	cin >> N;
  
  //int N[4] = 0;
  int A[4];
  int i = 0;
  while(i < 4){
    A[3 - i] = N % 10;
    N /= 10;
    i++;
  }
  
  if((A[0]==A[1] && A[1]==A[2])
    	|| (A[1]==A[2] && A[2]==A[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H = int(input())
	ans = 1
	for i in range(50):
		if 2 ** i > H:
			ans = 2 ** i - 1
			break

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==2){
    printf("No");
  }else if(a==4 || a==6 ||a==9 ||a==11){
    if(b==4 || b==6||b==9 ||b==11){
      printf("Yes");
    }else{
      printf("No");
    }
  }else{
    if(b==4 || b==6||b==9 ||b==11 ||b==2){
      printf("No");
    }else{

       printf("Yes");
    }
  }
}


Measured memory_bytes: 128
N, Y = map(int, input().split())

ans = 0
for i in range(0, N+1):
  pool = Y - i * 10000
  for j in range(0, (N+1) - i):
  
    if pool - 1000 * j - 5000 *(N - i - j) == 0:
      ans = -1
      break
  if ans != 0:
    break
  
if ans == -1:
  print(i, N - i - j, j)
else:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;

int main(){
	int n, m, a, b;
	while(cin >> n, n) {
		vector<pair<int, int> > v;
		rep(i,n) {
			pair<int, int> p;
			cin >> m >> a >> b;
			p.first = a, p.second = m;
			v.push_back(p);
			p.first = b, p.second = -m;
			v.push_back(p);
		}
		sort(v.begin(), v.end());
		bool f = 0;
		int cur = 0, w = 0;
		rep(i,v.size()) {
			while(1) {
				cur =v[i].first, w +=v[i].second;
				if(i == v.size()-1 || v[i].first != v[i+1].first) break;
				i++;
			}
			if(w>150) {
				f = 1;
				break;
			}
		}
		if(f) cout << "NG" << endl;
		else cout << "OK" << endl;
	}
}

Measured memory_bytes: 1196
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 210000;

int n, m;
vector<int> eds[MAXN];
int en[MAXN];
string s;
int cc[MAXN][2];

void add(int a, int b, int d) {
	if (s[b] == 'A')
		cc[a][0] += d;
	else
		cc[a][1] += d;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	cin >> s;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
		add(a, b, 1);
		add(b, a, 1);
	}
	queue<int> qu;
	int cnt = n;
	for (int i = 0; i < n; ++i) {
		if (!cc[i][0] || !cc[i][1])
			qu.push(i), en[i] = 1, --cnt;
	}
	while (!qu.empty()) {
		int x = qu.front();
		qu.pop();
		for (int u: eds[x]) {
			if (!en[u]) {
				add(u, x, -1);
				if (!cc[u][0] || !cc[u][1])
					qu.push(u), en[u] = 1, --cnt;
			}
		}
	}
	if (cnt == 0)
		cout << "No\n";
	else
		cout << "Yes\n";
	return 0;
}




Measured memory_bytes: 13392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br.readLine());
        int[] s = createListInt(br.readLine());
        int q = ip(br.readLine());
        int[] t = createListInt(br.readLine());
        int count = 0;
        Arrays.sort(s);
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < n + 1; j++) {
                if (Arrays.binarySearch(s, t[i]) >= 0) {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}

Measured memory_bytes: 28408
from fractions import gcd
import sys
input = sys.stdin.readline

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

l_gcd_list = [0]*(N+1)
r_gcd_list = [0]*(N+1)
for i in range(N):
    l_gcd_list[i+1] = (gcd(l_gcd_list[i], A[i]))
    r_gcd_list[-(i+2)] = (gcd(r_gcd_list[-(i+1)], A[-(i+1)]))
# print(l_gcd_list)
# print(r_gcd_list)

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))


Measured memory_bytes: 16132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long W = in.nextLong();
            long H = in.nextLong();
            long x = in.nextLong();
            long y = in.nextLong();

            double v = (W * H) / 2.0;
            int w = (x * 2 == W) && (y * 2 == H) ? 1 : 0;
            out.printf("%.6f %d\n", v, w);
        }

    }
}



Measured memory_bytes: 23892
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;

    int ans = 0;

    for(int a = 1;a <= n;a ++){

        int f,e;
        e = a % 10;

        if(e == 0) continue;
        f = a;

        while(f >= 10){
            f /= 10;
        }
        int b = e;
        if(e == f){
            ans ++;
        }

        for(int i = 1;i <= 5;i ++){
            b = e * pow(10,i);
            b += f;
            if(b > n) break;

            if(10 <= b && b <= 99){
                ans ++;
            }else if(100 <= b && b <= 999){
                for(int j = 0;j < 10;j ++){
                    ans ++;
                    b += 10;
                    if(b > n) break;
                }
            }else if(1000 <= b && b <= 9999){
                for(int j = 0;j < 100;j ++){
                    ans ++;
                    b += 10;
                    if(b > n) break;
                }
            }else if(10000 <= b && b <= 99999){
                for(int j = 0;j < 1000;j ++){
                    ans ++;
                    b += 10;
                    if(b > n) break;
                }
            }else{
                for(int j = 0;j < 10000;j ++){
                    ans ++;
                    b += 10;
                    if(b > n) break;
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
//#include <vector>
#include <iostream>
//#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int k;
	cin >> k;
	if (k % 2 == 0) {
		cout << (k/2)*(k/2) << endl;
	}
	else {
		cout << (k-1)/2 * (k+1)/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import  math
N,D=map(int,input().split())

nums=[input().split()for i in range(N)]
sum=0
for i in range(N):
    for j in range(D):
        nums[i][j]=int(nums[i][j])
#print(nums)

def is_integer_num(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

cout=0

for i in range(N-1):
    for j in range(i+1,N):
           for k in range(D):
               sum+=(nums[i][k]-nums[j][k])*(nums[i][k]-nums[j][k])

           sum=math.sqrt(sum)
          

           if is_integer_num(sum)==True:
                cout+=1
                sum=0
           else:
                sum=0

print(cout)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	for(int i=0; i<N; ++i) cin >> L[i];
	int MAX = 0;
	int sum = 0;
	for(int i=0; i<N; ++i){
		MAX = max(MAX, L[i]);
		sum += L[i];
	}
	if(MAX < sum-MAX) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

const double PI = acos(-1.0);
int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double alpha = (H * 60 + M) / 720 * (PI * 2);
    double beta = M / 60 * (PI * 2);
    double xA = A * cos(alpha), yA = A * sin(alpha);
    double xB = B * cos(beta), yB = B * sin(beta);
    double res = sqrt((xA-xB)*(xA-xB) + (yA-yB)*(yA-yB));
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 4140
N = int(input())
M = {}
for i in range(N):
  A = int(input())
  if not(A in M):
    M[A] = 0
  M[A] += 1
r = 0
for A in M.keys():
  if M[A]%2 == 1:
    r += 1
print(r)


Measured memory_bytes: 15076