akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	int[][][] data=new int[5][4][11];
	
	
	public void run() {
		int N = sc.nextInt();
		for(int i=0;i<data.length;i++)for(int j=0;j<data[i].length;j++)Arrays.fill(data[i][j],0);
		for(int i=0;i<N;i++){
			int b=sc.nextInt(),f=sc.nextInt(),r=sc.nextInt(),v=sc.nextInt();
				data[b][f][r]+=v;
		}
		
		for(int b=1;b<=4;b++){
			for(int f=1;f<=3;f++){
				for(int r=1;r<=10;r++){
					pr(" "+data[b][f][r]);
				}
				ln();
			}
			if(b!=4)ln("####################");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

int main(){
    int H, W;
    cin >> H >> W;
    string s[100];
    for (int i = 1; i <= H; i++){
        cin >> s[i];
    }
    for (int i = 1; i <= H; i++){
        s[i] = "." + s[i] + ".";
    }
    for (int i = 0; i <= W + 1; i++){
        s[0] = s[0] + ".";
        s[H + 1] = s[H + 1] + ".";
    }

    bool flag = true;
    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            if (s[i][j] == '#' &&
                s[i][j + 1] == '.' && 
                s[i][j - 1] == '.' &&
                s[i - 1][j] == '.' &&
                s[i + 1][j] == '.'){
                flag = false;
            }
        } 
    }
    
    /*for (int i = 0; i <= H + 1; i++){
        cout << s[i] << endl;
    }*/
    
   if (flag == true){
       cout << "Yes" << endl;
   }
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll count ;

    if(0<=a+b-c){
        count=b+c;
    }
    else if(c>a+b){
        count=a+2*b+1;
    }
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fact(int n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}

int main(){
	//freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
     int n; cin>>n;
     vector <long double> x (n);
     vector <long double> y (n);
     long double ans=0;
     for(int i=0; i<n; i++){
     	cin>>x[i];
     	cin>>y[i];
	}
	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			ans+=((sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])))*(n-1)*2*(fact(n-2))/(fact(n)));
		}
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
}

Measured memory_bytes: 18312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int v, e;
    cin >> v >> e;
    vector<vector<int>> graph(v, vector<int>());
    vector<int> deg(v);
    for(int i = 0; i < e; i++){
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        deg[b]++;
    }
    vector<int> topological;
    queue<int> q;
    for(int i = 0; i < v; i++) if(!deg[i]) q.push(i);
    while(!q.empty()){
        int s = q.front();
        topological.push_back(s);
        q.pop();
        for(auto to: graph[s]){
            deg[to]--;
            if(!deg[to]) q.push(to);
        }
    }
    for(int i = 0; i < v; i++) cout << topological[i] << "\n";
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;

	if (N * 2 != (LL)sqrt(N * 2)*((LL)sqrt(N * 2) + 1))
	{
		out << "No" << std::endl;
		return 0;
	}
	if (N == 1)
	{
		out << "Yes" << std::endl << 2 << std::endl << 1 << " " << 1 << std::endl << 1 << " " << 1 << std::endl;
		return 0;
	}

	LL size = sqrt(N * 2);
	std::vector<std::vector<LL>>field(size);
	LL num = 1;
	rep(i, size)
	{
		rep(j, i + 1)
		{
			field[i].push_back(num);
			++num;
		}
	}

	std::vector<std::vector<LL>>ans(size + 1);
	rep(i, size)
	{
		ans[0].push_back(field[i][0]);
		ans[1].push_back(field[size - 1][i]);
		ans[2].push_back(field[i][i]);
	}
	rep(i, size - 2)
	{
		rep(j, i + 1) ans[i + 3].push_back(field[i + 1][j]);
		rep(j, size - i - 1) ans[i + 3].push_back(field[i + 1 + j][i + 1]);
	}

	out << "Yes" << std::endl << ans.size() << std::endl;
	rep(i, ans.size())
	{
		out << ans[i].size() << " ";
		rep(j, ans[i].size()) out << ans[i][j] << (j < ans[i].size() - 1 ? " " : "\n");
	}
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
    //freopen("input.txt", "r", stdin);
    int n, an=1;
    string s;
    cin>>n>>s;
    int q[26];
    for(int a=0; a<26; a++) q[a]=0;
    for(int a=0; a<n; a++) q[s[a]-'a']++;
    for(int a=0; a<26; a++) an=(1ll*an*(q[a]+1))%mod;
    an--;
    if(an<0) an+=mod;
    cout<<an;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
