akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <climits>
#include <functional>
#include <numeric>

using namespace std;

#define alloc(type,n) (type*)calloc(sizeof(type),(n));
typedef long long lli;

int n,m;
char a[55][55];
char b[55][55];

bool check(int x,int y){
	for(int i = 0;i < m;i++){
		for(int j = 0;j < m;j++){
			if(a[i+x][j+y] != b[i][j]){
				return false;
			}
		}
	}
	return true;
}

int main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < m;i++){
		cin >> b[i];
	}
	for(int i = 0;i <= n-m;i++){
		for(int j = 0;j <= n-m;j++){
			if(check(i,j)){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define xfor(i, a, b) for (int i = a; i < b; i++)
#define ifor(i, a, b) for (int i = a; i <= b; i++)
#define rxfor(i, b, a) for (int i = b; i > a; i--)
#define rifor(i, b, a) for (int i = b; i >= a; i--)
#define foreach(v, c) for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

int main()
{
    int n;
    cin >> n;
    long long s = 0;
    ifor(i, 1, n)
    {
        if (i % 3 != 0 && i % 5 != 0)
            s += i;
    }
    cout << s << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    double n;
    while(cin >>n && n){
        vector<int> A(n);
        double sum=0;
        for(int i=0; i<n; i++){
            cin >> A[i];
            sum+= A[i];
        }
        double ave= sum/n;
        int ans=0;
        for(int i=0; i<n; i++){
            if(ave>=A[i]) ans++;
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
int main(){
    long long n,y;
    cin >> n >> y;
    bool h=false;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            long long sum =y;
            sum -= (i*10000+j*5000);
            if(sum%1000==0 && sum>=0 && sum/1000 ==(n-i-j)){
                h=true;
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                break;
            }
            if(h){
                break;
            }
        }
        if(h){
            break;
        }
    }
    if(h==false){
        cout<<"-1 -1 -1"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool dfs(int st,int par,vector<vector<int> >&adj,vector<int>&p,vector<int>&h,vector<int>&g,vector<int>&b){
    bool ans=true;
    int flag=0;
    int x,y;
    for(int j=0;j<adj[st].size();j++){
        if(adj[st][j]!=par){
        //cout<<adj[st][j]<<" "<<par<<" "<<st<<endl;
            flag=1;
            ans=ans&dfs(adj[st][j],st,adj,p,h,g,b);
            g[st]+=g[adj[st][j]];
            b[st]+=b[adj[st][j]];
            p[st]+=p[adj[st][j]];
        }
    }
    if(flag==0){
        if(abs(h[st])>p[st]){
        	//cout<<st<<endl;
        	return false;
		}
        else {
            g[st]=(p[st]+h[st])/2;
            b[st]=(p[st]-h[st])/2;
            //cout<<st<<" "<<p[st]<<" "<<h[st]<<" "<<g[st]<<" "<<b[st]<<endl;
            if(g[st]+b[st]==p[st])
            return true;
            else return false;
        }
    }
    else{
        int x=(p[st]+h[st])/2;
        int y=(p[st]-h[st])/2;
        //cout<<st<<" "<<p[st]<<" "<<h[st]<<" "<<g[st]<<" "<<b[st]<<" "<<ans<<endl;
        if(x<0||y<0||(x+y)!=p[st]||(x-y)!=h[st]||abs(h[st])>p[st]||x<g[st])return ans&false;
        else {
        	g[st]=x;
        	b[st]=y;
        	return ans&true;
		}
    }
}

int main()
{
    int n;
    cin>>n;
    double d;
    cin>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        double x,y;
        cin>>x>>y;
        double dis=x*x;
        dis+=y*y;
        dis=sqrt(dis);
        if(dis<=d)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3812
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = math.ceil(n/1000)
    ans = 1000*a-n
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27160
N = gets.to_i
 inputs = []
 N.times do |i|
   x,y = gets.split(" ")
   inputs.push({x: x.to_f, y: y.to_f})
end

permu = inputs.permutation(N).to_a

res = []
permu.each do |a|
  sum = 0

  (a.length - 1).times do |i|
    sum += Math.hypot(a[i][:x] - a[i+1][:x], a[i][:y] - a[i+1][:y])
  end

  res.push(sum)
end

ave = (res.inject(:+) / res.length).round(10)

puts ave

Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i++)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<__LINE__<<")"<<endl;}
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
//=======================================================================================================

int main()
{
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    long double sum = 0;
    rep(i,n) {
        sum += (long double) 1 / a[i];
    }
    sum = 1 / sum;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  set<long long>ans;
  long long A=a;
  long long B=b;
  long long g=__gcd(a,b);
  for(int i=2;(long long)i*i<=g;i++)
  {
	long long t=i;
    if(g%t==0)
    {
      ans.insert(t);
      while(g%t==0)g/=t;
    }
  }
  if(g>1)ans.insert(g);
  cout<<ans.size()+1<<endl;
  return 0;
 }

Measured memory_bytes: 3632
while buf=gets
        n=buf.to_i
        s=[]
        while n>0
                0.upto(10){|i|
                        if 2**i>n
                                s<<2**(i-1)
                                n-=2**(i-1)
                                break
                        elsif 2**i==n
                                s<<2**i
                                n-=2**i
                                break
                        end
                }
        end
        puts s.sort.join(' ')
end

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

int main()
{
    int n;
    cin>>n;
    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
        }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#define mm(a) memset(a,0,sizeof(a));
#define max(x, y) (x)>(y)?(x):(y)
#define min(x, y) (x)<(y)?(x):(y)
#define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
#define rep(i, a, b) for(int i=(a);i<=(b);i++)
#define per(i, b, a) for(int i=(b);i>=(a);i--)
#define PII pair<ll,ll>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;

int n;
ll a[MAXN],b[MAXN],dp[MAXN][2];
int main() {
    while(~scanf("%d",&n)) {
        for(int i=1; i<=n+1; i++)scanf("%lld",&a[i]); //monster
        for(int i=2; i<=n+1; i++)scanf("%lld",&b[i]); //attack
        ll ans=0;
        for(int i=2; i<=n+1; i++) {
            ll temp=min(a[i-1],b[i]);
            ans+=temp;
            a[i-1]-=temp;
            b[i]-=temp;
            temp=min(a[i],b[i]);
            ans+=temp;
            a[i]-=temp;
            b[i]-=temp;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}

signed main() {
	int n, k;
	cin >> n >> k;
	if ((n - 1) * (n - 2) / 2 < k) {
		cout << -1 << endl;
	}
	else {
		int ans = (n - 1) * (n - 2) / 2 - k;
		cout << ans + n - 1 << endl;
		for (int i = 2; i <= n; i++) {
			cout << 1 << " " << i << endl;
		}
		for (int i = 2; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (ans <= 0) return 0;
				cout << i << " " << j << endl;
				ans--;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll w, h;
    cin >> w >> h;
    vector<pair<ll, int>> pq(h + w);
    for(int i = 0; i < h + w; i++) {
        cin >> pq[i].first;
        pq[i].second = i < w;
    }
    h++, w++;
    sort(all(pq));
    ll ans = 0;
    for(int i = 0; i < pq.size(); i++) {
        if(pq[i].second) {
            ans += pq[i].first * h;
            w--;
        } else {
            ans += pq[i].first * w;
            h--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))

ll memo[100];

ll L(int N)
{
	if(memo[N] != 0) return memo[N];
	if(N == 0) return 2;
	else if(N == 1) return 1;
	return memo[N] = L(N - 1) + L(N - 2);
}

int main(int argc, char* argv[])
{
	int N;
	scanf("%d", &N);
	printf("%lld\n", L(N));

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace ABC073_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = 0;
            for (int i = 0; i < N; i++)
            {
                var lr = Console.ReadLine().Split().Select(int.Parse).ToArray();
                s += lr[1] - lr[0] + 1;
            }
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<int,PII> PIII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

void union_init(int d[], int s) { for (int i=0; i < s; i++) d[i]=i; }
int union_query(int d[], int n) { int res=n; while (d[res]!=res) res=d[res]; int m; while (d[n]!=n) {m=d[n];d[n]=res;n=m;} return res; };
int union_merge(int d[], int x, int y) { x=union_query(d,x); y=union_query(d,y); if (x==y)return -1; d[x]=y; return 1; }

const int MAXN = 100005;
int par[MAXN];

int n;

vector<PII> xi, yi;

priority_queue<PIII> pq;

int main() {
    GI(n);

    int x, y;

    union_init(par, n);

    LL res = 0;

    FORN(i, n) {
        GI(x);
        GI(y);

        xi.PB(MP(x, i));
        yi.PB(MP(y, i));
    }

    sort(xi.begin(), xi.end());
    sort(yi.begin(), yi.end());

    FORN(i, n-1) {
        pq.push(MP(xi[i].FF - xi[i+1].FF, MP(xi[i].SS, xi[i+1].SS)));
    }
    FORN(i, n-1) {
        pq.push(MP(yi[i].FF - yi[i+1].FF, MP(yi[i].SS, yi[i+1].SS)));
    }

    while (pq.size() > 0) {
        auto t = pq.top(); pq.pop();

        int i = t.SS.FF;
        int j = t.SS.SS;

        if (union_query(par, i) == union_query(par, j)) {
            continue;
        }
        else {
            res -= t.FF;
            union_merge(par, i, j);
        }
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 7528
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if ((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int r;
  cin >> r;
  cout << r*r << endl;

  return 0;
}

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

bool number753_checker(string num_str) {
    if (num_str.find("3") == string::npos) {
        return false;
    }
    if (num_str.find("5") == string::npos) {
        return false;
    }
    return num_str.find("7") != string::npos;
}

int solve(int n) {
    stack<string> targets;
    targets.push("3");
    targets.push("5");
    targets.push("7");
    int ans = 0;
    while (!targets.empty()) {
        string target_num = targets.top();
        targets.pop();

        if (stoll(target_num) > n) {
            continue;
        }

        if (number753_checker(target_num)) {
            ++ans;
        }
        targets.push(target_num + "3");
        targets.push(target_num + "5");
        targets.push(target_num + "7");
    }
    return ans;
}

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

    cout << solve(n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,m,x,i,s=0,c=0,d;
        scanf("%d%d%d",&n,&m,&x);
        int a[n+1];
        for(i=0;i<n+1;i++)
                a[i]=0;
        for(i=0;i<m;i++){
                scanf("%d",&d);
                a[d]=1;
        }
        for(i=x;i<=n;i++)
                s+=a[i];
        for(i=0;i<=x;i++)
                c+=a[i];
        if(s>=c)printf("%d\n",c);
        else printf("%d\n",s);
        return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=4005,M=2e5+5,mod=1e9+7;
int n,x[M],y[M],f[N][N],fac[N<<1],inv[N<<1],ans;
void init(int n){
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	rep (i,2,n) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	rep (i,2,n) inv[i]=(ll)inv[i-1]*inv[i]%mod;
}
int C(int n,int m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main(){
	scanf("%d",&n); init(8000);
	rep (i,1,n) scanf("%d%d",&x[i],&y[i]),f[2001-x[i]][2001-y[i]]++;
	rep (i,1,4001) rep (j,1,4001) f[i][j]=((ll)f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	rep (i,1,n) ans=(ans+mod-C(2*(x[i]+y[i]),2*x[i]))%mod;
	rep (i,1,n) ans=(ans+f[2001+x[i]][2001+y[i]])%mod;
	ans=(ll)ans*((mod+1)/2)%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 64512
N,P =map(int, input().split())
A = list(map(int, input().split()))
l0,l1=0,0

for a in A:
    if a%2==0:
        l0 +=1
    else:
        l1 +=1

if P==1 and l1==0:
    print(0)
elif P==0 and l1==0:
    print(2**N)
else:
    print(2**(N-1))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
k = max(a) + 1

b = [0 for i in range(n)]
c = [0 for i in range(k)]

for j in range(n):
    c[a[j]] += 1

for i in range(1,k):
    c[i] += c[i-1]

for j in reversed(range(n)):
    b[c[a[j]] - 1] = a[j]
    c[a[j]] -= 1

print(*b)

Measured memory_bytes: 233788
import Foundation

func readArrayDouble() -> [Double] {
    readLine()!.split(separator: " ").map({Double($0)!})
}

let line = readArrayDouble()
let (A, B, H, M) = (line[0], line[1], line[2], line[3])
let degree = 5.5 * ((H * 60) + M)
print((A * A + B * B - 2 * A * B * cos(degree * Double.pi / 180)).squareRoot())


Measured memory_bytes: 13664
n = int(input())
A = list(map(int,input().split()))
aj = max(A)
temp = 10000000000
for a in A:
    if a != aj:
        if temp > abs(int(aj/2+0.5)-a):
            ai = a
            temp = abs(int(aj/2+0.5)-a)
            
print(aj,ai)

Measured memory_bytes: 14428
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
# N, M = map(int,input().split())

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)
def inpl(): return list(map(int, input().split()))

N, M = inpl()
A = [""]*M
P = [[] for _ in range(N+1)]
for i in range(M):
  p, y = inpl()
  P[p].append((y, i))

# print(P)
for ind, p in enumerate(P):
  p = sorted(p, key=lambda x: x[0])
  for j, (y, i) in enumerate(p):
    A[i] = "{}{}".format(str(ind).zfill(6), str(j+1).zfill(6))

print("\n".join(A))


Measured memory_bytes: 44536
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	static public void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();

		String next = "";
		if (s.length() < 26) {
			for (char c = 'a'; c <= 'z'; c++) {
				if (s.indexOf(c) < 0) {
					next = s + c;
					break;
				}
			}
		} else {
			Set<Character> set = new TreeSet<>();
			set.add(s.charAt(s.length() - 1));
			out: for (int i = s.length() - 2; i >= 0; i--) {
				char check = s.charAt(i);
				for (Character val : set) {
					if (check < val) {
						next = s.substring(0, i) + val;
						break out;
					}
				}
				set.add(check);
			}
			if (next.length() == 0) {
				next = "-1";
			}
		}
		System.out.println(next);
	}
}


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

int N;
vector<int> G[200100];
vector<int> rG[200100];

int nexts[200100];
bool used[200100];
bool is_loop[200100];
int A[200100];

int get_grundy(int pos){
    set<int> s;
    for(int to : G[pos]){
        s.insert(A[to]);
    }
    for(int i = 0; ; i++){
        if(s.count(i) == 0){
            return i;
        }
    }
}

void detect_loop(int pos){
    used[pos] = true;
    for(int to : rG[pos]){
        if(!used[to]){
            nexts[pos] = to;
            detect_loop(to);
        }
        else{
            int cnt = 0;
            int c = to;
            while(1){
                is_loop[c] = true;
                cnt++;
                if(c == pos) break;
                c = nexts[c];
            }
        }
    }
}

void rec(int pos){
    set<int> s;
    for(int to : G[pos]){
        rec(to);
        s.insert(A[to]);
    }
    
    for(int i = 0; ; i++){
        if(s.count(i) == 0){
            A[pos] = i;
            break;
        }
    }
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        p--;
        rG[i].push_back(p);
        G[p].push_back(i);
    }
    
    memset(nexts, -1, sizeof(nexts));

    detect_loop(0);

    for(int i = 0; i < N; i++){
        if(is_loop[i] && G[i].size() > 1){
            // 葉から順番に割り当てを行う
            for(int to : G[i]){
                if(is_loop[to]) continue;
                rec(to);
            }

        }
    }

    // loopの構成要素を1つ選び、そこに可能な割り当てを行う
    // 残りの要素
    int start = -1;
    for(int i = 0; i < N; i++){
        if(is_loop[i]){
            start = i;
            break;
        }
    }

    // startに割り当てる要素を決定
    set<int> st;
    for(int to : G[start]){
        if(is_loop[to]) continue;
        st.insert(A[to]);
    }

    vector<int> v;
    int cnt = 0;
    for(int i = 0; ; i++){
        if(st.count(i) == 0){
            if(cnt == 0){
                v.push_back(i);
                cnt++;
            }
            else if(cnt == 1){
                v.push_back(i);
                break;
            }
        }
    }

    for(int val : v){
        for(int i = 0; i < N; i++){
            if(is_loop[i]){
                A[i] = -1;
            }
        }

        A[start] = val;

        int cpos = start;
        while(1){
            int npos = -1;
            for(int to : rG[cpos]){
                if(is_loop[to]){
                    npos = to;
                    break;
                }
            }

            cpos = npos;

            if(cpos == start) break;

            A[cpos] = get_grundy(cpos);
        }

        int check = get_grundy(start);
        if(check == A[start]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 30720
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define MOD 1000000007
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
#define END system("PAUSE");return 0
string s;
int a[3];
signed main() {
	cin >> s;
	rep(i, s.size())a[s[i] - 'a']++;
	sort(a, a + 3);
	if (a[2] - a[0] <= 1)puts("YES");
	else puts("NO");
	END;
}


Measured memory_bytes: 760
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

divisors=make_divisors(n)
divisors.pop(0)
cnt=0
for div in divisors:
    # print(n,div)
    # print(div, prime_fact(div), set(prime_fact(div)))
    if len(set(prime_fact(div)))==1 and n>1 and n%div==0:
        n//=div
        cnt+=1
    elif n<1:
        break
print(cnt)


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

int N, M, Goal, D, G[50];

bool existLine(int x, int y, int dir) {
  int i = x + (dir == -1 ? -1 : 0);
  if(i < 0 || i >= N-1) return false;
  return (G[y] & (1<<i));
}

bool simulation() {
  int x = M;
  for(int i = 0; i < D; ++i) {
    for(int d = -1; d <= 1; d += 2) {
      if(existLine(x, i, d)) {
	x += d;
	break;
      }
    }
  }
  return x == Goal;
}

bool canDrawLine(int i, int j) {
  for(int d = -1; d <= 1; d++) {
    int nj = j + d;
    if(nj < 0 || nj >= N-1) continue;
    if(G[i] & (1<<nj)) return false;
  }
  return true;
}

void solve() {
  if(simulation()) {
    cout << 0 << endl;
    return;
  }
  for(int i = 0; i < D; ++i) {
    for(int j = 0; j < N-1; ++j) {
      if(canDrawLine(i,j)) {
	int mem = G[i];
	G[i] |= (1<<j);
	if(simulation()) {
	  cout << i+1 << " " << j+1 << endl;
	  return;
	}
	G[i] = mem;
      }
    }
  }
  cout << 1 << endl;
}

int main() {
  while(cin >> N && N) {
    cin >> M;
    cin >> Goal;
    cin >> D;
    --M; --Goal;
    for(int i = 0; i < D; ++i) {
      G[i] = 0;
      for(int j = 0; j < N-1; ++j) {
	char c;
	cin >> c;
	if(c == '1') G[i] |= (1<<j);
      }
    }
    solve();
  }
  return 0;
}

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

int main() {
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; ++i) cin >> T[i];
    sort(T.begin(), T.end());
    int res = 0;
    for (int i = 0; i < N;) {
        ++res;
        int start = i;
        while (i < N && T[i] - T[start] <= K && i - start < C) ++i;
    }
    cout << res << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD3 1000000000
#define MOD2 998244353 
float PHI = 1.6180339;
const float  PI_F=3.14159265358979f;
#define MAX 1000 m
#define endl "\n"    
#define manhunt 32 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define pi 3.1415926535897932384626433
//typedef long long float;
#define int long long
//#define double long double
typedef pair<int, int> pii;
//#define float unsigned long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define CHAR_SIZE 26 

int modpow(int x, int n, int m) { if (n == 0) return 1%m; long long u = modpow(x,n/2,m); u = (u*u)%m; if (n%2 == 1) u = (u*x)%m; return u; } 


int add(int x, int y,int m) 
{
	x += y;
	if (x >= m) return x - m;
	return x;
}
int sub(int x, int y) 
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int inv(int a, int m = MOD2)
{
	return modpow(a, m - 2, m);
}
int mul(int a, int b,int m) 
{
	return (long long) a * b % m;
}


int nCrModp(int n, int r, int p) 
{ 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
    if(a.first==b.first)
    return a.second<b.second;
      return (a.first > b.first); 
       //return (a.first-a.second)>(b.first-b.second);
}

vector<int> z_function(string &s)
{
	int n=s.size();
	vector<int> z(n);
	for(int i=1,l=0,r=0;i<n;i++)
	{
		if(i<=r)
			z[i]=min(r-i+1, z[i-l]);
		while(i+z[i]<n && s[z[i]]==s[i+z[i]])
			z[i]++;
		if(i+z[i]-1>r)
			l=i, r=i+z[i]-1;
	}
	return z;
}

bool isprime(int n) 
{ 
    if (n <= 1)  return false; 
  
    for (int i=2; i*i<=n; i++) 
        if (n%i == 0) 
            return false; 
  
    return true; 
}

void SieveOfEratosthenes(int n, bool isPrime[]) 
{ 
    isPrime[0] = isPrime[1] = false; 
    for (int i=2; i<=n; i++) 
        isPrime[i] = true; 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (isPrime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                isPrime[i] = false; 
        } 
    } 
}


int32_t main()
{
    /* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); */
    FAST
    cout << fixed << setprecision(16);

    double n,d;
    cin>>n>>d;
    int a=0;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        double val=x*x;
        double val2=y*y;
        double c=val+val2;
        double ans=sqrt(c);
        //cout<<ans<<endl;
        if(ans<=d)
        ++a;
    }
    cout<<a<<endl;
    
    
    return 0;
}





Measured memory_bytes: 3864
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		if (a>=30) {
			System.out.println("Yes");
        } else {
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35680
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int[] input = Arrays.stream(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		long ans = IntStream.rangeClosed(input[0], input[1])
				.mapToObj(String::valueOf)
				.filter(s -> s.equals((new StringBuilder(s)).reverse().toString()))
				.count();
		System.out.println(ans);
	}

}

Measured memory_bytes: 42036
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> P(N); rep(i, 0, N) {
		cin >> P[i];
		P[i]--;
	}
	vector<int> idx(N);
	rep(i, 0, N) {
		idx[P[i]] = i;
	}
	dump(idx);
	int ans = N - 1;
	int x = 1;
	rep(i, 0, N - 1) {
		if (idx[i] < idx[i + 1]) {
			x++;
			chmin(ans, N - x);
		}
		else {
			x = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

a,b = ( int(x) for x in input().split() )

min_ = min([a,b])

ret = a * b

for i in reversed(range(1,min_+1)):
  if a % i == 0 and b % i == 0:
    ret = int(a * b / i)
    break

print(ret)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
using namespace std;
int main(void) {
	long long n, a;
	cin >> n;
	map<long long, long long > mp;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++mp[a];
	}
	long long ans = 0;
	for (auto x : mp) {
		if (x.second >= x.first)
			ans += x.second - x.first;
		else
			ans += x.second;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

    int kekka = 0;
    char k;
    cin >> k;
    for(int i = 0; i < 3; i++)
    {
        char j;
        cin >> j;
        if(j == k)
        {
            kekka = 1;
        }
        k = j;
    }

    if(kekka == 1)
    {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N, M, X;
    cin>>N>>M>>X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i, N){
        cin>>C[i];
        rep(j, M){
            cin>>A[i][j];
        }
    }
    ll Ans=INF;
    for(ll i=0; i<(1<<N); i++){
        vector<ll> Sum(M, 0);
        ll Cost=0;
        for(ll j=0; j<N; j++){
            if(i&(1<<j)){
                Cost+=C[j];
                rep(k, M){
                    Sum[k]+=A[j][k];
                }
            }
        }
        bool T=true;
        rep(j, M){
            if(Sum[j]<X)T=false;
        }
        if(T)Ans=min(Ans, Cost);
    }
    if(Ans==INF){
        cout<<-1<<endl;
    }
    else{
        cout<<Ans<<endl;
    }
}

Measured memory_bytes: 3628
s = list(input())
K = int(input())

for i in range(len(s)):
    cnt_to_a = (ord('z') - ord(s[i]) + 1 ) % 26
    if cnt_to_a <= K:
        K -= cnt_to_a
        s[i] = 'a'
if K > 0:
    s[-1] = chr(ord(s[-1]) + K % 26)
print("".join(s))

Measured memory_bytes: 4148
//気がくるってしまった
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int M = 1e9;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], *di = dn;

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


	int N = getint();
	int A[500001];
	*A = getint();
	int d[500000];
	rep(i, N) {
		*(d + i) = getint();
		int ab = *(d + i) - *(A + i);
		if(*(A + i) >= *(d + i)) *(A + i + 1) = -ab;
		else if (*(A + i) >= ab) *(A + i + 1) = ab;
		else *(A + i + 1) = *(A + i);
	}
	int B[500000];
	*(B + N - 1) = 1;
	for(int i = N - 1; i >= 1; i--) {
		if (*(B + i) >= M || *(B + i) * 2 <= *(d + i)) *(B + i - 1) = *(B + i);
		else *(B + i - 1) = *(B + i) + *(d + i);
	}
	int Q = getint();
	char n[3] = { 'N', 'O', '\n' };
	char y[4] = { 'Y', 'E', 'S', '\n' };
	rep(i, Q) {
		int q = getint() - 1;
		if (*(A + q) < *(B + q)) {
			memcpy(di, n, 3);
			di += 3;
		}
		else {
			memcpy(di, y, 4);
			di += 4;
		}
	}

	fwrite(dn, di - dn, 1, stdout);

	cin >> N;
	
	Would you please return 0;
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Solve();
    }

    static void Solve()
    {
        int n = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int cnt = 0;
        for(int i = 1; i < n - 1; i++)
        {
            if (d[i - 1] > d[i] && d[i] >= d[i + 1]) cnt++;
            else if (d[i + 1] > d[i] && d[i] >= d[i - 1]) cnt++;
        }

        Console.WriteLine(cnt);
        
    }
}



Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#define rep(i,n) for (int i = 0; i < n; ++i)
const int INF = 1001001001;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<pair<int,int>> p;
    int x, y;
    rep(i,n) {
        cin >> x >> y;
        p.emplace_back(x, y);
    }

    auto dist = [](pair<int,int> p1, pair<int,int> p2) {
        double dx = p1.first - p2.first;
        double dy = p1.second - p2.second;
        return sqrt(dx*dx + dy*dy);
    };

    vector<int> per(n);
    rep(i,n) per[i] = i;
    double ans = 0;
    int count = 0;
    do {
        rep(i, n-1) {
            ans += dist(p[per[i]], p[per[i+1]]);
        }
        count++;
    } while (next_permutation(per.begin(), per.end()));
    printf("%.10f\n", ans / count);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll x;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(x);
	for(ll i = -1000;i <= 1000;i++){
		for(ll j = -1000;j <= 1000;j++){
			ll sum = i * i * i * i * i - j * j * j * j * j;
			if(sum == x){
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  long double A, B;
  cin >> A >> B;
  cout << (unsigned long long)floor(A*B) << endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll H,N;
  cin>>H>>N;
  vector<ll> A(N);
  REP(i,N){
    cin>>A[i];
  }
  if(accumulate(ALL(A),0)>=H){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3932
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N;
        N = scanner.nextInt();
        switch (N){
            case 1:
                System.out.println("Hello World");
                break;
            case 2:
                int A,B;
                A = scanner.nextInt();
                B = scanner.nextInt();
                System.out.println(A + B);
                break;
        }
    }
}

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

int main(){
  int n, m;
  cin >> n >> m;
  map<int,int> mp;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    mp[a]++;
    mp[b]++;
  }
  for(auto e : mp) {
    if (e.second & 1) {
      puts("NO");
      return 0;
    } 
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

ll kai[1000010];

ll mypow(ll a, ll b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    ll ans = mypow(a,b/2);
    ans *= ans;
    ans %= mod;
    if (b&1) ans *= a;
    return ans % mod;
}

ll inv(ll k) {
    return mypow(k,mod-2);
}

ll c(ll a, ll b) {
    return kai[a] * inv(kai[b]) % mod * inv(kai[a - b]) % mod;
}

int main() {
    ll x,y;
    cin >> x >> y;
    ll sum = (x + y) / 3;
    if (sum * 3 != x + y) {
        cout << 0 << endl;
        return 0;
    }
    x -= sum;
    y -= sum;
    if (x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    if (x == 0 || y == 0) {
        cout << 1 << endl;
        return 0;
    }
    kai[0] = 0;
    kai[1] = 1;
    for (ll i = 2; i < 1000010; i++) {
        kai[i] = kai[i - 1] * i;
        kai[i] %= mod;
    }
    cout << c(sum,x) << endl;
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

int chars[26]={};

main(){
    string w;
    cin >> w;
    REP(i,LEN(w)){
        chars[w[i]-'a']++;
    }
    bool ans = true;
    REP(i,26){
        if(chars[i]%2) ans = false;
    }

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
VI pos[100001];
LL fact[100001];
LL inv[100001];
LL inv_fact[100001];
LL mod_pow(LL x, LL a) {
	if (a == 0) return 1;
	if (a % 2 == 0) {
		LL ret = mod_pow(x, a / 2);
		return (ret*ret) % MOD;
	}
	else {
		return (x*mod_pow(x, a - 1)) % MOD;
	}
}
LL comb(LL n, LL k) {
	if (n < k) return 0;
	LL ans = (fact[n] * inv_fact[k]) % MOD;
	ans = (ans*inv_fact[n - k]) % MOD;
	return ans;
}
int main() {
	int n;
	cin >> n;
	rep(i, n+1) {
		int a;
		cin >> a;
		pos[a].push_back(i);
	}
	int x;
	REP(i, 1, n + 1) {
		if (pos[i].size() == 2) {
			x = i;
			break;
		}
	}
	REP(i, 1, n + 1) {
		inv[i] = mod_pow(i, MOD - 2);
	}
	fact[0] = 1;
	inv_fact[0] = 1;
	REP(i, 1, n + 1) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * inv[i]) % MOD;
	}
	cout << n << endl;
	REP(i, 2, n + 2) {
		LL ans = (comb(n - 1, i - 2) + comb(n - 1, i)) % MOD;
		ans = (ans + 2*comb(n - 1, i - 1)) % MOD;
		ans = (ans - comb(pos[x][0]+n-pos[x][1], i - 1) + MOD) % MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 9088
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
ll n,m,k;
int main()
{
	cin>>n>>m>>k;
	if(n*m<k){
		cout<<"No";
		return 0;
	}
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=m;j++){
			ll count=0;
			count+=i*m;
			count+=n*j;
			count-=i*j*2;
				if(count==k){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char buf[1000];
pair<pair<string,int>, int> data[100];
int res[100];
int main(){
  int i, k;
  rd(N);
  for(i=0;i<N;i++){
    rd(buf);
    rd(k);
    data[i].second = i;
    data[i].first = make_pair((string)buf, -k);
  }
  sort(data, data+N);
  for(i=0;i<N;i++){
    res[i] = data[i].second + 1;
  }
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      wt_L(res[Lj4PdHRW]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N;
// char buf[1000];
// 
// pair<pair<string,int>, int> data[100];
// int res[100];
// 
// {
//   int i, k;
// 
//   rd(N);
//   rep(i,N){
//     rd(buf, k);
//     data[i].second = i;
//     data[i].first = make_pair((string)buf, -k);
//   }
//   sort(data, data+N);
//   rep(i,N) res[i] = data[i].second + 1;
// 
//   wtLn(res(N));
// }


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>

#define ll long long

using namespace std;


int main(void){
    char str[100];
    stack<ll> s;
    ll a, b;
    
    while (scanf("%s", str) != EOF) {
        if (str[0] == '+') {
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(a + b);
        }
        else if (str[0] == '-') {
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(b - a);
        }
        else if (str[0] == '*') {
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(a * b);
        }
        else {
            s.push(atoi(str));
        }
    }
    
    cout << s.top() << endl;
}



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

using namespace std;




int main()
{
    int n , ans = 0;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
    {
        int aux = i , s = 0;
        while(aux)
        {
            s++;
            aux /= 10;
        }
        ans += (s % 2 == 1);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int w, h, xs, ys, xg, yg;
int field[100][100];

bool recur(int c, int x, int y){
	if(field[x][y] != c){ return false; }
	if(x == xg && y == yg){ return true; }
	field[x][y] = -1;
	if(x > 0 && recur(c, x - 1, y)){ return true; }
	if(x < w - 1 && recur(c, x + 1, y)){ return true; }
	if(y > 0 && recur(c, x, y - 1)){ return true; }
	if(y < h - 1 && recur(c, x, y + 1)){ return true; }
	return false;
}

int main(){
	while(true){
		scanf("%d%d", &w, &h);
		if(w == 0 || h == 0){ break; }
		scanf("%d%d%d%d", &xs, &ys, &xg, &yg);
		xs--; ys--; xg--; yg--;
		int n;
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			int c, d, x, y;
			scanf("%d%d%d%d", &c, &d, &x, &y);
			x--; y--;
			for(int j = 0; j < 2; j++){
				for(int k = 0; k < 4; k++){
					if(d == 0){
						field[x + k][y + j] = c;
					}else{
						field[x + j][y + k] = c;
					}
				}
			}
		}
		puts(recur(field[xs][ys], xs, ys) ? "OK" : "NG");
	}
	return 0;
}

Measured memory_bytes: 0
function main(arg) {
  var str = arg[0].split('');
  var rslt = 'No';
  str.forEach(a => {
  	if(a == 7) {
      rslt = 'Yes'
    }
  })
  console.log(rslt)
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n'));

Measured memory_bytes: 29588