akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(str(input()))
ans = 0
for i in range(len(t)):
    #print(i)
    if i >= k:
        if t[i] == t[i-k]:
            t[i] = '0'
            continue
    if t[i] == 'r':
        ans += p
    elif t[i] == 's':
        ans += r
    elif t[i] == 'p':
        ans += s
print(ans)

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

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
    string s; cin >> s;
    string ans = "";
    forn(i,19) {
        if(i == 5 || i == 13) {ans += " "; continue;}
        ans += s[i];
        // cout << ans << endl;
    }
    cout << ans;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	int n;
	while(cin>> n){
		int cnt=0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if(i+j+k+l == n){
							cnt++;
						}
					}
				}
			}
		}
		cout<< cnt<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pii make_pair
int ceil(int a, int b) { if(a%b==0) return a/b; else return a/b+1; }
vector<pair<int, int> >adj[100005];
int mp[100005];
int vis[100005], dep[100005];

void dfs(int node)
{
    //cout<<node<<endl;
    vis[node]=1;
    for(int i=0; i<adj[node].size(); i++) {
        int chl=adj[node][i].first;
        int len=adj[node][i].second;
        if(vis[chl]) continue;
        dep[chl]=dep[node]+len;
        if(dep[chl]%2==0) mp[chl]=1;
        else mp[chl]=0;
        dfs(chl);
    }
}

main()
{
    //fastio;
    int n, x, y, z;
    cin>>n;
    for(int i=0; i<n-1; i++) {
        cin>>x>>y>>z;
        adj[x].push_back(pii(y, z));
        adj[y].push_back(pii(x, z));
    }
    if(n==1) {
        cout<<"1";
        return 0;
    }
    memset(vis, 0, sizeof(vis));
    memset(dep, 0, sizeof(dep));
    for(int i=1; i<=n; i++) {
        if(adj[i].size()==1) {
            mp[i]=1;
            dfs(i);
            break;
        }
    }
    for(int i=1; i<=n; i++) cout<<mp[i]<<endl;
}


Measured memory_bytes: 18148
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	fmt.Println(calcMaximumProfit(elems))
}

func calcMaximumProfit(elems []int) int {
	profit := elems[1] - elems[0]
	var min int
	if elems[1] > elems[0] {
		min = elems[0]
	} else {
		min = elems[1]
	}
	for i := 2; i < len(elems); i++ {
		if elems[i]-min > profit {
			profit = elems[i] - min
		}
		if elems[i] < min {
			min = elems[i]
		}
	}
	return profit
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	rs := make([]int, n)
	for i, _ := range rs {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		rs[i] = x
	}
	return rs, nil
}



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

using namespace std;

typedef long long ll;

const int M = 1e9 + 7;

int add(int a, int b)
{
    return ((ll) a + b) % M;
}

