akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

const int MAX_N = 50;
int N, M;
bool Graph[MAX_N + 1][MAX_N + 1];
bool visited[MAX_N + 1]; 
int dfs(int v){
    visited[v] = true;
    for(int v2 = 0; v2 < N; v2++){
        if(Graph[v][v2] == false)continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}
int main(){
    cin >> N >> M;
    vector<int> a(M), b(M);
    rep(i, M){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        Graph[a[i]][b[i]] = Graph[b[i]][a[i]] = true;
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        Graph[a[i]][b[i]] = Graph[b[i]][a[i]] = false;
        rep(i, N) visited[i] = false;
        dfs(0);
        bool bridge = false;
        rep(i, N)if(visited[i] == false)bridge = true;
        if(bridge)ans++;
        Graph[a[i]][b[i]] = Graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.PriorityQueue

data class Edge(val from: Int, val to: Int, val cost: Long)

data class State(val v: Int, val cost: Long)

fun compareState(s1: State, s2: State): Int {
  if (s1.cost > s2.cost) return 1
  if (s1.cost < s2.cost) return -1
  return 0
}

fun shortestPath(graph: Array<MutableList<Edge>>, s: Int): LongArray {
  val n = graph.size
  // Dijkstra from s
  // Kotlin 1.0 workaround.
  val pq = PriorityQueue<State>(11, { s1: State, s2: State -> compareState(s1, s2) })
  val dist = LongArray(n, { Long.MAX_VALUE })
  dist[s] = 0
  pq.add(State(s, 0L))
  while (pq.isNotEmpty()) {
    val state = pq.poll()!!
    if (dist[state.v] < state.cost) continue
    for (e in graph[state.v]) {
      if (state.cost + e.cost < dist[e.to]) {
        dist[e.to] = state.cost + e.cost
        pq.add(State(e.to, state.cost + e.cost))
      }
    }
  }
  return dist
}

fun main(args: Array<String>) {
  val (n, m, sRaw, tRaw) = readLine()!!.split(" ").map { it.toInt() }
  val s = sRaw - 1
  val t = tRaw - 1
  val aGraph = Array(n, { mutableListOf<Edge>() })
  val bGraph = Array(n, { mutableListOf<Edge>() })
  repeat(m) {
    val (uRaw, vRaw, a, b) = readLine()!!.split(" ").map { it.toInt() }
    val u = uRaw - 1
    val v = vRaw - 1
    aGraph[u].add(Edge(u, v, a.toLong()))
    aGraph[v].add(Edge(v, u, a.toLong()))
    bGraph[u].add(Edge(u, v, b.toLong()))
    bGraph[v].add(Edge(v, u, b.toLong()))
  }
  val distArrayA = shortestPath(aGraph, s)
  val distArrayB = shortestPath(bGraph, t)
  val costs = mutableListOf<Long>()
  var currentCost = Long.MAX_VALUE
  for (i in n - 1 downTo 0) {
    currentCost = Math.min(currentCost, distArrayA[i] + distArrayB[i])
    costs.add(currentCost)
  }
  costs.reverse()

  val output = StringBuilder()
  for (cost in costs) {
    output.append(1000000000000000L - cost)
    output.append('\n')
  }
  print(output)
}

Measured memory_bytes: 112452
r, c = map(int, input().split())

table = []
for i in range(r):
    array = list(map(int, input().split()))
    table.append(array)

ans = 0
for i in range(r):
    for j in range(c):
        print('{} ' .format(table[i][j]), end='')
        ans += table[i][j]
    print(ans)
    ans = 0

total = 0
for i in range(c):
    for j in range(r):
        ans += table[j][i]
    print('{} ' .format(ans), end='')
    total += ans
    ans = 0
print(total)


Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np


D = int(input())
c = np.array(list(map(int, input().split())))
S = np.array([list(map(int, input().split())) for i in range(D)])

last_day = np.zeros(26, dtype=int)
score = 0

T = [int(input()) for i in range(D)]

ans = []
for d, t in enumerate(T, 1):
    last_day[t-1] = d
    decrease = c * (d - last_day)
    score += S[d-1, t-1] - decrease.sum()
    ans.append(score)

print(*ans, sep='\n')

Measured memory_bytes: 27280
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         double a=gd();
         double b=gd();
         double x=gd();

         double d=0;;
         if(a*a*b/2<x) {
        	 d=Math.atan((2*a*a*b-2*x)/(a*a*a));
         } else {
        	 d=Math.atan(a*b*b/(2*x));
         }

         System.out.println(d*180/Math.PI);
     }


     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

const int mxN = 2e5 + 5;
int pointer[mxN];
bool visited[mxN];

int main() {
	int n;
	cin >> n;
	long long k;
	cin >> k;
	++k;
	for(int i = 1, x; i <= n; ++i)
		scanf("%d", &x), pointer[i] = x;
	vector<int> path;
	int d = 1;
	while(!visited[d] && --k) {
		path.push_back(d);
		visited[d] = true;	
		d = pointer[d];
	}
	if(!k)
		return cout << d, 0;
	long long last = -1;
	for(int i = 0; i < (int)path.size(); ++i) {
		if(path[i] == d) {
			last = i;
			break;
		}
	}
	--k;
	long long moves = k % (path.size() - last);
	cout << path[last + moves] << '\n';
}


Measured memory_bytes: 4876
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

string X, Y;
int dp[1001][1001];

int max3(int a, int b, int c){
    return Max2(a, (Max2(b, c)));
}

int lcs(){
    int lenX = (int)X.length();
    int lenY = (int)Y.length();
    Rep(i, 0, lenX + 1) Rep(j, 0, lenY + 1) dp[i][j] = 0;
    Rep(i, 0, lenX){
        Rep(j, 0, lenY){
            dp[i + 1][j + 1] = max3(dp[i][j] + (X[i] == Y[j]), dp[i][j + 1], dp[i + 1][j]);
        }
    }
    return dp[lenX][lenY];
}

int main(){
    int q;
    cin >> q;
    Rep(i, 0, q){
        cin >> X >> Y;
        cout << lcs() << endl;
    }
    return 0;
}


Measured memory_bytes: 7088
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na,nb = [0],[0]
for i in range(n):
  na.append(na[i]+a[i])
for j in range(m):
  nb.append(nb[j]+b[j])
ans = 0
l = m
for i in range(n+1):
  if na[i] > k:
    break
  while nb[l] > k - na[i]:
    l -= 1
  ans = max(ans,i+l)
print(ans)

Measured memory_bytes: 47480
DY = [-1, 0, 1, 0, -1, -1, 1, 1]
DX = [0, 1, 0, -1, -1, 1, 1, -1]

def lake_count(y, x, map, checked)
  return if checked[y][x]
  checked[y][x] = true

  8.times do |i|
    ny = y + DY[i]
    nx = x + DX[i]

    next if ny < 0 || nx < 0 || $h <= ny || $w <= nx
    next if map[ny][nx] == 0
    lake_count(ny, nx, map, checked)
  end
end

loop do
  $w, $h = gets.chomp.split.map(&:to_i)
  break if $w == 0 && $h == 0
  map = []

  $h.times do
    map << gets.chomp.split.map(&:to_i)
  end

  ans = 0
  checked = Array.new($h) { Array.new($w, false) }

  $h.times do |y|
    $w.times do |x|
      next if map[y][x] == 0 || checked[y][x]
      ans += 1
      lake_count(y, x, map, checked)
    end
  end

  puts ans
end



Measured memory_bytes: 12628
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 19 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        HashMap<Integer, Integer> hmap = new HashMap<>();
        hmap.put(1, 0);
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine(), " ");
        int a;
        for (int i = 2; i <= n; i++){
            hmap.put(i, 0);
            a = Integer.parseInt(st.nextToken());
            hmap.replace(a, hmap.get(a)+1);
        }
        br.close();

        for (int j = 1; j <= n; j++) {
            System.out.println(hmap.get(j));
        }
    }
}