mint dp[505][512];
int main(){
    int n,x;
    cin>>n>>x;
    if(x==0){
        cout<<1<<endl;
        return 0;
    }
    dp[0][0]=1;
    for(int i=1;i<=x;i++){
        for(int j=n-1;j>=0;j--){
            for(int k=0;k<512;k++){
                dp[j+1][i^k]+=dp[j][k];
            }
        }
    }
for(int i=0;i<=x;i++){
    for(int j=1;j<=n-2;j++){
            dp[j+2][x]+=dp[j][x];
    }
}
    cout<<dp[n-1][x]+dp[n][x]<<"\n";
}




Measured memory_bytes: 52112
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
t = ns()

ss = len(s)
tt = len(t)
ans = 0

for i in range(ss-tt+1):
    a = 0
    for j in range(tt):
        if s[i+j] == t[j]:
            a += 1
    ans = max(a,ans)

print(tt-ans)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll k;
std::vector<ll> v(3);
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>v[0]>>v[1]>>v[2]>>k;
  sort(all(v));
  reverse(all(v));
  rep(i,k) v[0]*=2;
  ll ans = 0;
  rep(i,3) ans += v[i];
  cout<<ans<<endl;


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


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

struct edge{ int to,cost; };
const int N = 2e5+10;
vector< edge > G[N];

void dikstra(int s,int t){
  typedef pair<int, int> P;
  const int INF = 1 << 30;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(N,INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  cout << d[t] << endl;
}

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

  int n,m,s,t; cin >> n >> m >> s >> t;
  s--,t--;
  vector<int> d(n);
  for(int i = 0; i < n; i++){
    cin >> d[i];
    G[i+1].push_back({i,0});
  }
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a].push_back({b,d[b]});
  }

  dikstra(s,t);

  return 0;
}



Measured memory_bytes: 17776
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll  inf=1e18;
const int maxn=2e5+10;
const int maxm=1e2+10;
char s[maxn];int n,lst,nxt[maxn],pre[maxn][26];
ll l,r,cutpos,ans[26],fib[maxm],f[maxm][26];
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(ll x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(ll x){print(x);putchar(' ');}
void get_nxt(){
    nxt[1]=0;
    for(int i=2,j;i<=n;i++){
        j=nxt[i-1];
        while(j&&s[j+1]!=s[i])j=nxt[j];
        nxt[i]=s[j+1]==s[i]?j+1:0;
    }
}
void get_fib(){
    fib[1]=n;
    for(int i=1;i<=n;i++){f[1][s[i]-'a']++;f[2][s[i]-'a']++;}
    fib[2]=n+cutpos;
    for(int i=0;i<26;i++)f[2][i]+=pre[cutpos][i];
    for(int i=3;;i++){
        for(int j=0;j<26;j++)f[i][j]=f[i-2][j]+f[i-1][j];
        fib[i]=fib[i-2]+fib[i-1];if(fib[i]>inf){lst=i;break;}
    }
}
void cal(ll x,ll v){
    for(int i=lst;i>=1;i--)
        if(fib[i]<=x){
            x-=fib[i];
            for(int j=0;j<26;j++)ans[j]+=v*f[i][j];
        }
    for(int i=0;i<26;i++)ans[i]+=v*pre[x][i];
}
int main(){
    scanf("%s",s+1);l=read();r=read();
    n=strlen(s+1);n>>=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<26;j++)pre[i][j]+=pre[i-1][j];
        pre[i][s[i]-'a']++;
    }get_nxt();cutpos=n-nxt[n];
    get_fib();cal(r,1);cal(l-1,-1);
    for(int i=0;i<26;i++)write(ans[i]);puts("");
    return 0;
}


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

