akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	char a; cin >> a;
	if('a'<=a && a<='z') puts("a");
	else puts("A");
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
char a[100][100];
int H,W;
int main(){
  int flag = 0;
  int count = 0;
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < H; i++){
    flag = 1;
    for(int j = 0; j < W; j++){
      if(a[i][j] == '#'){
        flag = 0;
      }
    }
    if(flag){
      for(int j = 0; j < W; j++){
        a[i][j] = '0';
      }
    }
  }
  for(int j = 0; j < W; j++){
    flag = 1;
    for(int i = 0; i < H; i++){
      if(a[i][j] == '#'){
        flag = 0;
      }
    }
    if(flag){
      for(int i = 0; i < H; i++){
        a[i][j] = '0';
      }
    }
  }
  for(int i = 0; i < H; i++){
    count = 0;
    for(int j = 0; j < W; j++){
      if(a[i][j] != '0'){
        cout << a[i][j];
        count++;
      }
    }
    if(count != 0){
      cout << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


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

signed main() {
    ll n; 
    cin >> n;
    
    
    
    mes(n*800 - 200*(n/15));
    
    
    
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <iostream>
#include <boost/range/algorithm/count.hpp>
using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < s.length(); i++){
    if (s.at(i) == 'o'){
      count++;
    }
  }
  cout << 700 + (100 * count) << endl;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main() {
	int i, a[3], max = 0, min = 999;

	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	for (i = 0; i < 3; i++) {
		if (a[i] >= max) max = a[i];
		if (a[i] <= min) min = a[i];
	}

	printf("%d\n", max - min);

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    sort(s, s + n);

    int ans = 0;
    rep(i, n) ans += s[i];

    if (ans % 10 == 0) {
        rep(i, n) {
            if ((ans - s[i]) % 10 != 0) {
                cout << ans - s[i] << endl;
                return 0;
            }
        }
    } else {
        cout << ans << endl;
        return 0;
    }

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


Measured memory_bytes: 3644
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/28/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll N; cin>>N;
  ll ans = N;
  for (ll i = sqrt(N); i > 1; i--) {
    if (N%i==0) {
      ans = i;
      break;
    }
  }
  cout << ans+N/ans-2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int h,w;cin>>h>>w;
	vector<vector<char>> a(h,vector<char>(w));
	for(int i=0;i<h*w;i++)cin>>a[i/w][i%w];
	int ans=0;
	
	set<pair<int,int>> que;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#'){
				if(i+1<h)if(a[i+1][j]=='.')que.insert(make_pair(i,j));
				if(i-1>=0)if(a[i-1][j]=='.')que.insert(make_pair(i,j));
				if(j+1<w)if(a[i][j+1]=='.')que.insert(make_pair(i,j));
				if(j-1>=0)if(a[i][j-1]=='.')que.insert(make_pair(i,j));
	}}}
	
	while(que.size()){
		set<pair<int,int>> que_buf=que;que.clear();
		pair<int,int> p;
		ans++;
		while(que_buf.size()){
			p=*que_buf.begin();que_buf.erase(que_buf.begin());
			int x=p.first,y=p.second;
			if(x+1<h)if(a[x+1][y]=='.'){a[x+1][y]='#';que.insert(make_pair(x+1,y));}
			if(x-1>=0)if(a[x-1][y]=='.'){a[x-1][y]='#';que.insert(make_pair(x-1,y));}
			if(y+1<w)if(a[x][y+1]=='.'){a[x][y+1]='#';que.insert(make_pair(x,y+1));}
			if(y-1>=0)if(a[x][y-1]=='.'){a[x][y-1]='#';que.insert(make_pair(x,y-1));}
		}
	}
	cout<<max(0,ans-1)<<endl;
}


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

using namespace std;

#define MAX_G 10
#define MAX_K 2000
typedef long long ll;

int K,L[MAX_G];
ll value[MAX_G][MAX_K];
ll dp[MAX_G][MAX_K];

ll solve(int g,int k){
  if(k == K) return 0LL;
  if(g == MAX_G) return 0LL;
  ll &res = dp[g][k];
  if(res >= 0LL) return res;
  res = max(res,solve(g+1,k));
  for(int i = 0 ; i < L[g] ; i++){
    if(k+i+1 <= K){
      res = max(res,solve(g+1,k+i+1)+value[g][i]);
    }else{
      break;
    }
  }
  return res;
}

