akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int A = 8;

int count (int x, int y, char mark, char fld[][12]) {
    static int dx[A] = {1, 1, 0, -1, -1, -1, 0, 1};
    static int dy[A] = {0, 1, 1, 1, 0, -1, -1, -1};
    int ret = 0;
    for(int i = 0; i < A; ++i) {
        int xx = x + dx[i];
        int yy = y + dy[i];
        while(0 <= xx && xx < A && 0 <= yy && yy < A) { 
            if(fld[xx][yy] == '.' || fld[xx][yy] == mark) break;
            xx += dx[i];
            yy += dy[i];
        }
        if(0 <= xx && xx < A && 0 <= yy && yy < A &&
                fld[xx][yy] == mark) { 
            ret += max(abs(x - xx), abs(y - yy)) - 1;
        }
    }
    return ret;
}

void set_cookie(int x, int y, char mark, char fld[][12]) {
    fld[x][y] = mark;
    static int dx[A] = {1, 1, 0, -1, -1, -1, 0, 1};
    static int dy[A] = {0, 1, 1, 1, 0, -1, -1, -1};
    for(int i = 0; i < A; ++i) {
        int xx = x + dx[i];
        int yy = y + dy[i];
        while(0 <= xx && xx < A && 0 <= yy && yy < A) { 
            if(fld[xx][yy] == '.' || fld[xx][yy] == mark) break;
            xx += dx[i];
            yy += dy[i];
        }
        if(0 <= xx && xx < A && 0 <= yy && yy < A &&
                fld[xx][yy] == mark) { 
            for(int m = x + dx[i], n = y + dy[i]; m != xx || n != yy;
                    m += dx[i], n += dy[i]) {
                fld[m][n] = mark;
            }
        }
    }
}

int main() {
    char fld[8][12];
    for (int i = 0; i < A; ++i) {
        scanf("%s", fld[i]);
    }
    int v_mami, x_mami, y_mami;
    int v_witch, x_witch, y_witch;
    int t;
    while(true) {
        v_mami = 0;
        v_witch = 0;
        for(int i = 0; i < A; ++i) {
            for(int j = 0; j < A; ++j) {
                if(fld[i][j] == '.') {
                    t = count(i, j, 'o', fld);
                    if(v_mami < t) {
                        x_mami = i;
                        y_mami = j;
                        v_mami = t;
                    }
                }
            }
        }
        if(v_mami > 0) {
            set_cookie(x_mami, y_mami, 'o', fld);
        }
        for(int i = 0; i < A; ++i) {
            for(int j = 0; j < A; ++j) {
                if(fld[i][j] == '.') {
                    t = count(i, j, 'x', fld);
                    if(v_witch <= t) {
                        x_witch = i;
                        y_witch = j;
                        v_witch = t;
                    }
                }
            }
        }
        if(v_witch > 0) {
            set_cookie(x_witch, y_witch, 'x', fld);
        }
        if(v_mami == 0 && v_witch == 0) {
            break;
        }
    }
    for(int i = 0; i < A; ++i) {
        printf("%s\n", fld[i]);
    }
    return 0;
}

Measured memory_bytes: 1112
# Aizu Problem ALDS_1_3_B: Queue
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N, quantum = [int(_) for _ in input().split()]
queue = []
for _ in range(N):
    name, length = input().split()
    queue.append([name, int(length)])

time = 0
while len(queue) > 0:
    name, length = queue.pop(0)
    if length > quantum:
        time += quantum
        queue.append([name, length - quantum])
    else:
        time += length
        print(name, time)

Measured memory_bytes: 15912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615


int main(){
  int n,k; cin>>n>>k;
  vector<ll> h(n);
  rep(i,n) cin>>h.at(i);
  ll ans=0;
  
  sort(h.begin(), h.end());
  
  rep(i,n-k){
    ans+=h.at(i);
  }
  cout<<ans;

}

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

using LL = long long;
using pii = pair<int, int>;
const int maxn = 100100;
int n, m;
pii p[maxn];