Measured memory_bytes: 81632
import heapq

def solve():
  k, t = list(map(int, input().split()))
  a = list(map(int, input().split()))
  
  q = []
  
  for i in range(len(a)):
    if a[i] != 0:
      heapq.heappush(q, (-a[i], i))
  
  count, i = heapq.heappop(q)
  count += 1
  keep = (count, i)

  while len(q) > 0:
    count, i = heapq.heappop(q)
    count += 1
    
    if keep[0] < 0:
      heapq.heappush(q, keep)
    keep = (count, i)
  
  print(- keep[0])
  return

if __name__ == "__main__":
  solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

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

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for(int i = 1; i < n; i++) {
        ans += max((int)0 , a[i-1]-a[i]);
        if(a[i-1] > a[i]) a[i] = a[i-1];
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, 0, N) cin >> h[i];

    vector<ll> dp(N, INT64_MAX);
    dp[0] = 0;
    
    rep(i, 0, N -1)
    {
        rep(k, 1, K + 1)
        {
            if (i + k < N) dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
        }    
    }

    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1408
n,m=map(int,input().split())
coins=list(map(int,input().split()))
DP = [n for i in range(n + 1)]
DP[0]=0
for c in coins:
    for i in range(c, n + 1):
        DP[i] = min(DP[i], DP[i - c] + 1)
