akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(int argc, const char * argv[]) {
    int A, B, C, D;
    std::string str;
    std::cin >> A >> B >> C >> D;
    
    int count=0;
    while(A>0 && C>0){
        if(count%2==0){
            C=C-B;
        }else{
            A=A-D;
        }
        count++;
    }
    
    if(A>0){
        str="Yes";
    }else{
        str="No";
    }
    
    // insert code here...
    std::cout << str;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    sort(all(a));
    printf("%d ", a[n-1]);
    int d, d_min, r = 0;
    d_min = abs(a[n-1]-a[0]*2);
    for(int j=1; j < n; ++j){
        d = abs(a[n-1]-2*a[j]);
        if (d < d_min){
            d_min = d;
            r = j;
        }
    }
    printf("%d", a[r]);
    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

int ans = -1;
int n;
vi values;
vi costs;

void solve(int i, int value, int cost) {
	ans = max(ans, value-cost);
	if(i==n) return;
	
	solve(i+1, value+values[i], cost+costs[i]);
	solve(i+1, value, cost);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n;
	values.resize(n);
	costs.resize(n);
	
	for(auto &it: values) cin>>it;
	for(auto &it: costs) cin>>it;
	
	solve(0, 0, 0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]
cumA1 = [0]
cumA2 = [0]
asum = 0
bsum = 0
for a,b in zip(A1,A2):
    asum += a
    bsum += b
    cumA1.append(asum)
    cumA2.append(bsum)
print(cumA2[N]+max([cumA1[i]-cumA2[i-1] for i in range(1,N+1)]))

Measured memory_bytes: 3064
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 305;
f80 dp[N][N][N];
int n;
f80 go(vector<int> v){
	if(dp[v[0]][v[1]][v[2]] != -1)
		return dp[v[0]][v[1]][v[2]];
	int tot = v[0] + v[1] + v[2];
	if(tot == 0) return 0;
	f80 ans = n;
	if(v[0]) ans += v[0] * go({v[0] - 1, v[1], v[2]});
	if(v[1]) ans += v[1] * go({v[0] + 1, v[1] - 1, v[2]});
	if(v[2]) ans += v[2] * go({v[0], v[1] + 1, v[2] - 1});
	ans /= tot;
	return dp[v[0]][v[1]][v[2]] = ans;
}
void solve(){
	fill(&dp[0][0][0], &dp[0][0][0] + N * N * N, -1);
	cin >> n;
	vector<int> v(3, 0);
	fr(i, 1, n){
		int x;
		cin >> x;
		v[x - 1]++;
	}
	cout << setprecision(10) << fixed << go(v) << endl;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

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

typedef struct Node{
  int value;
  Node *parent, *left, *right;
} Node;

Node *NIL, *root;

void insert(int k){
  Node *y = NIL, *x = root, *z;

  z = (Node *)malloc(sizeof(Node));
  z->value = k;
  z->left = z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->value < x->value) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->value < y->value) y->left = z;
  else y->right = z;
}

void preParse(Node *node){
  if(node == NIL) return ;

  cout << " " << node->value;
  if(node->left != NIL) preParse(node->left);
  if(node->right != NIL) preParse(node->right);
}

void inParse(Node *node){
  if(node == NIL) return ;

  if(node->left != NIL) inParse(node->left);
  cout << " " << node->value;
  if(node->right != NIL) inParse(node->right);
}

int main(){

  int n, key;
  string command;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> command;
    if(command == "insert"){
      cin >> key;
      insert(key);
    }else if(command == "print"){
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 26648
import java.util.Scanner;

class Main {
    public void kami() {
        Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
			
			int h = S / 3600;
			int m = (S - h * 3600) / 60;
			int s = S - (h * 3600) - (m * 60);
			
			System.out.println( h + ":" + m + ":" + s);
		
    }
	public static void main(String[] args) {
        new Main().kami();

	}

}

Measured memory_bytes: 17224
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (int i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll D;
    string res;

    cin >> D;

    if(D == 22)res = "Christmas Eve Eve Eve";
    if(D == 23)res = "Christmas Eve Eve";
    if(D == 24)res = "Christmas Eve";
    if(D == 25)res = "Christmas";

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.split(" ")[0].to_i
def check(ma,ss,cc)
  if(ma[2] == cc)
    return true if (ss >= ma[1])
    return false
  else
    return true if ((ss - 0.5) >= ma[1])
    return false
  end
end
vl = []
n.times do |nn|
  vl.push(gets.chomp.split(" ").map{ |it| it.to_i})
end
vl.sort!{ |a,b| a[1] <=> b[1]}
vl.sort!{ |a,b| a[0] <=> b[0]}

list = [[-1,-1,-1]]
while(vl.size > 0)
  ok = false
  cas = vl.shift
  list.size.times do |nn|
    unless ok
      if check(list[nn],cas[0],cas[2])
        list[nn] = cas
        ok =true
      end
    end
  end
  list.push(cas) unless ok
end
print "#{list.size}\n"

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

int main() {
  int H,N,tmp=0;
  cin >> H >> N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin >> A[i];
  for(int i=0;i<N;++i) tmp += A[i];
  if(tmp>=H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,k,c;
	scanf("%d",&n);
	c=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				c++;
			}
		}
	}
	printf("%d\n",c);
	return 0;
}
	

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
priority_queue<pair<uint64_t, uint64_t>> q;
int main()
{
  uint64_t n, m;
  cin >> n >> m;
  for (uint64_t i = 0; i < n; ++i) {
    uint64_t x;
    cin >> x;
    q.push({ x, (x & 1) });
  }
  while (!q.empty() && m > 0) {
    auto x = q.top();
    q.pop();
    uint64_t newx = x.first >> 1;
    if (newx > 0)
      q.push({ newx, (newx & 1) });
    --m;
  }
  uint64_t ans = 0;
  while (!q.empty()) {
    auto& x = q.top();
    ans += x.first;
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll X,Y,Z,K;
vector<ll> A,B,C;

int main(){
    cin>>X>>Y>>Z>>K;
    rep(i,X){ll a;cin>>a;A.push_back(a);}
    rep(i,Y){ll a;cin>>a;B.push_back(a);}
    rep(i,Z){ll a;cin>>a;C.push_back(a);}

    sort(A.begin(),A.end(),greater<ll>());
    sort(B.begin(),B.end(),greater<ll>());
    sort(C.begin(),C.end(),greater<ll>());

    priority_queue<ll> ans;
    rep(i,X){
        ll a=A[i];
        rep(j,Y){
            ll b=B[j];
            rep(k,Z){
                ll c=C[k];
                if((i+1)*(j+1)*(k+1)<=K) ans.push(a+b+c);
                else break;
            }
        }
    }

    rep(i,K){
        cout<<ans.top()<<endl;
        ans.pop();
    }
}

Measured memory_bytes: 1412
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e6+17;
int a[MAXN];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    int ans = 0;
    for (int i = 0; i < n-1; ++i)
    {
    	if(a[i]==i+1)
    	{
    		swap(a[i],a[i+1]);
    		ans++;
    	}
    }
    if(a[n-1]==n) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  // dp[i][j]:=（上からiビット目まで決めた時点で、その値がk未満かどうか確定した時(j==1)とそうでない時(j==0)の求めるものの最大値）
  vector<vector<int>> dp(50, vector<int>(2, -1));
  dp[41][0] = 0;
  for (int bit = 40; bit >= 0; bit--) {
    int one = 0;
    int pow = 1LL << bit;
    rep(i, n) if (a[i] & pow) one++;

    if (dp[bit + 1][0] >= 0) {
      if (k & pow) {
        cmax(dp[bit][1], dp[bit + 1][0] + pow * one); //未確定->確定
        cmax(dp[bit][0], dp[bit + 1][0] + pow * (n - one)); //未確定->未確定
      } else {
        cmax(dp[bit][0], dp[bit + 1][0] + pow * one); //未確定->未確定
      }
    }
    if (dp[bit + 1][1] >= 0) { //確定->確定
      cmax(dp[bit][1], dp[bit + 1][1] + pow * max(one, n - one));
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
   
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line;
        LOOP: while ((line = input.readLine()) != null) {
            int line_len = line.length();
            if (line_len == 1 && line.charAt(0) == '0')
                break LOOP;
            long total = 0;
            for (int i = 0; i < line_len; i++) {
                int ival = Character.getNumericValue(line.charAt(i));
                if (ival >= 0)
                    total += ival;
                // total += line.charAt(i) - '0';
            }
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 24244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807


void solve()
{
  
  string S;
  cin>>S;

  if(S == "A")
  {
    cout<<"T"<<endl;
  }
  else if (S == "T")
  {
    cout<<"A"<<endl;
  }
  else if(S == "C")
  {
    cout<<"G"<<endl;
  }
  else
  {
    cout<<"C"<<endl;
  }
  
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun,  4th Aug 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

int n,m;
vi seen;
vi order;
vi val;
vii g;

void dfs1(int p){

	if(seen[p]) return;
	seen[p] = 1;

	for(auto ch:g[p]){
		if(!seen[ch]) dfs1(ch);
	}

	order.pb(p);
}

void solve() {

	cin >> n >> m;

	g.assign(n, vi());

	rep(i,0,m){
		int x,y;
		cin >> x >> y;
		x--, y--;

		g[x].pb(y);
	}

	seen.assign(n,0);

	rep(i,0,n){
		if(!seen[i]) dfs1(i);
	}

	reverse(all(order));

	seen.assign(n,0);
	val.assign(n,0);

	rep(i,0,n){

		int p = order[i];

		for(auto ch:g[p]){
			val[ch] = max(val[ch], val[p]+1);
		}
	}

	pvi(val);

	cout << *max_element(all(val)) << endl;
}


Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  
  vector<Int> cnt(n,0);
  for(Int i=1;i<n;i++){
    Int u,v,a;
    cin>>u>>v>>a;
    cnt[u]^=a;
    cnt[v]^=a;
  }
  
  vector<Int> bc(16,0);
  for(Int i=0;i<16;i++) bc[i]=__builtin_popcount(i);
  
  Int ans=n,res=0;
  for(Int i=0;i<n;i++){
    if(!cnt[i]){
      ans--;
      continue;
    }
    if((res>>cnt[i])&1) ans--;
    res^=1<<cnt[i];
  }
  
  vector<Int> dp(1<<16,-1),ok(1<<16,0);
  for(Int i=0;i<(1<<16);i++){
    Int tmp=0;
    for(Int j=0;j<16;j++)
      if((i>>j)&1) tmp^=j;
    ok[i]=tmp==0;
  }
  
  function<Int(Int)> dfs;
  dfs=[&](Int b)->Int{
	if(!b) return 0;
	Int &v=dp[b];
	if(~v) return v;
	v=1;
	for(Int i=b;i>0;i=(i-1)&b){
	  if(i==b) continue;
	  if(ok[i]) chmax(v,dfs(i)+dfs(b^i));
	}
	return v;
      };
  
  cout<<ans-dfs(res)<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int n, m, x;
int d[15][15];
int c[15], al[15];
int dd[15];
int res = INT_MAX;

void dfs(int order, int cost) {
    if (order == n + 1) {
        memset(dd, 0, sizeof(dd));
        int i, j;
        for (i=1; i<=n; i++) {
            if (al[i]) for (j=1; j<=m; j++) dd[j] += d[i][j];
        }
        for (i=1; i<=m; i++) if (dd[i] < x) return;
        if (res > cost) res = cost;
        return;
    }
    dfs(order + 1, cost);
    al[order] = 1;
    dfs(order + 1, cost + c[order]);
    al[order] = 0;
}

void fastio() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
}

int main() {
    fastio();
    cin >> n >> m >> x;
    for (int i=1; i<=n; i++) {
        cin >> c[i];
        for (int j=1; j<=m; j++) cin >> d[i][j];
    }
    dfs(0, 0);
    if (res == INT_MAX) cout << "-1";
    else cout << res;
    return 0;
}

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

const int N=100005;

int n,tot,ans;
int a[N],b[N],c[N],d[N],f[N<<1];

map<int,int> mp;

int Find(int x){return f[x]==x?x:f[x]=Find(f[x]);}

void work()
{
	for(int i=1;i<=n;i++) if(c[i]!=d[i]){puts("-1");return ;}
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i]||i==n)
		{
			ans+=i<n;
			if(!mp[a[i]]) mp[a[i]]=++tot;
			if(!mp[b[i]]) mp[b[i]]=++tot;
		}
	}
	if(!ans){puts("0");return ;}
	for(int i=1;i<=tot;i++) f[i]=i;
	for(int i=1;i<=n;i++) if(a[i]!=b[i]) f[Find(mp[a[i]])]=Find(mp[b[i]]);
	for(int i=1;i<=tot;i++) ans+=f[i]==i;
	printf("%d\n",ans-1);
}
 
void init()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[n+1]^=a[i];
	for(int i=1;i<=n;i++) scanf("%d",&b[i]),b[n+1]^=b[i];
	n++;for(int i=1;i<=n;i++) c[i]=a[i],d[i]=b[i];
	sort(c+1,c+1+n);sort(d+1,d+1+n);
}

int main()
{
    init();
    work();
    return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a; cin >> b; cin >> c;
    int ct = 0;
    REP(i,c) {
        if(b < a) break;
        b -= a;
        ct++;
    }
    cout << ct << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main(){
  int kazu = 0;
  cin >> kazu;
  vector<int> nagasa(kazu);
  vector<string> taitoru(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> taitoru[i] >> nagasa[i];
  }
  string saigo;
  cin >> saigo;
  int a = 0;
  int kotae = 0;
  for(int i = 0;i <= kazu - 1;i++){
    if(a == 1){
      kotae += nagasa[i];
    }
    else if(taitoru[i] == saigo){
      a = 1;
    }
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,m;
int a[5];
int used[5];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        if(used[x] && a[x]!=y){
            cout<<-1<<endl;
            return 0;
        }
        a[x]=y;
        used[x]=1;
    }
    if(used[1] && a[1]==0 && n!=1){
        cout<<-1<<endl;
        return 0;
    }
    if(!used[1] && n!=1) a[1]=1;
    for(int i=1;i<=n;i++)
        cout<<a[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> l;
int main() {
  cin >> n; read_n(l, n);
  bool ok = true;
  for (lli i=0; i<n; ++i) {
    lli s = 0;
    for (lli j=0; j<n; ++j) {
      if (i==j) continue;
      s += l[j];
    }
    if (l[i] >= s) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}



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

int main() {

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x = i;
        if(i % 3 == 0) {
            cout << " " << i;
        }else{
            while(x){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
        
}



Measured memory_bytes: 3116
fn solve() {
    let n = read();
    let mut s: HashSet<usize> = HashSet::new();
    let mut f = 0;
    for _ in 0..n {
        let a: usize = read();
        if a >= 3200 {
            f += 1;
        } else {
            s.insert(a / 400);
        }
    }
    println!("{} {}", if s.len() != 0 { s.len() } else { 1 }, s.len() + f);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main()
{
  int N, D;
  cin >> N >> D;
  int K, l;
  K = N / (2 * D + 1);
  l = N % (2 * D + 1);
  if (l == 0)
  {
    cout << K << endl;
  }
  else
  {
    cout << K + 1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println(a*2+b*2);
        
    }
}



Measured memory_bytes: 26312
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x)
#define printl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;

int main(){
    string s, t; cin >> s >> t;
    t += s;
    print(t);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50;

int n,m,q;
long long a[N],d[N],c[N],ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n);
	read(q);
	a[++m]=n;
	while(q--){
		long long z; 
		read(z); 
		while(m&&z<=a[m])--m;
		a[++m]=z;
	}
	c[m]=1;
	dec(i,m,1){
		long long t=a[i];
		for(int p=upper_bound(a,a+i,t)-a-1;p;p=upper_bound(a,a+p,t)-a-1){
			c[p]+=t/a[p]*c[i];
			t=t%a[p];
		}
		d[1]+=c[i],d[t+1]-=c[i];
	}
	rep(i,1,n){
		printf("%lld\n",ans+=d[i]);
	}
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define input(a) for(int i=0;i<n;i++) cin>>a[i];
using namespace std;
int arr[19]={0};
int main(){
	IOS;
	int m,d;
	cin>>m>>d;
	int ctr=0;
	for(int i=1;i<=m;i++){
		for(int j=22;j<=d;j++){
			if(j==100)
				break;
			int d1=j%10;
			if(d1<2)
				continue;
			int d10=j/10;
			if(d10<2)
				continue;
			if(i==d1*d10){
				//cout<<i<<" "<<j<<endl;
				ctr++;
			}
		}
	}

	cout<<ctr;
return 0;
}

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

int main(){
    int X, Y;
    cin >> X >> Y;
    if(X * 4 >= Y && Y % 2 == 0 && X * 2 <= Y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
    long long int n, p, ans = 1;
    cin >> n >> p;
    long long int i = 1;
    long long int a = pow(2, n);
    long long int min = 2;
    int l = 2;
    if (n == 1)
    {
        cout << p << endl;
        return 0;
    }
    while (pow(i, n) <= p)
    {
        long long int tmp = pow(i, n);
        if (p % tmp == 0)
        {
            ans *= i;
            p /= tmp;
            if (i == 1)
                i++;
        }
        else
        {
            if (i == 3)
                i += 2;
            else if (i > 4)
            {
                i += l;
                l = 6 - l;
            }
            else
                i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    std::string input;
    std::unordered_map<char, int> mp;
    cin >> input;
    for (auto c : input){
        mp[c]+=1;
    }
    if(mp.size()!=2){
        cout<<"No"<<endl;
        return 0;
    }

    for(auto c : mp){
        if(c.second!=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

x = [1] * n

for i in range(m):
  a, b = map(int, input().split())
  
  if h[a-1] > h[b-1]:
    x[b-1] = 0
  elif h[a-1] < h[b-1]:
    x[a-1] = 0
  else:
    x[b-1] = 0
    x[a-1] = 0
    
print(sum(x))

Measured memory_bytes: 19900
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

int N;
int K;
int R;
int S;
int P;
string T;
string Note(1000000, ' ');

void solve() {
  cin >> N >> K >> R >> S >> P >> T;
  long long ans = 0;
  for(int i = 0; i < K; i++){
    if(T[i] == 'r'){
      ans += P;
      Note[i] = 'r';
    }
    else if(T[i] == 's'){
      ans += R;
      Note[i] = 's';
    }
    else if(T[i] == 'p'){
      ans += S;
      Note[i] ='p';
    }
  }
  for(int i = K; i < N; i++){
    if(T[i] == 'r' && Note[i-K] != 'r'){
      ans += P;
      Note[i] = 'r';
    }
    else if(T[i] == 's' && Note[i-K] != 's'){
      ans += R;
      Note[i] = 's';
    }
    else if(T[i] == 'p' && Note[i-K] != 'p'){
      ans += S;
      Note[i] ='p';
    } else{
      Note[i] = 'n';
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int sort(const void *a, const void *b){
    return *(int*)b-*(int*)a ;
}

int main(void){
    int n;
    scanf ("%d",&n);
    int a[n];
    bool choosen[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        choosen[i]=false;
    }
    qsort (a,n,sizeof(int),sort);
    long long yoko=0,tate=0;
    for (int i=0; i<n-1; i++){
        if (a[i]==a[i+1] && choosen[i]==false && choosen[i+1]==false){
            yoko=a[i];
            choosen[i]=true;
            choosen[i+1]=true;
            break;
        }
    }
    for (int i=0; i<n-1; i++){
        if (a[i]==a[i+1] && choosen[i]==false && choosen[i+1]==false){
            tate=a[i];
            break;
        }
    }
    long long ans;
    ans=yoko*tate;
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  string s;  cin>>s;
  vector<char>A(s.size());
  for(int i=0; i<s.size(); i++){
    A[i]=s[i];
  }
  sort(A.begin(),A.end());
  int yes=0;
  for (int i=0;i<s.size();i++){
    if(A[i]==A[i+1]){
      yes=1;
      break;
    }    
  }
  if(yes==1) cout<<"no"<<endl;
  else cout<<"yes"<<endl;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

xa = max(x)
ya = min(y)

for i in range(X+1, Y+1):
    if xa < i <= ya:
        print('No War')
        exit()
print('War')


Measured memory_bytes: 3316
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
  for($j = 0; $j < $a[$i]; $j++){
    list($b, $c) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $map[$i][$b-1] = $c; 
  }
}
$max = 0;
for($i = 0, $I = 2**$n; $i < $I; $i++){
  $bits = sprintf('%0'.$n.'b', $i);
  foreach($map as $from => $row){
    if($bits[$from] === '1'){ 
      foreach($row as $to => $v){
        if($bits[$to] != $v){ 
          continue 3;
        }
      }
    }
  }
  $sum = 0;
  for($j = 0; $j < $n; $j++){
    $sum+=$bits[$j];
  }
  $max = max($max, $sum);
}
echo $max;


Measured memory_bytes: 4604
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    long N = s.nextLong();
    ArrayList<String> str = new ArrayList<String>();
    ArrayList<Character> cha = new ArrayList<Character>();
    long Ans = 0;
    String a = new String();
    for (long i=0;i<N;i++){
      a = s.next();
        for(int j=0;j< a.length();j++){
          cha.add(a.charAt(j));
        }
      Collections.sort(cha);
      a = cha.toString();
      str.add(a);
      cha.clear();
    }
    Collections.sort(str);
    int REN = 0;
    for (int i=0; i<N-1;i++){
      String ha = str.get(i);
      if (ha.equals(str.get(i+1))){
        REN += 1;
        Ans += REN;
      }
      else{
        REN = 0;
      }
    }
    System.out.println(Ans);
  }
}

Measured memory_bytes: 74084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void no() {
  cout << -1 << endl;
  exit(0);
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> s(m), c(m);
  REP(i, m) {
    cin >> s[i] >> c[i];
    s[i]--;
  }

  REP(i, pow(10, n)) {
    string t = to_string(i);
    if (SZ(t) != n) {
      continue;
    }
    bool ok = true;
    REP(j, m) {
      if (t[s[j]] - '0' != c[j]) {
        ok = false;
      }
    }
    if (ok) {
      cout << t << endl;
      return 0;
    }
  }
  no();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <stack>
using namespace std;
using Graph = vector<vector<int>>;

// 探索
vector<bool> seen, finished;

// サイクル復元のための情報
int pos = -1; // サイクル中に含まれる頂点 pos
stack<int> hist; // 訪問履歴

void dfs(const Graph &G, int v, int p) {
    seen[v] = true;
    hist.push(v);
    for (auto nv : G[v]) {
        if (nv == p) continue; // 逆流を禁止する

        // 完全終了した頂点はスルー
        if (finished[nv]) continue;

        // サイクルを検出
        if (seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }

        // 再帰的に探索
        dfs(G, nv, v);

        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) return;
    }
    hist.pop();
    finished[v] = true;
}

int main() {
    // 頂点数 (サイクルを一つ含むグラフなので辺数は N で確定)
    int N; cin >> N;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b; // 頂点番号が 1-indexed で与えられるので 0-indexed にする
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 探索
    seen.assign(N, false), finished.assign(N, false);
    pos = -1;
    dfs(G, 0, -1);

    // サイクルを復元
    set<int> cycle;
    while (!hist.empty()) {
        int t = hist.top();
        cycle.insert(t);
        hist.pop();
        if (t == pos) break;
    }

    // クエリに答える
    int Q; cin >> Q;
    for (int _ = 0; _ < Q; ++_) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (cycle.count(a) && cycle.count(b)) cout << 2 << endl;
        else cout << 1 << endl;
    }
}


Measured memory_bytes: 19140
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
        digit = i[0]-1
        if digit > N-1:
            flag = False
            break
        elif ans[digit] != -1 and ans[digit] != i[1]:
            flag = False
            break
        elif i == [1, 0] and N > 1:
            flag = False
            break
        else:
            ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)

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


int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];

	int dp[n][3]={};
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];

	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][0],a[i]+max(dp[i-1][1],dp[i-1][2]));
		dp[i][1]=max(dp[i-1][1],b[i]+max(dp[i-1][0],dp[i-1][2]));
		dp[i][2]=max(dp[i-1][2],c[i]+max(dp[i-1][1],dp[i-1][0]));
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 5908
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (600)
#define MOD (1000000007)


//グラフ
#define MAXV (MAXN)
int Gv;
typedef struct edge
{
    int to;
    ll cost;
    struct edge* next;
}edge;

edge es[MAXV*MAXV];
int en = 0;
edge* Ge[MAXV]; //vから出てる有向辺
int Gd[MAXV]; //vの次数

void Gadd(int v, int to, ll cost)
{
    edge* e = &es[en];
    en++;
    e->to = to;
    e->cost = cost;
    e->next = Ge[v];
    Ge[v] = e;
    Gd[v]++;
}

int n;
double sc[MAXV];

int main(void)
{
    ll m;
    scanf("%d %ld",&n,&m);
    for(int i=0;i<m;i++) 
    {
        int s,t;
        scanf("%d %d",&s,&t);
        s--;t--;
        Gadd(s,t,0);
    }

    double ans = DBL_MAX;
    for(int i=0;i<n-1;i++)
    {
        sc[n-1] = 0.0;
        for(int j=n-2;j>=0;j--)
        {
            double mx = 0.0;
            double ns = 0.0;
            int c=0;
            edge* e = Ge[j];
            for(;e!=NULL;e=e->next)
            {
                if(sc[e->to]==-1.0) continue;
                mx = max(mx,sc[e->to]+1.0);
                ns += sc[e->to]+1.0;
                c++;
            }
            if(ns==0.0)
            {
                sc[j] = -1.0;
                continue;
            }
            if(i==j && c>=2)
            {
                sc[j] = (ns-mx)/(c-1);
            }else
            {
                sc[j] = ns/c;
            }
        }
        ans = min(ans,sc[0]);
    }

    printf("%lf\n", ans);
    return 0;
}


Measured memory_bytes: 6272
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int per = sc.nextInt();
    int maisu = sc.nextInt();
    int limitSecond = sc.nextInt();
    int result = (int)((limitSecond+0.5)/per)*maisu;
    System.out.println(result);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define S size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define SE second
#define ld long double



using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ld area(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3){
    return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
}

vector <ll> v;

void generate(string s){
    stringstream obj(s);
    ll x=0;
    obj>>x;
    if(x<=1e6){
        v.PB(x);
        generate(s+"1"), generate(s+"0");
    }
}

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    ll ar[n][3];
    REP(i,0,n){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    ll dp[n][3];
    REP(i,0,n){
        dp[i][0]=0, dp[i][1]=0, dp[i][2]=0;
    }
    dp[0][1]=ar[0][1], dp[0][0]=ar[0][0], dp[0][2]=ar[0][2];
    REP(i,1,n){
        REP(j,0,3){
            if(j==0){
                dp[i][j]=max(dp[i-1][1],dp[i-1][2])+ar[i][0];
            }
            if(j==1){
                dp[i][j]=max(dp[i-1][0],dp[i-1][2])+ar[i][1];
            }
            if(j==2){
                dp[i][j]=max(dp[i-1][0],dp[i-1][1])+ar[i][2];
            }
        }
    }
    ll ans=0;
    REP(i,0,3){
        ans=max(ans,dp[n-1][i]);
    }
    cout<<ans;


    
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>
int main(void) {
    int d,theta=0,temp,X,Y;
    double x=0.0,y=0.0;
    while (1) {
        scanf("%d,%d",&d,&temp);
        if (d==0&&temp==0) break;
        x+=d*sin(theta*asin(1)/90);
        y+=d*cos(theta*asin(1)/90);
        theta+=temp;
    }
    X = x;
    Y = y;
    printf("%d\n%d\n",X,Y);
    return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		sc.nextLine();

		int[] h = new int[n + 1];
		int[] dp = new int[n + 1];

		h[0] = Integer.MAX_VALUE;
		for (int i = 1; i <= n; i++) {
			h[i] = sc.nextInt();
			dp[i] = Integer.MAX_VALUE;
		}

		dp[1] = 0;
		for (int j = 1; j < n; j++) {
			for (int a = 1; a <= k; a++) {
				if (j + a <= n) {
					dp[j + a] = Math.min(dp[j + a], dp[j] + Math.abs(h[j] - h[j + a]));
				}
			}
		}

		System.out.println(dp[n]);

	}
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int N, M, K;
int calc(int i, int j) { 
    int ret = 0;
    ret += i * M;
    ret += j * N;
    ret -= 2 * j * i;
    return ret;
}
int main() {
    cin >> N >> M >> K;

    string ans = "No";
    rep(i, N + 1) rep(j, M + 1) if (calc(i, j) == K) {
        // cout << i << ", " << j << endl;
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}


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

typedef struct {
  int ban[3*3], sp, MD, p[3][3];  
}Record;

void IDA(Record); 
int Manhat(Record);
int dfs(int, int);

int cnt = 0, ans[3][3], size, limit, stack[3], time, path[100];
int dx[4] = {0, -1, 0, 1}; 
int dy[4] = {1, 0, -1, 0};
int MDT[3*3][3*3];
char dir[4] = {'r','u','l','d'}; 
char an[100];
Record data, in;

int main () {
  int i, j, k = 0, m = 0, l = 0;


  for(i = 0 ; i < 3*3 ; i++) {
    for(j = 0 ; j < 3*3 ; j++) {
      m = i / 3 - j / 3;
      l = i % 3 - j % 3;

      if(m < 0) m = -1 * m;
      if(l < 0) l = -1 * l;
      MDT[i][j] = m + l;
    }
  }

  for(i = 0 ; i < 3*3 ; i++) {
      scanf("%d",&in.ban[i]);

      if(in.ban[i] == 0) {
	in.ban[i] = 3*3;
	in.sp = i;
}
}

  IDA(in);
 
  printf("%d\n",strlen(an));

  return 0;
}

int Manhat(Record A) {
  int d = 0, i;
  
  for(i = 0 ; i < 3 * 3 ; i++) {
    if(A.ban[i] == 3*3) continue;
    d += MDT[i][A.ban[i]-1];
  }

  return d;
}

int dfs(int def, int prev) {
  int sx = 0, sy = 0, i, j, tx = 0, ty = 0, max = 0, min = 0, t1;
  Record tmp;

  if(data.MD == 0) return 1;

  if(def + data.MD > limit) return -1;

  sx = data.sp / 3;
  sy = data.sp % 3;

  for(i = 0 ; i < 4 ; i++) {
    tx = sx + dx[i];
    ty = sy + dy[i];

    if(tx < 0 || ty < 0 || tx >= 3 || ty >= 3) continue;

    if(prev > i) {
      max = prev;
      min = i;
    }

    else {
      max = i;
      min = prev;
    }

    if(max - min == 2) continue;

    tmp = data;
    data.MD -= MDT[tx * 3 + ty][data.ban[tx * 3 + ty]-1]; 
    data.MD += MDT[sx * 3 + sy][data.ban[tx * 3 + ty]-1];
    t1 = data.ban[tx * 3 + ty];
    data.ban[tx * 3 + ty] = data.ban[sx * 3 + sy];
    data.ban[sx * 3 + sy] = t1;

    data.sp = tx * 3 + ty;

    if(dfs(def + 1, i) == 1) {
      path[def] = i;
      return 1;
    }

    data = tmp;
  }
  
  return -1;
}


void IDA(Record A) {
  int i, cnt = 0, j = 0;
  
  in.MD = Manhat(in);

  for(limit = in.MD ; limit <= 100 ; limit++) {
    data = in;

    if(dfs(0, -100) == 1) {
      for(i = 0 ; i < limit ; i++) {
   
	an[j] = dir[path[i]];
	j++;
      }
      an[j] = '\0';
      return;
    }
  }
}




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

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    int ans = k;
    for( int i = 2; i <= n; i ++ )
        ans *= ( k - 1 );
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256