akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int n, m, p;
int x[102];

int main(){
  while(cin >> n >> m >> p, n || m || p){
    int sum = 0;

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

    sum *= 100 - p;

    if(x[m - 1] == 0){
      cout << 0 << endl;
    }
    else{
      cout << (int)((double)sum / x[m - 1]) << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int lis(const VI &a) {
  int n = a.size();
  // LIS, longest increasing subsequence
  VI m(n + 1);
  int l = 0;
  REP(i, 0, n) {
    int lo = 0;
    int hi = l + 1;
    while (hi - lo > 1) {
      int mid = (hi + lo) / 2;
      if (a[m[mid]] < a[i]) {
	lo = mid;
      } else {
	hi = mid;
      }
    }
    int newl = lo + 1;
    m[newl] = i;
    if (newl > l) {
      l = newl;
    }
  }
  return l;
}


#if 0

int main(void) {
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    a[i] = i + 1;
  }
  set<PI> occ;
  do {
    VI b(n);
    REP(i, 0, n) b[i] = -a[i];
    int inc = lis(a);
    int dec = lis(b);
    if (occ.count(PI(inc, dec)) == 0) {
      cout << "a=" << inc << " b=" << dec << endl;
      cout << "elem:";
      REP(i, 0, n) {
	cout << " " << a[i];
      }
      cout << endl;
    }
    occ.insert(PI(inc, dec));
  } while (next_permutation(a.begin(), a.end()));
  for (auto v: occ) {
    cout << "a=" << v.first << " b=" << v.second << endl;
  }
}

#else

VI div(int n, int a, int b) {
  VI ret(a, 1);
  n -= a;
  REP(i, 0, a) {
    int v = min(n, b - 1);
    ret[i] += v;
    n -= v;
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  if (a + b - 1 > n || a * b < n) {
    cout << -1 << endl;
    return 0;
  }
  VI d = div(n, a, b);
  VI ans(n);
  int pos = 0;
  REP(i, 0, d.size()) {
    int init = pos + 1;
    REP(j, 0, d[i]) {
      ans[pos++] = init + d[i] - 1 - j;
    }
  }
  assert (lis(ans) == a);
  VI negans(n);
  REP(i, 0, n) negans[i] = -ans[i];
  assert (lis(negans) == b);
  REP(i, 0, n) {
    cout << ans[i] << (i == n - 1 ? "\n" : " ");
  }
}
#endif


Measured memory_bytes: 6280
#include <iostream>
#include <stdlib.h>

using namespace std;
int comp(const void *a, const void *b)
{
	if (*((int*)b + 1) - *((int*)a + 1)){
		return *((int*)b + 1) - *((int*)a + 1);
	} else{
		return *(int*)a - *(int*)b;
	}
}

int main(){
	int n, m, dr[101][2], drs = 0, redge = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> dr[i][0] >> dr[i][1];
	}
	qsort(dr, m, sizeof(int) * 2, comp);

	int flag = 0;
	while (redge < n){
		for (int i = 0; dr[i][1] > redge; i++){
			if (dr[i][0] <= redge + 1){
				redge = dr[i][1];
				flag = 1;
				drs++;
				break;
			}
		}
		if (!flag){
			cout << "Impossible" << endl;
			return 0;
		}
		flag = 0;
	}
	cout << drs << endl;
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bcools
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            if (c <= a + b) System.out.println("Yes");
            else System.out.println("No");
        }

    }
}



Measured memory_bytes: 23636
import numpy as np

S = input()
N = len(S)
move = 10 ** 100

U = N + 1
D = move.bit_length()

dbl = np.zeros((D, U), dtype=int)
for i, s in enumerate(S, start=1):
    if s == "R":
        dbl[0, i] = i + 1
    else:
        dbl[0, i] = i - 1

for h in range(D - 1):
    dbl[h + 1] = dbl[h, dbl[h]]

child = np.arange(1, N + 1)
for i in reversed(range(D)):
    if move & (1 << i):
        child = dbl[i, child]

ans = np.bincount(child, minlength=N + 1)
print(*ans[1:])