#define N 200123
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
    string s;
    ll dp[N][13];
	cin >> s;
	s = '0' + s;
	int n = (int)s.size();

	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < 13; j++)
			dp[i][j] = 0;

	dp[0][0] = 1;
	for(int i = 1 ; i < n ; i++){
		for(int j = 0 ; j < 13 ; j++){
			if(s[i] == '?'){
				for(int k = 0 ; k < 10 ; k++){
					dp[i][(k + j*10)%13] = (dp[i][(k + j*10)%13] + dp[i-1][j]) % mod;
				}
			} else {
				int num = (int)s[i]-'0';
				dp[i][(num + j*10)%13] = (dp[i][(num + j*10)%13] + dp[i-1][j]) % mod;
			}
		}
	}

	cout << dp[n-1][5]%mod << endl;
    return 0;
}

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

int main () {
  int N;
  cin >> N ;
  if( ((N / 1000 == N % 1000 / 100)&&(N / 1000 == N % 100 / 10)) || ((N % 1000 / 100 == N % 100 / 10)&&( N % 100 / 10== N % 10 ))) {
    cout << "Yes" << endl;
  }
  
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[100005];
ll n, a, b;
bool valid (ll k) {
  ll temp = 0;
   for (int i = 0; i < n; i++) {
     if (b * k < h[i]) {
        temp += (h[i] - k * b + a - b - 1) / (a - b);
     }
  }
  return temp <= k;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  ll lo = 0, hi = 1e9;
  ll mid;
  while (lo < hi) {
     mid = (lo + hi) / 2;
     if (valid(mid)) {
        hi = mid;
     } else {
       lo = mid + 1;
     }
  }
  cout << hi << endl;
  //cout << lo << " " << mid << " " << hi << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll H, W;
    cin >> H >> W;
    ll ans = INF, S = H * W;
    rep(h, H)
    {
        ll s1 = h * W, s2 = (H - h) * (W / 2), s3 = S - (s1 + s2);
        ll sm = min({s1, s2, s3}), sM = max({s1, s2, s3});
        chmin(ans, sM - sm);
    }
    rep(w, W)
    {
        ll s1 = H * w, s2 = (H / 2) * (W - w), s3 = S - (s1 + s2);
        ll sm = min({s1, s2, s3}), sM = max({s1, s2, s3});
        chmin(ans, sM - sm);
    }
    rep(h, H)
    {
        ll s1 = h * W, s2 = ((H - h) / 2) * W, s3 = S - (s1 + s2);
        ll sm = min({s1, s2, s3}), sM = max({s1, s2, s3});
        chmin(ans, sM - sm);
    }
    rep(w, W)
    {
        ll s1 = H * w, s2 = H * ((W - w) / 2), s3 = S - (s1 + s2);
        ll sm = min({s1, s2, s3}), sM = max({s1, s2, s3});
        chmin(ans, sM - sm);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

const int INF = 1e9 + 5;

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n , k;
    std::cin >> n >> k;

    std::vector<int> stones(n);
    for(int& i : stones){
        std::cin >> i;
    }

    std::vector<int> dp(n , INF);  
    dp[0] = 0;
    for(int i = 0 ; i < n ; ++i){
        for(int j = 1 ; j <= k ; ++j){
            if(i + j < n){
                dp[i + j] = std::min(dp[i] + std::abs(stones[i] - stones[i + j]) , dp[i + j]);
            }
        }
    }

    std::cout << dp[n - 1] << '\n';   

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int X,N;
    int p[110];
    
    cin >> X >> N;
    for(int i=0;i<N;i++) cin >> p[i];
    
    int i=0;
    int min = X+1;
    bool diff = true;
    int near = X;
    
    while(1){
        for(int j=0;j<N;j++){
            if(i==p[j]) diff = false;
        }
        if(abs(X-i) > min) {
            cout << near;
            break;
        }
        if(abs(X-i) < min and diff == true) {
            min = abs(X-i);
            near = i;
        }
        diff = true;
        i++;
        
        
    }
    
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n;
    for (int i = 0; i < 32; i++) {
        if (abs(n) & (1ll << i)) n += (1ll << i) * (i % 2 ? 1 : -1), s = '1' + s;
        else s = '0' + s;
    }
    while (s.length() > 1 && s[0] == '0') s.erase(s.begin());
    cout << s;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<string>v(n);
		rep(i, 0, n) {
			cin >> v[i];
			int cnt(0);
			rep(j, 0, v[i].size()) {
				if (v[i][j] == '.') {
					v[i][j] = ' ';
					cnt++;
				}
			}
			if (cnt&&i) {
				v[i][cnt - 1] = '+';
				for (int j = i-1; j >= 0 && cnt -1 <v[j].length(); j--) {
					if (v[j][cnt - 1] == ' ')v[j][cnt - 1] = '|';
					else break;
				}
			}
		}
		rep(i, 0, n)cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3684
N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in range(N):
    p[i] = (1+p[i])/2
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s>s:
        s = max_s
print(s)


Measured memory_bytes: 24684
N, M = map(int, input().split())
X = list(map(int, input().split()))

# Xを昇順ソート
X = sorted(X)

# 1番左の要素は必ず選び
# 残りの(N-1)個は階差数列の大きい順に選んだときが最適

# 階差数列: (X[k]-X[k-1], k)
Xd = [None] * (M - 1)
for i in range(1, M):
    Xd[i-1] = (X[i] - X[i-1], i)

# 階差数列を昇順ソート
Xd = sorted(Xd)

# コマを置く座標のインデックス
K = []

# 残りのM-1個を選ぶ
for i in range(N-1):
    if len(Xd) == 0:
        break

    a = Xd.pop(-1) # lastのpopはO(1)
    K.append(a[1])
    
# 左端以外について、コマを置いた座標と左隣の座標の差 == 節約できた移動量
s = 0
for k in K:
    s += X[k] - X[k-1]

l = X[-1] - X[0] - s
print(l)


Measured memory_bytes: 18200
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    S = input()
    A = set(chr(ord("a") + x) for x in range(26))
    if len(S) < 26:
        se = A - set(S)
        x = min(se)
        print(S + x)

    else:
        if S == "".join(sorted(A, reverse=True)):
            print(-1)
            return
        else:
            c = []
            S = list(S)
            while True:
                x = S[-1]
                if not c or (x > max(c)):
                    c.append(S.pop())
                    continue
                y = min(ch for ch in c if ch > x)
                S = "".join(S[:-1]) + y
                print(S)
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  out((H2 * 60 + M2 - H1 * 60 - M1) - K);
}


Measured memory_bytes: 3640
//********************MY MISTAKES****************** //
//any inbuilt function like v.size()-1; should not be used directly,v.size() first should be stored in variable**************
//graph may be forest
//when removing a node and again checking for cycle the resultant graph may also become forest
//in detection of cycle take care in if condition where to use only visited and where to use if(visited==1)
//in detection of cycle in directed graph we should not pass parent in dfs


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

typedef long long ll;
# define  pii pair<ll,ll> 
# define pb push_back
# define f first 
# define s second 

vector<ll> Adj[100001];
ll visited[100001];


ll flag=0;

void dfs(ll u,ll visited[])
{
    visited[u]=1;
    
    for(auto it: Adj[u])
    {   //if(flag==1) break;
        //if(it==pa) continue;
        
        if(visited[it]==1)  {flag=1;break;}
        if(!visited[it])
        {
            
        dfs(it,visited);
           
        
        }
        
    }
    
    if(flag!=1) 
        visited[u]=2;
    
    
}

ll cn_flag=0;

void dfs2(ll u,ll ch_visited[])
{   
    ch_visited[u]=1;
    //cout<<"u "<<u<<endl;
    
    for(auto it: Adj[u])
    {   //cout<<it<<" "<<"visited[it] "<<visited[it]<<endl;
        if(visited[it]!=1) continue;
       // cout<<"it "<<it<<endl;

       // if(it==pa) continue;
        
        if(ch_visited[it]==1)  {cn_flag=1;break;}
        if(!ch_visited[it])
        dfs2(it,ch_visited);
    }
    
    ch_visited[u]=2;
    
}

int main() {
    
    ll n,m;
    cin>>n>>m;
    
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        Adj[x].pb(y);
    }
    
    
    
    memset(visited,0,sizeof(visited));
    
    for(ll i=1;i<=n;i++)
    {
        if(flag!=1)
        {
            if(!visited[i])
                dfs(i,visited);
        }
    }
    vector<ll> cycle_nodes;
    
    for(ll i=1;i<=n;i++)
    {  // cout<<i<<" "<<visited[i]<<" ";
        if(visited[i]==1)
        {
            cycle_nodes.pb(i);
            //cout<<i<<" ";
        }
       // cout<<endl;
    }
    
    
    ll check_visited[100001];
//cout<<"jj "<<cycle_nodes.size()<<endl;
ll sz=cycle_nodes.size();
    
    for(ll i=0;i<sz;i++)
    {   //cout<<"uuuu"<<endl;
        
        memset(check_visited,0,sizeof(check_visited));
        //cout<<cycle_nodes[i]<<" kk "<<endl;
        visited[cycle_nodes[i]]=3;
        
        cn_flag=0;
        
        for(int i=0;i<sz;i++)
        {
            if(!check_visited[cycle_nodes[i]])
        dfs2(cycle_nodes[i],check_visited);
        }
        
        if(cn_flag==0)  visited[cycle_nodes[i]]=1;
     }
    
    
    
    vector<ll> final;
    
    for(ll i=0;i<cycle_nodes.size();i++)
    {
        if(visited[cycle_nodes[i]]==1) final.pb(cycle_nodes[i]);
    }
    if(flag!=0)
    {
    cout<<final.size()<<endl;
    for(ll i=0;i<final.size();i++)
    {
        cout<<final[i]<<endl;
    }
    }
    else
    {
        cout<<"-1"<<endl;
    }
    
	return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        int a[100];
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n,cmp);
        int len=0;
        for(int i=0;i<k;i++)
        {
            len+=a[i];
        }
        cout<<len<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
import numpy as np

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
INF = 10 ** 18
V_MAX = 10 ** 3 * N

dp = np.full(V_MAX + 1, INF)
dp[0] = 0

for w, v in wv:
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)

