akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.lang.Math.*
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

val inf = 1000000000

fun main(args: Array<String>) {
    val n = nextInt()
    val h = nextListOfInt()
    val dp = Array(n+1){inf}
    dp[0] = 0
    for(i in 1 until n){
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if(i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
    }
    println(dp[n-1])
}

fun abc000a() {
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

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


ll knapsack(ll weight[],ll val[],ll n,ll W)
{
    ll t[n+1][W+1];
    
    // Initialisation 
    for(ll i=0;i<n+1;i++)
          {
            for(ll j=0;j<W+1;j++)
            {
            if(i==0||j==0)
                t[i][j]=0;
            }
          }   

    for(ll i=1;i<n+1;i++)
        for(ll j=1;j<W+1;j++)
        {
            if(weight[i-1]<=j)
                t[i][j]=max(val[i-1]+t[i-1][j-weight[i-1]],t[i-1][j]);
            else
                t[i][j]=t[i-1][j];
        }    
    
    return t[n][W];

}

int main()
{
ll n,W;cin>>n>>W;
ll val[n+1],weight[n+1];

for(ll i=0;i<n;i++)
    cin>>weight[i]>>val[i];


cout<<knapsack(weight,val,n,W);


return 0;
}

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

int main(){
	string s;
	cin >> s;
	for(int i=0; i < s.size() - 1; i++){
		if(s[i] == s[i + 1]) {
			cout << i+1 << " " << i+2;
			return 0;
		} else if(i + 2 < s.size() && s[i] == s[i + 2]) {
			cout << i+1 << " " << i+3;
			return 0;
		}
	}
	cout << "-1 -1";
	return 0;
}




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

class Point {
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator +(Point p) {
    return Point(x+p.x, y+p.y);
  }
  Point operator -(Point p) {
    return Point(x-p.x, y-p.y);
  }
  Point operator *(double a) {
    return Point(x*a, y*a);
  }
  Point operator /(double a) {
    return Point(x/a, y/a);
  }
  bool operator ==(const Point &p) const {
    return x == p.x && y == p.y;
  }
  bool operator <(const Point &p) const {
    double l1 = x+y;
    double l2 = p.x+p.y;
    if(l1 != l2) return l1 < l2;
    if(y != p.y) return y < p.y;
    return x < p.x;
  }
};

typedef Point Vector;

double norm(Point p1, Point p2) {
  return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y);
}

int n;
Point p[300];

int calc(Point p1, Point p2) {
  Point m = Point((p1.x+p2.x)/2.0, (p1.y+p2.y)/2.0);
  Point o;
  Vector moto = Vector(p2.y-p1.y, p1.x-p2.x);
  int cnt = 0;
  int newCnt;
  double p1p2 = norm(p1,p2);
  if(p1p2 > 4) return 1;
  double l = sqrt(4.0/p1p2-1)/2.0;

  for(int t = 0; t < 2; t++) {
    newCnt = 0;
    if(t == 1) {
      moto = moto * (-1);
    }
    o = m + moto * l;

    for(int i = 0; i < n; i++) {
      if(newCnt + n-i <= cnt) break;
      if(p[i] == p1 || p[i] == p2) continue;
      if((p[i].x-o.x)*(p[i].x-o.x) + (p[i].y-o.y)*(p[i].y-o.y) <= 1.0) {
	newCnt++;
      }
    }
    if(newCnt > cnt) cnt = newCnt;
  }
  return cnt + 2;
}

main() {
  while(1) {
    int ans;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      cin >> p[i].x >> p[i].y;
    }
    sort(p, &p[n]);
    ans = 1;
    for(int i = 0; i < n; i++) {
      for(int j = i+1; j < n; j++) {
	ans = max(ans, calc(p[i],p[j]));
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 968
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> kudamono = new ArrayList<>();
        for (int i=1;i<=n;i++) {
            kudamono.add(sc.nextInt());
        }

        int ans=0;
        Collections.sort(kudamono);
        for (int i=0;i<k;i++) {
            ans += kudamono.get(i);
        }
        System.out.println(ans);
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  REP(i, N) cin >> S[i];
  sort(S.begin(), S.end());
  string ans = "";
  for(int i = 0; i < N; i++) {
    ans += S[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
// #define max INT_MAX
int main()
{
    ll int n;
    cin >> n;
    ll int A[n];
    for(int i=0;i<n;i++)
    cin >> A[i];
    ll int count1=0,count2=0,temp;
    temp = A[0];
    if(temp<=0)
    {
        count1 = abs(1-temp);
        temp = 1;
    }
    for(int i=1;i<n;i++)
    {
        temp += A[i];
        if(i%2)
        {
            if(temp>=0)
            {
                count1 += abs(-1-temp);
                temp=-1;
            }
        }
        else 
        {
            if(temp<=0)
            {
                count1 += abs(1-temp);
                temp=1;
            }
        }
    }
    temp = A[0];
    if(temp>=0)
    {
        count2 += abs(-1-temp);
        temp = -1;
    }
    for(int i=1;i<n;i++)
    {
        temp += A[i];
        if(i%2)
        {
            if(temp<=0)
            {
                count2 += abs(1-temp);
                temp=1;
            }
        }
        else 
        {
            if(temp>=0)
            {
                count2 += abs(-1-temp);
                temp=-1;
            }
        }
    }
    cout << min(count1,count2) ;
}

Measured memory_bytes: 1024
INF = 10 ** 10
n, m = gets.split.map(&:to_i)
costs = []
keys = []
m.times do
  costs << gets.to_i
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res | 2 ** (num - 1) }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp[key] = [dp[key], costs[i]].min
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = [dp[next_opened], cost + costs[i]].min
  end
end
puts dp.last == INF ? - 1 : dp.last


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	 int n; cin >> n;
	 vector<ll> a(n);
	 for( auto &k : a ) cin >> k;
	 bitset<4000005> x;
	 bitset<4000005> y;
	 x.set(0);
	 for( int i = 0; i < n; ++i ){
		 y = ( x << a[i] );
		 y |= x;
		 x = y;
	 }
	 int sum = accumulate( a.begin(), a.end(), 0 );
	 int bound = (sum+1)/2;
	 for( int i = bound; i <= sum; ++i ){
		 if( x.test(i) ){
			 cout << i << endl;
			 break;
		 }
	 } 
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

class P {

public:

  double x , y;

  P(int xx, int yy) {

    x = xx;

    y = yy;

  }

};

double getDistance(P p1, P p2) {

  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y , 2));

}

int main() {

  P p1(0 , 0) , p2(0 , 0);

  cin >> p1.x >> p1.y >> p2.x >> p2.y;

  printf("%.8lf\n",getDistance(p1 ,  p2));

  return 0;

}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define int long long
#define ld long double
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(n % i == 0){
      if(i < 10 && (n / i) < 10){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

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

	int n;
	cin>>n;
	
	//probability of having 'i' heads
	vector<double> dp(n+1);
	dp[0]=1;
	
	for(int coin=0;coin<n;coin++)
	{
		double prob_head;
		cin>>prob_head;
		for (int i = coin+1; i >=0 ; i--)
		{
			double temp=0;
			if(i>0)temp=dp[i-1]*prob_head;
			dp[i]=temp+dp[i]*(1-prob_head);
		}
	}
	
	double ans=0;
	for (int i = 0; i < n+1; i++)
	{
		int t=n-i;
		if(i>t)
		{
			ans+=dp[i];
		}
	}
	
	cout<<setprecision(10)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 21;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, x, c[20], a[20][20], ans, s[20];

main () {
	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 1; j <= m; ++j)
			cin >> a[i][j];
	}

	ans = inf;
	for (int mask = 0; mask < (1 << n); ++mask) {
		int res = 0;
		memset(s, 0, sizeof(s));
		for (int i = 0; i < n; ++i) 
			if (mask & (1 << i)) {
				for (int j = 1; j <= m; ++j)
					s[j] += a[i][j];
				res += c[i];
			}

		bool ok = 1;
		for (int j = 1; j <= m; ++j)
			if (s[j] < x) {
				ok = 0;
				break;
			}

		if (ok) 
			ans = min(ans, res);		
	}

	if (ans == inf)
		ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() {
    long long n, r;
    cin >> n >> r;
    if(n > 10) {
        cout << r << "\n";
    } else {
        cout << r + (100 * (10 - n)) << "\n";
    }
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

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

        String c = scanner.next();
        String[] s = new String[] {"a", "i", "u", "e", "o"};
        int ans = 0;
        for (int i = 0; i < 5; i++) {
            if(c.equals(s[i]))ans = 1;
        }
        if(ans == 1){
            System.out.println("vowel");
        }else{
            System.out.println("consonant");
        }

    }
}




Measured memory_bytes: 9672
n = int(input())
l = list(map(int, input().split()))
kari = 0
p = 0
for i in range(n-1):
    if l[i+1] <= l[i]:
        kari += 1
        if kari > p:
            p = kari
    else:
        if kari > p:
            p = kari
        kari = 0
print(p)

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

using namespace std;

int main(int argc, const char *argv[])
{
  string s;
  cin >> s;
  vector<int> ans(s.size(), 0);
  int odd_cnt = 1, even_cnt = 1;

  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'L') {
      continue;
    }

    bool is_even_idx = i % 2 == 0;
    if (s[i + 1] == 'R') {
      if (is_even_idx) {
        even_cnt++;
      } else {
        odd_cnt++;
      }
    } else {
      ans[i] += is_even_idx ? even_cnt : odd_cnt;
      ans[i + 1] += is_even_idx ? odd_cnt : even_cnt;
      even_cnt = odd_cnt = 1;
    }
  }

  even_cnt = odd_cnt = 0;
  for (int i = s.size() - 1; i >= 1; i--) {
    if (s[i] == 'R') {
      continue;
    }

    bool is_even_idx = i % 2 == 0;
    if (s[i - 1] == 'L') {
      if (is_even_idx) {
        even_cnt++;
      } else {
        odd_cnt++;
      }
    } else {
      ans[i] += is_even_idx ? even_cnt : odd_cnt;
      ans[i - 1] += is_even_idx ? odd_cnt : even_cnt;
      even_cnt = odd_cnt = 0;
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
    cout << (i == ans.size() - 1 ? '\n' : ' ');
  }
  
  return 0;
}

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

int A, B;

int main(void){
    
    scanf("%d %d", &A, &B);
    
    int ans = 0;
    for(int i = A; i <= B; ++i){
        string a, b; a = b = to_string(i);
        reverse(b.begin(), b.end());
        if(a == b) ++ans;
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
ans=0
d={}
for a in range(1,n+1):
    for b in range(1,n+1):
        p=math.gcd(a,b)
        if d.get(p)!=None:
            d[p]+=1
        else:
            d[p]=1
for c in range(1,n+1):
    for e in range(1,n+1):
        p=math.gcd(c,e)
        ans+=d[e]*p
print(ans)        

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    string s; cin>>s;
    int l,r;
    rep(i,s.size())if(s[i]=='A'){l=i; break;}
    for(int i=s.size()-1; i>=0; i--)if(s[i]=='Z'){r=i; break;}
    cout<<r-l+1<<endl;

}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int h,w;
vector<vector<char>> grid;
vector<vector<int>> visited;
vector<vector<int>> dist;
int sx,sy,ex,ey;
int d4x[] = {0,1,0,-1};
int d4y[] = {1,0,-1,0};

void bfs( int x , int y ){
    deque<pair<int,int>> q;
    q.push_front({x,y});
    while(!q.empty()){
        pair<int,int> p = q.front();
        q.pop_front();
        int fx = p.ft;
        int fy = p.sd;
        visited[fx][fy] = 1;
        rep(d,0,4){
            int nx = fx + d4x[d];
            int ny = fy + d4y[d];
            if ( nx >= h || ny >= w || nx < 0 || ny < 0 )continue;
            if ( visited[nx][ny] || grid[nx][ny] == '#' )continue;
            if ( dist[fx][fy] < dist[nx][ny] ){
                dist[nx][ny] = dist[fx][fy];
                q.push_front({nx,ny});
            }
        }

        for ( int dx = -2 ; dx <= 2 ; dx++ ) {
            for ( int dy = -2 ; dy <= 2 ; dy++ ){
                int nx = fx + dx;
                int ny = fy + dy;
                if ( nx >= h || ny >= w || nx < 0 || ny < 0 )continue;
                if ( visited[nx][ny] || grid[nx][ny] == '#' )continue;
                if ( dist[fx][fy] + 1 < dist[nx][ny] ){
                    dist[nx][ny] = 1 + dist[fx][fy];
                    q.push_back({nx,ny});
                } 
            }
        }
    }
}

//START OF CODE ->->->->->->->

void solve()
{
    cin>>h>>w;
    cin>>sx>>sy;
    cin>>ex>>ey;
    sx--;sy--;ex--;ey--;
    grid = vector<vector<char>>(h,vector<char>(w));
    visited = vector<vector<int>>(h,vector<int>(w,0));
    dist = vector<vector<int>>(h,vector<int>(w,inf));
    dist[sx][sy] = 0;
    rep(i,0,h){
        rep(j,0,w){
            cin>>grid[i][j];
            if ( grid[i][j] == '#' ){
                visited[i][j] = 1;
            }
        }
    }
    bfs(sx,sy);

    cout<<((dist[ex][ey] == inf)?-1:dist[ex][ey])<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 20496
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] A = new int[N], B = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = in.nextInt();
            B[i] = in.nextInt();
        }
        Arrays.sort(A);
        Arrays.sort(B);

        double low = N % 2 == 0 ? (A[N/2] + A[N/2-1]) / 2.0 : A[N/2];
        double high = N % 2 == 0 ? (B[N/2] + B[N/2-1]) / 2.0 : B[N/2];

        int cnt = N % 2 == 0 ? (int) ((high - low) * 2) + 1 : (int) (high - low) + 1;
        System.out.println(cnt);
    }
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/


int main() {
  string s;
  cin >> s;
  cout << 700 + 100 * count(s.begin(), s.end(), 'o') << endl;
}


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

typedef long long ll;

int main(void){
    ll a,b,k;
    cin >> a >> b >> k;
    for(int i=0; i<k; i++){
        if(i%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;
    return 0;
}

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

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
	int i,x=753,n,l,m;
	char s[15];
	
	gets(s);
	
	l=strlen(s);
	
	for(i=0;i<l-2;i++){
		n=(s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48);
		m=abs(n-753);
		if(m<x){
			x=m;
		}
	}
	printf("%d\n",x);
	
	return 0;
}

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

int main()
{
    int a[5], k;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> k;   

    if ((a[4] - a[0]) > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
from collections import deque
import math

import sys
input = sys.stdin.readline

N, D, A = map(int, input().split())
S = [0]*N
atack = deque()
for i in range(N):
    x, h = map(int, input().split())
    S[i] = [x, h]

S.sort()
cnt = 0
dmg = 0
for i in range(N):
    while atack:
        if atack[0][0] < S[i][0]:
            x, d = atack.popleft()
            dmg -= d
        else:
            break

    if S[i][1] <= dmg:
        continue
    bomb = math.ceil((S[i][1]-dmg)/A)
    atack.append([S[i][0]+2*D, A*bomb])
    cnt += bomb
    dmg += A*bomb

print(cnt)


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

using namespace std;

#define ll long long

int main()
{
    ll n, k;
    cin >> n >> k;

    if(k >= n)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> health(n);

    for(ll &h : health) cin >> h;

    sort(health.begin(), health.end());

    ll res = 0;
    for(int i = 0 ; i < health.size()-k; ++i)
    {
        res += health[i];
    }

    cout << res << endl;

    return 0;
}



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


int main(){
    int n, cntl = 0, cntr = 0;
    cin >> n;
    vector<int> l(n+1), r(n+1);
    string s;
    cin >> s;
    l[0] = 0;
    r[n] = 0;
    rep(i,n){
        if (s[i] == 'W') cntl ++;
        l.at(i+1) = cntl;
    }
    rep(i,n){
        if (s[n-i-1] == 'E') cntr ++;
        r.at(n-i-1) = cntr;
    }
    int ans = n;
    rep(i,n){
//      cout << l.at(i) << " " << r.at(i+1) << endl;
        ans = min(ans, l.at(i) + r.at(i+1));
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int check(pair<int, int> foot, bool init, const vector<int> &a, int n) {
  //cout << "check" << endl;
  bool next = init;
  int res = 0;
  for(int i=0;i<n-2;++i) {
    if(next) {
      if(a[i] < foot.first) {
        //cout << i << endl;
        res++;
        foot.first = a[i];
      } else {
        foot.second = a[i];
        next = !next;
      }
    } else {
      if(foot.second < a[i]) {
        //cout << i << endl;
        res++;
        foot.second = a[i];
      } else {
        foot.first = a[i];
        next = !next;
      }
    }
    
  }
  return res;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  vector<int> mp = {-2, -1, 0, 1, -1, 0, 1, -1, 0, 1};

  while(1) {
    string s; cin >> s;
    int n = s.size();
    if(s == "#") break;
    vector<int> a(100000);
    pair<int, int> foot;
    bool init = 0;
    for(int i=0;i<(int)(s.size());++i) {
      int tmp = mp[(int)(s[i]-'0')];
      // cout << tmp << endl;
      if(i == 0) {
        foot.first = tmp;
      } else if(i == 1) {
        foot.second = tmp;
        if(foot.first < foot.second) {
          init = 0;
        } else {
          init = 1;
        }
      } else {
        a[i-2] = tmp;
      }
    }

    if(foot.first > foot.second) {
      swap(foot.first, foot.second);
    }
    
    if(foot.first == foot.second) cout << min(check(foot, 0, a, n), check(foot, 1, a, n)) << endl;
    else cout << check(foot, init, a, n) << endl;

  }
}



Measured memory_bytes: 3796
#include <iostream>

int main()
{
  int n;
  std::string s, t;

  std::cin >> n;
  std::cin >> s >> t;

  // std::cout << n << std::endl;
  // std::cout << s << ' ' << t << std::endl;

  for (int i = 0; i < n; i++) {
    std::cout << s[i] << t[i];
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 3584
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()

ds = []
for i in range(1, m+1):
    if i*i > m: break
    if m % i == 0:
        ds.append(i)
        if i*i < m:
            ds.append(m//i)
ds.sort()

for d in ds[::-1]:
    if m//d >= n:
        print(d)
        break


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> card(n);
	for (int i = 0; i < n; i++) cin >> card.at(i);
	sort(card.begin(), card.end(), greater<int>());

	int sumA = 0, sumB = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) sumA += card.at(i);
		else sumB += card.at(i);
	}
	cout << sumA - sumB << endl;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int D, N;
    cin >> D >> N;
    int k = 0;
    for (int i = 1; ; i++) {
        int now = i;
        int cnt = 0;
        while(now % 100 == 0) {
            now /= 100;
            cnt++;
        }
        if (cnt == D) {
            k++;
            if (k == N) {
                cout << i << endl;
                return;
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,r[101],i,cnt;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	cnt=0;
	for(i=0;i<=100;i++){
		r[i]=0;
	}
	for(i=a;i<b;i++){
		r[i]++;
	}
	for(i=c;i<d;i++){
		r[i]++;
	}
	for(i=0;i<=100;i++){
		if(r[i]==2){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    long long a,b,t,x,y;
    while ( scanf( "%lld %lld", &a, &b ) != EOF )
    {
	x = a; y = b;
	while ( y > 0 )
	{
	    t = x % y;
	    x = y;
	    y = t;
	}
	printf( "%llu %llu\n", x, a/x*b );
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <map>
#include <string>
#include <set>

using namespace std;

int main(){
	int n;
	string str;	
	map<string, set<int> > m;

	while(cin >> str >> n){
		m[str].insert(n);
	}
	for(auto it = m.begin(); it != m.end(); it++){
		cout << it->first << endl;
		int i = 0;
		for(auto its =  it->second.begin(); its != it->second.end(); its++){
			if(i != it->second.size() - 1) cout << *its << " ";
			else cout << *its;
			i++;
		}
		cout << endl;
	}
}

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

struct data
{
	int x, y;
	struct data *prev, *next;
};

void insert(struct data *a, struct data *b)//aの後ろにbを追加
{
	b->next = a;
	b->prev = a->prev;
	a->prev->next = b;
	a->prev = b;
}

int main()
{
	int n, tmp1, tmp2, i;
	int s, t;
	float sum = 0, length;

	scanf("%d", &n);
	

	struct data head, *p, *q;

	head.next = head.prev = &head;


	for (i = 0; i < n; i++)
	{


		struct data *point;
		point = (struct data *)malloc(sizeof(struct data));

		scanf("%d %d", &point->x, &point->y);

		insert(&head, point);
	}

	for (p = head.next; p != &head; p = p->next)
	{
		for (q = p->next; q != &head; q = q->next)
		{

			length = (float)(sqrt((p->x - q->x)*(p->x - q->x) + (p->y - q->y)*(p->y - q->y)));
			sum = sum + length;
		}
	}

	printf("%f\n", 2*sum/n);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
using namespace std;
int main()
{
    int n;
    string s;
    set<string> t;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s;
        t.insert(s);
    }
    cout << t.size() << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a<=9 && b<=9)
    {
        c = a*b;
        cout<<c<<endl;
    }
    else if(a<=20 && b<=20)
    {
        cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  

  
  str s;
  cin>>s;
  set<char>ch;
  f(i,0,4)
  {
    ch.add(s[i]);
  }
  auto s1=ch.begin();
  s1++;
  if(ch.size()==2&&count(all(s),*ch.begin())==2&&count(all(s),*s1)==2)
  {
    cout<<"Yes";
  }
  else
    cout<<"No";



    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <deque>
#include <memory.h>
#define mem(a,b) memset(a, b, sizeof(a))
using namespace std;
const int maxn = 1e5+5;
bool vis[maxn];
vector<int> vex;
vector<int> G[maxn];
deque<int> dq;
int n, m;
void Init(){
        mem(vis,0);
        vex.clear();
        dq.clear();
        for(int i = 0; i <= n; i++){
            G[i].clear();
        }
}
int main(){
    while(scanf("%d %d", &n, &m) != EOF){
        int x, y;
        Init();
        for(int i = 0; i < m; i++)
        {
            scanf("%d %d",&x, &y);
            G[x].push_back(y);
            G[y].push_back(x);
        }
        dq.push_back(1);
        vis[1] = true;
        bool fg = true, fg2 = true;
        while(fg || fg2){
            fg = false;
            int st = dq.front();
            for(int i = 0; i < G[st].size(); i++){
                if(!vis[G[st][i]])
                {
                    vis[G[st][i]] = true;   
                    dq.push_front(G[st][i]);
                    fg = true;
                    break;
                }
            }
            fg2 = false;
            int ed = dq.back();
            for(int i = 0; i < G[ed].size(); i++){
                if(!vis[G[ed][i]])
                {
                    vis[G[ed][i]] = true;   
                    dq.push_back(G[ed][i]);
                    fg2 = true;
                    break;
                }
            }

        }
        printf("%d\n", dq.size());
        while(!dq.empty()){
            printf("%d ", dq.front());
            dq.pop_front();
        }
        printf("\n");
    }
    return 0;
}

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

int main(){
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a+b << endl;
    else cout << a-b << endl;
    return 0;
}

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

int main(){
  ll n, q;
  cin >> n >> q;

  ll ans = (n-2)*(n-2);
  ll minh = n, minw = n;
  vector<ll> a(n+1,n), b(n+1,n);

  rep(i,q){
    ll t, x;
    cin >> t >> x;
    if(t == 1) {
      if(x<minw){
        for(int j = x; j<minw; j++){
          b[j] = minh;
        }
        minw = x;
      }
      ans -= b[x] -2;
    }else{
      if(x < minh){
        for(int j = x; j<minh; j++){
          a[j] = minw;
        }
        minh = x;
      }
      ans -= a[x]-2;
    }
  }
  

  cout << ans << endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }

  vector< vector<long long> > dp(n + 1, vector<long long>(n + 1));
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j + i <= n; j++) {
      dp[j][j + i] = 1e18;
      for (int k = 1; k < i; k++) {
        dp[j][j + i] = min(dp[j][j + i], dp[j][j + k] + dp[j + k][j + i] +
                          sum[j + i] - sum[j] );
      }
    }
  }
  cout << dp[0][n] << '\n';
  return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ret = 0;
    for(int i=0; i<N; ++i) {
        int t;
        cin >> t;
        if(t < A || B <= t) {
            ret++;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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



ll findgcd(ll,ll);

int main(){
    
    int N;
    cin >> N;
    vector<ll> x(N+1), d(N);
    for(int i=0;i<N+1;i++) cin >> x[i];
    sort(x.begin(),x.end());
    d[0] = x[1] - x[0];
    for(int i=1;i<N;i++){
        d[i] = findgcd( d[i-1] , x[i+1] - x[i] );
    }
    
    cout << d[N-1] << endl;
    
    return 0;
}

ll findgcd(ll a,ll b)
{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b==0) return a;
    // 0とのgdcはその数そのものと定義
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   ll x,d,k;
           cin>>x>>k>>d;
           ll ans=0;
           x=abs(x);
             ll step_max=x/d+1;//負までいける回数
                 if(k<step_max){
                   ans=x-d*k;
                 }
                 else{
                           //ans=min((x-x/d*d),(x-x/d*d-d));
                           if(k%2==x/d%2){
                            ans=x-x/d*d; 
                           }
                           else{
                            ans=x-x/d*d-d; 
                             ans=abs(ans);
                   }
                 }
           cout<<ans<<endl;
}

Measured memory_bytes: 3628
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    int n;
    cin >> n;

    int arr1[n], arr2[n];

    char a1[n], a2[n];

    for(int i = 0; i < n; i++){
        cin >> a1[i];
        arr1[i] = a1[i] - '0';
    }

    for(int i = 0; i < n; i++){
        cin >> a2[i];
        arr2[i] = a2[i] - '0';
    }

    int myints[n];

    for(int i = 0; i < n; i++) myints[i] = i + 1;

    int cnt1 = 0, cnt2 = 0;

    do {
        int cnt3 = 0;
        for(int i = 0; i < n; i++){
            if(myints[i] == arr1[i]) cnt3++;
        }
        if(cnt3 == n) break;
        cnt1++;
    } while ( std::next_permutation(myints,myints + n) );

    sort(myints, myints + n);

    do {
        int cnt3 = 0;
        for(int i = 0; i < n; i++){
            if(myints[i] == arr2[i]) cnt3++;
        }
        if(cnt3 == n) break;
        cnt2++;
    } while ( std::next_permutation(myints,myints + n) );

    cout << abs(cnt1 - cnt2);
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve() {
	n := getInt()
	as := getIntSlice(n)
	sort.Ints(as)

	c1, c2 := as[n-1]/2, (as[n-1]+1)/2
	minDist := inf
	ans := []int{as[n-1], 0}
	for _, a := range as {
		d := min(abs(a-c1), abs(a-c2))
		if d < minDist {
			ans[1] = a
			minDist = d
		}
	}

	fmt.Fprintln(wr, ans[0], ans[1])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 3072
#include<iostream>
#define ll long long
#define P pari<int,int>
#define mk make_pair
const int N = 1e5+10;
using namespace std;

int main()
{
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++)
   {
        if(s[i] == '?')
            s[i] = 'D';
   }
   cout << s;
    return 0;
}


Measured memory_bytes: 3760
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] c;
    int y, i;

    c = new int[51];
    for(i = 0;i < 51;i++)c[i] = 850 * 200;
    c[0] = 0;
    for(i = 0;i < 51;i++){
      if(i + 2 < 51 && c[i] + 380 < c[i + 2])c[i + 2] = c[i] + 380;
      if(i + 3 < 51 && c[i] + 550 < c[i + 3])c[i + 3] = c[i] + 550;
      if(i + 5 < 51 && c[i] + 850 < c[i + 5])c[i + 5] = c[i] + 850;
      if(i + 10 < 51 && c[i] + 1900 * 8 / 10 < c[i + 10])
        c[i + 10] = c[i] + 1900 * 8 / 10;
      if(i + 12 < 51 && c[i] + 2200 * 85 / 100 < c[i + 12])
        c[i + 12] = c[i] + 2200 * 85 / 100;
      if(i + 15 < 51 && c[i] + 2550 * 88 / 100 < c[i + 15])
        c[i + 15] = c[i] + 2550 * 88 / 100;
    }

    for(;;){
      y = sc.nextInt(); if(y == 0)break;
      out.println(c[y / 100]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int main() {
  ll n,count=0,a,b,t=-1000000000;
  cin >> n;
  vector<vector<ll>> v(n,vector<ll>(2,0));
  r(i,n)r(j,2)cin >> v[i][j];
  r(i,n){
    a=v[i][0]; b=v[i][1];
    v[i][0]=a+b; v[i][1]=a-b;
  }
  sort(v.begin(),v.end());
  r(i,n){
    if(t<=v[i][1]){
      count++;
      t=v[i][0];
    }
  }
cout<<count<<endl;
}

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

#define int long long int
#define fi first
#define so second
#define ps push_back
#define ld long double
#define mod 1000000007

signed main()
{
    int n,ct=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int c=0,t=i;
        while(t) {c++;t/=10;}
        if(c%2!=0) ct++;
    }
    cout<<ct;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
const int N = 100010;
int mod = 1000000007;
int main()
{
//	freopen("in.txt", "r", stdin);
	int n, m;
	while (~scanf("%d%d", &n, &m))
	{
		if (n == 1 && m == 1)
			printf("1\n");
		else if (n == 1)
			printf("%d\n", m - 2);
		else if (m == 1)
			printf("%d\n", n - 2);
		else
		{
			printf("%lld\n", (ll)(n-2)*(m-2));
		}
	}
   	return 0;
}

Measured memory_bytes: 256
import numpy as np
h, w, k = [int(w) for w in input().split()]
lc = [[1 if w == "#" else 0 for w in list(input())] for _ in range(h)]

lc = np.array(lc)

ans = 0
for i in range(2 ** h):
    # を採用したとき
    cntb = np.zeros(w)
    for j in range(h):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            cntb += lc[j]

    for ii in range(2 ** w):
        t = 0
        for jj in range(w):
            if ((ii >> jj) & 1):
                t += cntb[jj]
        if t == k:
            ans += 1

print(ans)


Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1e18;

int g[10000][10000];

signed main(){
  int n,m;
  cin>>n>>m;
  REP(i,n)REP(j,n)g[i][j]=i==j?0:INF;
  REP(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a][b]=-c;
  }

  REP(k,n)REP(i,n)REP(j,n){
    //if(g[i][k]!=INF&&g[k][j]!=INF)
    g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
  }
  int flag=false;
  //REP(i,n)if(g[i][i]<0)flag=true;
  if(g[0][0]!=0){
    cout<<"inf"<<endl;
  }else{
    cout<<-g[0][n-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 78336
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, M;
string word1[50000], word2[50000];

int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++){
		cin >> word1[i];
		word2[i] = word1[i];
		reverse(word2[i].begin(), word2[i].end());
	}
	sort(word1, word1+N);
	sort(word2, word2+N);

	for(int i=0; i<M; i++){
		string S;
		cin >> S;
		int idx = -1;
		for(int j=0; j<S.size(); j++){
			if(S[j] == '?') idx = j;
		}
		int ans = 0;
		if(idx == -1){
			if(S[0] == '*'){
				reverse(S.begin(), S.end());
				S.resize(S.size()-1);
				ans -= lower_bound(word2, word2+N, S) - word2;
				S[S.size()-1]++;
				ans += lower_bound(word2, word2+N, S) - word2;
			}
			else if(S[S.size()-1] == '*'){
				S.resize(S.size()-1);
				ans -= lower_bound(word1, word1+N, S) - word1;
				S[S.size()-1]++;
				ans += lower_bound(word1, word1+N, S) - word1;
			}
			else{
				ans -= lower_bound(word1, word1+N, S) - word1;
				S += 'a';
				ans += lower_bound(word1, word1+N, S) - word1;
			}
		}
		else{
			string T = S;
			for(int j=0; j<26; j++){
				S = T;
				S[idx] = 'a' + j;
				if(S[0] == '*'){
					reverse(S.begin(), S.end());
					S.resize(S.size()-1);
					ans -= lower_bound(word2, word2+N, S) - word2;
					S[S.size()-1]++;
					ans += lower_bound(word2, word2+N, S) - word2;
				}
				else if(S[S.size()-1] == '*'){
					S.resize(S.size()-1);
					ans -= lower_bound(word1, word1+N, S) - word1;
					S[S.size()-1]++;
					ans += lower_bound(word1, word1+N, S) - word1;
				}
				else{
					ans -= lower_bound(word1, word1+N, S) - word1;
					S += 'a';
					ans += lower_bound(word1, word1+N, S) - word1;
				}
			}
		}
		cout << ans << endl;
	}
}


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

long double n, m;
string s, t;
long double ans;

void in();
void solve();
void out();

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    in();
    solve();
    out();
}

void in(){
    cin >> n;
}

void solve(){
    long double a = n / 3;
    ans = a * a * a;
}
void out(){
    cout << fixed << setprecision(20) << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[12],n;
int f(int i, int cur){
	if(i==n+1) return !(cur&1);
	return f(i+1,cur*(ar[i]-1))+f(i+1,cur*ar[i])+f(i+1,cur*(ar[i]+1));
}
int32_t main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	cout<<f(1,1);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	vector<pii> v(m);
	vector<int> idx(n+1,0);
	stack<char> ans[m];
	map<pii,int> mp;
	FOR(i,0,m){
		int a,b;
		cin>>a>>b;
		v[i]=MP(b,a);
		mp[MP(b,a)]=i;
	}
	sort(v.begin(),v.end());
	FOR(i,0,m){
		int a=v[i].ND,b=v[i].ST;
		LL num=++idx[a];
		num=a*1000000LL+num;
		int tmp=mp[MP(b,a)];
		while(num>0){
			ans[tmp].push('0'+num%10);
			num/=10;
		}
		while(ans[tmp].size()!=12)ans[tmp].push('0');
	}
	FOR(i,0,m){
		while(ans[i].size()){
			cout<<ans[i].top();
			ans[i].pop();
		}
		cout<<endl;
	}
    return 0;
}


Measured memory_bytes: 76160
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
    ll x,sum=0,ans=0;
    cin >> x;
    if(x<=6) cout << 1<<endl;
    else if(x<=11){
      cout <<2<<endl;
    }
    else{
    sum+=(x/11);
    if(x%11>6) cout <<sum*2+2<<endl;
    else if (x%11==0)cout << sum*2<<endl;
    else cout << sum*2+1<<endl;
 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> b(n - 1);
    for (auto i : irange(0L, n - 1)) {
        cin >> b[i];
    }

    int64_t ans = 0;
    ans += b[0];
    for (auto i : irange(1L, n - 1)) {
        ans += min(b[i - 1], b[i]);
    }
    ans += b[n - 2];

    cout << ans << endl;
}

Measured memory_bytes: 256