akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

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

    mint ans = n * (n + 1.0) * (n + 2.0) / 6.0 - k * (k - 1.0) * (3.0 * n - 2.0 * k + 4.0) / 6.0 + (n - k + 2.0);

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

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

int main() {
    int N;
    cin>>N;
    int n4 = N%10;
    int n3 = (N-n4)/10%10;
    int n2 = (N-n4-n3*10)/100%10;
    int n1 = (N-n4-n3*10-n2*100)/1000;
    if (n1==n2 && n2== n3){
         cout << "Yes" << endl;
    }
    else if (n2==n3 && n3==n4){
        cout << "Yes" << endl;
    }
    else{
           cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
	class Program
	{
		static void Main(string[] args)
		{
			int x = int.Parse(Console.ReadLine());

			if (x == 3 || x == 5 || x == 7)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");

			Console.ReadKey();


		  
		}

	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n,k;
int ans=0;
vector<int> nei[2050];
int dis[2050][2050];
bool crash[2050][2050];
int cnum[2050]; 
void bfs(int root){
	queue<int> q;
	dis[root][root]=0;
	q.push(root); 
	while(!q.empty()){
		int last=q.front();
		q.pop();
		for(int i=0;i<nei[last].size();i++){
			if(dis[root][nei[last][i]]==-1){
				dis[root][nei[last][i]]=dis[root][last]+1;
				q.push(nei[last][i]);
			}
		}
	}
}
bool nocrash(){
	for(int i=0;i<n;i++){
		if(cnum[i]>0) return false;
	}
	return true;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dis[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		bfs(i);
	}
	for(int i=0;i<n;i++){
		int num=0;
		for(int j=0;j<n;j++){
			if(dis[i][j]>k){
				crash[i][j]=true;
				num++;
			}
		}
		cnum[i]=num;
	}
	while(!nocrash()){
		int mx=-1,imx=-1;
		for(int i=0;i<n;i++){
			if(cnum[i]>mx){
				mx=cnum[i];
				imx=i;
			}
		}
		for(int i=0;i<n;i++){
			 crash[imx][i]=false;
			 if(crash[i][imx]){
			 	crash[i][imx]=false;
			 	cnum[i]--;
			 }
		}
		cnum[imx]=-2;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 20864
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	ll k; cin>>k;
	vector<ll> a(n);
	REP(i,n){
		cin>>a[i];
		a[i]--;
	}
	vector<ll> num(n+1,-1);
	ll cur=0,loop=0,end=0;
	num[cur]=0;
	//cout<<"cur "<<cur<<endl;
	FOR(i,1,k+1){
		cur=a[cur];
		//cout<<i<<"cur "<<cur<<endl;
		if(num[cur]!=-1){
			loop=(i-num[cur]);
			end=k-i;
			break;
		}
		num[cur]=i;
	}
	if(loop==0){
		cout<<cur+1<<endl;
		return 0;
	}
	//cout<<loop<<endl;
	end%=loop;
	REP(i,end){
		cur=a[cur];
	}
	cout<<cur+1<<endl;
	return 0;
}


Measured memory_bytes: 6424
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ANickname {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin>>s;
        cout<<s[0]<<s[1]<<s[2]<<endl;
	}
};


int main() {
	ANickname solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3644
function main(input) {
  var H = input[0].split(" ")[0]-0;
  var W = input[0].split(" ")[1]-0;
  var map = [];
  for(var i=1;i<=H;i++){
    map[i-1] = input[i].split("");
  }
  for(var i=0;i<H;i++){
    for(var j=0;j<W;j++){
      if(map[i][j]=="."){
        var cnt = 0;
        for(var x=-1;x<=1;x++){
          for(var y=-1;y<=1;y++){
            if(map[x+i] && map[x+i][y+j] == "#") cnt++;
          }
        }
        map[i][j]=cnt;
      }
    }
  }
  console.log(map.map(v=>v.join("")).join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int h,w,par[160000],Size[160000][2];
char c[400][400];

int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
}

signed main(){
    cin>>h>>w;
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        par[i*w+j]=i*w+j;
        Size[i*w+j][c[i][j]=='#']=1;
        if(i&&c[i-1][j]!=c[i][j]&&root(i*w+j)!=root(i*w+j-w)){
            int x=root(i*w+j),y=root(i*w+j-w);
            par[x]=y;
            Size[y][0]+=Size[x][0];
            Size[y][1]+=Size[x][1];
            Size[x][0]=Size[x][1]=0;
        }if(j&&c[i][j-1]!=c[i][j]&&root(i*w+j)!=root(i*w+j-1)){
            int x=root(i*w+j),y=root(i*w+j-1);
            par[x]=y;
            Size[y][0]+=Size[x][0];
            Size[y][1]+=Size[x][1];
            Size[x][0]=Size[x][1]=0;
        }
    }int ans=0;
    rep(i,w*h){
        if(par[i]==i){
            ans+=Size[i][0]*Size[i][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4096
N = int(input())
A = list(map(int, input().split()))
L = [[] for i in range(N)]
for i in range(N):
    L[i] = [A[i], i+1]
L.sort()
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = L[i][1]
print(*ans)

Measured memory_bytes: 23604
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int m1,d1,m2,d2;
       cin>>m1>>d1>>m2>>d2;

        int arr[]={31,28,31,30,31,30,31,31,30,31,30,31};

        if(arr[m1-1]==d1)
         cout<<"1";

         else
         cout<<"0";

}


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
cnt = 1
ans = 0
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        cnt += 1
    else:
        if cnt%2 == 1:
            ans += 1
        cnt = 1
if cnt%2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 51544
import java.util.Random;
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();

        int differnce = A-B;

        int C = sc.nextInt();

        if (C > differnce) {
            System.out.println(C-differnce);
        } else {
            System.out.println(0);
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    int sum = 0, cnt = 0;
    while(true) {
        if(sum >= X) {
            cout << cnt << endl;
            return 0;
        }
        sum += ++cnt;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long long a,b,res;
  string s;
  cin >> a >> s;
  b=stoi(s.substr(0,1))*100+stoi(s.substr(2,2));
  res=a*b/100;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3196
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
ll n ,m;
cin>>n>>m;
ll c=0;
for(ll i=0;i<m;i++)
{
ll a;
cin>>a;
c+=a;
}
if((n-c)>=0) cout<<n-c<<"\n";
else cout<<"-1"<<"\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db; 
#define fi first
#define se second 
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;} 
const db eps=1e-8,PI=acos(-1.0);
const int N=1e6+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int ans[11],cnt,fa,sz,tot;
struct node{
	int sz,par[11];
	int find(int x){return par[x]==x?x:par[x]=find(par[x]);};
}a,t,nex;
struct my{
	char s[15];
}e[N];
bool operator<(my a,my b){
	return strcmp(a.s,b.s)<0;
}
bool operator==(my a,my b){
	return strcmp(a.s,b.s)==0;
}
queue<node>q;
void bfs(int n){
	a.sz=1;
	a.par[1]=1;
	q.push(a);
	while(!q.empty()){
		t=q.front();q.pop();
		if(t.sz==n){
			cnt=0;
			for(int i=1;i<=n;++i){
				fa=t.find(i);
				if(fa==i)ans[i]=cnt++;
			}
			for(int i=1;i<=n;++i){
				fa=t.find(i);
				if(fa!=i)ans[i]=ans[fa];
			}
			for(int i=1;i<=n;++i)
			e[tot].s[i-1]=ans[i]+'a';
			e[tot].s[n]='\0';
			tot++;
			continue;
		}
		sz=t.sz;
		nex=t;nex.sz++;
		for(int i=1;i<=sz;++i){
			fa=t.find(i);
			if(fa!=i)continue;
			nex.par[nex.sz]=i;
			q.push(nex);
		} 
		nex.par[nex.sz]=nex.sz;
		q.push(nex);
	}
	sort(e,e+tot);
	tot=unique(e,e+tot)-e;
	for(int i=0;i<tot;++i){
		printf("%s\n",e[i].s);
	}
} 
int main(){
	int n;
	scanf("%d",&n);
	bfs(n);
	return 0;
}

Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		String answer = new String();
		if(a > b)
			answer = "a > b";
		if(a < b)
			answer = "a < b";
		if(a == b)
			answer = "a == b";
		System.out.println(answer);
	}

}

Measured memory_bytes: 17156
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

bool subs(char* a, char* b)
{
	int j = 0;
	for (int i = 0; a[i]; ++i) {
		while (a[i] != b[j]) {
			if (b[j] == 0) return false;
			++j;
		}
		++j;
	}
	return true;
}

int main()
{
	char S[55];
	scanf("%s", S);
	puts(subs("KIHBR", S) && subs(S, "AKIHABARA") ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 764
class Dice
  attr :top, :front, :right, :left, :back, :bottom
  def initialize a,b,c,d,e,f
    @top = a; @front = b; @right = c; @left = d; @back = e; @bottom = f
  end
  def rotN
    t = @top; @top = @front; @front = @bottom; @bottom = @back; @back = t
  end
  def rotE
    t = @top; @top = @left; @left = @bottom; @bottom = @right; @right = t
  end
  def rotW
    t = @top; @top = @right; @right = @bottom; @bottom = @left; @left = t
  end
  def rotS
    t = @top; @top = @back; @back = @bottom; @bottom = @front; @front = t
  end
end

a,b,c,d,e,f = gets.split.map {|s| s.to_i}
die = Dice.new(a,b,c,d,e,f)
s = gets.chomp
l = s.length
for i in 1..l
  case s[i-1,1]
  when "N"
    die.rotN
  when "E"
    die.rotE
  when "W"
    die.rotW
  when "S"
    die.rotS
  end
end
puts die.top

Measured memory_bytes: 6128
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a[3];
	for (int i = 0; i < sizeof(a)/sizeof(*a); i++) cin >> a[i];
	sort(a, a+3);int ans = 0;
	for (int i = 1; i < sizeof(a)/sizeof(*a); i++) ans += a[i] - a[i-1];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int calc_rectangle(int a, int b, int *s, int *l)
{
    *s = a * b;

    *l = 2 * a + 2 * b;
}

int main(void)

{
    int a, b, s, l;
    scanf("%d %d", &a, &b);
    calc_rectangle(a, b, &s, &l);
    printf("%d %d\n", s, l);

    return 0;
}


Measured memory_bytes: 2608
#include <iostream>
#include <vector>
#include <tuple>
#include <set>
#include <queue>

using namespace std;
using ll = long long;

struct C {
    ll H_{};
    ll W_{};
    ll num_whites_{};
    vector<set<ll>> g_{};
    ll to_index(ll i, ll j) {
        return j-1 + W_*(i-1);
    }
    explicit C(ll H, ll W, vector<string> v) : H_(H), W_(W) {
        g_.resize(H*W);
        vector<vector<int>> wall{};
        wall.resize(H+2);
        for(auto&& e : wall) {
            e.resize(W+2, 1);
        }
        for(int i=0; i < H_; ++i) {
            auto&& s = v[i];
            for(int j=0; j < W_; ++j) {
                if(s[j] == '.') {
                   wall[i+1][j+1] = 0;
                }
            }
        }
        for(int i=1; i <= H_; ++i) {
            for(int j=1; j <= W_; ++j) {
                if(wall[i][j] == 0) {
                    ++num_whites_;
                    auto index = to_index(i, j);
                    if (wall[i-1][j] == 0) {
                        g_[index].emplace(to_index(i-1, j));
                        g_[to_index(i-1, j)].emplace(index);
                    }
                    if (wall[i+1][j] == 0) {
                        g_[index].emplace(to_index(i+1, j));
                        g_[to_index(i+1, j)].emplace(index);
                    }
                    if (wall[i][j-1] == 0) {
                        g_[index].emplace(to_index(i, j-1));
                        g_[to_index(i, j-1)].emplace(index);
                    }
                    if (wall[i][j+1] == 0) {
                        g_[index].emplace(to_index(i, j+1));
                        g_[to_index(i, j+1)].emplace(index);
                    }
                }
            }
        }
    }
    // returns -1 if not reachable
    ll path_length(ll src, ll tgt) {
        vector<bool> visited(H_*W_, false);
        vector<ll> dist_from_src(H_*W_, INT64_MAX);
        queue<ll> q{};
        q.push(src);
        dist_from_src[src] = 0;
        while(!q.empty()) {
            auto cur = q.front();
            q.pop();
            if (visited[cur]) {
                continue;
            }
            visited[cur] = true;
            if (cur == tgt) {
                return dist_from_src[cur]+1; // path length has one more distance
            }
            for(auto dest : g_[cur]) {
                if (!visited[dest]) {
                    q.push(dest);
                    dist_from_src[dest] = dist_from_src[cur] + 1;
                }
            }
        }
        return -1;
    }
    ll resolve() {
        auto len = path_length(to_index(1,1), to_index(H_, W_));
        if (len == -1) {
            return -1;
        }
        return num_whites_ - len;
    }
};

int main() {
    ll H, W;
    cin >> H >> W;
    vector<string> v{};
    for (int i=0; i < H; ++i) {
        string x;
        cin >> x;
        v.emplace_back(move(x));
    }
    C c{H, W, move(v)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long A = long.Parse(input[0]);
            long B = long.Parse(input[1]);
            long C = long.Parse(input[2]);
            long K = long.Parse(input[3]);
            long ans = 0;

            if (K >= A)
            {
                ans += 1 * A;

                if ((K - A - B) > 0)
                {
                    ans += -1 * (K - A - B);
                }
            }
            else
            {
                ans += 1 * K;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27492
import math

def solve():
  N, D = map(int, input().split())
  X = [[int(i) for i in input().split()]for i in range(N)]
  cnt = 0

  for i in range(N):
    xi = X[i]
    for j in range(i + 1, N):
      xj = X[j]
      dist = math.sqrt(sum([(xi[d] - xj[d]) ** 2 for d in range(D)]))
      if dist.is_integer(): cnt += 1

  return cnt

print(solve())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
 
//############################ENDOFTEMPLATE############################


void solve(){
  lli n;
  cin>>n;
  if(n%2==1){
    cout<<0;
    return;
  }
  

  
  lli ans = 0;
  lli denom = 10;
  while(denom<=n){
    ans = ans+(n/denom);
    denom *=5;
  }

  cout<<ans;


  
}
 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("moobuzz.in","r",stdin);
  //freopen("moobuzz.out","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3620
import java.util.Scanner;
class Main
{
	static long knapsack(int weight[],int val[],int w,int n)
	{
		int i,j;
		long [][] dp=new long[n+1][w+1];
		for(i=0;i<=n;i++)
			for(j=0;j<=w;j++)
			{
			   if(i==0||j==0)
			     dp[i][j]=0;
			   else if(weight[i-1]<=j)
			     dp[i][j]=Math.max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
			   else
			     dp[i][j]=dp[i-1][j];	
			}
			return dp[n][w];
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
        int n,w,i;
        n=sc.nextInt();
        w=sc.nextInt();
        int weight[]=new int[n];
        int val[]=new int[n];
		for(i=0;i<n;i++)
		{
			weight[i]=sc.nextInt();
			val[i]=sc.nextInt();
		}
		long ans=knapsack(weight,val,w,n);
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 127572
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	if(s[5] >= '1' || s[6] >= '5') cout << "TBD" << endl;
	else cout << "Heisei" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int solve(int n, int k, int s) {
    if(k == 0 && s == 0) return 1;
    int res = 0;
    for(int i = 1; i <= n; i++) {
        res += solve(i - 1, k - 1, s - i);
    }
    return res;
}

int main() {
    while(true) {
        int N, K, S; cin >> N >> K >> S;
        if(N == 0 && K == 0 && S == 0) break;
        cout << solve(N, K, S) << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int n; cin >> n;
    vec v(n); readvec(v);

    map<int, int> m1, m2;
    REP(i, n){
        if(i % 2 == 0){
            m1[v[i]] += 1;
        }else{
            m2[v[i]] += 1;
        }
    }

    int M1 = 0, M2 = 0;
    int N1, N2;
    for(auto p: m1){
        if(p.second > M1){
            M1 = p.second;
            N1 = p.first;
        }
    }
    for(auto p: m2){
        if(p.first != N1 && p.second > M2){
            M2 = p.second;
            N2 = p.first;
        }
    }
    int ans1 = n - M1 - M2;

    M1 = 0, M2 = 0;
    for(auto p: m2){
        if(p.second > M2){
            M2 = p.second;
            N2 = p.first;
        }
    }
    for(auto p: m1){
        if(p.first != N2 && p.second > M1){
            M1 = p.second;
            N1 = p.first;
        }
    }
    int ans2 = n - M1 - M2;
    cout << min(ans1, ans2);
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (n * 2 >= m) {
    cout << m / 2 << '\n';
  } else {
    cout << (n * 2 + m) / 4 << '\n';
  }
  return 0;
}

Measured memory_bytes: 3636
// ABC 156-D
// 2020.2.23 bal4u

#include <stdio.h>

typedef long long ll;

#define M 1000000007

int pow_mod(int b, int p) {
   int r = 1;
   while (p) {
      if (p & 1) r = (ll)r * b % M;
      b = (ll)b * b % M;
	  p >>= 1;
   }
   return r;
}

#define MOD 1000000007
#define MAX 200005
int fact[MAX] = {1,1};

int extended_gcd(int a, int b, int *x, int *y) {
	int d;
	if (b == 0) { *x = 1; *y = 0; return a; }
	d = extended_gcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

int inverse(int a) {
    int x, y;
    extended_gcd(a, M, &x, &y);
	return x % M;
}

int comb(int n, int a, int b) {
	int i, t, ans = 1;
	for (i = 0; i < a; ++i) ans = (ll)ans * (n-i) % M;
	t = 1;
	for (; i < b; ++i) t = (ll)t * (n-i) % M;
	return (ll)ans * (inverse(fact[a]) + (ll)t*inverse(fact[b])%M) % M;
}

int main()
{
	int i, n, a, b;
	ll ans;

	scanf("%d%d%d", &n, &a, &b);
	for (i = 2; i <= b; i++) fact[i] = (ll)fact[i-1]*i % M;
	ans = ((ll)pow_mod(2, n) - 1 - comb(n, a, b)) % M;
	if (ans < 0) ans += M;
	printf("%d\n", (int)ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, k;
  cin >> n >> k;
  int index = 0;
  rep (i, n) {
    int tmp;
    cin >> tmp;
    if (tmp == 1) index = i;
  }

  int ans    = 0;
  int hidari = index;
  int migi   = n - index - 1;
  if (hidari + 1 < k) {
    migi -= (k - hidari - 1);
    ans++;
    if (migi <= 0) {
      P(ans);
      return 0;
    }
    hidari = 0;
  } else if (migi + 1 < k) {
    hidari -= (k - migi - 1);
    ans++;
    if (hidari <= 0) {
      P(ans);
      return 0;
    }
    migi = 0;
  }
  // cout << "hidari: " << hidari << " / migi: " << migi << endl;
  ans += (hidari + migi) / (k - 1);
  // ans += hidari / (k - 1);
  // ans += migi  / (k - 1);
  // if (hidari % (k - 1) != 0) ans++;
  // if (migi % (k - 1) != 0) ans++;

  if ((hidari + migi) % (k - 1) != 0) ans++;
  P(ans);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n; cin >> n;
  vector<ll> v(n), t(n);
  rep(i, n){
    cin >> v[i];
    t[i] = v[i];
  }
  sort(All(t));
  for(int i = 0; i < n; i++){
    if(v[i] < t[n/2])cout << t[n/2] << endl;
    else cout << t[n/2-1] << endl;
  }
  system("pause");
}


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

using namespace std;

  int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
       cout<<"Yes"<<endl;
    } else if(s[3]==s[2]&&s[2]==s[1]){
       cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }

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

int main(){
	int d, t, s;
  	cin >> d >> t >> s;
  
  	int a = t * s;

  	if(a >= d) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

int main(){
  int n,k; cin >> n >> k;
  vector<long> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  long result =0;
  for(long i=0; i<n-k;i++){
    result += h.at(i);
  }
  
  cout << result << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
map<int,pair<int,int> >max_p,min_p;
map<char,int>mc;
int h,w,c,vis[101];
string s[51];
void mae(){
  r(i,h)r(j,w)
   if(s[i][j]=='.')s[i][j]='0';
   else{
    if(mc[s[i][j]])s[i][j]=mc[s[i][j]];
    else{
      mc[s[i][j]]=(c++)+'0';
      s[i][j]=(c-1)+'0';
    }
   }
}
void in(){
  for(int k=1;k<c;k++){
    int px=0,py=0,mx=1000,my=1000;
    r(i,h)r(j,w)
      if(s[i][j]-'0'==k){
        px=max(px,j);
        py=max(py,i);
        mx=min(mx,j);
        my=min(my,i);
      }
    max_p[k]=mk(px,py);
    min_p[k]=mk(mx,my);
  }
}
bool chb(){
  for(int k=1;k>c;k++){
    pair<int,int>p1=min_p[k],p2=max_p[k];
    for(int i=p1.se;i<=p2.se;i++)
      for(int j=p1.fi;j<=p2.fi;j++)
        if(s[i][j]=='0')return 1;
  }
  return 0;
}
bool dfs(int d,int x){
  if(d){
    pair<int,int>p1=min_p[x],p2=max_p[x];
    for(int i=p1.se;i<=p2.se;i++)
      for(int j=p1.fi;j<=p2.fi;j++)
        if(!vis[s[i][j]-'0'])return 0;
  }
  if(d==c-1)return 1;
  for(int i=1;i<c;i++)
    if(!vis[i]){
      vis[i]=1;
      if(dfs(d+1,i))return 1;
      vis[i]=0;
    }
  return 0;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    memset(vis,0,sizeof(vis));
    max_p.clear();
    min_p.clear();
    mc.clear();c=1;
    cin>>h>>w;
    r(i,h)cin>>s[i];
    mae();
    in();
    if(chb())cout<<"SUSPICIOUS"<<endl;
    else{
      if(!dfs(0,0))cout<<"SUSPICIOUS"<<endl;
      else cout<<"SAFE"<<endl;
    }
  }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
long long a[60],p[60];
long long f(long long n,long long x)
{
    if(n==0)
    {
        if(x<=0)
			return 0;
		return 1;
	}
    else if(x<=1+a[n-1])
		return f(n-1,x-1);
    return p[n-1]+1+f(n-1,x-2-a[n-1]);
}
int main()
{
	int i; 
	long long n,x;
	scanf("%lld %lld",&n,&x);
	a[0]=p[0]=1;
	for(i=1;i<n;i++)
	{
		a[i]=a[i-1]*2+3;
		p[i]=p[i-1]*2+1;
	}
	printf("%lld",f(n,x));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int a[3][3],i,j,temp,b,u;
    for (i=0; i<=2; i++) {
        for (j=0; j<=2; j++) {
            cin >> a[i][j];
        }
    }
    cin >> b;
    for (u=0; u<b; u++) {
        cin >> temp;
        for (i=0; i<=2; i++) {
            for (j=0; j<=2; j++) {
                if (temp==a[i][j]) {
                    a[i][j]=-1;
                }
            }
        }
    }
    for (i=0; i<=2; i++) {
        if ((a[i][0]==a[i][1])&&(a[i][0]==a[i][2])) {
            cout << "Yes";
            return 0;
        }
    }
    for (i=0; i<=2; i++) {
        if ((a[0][i]==a[1][i])&&(a[0][i]==a[2][i])) {
            cout << "Yes";
            return 0;
        }
    }
    if ((a[0][0]==a[1][1])&&(a[0][0]==a[2][2])) {
        cout << "Yes";
        return 0;
    }
    if ((a[0][2]==a[1][1])&&(a[0][2]==a[2][0])) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]

  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        M[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        M[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        M[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        M[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()


Measured memory_bytes: 115572
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod int(1e9+7)
#define hmod 1223334444555553LL
using namespace std;

ll n,a[105],y,sum1;
int main(){
	scanf("%lld%lld",&n,&a[1]); y=a[1];
	for (int i=2;i<=n;i++){
		scanf("%lld",&a[i]);
		y=y*a[i]/(__gcd(y,a[i]));
	}
	for (int i=1;i<=n;i++){
		sum1+=(y/a[i]);
	}
	printf("%.6lf\n",1.0*y/sum1);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
bool cust(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} 
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll a;cin>>a;
	cout<<(a+(a*a)+(a*a*a));
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	int a, b, c, d, ans;
	int i;

	

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		a = 1;
		b = 2;
		c = 4;

		if (n == 1) d = a;
		if (n == 2) d = b;
		if (n == 3) d = c;

		for (i = 4; i <= n ; i++) {
			
			d = a + b + c;
			a = b;
			b = c;
			c = d;
		}

		ans = d / 3650;
		if (d % 3650 != 0) ans++;
		printf("%d\n", ans);
	}

	
	return (0);
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;
    int a = -1, z = -1;

    rep(i, s.size()) {
        if (a == -1 && s[i] == 'A') a = i;
        if (s[i] == 'Z') z = i;
    }

    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

const double eps = 1e-10;
const double pi = acos(-1);
inline int sgn(double x)
{
    if(x < -eps) return -1;
    else if(x > eps) return 1;
    else return 0;
}
struct node
{
    double l,r;
    node(double _l = 0.0,double _r = 0.0) :l(_l),r(_r) {}
} f[4002];

bool cmp(const node &a,const node &b)
{
    if(sgn(a.r - b.r) == 0) return a.l < b.l;
    else return a.r < b.r;
}

double getang(int x,int y)
{
    double r = atan2(y,x);
    return r;
}

int main()
{
    int n,i,j,k,ans;
    int x1,x2,y1,y2;
    double g1,g2,g3,g4;
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if(x1 < 0 && y1 < 0 && y2 >= 0)
        {
            f[i].l = getang(x2,y2) - pi * 2;
            f[i].r = getang(x2,y1);
        }
        else
        {
            g1 = getang(x1,y1);
            g2 = getang(x2,y2);
            g3 = getang(x1,y2);
            g4 = getang(x2,y1);
            f[i].l = min(min(g1,g2),min(g3,g4));
            f[i].r = max(max(g1,g2),max(g3,g4));
        }
    }
    sort(f,f + n,cmp);
    for(i = 0; i < n; i++) f[n + i] = node(f[i].l + pi * 2,f[i].r + pi * 2);
    ans = n;
    for(i = 0; i < n; i++)
    {
        k = 1;
        g1 = f[i].r;
        for(j = i + 1; j < n + i; j++)
        {
            if(sgn(f[j].l - g1) == 1)
            {
                k++;
                g1 = f[j].r;
            }
        }
        ans = min(ans,k);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3488
#include<stdio.h>
#define MAX 25
#define NIL -1
struct node{
  int parent,left,right;
};
struct node T[MAX];
int n,D[MAX],H[MAX];

void depth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  if(T[u].left!=NIL) depth(T[u].left,d+1);
  if(T[u].right!=NIL) depth(T[u].right,d+1);
}
int height(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=height(T[u].left)+1;
  if(T[u].right!=NIL) h2=height(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int sibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(u!=T[T[u].parent].left&&T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
  if(u!=T[T[u].parent].right&&T[T[u].parent].right!=NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  int deg=0,flag;
  printf("node %d: parent = %d, ",u,T[u].parent);
  printf("sibling = %d, ",sibling(u));
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].parent==NIL) printf("root\n");
  else if(deg==0) printf("leaf\n");
  else printf("internal node\n");
}
void preorder(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preorder(T[u].left);
  preorder(T[u].right);
}
void inorder(int u){
  if(u==NIL) return;
  inorder(T[u].left);
  printf(" %d",u);
  inorder(T[u].right);
}
void postorder(int u){
  if(u==NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d",u);
}

int main(){
  int i,u,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].parent=T[i].left=T[i].right=NIL;

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&l);
    scanf("%d",&r);
    T[u].left=l;
    T[u].right=r;
    if(l!=NIL) T[l].parent=u;
    if(r!=NIL) T[r].parent=u;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }
  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2056
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int lSum=0,rSum=0;
		for(int i=0;i<n;i++){
			int lhs,rhs;
			scanf("%d %d",&lhs,&rhs);
			if(lhs > rhs) lSum += lhs + rhs;
			else if(lhs < rhs) rSum += lhs + rhs;
			else if(lhs == rhs){
				rSum += rhs;
				lSum += lhs;
			}
		}

		printf("%d %d\n",lSum,rSum);
	}
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 998244353
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int A, B;
	cin >> A >> B;
	
	int K = (A + B) / 2;

	if (abs(A - K) == abs(B - K))cout << K << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int i,n[6],q,a,b;
     
    for(i=0;i<6;i++){
        scanf("%d", &n[i]);
    }
     
    scanf("%d",&q);
    for(i=0; i<q; i++){
    scanf("%d %d",&a,&b);
    if(a == n[0]){
       if(b == n[1]){
          printf("%d\n",n[2]);
       }
       if(b == n[2]){
          printf("%d\n",n[4]);
       }
       if(b == n[3]){
          printf("%d\n",n[1]);
       }
       if(b == n[4]){
          printf("%d\n",n[3]);
       }
    }
    if(a == n[1]){
       if(b == n[0]){
          printf("%d\n",n[3]);
       }
       if(b == n[2]){
          printf("%d\n",n[0]);
       }
       if(b == n[3]){
          printf("%d\n",n[5]);
       }
       if(b == n[5]){
          printf("%d\n",n[2]);
       }
    }
    if(a == n[2]){
       if(b == n[0]){
          printf("%d\n",n[1]);
       }
       if(b == n[1]){
          printf("%d\n",n[5]);
       }
       if(b == n[4]){
          printf("%d\n",n[0]);
       }
       if(b == n[5]){
          printf("%d\n",n[4]);
       }
    }
    if(a == n[3]){
       if(b == n[0]){
          printf("%d\n",n[4]);
       }
       if(b == n[1]){
          printf("%d\n",n[0]);
       }
       if(b == n[4]){
          printf("%d\n",n[5]);
       }
       if(b == n[5]){
          printf("%d\n",n[1]);
       }
    }
    if(a == n[4]){
       if(b == n[0]){
          printf("%d\n",n[2]);
       }
       if(b == n[2]){
          printf("%d\n",n[5]);
       }
       if(b == n[3]){
          printf("%d\n",n[0]);
       }
       if(b == n[5]){
          printf("%d\n",n[3]);
       }
    }
    if(a == n[5]){
       if(b == n[1]){
          printf("%d\n",n[3]);
       }
       if(b == n[2]){
          printf("%d\n",n[1]);
       }
       if(b == n[3]){
          printf("%d\n",n[4]);
       }
       if(b == n[4]){
          printf("%d\n",n[2]);
       }
    }
}
    return 0;
}



Measured memory_bytes: 2032
#include <iostream>

using namespace std;

int main (int argc, const char * argv[])
{
    int S, h,m, s;

    cin >> S ;
    h = S/3600;
    m = S%3600/60;
    s = S%3600%60;
    cout << h  <<":" << m <<":" << s <<endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main () {
	string S;
	cin >> S;
	// BW -> WB
	// WB
	//
	// BBW -> BWB
	// BWB -> WBB
	// WBB
	//
	// BWW -> WBW
	// WBW -> WWB
	// WWB 
	//
	// BBBW -> BBWB
	// BBWB -> BWBB
	// BWBB -> WBBB
	// WBBB
	//
	// BBWW -> BWBW
	// BWBW -> BWWB, WBBW
	// BWWB, WBBW -> WBWB
	// WBWB -> WWBB
	// WWBB
	// 
	// BWWW -> WBWW
	// WBWW -> WWBW
	// WWBW -> WWWB
	// WWWB
	//
	// BWWWB -> WBWWB
	// WBWWB
	// WWBWB
	// WWWBB
	//
	// BWBWW
	// WBBWW
	// WBWBW
	// WBWWB
	// WWBWB
	// WWWBB
	//
	// WBWBW
	// WWBBW
	// WWBWB
	// WWWBB
	//
	// 結局, Bを右に1つずつ動かして右端からBを詰めた状態にするために, 個別のBを何回右に動かすかになる。
	// ...というのはちょっと単純化しすぎ。
	// 最も右のBから順に右端に移動させた回数を求める、というところか。 
	// Sの中のBの位置を全部求める。
	// 
	int num_b = 0;	
  for(int i=0; i<S.size(); ++i) {
		if (S[i] == 'B') {
			num_b++;
		}
	}
	int n = S.size();
	int m = num_b;
	ll ans = 0;
  for(int i=0; i<n; ++i) {
		if (S[i] == 'B') {
			m--;
			ans += (n-i-1)// このiより右側のplaceholder数  
				- m; // i番目の黒を除く、すでに右側にあるBの個数
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define FST first
#define SND second

#define MAX_N   (100)                  // 10^5
#define MAX_S   (100)                  // 10^5
// #define MAX_N   (1000000000)              // 10^9
// #define MAX_N   (1000000000000000000)     // 10^18
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

int N, S[MAX_N], SMX;
bool DP[2][MAX_N * MAX_S + 1];

void solve() {
  for (int i = 0; i <= N * SMX; i++) DP[0][i] = false;
  DP[0][0] = true;

  for (int i = 0; i < N; i++) {
    int x = i % 2, y = (i + 1) % 2;
    for (int j = 0; j <= N * SMX; j++) DP[y][j] = false;
    for (int j = 0; j <= N * SMX; j++) {
      DP[y][j] = DP[x][j];
      if (j - S[i] >= 0) DP[y][j] |= DP[x][j - S[i]];
    }
    // for (int j = 0; j <= N * SMX; j++) cout << DP[y][j] << " ";
    // cout << endl;
  }

  ll ans = 0;
  for (int i = N * SMX; i >= 0; i--) {
    if (i % 10 != 0 && DP[N % 2][i]) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

int main() {
  cin >> N;
  SMX = 0;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    SMX = max(SMX, S[i]);
  }

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

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

  ll ans = k;

  for (int i = 1; i < n; i++)
    ans *= k - 1;

  cout << ans << endl;
}


Measured memory_bytes: 3576
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
is10 = []
for i in range(n):
  if s[i] % 10 == 0:
    is10.append(1)
  else:
    is10.append(0)

t = sum(s)
if t % 10 != 0:
  print(t)
else:
  c = 0
  while c < n:
    if is10[c] == 0:
      print(t-s[c])
      exit(0)
    c += 1
  print(0)

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		//処理
		int ans = 0;
		for(int i = 1; i <= n; i++){
			String s = Integer.toString(i);
			if(s.length() % 2 == 1) ans++;
		}
		
		//出力
		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}
}

Measured memory_bytes: 28240
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Enu = System.Linq.Enumerable;

class Program
{
    long GCD(long a, long b)
    {
        return b == 0 ? a : GCD(b, a % b);
    }

    void Solve()
    {
        while (reader.HasNext())
        {
            long a = reader.Long(), b = reader.Long();
            var gcd = GCD(a, b);
            var lcm = a / gcd * b;
            Console.WriteLine(gcd + " " + lcm);
        }
    }

    static void Main() { new Program().Solve(); }
    static Reader reader = new Reader(Console.In);
    class Reader
    {
        private readonly TextReader reader;
        private readonly char[] splitter = new char[] { ' ' };
        private string[] s = new string[0];
        private int i;
        public Reader(TextReader r) { reader = r; }
        public bool HasNext() { return Enqueue(); }
        public string String() { return Dequeue(); }
        public int Int() { return int.Parse(Dequeue()); }
        public long Long() { return long.Parse(Dequeue()); }
        public double Double() { return double.Parse(Dequeue()); }
        public int[] IntArray() { return Array.ConvertAll(Line().Split(), int.Parse); }
        public int[][] IntGrid(int H) { return Enumerable.Range(0, H).Select(i => IntArray()).ToArray(); }
        public string[] StringArray(int N) { return Enumerable.Range(0, N).Select(i => Line()).ToArray(); }
        public string Line() { return reader.ReadLine().Trim(); }
        private bool Enqueue()
        {
            if (i < s.Length) return true;
            string line = reader.ReadLine();
            if (string.IsNullOrEmpty(line)) return false;
            s = line.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return true;
        }
        private string Dequeue() { Enqueue(); return s[i++]; }
    }
}

Measured memory_bytes: 5564