akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	
	public void run() {
		dp[1] = 1;
		dpK[1] = 1;
		for(int i = 1; i < 1000001; i++){
			calcDP(i);
			calcDPK(i);
		}
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0 )break;
			else calc(n);
			
		}
	}
	public void calc(int n){
		System.out.println(dp[n] + " " + dpK[n]);
	}
	int[] dp = new int[1000001];
	public int calcDP(int n){
		if(n == 0) return 0;
		else if(dp[n] != 0) return dp[n];
		else{
			int min = 10;
			for(int i = 1; i < n; i++){
				int t = i * (i + 1) * (i + 2) / 6;
				if(n - t < 0) break;
				int m;
				if(dp[n-t] != 0) m = dp[n-t] + 1;
				else m = calcDP(n - t) + 1;
				if(m < min) 
					min = m;
			}
			dp[n] = min;
			return dp[n];
		}
	}
	int[] dpK = new int[1000001];
	public int calcDPK(int n){
		if(n == 0) return 0;
		else if(dpK[n] != 0) return dpK[n];
		else{
			int min = 10000000;
			for(int i = 1; i < n; i++){
				int t = i * (i + 1) * (i + 2) / 6;
				if(n - t < 0) break;
				if(t % 2 == 1){
					int m;
					if(dpK[n-t] != 0) m = dpK[n-t] + 1;
					else m = calcDPK(n - t) + 1;
					if(m < min) min = m;
				}
			}
			dpK[n] = min;
			return dpK[n];
		}
	}

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

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m;
cin>>n>>m;
if(n==1&&m==1){
    cout<<1<<endl;
}
else if(n==1){
    cout<<m-2<<endl;
}
else if(m==1){
    cout<<n-2<<endl;
}
else{
    cout<<(n-2)*(m-2)<<endl;
}
return 0;
}

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

int main()
{
	int a[3];
	int ans=0;
	
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3,greater<int>());
  	if(a[0]==a[1]+a[2])
      cout<<"Yes";
  	else
      cout<<"No";
	
	return 0;
	
}

Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.max

fun main() {
    val pw = PrintWriter(System.out)

    val (n, m) = readInputLine().split(" ").map { it.toInt() }

    val h = readInputLine().split(" ").map { it.toInt() }

    val maxHeight = IntArray(n)

    repeat(m) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() - 1 }
        maxHeight[a] = max(maxHeight[a], h[b])
        maxHeight[b] = max(maxHeight[b], h[a])
    }

    var ans = 0

    repeat(n) {
        if (h[it] > maxHeight[it]) {
            ans++
        }
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 62772
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1) for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(L):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))


Measured memory_bytes: 52168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;
// Union find : O(α(V))
// verified : 
class UnionFind {
	typedef size_t U;
	// v[i] : i番目の頂点が根 ? i番目の頂点の属する木のサイズ * -1
	//                       : i番目の頂点の親のindex
	vector<int32_t> v;
public:
	UnionFind(U n) : v(n, -1) {}
	U find(U x) { return v[x] < 0 ? x : (v[x] = find((U)v[x])); }
	bool same(U x, U y) { return find(x) == find(y); }
	U size(U x) { return (U)-v[find(x)]; }
	void unite(U x, U y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y];
			v[y] = x;
		}
	}
};

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, m; cin >> n >> m;
	vl k(n);
	vvl l(m);
	REP(i, n) {
		cin >> k[i];
		REP(j, k[i]) {
			ll l1; cin >> l1;
			l[l1 - 1].push_back(i);
		}
	}

	UnionFind uf(n);
	REP(i, m) {
		if (l[i].size() < 1) continue;
		REP(j, l[i].size() - 1) {
			uf.unite(l[i][j], l[i][j + 1]);
		}
	}

	cout << (uf.size(0) == n ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 305 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

lli dp[100 + 5][100000 + 5];
lli pre[100 + 5][100000 + 5];

int main()
{
///////////////////////////////////////////
    fastio;

    lli n,k;
    cin>>n>>k;

    lli a[n+1];
    loopl(i,1,n+1) cin>>a[i];

    pre[1][0] = 1;
    dp[1][0] = 1;
    loopl(i,1,k+1)
    {
        if(i<=a[1])
            dp[1][i] = 1;

        pre[1][i] = pre[1][i-1] + dp[1][i] ;
    }


    loopl(i,2,n+1)
    {
        loopl(j,0,k+1)
        {
            if(j-a[i] > 0)
                dp[i][j] = (pre[i-1][j]%mod - pre[i-1][j-a[i]-1]%mod + mod)%mod;

            else
                dp[i][j] = pre[i-1][j];

            if(j-1>=0) pre[i][j] = pre[i][j-1];
            pre[i][j] += dp[i][j];
            pre[i][j] %= mod;
        }
    }

    cout<<dp[n][k]<<endl;

}

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

using namespace std;

using ll = long long;

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

    int n, m;
    string s;
    map<string, int> cnt;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        ++cnt[s];
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> s;
        --cnt[s];
    }

    int max_e = 0;
    for (auto it : cnt)
        max_e = max(max_e, it.second);

    cout << max_e << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = input()

