akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            int n = int.Parse(Console.ReadLine());

            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            int[] arr = new int[n];
            for (int index = 0; index < n; index++)
            {
                int num = int.Parse(array[index]);
                arr[index] = num;
            }

            string a=null;
            for(int i = 0; i < arr.Length; i++)
            {
                if (arr[i] % 2 == 0)
                {
                    if (arr[i] % 3 != 0 && arr[i] % 5 != 0)
                    {
                        a = "DENIED";
                        break;
                    }
                    else
                    {
                        a= "APPROVED";
                    }
                }
                else
                {
                    a="APPROVED";
                }
            }
            Console.WriteLine(a);
        }
    }
}



Measured memory_bytes: 27536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main
{
	private static void solve(FastScanner fr) {
		int d = fr.nextInt();
		int t = fr.nextInt();
		int s = fr.nextInt();

		sout(s*t>=d?"Yes":"No");
	}
    public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int n = 1;
		// int n = fs.nextInt();
		while (n-- > 0)	{
			solve(fs);
        }
    }

    private static void sout()          { System.out.println();  }
    private static void sout(String s)  { System.out.println(s); }
    private static void sout(int s)     { System.out.println(s); }
    private static void sout(long s)    { System.out.println(s); }
    private static void sout(double s)  { System.out.println(s); }
    
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); }
			return st.nextToken();
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		int nextInt() {	return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}


Measured memory_bytes: 25304
import numpy as np
import itertools

#m switch
#n light

m,n=map(int,input().split())

x=np.array([[0]*m for i in range(n)])

for i in range(n):
	tmp=list(map(int,input().split()))
	for j in range(1,tmp[0]+1):
		x[i][tmp[j]-1]=1

y=list(map(int,input().split()))        
      
s=[0,1]
sw=list(itertools.product(s, repeat=m))

cnt=0

for i in range(len(sw)):
	z=x.dot(np.array(sw[i]).T)
	for j in range(n):
		if z[j]%2!=y[j]:
			break
		if j==n-1:
			cnt+=1
    
print(cnt)

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


const int maxn = 1e6+5;
int k[34] = {0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n; cin >> n;
    cout << k[n] << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())

    cnt = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    ans = "YES" if all(c % 2 == 0 for c in cnt) else "NO"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a<b) swap(a,b);
  long long sum=gcd(a,b);
  a=a/sum;
  b=b/sum;
  cout<<a*b*sum<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())


int main()
{
  int a, b;
  cin >> a >> b;
  FOR(i, 1, 1100)
    {
    int na = i * 0.08 + 1e-9;
    int nb = i * 0.10 + 1e-9;
    if(na == a && nb == b){printf("%d\n", i);return 0;}
    }
  puts("-1");
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
    int n, i, x, min = __INT_MAX__, max = -__INT_MAX__;
    long sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &x);
        if(x > max) max = x;
        if(x < min) min = x;
        sum += x;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2104
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<ll,ll> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,h[100005]={},dp[100005]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  for(int i=0; i<=n; i++) {
    dp[i]=inf;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2; i<n; i++) {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

ll solver(ll x, ll c, ll d){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c, d);

    return res;
}