Measured memory_bytes: 279772
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , MOD = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out.txt","w",stdout);
#endif
    int n,ma = -1 ,mi = INF,x;
    scanf("%d",&n);
    for(int i = 0 ; i < n  ; i++){
        scanf("%d",&x);
        ma = max(ma,x);
        mi = min(mi,x);
    }
    printf("%d\n",ma-mi);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int X,A;
    scanf("%d %d",&X,&A);

    if(X<0||X>9||A<0||A>9)
    {
        printf("Invalid Input");
    }
    else if(X<A)
    {
        printf("0\n");
    }
    else
    {
        printf("10\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  double x;
  string u;
  double s = 0;
  rep(i, n) {
    cin >> x >> u;
    if (u == "JPY") s += x;
    else s += x * 380000.0;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int a,p;
	cin >> a >> p;
	cout << (p+a*3)/2 << endl;
}


Measured memory_bytes: 256
/**
 * Author: Deb Natkh Maxim (debnatkh@gmail.com)
 * Date: 24.03.2019
 */

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

const int MAXN = 1e5 + 10;
int arr[MAXN];

bool check(char c) {
    return (c == 'A' || c == 'T' || c == 'G' || c == 'C');
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            arr[i + 1] = arr[i] + 1;
        } else {
            arr[i + 1] = arr[i];
        }
    }
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << arr[r - 1] - arr[l - 1] << "\n";
    }

    return 0;
}

Measured memory_bytes: 1872
n, k = map(int, input().split())

a = list(map(int, input().split()))

b = min(a)

lft = 0
rgt = 0
for i in range(len(a)):
    if a[i] == b:
        lft = i
        break

ret = 0
i = 0
for i in range(len(a)):
    if a[i] == b:
        continue
    flag = False
    for j in range(k - 1):
        if not i + j < n:
            break
        if a[i+j] == b:
            flag = True
        a[i+j] = b
    if flag and i+k-1 < len(a):
        a[i+k-1] = b
    ret += 1

print(ret)

Measured memory_bytes: 14008
import java.util.*;

class Main {
	Scanner sc;
	int k, q;
	int[] d, dm;
	long[] e;
	