int mul(int a, int b)
{
    return (a * (ll) b) % M;
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    int n, m;
    scanf("%d%d", &n, &m);
    vector <int> x(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
    }
    vector <int> y(m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &y[i]);
    }
    int sum = 0;
    for (int i = 1; i < m; i++)
    {
        sum = add(sum, mul(y[i] - y[i - 1], mul(i, m - i)));
    }
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans = add(ans, mul(x[i] - x[i - 1], mul(sum, mul(i, n - i))));
    }
    cout << ans << '\n';
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int count = 0;
    bool able = false;
    for(int i = 0; i <= N / 7; i++){
        if((N - i * 7) % 4 == 0){
            able = true;
            break;
        }
    }
    if(able == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = Integer.parseInt(s.substring(0, 1));
		int b = Integer.parseInt(s.substring(1, 2));
		int c = Integer.parseInt(s.substring(2, 3));
		int d = Integer.parseInt(s.substring(3, 4));

		for(int i = 0 ; i < 1 << 3 ; i++) {
			StringBuilder sb = new StringBuilder();
			sb.append(a);
			int result = a;
			if((1 & i) == 1) {
				sb.append("+");
				result += b;
			} else {
				sb.append("-");
				result -= b;
			}
			sb.append(b);
			if((1 & i >> 1) == 1) {
				sb.append("+");
				result += c;
			} else {
				sb.append("-");
				result -= c;
			}
			sb.append(c);
			if((1 & i >> 2) == 1) {
				sb.append("+");
				result += d;
			} else {
				sb.append("-");
				result -= d;
			}
			sb.append(d);
			if(result == 7) {
				sb.append("=7");
				System.out.println(sb.toString());
				sc.close();
				return;
			}
		}
//		System.out.println();

		sc.close();

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int main()
{
    int K,X;
    cin>>K>>X;
    for(int i = X - K+1;i<X + K;i++){
        log(i);
    }
}


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

using namespace std;

int a, b, c, k;

int main(){
	scanf("%d%d%d%d", &a, &b, &c, &k);
	int cnt = 0;
	while(b <= a) b *= 2, cnt++;
	while(c <= b) c *= 2, cnt++;
	printf(cnt <= k ? "Yes" : "No");
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> b(n - 1);
  for(int i = 0; i < n - 1; i++){
    cin >> b[i];
  }
  int sum = b[0];
  for(int i = 0; i < n - 2; i++){
    sum += min(b[i], b[i + 1]);
  }
  sum += b[n - 2];
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0;

int32_t main()
{
	IOS
	int n;cin>>n;
	vector<vector<int>>A(3,vector<int>(n+1)),dp(3,vector<int>(n+1));
	
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>A[j][i];
		}
	}
	
	for(int i=0;i<3;i++)
	{
		dp[i][1]=A[i][1];
	}
	
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[j][i+1]=max( dp[(j+1)%3][i]+A[j][i+1] , dp[(j+2)%3][i]+A[j][i+1]);
		}
	}
	cout<<max({dp[0][n],dp[1][n],dp[2][n]})<<endl;
	
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 5752
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n, m;
    cin >> n >> m;
    vb r(n), w(n, 1);
    vi cnt(n, 1);
    w[0] = 0;
    r[0] = 1;
    forn(i, m){
        int x, y;
        cin >> x >> y;
        x--, y--;
        cnt[x]--, cnt[y]++;
        if (r[x]) r[y] = 1;
        if (w[x]) w[y] = 1;
        if (cnt[x] == 0){
            r[x] = w[x] = 0;
        }
    }
    int ans = 0;
    forn(i, n){
        if (r[i]) ans++;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	
	ll n;cin>>n;
	ll ans;
	if(n&1)ans=n/2;
	else ans=n/2-1;
	cout<<ans;
	
	return 0;
}



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