int main() {
    ll A, B, C, D, ans = 0;
    cin >> A >> B >> C >> D;

    ans = solver(B, C, D) - solver(A-1, C, D);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
ST = [list(map(int, input().split())) for _ in range(M)]
ST.sort()
Edge_out = [[] for _ in range(N+1)]
Edge_in = [[] for _ in range(N+1)]
for s, t in ST:
    Edge_out[s].append(t)
    Edge_in[t].append(s)

P_node = [0] * (N+1)  # 辿り着く確率
P_edge = [0] * (N+1)  # そこから出る辺を使う確率
P_node[1] = 1
for v, edge_out in enumerate(Edge_out[1:-1], 1):
    deg = len(edge_out)
    p = P_node[v] / deg
    P_edge[v] = p
    for u in edge_out:
        P_node[u] += p

# E_node_in = [0] * (N+1)  # ノードに到着するまでの辺の個数の期待値
#
# for v, edge_in in enumerate(Edge_in[2:], 2):
#     p_sum = 0
#     su = 0
#     for u in edge_in:
#         p = P_edge[u]
#         p_sum += p
#         su += p * E_node_in[u]
#     su /= p_sum
#     su += 1
#     E_node_in[v] = su

E_node_out = [0] * (N+1)  # ノードから出発したあと通る辺の個数の期待値

for v in range(N-1, 0, -1):
    edge_out = Edge_out[v]
    su = 0
    for u in edge_out:
        su += E_node_out[u]
    su /= len(edge_out)
    su += 1
    E_node_out[v] = su


# ans = e_all = E_node_out[1]
# for s, t in ST:
#     p_st = P_edge[s]
#     e_st = E_node_in[s] + E_node_out[t] + 1
#     print("e_st,p_st=",e_st,p_st)
#     a = (e_all - p_st*e_st) / (1 - p_st)
#     print("s,t,a=",s,t,a)
#     ans = min(ans, a)

ans = 0
for s, t in ST:
    p_s = P_node[s]
    #p_st = P_edge[s]
    deg = len(Edge_out[s])
    if deg==1:
        continue
    e = (E_node_out[s] - (1+E_node_out[t]) / deg) * (deg / (deg - 1))
    a = p_s * (e - E_node_out[s])
    #print("s,t,a=", s, t, a)
    ans = min(ans, a)
print(ans + E_node_out[1])


Measured memory_bytes: 82520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long
#define int long long 
# define INF 2e5 + 5
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}

int32_t main()
{
    
    c_p_c();
    int l,r,d;
    cin>>l>>r>>d;
    if(l%d==0){
      cout<<r/d-l/d+1<<"\n";
    }
    else{
    cout<<r/d-l/d<<"\n";
    }



    return 0;


             
    
}


Measured memory_bytes: 3604
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    int ma = 0, mi = IINF;
    rep(i, n){
        int a;
        cin >> a;
        ma = max(ma, a);
        mi = min(mi, a);
    }
    int ans = ma - mi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
 