ans = 0
for i in range(V_MAX, -1, -1):
    if dp[i] <= W:
        ans = i
        break

print(ans)


Measured memory_bytes: 29080
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	ll n, r;
	cin >> n >> r;
	if (n < 10)
		cout << r + 100 * (10 - n) << '\n';
	else
		cout << r << '\n';
	
	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] num = ReadLine().Split(' ');
        int n = int.Parse(num[0]);
        int k = int.Parse(num[1]);
        int ans = k;
        int n1 = n-1;
        int k1 = k-1;
        for(int i=0;i<n1;i++){
            ans*=k1;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

struct UnionFind {

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size) : data(size, -1) {}

	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			// 要素数の大きな方へ合併するためのswap
			if (data[y] < data[x]) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x != y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y) {
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x) {
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0) ? x : data[x] = root(data[x]);
	}

	// 集合の要素数を返す
	int size(int x) {
		return -data[root(x)];
	}
};
vector<int>G[100100];
int g[100100];
int main() {
	int n, m, k; cin >> n >> m >> k;
	UnionFind u(n);
	REP(i, n)g[i] = 0;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		u.unite(a, b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	REP(i, k) {
		int c, d;
		cin >> c >> d;
		c--, d--;
		if (u.find(c, d)) {
			g[c]++;
			g[d]++;
		}
	}
	REP(i, n) {
		cout << u.size(i) -G[i].size()-g[i]-1<< " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
int h,w,k,MIN,sum[20][1010];
int now[20];
char s[20][1010];
struct node
{
	int l,r;
}sh[20];
int main()
{
	scanf("%d%d%d",&h,&w,&k);
	for (int i=1;i<=h;i++)
	  scanf("%s",s[i]+1);
	for (int j=1;j<=w;j++)
	{
		for (int i=1;i<=h;i++)
		  sum[i][j]=sum[i-1][j]+s[i][j]-'0';
	}
	MIN=inf;
	int full=(1<<(h-1))-1;
	for (int mask=0;mask<=full;mask++)
	{
		int cnt=0,g=1;
		sh[g].l=1;
		for (int j=0;j<h-1;j++)
		{
			cnt+=((mask>>j)&1);
			if (((mask>>j)&1))
			{
				sh[g].r=j+1;
				g++;
				sh[g].l=j+2;
			}
		}
		sh[g].r=h;
		bool bl=1;
		for (int i=1;i<=g;i++)
		{
			now[i]=0;
			for (int j=1;j<=w;j++)
			{
				if (sum[sh[i].r][j]-sum[sh[i].l-1][j]>k)
				{
					bl=0;
					break;
				}
			}
		}
		if (!bl) continue;
		for (int j=1;j<=w;j++)
		{
			bl=1;
			for (int i=1;i<=g;i++)
			{
				now[i]+=sum[sh[i].r][j]-sum[sh[i].l-1][j];
				if (now[i]>k)
				{
					bl=0;
					break;
				}
			}
			if (!bl)
			{
				cnt++;
				for (int i=1;i<=g;i++)
				  now[i]=sum[sh[i].r][j]-sum[sh[i].l-1][j];
			}
		}
		MIN=min(MIN,cnt);
	}
	printf("%d\n",MIN);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
    int n;
    cin >> n;

    vector<int> d;
    inputVector(d, n);

    vector<int> ret;

    int maxNum = 0;
    rep(i, n) maxNum = max(maxNum, d[i]);

    int node[100];
    rep(i, 100) node[i] = -1;

    int prev = -1;
    rep(i, (maxNum + 1) / 2) {
	rep(j, n) {
	    if (d[j] == maxNum - i) {
		if (prev != -1) {
		    ret.push_back(prev);
		    ret.push_back(j);
		}
		node[maxNum - i] = j;
		d[j] = -1;
		prev = j;
		cerr << "prev : " << prev << endl;
		break;
	    }
	    if (j == n - 1) {
		cerr << 1 << endl;
		cout << "Impossible" << endl;
		return 0;
	    }
	}
    }

    if ((maxNum + 1) % 2) {
	rep(j, n) {
	    if (d[j] == maxNum - (maxNum + 1) / 2) {
		ret.push_back(prev);
		ret.push_back(j);
		node[maxNum - (maxNum + 1) / 2] = j;
		prev = j;
		cerr << "prev(center) : " << prev << endl;
		d[j] = -1;
		break;
	    }
	    if (j == n - 1) {
		cerr << 2 << endl;
		cout << "Impossible" << endl;
		return 0;
	    }
	}
    }

    for (int i = (maxNum + 1) / 2 - 1; i >= 0; i--) {
	rep(j, n) {
	    if (d[j] == maxNum - i) {
		ret.push_back(prev);
		ret.push_back(j);
		node[maxNum - i] = j;
		d[j] = -1;
		prev = j;
		cerr << "prev : " << prev << endl;
		break;
	    }
	    if (j == n - 1) {
		cerr << 3 << endl;
		cout << "Impossible" << endl;
		return 0;
	    }
	}
    }

    rep(i, n) {
	if (d[i] == -1) continue;
	if (d[i] == 0 || node[d[i] - 1] == -1) {
	    cout << "Impossible" << endl;
	    return 0;
	}
	ret.push_back(node[d[i] - 1]);
	ret.push_back(i);
    }

    cout << "Possible" << endl;

    return 0;
}


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

using namespace std;

#define pb push_back

const long long inf = 1e18;
const int maxi = 1e6+10;
int a[maxi];
vector<int> v[maxi];
string s;
string t;
long long k;
int main()
{
    cin>>s>>k;

    int n = s.size();

    if (n==1)
    {
        return !printf("%lld\n",k/2);
    }

    long long ans = inf;

    int cnt = 1;
    int rez = 0;

    for (int i =1;i<n;i++)
    {
        if (s[i] == s[i-1]) cnt++; else
        {
            rez+=cnt/2;
            cnt = 1;
        }
    }

    rez += cnt/2;


    if (s[0]!=s[n-1]) return !printf("%lld\n", k*rez); else
    {
        int first = 0;
        int last = 0;

        for (int i =1;i<n;i++)
            if (s[i]!=s[0])
        {
            first = i;
            break;
        }

        for (int i=n-2;i>=0;i--)
            if (s[i]!=s[n-1])
        {
            last = n - i - 1;
            break;
        }

        if (first == 0 )
        {
            return !printf("%lld\n", k*n/2);
        } else
        {
            if (first%2==0 || last%2==0) return !printf("%lld\n", k*rez); else
                return !printf("%lld\n", (k-1)*(rez+1) + rez);
        }
    }

    return 0;
}
//odlazim (da da da), a volim te (ne ne ne)


Measured memory_bytes: 24832
#include <stdio.h>

int main(){
  int H, W, i, j;
  char s[50][50];
  scanf("%d %d", &H, &W);
  for(i=0;i<H;i++){
    scanf("%s", s[i]);
  }

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      int check = 0;
      if(s[i][j] == '#'){
        if(i>0) {if(s[i-1][j] == '#') check++;}
        if(i<H) {if(s[i+1][j] == '#') check++;}
        if(j>0) {if(s[i][j-1] == '#') check++;}
        if(j<W) {if(s[i][j+1] == '#') check++;}
        if(check == 0){
          puts("No");
          return 0;
        }
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
p = list(map(int, input().split()))

s = [0] * (len(p)+1)
p = [0] + p
for i in range(1, len(p)) :
    s[i] = s[i-1] + ((p[i]*(p[i]+1)) // 2) /p[i]
    p[i] = ((p[i]*(p[i]+1)) // 2) /p[i]

#print(p)
#print(s)
maxValue = -100100100
anker = -99

for i in range(n-k+1) :
    if maxValue < s[i+k] - s[i] :
        maxValue = s[i+k] - s[i]
        anker = i
ans = 0
for i in range(anker+1, anker+k+1) :
    ans += p[i]
    #print(ans)

print(ans)


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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;
int n;
ll k;

int main() {
  fscanf(stdin, "%d%lld ", &n, &k);
  vector<pair<ll, ll>> ab(n);
  REP(i,n) {
    ll a, b;
    fscanf(stdin, "%lld%lld ", &a, &b);
    ab[i] = mp(a, b);
  }
  sort(ab.begin(), ab.end());
  ll cnt = 0;
  REP(i,n) {
    ll a = ab[i].first, b = ab[i].second;
    cnt += b;
    if (cnt >= k) {
      fprintf(stdout, "%lld\n", a);
      return 0;
    } 
  }
  return 0;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};
int n,m,a,b,c,x[20][20];
int dp[20][1<<20];

int main(){
  rep(i,20){
    rep(j,20) x[i][j]=INF;
    rep(j,(1<<20)) dp[i][j]=INF;
  }
  cin>>n>>m;
  rep(i,m){
    cin>>a>>b>>c;
    x[a][b]=c;
  }
  dp[0][1]=0;
  rep(i,(1<<n)){
    rep(j,n){
      if(dp[j][i]<INF){
        rep(k,n){
          if((i/(1<<k))%2==0){
            int dist=dp[j][i]+x[j][k];
            int pos=i+(1<<k);
            if(dp[k][pos]>dist){
              dp[k][pos]=dist;
            }
          }
        }
      }
    }
  }
  int maxn=INF;
  rep(i,n) maxn=min(dp[i][(1<<n)-1]+x[i][0],maxn);
  if(maxn==INF) maxn=-1;
  cout<<maxn<<endl;
}



Measured memory_bytes: 85048
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  cout << fixed;
  cout << setprecision(9) << W * H / 2;
  cout << " ";
  if(W / 2 == x && H / 2 == y) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll N, M;
  std::cin >> N >> M;

  std::vector< std::string > va(N, "");
  for (ll i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    va[i] = s;
  }

  std::vector< std::string > vb(M, "");
  for (ll i = 0; i < M; i++) {
    std::string s;
    std::cin >> s;
    vb[i] = s;
  }

  std::string ans = "No";
  for (ll y = 0; y < N - M + 1; y++) {
    for (ll x = 0; x < N - M + 1; x++) {
      bool judge = true;
      for (ll by = 0; by < M; by++) {
	for (ll bx = 0; bx < M; bx++) {
	  if (va[y+by][x+bx] != vb[by][bx]) {
	    judge = false;
	  }
	}
      }
      if (judge == true) {
	ans = "Yes";
      }
    }
  }

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n; 
    cin >> n;
    cout << n*n*n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,m;cin>>n>>m;
    ll a;;
    rep(i,0,m-1){
        cin>>a;
        n-=a;
    }
    if(n<0){
        cout<<-1<<endl;
    }else{
        cout<<n<<endl;
    }
    
}



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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int64_t> a(n);
    for(auto &e : a) cin >> e;
    vector<int64_t> sum(n + 1), pos(n + 1);
    for(int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i];
    for(int i = 0; i < n; ++i) pos[i + 1] = pos[i] + (a[i] > 0 ? a[i] : 0);
    int64_t ans = 0;
    for(int i = 0; i + k - 1 < n; ++i) {
        int j = i + k;
        int64_t add = sum[j] - sum[i];
        int64_t sub = pos[j] - pos[i];
        ans = max(ans, pos[n] - sub);
        ans = max(ans, pos[n] - sub + add);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        Integer[] delicious = new Integer[x];

        for(int i = 0; i < x; i++) {
            delicious[i] = Integer.parseInt(scanner.next());
        }

        int total = 0;
        for(int i = 0; i < x; i++) {
            for(int j = i+1; j < x; j++) {
                total += delicious[i] * delicious[j];
            }
        }

        System.out.println(total);
    }
}

Measured memory_bytes: 21844
import numpy as np

c = [[0]*3] * 3

for i in range(3):
    c[i] = list(map(int, input().split()))

c = np.array(c)

if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 21640
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
a=set(a)
for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Measured memory_bytes: 470264
import java.util.*;
import java.lang.*;
import java.io.*;
     
public class Main {
	public static void main(String[] args) {
	
		try (Scanner sc = new Scanner(System.in)){
			
			int n = sc.nextInt();
            System.out.println(getA(n));
		}
    }

    public static int getA(int n){
        int result = 0;
        if (n % 2 ==0) {
            return n;
        } else {
            return n * 2;
        }
    }
}

Measured memory_bytes: 21588
#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 int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

signed main(){

    int N;
    string S;
    cin >> N;
    cin >> S;

    int leftE = 0;
    int leftW = 0;
    int rightE = 0;
    int rightW = 0;

    FOR(i, 1, N){
        if(S[i] == 'W'){
            rightW++;
        }else{
            rightE++;
        }
    } 

    int ans = rightE;

    FOR(i, 1, N){
        if(S[i - 1] == 'W'){
            leftW++;
        }else{
            leftE++;
        }
        if(S[i] == 'W'){
            rightW--;
        }else{
            rightE--;
        }

        int ans_tmp = rightE + leftW;

        if(ans_tmp < ans) ans = ans_tmp;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 900
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int h[100010];
    cin >> n;
    int prev;
    int tmpcnt;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (i == 0) {
            tmpcnt = 0;
            prev = h[i];
            continue;
        }

        if (prev >= h[i]) {
            tmpcnt++;
            ans = max(ans, tmpcnt);
        }
        else {
            tmpcnt = 0;
        }
        prev = h[i];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll n;
  cin>>n;
  vector<ll> a(n+1),sum(n+1);
  for(ll i = 0 ; i<=n ; i++ ) { cin>>a[i];}
  sum[n] = a[n] ;
  for( ll i=n-1 ; i>=0 ; i--) { sum[i] = sum[i+1]+ a[i] ;}
  ll last = 1 ; ll ans = 1;
  if( (n==0 && a[0]!=1) || (n>0 && a[0]!=0) ) { cout<<-1; return 0;}
  for( ll i = 1 ; i<=n ; i++ )
  {
      ll poss = last*2 ;
      if( a[i] > poss  ) { cout<<-1; return 0 ; }
      ll acc = sum[i];
      ll temp = min( poss , acc ) ;
      ans += temp ;
      last = temp - a[i] ;
  }
  cout<<ans;
  return 0;

}


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

int main(void)
{
  int a[3];
  for(int i=0;i<3;i++){
	 cin >> a[i];
  }
    cout << a[3-1] << ' ' << a[1-1] << ' ' << a[2-1];
    
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int a,b,k,i,c=0;
	
	scanf("%d%d%d",&a,&b,&k);
	i=a+1;
	while(c<k){
		i--;
		if(a%i==0 && b%i==0)
			c++;
		}
	printf("%d",i);
	return 0;
}

		

Measured memory_bytes: 128