signed main() {
  // freopen("in", "r", stdin);
  while(~scanf("%d%d",&n,&m)) {
    for(int i = 1; i <= m; i++) {
      scanf("%d%d",&p[i].first,&p[i].second);
      if(p[i].first > p[i].second) swap(p[i].first, p[i].second);
    }
    sort(p+1, p+m+1, [](pii x, pii y){
      if(x.second != y.second) return x.second < y.second;
      return x.first < y.first;
    });
    int tot = 1;
    int pre = p[1].second;
    for(int i = 2; i <= m; i++) {
      if(pre > p[i].first) continue;
      else {
        tot++;
        pre = p[i].second;
      }
    }
    printf("%d\n", tot);
  }
  return 0;
}


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

int cal[20000];

int main() {
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        cal[d]++;
    }
    int h = 0, rem = 0;
    double ans = 0;
    for (int cur = 1; cur <= l; cur++) {
        if (rem > 0) {
            rem--;
            ans += 1.0 / v;
        } else {
            ans += 1.0 / u;
        }
        if (h > 0 && rem == 0) {
            h--;
            rem = v * t;
        }
        if (cal[cur]) {
            if (rem == 0) {
                rem = v * t;
            } else {
                if (h + cal[cur] > k) {
                    h = k;
                    rem = v * t;
                } else {
                    h += cal[cur];
                }
            }
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 3308
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n, m; cin >> n >> m;
  int a[31] = {};
  REP(i, n) {
    int k; cin >> k;
    REP(l, k) {
      int t; cin >> t;
      a[t]++;
    }
  }
  int ans = 0;
  REP(i, m + 1) {
    if (a[i] == n) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

int n;
vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double>(310, -1)));


double dfs(int a, int b, int c) {
    if (dp[a][b][c] >= 0) return dp[a][b][c];

    double res = 0;
    if (a) res += dfs(a - 1, b, c) * a;
    if (b) res += dfs(a + 1, b - 1, c) * b;
    if (c) res += dfs(a, b + 1, c - 1) * c;
    res += n;
    res /= a + b + c;
    return dp[a][b][c] = res;
}

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

    cin>>n;
    vector<int> cnt(3);
    rep(i, n) {
        int a;
        cin>>a; a--;
        cnt[a]++;
    }

    dp[0][0][0] = 0;
    double ans = dfs(cnt[0], cnt[1], cnt[2]);
    printf("%.10f\n", ans);
}

Measured memory_bytes: 237568
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll s, w;

int main() {
	cin >> s >> w;
	if (s > w) {
		cout << "safe" << endl;
	}
	else {
		cout << "unsafe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;
const ll MOD = 1000000007ll;

ll n, k, v1, v2, ans;
vector<vector<ll>> G;

void dfs(int v, int p) {
    int cur = 0;

    for (int c : G[v]) {
        if (c != p) {
            ans = (ans * (k - 1 - cur - (p != -1))) % MOD;
            dfs(c, v);
            cur++;
        }
    }
}

int main() {
    scanf("%lld%lld", &n, &k);

    G.resize(n);

    for (int i = 0; i < n - 1; i++) {
        scanf("%lld%lld", &v1, &v2);
        G[v1 - 1].push_back(v2 - 1);
        G[v2 - 1].push_back(v1 - 1);
    }

    ans = k;

    dfs(0, -1);

    printf("%lld\n", ans);

    return 0;
}

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

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

#define endl '\n'
#define len(x) (int)x.size()
#define rep(a, b, i) for (int i = a; i < b; i++)
#define repi(a, b, i) for (int i = a; i > b; i--)
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define binary_search
#define mem(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define __                                                                                                             \
    ios_base::sync_with_stdio(false);                                                                                  \
    cin.tie(0);                                                                              
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const ld PI = 3.141592653589793;
const int MAXN = 1e5 + 5;

int32_t main() {
    __;

	int n, m;
	cin >> n >> m;
	vi a(n);
	for (int &x : a) cin >> x;
	
	sort(allr(a));
	int t = accumulate(all(a), 0);
	
	for (int i = 0; i < m; i++) {
		if (4*m*a[i] < t) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";

    return 0;
}


















Measured memory_bytes: 256
N = gets.to_i
XYs = $<.map{|s|
  s.split.map &:to_i
}

fs = [->x,y{x + y}, ->x,y{x - y}, ->x,y{-x + y}, ->x,y{-x - y}]

p fs.map{|f|
  min, max = XYs.map{|x, y|f[x, y]}.minmax
  max - min
}.max

Measured memory_bytes: 33044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRingosFavoriteNumbers solver = new BRingosFavoriteNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRingosFavoriteNumbers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int D = in.nextInt();
            int N = in.nextInt();

            int res = solve(D, N);
            out.println(res);


        }

        private int solve(int d, int n) {
            if (n == 100)
                n = 101;
            if (d == 0) {
                return n;
            }
            if (d == 1) {
                return n * 100;
            }
            if (d == 2)
                return n * 10000;
            throw new RuntimeException("!");
        }

    }
}



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

