akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  string s,su,sd;
  cin >> s >> sd;
  for(int j = 0; j < W; j++){
    int num = 0;
    if(s[j] == '#')
      continue;
    if(s[j-1] == '#')
      num++;
    if(s[j+1] == '#')
      num++;
    if(sd[j] == '#')
      num++;
    if(sd[j-1] == '#')
      num++;
    if(sd[j+1] == '#')
      num++;
    s[j] = '0' + num;
  }
  cout << s <<endl;
  for(int i = 0; i < H-2; i++){
    su = s;
    s = sd;
    cin >> sd;
    for(int j = 0; j < W; j++){
      int num = 0;
      if(s[j] == '#')
        continue;
      if(s[j-1] == '#')
        num++;
      if(s[j+1] == '#')
        num++;
      if(sd[j] == '#')
        num++;
      if(sd[j-1] == '#')
        num++;
      if(sd[j+1] == '#')
        num++;
      if(su[j] == '#')
        num++;
      if(su[j-1] == '#')
        num++;
      if(su[j+1] == '#')
        num++;
      s[j] = '0' + num;
    }
    cout << s <<endl;
  }
  su = s;
  s = sd;
  for(int j = 0; j < W; j++){
    int num = 0;
    if(s[j] == '#')
      continue;
    if(s[j-1] == '#')
      num++;
    if(s[j+1] == '#')
      num++;
    if(su[j] == '#')
      num++;
    if(su[j-1] == '#')
      num++;
    if(su[j+1] == '#')
      num++;
    s[j] = '0' + num;
  }
  cout << s <<endl;
}

Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val num = readLine()!!.split(" ").map { it.toInt() }
    val ans = num.indices.map { idx-> (idx until n).map { Math.abs(num[idx] - num[it]) }.max()!! }.max()!!
    println(ans)
}



