akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         long long

using namespace std;

typedef pair<int, int> pii;
const int N = 2e3 + 5;
const int mod = (int)1e9 + 7;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int n, k, f[N][N], res;

int power(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1) res = 1ll * res * x % mod;
        x = 1ll * x * x % mod;
    }
    return res;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> k;
    if(n == 1) return cout << 1, 0;
    f[n][1] = f[n][0] = 1;
    for(int i = n - 1; i >= 2; --i) {
        for(int j = n - i + 1; j >= 0; --j) {
            f[i][j] = f[i][j + 1] + f[i + 1][j - 1];
            if(f[i][j] >= mod) f[i][j] -= mod;
        }
    }
    cout << 1ll * f[2][n - k] * power(2, max(0, n - k - 1)) % mod << ' ';
}


Measured memory_bytes: 15360
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
    	int a = sc.nextInt();
      	int b = sc.nextInt();
	    
      	if(-a+b <= 0){
        	System.out.println("delicious");
        }else if(-a+b <= x){
        	System.out.println("safe");
        }else{
        	System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 35656
#include <stdio.h>
int main()
{
    int a, b, c;
    int x = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (a; a <= b; a++)
    {
        if (c % a == 0)
        {
            x++;
        }
    }
    printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int i,n,sum1,sum2;
    char s[100001];
    gets(s);
    n=strlen(s);
    sum1=sum2=0;
    for(i=0; i<n; i++)
    {
        if(i%2==0&&s[i]=='0')
            sum1++;
        else if(i%2==1&&s[i]=='1')
            sum1++;
        if(i%2==0&&s[i]=='1')
            sum2++;
        else if(i%2==1&&s[i]=='0')
            sum2++;

    }
    if(sum1<sum2)
        printf("%d\n",sum1);
    else
        printf("%d\n",sum2);
    return 0;
}


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

int top = 0, S[1000];

void push(int x) {
  S[top++] = x;
}

int pop(void) {
  top--;
  return S[top];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


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

ll n, k, c;
string s;

int main() {
	cin>>n>>k>>c;
	cin>>s;
	string sl=s, sr=s;
	ll l[k+1], r[k+1], day=1;
	for (int i=1; i<=n; i++) {
		if (sl[i-1]=='o'&&day<=k) {
			l[day]=i;
			i+=c;
			day++;
		}
	}
	day=k;
	for (int i=n; i>0; i--) {
		if (sr[i-1]=='o'&&day>0) {
			r[day]=i;
			i-=c;
			day--;
		}
	}
	for (int i=1; i<=k; i++) {
		if (l[i]==r[i]) cout<<l[i]<<endl;
	}
}



Measured memory_bytes: 5380
#include<iostream>
using namespace std;
int main()
{
    // 文字列の入力
    string s, t, u;
	int N, count;
    cin >> N >> s >> t >> u;
	count = 0;
    for (int i = 0; i<N; i++){
       if (s.at(i) == t.at(i) && s.at(i) == u.at(i)){
		   count += 2;
	   }
	   else if (s.at(i) == t.at(i) || s.at(i) == u.at(i) || t.at(i) == u.at(i)){
		   count ++;
	   }
	}
	cout << 2*N-count << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(1000000)

    h, w = map(int, input().split())
    start = tuple(map(lambda x: int(x) - 1, input().split()))
    goal = tuple(map(lambda x: int(x) - 1, input().split()))

    maze = tuple([tuple(input()) for _ in range(h)])
    vis = [[False] * w for _ in range(h)]

    mw = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    mj = list(set((i, j) for i in range(-2, 3) for j in range(-2, 3)) - set(mw) - {(0, 0)})

    q = deque()
    q.append((start[0], start[1], 0))
    while q:
        y, x, c = q.popleft()
        if vis[y][x]:
            continue
        vis[y][x] = True
        if (y, x) == goal:
            print(c)
            break
        for a, b in mw:
            if 0 <= y + a < h and 0 <= x + b < w:
                if maze[y + a][x + b] == '.':
                    q.appendleft((y + a, x + b, c))
        for a, b in mj:
            if 0 <= y + a < h and 0 <= x + b < w:
                if maze[y + a][x + b] == '.':
                    q.append((y + a, x + b, c + 1))
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 322956
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 2e5 + 10;
string s1,s2;
ll a,b;
ll H,W,N;

void solve(){
    cin>>H>>W>>N;

    ll x,y; cin>>y>>x;

    cin>>s1>>s2;
    a = N;
    s1 = '(' + s1,s2 = '(' + s2;

    bool ans = true;
    ll n_x = x;

    FOR(i,1,a){
        if(s1[i] == 'L') n_x = n_x - 1;
        if(n_x < 1){
            ans = false;
            break;
        }
        if(s2[i] == 'R') n_x = min(n_x + 1,W);
    }

    if(!ans){
        cout<<"NO\n";
        return;
    }

    n_x = x;

    FOR(i,1,a){
        if(s1[i] == 'R') n_x = n_x + 1;
        if(n_x > W){
            ans = false;
            break;
        }
        if(s2[i] == 'L') n_x = max(1LL,n_x - 1);
    }

    if(!ans){
        cout<<"NO\n";
        return;
    }


    ll n_y = y;

    FOR(i,1,a){
        if(s1[i] == 'U') n_y = n_y - 1;
        if(n_y < 1){
            ans = false;
            break;
        }
        if(s2[i] == 'D') n_y = min(H,n_y + 1);
    }

    if(!ans){
        cout<<"NO\n";
        return;
    }

    n_y = y;

    FOR(i,1,a){
        if(s1[i] == 'D') n_y = n_y + 1;
        if(n_y > H){
            ans = false;
            break;
        }
        if(s2[i] == 'U') n_y = max(n_y - 1,1LL);
    }

    if(!ans){
        cout<<"NO\n";
        return;
    }

    cout<<"YES\n";
}

signed main(){

   FastRead;    


    ll t,w;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        solve();
    }
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    scanf("%lld", &N);
    ans = 0;
    ll LastNum, FirstNum;
    ll c[10][10];
    REP(int,i,0,10)
        REP(int,j,0,10) c[i][j] = 0;
    for ( ll i = 1; i <= N; i++ ){
        ll Number = i;
        LastNum = Number % 10;
        Number /= 10;
        FirstNum = 0;
        while(Number){
            FirstNum    = Number % 10;
            Number      = Number / 10;
        }
        if ( FirstNum == 0 ) FirstNum = LastNum;
        c[FirstNum][LastNum]++;
    }
    REP(int,i,1,10)
        REP(int,j,1,10)
            ans += c[i][j] * c[j][i];
    printf("%lld\n", ans);
    return 0;
}

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

#define LLI long long int

using namespace std;

int main(){
	int N,tmp,bbar;
	cin>>N;
	vector<int>a(N+1);
	vector<int>b(N+1);
	for(int i=0;i<N;i++)cin>>a[i+1];

	for(int i=N;i>0;i--){
		tmp=a[i];
		bbar=0;
		for(int j=2;j*i<=N;j++){
			bbar+=b[j*i];
		}
		b[i]=(bbar+tmp)%2;
	}
	int M=0;
	vector<int>c;
	for(int i=1;i<=N;i++){
		if(b[i]==1){
			M++;
			c.push_back(i);
		}
	}
	cout<<M;
	for(int i=0;i<M;i++){
		if(i>0){
				cout<<" ";
		}else{
				cout<<endl;
		}
		cout<<c[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 3064
unittest
{
	assert( [ "3", "011" ].solve == "2\n1\n1" );
	assert( [ "23", "00110111001011011001110" ].solve == "2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3" );
	
	assert( [ "3", "000" ].solve == "1\n1\n1" );		// 追加ケース
	assert( [ "3", "100" ].solve == "0\n1\n2" );		// 追加ケース
	assert( [ "3", "111" ].solve == "2\n2\n1" );		// 追加ケース
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto x = input.front.to!( dchar[] );
	
	// 立っているビットをカウント
	auto px = x.count( '1' );
	
	// x % ( x._popcnt - 1 ) を計算
	auto pm = px - 1;
	auto rm = 0L;
	if( 0 < pm )
	{
		foreach( i, b; x )
		{
			if( b == '1' ) rm = ( rm + remainder!2( 1, n - 1 - i, pm ) ) % pm;
		}
	}
	
	// x % ( x._popcnt + 1 ) を計算
	auto pp = px + 1;
	auto rp = 0L;
	foreach( i, b; x )
	{
		if( b == '1' ) rp = ( rp + remainder!2( 1, n - 1 - i, pp ) ) % pp;
	}
	
	// f(xi)を計算
	auto anss = new long[ n ];
	foreach( i, ref ans, b; lockstep( anss, x ) )
	{
		// 一回目の計算（xが64bitに収まらないので事前計算＋ビット反転箇所の差分で計算）
		auto r = 0L;
		if( b == '1' )
		{
			if( pm <= 0 ) continue;
			r = ( rm - remainder!2( 1, n - 1 - i, pm ) + pm ) % pm;
		}
		else
		{
			r = ( rp + remainder!2( 1, n - 1 - i, pp ) ) % pp;
		}
		ans++;
		
		// 二回目以降の計算
		for( ; 0 < r; r %= r._popcnt )
		{
			ans++;
		}
	}
	return anss.to!( string[] ).join( "\n" );
}

// ( a * B ^^ n ) % m を計算
auto remainder( long B )( long a, long n, long m )
{
	static long[][] memo;
	if( m <= 0 ) return 0L;
	if( memo.length <= m ) memo.length = m + 1;
	if( memo[ m ].length <= n )
	{
		if( memo[ m ].empty ) memo[ m ] = [ 1L % m ];
		auto i = memo[ m ].length.signed - 1;
		memo[ m ].length = n + 1;
		for( ; i < n; i++ )
		{
			memo[ m ][ i + 1 ] = ( memo[ m ][ i ] * B ) % m;
		}
	}
	return ( a * memo[ m ][ n ] ) % m;
}


Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0;
  string s;
  std::cin >> x>>y;
  if(x%y==0)std::cout << x/y << '\n';
  else std::cout << x/y+1 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <queue>
#define inf 1e18
#define llint long long

using namespace std;

typedef pair<llint, llint> P;

struct edge{
	int to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

llint N, M;
vector<edge> G[500005];
map< pair<llint, llint>, llint > mp;
llint S, T;
llint dist[500005];

void dijkstra()
{
	for(int i = 1; i <= T; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	int v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	cin >> N >> M;
	
	llint id = 1;
	llint p, q, c;
	for(int i = 0; i < M; i++){
		cin >> p >> q >> c;
		P pv = make_pair(p, c);
		P qv = make_pair(q, c);
		if(!mp.count(pv)) mp[pv] = id++;
		if(!mp.count(qv)) mp[qv] = id++;
		llint u = mp[pv], v = mp[qv];
		G[u].push_back(edge(v, 0));
		G[v].push_back(edge(u, 0));
	}
	
	for(auto it = mp.begin(); it != mp.end(); it++){
		G[it->second].push_back(edge(id + it->first.first, 1));
		G[id + it->first.first].push_back(edge(it->second, 0));
	}
	S = id+1, T = id+N;
	
	dijkstra();
	
	if(dist[id+N] >= inf) cout << -1 << endl;
	else cout << dist[id+N] << endl;
	return 0;
}

Measured memory_bytes: 60444
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
string s, t;
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s>>t;
    if(s.size() != t.size() - 1) {
        cout<<"No";
        return 0;
    }
    for(int i=0;i<s.size();i++)
        if(s[i] != t[i]) {
           cout<<"No";
           return 0;
        }
    cout<<"Yes";
}
/*
 2
 1 1
 1 0
 1 1
 1 1
 */


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3616
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

ans = 0
if N>=M:
    pass
else:
    X_diff = []
    for i in range(len(X)-1):
        X_diff.append(X[i+1]-X[i])
    X_diff.sort()
    ans = 0
    for i in range(M-N):
        ans += X_diff[i]
print(ans)

Measured memory_bytes: 13968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
   int x;
   cin>>x;
   if(x>=30) cout<<"Yes"<<endl;

   else cout<<"No"<<endl;

}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>

int *init(int size, int init_value) {
    int *array = malloc(sizeof(int) * size);
    int i;
    for (i = 0; i < size; ++i) {
        *(array+i) = init_value;
    }
    return array;
}

int main()
{
    int N, D, X, i, j;
    if (scanf("%d", &N) < 0) return 1;
    if (scanf("%d", &D) < 0) return 1;
    if (scanf("%d", &X) < 0) return 1;

    int *A = malloc(sizeof(int) * N);
    int *P = init(N, 1);
    for (i = 0; i < N; ++i) {
        if (scanf("%d", A+i) < 0) return 1;
    }

    int count = 0;
    for (i = 1; i <= D; ++i) {
        for (j = 0; j < N; ++j) {
            if (P[j] == i) {
                count++;
                P[j] = P[j] + *(A+j);
            }
        }
    }
    printf("%d\n", X + count);
    return 0;
}

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






int main(){

  long long n;
  cin>>n;
  
  queue<long long> data;
  
  data.push(3);
  data.push(5);
  data.push(7);

  

  int count=0;
  
  while (data.front()<=n){
    long long tmpnum=data.front();
    data.pop();
    
    data.push(10*tmpnum+3);
    data.push(10*tmpnum+5);
    data.push(10*tmpnum+7);
    
    string tmp=to_string(tmpnum);
    int count3=0;
    int count5=0;
    int count7=0;
    
    for (int i=0;i<int(tmp.size());i++){
      if (tmp.at(i)=='3'){
        count3++;
      }
      else if (tmp.at(i)=='5'){
        count5++;
      }
      else if (tmp.at(i)=='7'){
        count7++;
      }
    }
    
    if (count3>=1 and count5>=1 and count7>=1){
      count++;
    }
  }
  
  cout<<count<<endl;
    
    


 
  
  
    
    
           
    
      
           
      
      
      
    
  
  
  
    
    
    
    


  
}

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

using namespace std;

const int N=20,M=33005,inf=0x3F3F3F3F;

int n,m,ec[N][N],ans=inf,U;
int dp[M][N],sc[M][N],g[M];
bool ok[N][M];

int find(int*fa,int x){return fa[x]==x?x:fa[x]=find(fa,fa[x]);}
bool judge(int u,int S){
	if(S>>u&1)return -1;
	static int fa[N];
	static bool vi[N],ok[N];
	for(int i=0;i<n;i++)fa[i]=i,vi[i]=ok[i]=0;
	for(int i=0;i<n;i++)if(S>>i&1)for(int j=i+1;j<n;j++)if(S>>j&1)fa[find(fa,i)]=find(fa,j);
	for(int i=0;i<n;i++)if(S>>i&1){int k=find(fa,i);vi[k]=true;if(!ec[u][i])continue;ok[k]=true;}
	for(int i=0;i<n;i++)if(vi[i]&&!ok[i])return false;
	return true;
}

inline void upd(int&x,int y){x<y?:x=y;}

inline int F(int S,int T){
	int res=0;
	for(int i=0;i<n;i++)if(T>>i&1)res+=sc[S][i];
	return res;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v,c;i<=m;i++)scanf("%d%d%d",&u,&v,&c),u--,v--,ec[u][v]=ec[v][u]=c;
	U=(1<<n)-1;
	for(int i=0;i<n;i++)for(int j=0;j<=U;j++)ok[i][j]=judge(i,j);
	for(int S=0;S<=U;S++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(S>>j&1)sc[S][i]+=ec[i][j];
	memset(dp,0x3F,sizeof(dp));
	for(int S=1;S<=U;S+=2)if(ok[0][S^1])dp[S][0]=0;
	for(int S=0;S<=U/2;S++)for(int u=0;u<n;u++)if(dp[S][u]!=inf){
		for(int K=U-S,T=K;T;T=(T-1)&K)g[T]=F(S,T);
		for(int v=0;v<n;v++)if(~S>>v&1){
			if(!ec[u][v])continue;
			int T=U-S-(1<<v),cur=sc[S^(1<<u)][v];
			for(int z=T;z;z=(z-1)&T)if(ok[v][z])
				upd(dp[S|1<<v|z][v],dp[S][u]+cur+g[z]);
			upd(dp[S|1<<v][v],dp[S][u]+cur);
		}
	}
	for(int S=U/2+1;S<=U;S++)if(dp[S][n-1]!=inf)upd(ans,dp[S][n-1]+F(S,U^S));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int main(void){
int N, A[100], B[100], C[100], sum=0;
scanf("%d", &N);
for(int i=0;i<N;i++){
    scanf("%d", &A[i]);
}
for(int i=0;i<N;i++){
    scanf("%d", &B[i]);
    sum+=B[i];
}
for(int i=0;i<N-1;i++){
    scanf("%d", &C[i]);
}
for(int i=1;i<N;i++){
    if(A[i]-A[i-1]==1){
        sum+=C[A[i-1]-1];
    }
}
printf("%d", sum);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

vector<int> treeCentroid(const vector<vector<pair<int, long long>>>& g){
    vector<int> res;
    function<int(int, int)> dfs = [&](int pos, int prev){
        int size = 1;
        int maxSize = 0;
        for(auto& t : g[pos]){
            if(t.first == prev) continue;
            int cur = dfs(t.first, pos);
            size += cur;
            maxSize = max(maxSize, cur);
        }
        maxSize = max<int>(maxSize, g.size() - size);
        if(2*maxSize <= g.size()) res.push_back(pos);
        return size;
    };
    dfs(0, -1);
    return res;
}

pair<int, long long> solve(const vector<vector<pair<int, long long>>>& g, int pos, int prev){
    int num = 1;
    long long cost = 0;
    long long back = 0;
    for(auto& t : g[pos]){
        if(t.first == prev){
            back = t.second;
        } else {
            auto pr = solve(g, t.first, pos);
            num += pr.first;
            cost += pr.second;
        }
    }
    cost += 2 * num * back;
    return make_pair(num, cost);
}

int main(){
    int N;
    while(cin >> N){
        vector<vector<pair<int, long long>>> g(N);
        for(int i=0;i<N-1;i++){
            int A, B;
            long long C;
            cin >> A >> B >> C;
            g[A-1].emplace_back(B-1, C);
            g[B-1].emplace_back(A-1, C);
        }
        auto centroid = treeCentroid(g);
        long long res = solve(g, centroid[0], -1).second;
        long long dec = 1LL << 40;
        for(auto& t : g[centroid[0]]){
            if(centroid.size() == 2 && t.first == centroid[1]){
                dec = t.second;
                break;
            } else {
                dec = min(dec, t.second);
            }
        }
        cout << res - dec << endl;
    }
}

Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		int volume = a * a * b;
		double radian = 0;
		if(volume == x * 2){
			radian = Math.atan(b / (double)a);
		}else if(volume > x * 2){
			double c = x / (double)a / b * 2;
			radian = Math.atan(b / c);
		}else{
			double c = (x - volume / (double)2) / a / a * 2;
			radian = Math.atan((b - c) / (double)a);
		}
		System.out.println(radian * 180 / Math.PI);
	}
}


Measured memory_bytes: 23636
/*input
4
5 7
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  int a, b;
  cin >> n >> a >> b;
  bool flag = 0;
  for(int i = a; i <= b; i ++) {
    if(i % n == 0) {
      flag = 1;
      break;
    }
  }
  if(flag) {
    cout << "OK";
  } else {
    cout << "NG";
  }
  return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>
#include <math.h>

typedef struct {double x,y;}Point;

void koch(int n,Point a,Point b){
  if(n==0)return;

  Point s,t,u;
  double th =M_PI *60.0/180.0;

  s.x =(2.0*a.x +1.0 *b.x)/3.0;
  s.y =(2.0*a.y +1.0 *b.y)/3.0;
  t.x = (1.0*a.x+2.0*b.x)/3.0;
  t.y = (1.0*a.y+2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2072
h, w = map(int, input().split())
board = [[i for i in input()] for _ in range(h)]

def check(i, j):
    if (j-1 >= 0):
        if(board[i][j-1] == "#"):
            return False
    if (j+1 < w):
        if(board[i][j+1] == "#"):
            return False
    if (i-1 >= 0):
        if(board[i-1][j] == "#"):
            return False
    if (i+1 < h):
        if(board[i+1][j] == "#"):
            return False

    return True

def main():
    for i in range(h):
        for j in range(w):
            if (board[i][j] == "#"):
                if(check(i,j)):
                    return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
    string s, t; cin>>s>>t;
    int n=s.size(), m=t.size();
    int ans=m;
    for(int i=0; i<=n-m; i++){
        int cnt=0;
        for(int j=0; j<m; j++){
            if(s[j+i]!=t[j]) cnt++;
        }
        ans=min(ans, cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int m,f,r;
        while(true){
            m=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            if(m==-1&&f==-1&&r==-1) break;
            int s=m+f;
            if(m==-1||f==-1){
                System.out.println("F");
            }else if(s>=80){
                System.out.println("A");
            }else if(65<=s&&s<80){
                System.out.println("B");
            }else if((50<=s&&s<65)||r>=50){
                System.out.println("C");
            }else if(30<=s&&s<50){
                System.out.println("D");
            }else if((0<s&&s<30)||(r>=-1&&r<50)){
                System.out.println("F");
            }
        }
    }
}


Measured memory_bytes: 26384
#include<cstdio>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int dp[1001][1001],N,M,D[1001],C[1001],mi=1000000000;
signed main(){
    cin>>N>>M;
    fill(dp[0],dp[0]+1001*1001,1000000000);
    for(int i=0;i<N;i++){
        cin>>D[i];
    }
    for(int i=0;i<M;i++){
        cin>>C[i];
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
            dp[i+1][j+1]=min(dp[i][j]+D[i]*C[j],dp[i+1][j+1]);
        }
    }
    for(int i=0;i<=M;i++){
        mi=min(mi,dp[N][i]);
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 9000
var
	N,S,i,j,A,ans:Longint;
	dp:Array[0..3001]of Longint;
begin
	read(N,S);
	for i:=1 to N do begin
		dp[S]:=i;
		read(A);
		for j:=A to S do begin
			inc(dp[j-A],dp[j]);
			if dp[j-A]>=998244353 then dec(dp[j-A],998244353);
		end;
		inc(ans,dp[0]);
		if ans>=998244353 then dec(ans,998244353);
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>


int main(void)
{
   int a,b;
    int answer,i,j;
answer=0;
    scanf("%d",&a);
    scanf("%d",&b);

if((b-1)%(a-1)==0)
{
    answer=(b-1)/(a-1);
}else 
{
    answer=(b-1)/(a-1)+1;
}


printf("%d",answer);

   
    
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    Vi a(n); rep(i, n) cin >> a[i];
    ld tmp = 0;
    rep(i, n){
        tmp += 1.0 / a[i];
    }
    fcout(7) << (1.0 / tmp) << endl;

return 0;
}

Measured memory_bytes: 3780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<string> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s.at(i);
	}
	sort(all(s));

	string res;
	for (int i = 0; i < n; i++)
	{
		res += s.at(i);
	}

	println(res);
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define OUT(v) cout<<v<<"\n"
const int INF = 1e9;

int N, K;
int x[(int)1e5];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  scanf("%d%d", &N, &K);
  vi lt, ge;
  REP(i, N) {
    int x;
    scanf("%d", &x);
    if (x < 0)
      lt.push_back(x);
    else
      ge.push_back(x);
  }
  reverse(ALL(lt));
  int ans = INF;
  REP(k, K+1) {
    // ltのうちk個、geのうちK-k個つける
    if (lt.size() >= k && ge.size() >= K-k) {
      int a = k != 0 ? abs(lt[k-1]) : 0,
          b = K-k != 0 ? abs(ge[K-k-1]) : 0;
      ans = min(ans, min(a, b) * 2 + max(a, b));
    }
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 1020
n,m=map(int,input().split())
root=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    root[a].append(b)
    root[b].append(a)
s=[0]*(n+1)
s[0]=1
s[1]=1
ans=0
def f(a,x):
    global ans
    for i in root[a]:
        if x[i]==0:
            z=[x[j] for j in range(n+1)]
            z[i]=1
            f(i,z)
    if x.count(1)==n+1:
        ans+=1
f(1,s)
print(ans)




Measured memory_bytes: 73760
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b(n+1,0);
	for(ll i=n; i>=1; i--){
		ll sum = 0;
		for(ll j=2*i; j<=n; j+=i){
			sum += b[j];
		}
		if(sum%2 != a[i-1]) b[i]++;
	}
	vl ans;
	rep(i,n+1){
		if(b[i]) ans.push_back(i);
	}
	cout << ans.size() << endl;
	for(auto i : ans) cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 4980
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <list>
using namespace std;


#define MAX 500000
#define SENTINEL 2000000000
#define INFTY (1<<21)
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

string candidate[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string S; cin >> S;
  reverse(S.begin(), S.end());
  for (int i=0; i<4; i++){
    reverse(candidate[i].begin(), candidate[i].end());
  }
  int k=0;
  bool ans;
  while(k != S.size()){
    ans = false;
    for (int i=0; i<4; i++){
      string substring = S.substr(k, candidate[i].size());
      if (substring == candidate[i]){
        k += candidate[i].size();
        ans |= true;
      }
    }
    if (ans == false) break;
  }

  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2],dp[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  for(int i=1;i<=n;i++)cin>>aa[i];
  dp[1]=1;int mx=1;
  for(int i=2;i<=n;i++)
  {
    if(aa[i]>aa[i-1])dp[i]=1;
    else dp[i]=dp[i-1]+1;

    mx=max(mx,dp[i]);
  }
  cout<<mx-1<<endl;
  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int n, m; cin >> n >> m;
  vector<int> v(n, -1);
  bool ok = true;
  for(int i=0;i<m;++i) {
    int s, c; cin >> s >> c;
    s--;
    if(n == 1) {
      if(v[s] != -1 && v[s] != c) {
        ok = false;
      } else {
        v[s] = c;
      }
      continue;
    }
    if((s == 0 && c == 0) || (v[s] != -1 && v[s] != c)) {
      ok = false;
    } else {
      v[s] = c;
    }
  }
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  for(int i=0;i<n;++i) {
    if(v[i] == -1) {
      if(n != 1 && i == 0) cout << 1;
      else cout << 0;
    } else {
      cout << v[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int k;
	string s;
	cin>>k>>s;
	//cout<<s.size();
	if(s.size()<=k)cout<<s<<endl;
	else 
	{
		rep(i,k)cout<<s[i];
		cout<<"..."; 
	} 
	return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if((x-r>=0)&&(y-r>=0)&&(x+r<=w)&&(y+r<=h)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

}

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

int main() {
    int N;
    int A[20];
    int x[20][20], y[20][20];
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;

    for (int bit = 0; bit < (1 << N); bit++) {
        bitset<15> s(bit);
        bool can = true;
        int cont = 0;

        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                cont++;
                for (int j = 0; j < A[i]; j++) {
                    if(y[i][j] ^ s.test(x[i][j] - 1)) {
                        can = false;
                    }
                }
            } else continue;
        }

        if (can) ans = max(ans, cont);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// 2020-07-05 15:52:12
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int h, w;
  cin >> h >> w;
  vector<vector<int> > wall(h, vector<int>(w, 0));
  rep(hi, h) {
    string s;
    cin >> s;
    rep(wi, w) if(s[wi] == '#') wall[hi][wi] = 1;
  }
  vector<vector<int> > sumh(h, vector<int>(w, 0));
  vector<vector<int> > sumw(h, vector<int>(w, 0));
  rep(hi, h) {
    vector<int> sum(w+1, 0);
    rep(wi, w) {
      if(wall[hi][wi]) sum[wi+1] = 0;
      else sum[wi+1] = sum[wi] + 1;
    }
    REPCM(wi, w-1, 0) {
      if(wall[hi][wi]) {
        sumw[hi][wi] = 0;
      } else {
        sumw[hi][wi] = sum[wi+1];
        sum[wi] = sum[wi+1];
      }
    }
  }
  rep(wi, w) {
    vector<int> sum(h+1, 0);
    rep(hi, h) {
      if(wall[hi][wi]) sum[hi+1] = 0;
      else sum[hi+1] = sum[hi] + 1;
    }
    REPCM(hi, h-1, 0) {
      if(wall[hi][wi]) {
        sumh[hi][wi] = 0;
      } else {
        sumh[hi][wi] = sum[hi+1];
        sum[hi] = sum[hi+1];
      }
    }
  }
  int ans = 0;
  rep(hi, h) rep(wi, w) chmax(ans, sumh[hi][wi] + sumw[hi][wi] - 1);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 50388
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    double a;
    cin >> n;

    double sum = 0;
    double multi = 1;
    for (int i = 0; i < n; i++) {
        cin >> a;
        sum += 1 / a;
    }
    double ans = 1 / sum;
    printf("%.10f",ans);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n ;
	vi a(n), b(n), c(n);
	rep(i, n)
	cin >> a[i] >> b[i] >> c[i];
	vector<std::vector<int>>  dp(n, vector<int>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	repA(i, 1, n - 1)
	{
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
	}
	db1(max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 11140
#include <stdio.h>

// L, R, U, D

int proc(char *s, int isodd) {
  if (s[0] == '\0') return 1;
  
  if (isodd == 1) {
    if (!(s[0] == 'R' || s[0] == 'U' || s[0] == 'D')) return 0;
  } else {
    if (!(s[0] == 'L' || s[0] == 'U' || s[0] == 'D')) return 0;
  }

  if (proc (++s, (isodd+1) % 2) == 0) return 0; else return 1;
}

int main() {
  char s[100];
  scanf("%s", s);

  if (proc(s, 1) == 1) printf("Yes\n"); else printf("No\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	int M=N*(N-1)/2;
	M-=N/2;
	cout<<M<<endl;
	rep1(i,N)rep1(j,N){
		if(i>=j)continue;
		if(i+j==(N+1-N%2))continue;
		cout<<i<<" "<<j<<" "<<endl;
	}
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;

    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if (500 * i + 100 * j + 50 * k == x) ++ans;
            }
        }
    }

    cout << ans << endl;

}

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

int main(void){
    int p, q, r;
    
    cin >> p >> q >> r;
    
    int result = p + q + r;
    
    if(p > q && p > r){
        result -= p;
    } else if(q > r){
        result -= q;
    } else {
        result -= r;
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256