akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main() {
	var x1, x2, y1, y2 float64
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(math.Sqrt(math.Pow(x1-x2, 2) + (math.Pow(y1-y2, 2))))
}



Measured memory_bytes: 1152
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int d,c,a;
	cin>>d>>c;

	a=d*c;
	cout<<a<<endl;


	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> C[i][j];
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(C[i][j] == '.'){
                vector<vector<char>> d = C;
                vector<vector<int>> dist(H, vector<int> (W, 0));
                queue<P> q;
                q.push(P(i, j));
                d[i][j] = '#';
                while(!q.empty()){
                    P v = q.front();
                    q.pop();
                    int x = v.first, y = v.second;
                    for(int k = 0; k < 4; k++){
                        int nx = x + dx[k], ny = y + dy[k];
                        if(0 <= nx && nx < H && 0 <= ny && ny < W && d[nx][ny] == '.'){
                            dist[nx][ny] = dist[x][y] + 1;
                            ans = max(ans, dist[nx][ny]);
                            q.push(P(nx, ny));
                            d[nx][ny] = '#';
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N, M; cin >> N >> M;
    vii adj(N);
    for(int i=0; i<M; i++){
        int A, B; cin >> A >> B;
        A--, B--;
        adj[A].push_back(B);
    }
    vi min_cycle;
    int min_dist=INF;
    for(int i=0; i<N; i++){
        for(int j=0; j<(int)adj[i].size(); j++){
            int x=adj[i][0];
            vi prev(N);
            prev[x]=-1;
            queue<int> que;
            que.push(x);
            vi dist(N, INF);
            dist[x]=0;
            adj[i].erase(find(all(adj[i]), x));
            while(!que.empty()){
                int v=que.front();
                que.pop();
                for(auto &nv : adj[v]){
                    if(dist[nv] != INF) continue;
                    dist[nv]=dist[v]+1;
                    prev[nv]=v;
                    que.push(nv);
                }
            }
            if(dist[i]+1 < min_dist){
                min_dist=dist[i]+1;
                min_cycle.resize(0);
                for(int cur=i; cur != -1; cur=prev[cur]){
                    min_cycle.push_back(cur+1);
                }
            }
            adj[i].push_back(x);
        }
    }
    if(min_cycle.size() == 0) cout << -1 << endl;
    else cout << min_cycle.size() << endl;
    for(auto &v : min_cycle){
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
from collections import deque
import sys
input = sys.stdin.readline
        
N,Q = (int(i) for i in input().split())
A = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = (int(i) for i in input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

cnt = [0]*N   
for q in range(Q):
   p,x = (int(i) for i in input().split())
   cnt[p-1] += x

st = deque([(0,-1)])
while st:
    n,par = st.popleft()
    val = cnt[n]   
    for node in A[n]:
        if node == par:
            continue
        else:
            cnt[node] += val
            st.append([node,n])

print(*cnt)

Measured memory_bytes: 105876
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	int n;cin>>n;
	vector<int> a(n);
	int ans=0;
	bool flag=false;
	rep(i,n){
		cin>>a[i];
		if(a[i]==i+1){ 
			ans++;
			if(flag){
				flag=false;
				continue;
			}
			if(i>=1&&a[i-1]==i){
				if(!flag) ans--;
				flag=true;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  for (ll i = 0; i < n; i++) cin >> s[i];

  map<char, ll> ans;
  for (ll i = 0; i < s[0].size(); i++) {
    ans[s[0][i]]++;
  }
  
  for (ll i = 1; i < n; i++) {
    map<char, ll> m;
    for (ll j = 0; j < s[i].size(); j++) {
      m[s[i][j]]++;
    }
    for (char c = 'a'; c <= 'z'; c++) {
      ans[c] = min(ans[c], m[c]);
    }
  }
  for (auto i = ans.begin(); i != ans.end(); i++) {
    for (ll j = 0; j < (i -> second); j++) {
      cout << (i -> first);
    }
  }
  cout << endl;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;


ll mabs(ll x) {
    return x > 0 ? x : -x;
}

ll dist(const pii& a, const pii& b) {
    return min(mabs(a.first - b.first), mabs(a.second - b.second));
}

struct Dsu {
    vector<int> p;

    Dsu(int n): p(n) {
        iota(p.begin(), p.end(), 0);
    }

    int get(int v) {
        return v == p[v] ? v : p[v] = get(p[v]);
    }

    bool unite(int a, int b) {
        a = get(a);
        b = get(b);
        p[a] = b;
        return a != b;
    }
};

struct Edge {
    ll len;
    int a;
    int b;

    Edge(ll l, int aa, int bb): len(l), a(aa), b(bb) {}

    bool operator<(const Edge& e) const {
        return len < e.len;
    }
};

int main() {
#ifdef LOCAL
    // freopen("input", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    int n;
    cin >> n;
    vector<pii> ps(n);
    for (int i = 0; i < n; i++)
        cin >> ps[i].first >> ps[i].second;
    vector<Edge> es;
    vector<pair<pii, int>> xs(n);
    for (int i = 0; i < n; i++)
        xs[i] = {ps[i], i};
    for (int rep = 0; rep < 2; rep++) {
        sort(xs.begin(), xs.end());
        for (int i = 0; i < n - 1; i++)
            es.push_back(Edge(dist(xs[i].first, xs[i + 1].first), xs[i].second, xs[i + 1].second));
        for (int i = 0; i < n; i++)
            swap(xs[i].first.first, xs[i].first.second);
    }
    Dsu d(n);
    ll res = 0;
    sort(es.begin(), es.end());
    for (auto e : es)
        if (d.unite(e.a, e.b))
            res += e.len;
    cout << res << "\n";
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <cstdio>
#include <string>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

const int MAX_N = 45;
int N;
int X, Y, Z;

const int J = 1 << 17;

int dp[MAX_N][J];

signed main()
{
    cin >> N >> X >> Y >> Z;

    dp[0][0] = 1;
    int L = (1 << (Z-1)) | (1 << (Y+Z-1)) | (1 << (X+Y+Z-1));

    for(int i = 0; i < N; i++) {
        for(int bit = 0; bit < J; bit++) {
            if(dp[i][bit] == 0) {
                continue;
            }

            for(int num = 1; num <= 10; num++) {
                int nextBit = (bit << num) | (1<<(num-1)); nextBit &= J-1;
                if ((nextBit & L) != L) (dp[i+1][nextBit] += dp[i][bit]) %= MOD;
            }
        }
    }

    int ans = 1;
    for(int i = 0; i < N; i++) {
        ans *= 10;
        ans %= MOD;
    }

    int tmp = 0;
    for(int bit = 0; bit < J; bit++) {
        tmp += dp[N][bit];
        tmp %= MOD;
    }

    cout << (ans + MOD - tmp) % MOD << endl;

    return 0;
}

Measured memory_bytes: 41216
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> A(N + 1), B(N + 1), C(N + 1);

  int sum = 0;
  for (int n = 1; n <= N; ++n) {
    std::cin >> A[n];
  }
  for (int n = 1; n <= N; ++n) {
    std::cin >> B[n];
    sum += B[n];
  }
  C[0] = 0;
  for (int n = 1; n <= N; ++n) {
    std::cin >> C[n];
  }

  int prev_index = 0;
  for (int index : A) {
    if (prev_index + 1 == index) sum += C[prev_index];
    prev_index = index;
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    string S; cin>>S;
    int S_len = S.size();
    vector<int> ans(S_len, 0);
    int cnt=0;
    for (int i = 0; i < S_len; ++i) {
        cnt++;
        if(S[i]!=S[i+1]) {
            if (S[i] == 'R') {
                ans[i] += (cnt+1) / 2;
                ans[i+1] += cnt / 2;
            } else if (S[i] == 'L') {
                ans[i - cnt + 1] += (cnt+1) / 2;
                ans[i - cnt] += cnt / 2;
            }
            cnt = 0;
        }
    }

    for (int i = 0; i < S_len; ++i) {
        cout<<ans[i]<<" ";
    }


    return 0;
}

Measured memory_bytes: 1024
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

ll M=1e9+7;

signed main() {
    vector<ll> t(100010,1);
    rep(i,1,100010)
        t[i] = (t[i-1] * i)%M;
    ll n,m,ans;
    cin>>n>>m;
    if (n==m){
        ans=(2ll * ((t[n]*t[m])%M))%M;
    } else if (n==m+1 || m==n+1){
        ans=(t[n]*t[m])%M;
    } else {
        ans=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int rick[256];

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	
	ini(n);
	ini(k);
	set<int> morty;
	int rick;
	FOR(i,0,k){ini(x);morty.insert(x);}
	FOR(i,n,100000){
		string tmp = to_string(i);
		int one = 0;
		FOR(i1,0,tmp.size()){if(morty.find(tmp[i1]-'0')!=morty.end())one = 1;}
		if(one == 0){rick = i;break;}
	}	
	out(rick);











	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if ((a + d - 1) / d >= (c + b - 1) / b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int N;

int main() {
  cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N-1);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  for (int i = 0; i < N-1; i++)
    cin >> C[i];

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += B[A[i]-1];
    if (i < N-1 && A[i+1] == A[i]+1) {
      sum += C[A[i]-1];
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        int[] H = nints(N, 0, 1);
        H[N] = Integer.MAX_VALUE;
        int ans = 0;
        int count = 0;
        for (int i = N-1; i >= 0; i--) {
            if (H[i] >= H[i+1]) {
                count++;
            } else {
                ans = Math.max(ans, count);
                count = 0;
            }
        }
        
        ans = Math.max(ans, count);
        System.out.println(ans);
    }
    

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 50736
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N, K;
    scan(N, K);
    auto ans = K;
    foreach (i ; 0 .. N - 1) {
        ans *= K - 1;
    }
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n,ans;
    ans = 0;
    cin >>n;
    string s,sr;
    cin>>s;
    sr = s;
    reverse(sr.begin(),sr.end());

    // cout<<s<<endl;
    while(1){
       int w = s.find('W');
       int r = sr.find('R');
       if(w==string::npos)break;
       if(r==string::npos)break;
       if(s.size()-r<=w)break;

       s[w] = 'R'; 
       s[n-r-1] = 'W';
       int si = s.size();
       sr[r] = 'W'; 
       sr[n-w-1] = 'R';
    //    cout<<sr<<endl;
       ans++;
    }
    // cout<<s<<endl;
    bool f = false;
    rep(i,s.size()){
        if(s[i]=='W'){f=true;}
        if(f){
            if(s[i]=='R'){
            s[i]=='W';
            s[i]='W';
            ans++;
            }
            
        }
    }


    cout<<ans;


    return 0;
}

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

#define mp make_pair

using namespace std;

typedef long long ll;

// uniform_int_distribution<int>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> G[100005];
int dp[100005];
int ans[100005];
map<int,int> tab;
vector<int> ps[100005], ss[100005];
int m;

void mult(int &a, int b) {
	a = ((ll)a*b)%m;
}

int dfs(int v, int p) {
	dp[v] = 1;
	vector<int> childs;

	for(int x : G[v])
		if(x != p) {
			mult(dp[v], 1+dfs(x,v));
			tab[x] = childs.size();
			childs.push_back(x);
			ps[v].push_back(dp[v]);

		}

	int aux = 1;
	for(int i = (int)childs.size()-1; i >= 0; i--) {
		int x = childs[i];
		mult(aux, 1+dp[x]);
		ss[v].push_back(aux);
	}

	return dp[v];
}

void dfs2(int v, int p) {
	ans[v] = dp[v];
	if(v != p) {
		int idx = tab[v];
		
		int prefVal = idx ? ps[p][idx-1] : 1;
		int sufVal = (int)ss[p].size()-2-idx < 0 ? 1 : ss[p][(int)ss[p].size()-2-idx];

		mult(prefVal, sufVal);
		
		int tot = (1+prefVal)%m;
		ans[v] = ((ll)ans[v]*tot)%m;
		ps[v].push_back(ans[v]);
		
		ss[v].insert(ss[v].begin(), 1);
		
		for(int i = 0; i < ss[v].size(); i++)
			mult(ss[v][i], tot);
	}

	for(int x : G[v])
		if(x != p)
			dfs2(x,v);
}

int main() {
	int n,a,b;
	scanf("%d%d",&n, &m);

	for(int i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(1,1);
	dfs2(1,1);

	for(int i = 1; i <= n; i++)
		printf("%d\n", ans[i]);

    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  set<int> dd;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    dd.insert(d);
  }
  cout<<dd.size();

  return 0;
}

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

int main() {
  double X;
  double money = 100;
  int year = 0;
  
  cin >> X;
  
  while (money < X) {
    money += floor((money / 100.0));
    year++;
  }  
  
  cout << year << endl;
}  

Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var N = int.Parse(Console.ReadLine());
        var As = Console.ReadLine().Split().Select(e => int.Parse(e)).OrderBy(e => e).ToArray();
        //As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
        if ((As.Count(e => e == 1) == 1))
        {
            Console.WriteLine("1");
            return;
        }
        //1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
        if ((As.Count(e => e == 1) > 1))
        {
            Console.WriteLine("0");
            return;
        }

        var max = (int)1e6;

        //As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
        var cnt = new int[max+10];
        for (var num = 0; num < N; num++)
        {
            cnt[As[num]]++;
        }
        //Asに含まれる数字の倍数すべてをbool型で保持する
        //-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
        var baisuFlgs = new bool[max+1];
        foreach (var i in As.Distinct())
        {
            var temp = i;
            while(temp + i <= max)
            {
                temp += i;
                baisuFlgs[temp] = true;
            }

        }

        //cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
        var ans = 0;
        for (var i= 0;i < N;i++)
        {
            if (baisuFlgs[As[i]] == false && cnt[As[i]] == 1)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 54040
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int s,w;
    cin >> s >> w;
    if(w >= s ) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int cnt=0;
  bool flag = false;
  for(int i = 0; i < s.size()-1;i++){
    if(s[i]==s[i+1]){
      cnt++;
      if(cnt==2){
        flag = true;
        break;
      }
    }else{
      cnt = 0;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
X = int(input())

# 500円硬貨 1枚につき 1000、5円硬貨 1枚につき 5 の 嬉しさ を得ます。
# X円を持っています。嬉しさの最大値を出力せよ。

s = X // 500
a = X % 500
t = a // 5
print(s*1000 + t*5)

Measured memory_bytes: 9076
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

inv = lambda i: fainv[i] * fa[i-1] % mod

N, mod = map(int, input().split())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

##### Settings
unit = 1
td_unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i=-1: a + 1
adj_td = lambda a, i=-1: a + 1
calc = lambda i: merge(BU[i]-1, TD[i])
#####

SI = [1] * N
for i in R[1:][::-1]:
    SI[P[i]] += SI[i]

BU = [unit] * N
TD = [td_unit] * N
for i in R[1:][::-1]:
    BU[i] = adj_bu(BU[i], i)
    p = P[i]
    BU[p] = merge(BU[p], BU[i])
BU[R[0]] = adj_bu(BU[R[0]], R[0])

AX = [0] * N
for i in R:
    ac = unit
    for j in X[i]:
        AX[j] = ac
        ac = merge(ac, BU[j])
    ac = unit
    for j in X[i][::-1]:
        AX[j] = merge(AX[j], ac)
        TD[j] = adj_td(merge(merge(unit, TD[i]), AX[j]), j)
        ac = merge(ac, BU[j])

ANS = [calc(i) for i in range(N)]
print(*ANS)

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

using namespace std;

typedef long long  ll;

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

    int n, q;

    // Input
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    cin >> q;
    vector<int> t(q);
    for (int i = 0; i < q; ++i)
        cin >> t[i];

    int ans = 0;
    for (int i = 0; i < q; ++i)
        for (int j = 0; j < n; ++j)
            if (t[i] == s[j]) {
                ++ans;
                break;
            }

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    for (int i=0; i<=n; i+=4) {
        if ((n-i)%7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
root = None

class Node:
    def __init__(self, key, left, right):
        self.parent = -1
        self.key = key
        self.left = left
        self.right = right

def preorder(T):
    if T is None:
        return
    print(' ' + str(T.key), end='')
    preorder(T.left)
    preorder(T.right)

def inorder(T):
    if T is None:
        return
    inorder(T.left)
    print(' ' + str(T.key), end='')
    inorder(T.right)

def find(T, z):
    if T is None:
        return False
    if T.key == z:
        return True

    if z < T.key and T.left is not None:
        return find(T.left, z)
    elif z > T.key and T.right is not None:
        return find(T.right, z)
    else:
        return False

def insert(T, z):
    global root
    if T is None:
        root = Node(z, None, None)
        return

    # print("\n# Insert: " + str(z))
    # print("# T: " + str(T.key))

    parent = T
    while True:
        if parent.left is None and parent.right is None:
            break
        elif parent.left is None and z < parent.key:
            break
        elif parent.right is None and z > parent.key:
            break

        # print("# left: " + str(parent.left.key))
        # print("# right: " + str(parent.right.key))

        if z < parent.key:
            parent = parent.left
#            print("# Slide parent to left: " + str(parent.key))
        else:
            parent = parent.right
#            print("# Slide parent to right: " + str(parent.key))

    if z < parent.key:
        node = Node(z, None, None)
        parent.left = node
    elif z > parent.key:
        node = Node(z, None, None)
        parent.right = node

n = int(input())

for i in range(n):
    s = input().split()
    if s[0] == 'insert':
        insert(root, int(s[1]))
    elif s[0] == 'find':
        if find(root, int(s[1])):
            print('yes')
        else:
            print('no')
    else:
        inorder(root)
        print('')
        preorder(root)
        print('')



Measured memory_bytes: 105040
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;

struct lazy_segment_tree{
    struct Node{
        LL val,delay;
        Node(){val=delay=0;}
    };
    int N;
    vector<Node> data;
    explicit lazy_segment_tree(int size){
        N=1;
        while(N<size)N*=2;
        data=vector<Node>(2*N,Node());
    }
    inline void lazy_evaluate(int k,int a,int b){
        data[k].val+=data[k].delay*(b-a);//
        if(k<N){
            data[2*k].delay+=data[k].delay;//
            data[2*k+1].delay+=data[k].delay;//
        }
        data[k].delay=0;
    }
    inline LL f(LL a,LL b){
        return a+b;
    }
    inline LL merge(int k){
        return data[k].val=f(data[2*k].val,data[2*k+1].val);//
    }
    inline void update(int l,int r,LL v){update(l,r,v,1,0,N);}
    void update(int l, int r, LL v, int k, int a, int b){
        if(l<=a && b<=r){
            data[k].delay+=v;//
            lazy_evaluate(k,a,b);
            return ;
        }
        lazy_evaluate(k,a,b);
        if(b<=l || r<=a){return ;}//
        update(l,r,v,2*k,a,(a+b)/2);
        update(l,r,v,2*k+1,(a+b)/2,b);
        merge(k);
    }
    inline LL get(int l,int r){return get(l,r,1,0,N);}
    LL get(int l, int r, int k, int a, int b){
        if(b<=l || r<=a){return 0;}//
        lazy_evaluate(k,a,b);
        if(l<=a && b<=r){
            return data[k].val;
        }
        LL vall=get(l,r,2*k,a,(a+b)/2);
        LL valr=get(l,r,2*k+1,(a+b)/2,b);
        return f(vall,valr);
    }

};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<tuple<int,int,int>> s(n);
    for(int i=0; i<n; ++i){
        int l,r;
        cin >> l >> r;
        s[i]=make_tuple(r-l+1,l,r);
    }
    sort(s.begin(),s.end());

    auto it=s.begin();
    lazy_segment_tree seg(m+1);
    for(int i=1; i<=m; ++i){
        int ans=0;
        while(get<0>(*it)<i && it<s.end()){
            seg.update(get<1>(*it),get<2>(*it)+1,1);
            it++;
        }

        ans=s.end()-it;
        for(int j=i; j<=m; j+=i){
            ans+=seg.get(j,j+1);
        }
        cout << ans <<"\n";
    }




    return 0;
}



Measured memory_bytes: 8704
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long long ans,l[210];
int main()
{
	scanf("%d",&n);
	n*=2;
	for(int i=1;i<=n;i++)
		scanf("%lld",&l[i]);
	sort(l+1,l+1+n);
	for(int i=1;i<n;i+=2)
		ans+=l[i];
	printf("%lld",ans);
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
visit = [-1 for i in range(n)]
root = []
now = 1
length = 0
root.append(now)
if k > n:
    for i in range(n):
        if visit[now - 1] != 1:
            visit[now - 1] = 1
            now = a[now - 1]
            root.append(now)
            length += 1
        else:break
    start = 0
    for i in range(n):
        if root[i] == now:
            start = i
            break
    length -= start
    k -= start
    k %= length
    ans = root[start + k]
    print(ans)
else:
    for i in range(k):
        now = a[now - 1]
    print(now)

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

int main()
{
    int A, B, X;
    cin >> A >> B >> X;
    if (A <= X && X <= A + B)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
n, c, k = [int(e) for e in input().split()]# 5 3 5
t = [] # 1 2 3 6 12
bus_count = 0
time_diff = 0
stock = 0
first_customer_arrival_time = 0
i = 0

for _ in range(n):
    t.append(int(input()))
t.sort()
while i < n-1:
    # First customer
    if stock == 0:
        first_customer_arrival_time = t[i]
        stock = 1
    else:
        stock += 1
    time_diff = t[i+1] - first_customer_arrival_time
    # Timeout or Full
    if time_diff > k or stock == c:
        bus_count += 1
        stock = 0
        time_diff = 0 
    i += 1
# Lastbus
bus_count += 1
print(bus_count)

Measured memory_bytes: 7488
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
g :: Int -> [(Int,Int)] -> Int -> Bool
g x b k = (sum $ map (\(c,d) -> if x < c * d then c - (x `div` d) else 0) b) <= k

h :: Int -> Int -> [(Int,Int)] -> Int -> Int
h m n b k
    | m == n = m
    | g l b k = h m l b k
    | otherwise = h (l+1) n b k
    where l = (m+n)`div`2

main = do
    [n,k] <- (BS.getLine >>= return . (map (fst . fromJust . BS.readInt)) . BS.words) :: IO [Int]
    a <- BS.getLine >>= return . sort . (map (fst . fromJust . BS.readInt)) . BS.words
    f <- BS.getLine >>= return . reverse . sort . (map (fst . fromJust . BS.readInt)) . BS.words
    let b = zip a f
    putStrLn $ show $ h 0 (maximum $ map (\(c,d)->c*d) b) b k

Measured memory_bytes: 62844
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
string s;  cin >> s;
int cnt = 0;
int ans = -1;
for(int i{}; i<s.size(); i++){
	if(s[i]=='R'){
		++cnt;
	} 
	else
	{
		ans = max(ans, cnt);
		cnt = 0;
	}
}

cout << max(cnt, ans) << "\n";



}


Measured memory_bytes: 3648
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    while (sc.hasNext){
      val a, b, c, d, e, f = sc.nextInt
      val delta : Double = a * e - b * d
      val tx = BigDecimal((e * c - b * f) / delta)
      val ty = BigDecimal((a * f - d * c) / delta)
      val x = tx.setScale(3, scala.math.BigDecimal.RoundingMode.HALF_UP)
      val y = ty.setScale(3, scala.math.BigDecimal.RoundingMode.HALF_UP)
      println(x + " " + y)
    //println(f"$x%.3f $y%.3f")
    }
  }
}

Measured memory_bytes: 45284
#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 void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int C;
int main(){
  rd(A);
  rd(B);
  rd(C);
  if(A+B>=C){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B, C;
// {
//   rd(A,B,C);
//   wt( if[A+B>=C, "Yes", "No"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

void quit(int f)
{
    cout << f << '\n';
    exit(EXIT_SUCCESS);
}

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

    for(int i = N; i >= 1; i--)
    {
        if(s.substr(N-i, i) == t.substr(0, i)) quit(2*N - i);
    }
    quit(2*N);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		String[] a = next().split("");

		Map<String, Integer> memo = new HashMap<String, Integer>();
		for (int i = 0; i < a.length; i++) {
			memo.merge(a[i], 1, (oldV, newV) -> oldV + newV);
		}

		for (int elm : memo.values()) {
			if (elm != 2) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}

	private void solveB() {
		int n = nextInt();

		out.println("");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

int main() {
    int N,M;
    cin >> N >> M;

    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    
    int total = 0;
    for (int i = 0; i < N; i++){
        total += A.at(i);
    }
    
    int counter = 0;
    for (int i = 0; i < N; i++){
        if (A.at(i) > (total-1) / (4*M)){
            counter++;
        }
    }
    
    if (counter >= M){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int MOD = 998244353;

template <int N>
struct Eratosthenes
{
    int w[N + 1];
    bool is_not_prime[N + 1];
    constexpr Eratosthenes() : w(), is_not_prime()
    {
        w[0] = 0;
        w[1] = 1;
        for (int i = 2; i <= N; i++)
        {
            w[i] = MOD - 1LL * w[MOD % i] * (MOD / i) % MOD;
        }
        for (int prime = 2; prime <= N; prime++)
        {
            if (is_not_prime[prime])
            {
                continue;
            }
            for (int k = N / prime; k > 1; --k)
            {
                is_not_prime[k * prime] = true;
                w[k * prime] -= w[k];
                if (w[k * prime] < 0)
                {
                    w[k * prime] += MOD;
                }
            }
            w[prime] -= w[1];
        }
    }
};

int main()
{
    constexpr int M = 1000000;
    constexpr auto prime = Eratosthenes<M>();
    long long N, ans = 0;
    int a[1000001] = {};
    cin >> N;
    for (int i = 0, j; i < N; i++)
    {
        cin >> j;
        a[j] += j;
        if (a[j] >= MOD)
        {
            a[j] -= MOD;
        }
        ans -= j;
        if (ans < 0)
        {
            ans += MOD;
        }
    }
    for (int p = 2; p <= M; p++)
        if (!prime.is_not_prime[p])
            for (int k = M / p; k > 0; --k)
                if ((a[k] += a[k * p]) >= MOD)
                    a[k] -= MOD;
    for (int i = 1; i <= M; i++)
    {
        ans += 1LL * a[i] * a[i] % MOD * prime.w[i] % MOD;
    }
    ans %= MOD;
    if (ans & 1)
        ans = (ans + MOD) >> 1;
    else
        ans = ans >> 1;
    cout << ans << endl;
}


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

int main(){
  int x,y;
  cin >> x >> y;
  if(x==4||x==6||x==9||x==11)x=1;
  else if(x==2)x=2;
  else x=3;
  if(y==4||y==6||y==9||y==11)y=1;
  else if(y==2)y=2;
  else y=3;
  if(x==y)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n-1), b(n-1), d(n, 0);
  VVI e(n);
  map<P,int> mp;
  rep(i, n-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    d[a[i]]++;
    d[b[i]]++;
    e[a[i]].push_back(b[i]);
    e[b[i]].push_back(a[i]);
  }
  VI pc(n, 0);
  int color = 0;
  int idx = -1;
  rep(i, n) {
    if(color < d[i]) {
      color = d[i];
      idx = i;
    }
  }
  vector<bool> used(n, false);
  queue<int> que;
  que.push(idx);
  used[idx] = true;
  while(!que.empty()) {
    int v = que.front();
    que.pop();
    int tmp = 1;
    for(int u : e[v]) {
      if(used[u]) continue;
      if(pc[v] == tmp) tmp++;
      used[u] = true;
      mp[make_pair(v, u)] = mp[make_pair(u, v)] = pc[u] = tmp;
      tmp++;
      que.push(u);
    }
  }
  out(color);
  rep(i, n-1) out(mp[make_pair(a[i], b[i])]);

  return 0;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    if(i == N - 1 && S != "Y"){
      cout << "Three" << endl;
    }
  
  }


}

Measured memory_bytes: 3640
N, M = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

count = 0
for i in range(2 ** N):
    state = ''.join(list(reversed(str(bin(i))[2:].zfill(N))))
    flg = True
    for m in range(M):
        on = 0
        for s in S[m]:
            if state[s - 1] == '1':
                on += 1
        if on % 2 != P[m]:
            flg = False
            break
    if flg:
        count += 1
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli max(lli a,lli b){return(a>b)?a:b;}
lli knapsack(lli*wt,lli*val,lli w,lli n)
{
    lli dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(wt[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return dp[n][w];
}

int main() {
    lli n,w;
    cin>>n>>w;
    lli wt[n+1],val[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<knapsack(wt,val,w,n)<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    ll N;
    cin >> N;
    vector<ll> T(N);
    rep(i, N) cin >> T.at(i);
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    vector<pair<ll, ll>> h(N);
    rep(i, N){
        if(i == 0 || T.at(i) > T.at(i-1)){
            h.at(i) = {T.at(i), T.at(i)};
        }
        else{
            h.at(i) = {1, T.at(i)};
        }
    }
    rep(i, N){
        if(i == N-1 || A.at(i) > A.at(i+1)){
            if(A.at(i) < h.at(i).first || h.at(i).second < A.at(i)){
                cout << 0 << endl;
                return 0;
            }
            else{
                h.at(i) = {A.at(i), A.at(i)};
            }
        }
        else{
            if(A.at(i) < h.at(i).first){
                cout << 0 << endl;
                return 0;
            }
            else{
                chmin(h.at(i).second, A.at(i));
            }
        }
    }
    mint ans = 1;
    rep(i, N){
        ans *= h.at(i).second - h.at(i).first + 1;
    }
    cout << ans << endl;
}

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

#define N 16777216 // 4^12

char H[N];

int getChar(char ch){
  switch (ch) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
  }
  return 0;
}

// convert character string to Quintuple
int getKey(char *str){
  int i, sum=0, p=1;
  for(i=0; i<strlen(str); i++){
    sum += p * getChar(str[i]);
    p *= 4;
  }
  return sum;
}

int main(){
  int i,n;
  char str[13], command[7];
  // char H[N];
  for(i=0; i<N; i++)  H[i] = 0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s %s",command, str);
    if(command[0] == 'i')  H[getKey(str)]= 1;
    else{
      if(H[getKey(str)]) printf("yes\n");
      else  printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 18112
N,X=map(int,input().split())
L=[[1,1] for _ in range(N+1)]
i=0
while i+1<=N:
    L[i+1][0]=L[i][0]*2+1
    L[i+1][1]=L[i+1][0]*2-1
    i+=1

xx=[[1,1,1,1,1]for _ in range(N+1)]
i=0
while i+1<=N:
    xx[i+1][1]=L[i][1]+1
    xx[i+1][2]=L[i][1]+2
    xx[i+1][3]=2*L[i][1]+2
    xx[i+1][4]=2*L[i][1]+3
    i+=1

ans=0
while N>0:
    if xx[N][0]==X:
        break
    elif xx[N][1]>=X:
        N-=1
        X-=1
    elif xx[N][2]==X:
        ans+=1+L[N-1][0]
        break
    elif xx[N][3]>=X:
        ans+=1+L[N-1][0]
        X-=xx[N][2]
        N-=1
    else:
        ans+=1+2*L[N-1][0]
        break
    if N==0:
        ans+=1

print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200100
#define N2 1000010
#define MOD 1000000007
#define int long long int
#define INF 1000000000000000
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
int prime[N2]={0};
vector <int> pr;
void sieve(){
    prime[0]=1;prime[1]=1;
    for(int i=2;i<=sqrt(N2);i++){
        if(prime[i]==0)
            {
                for(int j=i*i;j<N2;j+=i){
                    prime[j]=1;
                }
            }
    }
    for(int i=2;i<N2;i++){
        if(!prime[i])
            pr.pb(i);
    }
    return ;
}
double pi=3.141592653589;
int a[N];
signed main() {  
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //sieve();
    int n,k;cin>>n>>k;
    int sum=0;
    for(int i=k;i<=n+1;i++){
        sum+=(i*(n-i+1));
        sum+=1;
        sum%=MOD;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  static int n, l;
  static String[] s;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt(); l = sc.nextInt();
    s = new String[n];
    for(int i = 0; i < n; i++){
      s[i] = sc.next();
    }

    Arrays.sort(s);
    for(int i = 0; i < n; i++){
      System.out.print(s[i]);
    }
    System.out.println();
  }
}


Measured memory_bytes: 10064