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

using namespace std;

int v,e;
const int MAX_V=10005;

vector<int> rinsetu[MAX_V];
bool visited[MAX_V];
vector<int> ans;

void dfs(int u){
    visited[u]=true;
    for(auto itr=rinsetu[u].begin();itr!=rinsetu[u].end();itr++){
        if(!visited[*itr]){
            dfs(*itr);
        }
    }
    ans.push_back(u);
}

void topological_sort(){
    for(int i=0;i<v;i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    reverse(ans.begin(),ans.end());
}

int main(){
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        rinsetu[s].push_back(t);
    }
    for(int i=0;i<v;i++){
        visited[i]=false;
    }
    topological_sort();
    for(auto itr=ans.begin();itr!=ans.end();itr++){
        cout<<*itr<<endl;
    }
    return 0;
}



Measured memory_bytes: 3808
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	if(n/100==7||n/10%10==7||n%10==7)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
def solve(line):

    w=line[0]
    h=line[1]
    x=line[2]
    y=line[3]
    r=line[4]
    if ( r <= x and x <= w - r ) and ( r <= y and y <= h - r ) :
        print("Yes")
    else:
        print("No")
 

def answer():
    s = input().split()
    line = list(map(int, s))
    
    solve(line)

if __name__ =='__main__':
    answer()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
	long x=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		x+=(s[i]-'0');
	}
	if(x%9==0) puts("Yes");
	else puts("No");
	return 0;
} 

Measured memory_bytes: 3720
#include <stdio.h>