int main(){
  int N,C,G;
  vector<int> books[MAX_G];
  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    cin >> C >> G; G--;
    books[G].push_back(C);
  }
  for(int i = 0 ; i < MAX_G ; i++){
    sort(books[i].rbegin(),books[i].rend());
    L[i] = books[i].size();
    if(L[i] > 0) value[i][0] = books[i][0];
    for(int j = 1 ; j < L[i] ; j++){
      books[i][j] += books[i][j-1];
      value[i][j] = books[i][j]+j*(j+1);
    }
  }
  memset(dp,-1,sizeof(dp));
  cout << solve(0,0) << endl;
  return 0;
}

Measured memory_bytes: 1448
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 20007;

int B[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	REP(i, n)
	{
		int p;
		cin >> p;
		--p;
		cout << n * (i + 1) << ' ';
		B[i] += n * (n - i);
		B[p] += i;
	}
	cout << endl;
	REP(i, n) cout << B[i] << ' ';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a = N/1000;
  int b = (N-1000*a)/100;
  int c = (N-1000*a-100*b)/10;
  int d = N-1000*a-100*b-10*c;
    
  if (a == b && b == c || b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib> 
using namespace std;
long long L,R,a,b;
inline long long gcd(long long a,long long b){if(b==0) return a; return gcd(b,a%b);}
inline long long cal(long long x)
{
  return R/x-(L-1)/x;
}
int main()
{
  cin>>L>>R>>a>>b;
  long long t1=cal(a)+cal(b)-cal(a*b/gcd(a,b));
  cout<<R-L+1-t1<<endl;
  return 0;
}

Measured memory_bytes: 384
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

a = {}
a[0] = 2
a[1] = 1
def lucas(n):
    if n in a:
        return a[n]
    
    a[n] = lucas(n-1) + lucas(n-2)
    return a[n]



def solve():
    n = f()[0]
    print(lucas(n))



solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
void solve(string f)
{
 cout<<((f[2]==f[3] && f[4]==f[5])?"Yes":"No")<<"\n";
}
int main()
{
 string cof;
 cin>>cof;
 solve(cof);
 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] p = new int[n];
		int minX = 100;
		int maxX = -100;
		
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
			minX = Math.min(minX, p[i]);
			maxX = Math.max(maxX, p[i]);
		}
		
		int res = Integer.MAX_VALUE;
		
		for (int i = minX; i <= maxX; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += ((i - p[j])*(i - p[j]));
			}
			res = Math.min(res, total);
		}
		
		if (res == Integer.MAX_VALUE) {
			System.out.println("0");
		} else {
			System.out.println(res);
		}
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n, k, a[109], f[100009];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        f[a[i]] = 1;
    }
    f[0] = 0;
    for(int i = 1; i <= k; ++ i)
    {
        f[i] = 0;
        for(int j = 1; j <= n; ++ j)
        {
            if(i >= a[j] && f[i - a[j]] == 0) f[i] = 1;
        }
    }
    if(f[k] == 0) cout << "Second";
    else cout << "First";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;



int main(){
	long long int h, n;
	cin >> h >> n;
	vector<int> a(n);
	long long int sigma = 0;
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		sigma += a.at(i);
	}
	if(sigma >= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)

int main(){
    int a,b,t;
    sc3(a,b,t);
    printf("%d\n",t/a*b);
    return 0;
}


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