a = int(S[:2])
b = int(S[2:])
#print(a,b)

am = ay = bm = by = False
if 1 <= a <= 12:
    am = True
if 1 <= b <= 12:
    bm = True
ay = True
by = True

#print(am,ay,bm,by)

if am and bm and ay and by:
    print('AMBIGUOUS')
elif am and by:
    print('MMYY')
elif bm and ay:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 4588
#include <iostream>
using namespace std;
 
int main()
{
 int a, b;
 string s;
 cin >> a >> s >> b;
 if( s == "+" )
 {
  cout << a + b << endl;
 }
 else if( s == "-")
 {
  cout << a - b << endl;
 }
 else
 {
  cout << "Error" << endl;
 }
 
 return 0;
}

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

ll gcd(int a, int b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

int main() {
	ll k, a,b,  sum(0);
	cin >> k;
	rep(i, k) {
		rep(j, k) {
			rep(l, k) {
				a = gcd(i, j);
				b = gcd(a,l);
				sum += b;
			}
		}
	}
	ll Ans;
	Ans = sum;
	cout << Ans;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int solve(string x, string y){
	x=' '+x;
	y=' '+y;
	int n=x.length();
	int m=y.length();
	int dp[n+1][m+1];
	int k=0;
	for(int i=0; i<n+1; i++)
		dp[i][0]=0;
	for(int i=0; i<m+1; i++)
		dp[0][i]=0;
	for(int i=1; i<n+1; i++){
		for(int j=1; j<m+1; j++){
			if(x[i]==y[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
			k=max(k, dp[i][j]);
		}
	}
	return k-1;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		string x,y;
		cin>>x>>y;
		cout<<solve(x, y)<<endl;
	}
	return 0;
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
 
using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=1e9 + 7;

#define bt(i) (1 << (i))
#define int ll

int n, m, ans, dp[maxn], w[maxn], v[maxn];

main()
{
	cin >> n >> m;
	forn(1, i, n)
	{
		cin >> w[i] >> v[i];
	}
	forn(0, i, 100000)
	{
		dp[i] = 1e18;
	}
	dp[0] = 0;
	forn(1, j, n)
	{
		nfor(0, i, 100000)
		{
			if(v[j] + i <= 100000)
			{
				dp[v[j] + i] = min(dp[v[j] + i], dp[i] + w[j]);
			}
		}
	}
	forn(0, i, 100000)
	{
		if(dp[i] <= m)
		{
			ans = i;
		}
	}
	cout << ans;
}

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

int N, A[100005], K;

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	int g = 0;
	for (int i = 0; i < N; i++) g = __gcd(g, A[i]);
	int mx = 0;
	for (int i = 0; i < N; i++) mx = max(mx, A[i]);
	if (K > mx || K % g != 0) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int x,y;
  string s,t;
  cin >> s >> t;
  x = 1;
  if(s == "D")
    x *= -1;
  if(t == "D")
    x *= -1;
  if(x == 1)
    cout << "H" << endl;
  else
    cout << "D" << endl;
  
  return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    A=list(map(lambda x:int(x)-1,input().split()))
    ans=sum(map(int,input().split()))
    C=list(map(int,input().split()))

    for i in range(n-1):
        if A[i+1]-A[i]==1: ans+=C[A[i]]

    print(ans)
resolve()

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

typedef long long int llint;

int n;
int i, j;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

  for(i = s.size() - t.size(); i >= 0; i--) {

    bool flg = true;
    for(j = 0; j < t.size(); j++) {
      if(s[i + j] != '?' && s[i + j] != t[j]) flg = false;
    }

    if(flg) {
      for(j = 0; j < t.size(); j++) s[i + j] = t[j];
      for(j = 0; j < s.size(); j++) if(s[j] == '?') s[j] = 'a';
      cout<< s <<endl;
      return 0;
    }
  }

  cout<< "UNRESTORABLE" <<endl;
  
  return 0;
}

Measured memory_bytes: 256
A = str(input())
B = str(input())
C = str(input())
D = str(input())
E = str(input())

num = sorted([A, B, C, D, E], key=lambda x: x[-1])
ans = 0
flag = 0
for i in num:
    if i[-1] == '0':
        ans += int(i)
    elif flag == 0:
        flag = 1
        ans += int(i)
    else:
        j = int(i) // 10 + 1
        ans += 10 * j

print(ans)

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    if(N%X == 0){
        cout << N / X * T << endl;
    }else{
        cout << (N / X + 1) * T << endl;
    }
    return 0;
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int c[252521];

ll modpow(ll a, ll b){
    ll r = 1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}


int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",c+i);
    sort(c,c+n);
    reverse(c,c+n);
    ll ans = 0;
    const ll INV2 = (MOD+1)/2;
    REP(i,n){
        ans += INV2 * INV2 % MOD * c[i] % MOD * (i+2) % MOD;
        ans %= MOD;
    }
    ans = ans * modpow(4,n) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007
a = sorted(a)
if n%2 ==1:
  flag = True
  if a[0]!=0:
    flag = False
  for i in range(1,n,2):
    if not(a[i]==a[i+1] and a[i-1]!=a[i]):
      flag =False
  print((2**(n//2))%mod if flag else 0)

else:
  flag = True
  if not(a[0]==a[1] and a[0]==1):
    flag = False
  for i in range(2,n,2):
    if not(a[i]==a[i+1] and a[i-1]!=a[i]):
      flag =False
  print((2**(n//2))%mod if flag else 0)

Measured memory_bytes: 14008
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    // dp[i] := grundy number of i stone(s)
    vector<int> dp(k+1, 0);
    RANGE(i, 1, k) {
        vector<int> appeared;
        REP(j, n) {
            if (i - a[j] < 0) break;
            appeared.emplace_back(dp[i - a[j]]);
        }
        int cand = 0;
        sort(ALL_OF(appeared));
        UNIQUE(appeared);
        REP(i, appeared.size()) {
            if (cand == appeared[i]) {
                cand = appeared[i] + 1;
            } else {
                break;
            }
        }
        dp[i] = cand;
    }

    // cerr << "[DEBUG] ";
    // REP(i, k+1) cerr << dp[i] << " \n"[i == k];

    cout << (dp[k] ? "First" : "Second") << endl;
    
}

Measured memory_bytes: 640
N = int(input())
A, B = map(int, input().split())
# rangeのときは多くもらないといけないからB+1
for i in range(A, B+1):
#   この中の何番目かでNで割って余りが0なら終了
  if i % N == 0:
    print('OK')
    break
else:
  print('NG')

Measured memory_bytes: 9060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderProject
{
    public static class Program
    {
        public static void Main()
        {
            var steps = Console.ReadLine();
            for(int i = 0; i < steps.Length; i++)
            {
                if((i + 1) % 2 == 0)
                {
                    if(steps[i] == 'R')
                    {
                        Console.WriteLine("No");
                        break;
                    }
                }
                else
                {
                    if (steps[i] == 'L')
                    {
                        Console.WriteLine("No");
                        break;
                    }
                }

                if(i == steps.Length - 1)
                {
                    Console.WriteLine("Yes");
                }
            }
        }

        private static List<int> ReadArgsAsInt()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => int.Parse(x)).ToList();
        }

        private static List<long> ReadArgsAsLong()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => long.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  double h,a;
  cin >> h >> a;
  cout << ceil(h/a) << endl;
}



Measured memory_bytes: 256
#include <iostream>

typedef unsigned long long int ulli;

int main()
{
  ulli a, b, x;
  std::cin >> a >> b >> x;
  
  ulli c = (b / x) - (a / x);
  
  if((a % x) == 0) ++c;
  
  std::cout << c << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,arr[10],c5=0,c7=0;
    for(i=0; i<3; i++) {
        scanf("%d", &arr[i]);
        if(arr[i] == 5) {
            c5 = c5 + 1;
        }
        if(arr[i] == 7) {
            c7 = c7 + 1;
        }
    }
    
    if((c5 == 2) && (c7 == 1)) {
        printf("YES");
    }
    else {
        printf("NO");
    }
    
    return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <set>

using namespace std;
const int MAX_N = 1010;

int Par[MAX_N];
int Rank[MAX_N];

void init(int n){
  for (int i = 0; i < n; i++){
    Par[i] = i;
    Rank[i] = 0;
  }
  return ;
}

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

void unit(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y)return ;

  if (Rank[x] < Rank[y]){
    Par[x] = y;
  }else{
    Par[y] = x;
    if (Rank[x] == Rank[y])Rank[x]++;
  }
}

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

int N,M;
int deg[MAX_N];
int main(){
  cin >> N >> M;
  init(N);
  for (int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    unit(a, b);
    deg[a]++;
    deg[b]++;
  }
  int village = 0;
  set<int> city;
  
  for (int i = 0; i < N; i++){
    if (deg[i]){
      int x = find(i);
      city.insert(x);
    }else{
      village++;
    }
    
  }
  //  cerr << village << " " << city.size() << endl;
  cout << abs(village - (int)city.size()) << endl;
}

Measured memory_bytes: 3136
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int k = 0; k <= B; k++) {
            for (int j = 0; j <= C; j++) {
                int sum = 500 * i + 100 * k + 50 * j;
                if (sum == X) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维 
**/
int main()
{
	int n,i,j,t,k;
	int a[55]={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};
	 cin>>n;
	 cout<<a[n-1];
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(void){
  int n,x[8],y[8];
  vector<int> p;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    p.pb(i);
  }
  double ans=0;
  int cnt=0;
  do{
    double d=0;
    for(int i=0;i<n-1;i++){
      double dx=abs(x[p[i+1]]-x[p[i]]);
      double dy=abs(y[p[i+1]]-y[p[i]]);
      d+=sqrt(pow(dx,2)+pow(dy,2));
    }
    ans+=d;
    ++cnt;
  }while(next_permutation(p.begin(),p.end()));
  ans/=cnt;
  printf("%.10lf\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 2147483647;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = sz(s);
    auto dp0 = make_vec<ll>(110, 4);
    auto dp1 = make_vec<ll>(110, 4);
    dp0[0][0] = 1;
    rep(i, n) {
        rep(j, 4) {
            for (char d = '1'; d <= '9'; d++) {
                if (d < s[i]) {
                    dp1[i + 1][j + 1] += dp0[i][j];
                    dp1[i + 1][j + 1] += dp1[i][j];
                }
                if (d == s[i]) {
                    dp0[i + 1][j + 1] += dp0[i][j];
                    dp1[i + 1][j + 1] += dp1[i][j];
                }
                if (d > s[i]) {
                    dp1[i + 1][j + 1] += dp1[i][j];
                }
            }

            if ('0' == s[i]) {
                dp0[i + 1][j] += dp0[i][j];
                dp1[i + 1][j] += dp1[i][j];
            } else {
                dp1[i + 1][j] += dp0[i][j];
                dp1[i + 1][j] += dp1[i][j];
            }
        }
    }
    cout << dp0[n][k] + dp1[n][k] << endl;
}

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

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

ll solve(void)
{
	ui N{};
	cin >> N;
	
	vector<ll> arrayW(N);
	ll sum{ 0 };
	for (size_t i = 0; i < arrayW.size(); ++i)
	{
		cin >> arrayW[i];
		sum += arrayW[i];
	}
	
	ll half_sum{ 0 };
	for (auto w : arrayW)
	{
		half_sum += w;
		if (half_sum >= sum / 2)
		{
			return min(abs((2 * half_sum) - sum), abs(sum - 2 * (half_sum - w)));
		}
	}
	
	return -1;
}

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

	ll ans = solve();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pqb             	priority_queue<int>
#define pqs             	priority_queue<int,vi,greater<int> >
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
vi g[N];
int dist[N];
int visited[N];
int parent[N];
void bfs(int src){
	queue<int> q;
	q.push(src);
	visited[src]=true;
	while(!q.empty()){
		auto node=q.front();
		q.pop();
		for(auto i: g[node]){
			if(!visited[i]){
				visited[i]=true;
				dist[i]=dist[node]+1;
				parent[i]=node;
				q.push(i);
			}
		}
	}
}

void JH(){
    int d=0,e=0,f=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n,m;cin>>n>>m;
    fo1(i,m){
    	int u,v;cin>>u>>v;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    bfs(1);
    for(int i=2;i<=n;i++){
    	if(parent[i]==0){
    		flag=1;
    	}
    }
    if(flag){
    	cout<<"No";
    	return;
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
    	cout<<parent[i]<<endl;
    }

}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<"Execution time: "<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 17036
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    string s = in<string>(), t = in<string>();
    vector<char> alpha(26), alpha_dash(26);
    REP(i, s.size()){
        if(!alpha[t[i] - 'a']){
            alpha[t[i] - 'a'] = s[i];
        }
        if(!alpha_dash[s[i] - 'a']){
            alpha_dash[s[i] - 'a'] = t[i];
        }
        if(!(alpha[t[i] - 'a'] == s[i])){
            cout << "No" << endl;
            return 0;
        }
        if(!(alpha_dash[s[i] - 'a'] == t[i])){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static String s;
	public static int index;
	
	public static char c(){
		return s.charAt(index++);
	}
	
	@SuppressWarnings("unchecked")
	public static Set<Integer> calc(List<Set<Integer>> list, List<Character> ope){
		int n = list.size();
		Set<Integer>[][] dp = new Set[n][n];
		for(int i=0;i<n;i++)dp[i][i]=list.get(i);
		for(int w=1;w<n;w++){
			for(int i=0;i+w<n;i++){
				Set<Integer> res = new HashSet<Integer>();
				for(int k=i;k<i+w;k++){
					for(int x : dp[i][k]){
						char ch = ope.get(k);
						for(int y : dp[k+1][i+w]){
							switch(ch){
							case '+': res.add(x+y);break;
							case '-': res.add(x-y);break;
							case '*': res.add(x*y);break;
							case '/': if(y==0)break;else res.add(x/y);break;
							}
						}
					}
				}
				dp[i][i+w] = res;
			}
		}
		return dp[0][n-1];
	}
	
	public static Set<Integer> exp(){
		List<Set<Integer>> list = new ArrayList<Set<Integer>>();
		List<Character> ope = new ArrayList<Character>();
		while(true){
			char ch = c();
			if(Character.isDigit(ch)){
				index--;
				Set<Integer> a = new HashSet<Integer>();
				a.add(num());
				list.add(a);
			}
			else if(ch=='('){
				list.add(kakko());
			}
			else if(ch=='$')break;
			else {
				ope.add(ch);
			}
		}
		return calc(list, ope);
	}
	
	public static Set<Integer> kakko(){
		List<Set<Integer>> list = new ArrayList<Set<Integer>>();
		List<Character> ope = new ArrayList<Character>();
		while(true){
			char ch = c();
			if(ch=='('){
				list.add(kakko());
			}
			else if(Character.isDigit(ch)){
				index--;
				Set<Integer> a = new HashSet<Integer>();
				a.add(num());
				list.add(a);
			}
			else if(ch==')'||ch=='$') break;
			else {
				ope.add(ch);
			}
		}
		return calc(list, ope);
	}
	
	public static int num(){
		char ch = c();
		int ans = ch-'0';
		while(Character.isDigit(ch)){
			ch = c();
			if(!Character.isDigit(ch))break;
			ans *= 10;
			ans += ch-'0';
		}
		index--;
		return ans;
	}
	
	public static void main(String[] args) {
		boolean debug = true;
		if(!debug){
			try {
				System.setOut(new PrintStream(new File("./src/icpc/D.txt")));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		Scanner sc = new Scanner(System.in);
		while(true){
			s = sc.next();
			if(s.equals("#"))break;
			s = s+"$";
			index = 0;
			System.out.println(exp().size());
		}
	}
}

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

std::vector<int> edges[100010];
int judge[100010];
int h[100010];


int rec(int i){
    if(judge[i]){
        return judge[i];
    }
    bool flag = true;
    for(int sub : edges[i]){
        if(h[i] > h[sub]){
            judge[sub] = 1;
        }else{
            flag = false;
        }
    }
    if(flag){
        return judge[i] = 2;
    }else{
        return judge[i] = 1;
    }

}

int main(){
    int n, m;
    std::cin >> n >> m;
    for(int i = 0; i < n; i++){
        std::cin >> h[i];
    }
    for(int i = 0; i < m; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        if(rec(i) == 2){
            count++;
        }
    }
    std::cout << count << std::endl;
}


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

typedef pair<int,int> PAIR;
const int INF=100000000;
 
int main() {
    int n,a[3000];
    cin>>n;

    int sum=0;
    for (int i = 0; i < n; ++i){
        cin>>a[i];
        sum+=a[i]-1;
    }

    cout<<sum<<endl;


}

Measured memory_bytes: 256
Module Module1

    Sub Main()

        Dim N As Integer = Console.ReadLine()
        Dim A As String() = Split(Console.ReadLine())
        Dim B As String() = Split(Console.ReadLine())
        Dim C As String() = Split(Console.ReadLine())
        Dim i As Integer
        Dim M As Integer = 0

        For i = 0 To N - 1
            M += Val(B(A(i) - 1))
            If i < (N - 1) AndAlso A(i) + 1 = A(i + 1) Then
                M += Val(C(A(i) - 1))
            End If
        Next

        Console.WriteLine(M)
        'Console.ReadLine()

    End Sub

End Module


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

#define dbg(x) cerr << #x"=" << x << endl;
const int MAX_N = 1e3+100;
int has[MAX_N*MAX_N];
int N,M;
const int MOD = 1e9+7;


int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    while(cin >> N >> M){
        int x;
        memset(has, 0, sizeof has);
        for(int i = 0; i < N; ++i) {
            cin >> x;
            has[x] |= 1;
        }
        for(int i = 0; i < M; ++i) {
            cin >> x;
            has[x] |= 2;
        }
        long long ans = 1;
        int s = 0, r = 0, c = 0;
        for(int i = N*M; i >= 1; --i){
            if(has[i] == 0){
                ans = 1LL * ans * s % MOD;
                --s;
            } else if(has[i] == 1){
                ans = 1LL * ans * c % MOD;
                s += c-1;
                ++r;
            } else if(has[i] == 2){
                ans = 1LL * ans * r % MOD;
                s += r-1;
                ++c;
            } else {
                s += r+c;
                ++r;
                ++c;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;
bool cmp(pair<int, int> a, pair<int, int> b)
{
	return a.second < b.second;
}
signed main()
{
	fastio();
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> s;
	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		s.pbc({ a,b });
	}
	sort(all(s), cmp);
	int nw = s[0].second;
	int ans = 1;
	for (int i = 1; i < m; ++i)
	{
		if (s[i].first >= nw)
		{
			ans++;
			nw = s[i].second;
		}
	}
	cout << ans;
	sp;
}

Measured memory_bytes: 1400
import sys

def gcd(m, n):
    r = m % n
    if r == 0:
        return n
    else:
        return gcd(n, r)

lines = sys.stdin.readlines()
for line in lines:
    a, b = map(int, line.split())
    m = max(a, b)
    n = min(a, b)
    print(gcd(m, n), m * n // gcd(m, n))

Measured memory_bytes: 7672
$bag = []

def size i
    j = load = 0
    needTrack = 1
    for $k in j...$bag.size
        load += $bag[$k]
        if (i < load)
            load = $bag[$k]
            needTrack += 1
        end
    end
    return needTrack
end

BagNum, TrackNum = gets.split.map &:to_i
BagNum.times {$bag << gets.to_i}

p ($bag.max..10**9).bsearch{|i|
    size(i) <= TrackNum
}

Measured memory_bytes: 7032
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

struct Node {
  int use;
  int to;
  double cost;
  Node(int u, int t, double c) : use(u), to(t), cost(c) {;}
  bool operator<(const Node &rhs) const { return cost > rhs.cost; }
};

int n, m, p, s, t;
int matrix[100][100];
int uma[10];
int visit[1 << 8][40];

int main() {
  while (scanf("%d %d %d %d %d", &n, &m, &p, &s, &t), n|m|p|s|t) {
    s--; t--;
    MEMSET(matrix, 0x0f);
    REP(i, n) { scanf("%d", &uma[i]); }
    REP(i, p) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      a--; b--;
      matrix[a][b] = matrix[b][a] = c;
    }
    MEMSET(visit, false);
    priority_queue<Node> que;
    que.push(Node(0, s, 0));
    while (!que.empty()) {
      Node node = que.top();
      que.pop();
      if (visit[node.use][node.to]) { continue; }
      visit[node.use][node.to] = true;
      if (node.to == t) {
        printf("%.4lf\n", node.cost);
        goto next;
      }
      int from = node.to;
      REP(to, m) {
        if (matrix[from][to] == 0x0f0f0f0f) { continue; }
        REP(i, n) {
          if ((1 << i) & node.use) { continue; }
          int nuse = node.use | (1 << i);
          if (visit[nuse][to]) { continue; }
          double ncost = node.cost + matrix[from][to] / (double)uma[i];
          que.push(Node(nuse, to, ncost));
        }
      }
    }
    puts("Impossible");
next:;
  }
}

Measured memory_bytes: 7920
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int N = read_item();
	const int K = read_item();
	const int C = read_item();
	const string S = read_item();

	vector<int> scores(N + 1, 0);
	for(auto i : revrange(N)) {
		scores[i] = scores[i + 1];
		if(S[i] == 'o') {
			int s = scores[min(N, i + C + 1)] + 1;
			scores[i] = max(scores[i], s);
		}
	}

	if(scores[0] > K) {
		return 0;
	}
	assert(scores[0] == K);

	vector<int> needed;
	int day = 0;

	for(auto step : range(K)) {
		while(S[day] != 'o') {
			day += 1;
		}
		assert(scores[day] == K - step);
		if(scores[day + 1] != scores[day]) {
			needed.push_back(day);
		}
		day = day + C + 1;
	}

	for(auto d : needed) {
		printf("%d\n", d + 1);
	}

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 3448
n = int(input())
ans = set()
num = float('inf')
total = 0
for i in range(1, n + 1):
    total += i
    if total >= n:
        num = i
        break
remove_num = total - n
for i in range(1, num + 1):
    if i != remove_num:
        ans.add(i)
print(*ans, sep='\n')

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main()
{
    IOS
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout); 
    //#endif
    int n,k;
    cin>>n>>k;
    int a[n],dp[n];
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
	for(int i=1;i<n;i++) dp[i]=INT_MAX;
	for(int i=1;i<n;i++) for(int j=1;j<=min(k,i);j++) dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
h,w=map(int,input().split())
s=["."+input()+"." for i in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flag=0
for i in range(h):
  for j in range(w):
    if s[i][j]=="#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flag=1
print("Yes" if flag==0 else "No")

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

int main() {
  long long n;
  cin >> n;
  for (long long i = sqrt(n); i >= 1; i--) {
    if (n % i == 0) {
      cout << i + n / i - 2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
const int nax = 1e6+5;
#define inf 4e18
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
ll dp[2010];
int x,n;
vi v;
ll f(int x){
    if(x==0){
        return 1;
    }
    if(dp[x] != -1){
        return dp[x];
    }
    ll ways = 0;
    for(int  i = 0;i<n;++i){
        if(x-v[i]>=0){
            ways = add(ways,f(x-v[i]));
        }
    }
    return dp[x] = ways;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>x; 
    for(int i = 3;i<=x;++i)
    {
        v.pb(i);
    }
    n = v.size();
    cout << f(x);
    
}

Measured memory_bytes: 3676
#include <stdio.h>

typedef struct {
	int id;
	int score;
} team;

int main(void)
{
	team pck[1024];
	int bucket[32] = {0};
	int id, score, rank;
	int n, i;

	n = 0;
	while (scanf("%d,%d", &id, &score), id | score){
		pck[n].id = id;
		pck[n].score = score;
		bucket[score] = 1;
		n++;
	}

	while (~scanf("%d", &id)){
		rank = 0;
		for (i = 0; i < n; i++){
			if (id == pck[i].id) break;
		}
		id = i;
		for (i = 30; i >= pck[id].score; i--){
			rank += bucket[i];
		}
		printf("%d\n", rank);
	}

	return (0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;
 
int main() {
    int x;
    cin >> x;
    string res = (x>=30) ? "Yes" : "No";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
const int N=100+10;
int a=1,b=1,n,m,ans;
char s[N];
int main()
{
	scanf("%s%d",&s,&n);
	m=strlen(s);
	if(s[0]!=s[m-1]||n==1)
	{
		for(int i=1;i<m;i++)
			if(s[i]==s[i-1])
			{
				s[i]=' ';
				ans++;
			}
		printf("%lld",ans*1ll*n);
		return 0;
	}
	ans=1;
	for(int i=1;i<m&&ans;i++)
		if(s[i]!=s[i-1])ans=0;
	if(ans)
	{
		printf("%lld",m*1ll*n/2);
		return 0;
	}
	for(int i=1;i<m;i++)
		if(s[i]!=s[i-1])break;
		else a++;
	for(int i=m-2;i>=0;i--)
		if(s[i]!=s[i+1])break;
		else b++;
	for(int i=a+1;i<m-b;i++)
		if(s[i]==s[i-1])
		{
			s[i]=' ';
			ans++;
		}
	printf("%lld",ans*1ll*n+a/2+b/2+((int)((a+b)/2))*1ll*(n-1));
	return 0;
}

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


int main() {
  vector<string> weather = {"Sunny", "Cloudy", "Rainy"};
  
  string s;
  cin >> s;
  int i = find(weather.begin(), weather.end(), s) - weather.begin();

  cout << weather[(i + 1) % 3] << endl;
  return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll a, b, c, x, y, p;
  cin >> a >> b >> c >> x >> y;
  if (a + b <= 2 * c)
	p = a * x + b * y;
  else if (a >= 2 * c && b >= 2 * c)
	p = max(x, y) * 2 * c;
  else if (a >= 2 * c)
	p = 2 * c * x + max(y-x, (ll)0) * b;
  else if (b >= 2 * c)
	p = max(x-y, (ll)0) * a + 2 * c * y;
  else if (a + b >= 2 * c)
	p = min(x, y) * 2 * c + max(x - min(x, y), (ll)0) * a + max(y - min(x, y), (ll)0) * b;
  
  cout << p << endl;
}


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


int main()
{
	int n,m,l,k;
	int d[110],a;
	bool bar[110];
	memset(bar,false,sizeof(bar)); 
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&d[i]);
		for(int j=1;j<=d[i];j++)
		{
			scanf("%d",&a);
			bar[a]=true;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!bar[i])	ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3760