int main(){
  string s;
  int k;
  cin >> k;
  cin >> s;

  if(s.size() <= k){
    cout << s << endl;
  }else{
    for(int i;i < k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }

  }


Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    char a[11];
    int num,cnt=0;
    cin>>a>>num;
    int len=strlen(a);
    for(int i=0;i<num;i++){
        char b[11];
        cin>>b;
        char c[21];
        strcpy(c,b);
        strcat(c,b);
        for(int j=0;j<10;j++){
            if(!strncmp(c+j,a,len)){
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;



    return 0;
}

Measured memory_bytes: 1180
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  if (k % 2) {
    n /= k;
    cout << n * n * n << endl;
  } else {
    auto m = n / k;
    auto l = (n + k / 2) / k;
    cout << m * m * m + l * l * l << endl;
  }
}



Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG: ttwo
*/

#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("ttwo.in");
ofstream fout("ttwo.out");

int dp[100001];
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto& it : a) cin >> it;

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    for (int i = 2; i < n; i++){
        int m = INT_MAX;
        for (int j = 1; j <= k && i - j >= 0; j++){
            m = min(dp[i - j] + abs(a[i] - a[i-j]), m);
        }
        dp[i] = m;

    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> k(M), p(M);
    vector<vector<int>> s(M, vector<int>(N, INF));
    vector<bitset<10>> x(M);
    rep(i, 0, M){
        cin >> k.at(i);
        rep(j, 0, k.at(i)){
            cin >> s.at(i).at(j);
            x.at(i).set(s.at(i).at(j) - 1, 1);
        }
    }
    rep(i, 0, M) cin >> p.at(i);
    //rep(i, 0, M) cout << x.at(i) << endl;
    
    int count = 0;
    rep(tmp, 0, 1 << N){
        bool can = true;
        bitset<10> y(tmp);
        rep(i, 0, M){
            int co = 0;
            rep(j, 0, 10){
                if(x.at(i).test(j)){
                    //cout << "x.at(i).test(j) " << i << " " << j << endl;
                    if (y.test(j)) {
                        co++;
                        //cout << "i " << i << " j " << j << endl;
                    }
                }
            }
            if (co % 2 != p.at(i)) can = false;
            //cout << "y " << y << " co " << co <<endl;
        }
        if (can) count++;
        //cout << "count " << count << endl;
        //cout << endl;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : 03 September, 2k20
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc042/tasks/abc042_a
|   Algorithm   :
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

void test_case()
{
    int n, l;
    cin >> n >> l;

    vector <string> vc(n);
    for(string &x: vc)cin >> x;

    sort( all(vc) );
    for(string x: vc)cout << x;
    cout << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}

/* ここからコード開始 */

int main(){
  kyopro;
  ll N, K;
  cin >> N >> K;
  ll keta{};
  for(; K >> keta > 0; keta++);
  vector<ll> Asum(40);
  rep(i, 0, N){
    ll A;
    cin >> A;
    rep(j, 0, 40){
      Asum[j] += (A >> j) % 2;
    }
  }
  // rep(i, 0, 40){
  //   cout << Asum[i] << rt;
  // }
  // cout << keta << rt;
  ll sum{};
  rep(i, 0, keta+1){
    ll tmp{};
    // cout << i << endl;
    // test(1);
    rem(j, 39, -1){
      if(j >= i) tmp = tmp*2 + ((K >> j)%2 ? N - Asum[j] : Asum[j]);
      else if(j == i-1) tmp = (K >> j)%2 ? tmp*2 + Asum[j] : 0;
      else tmp = tmp*2 + max(N - Asum[j], Asum[j]);
      // cout << j << sp << tmp << rt;
    }
    sum = max(tmp, sum);
  }
  cout << sum << rt;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
string s;
inline bool ok(string &s) {
    int l = 0, r = s.size();
    --r;
    while (l <= r) {
        if (s[l] != s[r])
            return false;
        ++l, --r;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    string s;
    cin >> s;
    int N = s.size();
    string l = s.substr(0, (N - 1) / 2);
    string r = s.substr((N + 1) / 2);
    if (!ok(s) || !ok(l) || !ok(r)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        sc.close();

        long i = 0;
        for (i = 1;; i++) {
            if (C - B * i <= 0 || A - D * i <= 0)
                break;
        }

        if (C - B * i <= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35744
/*****************************

       C - Rectangle

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

#include<stdio.h>

int main(void)
{
	int a, b;
	int S;
	int L;

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

	S = a * b;
	L = (2 * a) + (2 * b);

	printf("%d %d\n", S, L);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
    double r;
    double a;
    double b;
    
    cin>>r;
    
    a=r*r*3.141592653589;
    b=2*r*3.141592653589;
    
    printf("%f %f\n",a,b);
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 1e+9
#define MININF -INF
using namespace std;
using ll = long long;
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; }

vector<int> to[200010];
vector<int> ans;
void dfs(int v,int f=-1){
    for(int u:to[v]){
        if (u == f) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}
int main(){
    int n,q;
    cin >> n >> q;
    int a,b;
    REP(i,n-1){
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    int p,x;
    REP(i,q){
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    REP(i,n){
        PRINT(ans[i]);
    }
}


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

using namespace std;

int main(){
  long N,W;
  cin >> N >> W;
  vector<long>v(N);
  vector<long>w(N);

  // dp[i][j] : 商品iまで、重さjまでの価値最大値
  vector<vector<long> > dp(N, vector<long>(W+1, 0));


  for(int i = 0; i < N; i++){
    cin >> w.at(i) >> v.at(i);
  }

  for(int j = 0; j < W+1; j++){
    dp[0][j] = (j < w[0]) ? 0 : v[0];
  }

  for(int i = 1; i < N; i++){
    for(int j = 0; j < W+1; j++){
      if(j - w[i] >= 0){
        dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  cout << dp[N-1][W] << endl;
}

Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll bs(ll n,ll m){
	ll y,b,a;
	if(n>m)
	{
		a=n;
		n=m;
		m=a;
		
	}
	b=m;
	y=n;
	int f=0;//定义一个f，用来判断m是不是n的倍数
	while(b%y!=0)
	{
		a=b%y;
		b=y;
		y=a;
		f=1;
	}
	if(f==1 && y==1)//如果m不是n的倍数，而且最大公因数为1，最小公倍数为n*m
		b=n*m;
	else if(f==0){//如果m是n的倍数，则最小公倍数为m
		b=m;
	}
	else
		b=n*m/y;//否则为最大公因数*m
	return b;
}
int main(){
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d;
	e = bs(c,d);
	ll s1,s2,s3;
	if(a%c != 0){
		s1 = (b/c)-(a/c);
	}
	else{
		s1 = (b/c)-(a/c)+1;
	}
	if(a%d != 0){
		s2 = (b/d)-(a/d);
	}
	else{
		s2 = (b/d)-(a/d)+1;
	}
	if(a%e != 0){
		s3 = (b/e)-(a/e);
	}
	else{
		s3 = (b/e)-(a/e)+1;
	}
//	cout<<e<<" "<<s1<<" "<<s2<<" "<<s3<<endl;
	ll ans = b-a+1-(s1+s2-s3);
	cout<<ans<<endl;
	return 0;
}

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


using namespace std;

int a[200002] = {};
int b[200002] = {};



int main(){
  int n;
  int m = 0;
  cin >> n;

  for (int i=1;i<=n;i++) {
    a[i] = -1;
    b[i] = -1;
  }

  for (int i=1;i<=n;i++) {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
    if (i > n/2) {
      b[i] = tmp;
      m += b[i];
    }
  }
  for (int i=n/2;i>0;i--) {
    int b_mult = 0;
    for (int j=2;i*j<=n;j++) {
      if (b[i*j] < 0) {
	cerr << "unassigned on " << i*j << endl;
      }
      b_mult += b[i*j];
      b_mult %= 2;
    }
    b[i] = (b_mult + a[i]) %2;
    m += b[i];
  }
  cout << m << endl;
  for (int i=1;i<=n;i++) {
    if (b[i]==1) {
      cout << i << " ";
    }
  }
  cout << endl;
  return(0);
}


Measured memory_bytes: 2560
//--------------------------------------------------------------------------------
// Code By:
//					######                  #               ######
//					##   #                  #               #
//					#####      ##       #####      ##       #   ###
//					##   #              #   #               #   # #
//					##    #	            #####               ##### #
//---------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;

                             /* ----------------------------- START of Template ---------------*/
#define ll long long int
#define FOR(x,to) for(x=0;x<(to);x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<long long int> >
#define vll vector<long long int>
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SZ(X) ((int)(X).size())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second

void getZarr(string str, vll &Z)
{
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else
        {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
   } } }}
vector<ll>isprime;
void seive(ll size){
	isprime.resize(size+1,1);
	ll i,j;
	isprime[0]=0;
	isprime[1]=0;
	for(i=2;i*i<=size;i++){
		if(isprime[i]){
			for(j=2;j*i<=size;j++)isprime[i*j]=0;
		}
	}
}
ll power(ll x,unsigned ll y, ll m){
	if(y==0)return 1;
	ll p=power(x,y/2,m);
	p=(p*p)%m;
	if(y%2!=0)p=(p*x)%m;
	return p;
}
ll modinverse(ll a,ll m){
	return power(a,m-2,m);
}


                       /* ----------------------          End Of Template --------------------------------*/

ll findans(){
		ll n;
		cin>>n;
		if(n>=1800)cout<<1;
		else if(n>=1600)cout<<2;
		else if(n>=1400)cout<<3;
		else if(n>=1200)cout<<4;
		else if(n>=1000)cout<<5;
		else if(n>=800)cout<<6;
		else if(n>=600)cout<<7;
		else if(n>=400)cout<<8;
		cout<<endl;
return 0;




}

int main(){
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t,i;
	//cin>>t;
  t=1;
	for(i=0;i<t;i++){
		findans();
	}
return 0;
}





Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,q,cnt=-1;
int fir[200000],val[200000];
int to[400000],nxt[400000];
int tag[200000];
inline void add(int a,int b)
{
	to[++cnt]=b;
	nxt[cnt]=fir[a];
	fir[a]=cnt;
	return;
}

void dfs(int i,int fa)
{
	int t;
	for(int j=fir[i];j!=-1;j=nxt[j]){
		t=to[j];
		if(t==fa)
			continue;
		val[t]+=tag[i];
		tag[t]+=tag[i];
		dfs(t,i);
	}
	return;
}

int main(void)
{
	memset(fir,-1,sizeof(fir));
	scanf("%d%d",&n,&q);
	int a,b;
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		add(a-1,b-1);
		add(b-1,a-1);
	}
	while(q--){
		scanf("%d%d",&a,&b);
		val[a-1]+=b;
		tag[a-1]+=b;
	}
	dfs(0,-1);
	for(int i=0;i<n;i++)
		printf("%d%c",val[i],i==n-1?'\n':' ');
	return 0;
}

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

using namespace std;

typedef long long LL;

int main()
{
    LL a,b,c,d;
    cin>>a>>b>>c>>d;
    LL p1=a*c,p2=a*d,p3=b*c,p4=b*d;
    LL p=max(p1,p2);
    p=max(p,p3);
    p=max(p,p4);
    cout<<p;
}



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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, m, x[N], ans, c[N];
vector <int> v[N], a, b;

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

      for(int i = 1; i <= n; i ++)
      {
            cin >> x[i];
            v[x[i] % m].pb(x[i]);
      }

      ans += v[0].size() / 2;
      if(m % 2 == 0)
            ans += v[m / 2].size() / 2;

      for(int i = 1; i <= m / 2; i ++)
      {
            if(i == (m - i)) continue;
            a = v[i];
            b = v[m - i];
            if(a.size() > b.size())
                  a.swap(b);
            int need = (b.size() - a.size()) / 2, cnt = 0;
            sort(b.begin(), b.end());
            for(int j : b)
                  c[j] ++;
            for(int j = 0; j < b.size(); j ++)
                  if(j == 0 || b[j - 1] != b[j])
                        cnt += c[b[j]] / 2;
            for(int j : b)
                  c[j] --;
            ans += a.size() + min(need, cnt);
      }

      cout << ans << endl;
}


Measured memory_bytes: 29952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>

#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b ;
    ll x =(b+1)/2;
    ll y =b/2;
    if(a==1 || b==1) cout <<1;
    else if(a%2 == 0) cout << (x+y)*(a/2);
    else cout << x*(a/2+1)+y*(a/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j,z=0,y=0,x=0,ma=0,mi=0x3f3f3f3f;
	char s[200005];
	int a,b,c,d,flag=0;
	while(~scanf("%d%d",&a,&b))
	{
		flag=0;
        for(i=0;i<=100;i++)
        {
        	for(j=0;j<=100;j++)
        	{
        		if(i*2+j*4==b&&i+j==a)
        		{
        			flag=1;
        			printf("Yes\n");
        			break;
				}
			}
		}
		if(!flag)
		printf("No\n");
	}
	
} 

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
  if(intersect(s1,s2))return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
             min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

int main()
{
  int n,a,b,c,d,h;

  while(1){
    cin>>n;
    if(n==0)break;
    cin>>a>>b>>c>>d;

    Segment s(Point(a,b),Point(c,d));
    double ans=inf;

    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>d>>h;

      Point A(a,b),B(c,b),C(c,d),D(a,d);
      double dis=min(min(getDistance(s,Segment(A,B)),getDistance(s,Segment(B,C))),
                     min(getDistance(s,Segment(C,D)),getDistance(s,Segment(D,A))));
 
      if( ((a-s.p1.x)<eps && (b-s.p1.y)<eps) && ((a-s.p2.x)<eps && (b-s.p2.y)<eps) &&
          ((s.p1.x-c)<eps && (s.p1.y-d)<eps) && ((s.p2.x-c)<eps && (s.p2.y-d)<eps))dis=0;
      if(dis<=h)ans=min(ans,dis);
      else ans=min(ans,(dis*dis+h*h)/(double)(2*h));
    }
    printf("%.10f\n",ans);

  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int A[3][3];
    bool yes[3][3];
    rep(i, 3) rep(j, 3) yes[i][j] = false;
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N; cin >> N;
    rep(i, N){
        int b; cin >> b;
        rep(j, 3) rep(k, 3) if(A[j][k] == b) yes[j][k] = true;
    }
    if((yes[0][0] && yes[0][1] && yes[0][2]) || (yes[0][0] && yes[1][0] && yes[2][0]) || (yes[0][2] && yes[1][2] && yes[2][2]) || (yes[2][0] && yes[2][1] && yes[2][2])){
        cout << "Yes" << endl;
    }
    else if(yes[1][1]){
        if((yes[0][1] && yes[2][1]) || (yes[1][0] && yes[1][2]) || (yes[0][0] && yes[2][2]) || (yes[2][0] && yes[0][2])) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 1000000007

def fact(n)
  (1..n).inject(1){ |ans,x| ans*x % MOD }
end

def pow(n,k)
  ans = 1
  while k > 0
    ans = ans*n % MOD if k.odd?
    n = n*n % MOD
    k >>= 1
  end
  ans
end

def comb(n,k)
  fact(n) * pow(fact(n-k),MOD-2) % MOD * pow(fact(k),MOD-2) % MOD
end

n, k = gets.chomp.split.map(&:to_i)
l = n-k

(1..k).each do |i|
  if l-i+1 < 0
    puts(0)
  else
    ans = comb(k-1,i-1) * comb(l+1,i) % MOD
    puts(ans)
  end
end

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

int N;

int main(){
  cin >> N;
  int A[N];
  for (int i=0;i<N;++i) cin >> A[i];
  int max = 0;
  int i_max = 0;
  int max2 = 0;
  int i_max2 = 0;
  
  for (int k=0;k<N;++k){

    if (max < A[k]) {
      max2 = max;
      max = A[k];
      i_max = k;
    }else if (A[k] > max2) {
      max2 = A[k];
      i_max2 = k;
    }
  }
  for (int j=0;j<N;++j){
    if (j == i_max) {
      cout << max2 << endl;
    } else {
      cout << max << endl;
      }
  }   
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n;
    cin >> n;
    unordered_map<string, int> ump;
    rep(i, n) {
        string cmd, str;
        cin >> cmd >> str;
        if (cmd == "insert")
            ump[str] = n;
        else {
            auto itr = ump.find(str);
            if (itr != ump.end())
                printf("yes\n");
            else
                printf("no\n");
        }
    }
}


Measured memory_bytes: 35900
#include<bits/stdc++.h>
#define fi first
#define se second

typedef long long ll;
typedef long double ld;
using namespace std;
//#define int long long
const int N = (int)2e6 + 10;
int fact[N];
int inv[N];
const int mod = (int)1e9 + 7;
int pow(int a , int b){
    if(b == 0)return 1;
    int ans = pow(a , b / 2);
    ans = (1ll * ans * ans) % mod;
    if(b&1)ans = (1ll * ans * a) % mod;
    return ans;
}
int inverse(int x){
    return pow(x , mod - 2);
}
int f(int x , int y){
    return (((1ll*fact[x+y]*inv[x])%mod)*1ll*inv[y])%mod;
}
int stupid(int x , int y){
    int answer =0;
    for(int i = 0 ; i <= x; ++i)
        for(int j = 0 ; j <= y; ++j)
            {answer += f(i , j) ; if(answer >= mod)answer-=mod;}
    return answer;
}
int calc(int x , int y){
    int ans = 0;
    for(int i = 1; i <= x + 1;++i){
        ans += f(i , y); while(ans >= mod)ans-=mod;
    }
//    assert(stupid(x , y) == ans);
    return ans;
}
int sub(int x,  int y){
    int ans = x - y + mod;
    while(ans >= mod)ans -= mod;
    return ans;
}
void preproc(){
    fact[0] = 1;
    for(int i = 1; i  < N ; ++i){
        fact[i] = (1ll * fact[i - 1] * i) % mod;
    }
    for(int i = 0 ; i < N; ++i)
        inv[i] = inverse(fact[i]);
}
signed main(){
    preproc();
    int r1 , r2 , c1 , c2; cin >> r1 >> c1 >> r2 >> c2;
    int answer = sub(sub(calc(r2 , c2),calc(r1 - 1 , c2)),calc(r2,c1-1))+calc(r1-1,c1-1);
    while(answer >= mod)answer-=mod;
    cout << answer;
    return 0;
}


Measured memory_bytes: 15872
a1, b1 = [int(i) for i in input().split()]
a2, b2 = [int(i) for i in input().split()]
a3, b3 = [int(i) for i in input().split()]


d = [[a1, b1], [a2, b2], [a3, b3]]
dl = [a1, b1, a2, b2, a3, b3]


def findn(n,l):
    res = []
    resl = []
    for it, t in enumerate(l):
        for iv, v in enumerate(t):
            if n == v:
                if iv == 0:
                    res.append(t[1])
                else:
                    res.append(t[0])
                lc = l[:]
                del lc[it]
                resl.append(lc)
    return res, resl



for i in range(1, 5):
    s, rest = findn(i, d)
    for iv, v in enumerate(s):
        last, lrest = findn(v, rest[iv])
        for ia, a in enumerate(last):
            res, nul = findn(a, lrest[ia])
            if len(res) >0 :
                judge = "YES"
            else:
                judge = "NO"

for i in range(1, 5):
    if not(i in dl):
        judge = "NO"

print(judge)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define my_max zhi5968
typedef long long ll;
using namespace std;

int main()
{
	double  m,n,d;
	scanf("%lf %lf %lf",&n,&m,&d);
//	cout<<n<<m<<d<<endl;
	double tmp=1,ans;
//	cout<<tmp<<endl;
	if(n>2*d)
		tmp=(2.0*d/n+2.0-4.0*d/n)/n;
	else
		tmp=1.0/(1.0*n);
	if(d==0)
		tmp=1.0/n;
//	printf("%llf %llf\n",tmp,m-1);
//	ans=my_pow(tmp,int(m-1));*/
	printf("%.10lf\n",tmp*(m-1));
	return 0;
}


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

int main(){
    vector<int> a(5);
    int k;
    int i,j,han;
    for(i=0;i<5;i++){
        cin >> a.at(i);
    }
    cin >> k;
    han=0;
    for(i=0;i<4;i++){
        for(j=i+1;j<5;j++){
            if(abs(a.at(i)-a.at(j))>k){
                han++;
            }
        }
    }
    if(han==0){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
using namespace std;
int H, W; 
int main() {
  cin >> H >> W;
  vector< pair<int, int> > v;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (c == 'B') {
        v.push_back(make_pair(i, j));
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    int dist_max;
    if (v[i].first < H/2) {
      if (v[i].second < W/2) {
        dist_max = (H-v[i].first-1)+(W-v[i].second-1);
      } else {
        dist_max = (H-v[i].first-1)+v[i].second;
      }
    } else {
      if (v[i].second < W/2) {
        dist_max = v[i].first + (W-v[i].second-1);
      } else {
        dist_max = v[i].first+v[i].second;
      }
    }

    if (dist_max < ans) continue;

    for (int j = 0; j < v.size(); j++) {
      if (i == j) continue;
      if (dist_max < ans) break;
      ans = max(ans, abs(v[i].first-v[j].first)+abs(v[i].second-v[j].second));
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 11080
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	string s;
	cin >> s;
	if (s == "SUN") cout << 7;
	else if (s == "SAT") cout << 1;
	else if (s == "FRI") cout << 2;
	else if (s == "THU") cout << 3;
	else if (s == "WED") cout << 4;
	else if (s == "TUE") cout << 5;
	else cout << 6;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    int a = s.at(i) - '0';
    sum += a;
  }
  if (sum % 9 == 0 || s == "0") {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3724
a = $stdin.read.split("\n")
s,k = a[0], a[1]
position = nil
i = 0
s.split('').each do |b|
  unless b == '1'
    position = i
    break
  end
  i+=1
end
if position.nil?
  puts '1'
else
  if k.to_i <= 100
    if k.to_i <= i
      puts '1'
    else
      puts s.split('')[i]
    end
  else
    puts s.split('')[i]
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int par[1000];

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

void unite(int x, int y)
{
	x = find(x); y = find(y);
	par[x] = y;
}

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

void init_UFT(int n)
{
	REP(i, n)
	{
		par[i] = i;
	}
}

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

vector<edge> es;
int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		init_UFT(n);
		es.clear();
		int a, b, c;
		REP(i, m)
		{
			cin >> a >> b >> c;
			edge e = { a, b, c };
			es.push_back(e);
		}
		sort(ALL(es), comp);
		int sum = 0;
		REP(i, es.size())
		{
			if (!same(es[i].from, es[i].to))
			{
				unite(es[i].from, es[i].to);
				sum += es[i].cost;
			}
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = arg[0];
    const S = arg[1];
    let answer  = [0];
    let counter = 0;
    
    for(let i in S) {
        if(S.charAt(i) === "I") {
            counter++;
            answer.push(counter);
        } else {
            counter--;
            answer.push(counter);
        }
    }
    
    console.log(Math.max(...answer));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX], n;
	cin >> n;

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

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 3884
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int[] c = new int[101];
			
			while(true){
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a==0 && b==0) break;
				c[a]++;
				c[b]++;
			}
			int cnt = 0;
			for(int i=1;i<101;i++){
				if(c[i]%2==1) cnt++;
			}
			
			if(cnt!=2) System.out.println("NG");
			else if(c[1]%2==1 && c[2]%2==1) System.out.println("OK");
			else System.out.println("NG");
		}	
	}	
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int S = A+B+C;
  if(S >=22) {
    cout << "bust" << endl;
  }
  else if(S <= 21) {
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256