int N;
const int MAX_N = 200005;
int as[MAX_N];
int ac[MAX_N], bcc[MAX_N];
std::vector<std::pair<int, int>> bccc;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int v;
    scanf("%d", &v);
    as[i] = v;
    ac[v]++;
  }
  for (int i = 0; i < N; ++i) {
    int v;
    scanf("%d", &v);
    bcc[v]++;
  }
  for (int i = 0; i < MAX_N; ++i) {
    if (bcc[i]) bccc.push_back({i, bcc[i]});
  }
  bool doable = true;
  for (auto& kv: bccc) {
    if (kv.second + ac[kv.first] > N) {
      doable = false;
      break;
    }
  }
  if (!doable) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  std::vector<int> ans;
  auto eng = std::default_random_engine(12432);
  while (1) {
    auto bc = bccc;
    std::shuffle(bc.begin(), bc.end(), eng);
    ans.clear();
    int idx = 0, bidx = 0;
    while (bc.size()) {
      if (bc[bidx].first == as[idx]) {
        if (bc.size() == 1) break;
        bidx = (bidx + 1) % bc.size();
      }
      while (bc[bidx].second && as[idx] != bc[bidx].first) {
        idx++;
        bc[bidx].second--;
        ans.push_back(bc[bidx].first);
      }
      if (bc[bidx].second == 0) {
        std::swap(bc[bidx], bc.back());
        bc.pop_back();
        bidx = 0;
      }
    }
    if (ans.size() == N) break;
  }
  for (int i : ans) printf("%d ", i);
  printf("\n");
}


Measured memory_bytes: 10456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t a,b,c;
 
  cin >> a >> b >> c;
 
    int64_t x=(c-a-b)*(c-a-b);
    int64_t r=4*a*b;
    if((r<x)&&(c>a+b)) cout << "Yes" << endl;
  
    else cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    a--;
    b--;
    c--;
    d--;
    if(s[c]=='#'||s[d]=='#') cout<<"No";
    else{
        if(c<d){
            bool flag=true;
            while(b<d){
                if(s[b]=='#'&&s[b+1]=='#'){
                    flag=false;
                    break;
                }
                b++;
            }
            if(flag){
                while(a<c){
                    if(s[a]=='#'&&s[a+1]=='#'){
                    flag=false;
                    break;
                }
                a++;
                }
            }
            if(flag) cout<<"Yes";
            else cout<<"No";
        }else{
            bool flag1=true,flag2=false;
            ll a1=a,b1=b;
            while(b<d){
                if(s[b]=='#'&&s[b+1]=='#'){
                    flag1=false;
                    break;
                }
                b++;
            }
            while(b1<=d){
                if(s[b1-1]=='.'&&s[b1]=='.'&&s[b1+1]=='.'){
                    flag2=true;
                    break;
                }
                b1++;
            }
            if(flag1&&flag2){
                while(a<c){
                    if(s[a]=='#'&&s[a+1]=='#'){
                    flag1=false;
                    break;
                }
                a++;
                }
            }
            if(flag1&&flag2) cout<<"Yes";
            else cout<<"No";
        }
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

char ar[1001][1001];
ll dp[1001][1001];
ll mod=1e9+7;

ll fun(ll x,ll y,ll h,ll w){
	if(x==h && y==w){
		return 1;
	}
	if(dp[x][y]==-1){
		dp[x][y]=0;
		ar[x][y]='#';
		if(y+1<=w && ar[x][y+1]=='.'){
			dp[x][y]=(dp[x][y]+fun(x,y+1,h,w))%mod;
		}
		if(x+1<=h && ar[x+1][y]=='.'){
			dp[x][y]=(dp[x][y]+fun(x+1,y,h,w))%mod;
		}
		ar[x][y]='.';
	}
	return dp[x][y];
}

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll h,w;
		cin>>h>>w;
		for(ll i=1;i<=h;i++){
			for(ll j=1;j<=w;j++){
				cin>>ar[i][j];
			}
		}
		for(ll i=0;i<=h;i++){
			for(ll j=0;j<=w;j++){
				dp[i][j]=-1;
			}
		}
		cout << fun(1,1,h,w) << "\n";
		return 0;
	}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    while(true){
        int n,ans,z=0;
        vector<int> alp(26,0),A;
        char c,winner;
        cin>>n;
        if(!n) break;
        rep(i,n){
            cin>>c;
            alp[c-'A']++;
            A=alp;
            sort(A.begin(),A.end(),greater<int>());
            if(!z&&A[0]>A[1]+(n-i-1)){
                ans=i+1;
                rep(j,26) if(alp[j]==A[0]) winner=j+'A';
                z=1;
            }
        }
        if(z) cout<<winner<<" "<<ans<<endl;
        else cout<<"TIE"<<endl;
    }
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e9+9;

int main(){
	string s,t;
	cin>>s>>t;
	int sum=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])sum++;
	}
	cout<<sum;
	return 0;
} 

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