ll a[100010];
ll b[100010];
ll as[100010];
ll bs[100010];

ll sum(int l, int r, ll* s) {
	return s[r] - s[l];
}

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

	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		b[i] = max(0LL, a[i]);
		as[i + 1] = as[i] + a[i];
		bs[i + 1] = bs[i] + b[i];
	}

	ll ans = 0;
	for(int i = 0; i < N - K + 1; i++) {
		ll l = sum(0, i, bs);
		ll c = max(0LL, sum(i, i + K, as));
		ll r = sum(i + K, N, bs);
		ans = max(ans, l + c + r);
	}
	cout << ans << endl;
}

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


int main(){
    int x,y,z;
    cin >> x >> y >> z;
    map<int,int> result_map;
    result_map[x] = result_map[x]+1;
    result_map[y] = result_map[y]+1;
    result_map[z] = result_map[z]+1;
    if(result_map.size() == 2) cout << "Yes";
    else cout << "No";


}

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

ryuka = [0]*87
ryuka[0] = 2
ryuka[1] = 1

def culc_ryuka(N, ryuka):
    for i in range(2, N+1):
        ryuka[i] = ryuka[i-1]+ryuka[i-2]
        
    return ryuka

ryuka = culc_ryuka(N, ryuka)
print(ryuka[N])
    

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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef		long double							 ld;
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<ld>                           vld;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(18);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

int main(){
	flash; QuickSilver;
	int n; cin>>n;
	vld p(n); get(p);
	vld v(n+1, 1);
	rep(i,0,n) rep(j,i+2,0)
		if(j==0) v[j]*=(1-p[i]);
		else if(j==i+1) v[j]=v[j-1]*p[i];
		else v[j]=v[j]*(1-p[i])+v[j-1]*p[i];
	ld ans=0; rep(i,(n+1)>>1,n+1) ans+=v[i];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		int x1=sc.nextInt();
		int y1=sc.nextInt();
		int x2=sc.nextInt();
		int y2=sc.nextInt();

		int x4=-y2+y1+x1;
		int y4=x2-x1+y1;
		int x3=x2+x4-x1;
		int y3=y2+y4-y1;
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}

Measured memory_bytes: 23508
N=int(input())
S=list(input())
RS=S[::-1]
#print(RS)
RSS=[]
F=0
W=0
R=0
for i in range(len(RS)):
    if F==0:
        if RS[i]=="R":
            RSS.append("R")
            R+=1
            F=1
    else:
        RSS.append(RS[i])
        if RS[i]=="R":
            R+=1
        else:
            W+=1

SS=RSS[::-1]
#print(SS,R,W)

LW=[]
LR=[]
for i in range(len(SS)):
    if SS[i]=="W":
        LW.append(i)
    else:
        LR.append(i)
LR=LR[::-1]


LW.append(10**7)
LR.append(-1)
#print(LW,LR)
for i in range(len(LR)):
    if LW[i]>LR[i]:
        cnt=i
        break
print(min(cnt,W,R))

Measured memory_bytes: 24840
K, N = map(int, input().split())
A = list(map(int, input().split()))
diff = [0] * N
for i in range(N-1):
    diff[i] = A[i+1] - A[i]
diff[N-1] = (K + A[0]) - A[N-1]
print(K - max(diff))


Measured memory_bytes: 25452
#include<stdio.h>
#define NUM 500000
void buildMaxHeap();
void maxHeapify(int);

int a[NUM],h;
int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }

  buildMaxHeap();

  for(i=1;i<=h;i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}

void buildMaxHeap(){
  int i;
  for(i=h/2;i>=1;i--){
    maxHeapify(i);
  }
}