int main() {
  vector<int> a(5);
  for(int i=0; i<5; i++) cin >> a[i];
  int ans = 0;
  for(int i=0; i<5; i++){
    if(a[i] == 0) ans += i+1;
  }
  
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t, x;
  cin >> t >> x;
  cout << setprecision(10) << fixed << (double)t / x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/


int main() {
  int N,ans=0,mi=2*1e5+1;
  scanf("%d",&N);
  int p;
  REP(i,N) {
    scanf("%d",&p);
    if (p<mi) {
      ans++;mi = p;
    }
    }
  printf("%d",ans);
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans{1};
  char prev{S[0]};
  for (int i{1}; i < N; ++i) {
    if (prev != S[i]) {
      ++ans;
      prev = S[i];
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = 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")
}

fn main() {
    let s: String = read();
    let t: String = read();
    println!("{}{}", t, s);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
 
int n,m;
vector<vector<int>>g;
vector<int>dp;

int dfs(int v){
    if(dp[v]>=0)return dp[v];
    int res=0;
    for(auto x:g[v]){
        res=max(res,dfs(x)+1);
        //自分から出ているものから最長を選んでいく
    }
    return dp[v]=res;
}

void solve(){
    n,m;
    cin>>n>>m;
    g.resize(n);
    dp.resize(n,-1);
    int x,y;
    rep(i,m){
        cin>>x>>y;
        x--;y--;
        g[x].pb(y);
    }
    int ans=0;
    rep(i,n)chmax(ans,dfs(i));
    cout<<ans<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

void Main()
{
  ll a, b, c, d; cin >> a >> b >> c >> d;
  for(ll i = 0;;i++)
  {
    if(i % 2 == 0)
    {
      c -= b;
      if(c <= 0) fin("Yes");
    }
    else
    {
      a -= d;
      if(a <= 0) fin("No");
    }
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 3676
s,t = map(str, [input() for i in range(2)])

S = [s[i] for i in range(len(s))]
T = [t[i] for i in range(len(t))]


def XY(x, y):
    x.sort()
    y.sort(reverse=True)
    c = 0
    D = True
    while c < len(x) and c < len(y):
        if x[c] < y[c]:
            break
        elif x[c] == y[c]:
            c += 1
        elif x[c] > y[c]:
            D = False
            break
        if len(x) >= len(y) and c == len(y)-1 and x[c] >= y[c]:
            D = False


    return D

Result = XY(S, T)

if Result:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
H, W, K = gets.split.map(&:to_i)
src = ''
masks = []
H.times { src.concat(gets.strip) }
v = src.tr('.#','01').to_i(2)

(1 << H).times do |row|
  (1 << W).times do |col|
    mask = 0
    H.times do |y|
      mask <<= W
      mask += if (((row >> y) & 1) == 1) then col else 0 end
    end
    masks << mask
  end
end

ans = 0
masks.uniq.each do |m|
  bits = 0
  c = (v & m)
  while c > 0 do
    bits += (c & 1)
    c >>= 1
  end
  ans += 1 if bits == K
end
puts ans

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

using namespace std;
//static const int INF = 1 << 25; 戒め
static const long long INF = ((long long) 1) << 60;

struct edge
{
	long long to, cost;
	edge(long long t, long long  c){
		to = t;
		cost = c;
	}
};
typedef pair<int, long long> P;

long long  V, E;
vector<edge> G[100000];
long long d[100000];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while(que.size()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	int r;
	scanf("%d %d %d", &V, &E, &r);
	for(int i = 0; i < E; i++){
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);
		G[s].push_back(edge(t, d));
	}
	dijkstra(r);
	int ans = 0;
	for(int i = 0; i < V; i++){
		if(d[i] != INF){
			printf("%d\n", d[i]);
		}
		else{
			printf("INF\n");
		}
	}
	return 0;
}

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

int main(void) {
	int i, max, p = 0;
	scanf("%d", &max);
	int *A = malloc(sizeof(int) * max);
	for (i = 0; i < max; i++) {
		int c1, c2;
		scanf("%d", &c1);
		switch(c1) {
			case 0:
				scanf("%d", &c2);
				A[p] = c2;
				p++;
				break;
			case 1:
				scanf("%d", &c2);
				printf("%d\n", A[c2]);
				break;
			case 2:
				p--;
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 2524
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool check(string str){
	vector<int> is, ws;
	int n = str.length();
	for(int i=0; i<n; i++){
		if(str[i]=='i') is.push_back(i);
		if(str[i]=='w') ws.push_back(i);
	}
	if((int)is.size()!=2 || (int)ws.size()!=1) return false;
	return (is[0]==ws[0]-1 && is[0]==is[1]-2);
}

bool isPalin(string str){
	int n = str.length();
	for(int i=0; i<n; i++){
		if(str[i]=='(' && str[n-1-i]!=')') return false;
		if(str[i]=='{' && str[n-1-i]!='}') return false;
		if(str[i]=='[' && str[n-1-i]!=']') return false;
		if(str[i]=='i' && str[n-1-i]!='i') return false;
		if(str[i]=='w' && str[n-1-i]!='w') return false;
		if(str[i]==')' && str[n-1-i]!='(') return false;
		if(str[i]=='}' && str[n-1-i]!='{') return false;
		if(str[i]==']' && str[n-1-i]!='[') return false;
	}
	return true;
}

int main(){
	char buf[20];
	int ret = 0;
	scanf("%s", buf);
	int n = strlen(buf);
	for(int m=0; m<(1<<n); m++){
		string s = "";
		for(int i=0; i<n; i++)if((m>>i)&1){
			s += buf[i];
		}
		if(check(s) && isPalin(s)){
			ret = max(ret, (int)s.length());
		}
	}

	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 792
n = gets.to_i

x = []

(1..n).each do |i|
  if (i % 3 == 0) && ( i % 5 == 0 )
     x << "FizzBuzz"

  elsif (i % 3 == 0)
    x << "Fizz"

  elsif (i % 5 == 0)
    x << "Buzz"

  else
    x << i
  end
end


sum = 0

x.each do |k|
  if k.is_a?(Integer)
  sum += k
  end
end

puts sum

Measured memory_bytes: 41560
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;


int main() {

    int n;
    string s;

    cin >> n;
    cin >> s;

    vector<int> sint(n);

    for(int i = 0; i < n; ++i) {
        
        switch(s[i]) {
            case 'R':
                sint[i] = 0;
                break;
            case 'G':
                sint[i] = 1;
                break;
            case 'B':
                sint[i] = 2;
                break;
        }

    }

    vector<vector<int>> Count(3, vector<int>(n, 0));


    Count[sint[0]][0]++;

    for(int i = 1; i < n; ++i) {

        if(sint[i] == 0)
            Count[0][i]++;
        else if(sint[i] == 1)
            Count[1][i]++;
        else 
            Count[2][i]++;

        Count[0][i] += Count[0][i - 1];
        Count[1][i] += Count[1][i - 1];
        Count[2][i] += Count[2][i - 1];

    }

    long long sum = 0;

    for(int i = 0; i < n - 2; ++i) {
        for(int j = i + 1; j < n - 1; ++j) {

            if(sint[i] == sint[j])
                continue;

            int color = 3 - sint[i] - sint[j];
            sum += Count[color][n - 1] - Count[color][j];

            int k = 2 * j - i;
            if(k < n && sint[k] == color)
                sum--;


        }
    }

   // cout << endl;
    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 3644
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <cstdio>
#include <cstdint>
#include <cmath>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ld INF_F = std::numeric_limits<float>::infinity();
constexpr ld PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S[1] = 'R' ^ S[1] ^ 'B';
    cout << S;

    return 0;
}

Measured memory_bytes: 3140
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let s = get!(String; n);

    let mut map = BTreeMap::new();
    for e in s {
        *map.entry(e).or_insert(0) += 1;
    }
    let mut mx = 0;
    for (k,&v) in &map {
        mx = max!(mx,v);
    }

    for (k,v) in map {
        if mx == v {
            println!("{}", k);
        }
    }
}


Measured memory_bytes: 28924
n = int(input())
a = list(map(int, input().split()))

a.sort()

large = max(a)
a.remove(large)
min_list = [0, large/2]
for i in a:
    if abs(i - large/2) < min_list[1]:
        min_list = [i, abs(i - large/2)]

print(large, min_list[0])


Measured memory_bytes: 14052
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#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(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<ll> cnt(246913, 0);
	vector<bool> p(246913, true);
	FOR(i, 2, 246913) {
		if(p[i]) {
			cnt[i] = cnt[i - 1] + 1;
			for(ll j = 1; i * j <= 246912; ++j) {
				p[i * j] = false;
			}
		} else {
			cnt[i] = cnt[i - 1];
		}
	}
	while(true) {
		int n;
		cin>>n;
		if(n == 0)break;
		cout<<cnt[2 * n] - cnt[n]<<endl;
	}
}

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

void f(long long x, long long &ans) {
  if (x == 1) {
    ans += 1;
    return;
  }
  f(x / 2, ans);
  ans *= 2;
  ans += 1;
  return;
}
   
int main() {
  long long h;
  cin >> h;
  long long ans = 0;
  
  f(h, ans);
  cout << ans << endl;
}  

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    double x1,x2,y1,y2,dx,dy;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    dx=x2-x1;
    dy=y2-y1;
    printf("%lf\n",sqrt(dx*dx+dy*dy));
}



Measured memory_bytes: 2708
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>

typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;

const double EPS = 1e-8;

int main()
{
	char S[2000000];

	cin >> S;

	int a=0,z=0;
	bool af=0;

	for(int i=0;i<strlen(S);i++){
		if(S[i]=='A'&&af==0){ a=i;af=1;};
		if(S[i]=='Z') z=i;
	}

	cout << z-a+1<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

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

        int n = sc.nextInt();

        String str = sc.nextLine();
        int[] num = new int[n];
        for(int i = 0;i < n;i++){
            num[i] = sc.nextInt();
        } 

        int tmp,j;
        for(int i = 0;i < n;i++){
            tmp = num[i];
            j = i - 1;
            while(j >= 0 && num[j] > tmp){
                num[j + 1] = num[j];
                j--;
                num[j + 1] = tmp;
            }
            for(int k = 0;k < n;k++){
                if(k != 0)  System.out.print(" ");
                System.out.print(num[k]);
            }
            System.out.println("");
        }
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int S;
const ll mo=1000000007;
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	ll ret=0;
	for(i=0;3*i<=S;i++) {
		x=S-3*i;
		ret+=hcomb(i,x);
	}
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 13020
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;


int main(){
    int m,d;
    cin>>m>>d;
    int n = 0;
    for(int i=1;i<=m;i++){
        for(int j=22;j<=d;j++){
            int one = j%10;
            int ten = j/10;
            if(one>=2 && ten>=2){
                if(one*ten==i){
                    n++;
                }
            }
        }
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int main() {
    int n, q;
    cin >> n >> q;
    int x = 0;
    VI a(n);
    a[0] = a[1] = 1;
    while (q--){
        int s, t;
        scanf("%d %d", &s, &t);
        s--;
        t--;
        swap(a[s], a[t]);
        if (x == s) x = t;
        else if (x == t) x = s;

        if (x > 0) a[x-1] = 1;
        if (x < n-1) a[x+1] = 1;
    }

    int ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  long K, A, B;
  cin >> K >> A >> B;

  long bisket = 1;

  if (K <= A) {
    cout << K + 1 << endl;
    return 0;
  }

  if (B - A < 2) {
    cout << K + 1 << endl;
    return 0;
  }

  bisket += A - 1;
  K -= A - 1;

  bisket += (K / 2) * (B - A) + (K % 2);

  cout << bisket << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll x;
    cin >> x;
    cout << 10 - x / 200 << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
map<ll, ll> m;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  ll ans = 0, res;
  for (auto p : m) {
    res = abs(p.first - p.second);
    if (p.first > p.second || N <= res) {
      ans += p.second;
    } else {
      ans += res;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10016
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum = 0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
        sum += a[i];
    }


    ll ans = 0;
    for(ll i=0;i<n;++i){
        sum -= a[i];
        ans += (sum % MOD) * a[i] % MOD;
        ans %= MOD;
    }
    ans %= MOD;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6424
<?php
$ppl = array();
while(fscanf(STDIN,"%d %d\n",$n,$p)){
    if($n==0 && $p==0)
        break;
    $ppl = array_fill(0, $n, 0);
    $bowl=$p;
    while(1){
        for($i=0;$i<$n;$i++){
            if($bowl>0){
                $ppl[$i]++;
                $bowl--;
            }
            else{
                $bowl=$ppl[$i];
                $ppl[$i]=0;
            }
            if($ppl[$i]==$p){
                echo $i."\n";
                break 2;
            }  
        }
    }
}
?>

Measured memory_bytes: 6600
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> data(10, vector<int>(10));
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> data[i][j];
		}
	}
	//わーしゃるふろいど
	for (int k = 0; k < 10; ++k) {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				data[i][j] = min(data[i][j], data[i][k] + data[k][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int num;
			cin >> num;
			if (-1 != num) {
				ans += data[num][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3556
while True:
    try:
        a,b,c,d,e,f=map(int,input().split())
        m=b*d-e*a
        x=-(c*e-f*b)/m
        y=(c*d-f*a)/m
        if x==0:
            x=abs(x)
        if y==0:
            y=abs(y)
        print("{:.3f} {:.3f}" .format(x,y))
        
    except:
        break


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

struct edge {
    int to, cost;
};

int main() {
    int n;
    cin >> n;
    vector<vector<edge> > G(n);
    rep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge e;
        e.to = b;
        e.cost = c;
        G[a].push_back(e);
        e.to = a;
        G[b].push_back(e);
    }

    vector<int> ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i, sz(G[v])) {
            int u = G[v][i].to;
            int w = G[v][i].cost;
            if (ans[u] != -1) continue;
            ans[u] = (ans[v]+w)%2;
            q.push(u);
        }
    }

    rep(i, n) {
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 6784
// ?????±???????????????????????? 2015-1
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
int main(){
  int a[4],b[2];
  for(int i=0;i<4;i++) scanf("%d",a+i);
  for(int i=0;i<2;i++) scanf("%d",b+i);
  sort(a,a+4);
  sort(b,b+2);
  int ans = 0;
  for(int i=3;i>0;i--) ans+=a[i];
  ans+=b[1];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2676
M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d10 = d // 10 % 10
        d1 = d % 10
        if d1 >= 2 and d10 >= 2:
            if m == d1 * d10:
                ans += 1

print(ans)

Measured memory_bytes: 9184
#include <stdio.h>

int main(void){
    int a = 0, b = 0, N = 0, flag = 0;
    int s[100] = {}, f[100] = {};
    scanf("%d %d", &a, &b); scanf("%d", &N);
    for(int w = 1; w <= N; w++){
        scanf("%d %d", &s[w], &f[w]);
        if( a > s[w] && a < f[w] ){ flag = 1; } else if( b > s[w] && b < f[w] ){ flag = 1; } else if( a == s[w] && b == f[w] ){ flag = 1; } else if( a < s[w] && b > f[w] ){ flag = 1; }
    }
    if( flag == 1 ){ printf("1\n"); } else { printf("0\n"); }
    return 0;
}


Measured memory_bytes: 2148
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b;
	sum = a + b;
	if (sum % 3 != 0) {
		if (a % 3 != 0) {
			if (b % 3 != 0) {
				cout << "Impossible" << rt;
				cnt++;
			}
		}
	}
	if (cnt != 1)cout << "Possible" << rt;
	please AC;
}

Measured memory_bytes: 256
N = int(input())
work = []
for i in range(N):
    work.append(list(map(int, input().split())))
work.sort(key=lambda x:x[0])
work.sort(key=lambda x:x[1])

time = 0

for A, B in work:
    time += A
    if time > B:
        print("No")
        break
        
else:
    print("Yes")

Measured memory_bytes: 53612
import math


def resolve():
    import sys
    input = sys.stdin.readline
    a = []
    a1 = [int(x) for x in input().rstrip().split(" ")]
    a2 = [int(x) for x in input().rstrip().split(" ")]
    a3 = [int(x) for x in input().rstrip().split(" ")]


    a += a1 + a2 + a3

    opened = set()

    n = int(input().rstrip())
    for _ in range(n):
        b = int(input().rstrip())
        if b in a:
            opened.add(a.index(b))

    # 判定
    if all([x in opened for x in {0,3,6}]) or all([x in opened for x in {1,4,7}]) or all([x in opened for x in {2,5,8}]):
        print("Yes")
    elif all([x in opened for x in {0,1,2}]) or all([x in opened for x in {3,4,5}]) or all([x in opened for x in {6,7,8}]):
        print("Yes")
    elif all([x in opened for x in {0,4,8}]) or all([x in opened for x in {2,4,6}]):
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9292
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		int data;
		for( int i=1; ; i++ ) {
			data=kb.nextInt();
			if( 0 != data ) {
				System.out.println( "Case "+i+": "+data );
			} else {
				break;
			}
		}
	}
}

Measured memory_bytes: 33080
#include <bits/stdc++.h>
const int maxn=1e5+7;
using namespace std;
map<int,int>mp;
int main(){
    int s[maxn];
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&s[i]);
    }
    for(int i=1;i<=n;i++){
        if(s[i]==i) {
                ans++;
        s[i+1]=s[i];
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640