akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int n, now = 0, ans = 0;
    cin >> n;

    vector <int> h(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for (int i = 0; i < n; i++) {
        if (h[i] > now) {
            ans += h[i] - now;
        }
        now = h[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
answer_time = list(map(int, input().split()))
M = int(input())

answer = 0
for _ in range(M):
    p, x = map(int, input().split())
    change = answer_time[p-1]
    answer_time[p-1] = x
    print(sum(answer_time))
    answer_time[p-1] = change

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()
    if (N % 2 == 1L) {
        println(0)
        return
    }

    var result = 0L
    var current = 5L
    while (current < N) {
        result += (N / current) / 2
        current *= 5
    }
    println(result)
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int N;
	cin >> N;
	vector<string> S(N);
	rep(i,N){
		cin >> S[i];
	}

	ll ans = 0;
	rep(i,N){
		// A = 0, B = i の時に線対称かをチェックする
		bool check = true;
		rep(j,N){
			rep(k,N){
				// (j,k) -> (j,(k+i)%N)
				// (?,?) -> ((k+i)%N, j)
				// (?,?) == ((k+i)%N, (j+N-i)%N);
				if(S[j][k] == S[(k+i)%N][(j+N-i)%N]){
					// ok
				} else {
					check = false;
					break;
				}
			}
			if(check == false){
				break;
			}
		}
		if(check) ans ++;
	}
	cout << ans * N << endl;
}


Measured memory_bytes: 384
k=int(input())

ans=0
import itertools
import math
for seq in itertools.combinations_with_replacement(range(1,k+1),3):
    if seq[0]==seq[1] or seq[1]==seq[2]:
        if  seq[0]!=seq[2]:
            ans+=(math.gcd(seq[0],math.gcd(seq[1],seq[2])))*3
        else:
            ans+=math.gcd(seq[0],math.gcd(seq[1],seq[2]))

    else:
        ans+=math.gcd(seq[0],math.gcd(seq[1],seq[2]))*6
print(ans)

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

int main(){
    int ans = 0;
    bool flag;
    string s;

    while( getline(cin,s) ){
        flag = true;
        for(int i=0 ; i<s.size() ; i++){
            if(s[i]!=s[s.size()-i-1]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 0
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] < l[j] < l[k] and l[i] + l[j] > l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9136
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    stack<char> s;
    string input;
    cin >> input;
    for(int i = 0; i < input.length(); ++i) {
        if(input[i] == 'B') {
            if(!s.empty()) {
                s.pop();
            }
        } else {
            s.push(input[i]);
        }
    }
    stack<char> ans;
    while(!s.empty()) {
        ans.push(s.top());
        s.pop();
    }
    while(!ans.empty()) {
        cout << ans.top();
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, k;
string s;

int main(void){
    cin >> n >> k;
    cin >> s;
    s = 'R'+s+'L';
    lli ans = 0;
    for(int i = 1; i <= n; i++){
        if(s[i] == 'L'){
            if(s[i-1] == 'L') ans++;
        }else{
            if(s[i+1] == 'R') ans++;
        }
    }
    cout << min(ans+2*k, n-1) << endl;
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();
        if(age==1){
        	System.out.println("Hello World");
        }else if(age==2){
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	System.out.println(a+b);
        }else{
        	System.out.println("you are too old");
        }
    }
}

Measured memory_bytes: 24148
import math

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

point = []
for _ in range(n):
    x = list(map(int, input().split()))
    point.append(x)

cnt = 0
for i in range(n-1):
    for j in range(i+1, n):
        dist = 0
        for d in range(D):
            dist += (point[i][d] - point[j][d])**2

        dist = math.sqrt(dist)
        if int(dist) == dist:
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();

		int red = 0;
		int blue = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'R') {
				red++;
			} else {
				blue++;
			}
		}

		System.out.println(red > blue ? "Yes" : "No");

	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22612
import sys

while True:
    n = int(raw_input())
    if n == 0: break
    
    a = []
    for i in range(n):
        a.append(map(int, raw_input().split()))
    
    for i in range(n):
        a[i].append(sum(a[i]))
    
    col_sum = []
    for col in range(len(a[0])):
        s = 0
        for row in range(len(a)):
            s += a[row][col];
        col_sum.append(s)
    a.append(col_sum)

    for row in range(len(a)):
        for col in range(len(a[0])):
            sys.stdout.write("%5d" % a[row][col])
        print

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

using namespace std;
const int N = 8200;
int t,n,a[N],pre[N];
bool check[N];

int main(){
	string s,t;
	cin>>s>>t;
	bool flag=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]) flag=1;
	}
	if(s.length()+1!=t.length()) flag=1;
	if(flag) puts("No");
	else puts("Yes");
	
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

int main(){
	ll N;
	cin>>N;
	vll A;
	ll i;
	for(i=0;i<N;i++){
		ll a;
		cin>>a;
		A.push_back(a);
	}
	ll ans = 0;
	ll c = 10000;
	for(i=1;i<N;i++){
		if(A[i]==A[i-1]){
			ans++;
			A[i] = c;
			c--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int N_MAX = 100001;
int main()
{
  long long n,m,i,res=0;
  bool chk[26][N_MAX];
  string::size_type p[26][N_MAX];
  string s,t;
  char c;
  string::size_type pos=0,posb=0;
  cin >> s >> t;
  n=s.size();
  m=t.size();
  for(i=0;i<26;i++)
    fill(chk[i],chk[i]+m,false);
  i=0;
  while(i<m){
    c=t[i];
    if(chk[c-'a'][posb]){
      pos=p[c-'a'][posb];
    }else{
      pos=s.find(c,posb);
      p[c-'a'][posb]=pos;
      chk[c-'a'][posb]=true;
    }
    if(pos==string::npos){
      if(posb==0){
        cout << "-1" << endl;
        return 0;
      }
      res+=n;
      posb=0;
    }else{
      posb=pos+1;
      i++;
    }
  }
  res+=pos+1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 23424
#include <iostream>
#define M 100000
using namespace std;
typedef long long llong;
llong T[M];int n, k;
int check(llong p) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong x = 0;
		for (i; x + T[i] <= p; x += T[i++]) if (i == n)return n;
	}
	return i;
}
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
	llong left = 0, right = M * M;
	while (right - left > 1) {
		llong mid = (right + left) / 2;
		if (check(mid) >= n)right = mid;
		else left = mid;
	}
	cout << right << endl;
}

Measured memory_bytes: 3792
#include<stdio.h>

void gotocall( int n )
{
	int i=1;
	int x;
	
	while( 1 ) {
		x=i;
		if( 0==(x%3) ) {
			printf( " %d", i );
		} else {
			while( 1 ) {
				if( 3==(x%10) ) {
					printf( " %d", i );
					break;
				} else {
					x /= 10;
					if( !x ) { break; }
				}
			}
		}
		if(  n < ++i  ) { break; }
	}
	
	printf( "\n");
	return;
}

int main( void ) 
{
	int n;

	scanf( "%d", &n ); 
	gotocall( n );

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
using namespace std;
int a[10],ans[10];
bool get;
void dfs(int x,int sum)
{
    if(x == 4)
	{
        if(sum==7) get=1;
        return;
    }
    if(get) return;
    ans[x] = -1;
    dfs(x+1,sum-a[x+1]);
    if(get) return;
    ans[x] = 1;
    dfs(x+1,sum+a[x+1]);
    if(get) return;
    ans[x] = 0;
}
int main()
{
    for(int i=1;i<=4;i++)
        scanf("%1d",&a[i]);
    dfs(1,a[1]);
    for(int i=1;i<4;i++)
        printf("%d%c",a[i],(ans[i]==-1?'-':'+'));
    printf("%d=%d\n",a[4],7);
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc054/tasks/abc054_c
//例題2-1-4 n!通りの全探索 https://qiita.com/drken/items/e77685614f3c6bf86f44
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

typedef pair<int, int> P;

int main(){
  int n,m; cin >> n >> m;
  vector<P> edge(m);
  vector<int> node;
  for(int i=0; i<m; ++i){
    int a,b; cin>>a>>b;
    edge[i] = P(a,b);
  }
  for(int i=2; i<=n; ++i) node.push_back(i);
  long sum=0;
  bool failed;
  do{
    int cur = 1;
    for(vector<int>::iterator itr=node.begin(); itr!=node.end(); ++itr){
      failed = true;
      for(int i=0; i<m; ++i){
        if(edge[i].first == cur){
          if(edge[i].second == *itr){
            cur = *itr; failed = false; break;
          }
        }
        if(edge[i].second == cur){
          if(edge[i].first == *itr){
            cur = *itr; failed = false; break;
          }
        }
      }
      if(failed) break;
    }
    if(!failed) sum++;
  }while(next_permutation(node.begin(), node.end()));

  cout << sum << endl;
  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(1 << N); rep(i, 0, 1 << N) { cin >> v[i]; }
	sort(all(v));
	dump(v);

	multiset<int, greater<int>, allocator<int>>s;
	vector<int>x;
	x.eb(v.back());
	rep(i, 0, v.size() - 1) {
		s.insert(v[i]);
	}

	while (s.size()) {
		vector<int>t;
		for (auto y : x) {
			auto ub = s.upper_bound(y);
			if (ub == s.end()) {
				cout << "No" << endl;
				return 0;
			}
			else {
				t.eb(*ub);
				s.erase(ub);
			}
		}
		x.insert(x.end(), all(t));
		dump(x);
		//dump(s);
		
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 14592
n = int(input())
s = input()

kind = 0

first = []
for i in range(n-2):
  if s[i] not in first:
    first.append(s[i])
    second = []
    for j in range(i+1, n-1):
      if s[j] not in second:
        second.append(s[j])
        third = []
        for k in range(j+1, n):
          if s[k] not in third:
            third.append(s[k])
        kind += len(third)
print(kind)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll n, a, b; cin >> n >> a >> b;
	if(b < a || n == 1 && a != b){
		cout << 0 << endl;
		return 0;
	}
	
	ll r = a + (n - 1) * b, l = a * (n - 1) + b;
	cout << r - l + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B;
  cin >> A >> B;

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}


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

int main(){
  char s[100];
  int i,top=0;
  int A[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      A[top-1]=A[top-1] + A[top];
      top--;
    }
    else if(s[0] == '-'){
      A[top-1]=A[top-1] - A[top];
      top--;
    }
    else if(s[0] == '*'){
      A[top-1]=A[top]*A[top-1];
      top--;
    }
    else {
      top++;
      A[top] = atoi(s);
    }
  }
printf("%d\n",A[1]);
  
}



Measured memory_bytes: 2052
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';

  cout << s << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n,k;
	cin>>n>>k;
	int h[n+1];
	FOR0(n) cin>>h[i+1];
	int dp[n+5];
	FOR0(n+3) dp[i]=inf;
	dp[1]=0;dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		for(int j=1;j<=k;j++){
			if((i-j)<1) break;
		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
//		dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	}
	cout<<dp[n];
}



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

fn main() {
    let ab: usize = read();
    let bc: usize = read();
    let _: usize = read();
    println!("{}", ab * bc / 2);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4476
#include <iostream>
#include <queue>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        que.push(a);
    }

    for (int i = 0; i < m; i++) {
        int a = que.top();
        que.pop();
        que.push(a / 2);
    }

    int64_t ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  ll h, n;
	cin >> h >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll sum = 0;
	rep(i, n) sum += a[i];

	if(sum>=h) cout << "Yes" << endl;
	else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#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;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define PI acos(-1)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());

	int n;
	cin >> n;
	int a[n];
	bool ok = 1;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2 == 0) {
			if((a[i] % 3 == 0) || (a[i] % 5 == 0)) {

			}
			else {
				ok = 0;
			}
		}
	}
	if(ok) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> L >> R >> D;
    for (int i = L; i <= R; i++) {
        if (i % D == 0)
            ans++;
    }
    cout << ans << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

#define MAX 100010
int par[MAX];
int find(int x) {
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}
void unite(int x,int y) {
  x = find(x);
  y = find(y);
  if( x != y ) par[x] =y;
}

int V, E, H[MAX];

vector<int> G[MAX];
bool used[MAX];

struct Data {
  int v, h;
  bool operator < ( const Data &d ) const {
    return h > d.h;
  }
};

int main() {
  cin >> V >> E;
  rep(i,V) cin >> H[i];
  int s,t;
  rep(i,E) {
    cin >> s >> t;
    --s, --t;
    G[s].pb(t);
    G[t].pb(s);
  }
  vector<Data> vec;
  rep(i,V) vec.pb((Data){i,H[i]});
  sort(ALL(vec));
  memset(used,false,sizeof used);
  int ans = 0;
  rep(i,V) {
    Data d = vec[i];
    if( used[d.v] ) continue;
    used[d.v] = true;
    bool ok = true;
    rep(j,(int)G[d.v].size()) {
      int nex = G[d.v][j];
      if( H[nex] >= d.h )  {
	ok = false;
	used[nex] = true;
	break;
      }
    }
    if( ok ) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  map<string, int> M;
  for (int i = 1; i <= N; i++) {
    string S = to_string(i);
    string T = "";
    T += S.at(0);
    T += S.at(S.size() - 1);
    M[T]++;
  }
  ll ans = 0;
  for (pair<string, int> p : M) {
    string key = p.first;
    int value = p.second;
    string S = "";
    S += key.at(1);
    S += key.at(0);
    ans += value * M[S];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
results = []
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    results.append([m, f, r, m+f])

for result in results:
    if result[0] == -1 or result[1] == -1:
        print('F')
    else:
        if result[3] >= 80:
            print('A')
        elif result[3] >= 65:
            print('B')
        elif result[3] >= 50:
            print('C')
        elif result[3] >= 30:
            if result[2] >= 50:
                print('C')
            else:
                print('D')
        else:
            print('F')



Measured memory_bytes: 5596
use std::io::{Read, stdin};
use std::str::FromStr;
use std::cmp::min;


fn main() {
    let d: usize = read();
    let g: i64 = read();
    let mut p = vec![0; d as usize];
    let mut c = vec![0; d as usize];
    for i in 0..d {
        p[i] = read();
        c[i] = read();
    }
    let mut ans: i64 = 100000000000000;
    for i in 0..1 << d {
        let mut cnt: i64 = 0;
        let mut scr: i64 = 0;
        for j in 0..d {
            if i & 1 << j == 0 {
                cnt += p[j];
                scr += c[j] + p[j] * (j + 1) as i64 * 100;
            }
        }
        if scr >= g {
            ans = min(ans, cnt);
        } else {
            let mut rev:Vec<usize> = (0..d).collect::<Vec<usize>>();
            rev.reverse();
            for j in rev {
                if i & 1 << j != 0 {
                    if g - scr - p[j] * (j + 1) as i64 * 100 > 0 {
                        break;
                    } else {
                        cnt += (g - scr) / (j + 1) as i64 / 100;
                        if (g - scr) % ((j + 1) as i64 * 100) != 0 {
                            cnt += 1;
                        }
                        ans = min(ans, cnt);
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	for(int h, w, n; cin >> h >> w >> n, h;) {
		vector<vector<int> > east(h, vector<int>(w));
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				cin >> east[i][j];

		vector<vector<int> > dp(h + 1, vector<int>(w + 1, 0));
		dp[0][0] = n;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				int num_east = dp[i][j] - dp[i][j] / 2, num_south = dp[i][j] / 2;
				if(!east[i][j])
					swap(num_east, num_south);

				dp[i][j + 1] += num_east;
				dp[i + 1][j] += num_south;
			}
		}

		int x = 0, y = 0;
		while(x < w && y < h) {
			if((dp[y][x] + east[y][x]) & 1)
				++y;
			else
				++x;
		}

		cout << y + 1 << " " << x + 1 << endl;
	}

	return EXIT_SUCCESS;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

int dfs(vector<vector<int>> &edges, vector<int> &longest, vector<bool> &visited, vector<bool> &calculated, int to) {
    if (visited[to]) {
        if (!calculated[to]) return -1;
        return longest[to];
    }
    visited[to] = true;
    longest[to] = 0;
    for (int next : edges[to]) {
        int r = dfs(edges, longest, visited, calculated, next);
        if (r == -1) return -1;
        cmax(longest[to], r + 1);
    }
    calculated[to] = true;
    return longest[to];
}

int solve(vector<vector<int>> &edge) {
    int ans = -1;
    vector<int> longest(edge.size(), 0);
    vector<bool> visited(edge.size(), false);
    vector<bool> calculated(edge.size(), false);
    rep(i, edge.size()) {
        int t = dfs(edge, longest, visited, calculated, i);
        if (t == -1) return -1;
        cmax(ans, t);
    }
    return ans + 1;
}

int main() {

//    std::ifstream f("C:\\Users\\riku\\Downloads\\b08");

    int n;
    cin >> n;
    vector<vector<int>> match(n, vector<int>(n - 1));
    rep(i, n) rep(j, n - 1) cin >> match[i][j];
    rep(i, n) rep(j, n - 1) match[i][j]--;

    vector<vector<int>> id_table(n, vector<int>(n, -1));
    {
        vector<P> m;
        rep(i, n) {
            rep (j, n) {
                if (j <= i) continue;
                m.emplace_back(i, j);
            }
        }
        rep(i, m.size()) {
            P p = m[i];
            id_table[p.first][p.second] = i;
            id_table[p.second][p.first] = i;
        }
    }

    auto to_id = [&](int i, int j) {
        return id_table[i][j];
    };

    vector<vector<int>> edge(n * (n - 1) / 2);

    auto add = [&](int a, int b1, int b2) {
        int m1 = to_id(a, b1);
        int m2 = to_id(a, b2);
        edge[m1].push_back(m2);
    };

    rep(i, n) {
        rep(j, n - 2) {
            add(i, match[i][j], match[i][j + 1]);
        }
    }

    cout << solve(edge) << endl;
}


Measured memory_bytes: 37736
program circle_pond
  implicit none
  real(8), parameter :: pi = 3.14159265358979d0
  real(8) :: r
  character(64) :: s
  read(*,*) r
  write(s,'(f32.16)') 2.d0*pi*r
  write(*,'(a)') trim(adjustl(s))
end program circle_pond

Measured memory_bytes: 3036
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] red = new int[N][2];
		int[][] blue = new int[N][2];
		boolean[] used = new boolean[N];
		int ans = 0;
		for(int i = 0; i < N; i++) {
			red[i][0] = sc.nextInt();
			red[i][1] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			blue[i][0] = sc.nextInt();
			blue[i][1] = sc.nextInt();
		}
		Arrays.sort(blue, (x,y) -> x[0] - y[0]);
		Arrays.sort(red, (x,y) -> x[1] - y[1]);
		for(int i = 0; i < N; i++) {
			for(int j = N-1; j >= 0; j--) {
				if(blue[i][0] > red[j][0] && blue[i][1] > red[j][1] && !used[j]) {
					ans += 1;
					used[j] = true;
					break;
				}
			}
		}
		System.out.println(ans);

	}

}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 20+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
char c[N][N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
bool vis[N][N];
int d[N][N];

bool ok(int x, int y){
	return x>=0 && x<n && y>=0 && y<=m && c[x][y] == '.';
}
int cost(int x, int y, int a, int b){
	if (x == a && y == b) return 0;
	queue<pii> q;
	memset(vis, 0, sizeof vis);
	memset(d, 0, sizeof d);
	vis[x][y] = true;
	q.push({x, y});
	while(!q.empty()){
		pii v = q.front(); q.pop();
		for(int i=0; i<4; i++){
			int nx = v.st + dx[i];
			int ny = v.nd + dy[i];

			if (!ok(nx, ny)) continue;
			if (vis[nx][ny]) continue;
			d[nx][ny] = d[v.st][v.nd] + 1;
			vis[nx][ny] = true;
			if (nx == a && ny == b) return d[a][b];
			q.push({nx, ny});
		}
	}
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++){
			cin >> c[i][j];
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			for(int k=0; k<n; k++){
				for(int l=0; l<m; l++){
					if (c[i][j] == '.' && c[k][l] == '.') {
						ans = max(ans, cost(i, j, k, l));
					}
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
a,b,c = gets.split.map(&:to_i)
k = gets.to_i

yes = 'Yes'
no = 'No'

k.times do
  if a >= b
    b *= 2
  elsif b >= c
    c *= 2
  end
end

if a < b && b < c
  puts yes
else
  puts no
end


Measured memory_bytes: 14364
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

template<typename T>
T modulo(T x, T N){
    return (x % N + N) % N;
}

int main()
{
    int64_t N;
    std::cin >> N;

    if (N == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::string ans;

    while (N != 0) {
        // ???
        int64_t r = std::abs(N) & 1;
        if (r == 0) {
            ans += '0';
        }
        else {
            ans += '1';
        }
        N = (N - r)/ (-2);
    }

    std::reverse(ans.begin(), ans.end());
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int x,y,s;
	while(cin>>x and x>0){
		cin>>y>>s;
		int ans=0;
		for(int i=1;i<s;i++){
			for(int j=1;j<s;j++){
				int before=i*(100+x)/100+j*(100+x)/100;
				int after=i*(100+y)/100+j*(100+y)/100;
				if(before==s){
					if(ans<after) ans=after;
				}
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3036
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            String[] num = line.split(" ", -1);
            int a = Integer.parseInt(num[0]);
            int b = Integer.parseInt(num[1]);
            if(a < b) {
                System.out.println("a < b");
            }else if(a > b) {
		System.out.println("a > b");
            }else {
                System.out.println("a == b");
            }
	} catch (IOException e) {
            System.out.println(e);
	} catch (NumberFormatException e) {
            System.out.println("error");
	}
    }
}

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

int main () {
  int x, n;
  cin >> x >> n;
  
  if (n==0) cout << x << endl;
  else {
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    
    vector<int> q(102);
    rep(i,102) q[i] = i;
    rep(i,n) q[p[i]] = 20000;
    
    vector<int> r(102);
    rep(i,102) {
      r[i] = abs(q[i] - x);
    }
    
    int s = 200;
    rep(i,102) s = min(s,r[i]);
    
    rep(i,102) {
      if (r[i] == s) {
        cout << q[i] << endl;
        break;
      }
    }
  }
}

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

int main(){
  int p, q, r;
  cin >>  p >> q >> r;
  cout << p+q+r-max(max(p,q),r) << endl;

  return 0;
}

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

typedef long long ll;

int main(){
  int n;
  cin >> n;
  int k=3*n;
  ll a[k];
  for(int i=0;i<k;i++){
    cin >> a[i];
  }
  sort(a,a+k);
  ll ans=0;
  for(int i=n;i<k;i+=2){
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
def main():
    n, *a = map(int, open(0).read().split())
    c = 1
    f = 0
    d = [1,-1]
    for i, j in zip(a, a[1:]):
      if i == j:
        continue
      g = d[i < j]
      if f * g == -1:
        f = 0
        c += 1
      else:
        f = g
    
    print(c)


if __name__ == '__main__':
    main()


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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: u64 = read();
    let mut ret = 1;
    let mut base = 7;

    if n % 2 == 0 || n% 5 == 0 {
        println!("-1");
        return;
    }

    loop {
        if base % n == 0 {
            break;
        }
        ret += 1;
        base = (base * 10) % n;
        base = (base + 7) % n;
    }
    println!("{}", ret);
}

fn inverse(n1: u64) -> u64 {
    let mut n = n1;
    let mut ret = 1;

    for i in 2..n1 {
        if n < i * i {
            break;
        }

        let mut pow = 0;
        while n % i == 0 {
            n /= i;
            pow += 1;
            ret *= i;
        }

        if pow > 0 {
            ret /= i;
            ret *= i - 1;
        }
    }

    if n > 1 {
        ret *= n - 1;
    }
    ret
}


Measured memory_bytes: 2152
#include <iostream>

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int n = 0; n < k; n++) {
		if (n % 2 == 0) {
			if (a % 2 != 0) {
				a--;
			}
			a /= 2;
			b += a;
		}
		else {
			if (b % 2 != 0) {
				b--;
			}
			b /= 2;
			a += b;
		}
	}
	cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

    long long k, n;
    cin >> k;
    cin >> n;

    long long a[n+1];
    for(long long i=0;i<n;i++) cin >> a[i];
    a[n] = k+a[0];

    for(long long i=0;i<n;i++) a[i] = a[i+1] - a[i];

    a[n] = 0;
    long long max = a[n];
    for(long long i=0;i<n;i++){
        max = max<a[i] ? a[i] : max;
    }
    cout << k-max << endl;

    return 0;
}

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

int main(){
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    for(int i=0; i<A; i++) cin >> s[i];
    for(int i=0; i<B; i++) cin >> t[i];

    while(Q>0){
        ll x; cin >> x;
        int sr, tr;
        if(s[A-1]<x) sr = A;
        else sr = lower_bound(s.begin(), s.end(), x) - s.begin();
        if(t[B-1]<x) tr = B;
        else tr = lower_bound(t.begin(), t.end(), x) - t.begin();

        ll srx, slx, trx, tlx;
        if(sr!=A) srx = s[sr];
        else srx = 1e15; 
        if(tr!=B) trx = t[tr];
        else trx = 1e15;
        if(sr!=0) slx = s[sr-1];
        else slx = -1e15;
        if(tr!=0) tlx = t[tr-1];
        else tlx = -1e15;

        ll ans = 1e18;
        ans = min(max(trx-x, srx-x), max(x-slx, x-tlx));
        ans = min(ans, (x-tlx)*2 + srx-x);
        ans = min(ans, (x-slx)*2 + trx-x);
        ans = min(ans, (trx-x)*2 + x-slx);
        ans = min(ans, (srx-x)*2 + x-tlx);
        cout << ans << endl;
        Q--;
    }
}


Measured memory_bytes: 2944
#include <iostream>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 100000009
#define maxn 1000009
#define mod 1000000007
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
int vis[200001];
int main()
{
    int n,m,a,b;
    scanf("%d %d",&n,&m);
    memset(vis,0,sizeof(vis));
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&a,&b);
        if(a==1||b==1)
        {
            if(a==1)
            vis[b]++;
            else
            vis[a]++;
        }
        if(a==n||b==n)
        {
            if(a==n)
            vis[b]++;
            else
            vis[a]++;
        }
    }
    int flag=0;
    for(int i=0;i<=n;i++)
    {
        if(vis[i]==2)
        flag=1;
    }
    if(flag)
    printf("POSSIBLE\n");
    else
    printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		int dist = in.nextInt();
		int time = in.nextInt();
		int speed = in.nextInt();
      	int need = dist / speed;
      	if (dist%speed != 0) need += 1;
      
      	if (time >= need) {
          	System.out.println("Yes");
        } else {
          	System.out.println("No");
        }
    }
}


Measured memory_bytes: 35652