void maxHeapify(int i){
  int l,r,largest,a1;
  l=2*i;
  r=2*i+1;
  if(l<=h&&a[l]>a[i]){
    largest=l;
  }else{
    largest=i;
  }
  if(r<=h&&a[r]>a[largest]){
    largest=r;
  }
  if(largest!=i){
    a1=a[i];
    a[i]=a[largest];
    a[largest]=a1;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

#define int long long

signed main(){
  int a,b;
  int x;
  cin >> a >> b;
  x = max(max(a+b,a+a-1),b+b-1);
  cout << x << endl;
}


Measured memory_bytes: 256
//最長共通部分列 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
//要は何枚のコインで支払えますか問題。

// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000019
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[2000][2000];
vector<int> w(2000);
vector<int> v(2000);

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0;
    int i;
    double h;
    int n,x,m=5;
    int a,b,d,c;
    //int e,weight;
    int target;
    //targetが目的値、nが個数
    //ll _=1;

    while(1){
        cin>>n;
        if(n==0) return 0;
        vector<vector<ll>> v(n,vector<ll> (m));
        vector<vector<ll>> f(n,vector<ll> (m));
        ll sum=0;
        //vector<vector<ll>> v(n,vector<ll> (m));
        rep(i,n)rep(j,m) {cin>>v[i][j];f[i][j]=0;}
        ll endf=0;
        while(!endf){
            endf=1;
            rep(i,n) rep(j,m) f[i][j]=0;
            for(ll i=0;i<n;i++) {
                for(ll j=0;j<m-2;j++){
                    if(v[i][j]==0) continue;
                    if(v[i][j]!=v[i][j+1]) continue;
                    if(v[i][j]!=v[i][j+2]) continue;
                    f[i][j]=1;
                    f[i][j+1]=1;
                    f[i][j+2]=1;
                }
            }
            for(ll i=0;i<n;i++) {
                for(ll j=0;j<m;j++){
                    if(f[i][j]==1) {
                        sum+=v[i][j];
                        v[i][j]=0;
                        endf=0;
                    }
                }
            }



            for(ll j=0;j<m;j++){
                ll takasa=n-1;
                for(ll i=n-1;i>=0;i--){
                    if(f[i][j]==0){
                        v[takasa][j]=v[i][j];
                        takasa--;
                    }
                }
                for(i=takasa;i>=0;i--){
                   v[i][j]=0;
                }
            }
            /*
            rep(i,n){
                rep(j,m){
                    cout<<v[i][j]<<" ";
                }
                    cout<<endl;
            }
            cout<<endl;
*/
        }
        cout<<sum<<endl;

    }

    return 0;
}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int units[] = {10, 50, 100, 500};

int change(int x) {
    int ret = 0;
    rrep(i, 4) {
        ret += x / units[i];
        x %= units[i];
    }
    return ret;
}

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

    int m;
    int flag = 0;
    while (cin >> m, m) {
        if (flag++ > 0) cout << endl;
    
        vector<int> v(4);
        int num_coin = 0;
        rep(i, 4) {
            cin >> v[i];
            num_coin += v[i];
        }

        int mi = 1e9;
        vector<int> ans(4);
        rep(i, v[0] + 1) {
            rep(j, v[1] + 1) {
                rep(k, v[2] + 1) {
                    rep(l, v[3] + 1) {
                        int payment = 10 * i + 50 * j + 100 * k + 500 * l;
                        if (payment < m) continue;
                        int rest = num_coin - i - j - k - l + change(payment - m);
                        if (mi > rest) {
                            mi = rest;
                            ans[0] = i;
                            ans[1] = j;
                            ans[2] = k;
                            ans[3] = l;
                        }
                    }
                }
            }
        }

        rep(i, 4) {
            if (ans[i] > 0) cout << units[i] << " " << ans[i] << endl;
        }
    }
}

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

using ll = long long;

int main(){	
	ios::sync_with_stdio(false);

  ll n;
  cin >> n;

  vector<ll> a1(n), a2(n);

  for(ll i=0; i<n; i++) cin >> a1[i];
  for(ll i=0; i<n; i++) cin >> a2[i];


  for(ll i=1; i<n; i++) a1[i] += a1[i-1];
  a2[0] += a1[0];
  for(ll i=1; i<n; i++) a2[i] += (a2[i-1] > a1[i] ? a2[i-1] : a1[i]);


  cout << a2[n-1] << endl;

}


Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