print(DP[n])


Measured memory_bytes: 7640
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  if (k == 1) {
    cout << "OK" << endl;
    return 0;
  }
  if (a % k == 0 || b % k == 0) {
    cout << "OK" << endl;
    return 0;
  }
  a = a / k;
  b = b / k;
  if (a < b)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  return 0;
}
//
// #include <iostream>
// using namespace std;
// int main() {
//   int c[5002];
//   int n, a;
//   c[0] = 1;
//   c[1] = a;
//   int di = 1;
//   int num = 0;
//   cin >> a >> n;
//   for (int i = 1; i <= n; i++) {
// for (int j = 0; j < di; j++) {
//   num = c[j] * a + num;
//   c[j] = num % 10;
//   num = num / 10;
// }
// while (num) {
//   c[di] = num % 10;
//   num = num / 10;
//   di++;
// }
//   }
//   for (int i = di - 1; i >= 0; i--) {
// cout << c[i];
//   }
//   return 0;
// }

Measured memory_bytes: 3624
N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))


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


int main(){
	int N,H,W;cin>>N>>H>>W;
	int cnt = 0;
	for(int i=0;i<N;i++){
		int a,b;cin>>a>>b;
		if(a >= H && b >= W) cnt += 1;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
 #define S second
#define PB push_back
#define MP make_pair
#define ll long long int

#define PI 3.14159


using namespace std;

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

	
	int n, m;
	
	cin >> n >> m;
	
	
	int A[m];
	
	for(int i = 0 ; i < m ; i++) cin >> A[i];
	
	ll sum = 0;
	for(int i = 0 ; i < m; i++)
	{
		sum += A[i];
	}
	
	if(sum <= n) cout << n - sum << "\n";
	else cout << -1 << "\n";
	
	
return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll ans = 0;
  for (ll d = 0; d < N; d++)
  {
    ll tmp = 0;
    for (ll i = 0; i < N - d; i++)
    {
      if (S.at(i) == S.at(i + d))
        tmp++;
      else
        tmp = 0;
      
      chmax(ans, min(d, tmp));
    }
  }

  cout << ans << endl;
}

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

int n, root;
int a[200005], l[200005], r[200005];
vector<int> e[200005];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
void dfs(int u, int fa) {
    if (e[u].size() == 1) return l[u] = r[u] = a[u], void();
    int mxl = 0, suml = 0, sumr = 0;
    for (int i = 0, v; i < e[u].size(); ++i)
        if ((v = e[u][i]) != fa)
            dfs(v, u), suml += l[v], sumr += r[v], mxl = max(mxl, l[v]);
    l[u] = max(0, 2 * a[u] - sumr), r[u] = min(2 * a[u] - sumr, a[u]);
    if (l[u] > r[u] || a[u] < mxl) puts("NO"), exit(0);
}

int main() {
    n = read();
    for (int i = 1; i <= n; ++i) a[i] = read();
    if (n == 2) return puts(a[1] == a[2] ? "YES" : "NO"), 0;
    for (int i = 1, u, v; i < n; ++i) u = read(), v = read(), add(u, v);
    for (int i = 1; i <= n; ++i)
        if (e[i].size() > 1) root = i;
    dfs(root, 0), puts(l[root] ? "NO" : "YES");
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


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

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

  int A, B, C;
  cin >> A >> B >> C;
  int go = 0, nana = 0;
  if(A == 5){
    go++;
  }
  if(A == 7){
    nana++;
  }
    if(B == 5){
    go++;
  }
  if(B == 7){
    nana++;
  }
    if(C == 5){
    go++;
  }
  if(C == 7){
    nana++;
  }
  if(go == 2 && nana == 1){
    cout << "YES"<<endl;
  } else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

#define mod 1000000007;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	long long int n, k;
	cin >> n >> k;
	long long int sum = 0, min = 0,max = 0;
	for (long long int i = 0; i <= n; i++) {
		min += i;
		max += n - i;
		if (i + 1 >= k) {
			sum += max - min + 1;
			sum %= mod;
		}
	}
	
	cout << sum << endl;








	return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int N, K;
    char S[50];
    cin >> N >> K >> S;
    S[K - 1] += 32;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int a,b,c,i,x;
	
	int ans=0;
	
	scanf("%d %d %d\n",&a,&b,&c);
	
	for( i=a ; i<=b ; i++ ){

	
		if( (c%i) == 0 ){
			
			ans++;
		
		}else{
			
		}	
		
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, M; cin >> N >> M;
    int dp[100010] = {0};
    for (int i = 0; i < M; i++) {
        int a; cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        if (dp[i] == -1) continue;
        if (dp[i+1] != -1) dp[i+1] += dp[i];
        if (dp[i+2] != -1) dp[i+2] += dp[i];
        dp[i+1] %= MOD;
        dp[i+2] %= MOD;
    }
    cout << dp[N] << endl;
}   


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	int n; cin >> n;
	rep(i, 10) {
		rep(j, 10) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a<<" "<<b<<" "<<3*c-a-b;
	cout<<endl;
	cout<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c;
	cout<<endl;
	cout<<a+b-c<<" "<<3*c-b-c<<" "<<2*c-a;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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
















int main(){
    ll a, b;
    cin >> a >> b;
    for(ll i = 1; i <= 50000; i++){
        if((ll)((double)i * 0.08) == a && (ll)((double)i * 0.10) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
int main(void){
	
	int k;
	int num[3];
	scanf("%d %d %d",&num[0],&num[1],&num[2]);
	scanf("%d",&k);
	qsort(num,3,sizeof(int),desc);
	int d = pow(2,k);
	printf("%d\n",num[0]*d+num[1]+num[2]);
	return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<string> s;
    int n;
    cin >> n;
    REP(i,n){
        string si;
        cin >> si;
        s.insert(si);
    }
    cout << (int)s.size() << endl;

    return 0;
}

Measured memory_bytes: 19168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 10000000000
int n, w;
vector<ll> dp(100010, 0);
vector<pair<ll, ll> > elems;  // weight, value
ll a, b;
int main()
{
    cin >> n >> w;
    while(n--)
    {
        cin >> a >> b; // weight, value
        elems.push_back({a, b});
    }
        
    
    for (pair<ll, ll> elem: elems)
    {
        //for (int i = 0; i + elem.first <= w; ++i) (Knapsack with repetitions)
        for (int i = w - elem.first; i >= 0; --i)
        {
            dp[i+elem.first] = max(dp[i+elem.first], dp[i] + elem.second);
        }
    }
    cout << dp[w] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)


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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n),dp(n);
	rep(0, n) {
		cin >> a[i];
		dp[i] = -1;
	}
	dp[0] = 0;
	rep(1, n) {
		if (i == 1) {
			dp[i] = abs(a[1] - a[0]);
		}
		else {
			dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
		}
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int main(){
  int a,b; cin>>a>>b;
  int ans=a+b/2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
inf = 10**9+7

inv_t = [0]+[1]
for i in range(2,n+1):
    inv_t += [inv_t[inf % i] * (inf - int(inf / i)) % inf]
    
bik =  [1]+[1]
for i in range(2,n+1):
    bik += [(bik[i-1]*i)% inf]
    
bik_inv =  [1]+[1]
for i in range(2,n+1):
    bik_inv += [(bik_inv[i-1]*inv_t[i])% inf]

def conv(l,r):
    if l>=r:
        up = bik[l]
        lo = bik_inv[l-r]*bik_inv[r]
        return up*lo
    else:
        return 0

for i in range(1,k+1):
    """print("#########")
    print(i)
    print(conv(n-k+1,i))
    print(conv(k-1,i-1))"""
    print((conv(n-k+1,i)*conv(k-1,i-1))%inf)

Measured memory_bytes: 42864
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        System.out.println(op.equals("+") ? a + b : a - b);
    }
}

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

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

    vector<vector<long long int> > dp(N+1, vector<long long int>(21));
    int now;
    cin >> now;
    dp[1][now] = 1LL;
    for (int i = 1; i < N; i++) {
        cin >> now;
        for (int j = 0; j <= 20 ; j++) {
            if (j + now <= 20) dp[i+1][j+now] += dp[i][j];
            if (j - now > -1) dp[i+1][j-now] += dp[i][j];
        }
    }

    cout << dp[N][0] << endl;

    return 0;
}

Measured memory_bytes: 3168
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let abm : Vec<i64> = get_vec();
    let (a,b,m) = (abm[0], abm[1], abm[2]);
    let a : Vec<i64> = get_vec();
    let b : Vec<i64> = get_vec();
    let mut ans = a.iter().min().unwrap() + b.iter().min().unwrap();
    for _i in 0..m {
        let xyc : Vec<u64> = get_vec();
        let (x,y,c) = (xyc[0] as usize, xyc[1] as usize, xyc[2] as i64);
        let tmp = a[x-1] + b[y-1] - c;
        ans = std::cmp::min(ans, tmp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;

int digit(ll n){
    return to_string(n).size();
}

int main(){
    cin >> N;
    int ans=INF;
    for(ll i=1;i*i<=N;i++){
        if(N%i) continue;
        ll A = i;
        ll B = N/i;
//        cout << A << " " << B << endl;
        ans=min(ans,max(digit(A),digit(B)));
    }
    cout << ans << endl;
}


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

char S[ 200010 ];

int main()
{
int i;
int iCnt;
long long iSum;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;

	i = 0;
	iSum = 0;
	iCnt = 0;
	while( C = S[ i++ ] )
	{
		if( C == 'W' )
		{
			iCnt++;
			iSum += ( i - iCnt );
		}
	}

	
	cout << iSum << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

void dfs(int H,int i,vb v,vvb &Hv) {
  if(i==H) {
    Hv.push_back(v);
    return;
  }
  dfs(H,i+1,v,Hv);
  v[i]=true;
  dfs(H,i+1,v,Hv);
}

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vvc c(H,vc(W));
  rep(i,H) {
    rep(j,W) cin >> c[i][j];
  }
  
  vvb Hv,Wv;
  dfs(H,0,vb(H),Hv);
  dfs(W,0,vb(W),Wv);
  
  int ans=0;
  rep(i,Hv.size()) {
    rep(j,Wv.size()) {
      int count=0;
      rep(h,H) {
        rep(w,W) {
          if(!Hv[i][h]&&!Wv[j][w]&&c[h][w]=='#') count++;
        }
      }
      if(count==K) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <cstring>
using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string s;

void solve(){
	llint n;
	cin >> n;
	llint dp[n+1];
	memset(dp,0,sizeof(dp));
	for(llint i=1;i<=n;i++){
		llint t=i;
		for(llint j=2;j<=n;j++){
			while(t%j==0){
				dp[j]++;
				t/=j;
			}
		}
	}
	llint ans=1;

	for(llint i=0;i<=n;i++)(ans*=dp[i]+1)%=mod;
	cout << ans << endl;
}

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


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, m;
    int a[100000];
    cin >> n >> m;
    for (int i = 0; i < m; i++)
        cin >> a[i];

    set<int> s;
    for (int i = 0; i < m; i++)
        s.insert(a[i]);

    int dp[100001] = {1, 1};
    for (int i = 2; i <= n; i++)
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;

    // for (int i = 0; i <= n; i++)
    //     cout << dp[i] << " ";
    // cout << endl;

    int pr = INF;
    bool f = true;
    vector<int> v;
    // {0, n};
    for (auto itr = s.begin(); itr != s.end(); itr++)
    {
        v.push_back(*itr);
        if (*itr - pr == 1)
            f = false;
        pr = *itr;
    }
    sort(all(v));
    unsigned long long ret = 1;
    if (!f)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        if (v.size() == 0)
            ret = dp[n];
        else if (v.size() == 1)
            ret = (dp[v[0] - 0 - 1] * dp[n - v[0] - 1]) % MOD;
        else
        {
            // cout << v[0] - 1 << endl;
            // cout << n - v[v.size() - 1] - 1 << endl;
            ret = (ret * dp[v[0] - 0 - 1]) % MOD;
            ret = (ret * dp[n - v[v.size() - 1] - 1]) % MOD;
            for (int i = 1; i < v.size(); i++)
            {
                // cout << v[i] - v[i - 1] - 2 << endl;
                ret = (ret * dp[v[i] - v[i - 1] - 2]) % MOD;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 7672
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(ll, N, M, X, Y);
	in_v(ll, x, N);
	in_v(ll, y, M);
	x.push_back(X);
	y.push_back(Y);
	bool OK = (*std::max_element(x.begin(), x.end())) < (*std::min_element(y.begin(), y.end()));
	out(OK?"No War":"War");
}

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

int main() {
    string s;
    int k;
    cin >> s >> k;
    int len = s.size();

    for (int i = 0; i < len - 1; i++) {
        int d = (26 - (s.at(i) - 'a')) % 26;
        if (d <= k) {
            s.at(i) = 'a';
            k -= d;
        }
    }
    s.at(len - 1) = 'a' + (s.at(len - 1) - 'a' + k) % 26;
    cout << s << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  string s,t;
  cin >> s >> t;
  reverse(all(s));
  reverse(all(t));
  rep(i,200-s.size()) s.push_back('0');
  rep(i,200-t.size()) t.push_back('0');
  reverse(all(s));
  reverse(all(t));
  if (s>t) cout << "GREATER" << endl;
  else if (s<t) cout << "LESS" << endl;
  else cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split()))

for i in range(n, 0, -1):
    a[i] = sum(a[i::i]) % 2
print(sum(a))
for i in range(1, n + 1):
    if a[i] == 1:
        print(i)


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

int main(){
    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(i==0 && j==0)cout<<c[i][j];
            else if(i==1 && j==1)cout<<c[i][j];
            else if(i==2 && j==2)cout<<c[i][j];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,sw,m,n:Integer;
  s123,s1,s2,s3,a,b:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(a);
    Readln(b);

    if Length(a)>Length(b) then begin
      Writeln('GREATER');
      Readln;
      exit;
    end else if Length(a)<Length(b) then begin
      Writeln('LESS');
      Readln;
      exit;
    end;

    for i := 1 to Length(a) do begin
      if StrToInt(a[i])>StrToInt(b[i]) then begin
        Writeln('GREATER');
        Readln;
        exit;
      end else if StrToInt(a[i])<StrToInt(b[i]) then begin
        Writeln('LESS');
        Readln;
        exit;
      end;
    end;
    Writeln('EQUAL');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL)

const ll modd=1e9+7;
const ll inff=1e18;

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

/*-----------------------------------------------------------------------------------------------*/

int main(){
  fastt;
   
  ll n;
  cin >> n;

  ll ans = 0;

  for(ll i = 1; i <= n; i++){
      ll x;
      cin >> x;
      if(i%2 == 1 && x%2 == 1) ans++;
  }

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

Measured memory_bytes: 3644
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;

void solve() {
    int N;
    R(N);
    VI A(N);
    REP(i, N) {
        R(A[i]);
    }
    LL ans = 0;
    REPP(i, 1, N) {
        if (A[i] < A[i-1]) {
            ans += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    W(ans);
}

int main() {
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;


int n;
int a[3][maxn];

int cnt[2][maxn];

int main()
{
	//IOS;
	cin>>n;
	REP(i,3) REP(j,n) cin>>a[i][j];
	
	REP(i,3) sort(a[i],a[i]+n);
	
	int x=-1,y=0;
	
	ll ans=0;
	
	for(int i=0;i<n;i++){
		int tmp=lower_bound(a[0],a[0]+n,a[1][i])-a[0]-1;
		int tmp2=upper_bound(a[2],a[2]+n,a[1][i])-a[2];
		debug(tmp,tmp2);
		ans+=1LL*(tmp+1)*(n-tmp2);
	}
	
	cout<<ans;
	return 0;
}












Measured memory_bytes: 1408
m,k = map(int,input().split())
if m == 0:
    if k == 0:
        print(0,0)
    else:
        print(-1)
    exit()
if m == 1:
    if k== 0:
        print(0,0,1,1)
    else:
        print(-1)
    exit()
if k < 2**m:
    l = [i for i in range(2**m) if i != k ]
    l = l + [k] + l[::-1] + [k]
    print(*l)
else:
    print(-1)

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

int32_t main()
{
    string a, b, c;
    map<string, int> mapa;
    int x, y;
    cin >> a >> b >> x >> y;
    mapa[a] = x;
    mapa[b] = y;
    cin >> c;
    mapa[c]--;

    cout << mapa[a] << ' ' << mapa[b] << '\n';    
    

	return 0;
}

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

int main(void){
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    int ans = 0;
    for(int i = 0;i < m;i++)cin >> b[i];
    for(int i = 0;i < n;i++){
        int sum = 0;
        for(int j = 0;j < m;j++){
            int a;
            cin >> a;
            sum += a*b[j];
        }
        sum += c;
        if(sum > 0)ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] line = scanner.nextLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);

        long result = 0;

        if(Math.abs(n-m) > 1){
            result = 0;
        } else if(Math.abs(n-m) == 1){
            result = factorialsModBillion(n, m);
        } else {
            result = factorialsModBillion(n, m);
            result = (result * 2) % 1000000007L;
        }

        System.out.println(result);
    }

    private static long factorialsModBillion(int n, int m){
        long result = 1;
        for(long i = 1; i <= n; i++) {
            result = (result * i) % 1000000007L;
        }
        for(long i = 1; i <= m; i++) {
            result = (result * i) % 1000000007L;
        }
        return result;
    }
}


Measured memory_bytes: 23892
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

int main(){
  int N;
  cin >> N;
  ll ans = 0;
  rep(i, 4){
    if(N % 10 == 2) ans++;
    N /= 10;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s=input()[:-1]
n=len(s)
ans=0
for i in range(n):
    t_str=s[:i+1]
    l=len(t_str)
    if l%2==0:
      if t_str[:(l//2)]==t_str[(l//2):l+1]:
          ans=max(ans,l)
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iH = int.Parse(sS[1]);
            int iW = int.Parse(sS[2]);
            List<ClsPlt> lstPlt = new List<ClsPlt>();
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                ClsPlt oneUsr = new ClsPlt();
                oneUsr.iA = int.Parse(sS[0]);
                oneUsr.iB = int.Parse(sS[1]);
                lstPlt.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < lstPlt.Count; i++)
            {
                if (lstPlt[i].iA >= iH && lstPlt[i].iB >= iW) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 板
        private class ClsPlt
        {
            public int iA { get; set; } = 0;                    // 縦
            public int iB { get; set; } = 0;                    // 横
        }

}


Measured memory_bytes: 13376