int main(void) {
  int i, j, k;
  int n, m, l;
  scanf("%d %d %d", &n, &m, &l);
  int a[n + 1][m + 1], b[m + 1][l + 1];
  long long int c[n + 1][l + 1];

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (i = 0; i < m; i++) {
    for (j = 0; j < l; j++) {
      scanf("%d", &b[i][j]);
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      c[i][j] = 0;
    }
  }



  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      for(k = 0; k < m; k++)
        c[i][j] += a[i][k] * b[k][j];
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      if (j == l - 1) {
        printf("%lld\n", c[i][j]);
      } else {
        printf("%lld ", c[i][j]);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2124
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string sa, sb, sc; cin >> sa >> sb >> sc;

    int ia = 0, ib = 0, ic = 0;
    char cur = 'a';
    while (true) {
        if (cur == 'a') {
            if (ia == sa.size()) {
                cout << "A" << endl;
                return 0;
            }
            cur = sa[ia];
            ia++;
        } else if (cur == 'b') {
            if (ib == sb.size()) {
                cout << "B" << endl;
                return 0;
            }
            cur = sb[ib];
            ib++;
        } else {
            if (ic == sc.size()) {
                cout << "C" << endl;
                return 0;
            }
            cur = sc[ic];
            ic++;
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int H, W, D;
  scanf("%d%d%d", &H, &W, &D);
  VPII co(H*W+1);
  REP(i, H) REP(j, W)
  {
    int A;
    scanf("%d", &A);
    co[A] = PII(i, j);
  }
  VVI mp(D, VI());
  REP(i, D)
  {
    int s = i;
    if (i == 0) s = D;
    int y, x, yy, xx;
    int idx = 0;
    while(s <= H*W)
    {
      if (idx == 0) mp[i].push_back(0);
      else
      {
        y = co[s-D].first; x = co[s-D].second;
        yy = co[s].first; xx = co[s].second;
        mp[i].push_back(mp[i][idx-1] + abs(yy-y) + abs(xx-x));
      }
      s += D;
      idx++;
    }
  }
  int Q;
  scanf("%d", &Q);
  REP(q, Q)
  {
    int L, R;
    scanf("%d%d", &L, &R);
    printf("%d\n", mp[L%D][(R-1)/D] - mp[L%D][(L-1)/D]);
  }

  return 0;
}

Measured memory_bytes: 6016
import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int H = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    int[] sx = {-1, 0, +1, 0};
    int[] sy = {0, +1, 0, -1};
    
    char[][] c = new char[H][W];
    for(int i = 0; i < H; i++){
      c[i] = sc.nextLine().toCharArray();
    }
    
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        boolean check = true;
        if(c[i][j] == '#'){
          for(int k = 0; k < 4; k++){
            if(i + sx[k] >= 0 && i + sx[k] < H && j + sy[k] >= 0 && j + sy[k] < W){
              if(c[i + sx[k]][j + sy[k]] == '#'){
                check = false;
              }
            }
          }
          if(check){
            System.out.println("No");
            System.exit(0);
          }
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int k, x; scanf("%d%d", &k, &x);
	
	for(int i = x - k + 1; i < x + k; i++) printf("%d ", i);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int a, b, c, d, x;

int main()
{
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}

	if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        h = [I() for _ in range(n)]
        hm = max(h)
        m = I()
        ms = []
        ma = []
        zf = False
        for _ in range(m):
            nama,mp,target,damege = LS()
            mp = int(mp)
            damege = int(damege)
            if damege == 0:
                continue
            if mp == 0:
                zf = True
                continue
            if target == 'All':
                ma.append((mp,damege))
            else:
                ms.append((mp,damege))
        if zf:
            return 0
        ds = [inf] * (hm+1)
        ds[0] = 0
        for mp, dm in ms:
            for i in range(dm,hm+1):
                if ds[i] > mp + ds[i-dm]:
                    ds[i] = mp + ds[i-dm]
            if dm < 2:
                continue
            t = min(ds[-dm+1:])
            if ds[-1] > t + mp:
                ds[-1] = t + mp

        da = [inf] * (hm+1)
        da[0] = 0
        for mp, dm in ma:
            for i in range(dm,hm+1):
                if da[i] > mp + da[i-dm]:
                    da[i] = mp + da[i-dm]
            if dm < 2:
                continue
            t = min(da[-dm+1:])
            if da[-1] > t + mp:
                da[-1] = t + mp
        for i in range(hm-1,-1,-1):
            if ds[i] > ds[i+1]:
                ds[i] = ds[i+1]
            if da[i] > da[i+1]:
                da[i] = da[i+1]
        mm = r = inf
        for i in range(hm,-1,-1):
            if mm <= da[i]:
                continue
            mm = tp = da[i]
            for hi in h:
                if hi > i:
                    tp += ds[hi-i]
            if r > tp:
                r = tp
        return r

    while True:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 13760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main() {
  int n;
  cin >> n;
  map<string, int> strings;
  string s;
  for (int i=0; i<n; i++) {
    cin >> s;
    strings[s] += 1;
  }


  int maxv = 0;
  for (auto it : strings) {
    int v = it.second;
    chmax(maxv, v);
  }
  for (auto it : strings) {
    if (it.second == maxv) {
      cout << it.first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 25216
import numpy as np

H, W = map(int, input().split())

S = np.ones([H+2, W+2], dtype=bool)
for h in range(H):
  S[h+1] = np.array(['.'] + list(input()) + ['.']) == '.'

dp1 = np.zeros([H+2, W+2, 2], dtype=int) # [up, left]
for h in range(H):
  dp1[h+1, :, 0] = (dp1[h, :, 0] + 1)*S[h+1]

for w in range(W):
  dp1[:, w+1, 1] = (dp1[:, w, 1] + 1)*S[:, w+1]

dp2 = np.zeros([H+2, W+2, 2], dtype=int) # [down, right]
for h in range(H, 0, -1):
  dp2[h, :, 0] = (dp2[h+1, :, 0] + 1)*S[h]

for w in range(W, 0, -1):
  dp2[:, w, 1] = (dp2[:, w+1, 1] + 1)*S[:, w]

print(np.max((np.sum(dp1, axis=2)+np.sum(dp2, axis=2))[1:-1, 1:-1])-3)

Measured memory_bytes: 235604
#include <stdio.h> 

int main(){
	double w,h,x,y;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	if(x==w/2.0 && y == h/2.0){
		printf("%lf 1",0.5*w*h);
	}
	else{
		printf("%lf 0",0.5*w*h);
	}
	return 0; 
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main(void){
	int  n, i, b, x, ans;
	int p[10000];
	scanf("%d", &n);
        b = 0;
        x=0;
	for (i = 0; i<n; i++){
            scanf("%d", &p[i]);  //ここまで配列の準備
            b =  b + p[i];
        }
       
        for(i = 0; i<n; i++){
            if(p[i]>=x){
                  x = p[i];
            }
        }
        x = x/2;
        ans = b-x;
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())

    #[行先, 距離]
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        l,r,d = map(int, input().split())
        adj[l-1].append([r-1, d])
        adj[r-1].append([l-1, -d])

    x = [inf]*n

    def bfs(v):
        if x[v]==inf:
            x[v] = 0
        d = deque([v])
        while d:
            v  = d.popleft()
            for nv, cost in adj[v]:
                if x[nv] == inf:
                    x[nv] = x[v] + cost
                    d.append(nv)
                else:
                    if x[nv] - x[v] != cost:
                        return False
        return True

    for v in range(n):
        if not bfs(v):
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 77312
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n;
	cin>>n;
	int c[501],s[501],f[501],ans;
	for(int i=0;i<n-1;i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	for(int i=0;i<n;i++){
		ans=0;
		for(int j=i;j<n-1;j++){
			if(ans<s[j])ans=s[j];
			else if(ans%f[j]==0);
			else ans+=f[j]-ans%f[j];
			ans+=c[j];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int sum = 0;
  if(a+b>2*c){
    if(x>y){
      sum=min(2*c*x,2*c*y+a*(x-y));
    }
    else{
      sum=min(2*c*y,2*c*x+b*(y-x));
    }
  }
  else{
    sum=a*x+b*y;
  }
  cout<<sum<<endl;
  return 0;
}




Measured memory_bytes: 256
using System;

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			int num = 0;
			var s = Console.ReadLine().ToCharArray();
			foreach (var item in s)
			{
				if (item == '1')
					num++;
			}
			Console.WriteLine(num);
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

typedef struct {
  int x,y;
}Points;

bool comp1(const Points&l, const Points&r) { return l.y < r.y; };
bool comp2(const Points&l, const Points&r) { return l.x > r.x; };
bool f1[110];
bool f2[110];

int main() {
  int N; cin >> N;
  vector<Points> red(N);
  vector<Points> blue(N);
  for ( int i = 0; i < N; i++ ) cin >> red[i].x >> red[i].y;
  for ( int i = 0; i < N; i++ ) cin >> blue[i].x >> blue[i].y;

  sort(red.begin(),red.end(),comp2);
  sort(blue.begin(),blue.end(),comp1);  
  int cnt1 = 0;
  // cout << endl;
  for ( int i = 0; i < N; i++ ) {
    // cout << red[i].x << " " << red[i].y << endl;
  }
    for ( int i = 0; i < N; i++ ) {
      for ( int j = 0; j <  N; j++ ) {

	if( red[j].x < blue[i].x && red[j].y < blue[i].y
	    && f1[i]== false && f2[j] == false ) {
	  f1[i] = true;
	  f2[j] = true;
	  //	cout <<  blue[i].x << " " << blue[i].y << " " << 
	  //  red[j].x << " " <<  red[j].y <<  endl;		  
	  //  cout << "f1[i]" << " " <<i << " " <<  f1[i] << endl;

	  cnt1++;
	}
      }
    }

/*
  sort(red.begin(),red.end(),comp2);
  sort(blue.begin(),blue.end(),comp2);

  int cnt2 = 0;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j <  N; j++ ) {
      if( red[i].x < blue[i].x && red[j].y < blue[j].y
	  && f2[i] == false ) {
	f2[i] = true;
	cnt2++;
      }
    }
  }  
*/		
//  cout << max(cnt1,cnt2) << endl;
cout << cnt1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> red,white;
    for(int i=0; i<n; i++) {
        if(s[i]=='R')
            red.pb(i);
        else white.pb(i);
    }
    int cnt=0, i=red.size()-1, j=0;
    while(i>=0 && j<(int)white.size() && (red[i] > white[j])) {
        cnt++;
        int rr = red[i], lw = white[j];
        swap(s[rr], s[lw]);
        i--;
        j++;
    }

    cout<<cnt;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 4768
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	string s="Impossible";
	cin >> a; cin >> b; cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	//if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)s = "Possible";
	cout << min(a+b,min(a+c,b+c)) << endl;
	
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,M=MI()
    nh=[0]*H
    nw=[0]*W
    
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(M):
        h,w=MI()
        h-=1
        w-=1
        dd[(h,w)]=1
        nh[h]+=1
        nw[w]+=1
        
    Mh=max(nh)
    Mw=max(nw)
    
    if Mh==0:
        print(Mw)
    elif Mw==0:
        print(Mh)
    else:
        ans=Mh+Mw-1#交差するところに爆弾があったと仮定する．なければあとで+1
        
        hh=[]
        ww=[]
        for i in range(H):
            if nh[i]==Mh:
                hh.append(i)
        
        for i in range(W):
            if nw[i]==Mw:
                ww.append(i)
                
        for h in hh:
            for w in ww:
                if dd[(h,w)]==0:
                    ans+=1
                    print(ans)
                    exit()
        print(ans)
                

main()


Measured memory_bytes: 167532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll x,y,a,b,c;
ll p[100010],q[100010],r[100010];
priority_queue<ll, vector<ll>, greater<ll>> P,Q;
ll ans=0;

int main(void){
	cin>>x>>y>>a>>b>>c;
	rep(i,a)cin>>p[i];
	rep(i,b)cin>>q[i];
	rep(i,c)cin>>r[i];
	sort(p,p+a);
	rep(i,x)P.push(p[a-1-i]);
	sort(q,q+b);
	rep(i,y)Q.push(q[b-1-i]);
	sort(r,r+c);
	irep(i,c){
		ll p=P.top(),q=Q.top();
		if(p<q){
			if(p<r[i]){
				P.pop();
				P.push(r[i]);
			}
		}else{
			if(q<r[i]){
				Q.pop();
				Q.push(r[i]);
			}
		}
	}
	rep(i,x){
		ans += P.top();
		P.pop();
	}
	rep(i,y){
		ans += Q.top();
		Q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4852
s = int(input())
a = []
a.append(s)

for i in range(1, 1000000, 1):
    if(a[i-1] % 2 == 0):
        a.append(a[i-1] / 2)
    else:
        a.append((3 * a[i-1]) + 1)
    for j in range(i-1, -1, -1):
        if(a[j] == a[i]):
            print(int(i+1))
            exit()


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int n,k,q,a;
	int pt[100000]={};
	scanf("%d%d%d", &n,&k,&q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &a);
		pt[a-1]++;
	}
	for (int i = 0; i < n; i++) {
		if(pt[i]-q+k>0){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 896
import sys
input = sys.stdin.readline

N = int(input())
C = [int(input()) for _ in range(N)]
mod = 10 ** 9 + 7

newC = []
while C:
    c = C.pop()
    if not newC or newC[-1] != c:
        newC.append(c)
N = len(newC)

seen = [0] * (2*10 ** 5 + 10)
dp = [0] * (N + 1)
dp[0] = 1
seen[newC[0]] = 1

for i, c in enumerate(newC[1:], start=1):
    cnt = seen[c]
    seen[c] = (seen[c] + dp[i - 1]) % mod
    dp[i] = (dp[i - 1] + cnt) % mod

ans = dp[N - 1]
print(ans)


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

int main(){
  int N,M;
  cin >>N>>M;
  vector<int> a(M);
  vector<string> b(M);
  for(int i=0;i<M;i++){
    cin >> a[i];
    cin >> b[i];
  }
  
  int ans1=0,ans2=0;
  vector<int> c(N,0);
  vector<int> d(N,0);
  for(int i=0;i<M;i++){
    if(b[i]=="WA"){
      if(!(c[a[i]-1])){
        d[a[i]-1]++;
      }
      else{
        continue;
      }
    }
    if(c[a[i]-1]){
      continue;
    }
    if(b[i]=="AC"){
      c[a[i]-1]=1;
      ans1++;
      ans2+=d[a[i]-1];
    }
  }
  cout << ans1 << ' ' << ans2 <<endl;
}

      
    
    
  

Measured memory_bytes: 7500
if __name__ == '__main__':
	N = int(input())
	S = input()

	listS = list(S)

	r = listS.count('R')
	g = listS.count('G')
	b = listS.count('B')

	ans = r*g*b

	for i in range(N-1):
		si = S[i]
		for j in range(i,N):
			sj = S[j]
			if si != sj:
				k = 2 * j - i
				if j < k and k < N:
					sk = S[k]
					if sk != si and sk != sj:
						ans -= 1

	print(ans)


Measured memory_bytes: 68152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

typedef long long ll;

using namespace std;

int main()
{ll N; cin >> N; 
 vector<string> A(N);
 for(ll i = 0; i < N; i++)
 {cin >> A[i];}
 
 ll m = 0;
 ll a = 0;
 ll r = 0;
 ll c = 0;
 ll h = 0;
 
 for(ll i = 0; i < N; i++)
 {if(A[i][0] == 'M'){m++;}
  else if(A[i][0] == 'A'){a++;}
  else if(A[i][0] == 'R'){r++;}
  else if(A[i][0] == 'C'){c++;}
  else if(A[i][0] == 'H'){h++;}
 }
 
 ll X = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  cout << X << endl;
 
 return 0;
}
 


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

int n,k;

signed main(){
  cin>>n>>k;
  int r=0;
  if (k==0)r=n*n;
  else
  for(int b=k+1;b<=n;b++){
    r+=(b-k)*(n/b)+(n%b-k+1 >= 0 ? n%b-k+1 : 0);
  }
  cout<<r;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

void hoge(int a,int b,int c,int d){
    cout<<a <<" "<<b<<" "<<c<<" "<<d<<endl;
}
int main(){
    LCIN(A);LCIN(B);LCIN(C);
    cout<<min({A*B*(C%2),A*C*(B%2),B*C*(A%2)})<<endl;;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int c,a,b;
  scanf("%d%d%d",&c,&a,&b);
  if (c>a && c>b){
    printf("%d\n",a*b/2);
  }
  if (a>c && a>b){
    printf("%d\n",c*b/2);
  }
  if (b>a && b>c){
    printf("%d\n",a*c/2);
  }
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Cost(int[] A, int n)
        {
            return A.Sum(a => (n - a) * (n - a));
        }
        static int Solve(int[] A)
        {
            int min = int.MaxValue;
            for (int i = -100; i <= 100; ++i) { min = Math.Min(Cost(A, i), min); }
            return min;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(A));
        }
    }
}


Measured memory_bytes: 13268
package main

import(
    "fmt"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := (a+b+1)/2
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int a,b,c,i,n,k[10000];
  while(scanf("%d",&n),n!=0){
    for(a=b=c=i=0;i<n;i++){
      scanf("%d",&k[i]);
      if(k[i]>1){ a=1; c++;}
       else b+=k[i]; 
    }
    if(a==0) printf("NA\n");
     else printf("%d\n",c+b+1);
  }
  return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
int n, m, a[200009], b[200009];
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i]; sort(a, a + n);
	cin >> m; for (int i = 0; i < m; i++)cin >> b[i]; sort(b, b + m);
	int cx = 0;
	for (int i = 0; i < m; i++) {
		while (cx < n && a[cx] < b[i])cx++;
		if (cx == n || a[cx] != b[i]) { cout << "NO" << endl; return 0; }
		cx++;
	}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int64> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

vi adj[maxn];

int dfs(int s, int p){
	int vis = 0, two = 0;

	for (int i = 0; i < (int)adj[s].size(); ++i){
		int u = adj[s][i]; if (u == p) continue;
		int tree = dfs(u, s);

		two |= tree & vis;
		vis |= tree;
	}

	if (two)
		two |= (1 << __lg(two)) - 1;

	int tmp = ~two & ~vis;
	int me = tmp & -tmp;
	vis |= me;
	vis &= ~( me - 1 );

	return vis;
}

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

	int n; cin >> n;

	for (int i = 1; i < n; ++i){
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	int ans = dfs(1, 1);
	cout << __lg(ans) << endl;


	return 0;
}



Measured memory_bytes: 10240
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i,a;
    ll color[8],t1=0,t2=0;
    for(i=0;i<8;i++){
        color[i]=0;
    }
    for(i=0;i<N;i++){
        cin >>a;
        if(a<3200)color[a/400]=1;else t2++;
    }
     for(i=0;i<8;i++){
        t1+=color[i];
    }
    cout << max(t1,(ll)1) <<" "<< t1+t2 <<endl;
    return 0;
}


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

int n;


int binary_search(vector<int> &a ,int k){
    int low , mid , high;
    low = 0;
    high = n - 1;
    while( low <= high ){
        mid = (low + high) / 2;
        if(k == 0 ) return 0;
        if(k == a[mid] ) {
            if( a[mid-1]!=k && mid-1>=0 ) return mid;
            else if(mid == 0) return 0;
            else high = mid - 1;
        }
        else if(k < a[mid]) {
            high = mid - 1;
        }
        else if(k > a[mid]) {
            if( k <= a[mid+1]) return mid + 1;
            low = mid + 1;
        }
    }
    if(a[mid]>k && a[mid-1]<k && mid-1>=0) return mid;
    if(a[mid]<k && a[mid+1]>k && mid+1<=n-1) return mid+1;
    if(a[0]>k) return 0;
    return n;
}



int main(){
    cin >> n;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    int q; cin >> q;
    rep(i ,q){
        int k; cin >> k;
        cout << binary_search(a , k) << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int n;
	char c;
	cin>>c; cout<<(char)(c+1)<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 256
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
mod = 10**9+7
dp = [[0 for j in range(m)]for i in range(n)]
for i in range(m):
    if s[0] ==t[i]:
        dp[0][i] = 1
for i in range(n):
    if s[i] ==t[0]:
        dp[i][0] = 1

sumdp = [[0 for j in range(m)]for i in range(n)]
if s[0] ==t[0]:
    sumdp[0][0] =1
for i in range(m-1):
    sumdp[0][i+1] =sumdp[0][i]
    if s[0] == t[i+1]:
        sumdp[0][i+1] += 1
for i in range(n-1):
    sumdp[i+1][0]=sumdp[i][0]
    if s[i+1] ==t[0]:
        sumdp[i+1][0] += 1

for i in range(n-1):
    for j in range(m-1):
        if s[i+1] == t[j+1]:
            dp[i+1][j+1] = (sumdp[i][j] + 1) % mod
        sumdp[i+1][j+1] = (sumdp[i][j+1]+sumdp[i+1][j] - sumdp[i][j]+dp[i+1][j+1])%mod
print((sumdp[n-1][m-1]+1)%mod)

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

int main()
{
	unsigned long long A, B, C, D;
	cin >> A >> B >> C >> D;
	// gcd
	unsigned long long a = D;
	unsigned long long b = C;
	if (C > D)
	{
		a = C;
		b = D;
	}
	unsigned long long mod = a % b;
	while (mod)
	{
		a = b;
		b = mod;
		mod = a % b;
	}
	
	unsigned long long koubai = C * D / b;
	unsigned long long num = (B - A + 1) - ((B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / koubai - (A - 1) / koubai));
	cout << num;
}



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

int main() {
    //
    string str;
    long long num;
    long long cnt = 0;
    long long tmpCnt = 0;
    bool chk = true;

    cin >> str >> num;

    for (int i = 0; i < str.size() - 1; i++) {
        if (str.at(i) != str.at(i + 1)) chk = false;
    }

    if (chk == false) {
        for (int i = 0; i < str.size() - 1; i++) {
            if (str.at(i) == str.at(i + 1)) {
                tmpCnt = 0;
                for (int j = i; j < str.size() - 1; j++) {
                    i = j;
                    if (str.at(j) == str.at(j + 1)) tmpCnt++;
                    else break;
                }

                cnt += (tmpCnt+1) / 2;
            }
        }
    }

    if (chk == true) {
        cnt = str.size() * num / 2;
    } else if (str.at(0) == str.at(str.size() - 1)) {
        tmpCnt = 0;
        for (int i = 0; i < str.size() - 1; i++){
            if (str.at(i) == str.at(i + 1)) tmpCnt++;
            else break;
        }
        for (int i = str.size() - 1; i > 0; i--){
            if (str.at(i) == str.at(i - 1)) tmpCnt++;
            else break;
        }
        cnt *= num;
        if(tmpCnt % 2 == 0) cnt += num - 1;
    } else {
        cnt *= num;
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3632
#include<cstdio>

using namespace std;
typedef long long ll;

int main(){
    int n;
    ll sum = 0;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    printf("%lld",sum);
}

Measured memory_bytes: 1728
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = 0
idx = 0
flg = False
for _ in range(n):
    k = a[idx]
    idx = k-1
    cnt += 1
    if idx == 1:
        flg = True
        break
        
if flg:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 7084
import java.util.Scanner;

//Hamming Numbers
public class Main{

	public static void main(String[] args) {
		boolean[] h = new boolean[1000001];
		h[1] = true;
		int[] s = new int[1000001];
		s[1] = 1;
		for(int i=2;i<1000001;i++){
			if(i%2==0&&h[i/2])h[i]=true;
			if(i%3==0&&h[i/3])h[i]=true;
			if(i%5==0&&h[i/5])h[i]=true;
			s[i] = s[i-1] + (h[i]?1:0);
		}
		Scanner sc = new Scanner(System.in);
		while(true){
			int m = sc.nextInt();
			if(m==0)break;
			int n = sc.nextInt();
			System.out.println(s[n]-s[m-1]);
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  int sum=0;
  int flag =0;
  if(n>=100000) cout << 90909 <<endl ,flag=1;
  if(n>=10000 && flag==0)  cout << 909+n-10000+1<<endl,flag=1;
  if(n>=1000&& flag==0)  	cout << 909 << endl,flag=1;
  if(n>=100&& flag==0)	cout << 9+n-100+1<<endl,flag=1;
  if(n>=10&& flag==0)		cout << 9 <<endl,flag=1;
  if(9>=n&& flag==0)		cout << n << endl,flag=1;
}

Measured memory_bytes: 256
ar = gets.chomp.split(" ").map{|i|i = i.to_i}
n = ar[0]
q = ar[1]

s = gets.chomp!
arr = []
ac_pos_arr = []
flag=0
count=0
s.length.times{|i|
    if s[i]=="A" && s[i+1]=="C" then
        flag=1
    elsif flag==1 then
        count+=1
        flag=0
    end
    ac_pos_arr << count
}
q.times{
    ar = gets.chomp.split(" ").map{|i|i = i.to_i}
    puts ( ac_pos_arr[ar[1]-1] - ac_pos_arr[ar[0]-1] )
}


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

using namespace std;

const int N = 505;

struct event {
	pair <int, int> x;
	pair <int, int> y;
	event (int a, int b, int c, int d) {
		x.first = a;
		x.second = b;
		y.first = c;
		y.second = d;
	}
};

int a[N][N];

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	vector <event> ans;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] & 1) {
				if (j == m - 1) {
					if (i + 1 < n) {
						a[i][j]--;
						a[i + 1][j]++;
						ans.emplace_back(i + 1, j + 1, i + 2, j + 1);
					}
				} else if (i == n - 1) {
					if (j + 1 < m) {
						a[i][j]--;
						a[i][j + 1]++;
						ans.emplace_back(i + 1, j + 1, i + 1, j + 2);
					}	
				} else {
					a[i][j]--;
					a[i][j + 1]++;
					ans.emplace_back(i + 1, j + 1, i + 1, j + 2);
				}
			}
		}
	}
	printf("%d\n", (int)ans.size());
	for (int i = 0; i < (int)ans.size(); i++) {
		printf("%d %d %d %d\n", ans[i].x.first, ans[i].x.second, ans[i].y.first, ans[i].y.second);
	}
	return 0;
}

Measured memory_bytes: 5232
n = int(input())
field = list(map(int,input().split()))
dp = [float("inf")]*n

dp[0] = 0

for i in range(1,n):
  dp[i] = min(dp[i],dp[i - 1] + abs(field[i] - field[i - 1]))
  if i > 1:
    dp[i] = min(dp[i],dp[i - 2] + abs(field[i] - field[i - 2]))
print(str(dp.pop()))

Measured memory_bytes: 13928
import java.util.*;
public class Main{
	public static void main(String[] args) {
		int a,b;
		Scanner sc = new Scanner(System.in);
		a= sc.nextInt();
		b= sc.nextInt();
		System.out.println(max(a+b,max(a*b,a-b)));
	}
	public static int max(int a,int b){
		return (a>b)?a:b;
	}
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<string>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>

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

int main(){
    int n;
    double v[55]={};
    scanf("%d",&n);
    REP(i,n)scanf("%lf",&v[i]);
    sort(v,v+n);
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans=(ans+v[i])/2;
    }
    printf("%f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	ll n, m; cin >> n >> m;
	ll ans = 0;
	if (n * 2 <= m) {
		ans += n;
		m -= n * 2;
		ans += m / 4;
	}
	else {
		ans += m / 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main ()
{
  long long X, K, D;
  cin >> X >> K >> D;
  long long ans;
  if (X < 0) {
    X = -1 * X;
  }
  long count = X / D;  // 残り距離が正としたときの試行回数
  if (count > K) {
    ans = X - K * D;
    cout << ans << endl;
    return 0;
  }
  long distance = X - D * count;  // 残り距離
  count = K - count;  // 残り試行回数
  if (count % 2 == 0) {
      ans = distance;
  } else {
      ans = D - distance;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first

ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const ll INF = 1e9;
//=========================CODE STARTS HERE=============================//

int main() {
	
	fast_cin();
 
	ll n, k;
	cin >> n >> k;
	
	vl arr(n);
	
	fo(i, n) {
		cin >> arr[i];
	}
	
	vi dp(k + 1, 0);
	
	dp[0] = 0;
	
	fo(i, k + 1) {
		fo(j , n) {
			if (dp[i] != 0) continue;
			
			if (i + arr[j] < k + 1) {
				dp[i + arr[j]] = 1;
			}
		}
	}
	
	if (dp[k] == 1) {
		cout << "First" << endl;
	}else {
		cout << "Second" << endl;
	}			  
	
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define ll long long
using namespace std;
ll n,d,a,j=1ll,sumv=0ll,total=0ll;
ll bomb[200005];
pair<ll,ll>m[200005];
int main(){
	cin>>n>>d>>a;
	for (int i=1;i<=n;i++)
	{
		cin>>m[i].first>>m[i].second;
		m[i].second=(m[i].second+a-1)/a; //算出需要扁的次数
	}
	sort(m+1,m+n+1);//排序，不需要用cmp
	for (int i=1;i<=n;i++)
	{
		while ((j<i)&&(m[i].first-m[j].first>d*2))//找怪兽扁
		{
			sumv-=bomb[j];
			j++;
		}
		bomb[i]=max(m[i].second-sumv,0ll);//特别注意！
		sumv+=bomb[i];
		total+=bomb[i];//累加
	}
	cout<<total<<endl;
	return 0;//养成好习惯
}

Measured memory_bytes: 4992