Measured memory_bytes: 38592
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int main(){
	string s;
	cin>>s;
	bool f, F, fn, fs;
	f = F = fn = false;
	fs = s.size() >= 6;
	rep(i, s.size()){
		if(s[i]>='a'&&s[i]<='z') f = true;
		else if(s[i] >= 'A' && s[i] <= 'Z') F = true;
		else if(s[i] >= '0' && s[i] <= '9') fn = true;
	}
	cout<<(f&F&fn&fs?"VALID":"INVALID")<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
const int inf = (int)(1e7);

int n, ar[N], dp[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];

	fill(dp + 1, dp + n + 1, inf);

	dp[0] = inf;
	dp[1] = 0;

	for(int i = 2; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(ar[i] - ar[i - 1]), dp[i - 2] + abs(ar[i] - ar[i - 2]));

	cout << dp[n];
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n,y;
    cin >> n >> y;
    for (int i = 0;i <= n;i++){
        for (int j = 0;j <= n;j++){
            if (10000*i+5000*j+1000*(n-i-j) == y && n-i-j >= 0){
                cout << i << " " << j << " " << n-i-j  << endl;
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
    
}

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

int main(void){
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;

    ll ans = 0;
    if(10 % p == 0){
        for(int i=0;i<n;i++){
            if((s[i]-'0')%p==0) ans += i+1; 
        }
    }else{
        vector<int> d(n+1,0);
        int ten = 1;
        for(int i=n-1;i>=0;i--){
            int tmp = (s[i]-'0')*ten % p;
            d[i] = (d[i+1]+tmp)%p;
            ten *= 10; ten %= p;
        }

        map<int,ll> mp;
        for(int i=0;i<=n;i++) mp[d[i]]++;
        for(auto p: mp){
            ll k = p.second;
            k *= k-1; k /= 2;
            ans += k;
            //cout << "mod:" << p.first << ", num:" << p.second << endl;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1796
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

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

using P = pair<ll, ll>;
using TP = tuple<ll, ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

/*
 Warshall–Floyd Algorithm
 */
void warshall_floyd(ll N, vector<vector<ll>>& d){
  REP(k,N){
    REP(i,N){
      REP(j,N){
        // update distance from i to j via k
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
}

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

  ll N,M,L;
  cin >> N >> M >> L;
  vector<vector<ll>> d(N, vector<ll>(N,INF));
  REP(i,M) {
    ll ai, bi, ci;
    cin >> ai >> bi >> ci;
    if (ci <= L){
      ai--;bi--;
      d[ai][bi] = ci;
      d[bi][ai] = ci;
    }
  }

  warshall_floyd(N,d);

  vector<vector<ll>> dc(N, vector<ll>(N,INF));
  REP(i,N){
    REP3(j,1,N){
      if (d[i][j]<=L){
        dc[i][j] = 1;
        dc[j][i] = 1;
      }
    }
  }
  warshall_floyd(N,dc);

  ll Q;
  cin >> Q;
  REP(i,Q) {
    ll si, ti;
    cin >> si >> ti;
    si--;ti--;

    ll ans = (dc[si][ti]!=INF) ? dc[si][ti]-1 : -1;
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 1920
from collections import Counter
from itertools import count


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def index_counter(e):
    c = 0
    for i in count(start=1):
        e -= i
        if e >= 0:
            c += 1
        else:
            break
    return c


N = int(input())
prime_factors = Counter(prime_factorize(N))
ans = 0
for key, value in prime_factors.items():
    ans += index_counter(value)
print(ans)


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

ll dp[105][100005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,W;
    
    memset(dp,0,sizeof(dp));

    cin>>n>>W;
    
    ll *v = new ll[n+1]{0};
    ll *w = new ll[n+1]{0};
    
    for(ll i=1;i<=n;++i)
    {
        cin>>w[i]>>v[i];
    }

    for(int i=w[1];i<=W;++i)
    {
        dp[1][i] = v[1];
    }

    for(ll i=2;i<=n;++i)
    {
        for(ll x = 1;x<=W;++x)
        {
            dp[i][x] = dp[i-1][x];
            if(w[i] > x)
                continue;
            dp[i][x] = max(dp[i][x],dp[i-1][x-w[i]] + v[i]);
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 82432
n = int(input())
a = 0
b = 0
ans = 1000000000
for i in range(1, n):
    a = n - i
    b = n - a
    a = list(map(int,str(a)))
    b = list(map(int,str(b)))
    if sum(a) + sum(b) <= ans:
        ans = sum(a) + sum(b)
print(ans)


Measured memory_bytes: 74720
import Foundation

let N = Int(readLine()!)!

var countAC = 0
var countWA = 0
var countTLE = 0
var countRE = 0

for _ in 0..<N {
    switch readLine()! {
    case "AC":
        countAC += 1
    case "WA":
        countWA += 1
    case "TLE":
        countTLE += 1
    case "RE":
        countRE += 1
    default:
        fatalError()
    }
}

print("AC x \(countAC)")
print("WA x \(countWA)")
print("TLE x \(countTLE)")
print("RE x \(countRE)")


Measured memory_bytes: 13080
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, x;
    cin >> n;
    for(int i = 1;i <= n;i++){
        x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }
        else{
            while(x > 0){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(void)
{
	char str[400];
	int i;
	
	gets(str);
	
	for (i = 0; str[i] != '\0'; i++){
		if (str[i] >= 'a' && str[i] <= 'z'){
			str[i] -= 0x20;
		}
	}
	
	printf("%s\n", str);
	
	return (0);
}

Measured memory_bytes: 524
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int X=0,A=0,B=0;
  cin >> X >> A >> B;
  cout << (X-A)%B << endl;

  return 0;
}

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

int w,h;
int c[60][60];

void dfs(int x,int y){
    c[x][y]=0;
    
    for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){
            int nx=x+dx,ny=y+dy;
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&c[nx][ny]==1)dfs(nx,ny);
        }
    }
    
    return ;
}

int main(void){
    while(1){
        cin>>w>>h;
        if(w==0&&h==0)break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>c[i][j];
            }
        }
        int res=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(c[i][j]==1){
                    dfs(i,j);
                    res++;
                }
            }
        }
        cout<<res<<endl;
    }
    return 0;
}



Measured memory_bytes: 3244
N, X = list(map(int,input().split()))
m = [int(input()) for i in range(N)]
m_min = 1000000
hantei = 1
ans = 0

for j in range(N):
    X = X - m[j]
    ans += 1
    m_min = min(m_min,m[j])

while hantei == 1:
    X -= m_min
    if X >= 0:
        ans += 1
    else:
        hantei = 0

print(ans)

Measured memory_bytes: 3064
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e9;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int s;
    cin>>s;
    cout<<"0 0 ";
    cout<<inf<<" 1 ";
    int x=(inf-(s%inf))%inf;
    int y=(s+x)/inf;
    cout<<x<<" "<<y<<endl;
    return 0;

}






































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

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

	for (int i = 1; i <= 2000; i++)
	{
		int x = i * 8 / 100;
		int y = i * 10 / 100;
		if (x == A && y == B)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 long long N, A[87], CurrentMoney = 1000;
 int main() {
 cin >> N;
 for (int i = 1; i <= N; i++) cin >> A[i];
 for (int i = 1; i <= N - 1; i++) {
 long long Stocks = 0;
 if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
 CurrentMoney += (A[i + 1] - A[i]) * Stocks;
 }
 cout << CurrentMoney << endl;
 }

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,k; cin>>a>>b>>c>>k;
	ll mn=min(k,a);
	k-=mn;a-=mn;
	ll sum=mn;
	mn=min(b,k);
	k-=mn;
	b-=mn;
	mn=min(k,c);
	if(mn>0)
		sum-=mn;
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 3648
n,m=[int(x) for x in input().split()]
t=[0 for i in range(n)]
for i in range(m):
  a,b=[int(x) for x in input().split()]
  if a==1:
    t[b-1]+=1
  if b==n:
    t[a-1]+=1
    
if 2 in t:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 4656
using System;


class Prime_Numbers
{
    public static void Main()
    {
      int n = int.Parse(Console.ReadLine());
      int cnt = n;
      
      for(int i=0;i<n;i++)
      {
        int number = int.Parse(Console.ReadLine());
        int rtnum = (int)Math.Sqrt(number);
        
        for(int j=2;j<=rtnum;j++)
        {
          if(number%j==0)
          {
            
            cnt--;
            break;
          }
        }
     }
     
     Console.WriteLine(cnt);
    }
}

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

int main( int argc, char *argv[] )
{
    long long a = 100;
    long long x;

    scanf( "%lld", &x );

    for( int i=1; ; i++ ) {

        a *= 1.01;

        if( a >= x ) {
            printf( "%d\n", i );
            exit( 0 );
        }
    }

    puts( "NG" );
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int a,b,c,k;cin>>a>>b>>c>>k;
  int ans = 0;
  ans += min(a,k);
  k -= min(a,k);
  k -= min(b,k);
  ans -= min(k,c);
  print(ans);
  return 0; 
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
  int a,b,c,k,i,max,ans=0;
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a>b)
    {
      if(a>c)
	{
	  max = a;
	  a=0;
	}
      else
	{
	  max = c;
	  c=0;
	}
    }
  else
    {
      if(b>c)
	{
	  max = b;
	  b=0;
	}
      else
	{
	  max = c;
	  c=0;
	}
    }
  for(i=0;i<k;i++)
    {
      max *= 2;
    }
  ans = max+a+b+c;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static String[] mySplit(String str){return str.split("");}
        public static void main(String[] args){
          int N = getInt();
          int output = 0;
          int check = 0;
          while(N > check){
            output++;
            check = check + output;
          }
          myout(output);
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

double distance(double xi, double yi, double xj, double yj) {
    return sqrt((xi - xj) * (xi - xj) + (yi - yj) * (yi - yj));
}

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

    int N;
    cin >> N;
    vector<double> x, y;
    for (int i = 0; i < N; i++) {
        double tmp_x, tmp_y;
        cin >> tmp_x >> tmp_y;
        x.emplace_back(tmp_x);
        y.emplace_back(tmp_y);
    }

    double dis[10][10];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dis[i][j] = distance(x[i], y[i], x[j], y[j]);
            dis[j][i] = distance(x[i], y[i], x[j], y[j]);
        }
    }

    vector<int> permutation;
    for (int i = 0; i < N; i++) {
        permutation.emplace_back(i);
    }
    double ans = 0;
    int div_num = 0;
    do {
        div_num++;
        int now = permutation[0];
        for (int i = 1; i < N; i++) {
            int next = permutation[i];
            ans += dis[now][next];
            now = next;
        }
    } while (next_permutation(ALL(permutation)));

    cout << std::setprecision(10) << ans / div_num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=1;i<n-1;i++){
        vector<ll> v;
        v.push_back(arr[i-1]);
        v.push_back(arr[i]);
        v.push_back(arr[i+1]);
        sort(v.begin(),v.end());
        if(v[1]==arr[i])
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    double a, b;
    cin >> a >> b;
    cout << ceil((a + b)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())

if N >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10448
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool IsPrime[15000];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, 15000);
	for(int i = 2; i < 15000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 15000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		for(int i = 0; Prime[i] <= n; ++i)
		{
			int sum = 0;
			int pos = i;
			while(sum < n)
			{
				sum += Prime[pos];
				pos++;
			}
			if(sum == n)
			{
				count++;
			}
		}
		cout << count << endl;
	}

}

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

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>

using namespace std;

class stack{
public:
  int size;
  int data[1000];
  int top;
  void push(int x);
  int pop();
  bool isEmpty();
  bool isFull();

  stack():top(0){}
};

void stack::push(int x){
  if(top==size){
    cout << "Stack is Full"<<endl;
  }else{
    data[top+1]=x;
    top+=1;
  }
}
int stack::pop(){
  int send;
  if(top==0){
    cout << "Stack is Empty"<<endl;
    return 0;
  }else{
    send=data[top];
    top-=1;
    return send;
  }
}
bool stack::isEmpty(){
  if(top==0){
    return true;
  }else{
    return false;
  }
}
bool stack::isFull(){
  if(top==size){
    return true;
  }else{
    return false;
  }
}


int main() {
  stack S;
  char s[1000];
  int op1,op2;
  S.size=1000;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      op2=S.pop();
      op1=S.pop();
      S.push(op1+op2);
    }else if(s[0]=='-'){
      op2=S.pop();
      op1=S.pop();
      S.push(op1-op2);
    }else if(s[0]=='*'){
      op2=S.pop();
      op1=S.pop();
      S.push(op1*op2);
    }else{
      S.push(atoi(s));
    }
  }
  cout <<S.pop()<<endl;

}



Measured memory_bytes: 3172
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()
  for a in range(-500,501):
    for b in range(-500,501):
      if a**5-b**5==x:
        return str(a)+' '+str(b)

# main()
print(main())


Measured memory_bytes: 10788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int main(){
  int n, m, sum = 0;
  cin >> n;
  vector<int> T(n);
  rep(i, n) { cin >> T[i]; sum += T[i]; }
  cin >> m;
  vector<int> P(m), X(m);
  rep(i, m) cin >> P[i] >> X[i];

  rep(i,m){
    int res = sum - T[P[i]-1] + X[i];
    cout << res << ln;
  }
}


Measured memory_bytes: 256
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
    print(-1)
else:
    m=(n-1)+(n-1)*(n-2)//2-k
    print(m)
    for i in range(n-1):
        print(i+1,n)
    count=(n-1)*(n-2)//2-k
    import sys
    for i in range(1,n):
        for j in range(i+1,n):
            if count==0:
                sys.exit()
            print(i,j)
            count=count-1


Measured memory_bytes: 42736
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <time.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  int f = 1;
  vector<int> kekka(10005);
  //clock_t start = clock();
  //  int n = sqrt(i) ;
    for(int x = 1;x <= 100;++x){

        for(int y = 1;y <= 100;++y){

            for(int z = 1;z <= 100;++z){
              f = x*x + y*y + z*z + x*y + y*z + z*x;
              if(f <= N){
                kekka.at(f)++;
}
            }

        }

    }
  for(int i = 1;i <= N;i++){
    cout << kekka.at(i) << endl;
  }
  //clock_t end = clock();
  //cout << (double)(end - start) / CLOCKS_PER_SEC << endl;
}
/*int main(){
  int N;
  cin >> N;
  for(int i = 1;i <= N;i++){
    int count = 0;
    for(int x = 1; x < sqrt(N) + 1;x++){
      for(int y = x;y < sqrt(N) + 1;y++){
        for(int z = y;z < sqrt(N) + 1;z++){
          int judge = x*x + y*y + z*z + x*y + y*z + z*x;
          if(judge > i){
            break;
          }else if(judge == i){
            if(x == y && y == z){
              count++;
            }else if(x != y && y != z && z != x){
              count += 6;
            }else{
              count += 3;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}*/


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

int main()
{
    int N;
    cin >> N;
    vector<int> result;
    int modify_count = 0;

    deque<int> array(N);
    for (int i = 0; i < N; i++) {
        cin >> array.at(i);
    }

    int end_pos = N;
    for (int i = 0; i < end_pos; i++) {
        if (array[i] != i + 1) {
            array.pop_front();
            i--;
            end_pos--;
            modify_count++;
        } else {
            result.push_back(array[i]);
        }
    }

    if (result.size() == 0) {
        cout << -1 << endl;
    } else {
        cout << modify_count << endl;
    }

    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N),b(N),c(N);
  for(ll i=0;i<N;i++) cin >> a[i];
  for(ll i=0;i<N;i++) cin >> b[i];
  for(ll i=0;i<N;i++) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll ans=0;
  for(int i=0;i<N;i++) {
    ans+=((lower_bound(a.begin(),a.end(),b[i])-a.begin())*(c.end()-upper_bound(c.begin(),c.end(),b[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
n,k = map(int,input().split())
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    if i == 0:
        ans = [i for i in range(1,n+1)]
    for i in a:
        if i in ans:
            ans.remove(i)
print(len(ans))

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

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

    if(X < 600){
        cout << "8";
    }else if(X < 800){
        cout << "7";
    }else if(X < 1000){
        cout << "6";
    }else if(X < 1200){
        cout << "5";
    }else if(X < 1400){
        cout << "4";
    }else if(X < 1600){
        cout << "3";
    }else if(X < 1800){
        cout << "2";
    }else if(X < 2000){
        cout << "1";
    }
}

Measured memory_bytes: 3632
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var nums = input.split(' ');
    var X = nums[0]
    var Y = nums[1]
    var Z = nums[2]
    console.log(Z+'\ '+X+'\ '+Y);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void) {
  int n;
  cin >> n;
  string s[n];
  int t[n];
  rep (i, n) {
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;

  bool add = false;
  ll ans = 0;

  rep (i, n) {
    if (add) ans += t[i];
    if (s[i] == x) add = true; 
    
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

vector<vector<P>> G(256, vector<P>());
int N, M, R, a, b, c, r;

void dijkstra(int f, vector<int> &dist){
	priority_queue<P, vector<P>, greater<P>> Q;
	dist[f] = 0;
	Q.emplace(dist[f], f);
	while(!Q.empty()){
		int ncost = Q.top().first;
		int nf = Q.top().second;
		Q.pop();
		if(ncost > dist[nf])continue;
		for(auto x:G[nf]){
			if(dist[x.first] > ncost + x.second){
				dist[x.first] = ncost + x.second;
				Q.emplace(dist[x.first], x.first);				
			}
		}
	}
}

int main(){
	cin >> N >> M >> R;
	int rts[R];
	G.resize(N);
	rep(i,R){
		cin >> r;
		--r;
		rts[i] = r;
	}
	sort(rts, rts + R);
	rep(i,M){
		cin >> a >> b >> c;
		--a; --b;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	vector<vector<int>> dist(N, vector<int>(N, inf));
	rep(i,N)dijkstra(i, dist[i]);
	int ans = inf;
	do{
		int e_ans = 0;
		rep(i,R-1){
			e_ans += dist[rts[i]][rts[i+1]];
		}
		ans = min(ans, e_ans);
	}while(next_permutation(rts, rts + R));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char>> grid(h,vector<char>(w));
	int cnt_black = 0;
	rep(i,h) rep(j,w){
		cin >> grid[i][j];
		if(grid[i][j] == '#') cnt_black++;
	}
	
	vector<int> dy = {0,1,0,-1};
	vector<int> dx = {1,0,-1,0};
	vector<vector<ll>> d(h,vector<ll>(w,INF));
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	while(!q.empty()){
		int y = q.front().first, x = q.front().second;
		rep(i,4){
			int ny = y+dy[i], nx = x+dx[i];
			if(ny < 0 || ny > h-1 || nx < 0 || nx > w-1)
				continue;
			if(grid[ny][nx] == '.' && d[ny][nx] == INF){
				d[ny][nx] = d[y][x]+1;
				q.push(make_pair(ny,nx));
			}
		}
		q.pop();
	}

	if(d[h-1][w-1] == INF){
		cout << -1 << endl;
		return 0;
	}
	int ans = h*w - cnt_black - (d[h-1][w-1]+1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

int main() {
	int H, W, h, w;
	std::cin >> H >> W >> h >> w;

	if (H % h == 0 && W % w == 0) {
		puts("No");
		return 0;
	}
	
	constexpr int INF = 1e9;

	puts("Yes");
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i % h == 0 && j % w == 0) {
				printf("%d ", INF - 1);
			} else if (i % h == h - 1 && j % w == w - 1) {
				printf("%d ", -INF);
			} else {
				printf("%d ", 0);
			}
		}
		puts("");
	}
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int month[12]={0,3,4,0,2,5,0,3,6,1,4,6};
int main(){
  int m,d;
  while(cin >>m>>d,m||d){
    switch((d+month[m-1])%7){
    case 1:
      cout <<"Thursday"<<endl;break;
    case 2:
      cout <<"Friday"<<endl;break;
    case 3:
      cout <<"Saturday"<<endl;break;
    case 4:
      cout <<"Sunday"<<endl;break;
    case 5:
      cout <<"Monday"<<endl;break;
    case 6:
      cout <<"Tuesday"<<endl;break;
    case 0:
      cout <<"Wednesday"<<endl;break;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n;
ll x, y;
int main(){
	cin >> x >> y;
	if(x % y == 0) {
		cout << -1 << endl;
		return 0;
	}

	ll m = 1;
	while(1) {
		if(x * m > 1000000000000000000){
			cout << -1 << endl;
			return 0;
		}
		if(x * m % y != 0) {
			cout << x * m <<  endl;
			break;
		}
		m++;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int MaxN = 1e5 + 10;

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Fri Sep 29 19:39:00 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint64_t N, K;
  cin >> N >> K;

  uint64_t count = K;
  for (uint32_t i = 1; i < N; i++) {
    count *= K - 1;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    //int a,b,c,d;
    char a,b,c;
    int i=0;
    cin>>a>>b>>c;
    if(a-'a'+b-'a'+c-'a'==3) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;

typedef long long int ll;



int main(void)
{

    int N;
    cin >> N;
    vector< int > x(N), y(N);
    vector< pair<int, int> > Sum(N); // max, index
    vector< pair<int, int> > Minus(N);

    for(int i=0; i<N; i++)
    {
        cin >> x[i] >> y[i];
        Sum[i].first = x[i] + y[i];
        Sum[i].second = i;
        Minus[i].first = x[i]-y[i];
        Minus[i].second = i;
    }

    sort(Sum.begin(), Sum.end() );
    sort(Minus.begin(), Minus.end() );

    int MaxSum = Sum[N-1].first-Sum[0].first;
    int id1 = Minus[N-1].second;
    int id2 = Minus[0].second;
    // cout << "ID " << id1 << " " << id2 << endl;
    int MinusSum = abs(x[id1]-x[id2]) + abs(y[id1]-y[id2]);
    // cout << MaxSum << " " << MinusSum << endl;
    cout << max(MaxSum, MinusSum) << endl;



    return 0;
}


Measured memory_bytes: 7976
S = input()

ans = 0

ALEN = (len(S))
 
B = list(S)
 
 
 
B_re =  list(reversed(B))
 
ans = 0
 

 
for i in range(ALEN):
  if B[i] != B_re[i]:
        ans = ans+1
    
if ans % 2 == 0:
    print(ans//2)
elif ans %2 != 0:
    print((ans//2) +1)
elif ans == 0:
    print(0)


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

int main(){
    long long n,a,b,c,d,e;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    vector<long long> capacities{a, b, c, d, e};
    sort(capacities.begin(), capacities.end());
    if (n % capacities[0] == 0){
        cout << 4 + n/capacities[0] << endl;
    } else {
        cout << 4 + n/capacities[0] + 1 << endl;
    }
    return 0;
}

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

class Main{
    public static void main(String args[]){
	int i,n=0;
	int A[] = new int[250];
	try{
	    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
	    String str = buffer.readLine();
	    n = Integer.parseInt(str);
	    StringTokenizer st = new StringTokenizer(buffer.readLine());
	    for(i=1;i<=n;i++){
		A[i] = Integer.parseInt(st.nextToken());
	    }
	}catch(Exception e){
	    System.out.println("error");
	}
	
	for(i=1;i<=n;i++){
	    System.out.print("node "+i+": ");
	    System.out.print("key = "+A[i]+", ");
	    if((i/2)!=0){
		System.out.print("parent key = "+A[i/2]+", ");
	    }
	    if((2*i) <= n){
		System.out.print("left key = "+A[2*i]+", ");
	    }
	    if(2*i+1 <= n){
		System.out.print("right key = "+A[2*i+1]+", ");	
	    }
	    System.out.println("");
	}
    }
}




Measured memory_bytes: 24980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  int H, W, N;
  cin >> H >> W >> N;

  if (H <= W) {
    int tmp = W;
    W = H;
    H = tmp;
  }

  int ans = 0;
  int cnt = 0;
  while (true) {
    if (ans < W) {
      ans++;
      cnt += H;
      if (cnt >= N) break;
    }
    else {
      ans++;
      cnt += W;
      if (cnt >= N) break;
    }
  }

  cout << ans << endl;
        

  return 0;
}


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

bool contain(int mask,int position){
    if((mask & (1<<position))!=0)return true;//ここのカッコが原因
    else return false;
}
int main(){
    string s;cin >> s;
    string t;
    int size=s.size()-1;
    for(int mask;mask < (1<<size);++mask){
        int sum=0;
        short int flag=0;
        t=s.substr(0,1);
        sum+=stoi(t);
        if(contain(mask,2)){
            t=s.substr(1,1);
            sum+=stoi(t);
            flag+=4;
        }else{
            t=s.substr(1,1);
            sum-=stoi(t);
        }
        if(contain(mask,1)){
            t=s.substr(2,1);
            sum+=stoi(t);
            flag+=2;
        }else{
            t=s.substr(2,1);
            sum-=stoi(t);
        }
        if(contain(mask,0)){
            t=s.substr(3,1);
            sum+=stoi(t);
            flag+=1;
        }else{
            t=s.substr(3,1);
            sum-=stoi(t);
        }
        if(sum==7){
            //cout << s.substr(0,1) << (contain(flag,3)==True)?"+":"-" << s.substr(1,1) << (contain(flag,2)==True)?"+":"-" << s.substr(2,1) << (contain(flag,1)==True)?"+":"-" << s.substr(3,1) << "=7" << endl;
            cout << s.substr(0,1);
            if(contain(flag,2)){
                cout << "+";
            }else{cout << "-";}
            cout << s.substr(1,1);
            if(contain(flag,1)){
                cout << "+";
            }else{cout << "-";}
            cout << s.substr(2,1);
            if(contain(flag,0)){
                cout << "+";
            }else{cout << "-";}
            cout << s.substr(3,1);
            cout << "=7"<<endl;
            break;

        }
    }

}


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

pub 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")
}

fn main() {
    let n: usize = read();

    if n == 1 {
        println!("Hello World")
    } else {
        println!("{}", read::<usize>() + read::<usize>());
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=3005;
const ll inf=1e9+7;
ll dp[maxn][maxn];
ll p[maxn][maxn];
string s,t;
int main()
{
    //IOS;
    while(cin>>s>>t)
    {
        memset(dp,0,sizeof(dp));
        rep1(i,s.size())
        {
            rep1(j,t.size())
            {
                if(s[i-1]==t[j-1]) //dp[i][j]=dp[i-1][j-1]+1;
                {
                    dp[i][j]=dp[i-1][j-1]+1;
                    p[i][j]=1;
                }
                else if(dp[i][j-1]>dp[i-1][j])
                {
                    dp[i][j]=dp[i][j-1];
                    p[i][j]=2;
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                    p[i][j]=3;
                }
            }
        }
        string ans="";
        ll a=s.size(),b=t.size();
        while(a>0&&b>0)
        {
            if(p[a][b]==1)
            {
                ans=s[a-1]+ans;
                a--,b--;
            }
            else if(p[a][b]==2) b--;
            else a--;
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 141440
N,A,B = map(int,input().split())
ans = 0
for i in range(1,int(N)+1):
    sum = 0
    num = i
    while(True):
        sum += num%10
        num = num//10
        if(num == 0):
            if(sum >= A and sum <= B):
                ans += i
                break
            else:
                break
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int n,i,a;
int ans=0;
  scanf("%d",&n);
vector<int> d(n);
  for(i=0;i<n;i++)cin>>d[i];
  sort(d.begin(),d.end());
  for(i=0;i<n;i++){
    if(i==0){
      a=d[i];
      ans++;
    }
    else{
      if(d[i]==a)continue;
      else{
        a=d[i];
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String s,t,u;
        int a,b,hako;
        hako=0;
        String[] abc=new String[2];
        int[] xyz=new int[2];
        try{
                s=reader.readLine();
                t=reader.readLine();
                a=Integer.parseInt(s);
                b=Integer.parseInt(t);
                int[] x=new int[a+1];
                x[0]=0;
                for(int j=1;j<(a+1);j++){
                    x[j]=j;
                }
                for(int i=0;i<b;i++){
                    u=reader.readLine();
                    abc=u.split(",");
                    for(int k=0;k<2;k++){
                        xyz[k]=Integer.parseInt(abc[k]);
                    }
                    hako=x[xyz[0]];;
                    x[xyz[0]]=x[xyz[1]];
                    x[xyz[1]]=hako;
                }
                for(int l=1;l<(a+1);l++){
                    System.out.println(x[l]);
                }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		long aSum = 0;
		long bSum = 0;
		boolean flg = true;
		for (int i = N - 1; i >= 0; i--) {
			if (flg) {
				aSum += input[i];
				flg = !flg;
			} else {
				bSum += input[i];
				flg = !flg;
			}
		}
		System.out.println(aSum - bSum);

	}
}


Measured memory_bytes: 36104
#include<stdio.h>
int main(void)
{
	int n,a[21],b[101],i,z,zz,max;
	max=-1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a[n],&b[n]);
		if(b[n]>max){
			max=b[n];
			z=a[n];
		}
		if(max==b[n]){
			if(z<a[n]){
			z=z;
			}
			else if(z>a[n]){
			z=a[n];
			}
		}
	}
	printf("%d %d\n",z,max);
	return 0;
}		

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;

int DFS(vector<int> G[],vector<bool> &has_done,int v){
	int result=0;
	has_done[v]=true;
	REP(i,0,G[v].size()){
		if(has_done[G[v][i]]) continue;
		result=max(result,DFS(G,has_done,G[v][i]));
	}
	has_done[v]=false;
	return result+1;
}

int DFS(vector<int> G[],vector<bool> &&has_done,int v){
	int result=0;
	has_done[v]=true;
	REP(i,0,G[v].size()){
		if(has_done[G[v][i]]) continue;
		result=max(result,DFS(G,has_done,G[v][i]));
	}
	has_done[v]=false;
	return result+1;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while(cin >> N&&N){
		vector<int> G[100];
		REP(i,0,N){
			int A,B;
			cin >> A >> B;
			--A;
			--B;
			G[A].push_back(B);
			G[B].push_back(A);
		}
		int ans=0;
		REP(i,0,100) ans=max(ans,DFS(G,vector<bool>(100),i));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a * b) % 2 == 0 ?  "Even" : "Odd");
    }
}


Measured memory_bytes: 23764
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
ps=[input().split() for i in range(m)]

dic={}
anslst=[0]*n
for i in range(m):
    p,s=ps[i]
    if s=="AC":
        dic[p]=1
    else:
        if p in dic:
            continue
        else:
            anslst[int(p)-1]+=1


ans=0
for i in dic.keys():
    ans+=anslst[int(i)-1]
print(len(dic),ans)

Measured memory_bytes: 114824
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll,ll> P;
template <typename T> std::string tostr(const T& t){std::ostringstream os; os<<t; return os.str();}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main(){
    string s;
    cin>>s;
    int n=s.length();
    //2文字ごとに確認
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<' '<<i+2<<endl;
            return 0;
        }
    }
    //3文字ごとに確認
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+2]){
            cout<<i+1<<' '<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<' '<<-1<<endl;
    return 0;
}

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

int main(){
	int sum = 0, n = 0;
	string s;

	while( getline(cin,s) ){
		for(int i=0 ; i<s.size() ; i++){
			if( s[i]>='0' && s[i]<='9'){
				n *= 10;
				n += s[i]-'0';
			}else{
				sum += n;
				n = 0;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 0