	void calc() {
		sc = new Scanner(System.in);
		k = sc.nextInt();
		q = sc.nextInt();
		
		d = new int[k];
		dm = new int[k];
		e = new long[k];
		for (int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
		}
		
		for (int i = 0; i < q; i++) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int m = sc.nextInt();
			
			dm[0] = d[0] % m;
			e[0] = dm[0] + ((dm[0] == 0)?m:0);
			for (int j = 1; j < k; j++) {
				dm[j] = d[j] % m;
				e[j] = e[j-1] + dm[j];
				if (e[j] == e[j-1]) e[j] += m;
			}
			
			long sum = (x%m) + e[k-1]*( (n-2)/k )+e[(n-2)%k];
			long c = sum/m;
			System.out.println(n-1-c);
		}
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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


int main(){
	    vector<vector<int>> A(3,vector<int>(3, 0));
        vector<vector<bool>> bingo(3, vector<bool>(3, false));
        rep(i, 3){
            rep(j, 3){
                cin >> A[i][j];
            }
        }
        
        int N; cin >> N;
        vector<int> B(N, 0);
        rep(i, N){
            cin >> B[i];
        }

        rep(i, N){
            rep(j, 3){
                rep(k, 3){
                    if(B[i] == A[j][k]) bingo[j][k] = true;
                }
            }
        }
        if(bingo[0][0] && bingo[0][1] && bingo[0][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[1][0] && bingo[1][1] && bingo[1][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[2][0] && bingo[2][1] && bingo[2][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][0] && bingo[1][0] && bingo[2][0]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][1] && bingo[1][1] && bingo[2][1]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][2] && bingo[1][2] && bingo[2][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][0] && bingo[1][1] && bingo[2][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][2] && bingo[1][1] && bingo[2][0]){
            cout << "Yes" << endl;
            return 0;
        }
        else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        if(n<357){
            out.println(0);
        }else{
            int ans=0;
            int c=String.valueOf(n).length();
            for (int i = 3; i <=c ; i++) {
                long m=power(3,i);
                for (int j = 0; j < m; j++) {
                    String s=Integer.toString(j, 3);
                    int l=i-s.length();
                    for (int k = 0; k < l; k++) {
                        s="0"+s;
                    }
                    s=s.replaceAll("0", "3");
                    s=s.replaceAll("1", "5");
                    s=s.replaceAll("2", "7");
                    int k=Integer.parseInt(s);
                    //out.println("s="+s+"  k="+k+"  judge="+(k<=n&&f(s)));
                    if(k<=n&&f(s))ans++;
                }
            }
            out.println(ans);
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
    static boolean f(String s){
        int k=s.length();
        int c3=0,c5=0,c7=0;
        for (int i = 0; i < k; i++) {
            char p=s.charAt(i);
            if(p=='3')c3++;
            else if(p=='5')c5++;
            else if(p=='7')c7++;
        }
        return(c3*c5*c7>0&&c3+c5+c7==k);
    }
}


Measured memory_bytes: 59792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    long double N,V;
    cin >> N;

    priority_queue<int> que;
    V = (N/3.0)*(N/3.0)*(N/3.0);
        
    cout << fixed << setprecision(10) << V << endl; // C++
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

x, y = list(map(str, input().split()))

x = int("0x"+x, 16)
y = int("0x"+y, 16)

if x > y:
    print(">")
elif x == y:
    print("=")
else:
    print("<")


Measured memory_bytes: 9012
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int N, M, L;

struct State {
    int v, sum, dist;
    State(int v, int sum, int dist) : v(v), sum(sum), dist(dist) {}
    bool operator<(const State& a) const {
        return dist > a.dist;
    }
};

struct edge {
    int to, money, enemy;
    edge(int to, int money, int enemy):to(to),money(money),enemy(enemy){}
};

vector<edge> G[101];
int d[101][101];

void dijkstra(int s)
{
    for (int i = 0; i <= 100; ++i) for (int j = 0; j < N; ++j) d[i][j] = inf;

    priority_queue<State> q;
    q.push(State(s, 0, 0));

    d[0][s] = 0;

    while (q.size()) {
        State st = q.top(); q.pop();

        if (d[st.sum][st.v] < st.dist) continue;

        for (int i = 0; i < G[st.v].size(); ++i) {
            edge e = G[st.v][i];

            if (st.sum + e.money <= L) {
                do {
                if (d[st.sum + e.money][e.to] <= st.dist) continue;
                d[st.sum + e.money][e.to] = st.dist;
                q.push(State(e.to, st.sum + e.money, d[st.sum + e.money][e.to]));
                } while(0);
            }

            if (d[st.sum][e.to] > st.dist + e.enemy) {
                d[st.sum][e.to] = st.dist + e.enemy;
                q.push(State(e.to, st.sum, d[st.sum][e.to]));
            }
        }
    }
}

signed main()
{
    while (scanf("%d%d%d", &N, &M, &L), N) {
        for (int i = 0; i < N; ++i) G[i].clear();

        for (int i = 0; i < M; ++i) {
            int A, B, D, E;
            scanf("%d%d%d%d", &A, &B, &D, &E);
            A--, B--;
            G[A].push_back(edge(B, D, E));
            G[B].push_back(edge(A, D, E));
        }

        dijkstra(0);

        int mi = inf;

        for (int i = 0; i <= 100; ++i) {
            chmin(mi, d[i][N - 1]);
        }

        printf("%d\n", mi);
    }
}

Measured memory_bytes: 1716
S = input()
T = input()

S_list = list(S)
T_list = list(T)

t_cnt = 0
t_cnt_max = 0
start_pos = 0

#print(S_list, T_list)

for i in range(len(S_list) - len(T_list)+1):
    t_cnt = 0
    for j in range(len(T_list)):
        if S_list[i+j] == T_list[j]:
            t_cnt += 1
            start_pos = i
            #print(S_list[i+j], T_list[j], t_cnt, j)
            if t_cnt_max < t_cnt:
                t_cnt_max = t_cnt
print(len(T_list) - t_cnt_max)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

/*
  奇数枚あるところから別の奇数枚あるところに移動する。
  選ばれたことのないマスから選ぶ。

  途中で通るマスは必ず元々偶数枚である。
  なぜならば、途中に奇数枚のマスが存在するならば、そこで止まればよい。
*/

typedef struct {
  int x;
  int y;
} Pos;

int H, W, a;
vector<vector<bool>> selected;
vector<Pos> odds;
// procs[i]:
//   [0]: y_i
//   [1]: x_i
//   [2]: y'_1
//   [3]: x'_i
vector<vector<int>> procs;

int main() {
  scanf("%d%d", &H, &W);

  selected = vector<vector<bool>>(H+1, vector<bool>(W+1, false));

  for (int h = 1; h <= H; ++h) {
    for (int w = 1; w <= W; ++w) {
      scanf("%d", &a);
      if (a % 2 == 1) odds.push_back(Pos{w, h});
    }
  }

  // できるだけ同じ行内で解決する。
  vector<Pos> remain_odds;
  for (int i = 0; i < odds.size(); ++i) {
    if (i == odds.size() - 1) {
      remain_odds.push_back(odds[i]);
      break;
    }

    if (odds[i].y == odds[i+1].y) {
      int y = odds[i].y;
      for (int x = odds[i].x; x < odds[i+1].x; ++x) {
        selected[y][x] = true;
        procs.push_back(vector<int>({y, x, y, x+1}));
      }
      i += 1;
    }
    else {
      remain_odds.push_back(odds[i]);
    }
  }

  // for (int i = 0; i < remain_odds.size(); ++i) {
  //   printf("%d %d\n", remain_odds[i].y, remain_odds[i].x);
  // }

  // 残った場所はできるだけ近い列のものと解決させる。
  for (int i = 0; i + 1 < remain_odds.size(); i += 2) {
    int y1 = remain_odds[i].y;
    int x1 = remain_odds[i].x;
    int y2 = remain_odds[i+1].y;
    int x2 = remain_odds[i+1].x;

    // 上にある方が、一番右まで行って下に下がる
    int x = x1;
    int y = y1;

    while (x != W) {
      procs.push_back(vector<int>({y, x, y, x+1}));
      x += 1;
    }

    // 行が同じになるまで下がる。
    while (y != y2) {
      procs.push_back(vector<int>({y, W, y+1, W}));
      y += 1;
    }

    // 行が同じになったら、ひたすら左に進む。
    while (x != x2) {
      procs.push_back(vector<int>({y2, x, y2, x-1}));
      x -= 1;
    }
  }

  printf("%d\n", procs.size());
  for (int i = 0; i < procs.size(); ++i) {
    printf("%d %d %d %d\n", procs[i][0], procs[i][1], procs[i][2], procs[i][3]);
  }

  return 0;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  string T;

  void init() {
    cin >> T;
  }

  void solve() {
    rep(i, T.size()) {
      if(T[i] == '?') cout << 'D';
      else cout << T[i];
    }
    cout << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <string.h>
int main()
{int d;
	char s[3];
	gets(s);
	d=strcmp(s, "SUN");
	if(d==0)
	{
		printf("7\n");
	}d=strcmp(s, "SAT");
	if(d==0)
	{
		printf("1\n");
	}d=strcmp(s, "MON");
	if(d==0)
	{
		printf("6\n");
	}d=strcmp(s, "TUE");
	if(d==0)
	{
		printf("5\n");
	}d=strcmp(s, "WED");
	if(d==0)
	{
		printf("4\n");
	}d=strcmp(s, "THU");
	if(d==0)
	{
		printf("3\n");
	}d=strcmp(s, "FRI");
	if(d==0)
	{
		printf("2\n");
	}
	return 0;
	}


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

int main()
{
  int N,A,B,ans;
  cin >> N >> A >> B;
  
  ans = N*A;
  if(ans > B){
    cout << B << endl;
  }
  else if(ans < B){
    cout << ans << endl;
  }
  else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main() {
	int L = 0;
	int H = 0;
	int N = 0;
	int A[200] = { 0 };
	int ans = 0;
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);

	for (int i = 0; i < L; i++) {
		ans += A[N - 1 - i];
	}
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin >> t;
        if (i % 2 == 1 && t % 2 == 1)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long i64;
 
const int month_day[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
 
string s;
 
inline bool is_leap(int y) { return y%4 == 0 and (y%100 != 0 or y%400 == 0);}
inline int leap_count(int y) { return (y-1)/4-(y-1)/100+(y-1)/400; }
inline i64 day_count(int y, int m, int d) { return leap_count(y)*366LL+(y-leap_count(y))*365LL+month_day[m-1]+(is_leap(y)&(m>2))+d; }
 
void to_maya()
{
        int y, m, d;
        sscanf(s.c_str(),"%d.%d.%d", &y, &m, &d);
        i64 ds = (day_count(y,m,d)-day_count(2012,12,21))%(20*18*20*20*13);
        printf("%lld.%lld.%lld.%lld.%lld\n", ds/(20*18*20*20), ds/(20*18*20)%20, ds/(20*18)%20, ds/20%18, ds%20);
}
 
void to_ad()
{
        int b, ka, t, w, ki;
        sscanf(s.c_str(),"%d.%d.%d.%d.%d", &b, &ka, &t, &w, &ki);
        i64 ds = ki+20*w+20*18*t+20*18*20*ka+20*18*20*20*b+day_count(2012,12,21);
        int y = 0, m = 0, d = 0;
        while(ds >= is_leap(y)+365) ds -= is_leap(y++)+365;
        while(ds >= month_day[m+1]+(is_leap(y)&(m>=1))) m++;
        ds -= month_day[m]+(is_leap(y)&(m>1));
        m++;
        d = ds+1;
        printf("%d.%d.%d\n", y, m, d);
}
 
void solve()
{
        int cnt = 0;
        for(auto &e: s) cnt += e == '.';
        return cnt == 2 ? to_maya() : to_ad();
}
 
bool input()
{
		cin.tie(0);
		ios::sync_with_stdio(false);
        cin >> s;
        return s[0] != '#';
}
 
int main()
{
        while(input()) solve();
        return 0;
}

Measured memory_bytes: 1248
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), M = in.nextInt();
        ArrayList<Integer>[] adj = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            adj[i] = new ArrayList<>();
        }
        for (int i = 0; i < M; i++) {
            int n1 = in.nextInt() - 1, n2 = in.nextInt() - 1;
            adj[n1].add(n2);
            adj[n2].add(n1);
        }
        int[] distance = new int[N];
        for (int i = 1; i < N; i++) {
            distance[i] = Integer.MAX_VALUE;
        }
        int[] point = new int[N];
        Queue<Integer> pq = new PriorityQueue<>((a, b) -> distance[a] - distance[b]);
        pq.offer(0);
        boolean[] added = new boolean[N];
        added[0] = true;
        while (!pq.isEmpty()) {
            int n = pq.poll();
            for (int i : adj[n]) {
                if (distance[n] + 1 < distance[i]) {
                    distance[i] = distance[n] + 1;
                    point[i] = n;
                    if (!added[i]) {
                        pq.offer(i);
                    }
                }
            }
        }
        System.out.println("Yes");
        for (int i = 1; i < N; i++) {
            System.out.println(point[i] + 1);
        }
    }
}

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

#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

vl A,B;

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    /*
    vl A2;
    vl B2;
    n = 20;
    cerr << n << "\n";
    rep(c1,0,n){
        A.push_back(1);
        cerr << A[c1] << " ";
        A2.push_back(A[c1]);
    }cerr << "\n";
    a = 0;
    rep(c1,0,15423){
        ll i = random2()%n;

        if(A[i] + (A[(i+n-1)%n] + A[(i+1)%n]) <= 1000000000){A[i] += (A[(i+n-1)%n] + A[(i+1)%n]);a++;}

    }
    rep(c1,0,n){
        B2.push_back(A[c1]);
        cerr << A[c1] << " ";
    }cerr << "\n";

    cerr << "A: " << a << "\n";
*/

    cin >> n;


    rep(c1,0,n){
        cin >> a;
        A.push_back(a);
       // A[c1] = A2[c1];
    }
    bool fail = 0;
    priority_queue<pll> pq;
    rep(c1,0,n){
        cin >> a;
        B.push_back(a);

      //a = B2[c1];
     // B.push_back(B2[c1]);

        if(a < A[c1])fail = 1;
        if(a != A[c1])pq.push({a,c1});
    }

    if(fail){
        cout << "-1\n";
        return 0;
    }

    ll ans = 0;

    while(!pq.empty()){
        ll i = pq.top().second;
        pq.pop();

        d = B[(i+1)%n] + B[(n+i-1)%n];

        ll times = (B[i]-A[i])/d;
        if(times <= 0)break;
       // times = 1;
        B[i] -= times*d;
        if(B[i] <= 0)break;
        if(B[i] > A[i])pq.push({B[i],i});
        ans += times;

        /*
        rep(c1,0,n){
            cerr << B[c1] << " ";
        }cerr << "\n";
        */


    }

    rep(c1,0,n){
        if(A[c1] != B[c1])ans = -1;
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 10992
#include <bits/stdc++.h>
#define maxn 0x7fffffff
using namespace std;
int a[10001];
int ans;
int cnt;
int pp=maxn;
int main()
{
	int n;cin>>n;
	int in=maxn,ax=-maxn;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt+=a[i];
		in=min(in,a[i]);
		ax=max(ax,a[i]);
		
		
	}
	int p=maxn;
	for(int k=in;k<=ax;k++){
		ans=0;
		for(int i=1;i<=n;i++)
			ans+=pow(a[i]-k,2);
		if(ans<p)p=ans;
		
		
	}
	cout<<p;
	return 0;
}


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >> n;
    rep(i,10){
        rep(j,10){
            if(i*j==n){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;



}

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

int a[17], c[100];
priority_queue<pair<int,int> > b;

int can_sit(int n) {
  int p = 0;
  for (int i=0; i<17; i++) {
    if (a[i] == -1) {
      ++p;
    } else {
      p = 0;
    }
    if (p == n) {
      return i-n+1;
    }
  }
  return -1;
}

int sit(int id, int stt, int n) {
  for (int i=0; i<n; i++) {
    a[i+stt] = id;
  }
}

int stand(int id) {
  for (int i=0; i<17; i++) {
    if (a[i] == id) {
      a[i] = -1;
    }
  }
}

int main() {
  int t, p, q, r;
  for (int i=0; i<17; i++) a[i] = -1;
  t = 0;
  p = 0;
  while (1) {
    while (t >= 5*p && p<100) {
      q = (p%5==1) ? 5 : 2;
      r = can_sit(q);
      if (r != -1) {
        c[p] = t - 5*p;
        sit(p, r, q);
        b.push(pair<int, int>(-(t + 17*(p%2) + 3*(p%3) + 19), p));
        p++;
      } else {
        break;
      }
    }
    if (-b.top().first <= ((t/5)+1)*5) {
      t = -b.top().first;
      stand(b.top().second);
      b.pop();
    } else {
      t = ((t/5)+1)*5;
    }
    if (p==100) {
      break;
    }
  }

  while (cin >> t) {
    cout << c[t] << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

int main(){
    string S;
    cin >> S;
    map<char, int> mp;
    for(char c : S)
        mp[c]++;

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

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 3005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int ans1;
int ans2;
inline ll read()
{
	ans1=ans2=0;
	ll x=0,w=1; char c=getchar();
	ans1=ans2=0;
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	ans1=ans2=0;
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	ans1=ans2=0;
	return w==1?x:-x;ans1=ans2=0;
}

ll dp[maxn][maxn],n,k,a[maxn];
const ll mod=998244353;

int main()
{ans1=ans2=0;
	ans1=ans2=0;
	ans1=ans2=0;
	n=read(); k=read(); rep(i,1,n) a[i]=read(); dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{ans1=ans2=0;
		for(int j=k;j>=0;j--) dp[i][j]=(dp[i-1][j]*2)%mod;
		for(int j=k;j>=a[i];j--)
		{ans1=ans2=0;
			dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;ans1=ans2=0;
		}
	}
	ans1=ans2=0;
	ll ans=0;ans1=ans2=0;
	for(int i=1;i<=n;i++) ans=(ans+dp[i][k])%mod;
	ans1=ans2=0;
	cout<<dp[n][k]+ans1+ans2<<endl;
	return 0;
}


Measured memory_bytes: 74084
#include<bits/stdc++.h>
using namespace std;
#define maxn 1010
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize(2)
#define ll long long
#define makefa(n) for(int i=1;i<=(n);i++)f[i]=i;
#define hh puts("");
#define eps 1e-10
#define db double
int n;
int dif=1;
char s[maxn];
void dfs(int i){
    if(i==n+1){
        cout<<s+1<<endl;
        return;}
    for (int j = 0; j <=dif ; ++j) {
        s[i]='a'+j;
        int tmp=dif;
        if(j==dif)dif++;
        dfs(i+1);
        dif=tmp;
    }
}
int main(){
    cin>>n;
    s[1]='a';
    dfs(2);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

VI primes = {2};
VI primesl = VI(100000, 1);
unordered_map<long, long> isps;

void addp() {
    for (long i = 3; i * i * i <= 1e10; i+=2) {
        bool fl = true;
        for (long p: primes) {
            if (i % p == 0) fl = false;
        }
        if (fl) primes.push_back(i);
    }
}

void addpl() {
    primesl[0] = 0;
    primesl[1] = 0;
    REPI(i,2,100000) {
        if (!primesl[i]) continue;
        for (long j = 2; i * j < 100000; j++) {
            primesl[i * j] = 0;
        }
    }
    
    REPI(i,2,100000) {
        if (primesl[i]) {
            isps[i * i] = true;
        }
    }
}

long red(long s) {
    for (long p: primes) {
        while (s % (p * p * p) == 0) {
            s /= p * p * p;
        }
    }
    return s;
}

long findp(long s) {
    for (long p: primes) {
        while (s % p == 0) {
            s /= p;
        }
    }
    return s;
}

long brv(long s) {
    long ans = 1;
    for (long p: primes) {
        if (s % (p * p) == 0) {
            if (double(ans) * p > 1e10) return -1;
            ans *= p;
        } else if (s % p == 0) {
            if (double(ans) * p * p > 1e10) return -1;
            ans *= p * p;
        }
    }
    return ans;
}

long opp(long s) {
    long p = findp(s);
    long b = s / p;
    long br = brv(b);
    if (br == -1) return -1;
    
    if (p == 1) return br;
    // if p is prime square
    if (isps[p]) {
        if (double(br) * sqrt(p) > 1e10) return -1;
        return br * long(sqrt(p));
    }
    // if p * p can be prime square, less than 1e10
    if (double(br) * p * p > 1e10) return -1;
    if (isps[p * p]) {
        return br * p * p;
    }
    // otherwise, p is p1 * p2
    return -1;
}

map<long, long> m;

int main() {
    addp();
    addpl();
    bool hasOne = false;
    int n;
    cin >> n;
    REP(i,n) {
        long a;
        cin >> a;
        a = red(a);
        if (a == 1) hasOne = true;
        else m[a]++;
    }
    
    long ans = 0;
    for (auto i = m.begin(); i != m.end(); i++) {
        if (i->second == 0) continue;
        long op = opp(i->first);
        if (op == -1) {
            ans += i->second;
            m[i->first] = 0;
        } else {
            ans += max(i->second, m[op]);
            m[i->first] = 0;
            m[op] = 0;
        }
    }
    cout << ans + hasOne << endl;
}



Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll ans = 0;
    ll n;
    cin >> n;
    ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl; 
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;
#define LINK(i,graph,pos) for (REG int i=graph.head[pos];i;i=graph.next[i])

#define MAXN 10000
#define MAXM 10000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;



int n,m;
int d[12][12];
int dd[12][12];
int c[110][110]; 
set <int> st;

int main()
{
	cin>>n>>m;
	RPT(i,1,n+1)
		RPT(j,1,m+1)
			scanf("%d",&d[i][j]);
	MST(dd,INF);
	RPT(i,0,101)
		RPT(j,0,101)
			RPT(ii,1,n+1)
				RPT(jj,1,m+1)
					c[i][j]=max(c[i][j],d[ii][jj]-i*ii-j*jj);
	RPT(i,0,101)
		RPT(j,0,101)
			RPT(ii,1,n+1)
				RPT(jj,1,m+1)
					dd[ii][jj]=min(dd[ii][jj],jj*j+ii*i+c[i][j]);
	RPT(i,1,n+1)
		RPT(j,1,m+1)
		{
			if (dd[i][j]!=d[i][j])
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
	cout<<"Possible"<<endl;
	cout<<202<<' '<<200+101*101<<endl;
	RPT(i,1,101)
		cout<<i<<' '<<i+1<<' '<<'X'<<endl;
	RPT(i,102,202)
		cout<<i+1<<' '<<i<<' '<<'Y'<<endl;
	RPT(i,0,101)
		RPT(j,0,101)
			cout<<i+1<<' '<<j+1+101<<' '<<c[i][j]<<endl;
	cout<<1<<' '<<102<<endl;
	return ~~(0^_^0);
}


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

using namespace std;

typedef long long ll;

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 solve(const int N, const int K, const string S) {
    char prev = S[0];
    int count = 0;
    int ok = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] != prev) {
            count++;
            prev = S[i];
        } else {
            ok++;
        }
    }
    if (count % 2 == 1) {
        if (K >= (count + 1) / 2) {
            return N - 1;
        } else {
            return ok + 2 * K;
        }
    } else {
        return min(N - 1, ok + 2 * K);
    }
}

int main(void) {
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    cout << solve(N, K, S) << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
int main()
 
{
 int n,a,b ;
 cin>>n>>a>>b;
 if(n==1){
    cout<<"Hello World"<<endl;
 }
 else if(n==2){
    cout<<a+b<<endl;
 }
 
  return 0;
}

Measured memory_bytes: 256
n=int(input())
nums=list(map(int,input().split()))
nums=list(enumerate(nums))
nums.sort(key=lambda x:x[1])

med=[0]*n
for i in range(n):
    ind=nums[i][0]
    if i<n//2:
        med[ind]=nums[n//2][1]
    else:
        med[ind]=nums[n//2-1][1]
print(*med,sep='\n')

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

int table[256];

void solve() {
	int N, D;
	cin >> N >> D;

	int ans = D;
	for (int i = 0; i < N - 1; i++) {
		int y = 127 ^ D;
		ans -= D;
		ans += y + (y ^ D);
		D = y;
	}
	cout << ans << endl;
}

int main() {
	int T;
	cin >> T;

	for (int i = 0; i < 128; i++) {
		int mx = -1;
		for (int j = 0; j < 128; j++) {
			if (j + (i ^ j) > mx) {
				mx = j + (i ^ j);
				table[i] = j;
			}
		}
	}

	while (T--) solve();
}

Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

func readLine(r *bufio.Reader) []byte {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := r.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return buf
}

const mod = 1000000007

func main() {
	r := bufio.NewReaderSize(os.Stdin, 4096)

	var H, W int
	fmt.Scan(&H, &W)

	m := make([][]byte, H)
	for i := 0; i < H; i++ {
		m[i] = readLine(r)
	}

	var dp [1001][1001]int
	dp[0][1] = 1
	for y := 1; y <= H; y++ {
		for x := 1; x <= W; x++ {
			if m[y-1][x-1] == '.' {
				dp[y][x] = (dp[y-1][x] + dp[y][x-1]) % mod
			}
		}
	}

	out(dp[H][W])
}


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

using namespace std;

long long dp[405][405];
vector<long long> cost;
vector<long long> prefix;

long long pref(int start, int end) {
	if (end < start)
		return 0;
	if (start <= 0)
		return prefix[end];
	return prefix[end] - prefix[start-1];
}

long long solve(int start, int end) {
	if (dp[start][end] != -1)
		return dp[start][end];
	if (end < start)
		return LLONG_MAX;
	if (end == start + 1)
		return dp[start][end] = cost[start] + cost[end];
	
	long long mini = LLONG_MAX;
	for (int i = start+1; i <= end; i++) {
		mini = min(mini, solve(start, i - 1) + solve(i, end) + pref(start, i - 1) + pref(i, end));// + 2ll * cost[i] + pref(i + 1, end) + min(pref(start, i - 1), pref(i + 1, end)));
	}
	return dp[start][end] = mini;
}

int main() {
	int n;
	cin >> n;
	memset(dp, -1, 405 * 405 * sizeof(long long));
	cost.resize(n);
	prefix.resize(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		dp[i][i] = 0;
	}
	prefix[0] = cost[0];
	for (int i = 1; i < n; i++) {
		prefix[i] = prefix[i - 1] + cost[i];
	}
	cout << solve(0, n - 1) << "\n";
	return 0;
}

Measured memory_bytes: 1536
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     string s;cin>>s;
     if(s[0]=='R'&&s[1]=='R'&&s[2] == 'R'){
         cout<<"3"<<endl;
     }
     else if(s[0]=='R' && s[1]=='R' || s[1]=='R' && s[2]=='R'){
         cout<<"2"<<endl;
     }
     else if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
         cout<<"1"<<endl;
     }
     else{
         cout<<"0"<<endl;
     }
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 3668
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] l = new int[n*2];
        for(int i=0; i<n*2; i++) {
            l[i] = in.nextInt();
        }

        Arrays.sort(l);

        int sum = 0;
        for(int i=0; i<n*2; i+=2) {
            sum += l[i];
        }

        System.out.println(sum);

        in.close();
    }
}


Measured memory_bytes: 9684
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N], B[N];
  for(int i=0;i<N;++i) cin>>A[i]>>B[i];
  vector<int> S;
  for(int i=31;i>=0;--i) {
    if((K&(1<<i))!=0) S.push_back(i);
  }
  ll ans = 0;
  ll tmpans;
  bool can;
  for(int i=0;i<S.size();++i) {
    tmpans = 0;
    for(int j=0;j<N;++j) {
      can = true;
      for(int k=31;k>S[i];--k) {
        if((K&(1<<k))==0 && (A[j]&(1<<k))!=0) can = false;
      }
      if((A[j]&(1<<S[i]))!=0) can = false;
      if(can) tmpans += B[j]; 
    }
    ans = max(ans, tmpans);
  }
  tmpans = 0;
  for(int i=0;i<N;++i) {
    can = true;
    for(int j=31;j>=0;--j) {
      if((K&(1<<j))==0 && (A[i]&(1<<j))!=0) can = false;
    }
    if(can) tmpans += B[i];
  }
  ans = max(ans, tmpans);
  cout<<ans<<endl;
}



Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

struct UnionFind {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> Size;
    UnionFind(ll n) {
        init(n);
    }
 
    void init(ll n) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        rep0(i, n + 1){
            par[i] = i;
            rank[i] = 0;
            Size[i] = 1;
        }
    }
 
    ll root(ll x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
 
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
 
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }
 
    ll size(ll x){
        return Size[root(x)];
    }
};

//modの値の確認をすること
int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind u(n);
    vector<ll> p(n);
    rep0(i, n){
        cin >> p[i];
        --p[i];
    }
    rep0(i, m){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        u.merge(a, b);
    }
    ll ans = 0;
    rep0(i, n)if(u.same(p[i], i))++ans;
    pf(ans);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n;
  cin >> n;

  pr(n*(1+n)/2);


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;


int main() {
	string a, b;
	cin >> a >> b;
	if (a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

}

Measured memory_bytes: 3576