n = int(input())
x_list, y_list = [], []
for i in range(n):
    a, b = [ int(v) for v in input().split() ]
    x_list.append((a,b))
    y_list.append((b,a))
x_list.sort()
y_list.sort()

def swap(i):
    return (i[1],i[0])

def simplehash(i, r = 0):
    if r == 1:
        a, b = swap(i)
    else:
        a, b = i
    return a*10**10+b

x_node = [ ( (x_list[i+1][0] - x_list[i][0]), simplehash(x_list[i]), simplehash(x_list[i+1]) ) for i in range(n-1) ]
y_node = [ ( (y_list[i+1][0] - y_list[i][0]), simplehash(y_list[i],1), simplehash(y_list[i+1],1) ) for i in range(n-1) ]
node_set = set([])
for i in x_node:
    node_set.add(i[1])
    node_set.add(i[2])
node = list(sorted(node_set))
node_dic = { v : i for i, v in enumerate(node) }

x_list = [ (i[0], node_dic[i[1]], node_dic[i[2]] ) for i in x_node ]
y_list = [ (i[0], node_dic[i[1]], node_dic[i[2]] ) for i in y_node ]

connect_list = [ set([]) for i in range(n) ]
for i in x_list + y_list:
    c, a, b = i
    connect_list[a].add((c,b))
    connect_list[b].add((c,a))

def prim(in_connect_list,p,m):
    total_cost = 0
    connected_node = [ 0 for i in range(m) ]
    connected_node[p] = 1
    search_list = [p]
    search_heap = []
    while search_list != []:
        new_search_list = []
        for i in search_list:
            for c, k in connect_list[i]:
                if connected_node[k] == 0:
                    heapq.heappush(search_heap,(c,k))
          
        while search_heap != []:
            c, k = heapq.heappop(search_heap)
            if connected_node[k] == 0:
                new_search_list = [k]
                connected_node[k] = 1
                total_cost += c
                break
        search_list = new_search_list
    return total_cost

print(prim(connect_list,0,n))

Measured memory_bytes: 145012
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, K;
	cin >> N >> K;
	vi X(N);
	REP(i, N) {
		cin >> X[i];
	}
	int ans = 0;
	REP(i, N) {
		if (abs(0 - X[i]) > abs(K - X[i])) {
			ans += abs(K - X[i]) * 2;
		}
		else {
			ans += abs(0 - X[i]) * 2;
		}
	}
	OUT(ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;

// 最小公約数
long long gcd(long long a, long long b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}

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

// 切り上げ（long long）
long long ceil(long long a, long long b) {
	return (a + b - 1) / b;
}

int main() {
	long long A, B, C, D; cin >> A >> B >> C >> D;
	long long range = B - A + 1;
	long long ans = range;
	long long div = C;
	long long num = B / div - ceil(A, div) + 1;
	ans -= num;
	div = D;
	num = B / div - ceil(A, div) + 1;
	ans -= num;
	div = lcm(C, D);
	num = B / div - ceil(A, div) + 1;
	ans += num;

	cout << ans;

}

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

int main(void) {
  long long N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<int> k(Q);
  for (int i = 0; i < Q; i++) {
    cin >> k[i];
  }
  for (int j = 0; j < Q; j++) {
    long long d = 0, m = 0, dm = 0, ans = 0;
    for (int i = 0; i < N; i++) {
      if (i >= k[j]) {
        if (S[i - k[j]] == 'D') {
          d--;
          dm -= m;
        }
        if (S[i - k[j]] == 'M') m--;
      }

      if (S[i] == 'D') d++;
      if (S[i] == 'M') {
        m++;
        dm += d;
      }
      if (S[i] == 'C') {
        ans += dm;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1540
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  string checkT = T.substr(0, T.size()-1);
  if (checkT == S) {
   if (S.size() <= 10 && S.size() >= 1) {
    cout << "Yes" << endl;
     return 0;
   }
    cout << "No" << endl;
  return 0;  
  }
  cout << "No" << endl;
 return 0; 
}

Measured memory_bytes: 3584
import java.util.Scanner ;

class Main{
     
    public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in); 
        int i = 0;
         
        while(true){
            i++;
            int t = scan.nextInt();
            if(t == 0){
                break;
            }
            System.out.println("Case "+ i +": "+ t);
        }
         
    }
     
}

Measured memory_bytes: 42188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;


int w[110000];
int val[110000];

int main(){
    int n,wt;
    cin>>n;
    cin>>wt;
    for(int i=0;i<n;i++)
    {
        cin>>w[i];cin>>val[i];
    }
    long long int dp[wt+1][n+1];

    for(int i=0;i<=wt;i++){
        for(int j=0;j<=n;j++){
            if(i==0) dp[i][j]=0;
            else if(j==0) dp[i][j]=0;
            else if(i>=w[j-1]){
                dp[i][j]=max(val[j-1]+dp[i-w[j-1]][j-1],dp[i][j-1]);
            }
            else{
                dp[i][j]=dp[i][j-1];
            }

        }
    }
    cout<<dp[wt][n];
return 0;
}


Measured memory_bytes: 79104
#include<iostream>
using namespace std;
main()
{
	long long int n;
	cin >> n;
	long long int i, sum = 0;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
		sum+=i;
	}
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        for(int i = 0; i < S.length(); i++){
            char x = S.charAt(i);
            char y = ' ';
            if(Character.isLowerCase(x)) y = Character.toUpperCase(x);
            else y = Character.toLowerCase(x);
            System.out.print(y); 
        }
        sc.close();
        System.out.println("");
    }
}