public class Main {
    static final int R = 2500;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), a = in.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; ++i) v[i] = in.nextInt();

        long[][] dp = new long[n + 1][R + 1];
        dp[0][0] = 1;

        for (int i = 0; i < n; ++i) {
            for (int j = R; j >= 0; --j) {
                for (int k = n; k >= 0; --k) {
                    if (dp[k][j] == 0) continue;
                    dp[k + 1][j + v[i]] += dp[k][j];
                }
            }
        }
        long res = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= R; ++j) {
                if (j / i == a && j % i == 0) {
                    res += dp[i][j];
                }
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 24404
#include<stdio.h>
#define MAX 1000005
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL){
    printf("root, ");
  }else if(T[u].l == NIL){
    printf("leaf, ");
  }else{
    printf("internal node, ");
  }
  printf("[");

  for(i = 0,c = T[u].l;c!=NIL;i++,c = T[c].r){
    if(i)printf(", ");

    printf("%d",c);
  }
  printf("]\n");
    }

int rec(int u,int p){
  D[u] = p;
  if(T[u].r != NIL){
    rec(T[u].r,p);
  }
  if(T[u].l!= NIL){
    rec(T[u].l,p+1);
  }
}

int main(){
  int i,j,d,c,v,l=0,r;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r = NIL;
  }
  for(i = 0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j = 0;j<d;j++){
      scanf("%d",&c);
      if(j == 0){
	T[v].l = c;
      }else{
	T[l].r = c;
      }
	l = c;
	T[c].p = v;
      
    }
  }
  for(i = 0;i<n;i++){
    if(T[i].p == NIL){
      r = i;
    }
  }
  rec(r,0);
  for(i = 0;i<n;i++)print(i);

  return 0;
  
}



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

vector<ll> to[1010];
vector<ll> ot[1010];
bool ok1[1010];
bool ok2[1010];

void dfs(int s){
  if(ok1[s]) return;
  ok1[s] = true;
  for(int i = 0;i < to[s].size();i++){
    dfs(to[s][i]);
  }
}
 
void dfs2(int s){
  if(ok2[s]) return;
  ok2[s] = true;
  for(int i = 0;i < ot[s].size();i++){
    dfs2(ot[s][i]);
  }
}