Measured memory_bytes: 26832
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string s,t;
	cin >> s >> t;
	cout << t << s <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  ll N;
  ll M;
  ll X;
  cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N);
  REP(i, N) {
    cin >> C[i];
    vector<ll> Ai(M);
    REP(j, M) { cin >> Ai[j]; }
    A[i] = Ai;
  }
  ll ans = MOD;
  REP(i, 1 << N) {
    ll cost = 0;
    vector<ll> rikaido(M, 0);
    REP(j, N) {
      if ((i >> j) & 1) {
        cost += C[j];
        REP(k, M) { rikaido[k] += A[j][k]; }
      }
    }
    bool ok = true;
    REP(k, M) {
      if (rikaido[k] < X) {
        ok = false;
      }
    }
    if (ok) {
      ans = min(ans, cost);
    }
  }
  if (ans == MOD) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, p[10000], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> p[i];
	sort(p, p + n);
	
	for (int i = 0; i < n-1; ++i)cnt = cnt + p[i];
	cnt = cnt + (p[n - 1] / 2);
	cout << cnt << endl;
	return 0;
}

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 1000, MAX_M = 1000;
const i64 M = 1000000007;
int n,m;
int a[MAX_N];
int ra[MAX_N*MAX_M] = {};
int b[MAX_M];
int rb[MAX_N*MAX_M] = {};

int main()
{
  cin >> n >> m;
  fill_n(ra,n*m,-1);
  fill_n(rb,n*m,-1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
    if (ra[a[i]] >= 0) {
      cout << 0 << endl;
      return 0;
    } else {
      ra[a[i]] = i;
    }
  }

  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    b[i]--;
    if (rb[b[i]] >= 0) {
      cout << 0 << endl;
      return 0;
    } else {
      rb[b[i]] = i;
    }
  }

  sort(a,a+n);
  sort(b,b+m);

  i64 res = 1;
  int i = n-1, j = m-1, c = 0;
  for (int v = n*m-1; v >= 0; v--) {
    while (i >= 0 && a[i] > v) i--;
    while (j >= 0 && b[j] > v) j--;
    //printf("v=%d i=%d j=%d\n",v,i,j);
    if (i >= 0 && a[i] == v && j >= 0 && b[j] == v) {
      res *= 1;
    } else if (i >= 0 && a[i] == v) {
      res = res * (m-j-1) % M;
    } else if (j >= 0 && b[j] == v) {
      res = res * (n-i-1) % M;
    } else {
      res = (res * ((n-i-1) * (m-j-1) - c) + M) % M;
    }
    //printf("%ld\n", res);
    c++;
  }

  cout << res << endl;


  return 0;
}


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

int N, M, Q;
int A[11]{};
int a[50], b[50], c[50], d[50];

int ans = 0;

void dfs(int n) {
    if (n == N) {
        int sum = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    for (int i = min(A[n], M); i <= M; i++) {
        A[n + 1] = i;
        dfs(n + 1);
    }

}
int main() {
    cin >> N >> M >> Q;

    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    A[0] = 1;
    dfs(0);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力

            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;

            // 累積和
            Integer s[] = new Integer[1000];
            s[0] = 1;
            for (int i = 2; i < 1000; ++i) {
                s[i - 1] = s[i - 2] + i;
            }

            for (int i = 1; i < 1000; i++) {
                if ((s[i] - s[i - 1]) == (b - a)) {
                    ans = s[i] - b;
                    break;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23636
#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()

ll a[100005];

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        if (t > 100000)
            ans++;
        else
            a[t - 1]++;
    }
    for (ll i = 0; i < 100000; i++)
    {
        if (a[i] > i + 1)
        {
            ans += a[i] - (i + 1);
        }
        else if (a[i] < i + 1)
        {
            ans += a[i];
        }
    }
    cout << ans << endl;
}

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

int main(int argc, char *argv[])
{
  int a=0, b=0;
  scanf("%d %d", &a, &b);
  if(a<b)
    cout << "a < b" << endl;
  else if(a==b)
    cout << "a == b" << endl;
  else
    cout << "a > b" << endl;

  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>d(k);
    rep(i,k)cin>>d[i];
    for(int i=n;;++i){
        bool ok=true;
        string s=to_string(i);
        rep(j,s.size()){
            rep(l,d.size()){
                if(s[j]-'0'==d[l])ok=false;
            }
        }
        if(ok){cout<<i<<endl; return 0;}
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, s, g) for(int i = s; i < g; i++)
#define FORR(i, s, g) for(int i = s - 1; i >= g; i--)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define DMP(a) std::cerr << "[Debug] : " << #a << " = " << a << "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<std::string> vs;
struct aaa{
    aaa(){
        std::cin.tie(0); std::ios::sync_with_stdio(0); std::cout<<std::fixed<<std::setprecision(20);
    };
}aaaaaaa;

class UnionFind {
private:
    vi _par;
    vi _rank;
public:
    UnionFind(const int n);
    int find(const int n);
    void unite(int x, int y);
    bool same(const int x, const int y);
};

UnionFind::UnionFind(const int n) {
    REP(i,n) {
        _par.push_back(i);
        _rank.push_back(0);
    }
}

int UnionFind::find(const int x) {
    if(_par[x] == x) return x;
    else return _par[x] = find(_par[x]);
}

void UnionFind::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(_rank[x] < _rank[y]) _par[x] = y;
    else {
        _par[y] = x;
        if(_rank[x] == _rank[y]) _rank[x]++;
    }
}

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

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind ufr(n), ufl(n);
    REP(i, k) {
        int p, q;
        cin >> p >> q;
        ufr.unite(p - 1, q - 1);
    }
    vi a(n,1);
    REP(i, l) {
        int r, s;
        cin >> r >> s;
        ufl.unite(r - 1, s - 1);
    }

    map<pair<int, int>, int> ans;
    vector<pair<int, int>> p(n);
    REP(i, n) {
        p[i].first = ufr.find(i);
        p[i].second = ufl.find(i);
        ans[p[i]]++;
    }
    REP(i, n) {
        if(i != n - 1) cout << ans[p[i]] << " ";
        else cout << ans[p[i]] << "\n";
    }

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    vector<int> l(N);
    for (int n = 0; n < N; ++n){
      int t;
      cin >> t;
      l[n] = t;
    }
    int max = *max_element(l.begin(), l.end());
    int index = distance(l.begin(), max_element(l.begin(), l.end()));

    int sum_len = 0;
    for(int i =0,end = l.size();i < end; ++i){
      if (i != index){
        sum_len += l.at(i);
        if (sum_len > max) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }

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


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

int main(){
    int x,y;
    cin>>x>>y;
    int ans=INT_MAX;
    if(y>=x)ans=min(ans,y-x);
    x=-x;
    if(y>=x)ans=min(ans,y-x+1);
    x=-x,y=-y;
    if(y>=x)ans=min(ans,y-x+1);
    x=-x;
    if(y>=x)ans=min(ans,y-x+2);
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(){
	ll d,n; cin>>d>>n;
	ll ans=1;

	for(int i=0;i<d;i++){
		ans *= 100;
	}

	if(n == 100)n = 101;
	ans *= n;

	cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int s,a,b,c;
   scanf("%d",&s);
       a=s/3600;
       b=(s-a*3600)/60;
       c=s-(a*3600+b*60);
   
   printf("%d:%d:%d\n",a,b,c);
   return 0;
}

Measured memory_bytes: 1852
from functools import reduce


def M(x, y):
    if x == 'T' and y == 'T':
        return 'T'
    elif x == 'T' and y == 'F':
        return 'F'
    elif x == 'F' and y == 'T':
        return 'T'
    else:
        return 'T'


_ = input()
P = input().split()

print(reduce(M, P))



Measured memory_bytes: 7196
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{it.toInt()}
    a = ((a.sorted()).toSet()).toList()
    var min = 0
    
    (1..a.size-1).map{i->
        min += a[i] - a[i-1]
    }
    println(min)
    
}


Measured memory_bytes: 36108
// @tanakh https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ------

fn main() {
    input! {
        n: u32,
        m: u32,
    }

    let t = 100 * (n - m) + 1900 * m;
    let t = t * 2u32.pow(m);

    println!("{}", t);
}


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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

const llong inf=100000000;



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

    int n, m, k[11], s[11][11], p[11];

    cin >> n >> m;
    REP(i, m)
    {
        cin >> k[i];
        REP(j, k[i])
            cin >> s[i][j];
    }
    REP(i, m)
        cin >> p[i];

    int res;
    
    for (int i = 0; i < (1 << n); i++)
    {
        int sn[11];
        memset(sn, 0, sizeof(sn)); //11bite分のchを定義
        REP(j, n)
        {
            if (!(i & (1 << j)))
                continue;
            REP(l, m)
            {
                bool has = false;
                REP(o, k[l])
                {
                    if (s[l][o] == j + 1)
                        has = true;
                }

                sn[l] += has;
            }
        }

        bool ok = true;
        REP(j, m)
        {
            if (sn[j] % 2 != p[j] % 2)
                ok = false;
        }

        res += ok;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
int min(int a, int b);
int main()
{
    char queue[100000];
    int happy_num = 0;
    int len, time;
    scanf("%d%d",&len, &time);
    scanf("%s", queue);
    for(int i = 0; i < strlen(queue);i++)
    {
        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))
            happy_num++;
        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))
            happy_num ++;
    }
    printf("%d", min((happy_num + 2*time), len -1));
    return 0;
}
int min(int a, int b)
{
    return (a>=b)?b:a;
}

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