int main(){
  ll N,M;cin >> N >> M;
  vector<tuple<ll,ll,ll>> edges;
  for(int i = 0;i < M;i++){
    int a,b,c;cin >> a >> b >> c;
    a--;b--;
    c = -c;
    to[a].push_back(b);
    ot[b].push_back(a);
    edges.emplace_back(a,b,c);
  }
  bool upd = true;
  vector<ll> d(N,INF);
  d[0] = 0;
  ll step = 0;
  vector<bool> NEG(N,0);
  vector<bool> ok3(1010);
  fill(ok1,ok1+1010,0);
  fill(ok2,ok2+1010,0);
  dfs(0);
  dfs2(N-1);
  for(int i = 0;i < 1010;i++){
    ok3[i] = ok1[i] & ok2[i];
  }
  while(upd){
    upd = false;
    for(int i = 0;i < M;i++){
      ll a,b,c;
      tie(a,b,c) = edges[i];
      if(!ok3[a] || !ok3[b]) continue;
      if(NEG[a]){
        NEG[b] = 1;
      }
      ll newD = d[a] + c;
      if(d[b] > newD){
        upd = true;
        d[b] = newD;
        NEG[b] = 1;
      }
    }
    step++;
    if(step > N){
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -d[N-1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する


char c[1010][1010];
int memo[1010][1010];
queue<P>que;
int f[] = { 0,1,0,-1 };
int g[] = { 1,0,-1,0 };
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] != '#')memo[i][j] = INF;
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (c[i][j] == '#')que.push(make_pair(i, j));
		}
	}
	while(!que.empty()){
		P p = que.front();
		que.pop();
		rep(i, 4) {
			int nh = p.first + f[i], nw = p.second + g[i];
			if (nh < 0 || h <= nh || nw < 0 || w <= nw || memo[nh][nw] != INF)continue;
			memo[nh][nw] = memo[p.first][p.second] + 1;
			que.push(make_pair(nh, nw));
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j,w){
			ans = max(ans, memo[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19508
# D - joisino's travel
from scipy.sparse.csgraph import shortest_path
import numpy as np
import itertools

N, M, R = map(int, input().split())
R = [int(x) for x in input().split()]

# 任意の2地点間の距離を求める
edge = np.zeros((N+1, N+1)) # 1行目と1列目は使わない
for _ in range(M):
    A, B, C = map(int, input().split())
    edge[A, B] = C

# 2地点間の最短距離　　引数directed=False とすると無向グラフ
dist = shortest_path(edge, directed=False).astype(int)

# 全訪問順を試す 8! = 40320なので十分
answer = 10 ** 18
for visit in itertools.permutations(R):
    p = 0
    prev = visit[0]
    for x in visit[1:]:
        p += dist[prev, x]
        prev = x
    answer = min(answer, p)
  
print(answer)

Measured memory_bytes: 18480
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  vector<int>A(N+1);
  vector<ll>sum(N+1);
  sum[0] = 0;
  for ( int i = 1; i <= N; i++ ) cin >> A[i];

  for ( int i = 1; i <= N; i++ ) {
    sum[i] = sum[i-1]+A[i];
  }
  
  sort(sum.begin(),sum.end());
  ll tmp = sum[0];
  ll cnt = 1;
  ll ans = 0;
  for ( int i = 1; i < sum.size(); i++ ) {
    if ( tmp == sum[i] ) cnt++;
    else {
      if (cnt >=2 ) {
	ans += cnt*(cnt-1)/2;
      }
      tmp = sum[i];
      cnt = 1;
    }
  }
  if ( cnt >= 2 ) ans += cnt*(cnt-1)/2 ;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cEdges=vector<vector<int>>;

int main() {
	string str;
	cin>>str;
	long long ans=0;
	if(str.size()>1){
		queue<pair<vector<bool>,int>> Q;
		vector<bool> tmp(str.size()-1,false);
		Q.push(make_pair(tmp,1));
		tmp[0]=true;
		Q.push(make_pair(tmp,1));
		while(!Q.empty()){
			auto now=Q.front();
			Q.pop();
			if(now.second>=now.first.size()){
				int prev=0;
				long long sum=0;
				for(int i=0;i<now.first.size();++i){
					if(now.first[i]){
						sum+=stoll(str.substr(prev,i+1-prev));
						prev=i+1;
					}
				}
				sum+=stoll(str.substr(prev,str.size()-prev));
				ans+=sum;
			}
			else{
				auto next=now.first;
				next[now.second]=false;
				Q.push(make_pair(next,now.second+1));
				next[now.second]=true;
				Q.push(make_pair(next,now.second+1));
			}
		}
	}
	else{
		ans+=stoll(str);
	}

	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
vector<ll> g[N], vis(N), a(N), ans(N);
multiset<ll> s;
void dfs(ll v = 0)
{
    vis[v] = 1;
    s.insert(a[v]);
    auto it = s.lower_bound(a[v]);
    it++;
    ll x = 0;
    if (it != s.end())
        s.erase(it),
            x = *it;
    ans[v] = s.size();
    for (ll e : g[v])
        if (!vis[e])
            dfs(e);
    it = s.lower_bound(a[v]);
    if (it != s.end() && *it == a[v])
        s.erase(it);
    if (x)
        s.insert(x);
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, u, v;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    for (ll i = 1; i < n; i++)
        cin >> u >> v, u--, v--, g[u].push_back(v), g[v].push_back(u);
    dfs();
    for (ll i = 0; i < n; i++)
        cout << ans[i] << '\n';
}

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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>

using namespace std;



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	string str1;
	string str2;
	cin >> str1 >> str2;
	long long int arr[str1.length() + 1][str2.length() + 1];
	for (long long int i = 0; i <= str1.length(); i++)
	{
		arr[i][0] = 0;
	}
	for (long long int i = 0; i <= str2.length(); i++)
	{
		arr[0][i] = 0;
	}

	for (long long int i = 1; i < str1.length() + 1; i++)
	{
		for (long long int j = 1; j < str2.length() + 1; j++)
		{
			if (str1[i - 1] == str2[j - 1])
			{
				arr[i][j] = 1 + arr[i - 1][j - 1];
			}
			else {
				arr[i][j] = max(arr[i - 1][j], arr[i][j - 1]);
			}
		}
	}


	long long int i = str1.length();
	long long int j = str2.length();
	string ans;
	while (i > 0 && j > 0)
	{
		if (str1[i - 1] == str2[j - 1])
		{
			ans += str1[i - 1];
			i--;
			j--;
		}
		else {
			if (arr[i - 1][j] > arr[i][j - 1])
			{
				i--;
			}
			else {
				j--;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;









	return 0;


}


Measured memory_bytes: 74020
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 INF = 1 << 28;
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0)
				break;
			int land[][] = new int[n + 1][n + 1];
			int sea[][] = new int[n + 1][n + 1];
			for (int i = 1; i <= n; i++) {
				Arrays.fill(land[i], INF);
				Arrays.fill(sea[i], INF);
				land[i][i] = sea[i][i] = 0;
			}
			for (int i = 0; i < m; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int t = sc.nextInt();
				String sl = sc.next();
				if (sl.equals("L")) {
					land[x][y] = land[y][x] = Math.min(t, land[x][y]);
				} else {
					sea[x][y] = sea[y][x] = Math.min(t, sea[x][y]);
				}
			}
			for (int k = 1; k <= n; k++) {
				for (int i = 1; i <= n; i++) {
					for (int j = 1; j <= n; j++) {
						land[i][j] = Math.min(land[i][j], land[i][k]
								+ land[k][j]);
						sea[i][j] = Math.min(sea[i][j], sea[i][k] + sea[k][j]);
					}
				}
			}
			int r = sc.nextInt();
			int[] zs = new int[r];
			for (int i = 0; i < r; i++) {
				zs[i] = sc.nextInt();
			}
			int[][] dp = new int[r][n + 1]; // dp[i][j]
											// i番目までの配達を終え、船がjにあるときの最短時間。
			for (int i = 0; i < r; i++) {
				Arrays.fill(dp[i], INF);
			}
			dp[0][zs[0]] = 0;
			for (int i = 1; i < r; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						dp[i][j] = Math.min(dp[i][j], dp[i - 1][k]
								+ land[zs[i - 1]][k] + sea[k][j]
								+ land[j][zs[i]]);
					}
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]
							+ land[zs[i - 1]][zs[i]]);
				}
			}
			int ans = INF;
			for (int i = 1; i <= n; i++) {
				ans = Math.min(dp[r - 1][i], ans);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;
  cout << "A" << S2[0] << "C" << endl;
}

Measured memory_bytes: 256
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define lb(a) lower_bound(a)
#define is(a) insert(a)
#define ps(a) push(a)
const int N=5e5+10;
const int inf=0x3f3f3f3f;
int in[N],loc[N],p[N],ans[N],tot,n,k;
std::priority_queue <int,std::vector<int>,std::greater<int> > q;
int head[N],to[N<<1],Next[N<<1],cnt;
void add(int u,int v)
{
    to[++cnt]=v,Next[cnt]=head[u],head[u]=cnt;
}
#define ls id<<1
#define rs id<<1|1
int min(int x,int y){return x<y?x:y;}
int max(int x,int y){return x>y?x:y;}
int mi[N<<2];
void change(int id,int l,int r,int p,int d)
{
    if(l==r) {mi[id]=d;return;}
    int mid=l+r>>1;
    if(p<=mid) change(ls,l,mid,p,d);
    else change(rs,mid+1,r,p,d);
    mi[id]=min(mi[ls],mi[rs]);
}
int query(int id,int L,int R,int l,int r)
{
    if(mi[id]==inf) return inf;
    if(l==L&&r==R) return mi[id];
    int Mid=L+R>>1;
    if(r<=Mid) return query(ls,L,Mid,l,r);
    else if(l>Mid) return query(rs,Mid+1,R,l,r);
    else return min(query(ls,L,Mid,l,Mid),query(rs,Mid+1,R,Mid+1,r));
}
int main()
{
    scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d",p),p[p[0]]=i;
    memset(mi,0x3f,sizeof(mi));
    dep(i,n,1)
    {
        int loc=query(1,1,n,p[i],min(n,p[i]+k-1));
        if(loc!=inf) add(p[i],p[loc]),++in[p[loc]];
        loc=query(1,1,n,max(1,p[i]-k+1),p[i]);
        if(loc!=inf) add(p[i],p[loc]),++in[p[loc]];
        change(1,1,n,p[i],i);
    }
    rep(i,1,n) if(!in[i]) q.ps(i);
    while(!q.empty())
    {
        int now=q.top();
        ans[now]=++tot;
        q.pop();
        for(int i=head[now];i;i=Next[i])
        {
            int v=to[i];
            --in[v];
            if(!in[v]) q.ps(v);
        }
    }
    rep(i,1,n) printf("%d\n",ans[i]);
    return 0;
}



Measured memory_bytes: 27268
import math
a,b,x=list(map(int, input().split(" ")))
total_vol = (a**2)*b

# if x is less than half the volume of the bottle,
# we require contained_water_volume <= x in order for water not to overflow
# therefore we can compute for beta as follows:
# (b/tan beta)*a*b*0.5 <= x
# --> 0.5ab^2/x <= tan beta
# --> beta >= tan^-1(0.5 ab^2 / x)

# else if x is more than half the volume of the bottle,
# we require total_vol - unsubmerged_vol <= x in order for water not to overflow
# therefore we can compute for beta as follows:
# a^2 b - 0.5 a^2 (a tan beta) <= x
# --> - 0.5 a^2 (a tan beta) <= x - a^2 b
# --> beta >= tan^-1 ((-2(x-a^2 b))/(a^3))

if x <= 0.5*total_vol:
    beta = math.atan(a*(b**2)/(2*x))
    print(math.degrees(beta))
else:
    beta = math.atan((-2*(x-b*(a**2)))/(a**3))
    print(math.degrees(beta))


Measured memory_bytes: 3060
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <deque>

using ll = long long;
using ull = unsigned long long;

using namespace std;

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    int l, r, d;
    cin >> l >> r >> d;

    int ans{};

    for (int i = l; i <= r; ++i)
    {
        if (i % d == 0)
            ++ans;
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#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() {
  double n;
  cin >> n;
  int n1 = (n + 1) / 2;
  double ans = n1 / n;
  printf("%.10f", ans);
  return 0;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N, K;
    cin >> N >> K;
    vector<ll>A(N);
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    vector<ll>B;
    for(ll i = 1; i * i <= sum; i++){
        if(sum % i == 0){
            B.push_back(i);
            B.push_back(sum / i);
        }
    }
    ll ans = 1;
    for(ll i = 0; i < B.size(); i++){
        ll b = B[i];
        vector<ll>v;
        for(ll j = 0; j < N; j++){
            v.push_back(A[j] % b);
        }
        sort(v.begin(), v.end());
        ll cost = 0;
        ll L = 0, R = v.size() - 1;
        ll tmp = 0;
        for(;L <= R;){
            if(tmp <= 0){
                tmp += v[L];
                cost += v[L];
                L++;
            }
            else{
                tmp -= (b - v[R]);
                R--;
            }
        }
        if(cost <= K)ans = max(ans, B[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
    if i==N:
      print(sum(A))
      exit()
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))

Measured memory_bytes: 36212
#include<cstdio>
#include <algorithm>
using namespace std;
const int N=10000005;
int a[N];
int main(){
    a[0]=1;
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    a[i]=min(a[i-1]+k,a[i-1]*2);
    printf("%d\n",a[n]);
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N + 1, 0);
  auto f = [](int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; };
  for (int x = 1; x < 10000; x++) {
    for (int y = 1; y < 10000; y++) {
      for (int z = 1; z < 10000; z++) {
        int a = f(x, y, z);
        if (a > N) break;
        A[a]++;
      }
    }
  }
  for (int i = 1; i < N + 1; i++) {
    cout << A[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,b[200010] = {};
	cin >> n;
	for(int i = 1;i < n;i++){
		int a;
		cin >> a;
		b[a - 1]++;
	}
	for(int i = 0;i < n;i++) cout << b[i] << endl;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 40
#define INF 1000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int w[300];
bool dp[300][300];
int ddp[301];

void solve(){
    memset(dp,0,sizeof(dp));
    rep(i,n) cin >> w[i];
    for(int i = 1; i < n; i+= 2){
        for(int j = 0; j < n-i; j++){
            if(abs(w[j]-w[j+i]) <= 1){
                if(i == 1 || dp[j+1][j+i-1] == true){
                    dp[j][j+i] = true;
                }
            }
            for(int k = j+1; k <= j+i-2; k += 2){
                if(dp[j][k] == true && dp[k+1][j+i] == true){
                    dp[j][j+i] = true;
                }
            }
        }
    }
    rep(i,n) ddp[i] = 0;
    for(int i = 1; i < n; i += 2) if(dp[0][i]) ddp[i] = i+1;
    for(int i = 1; i < n; i++){
        ddp[i] = max(ddp[i],ddp[i-1]);
        for(int j = 1; j < n-i; j += 2){
            if(dp[i][i+j]) ddp[i+j] = max(ddp[i+j],ddp[i-1]+j+1);
        }
    }
    cout << ddp[n-1] << endl;
}

int main(){
    while(cin >> n){
        if(n == 0) break;
        solve();
    }
}

Measured memory_bytes: 3184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.System.*;


public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int nRows = Integer.parseInt(st.nextToken());
        int nCols = Integer.parseInt(st.nextToken());
        char[][] maze = new char[nRows][nCols];
        for (int i = 0; i < nRows; i++) {
            maze[i] = in.readLine().toCharArray();
        }

        int ans = 0;
        ArrayList<Coor> points = new ArrayList<>();
        for (int i = 0; i < nRows; i++) {
            for (int j = 0; j < nCols; j++) {
                if (maze[i][j] == '#') continue;
                points.add(new Coor(i, j));
            }
        }

        for(Coor src : points) {
            int d = dist(maze, src);
            ans = Math.max(ans, d);
        }

        out.println(ans);

    }

    static class Coor {
        int r, c;

        public Coor(int r, int c) {
            this.r = r;
            this.c = c;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Coor coor = (Coor) o;
            return r == coor.r &&
                    c == coor.c;
        }

        @Override
        public int hashCode() {
            return Objects.hash(r, c);
        }

        @Override
        public String toString() {
            return "Coor{" +
                    "r=" + r +
                    ", c=" + c +
                    '}';
        }
    }

    static  int DX[] = {1,0,-1,0};
    static  int DY[] = {0,1,0,-1};


    static int dist(char[][] maze, Coor src) {
        int nRows = maze.length;
        int nCols = maze[0].length;
        LinkedList<Coor> queue = new LinkedList<>();
        queue.offer(src);
        HashSet<Coor> visited = new HashSet<>();
        LinkedList<Integer> S = new LinkedList<>();
        S.offer(0);
        int ans = 0;
        while (!queue.isEmpty()) {
            Coor curr = queue.poll();
            int r = curr.r;
            int c = curr.c;
            int steps = S.poll();
            if (visited.contains(curr)) continue;
            if (r < 0 || r >= nRows || c < 0 || c >= nCols) continue;
            if (maze[r][c] == '#') continue;
            visited.add(curr);
            ans = Math.max(ans, steps);
            for (int m = 0; m < 4; m++) {
                int nr = r + DX[m];
                int nc = c + DY[m];
                queue.offer(new Coor(nr, nc));
                S.offer(steps+1);
            }
        }
        return ans;
    }

}


Measured memory_bytes: 45352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO
        string s,a,b,br,c,cr;
        cin>>s;

        a=s;
        int n=s.length();
        reverse(a.begin(),a.end());
        b=s.substr(0,(n-1)/2);
        c=s.substr((n+3)/2-1,(n)-(n+3)/2+1);
        cr=c;
        br=b;
        
        reverse(cr.begin(),cr.end());
        reverse(br.begin(),br.end());
        if(a==s &&br==b &&cr==c)
        	cout<<"Yes";
        else
        	cout<<"No";
        return 0;
    }


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    ArrayList <Integer> li = new ArrayList <Integer>();
    ArrayList <Integer> lili = new ArrayList <Integer>();
    for(int i=0; i<number-1; i++){
      int a = sc.nextInt();
      li.add(a);
    }
    for(int i=0;i<number-1;i++){
      lili.add(0);
    }
    for(int i=0; i<number-1; i++){
      int a = li.get(i);
      lili.set(a-1,lili.get(a-1)+1);
    }
    for(int i=0; i<number-1; i++){
      System.out.println(lili.get(i));
    }
    System.out.println(0);
  }
}

Measured memory_bytes: 67252