int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  else if(s=="MON") cout<<6<<endl;
  else if(s=="TUE") cout<<5<<endl;
  else if(s=="WED") cout<<4<<endl;
  else if(s=="THU") cout<<3<<endl;
  else if(s=="FRI") cout<<2<<endl;
  else if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

int N, W;
vector<ll> w;
vector<ll> v;
vector<ll> dp;

int input(){
  cin >> N >> W;
  REP(i,N) {
    w.push_back( inp<ll>() );
    v.push_back( inp<ll>() );
  }
}

int main()
{
  input();
  
  REP(i,202000+2) dp.push_back( INF ); //v
  dp[0] = 0;
  
  REP(i,N){
    ll iw = w[i];
    ll iv = v[i];
    REPR(j,200000+2){
      dp[j+iv] = min( dp[j+iv], dp[j] + iw );
    }
  }
  
  ll maxv = 0;
  REP(i,202000){
    if (dp[i]<=W){
       maxv = i;
    }
  }
  cout << maxv << endl;
}

Measured memory_bytes: 2424
n, m, d = map(int, input().split())

#print(2 * (n - d) * (m - 1) / (n ** m))
# print((n - d) * 2 * (n - 1) * (m - 1) * (n ** (m - 1)) / (n ** m))
if d != 0:
    print((n - d) * 2 * (m - 1) / (n ** 2))
else:
    print((m - 1) / n)


Measured memory_bytes: 2940