akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        string S = NextString();
        bool f = false;
        for (int i = 0; i < 3; i++) if (S[i] == S[i + 1]) f = true;
        Console.WriteLine(f ? "Bad" : "Good");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

pair<int,int> usa[1111111];
pair<int,int> neko[1111111];

int sumusa[2222];
int sumneko[2222];
int usascore,nekoscore;
int N,U,V,M;

int main(){

	cin >> N >> U >> V >> M;
	REP(i,N){
		REP(j,N){
			int tmp;cin >> tmp;
			usa[tmp] = MP(i+1,j+1);
		}
	}
	REP(i,N){
		REP(j,N){
			int tmp;cin >> tmp;
			neko[tmp] = MP(i+1,j+1);
		}
	}

	REP(i,M){
		int tmp;cin >> tmp;
		if(N == 1){
			int us = usa[tmp].FI != 0;
			int ne = neko[tmp].FI != 0;
			if(us >= U && ne < V){
				cout << "USAGI" << endl;
				return 0;
			}
			if(us < U && ne >= V){
				cout << "NEKO" << endl;
				return 0;
			}
		}
		else {
			if(usa[tmp].FI != 0){
				sumusa[usa[tmp].FI]++;
				if(sumusa[usa[tmp].FI] == N){
					usascore++;
				}
				sumusa[555+usa[tmp].SE]++;
				if(sumusa[555+usa[tmp].SE] == N){
					usascore++;
				}
				if(usa[tmp].FI == usa[tmp].SE){
					sumusa[1111]++;
					if(sumusa[1111] == N)usascore++;
				}
				if(usa[tmp].FI == (N - usa[tmp].SE + 1)){
					sumusa[1119]++;
					if(sumusa[1119] == N)usascore++;
				}
			}
			if(neko[tmp].FI != 0){
				sumneko[neko[tmp].FI]++;
				if(sumneko[neko[tmp].FI] == N){
					nekoscore++;
				}
				sumneko[555+neko[tmp].SE]++;
				if(sumneko[555+neko[tmp].SE] == N){
					nekoscore++;
				}
				if(neko[tmp].FI == neko[tmp].SE){
					sumneko[1111]++;
					if(sumneko[1111] == N)nekoscore++;
				}
				if(neko[tmp].FI == (N - neko[tmp].SE + 1)){
					sumneko[1119]++;
					if(sumneko[1119] == N)nekoscore++;
				}
			}
			if(usascore >= U && nekoscore < V){
				cout << "USAGI" << endl;
				return 0;
			}
			if(usascore < U && nekoscore >= V){
				cout << "NEKO" << endl;
				return 0;
			}
		}
	}
	cout << "DRAW" << endl;

	return 0;
}



Measured memory_bytes: 18728
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> v2l;
typedef vector<bool> vb;
typedef vector<vb> v2b;

const ll AMAX = 5e12;

int dfs(vi e[], int x, int p, v2l &dp1, v2b &dp2) {
    int sz = 1;

    for (int y : e[x]) {
        if (y == p) {
            continue;
        }

        int ysz = dfs(e, y, x, dp1, dp2);
        for (int i = sz - 1; i >= 0; i--) {
            for (int j = ysz - 1; j >= 0; j--) {
                if (j > 0) {
                    dp1[x][i+j] = min(dp1[x][i+j], dp1[x][i] + dp1[y][j]);
                    dp2[x][i+j] = dp2[x][i+j] || dp2[x][i] && dp2[y][j];
                }
                if (dp1[y][j] < 0 || dp2[y][j]) {
                    dp1[x][i+j+1] = min(dp1[x][i+j+1], dp1[x][i]);
                    dp2[x][i+j+1] = dp2[x][i+j+1] || dp2[x][i];
                }
            }
            dp1[x][i] = min(AMAX, dp1[x][i] + dp1[y][0]);
            dp2[x][i] = dp2[x][i] && dp2[y][0];
        }

        sz += ysz;
    }

    return sz;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    v2l dp1(n, vl(n, AMAX));
    for (int i = 0; i < n; i++) {
        dp1[i][0] = a[i];
    }

    v2b dp2(n, vb(n, false));
    for (int i = 0; i < n; i++) {
        if (a[i] > 0) {
            dp2[i][0] = true;
        }
    }

    dfs(e, 0, -1, dp1, dp2);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (dp1[0][i] < 0 || dp2[0][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 201472
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, M;
    cin >> N >> M;
    vec<P> store(N);
    REP(i, N){
        cin >> store[i].fi >> store[i].se;
    }
    sort(ALL(store));
    ll money = 0;
    EACH(s, store){
        if(s.se >= M){
            //買えるなら
            money += M*s.fi;
            break;
        }
        money += s.se*s.fi;
        M -= s.se;
    }
    cout << money << el;
}



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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> b;

    for (int i = 0; i < M; i++)
    {
        int bi;
        cin >> bi;
        b.push_back(bi);
    }

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        int ans = 0;
        for (int j = 0; j < M; j++)
        {
            int ai;
            cin >> ai;
            ans += ai * b[j];
        }
        ans += C;

        if (ans > 0)
        {
            sum += 1;
        }
    }

    cout << sum << endl;
}


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

int main() {
	int n; string l; cin>>n>>l;
	vector<string> a(n);
	for(int i = 0; i<n; i++){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	for(auto x: a){
		cout<<x;
	}
	return 0;
}

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

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let n = it.next().unwrap();
    
    println!("{}",n*n*n);

    
}


Measured memory_bytes: 5024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    long n, x, y;
    scan(n, x, y);
    x--, y--;
    if (x > y)
        swap(x, y);
    auto dist = new long[](n - 1);
    foreach (i; iota(n))
    {
        foreach (j; iota(i + 1, n))
        {
            dist[min(j - i, abs(x - i) + abs(y - j) + 1) - 1]++;
        }
    }
    foreach (e; dist)
        e.writeln();
}

bool is_mindist(long i, long j, long x, long y, long dist)
{
    return dist == min(j - i, abs(x - i) + abs(y - j) + 1);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define MAX_N 20
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,tx,ty;
ll ans=0;
ll a[MAX_N];
ll is_good[MAX_N]={};
vector<ll> x[MAX_N],y[MAX_N];
signed main(){
  ll tmp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    for(int j=0;j<a[i];j++){
      cin >> tx >> ty;
      tx--;
      x[i].push_back(tx);
      y[i].push_back(ty);
    }
  }
  bool can;
  ll cnt=0;
  for(ll i=0;i<(1<<(n+1));i++){
    fill(is_good,is_good+MAX_N,-1);
    can = true;
    cnt = 0;
    tmp = i;
    for(ll j=0;j<n;j++){
      is_good[j] = tmp%2;
      cnt+=tmp%2;
      tmp/=2;
    }
    for(ll j=0;j<n;j++){
      if(is_good[j]==0) continue;
      for(int k=0;k<a[j];k++){
        if(is_good[x[j][k]]!=y[j][k]){
          can = false;
          break;
        }
      }
    }
    if(can){
      ans = max(cnt,ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
bool prime(int x)
{
	if(x==1)
	{
		return false;
	}
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	int n;
	cin>>n;
	for(int i=n;;i++)
	{
		if(prime(i))
		{
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
lis = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if lis[i] != lis[j] and lis[i] != lis[k] and lis[k] != lis[j] and lis[i] + lis[j] > lis[k] and lis[i] + lis[k] > lis[j] and lis[j] + lis[k] > lis[i]:
                ans += 1
                # print(i, j, k)
print(ans)


Measured memory_bytes: 9016
#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() {
    int N, M;
    cin >> N >> M;

    int ML = 1;
    int mR = N;
    while (M--)
    {
        int L, R;
        cin >> L >> R;
        ML = max(ML, L);
        mR = min(mR, R);
    }
    
    if (mR - ML + 1 > 0)
    {
        cout << mR - ML + 1 << endl;
    } else
    {
        cout << 0 << endl;
    }
    
    
    
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(fab(n));
	}
	//recursive 
	public static int  fib(int n){
		if(n==1) return 1; 
		if(n==0) return 1; 
		return fib(n-1)+fib(n-2);
	}
	public static int fab(int n){
		int dp[] = new int[n+1];
		dp[0]=1;
		dp[1] =1;
		for(int i=2;i<=n;i++){
			dp[i] = dp[i-1]+dp[i-2];
		}
		return dp[n];
	}
	
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

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

void solve() {
    double d, t, s, pk;
    cin >> d >> t >> s;
    pk = d / s;
    cout << ((pk <= t) ? "Yes\n" : "No\n");
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;


struct Node {
  int key;
  Node *right,*parent,*left;
};

  Node *root,*Nil;



void insert(int a){
  Node *x=root;
  Node *y=Nil;
  Node *z;

  z=(struct Node *)malloc(sizeof( Node));
  z->key=a;
  z->left=Nil;
  z->right=Nil;

  while(x!=Nil){
    y=x;
    if(z->key < x->key){x = x->left;}
    else {x = x->right;}
  }
 z->parent=y;

 if(y==Nil){root=z;}
 else {
   if(z->key < y->key){y->left=z;}
   else {y->right=z;}
 }
}

void inorder(Node *x){
   if(x==Nil)return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

void preorder(Node *x){
  if(x==Nil)return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);
}

int main(){
  int n,i,a;
  string co;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin >> co;
    if(co=="insert"){
      scanf("%d",&a);
      insert(a);
    }
    else if(co=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26748
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
a = [[0] * (W + 2) for _ in range(H + 2)]
for i in range(H):
    for j in range(W):
        tmp_i = i + 1
        tmp_j = j + 1

        if s[i][j] == "#":
            a[tmp_i + 1][tmp_j] += 1
            a[tmp_i - 1][tmp_j] += 1
            a[tmp_i][tmp_j + 1] += 1
            a[tmp_i][tmp_j - 1] += 1
            a[tmp_i + 1][tmp_j + 1] += 1
            a[tmp_i + 1][tmp_j - 1] += 1
            a[tmp_i - 1][tmp_j + 1] += 1
            a[tmp_i - 1][tmp_j - 1] += 1
for i in range(H):
    for j in range(W):
        tmp_i = i + 1
        tmp_j = j + 1
        if s[i][j] == "#":
            a[tmp_i][tmp_j] = "#"
ans = []
for i in range(1,H+1):
    for j in range(1,W+1):
        ans.append(str(a[i][j]))
    print("".join(ans))
    ans = []


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

using P = pair<int,int>;

int main(void){
    int n,m;
    cin>>n>>m;
    vector<P> v(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        v[i] = P(a,b);
    }
    sort(all(v));
    int end = 0;
    int res = 0;
    rep(i,m){
        int a = v[i].first;
        int b = v[i].second;
        if(end <= a){
            res++;
            end = b;
        }else{
            end = min(end,b);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char *argv[])
{
        int n[3];
        int i, j, tmp;

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

        for (i = 0; i < 2; i++) {
                for (j = 0; j < 2 - i; j++) {
                        if (n[j] > n[j+1]) {
                                tmp = n[j+1];
                                n[j+1] = n[j];
                                n[j] = tmp;
                        }
                }
        }

        printf("%d %d %d\n", n[0], n[1], n[2]);

        return 0;
}

Measured memory_bytes: 596
n=int(input())
t,a=map(int,input().split())
hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mn=abs(a-(t-hl[0]*0.006))
temp=[]
for i in range(n):
    mn=min(mn,abs(a-(t-hl[i]*0.006)))
    temp.append(abs(a-(t-hl[i]*0.006)))

print(temp.index(mn)+1)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  
  int cnt=0;
  int K=0,S=0;
  int X=0,Y=0,Z=0;
  scanf("%d %d", &K,&S);
  
  for(; X <= K; X++){
    Y=0;
      for(; Y <= K; Y++){
          if(S-X-Y >= 0 && S-X-Y <=K){
            cnt++;
          }
      }
  }
  
  printf("%d", cnt);
  
 return 0; 
}

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


using namespace std ; 

int main ( ) 
{
	int x , y ; 
	cin >> x >> y ; 
	if (x == y)
	 {
	 	cout << "Draw" ; 
	 	
	}
	else if ((x > y ) && y !=1)
	{	cout << "Alice" ;

	}
	else  if (y>x&& x!=1)
	
	cout << "Bob" ; 
	else if ( y >x && x==1) {
		cout << "Alice" ;
	}
	else 
	cout << "Bob" ; 
		return 0 ; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i,flag=1,n,A[100],temp,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }

  while(flag)
    {
      flag=0;
      for(i=n-1;i>0;i--)
	{
	  if(A[i] < A[i-1])
	    {
	      temp=A[i];
	      A[i]=A[i-1];
	      A[i-1]=temp;
	      count++;
	      flag=1;
	    }
	}
    }
    

  for(i=0;i<n;i++)
    {
      if(i == n-1)
	{
	  printf("%d\n%d\n",A[i],count);
	}
      else
	{
	  printf("%d ",A[i]);
	}
    }

  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision

using namespace std;
using p = pair<int,int>;
int main(){
    cout << fixed << setprecision(10);
    int n; cin >> n;
    vector<p> towns(n);
    double ave;
    for (int i = 0; i < n; i++)
    {
        cin >> towns[i].first >> towns[i].second; 
    }
    vector<vector<double>> dis(n,vector<double>(n,0));
    vector<int> perm(n);
    for (int i = 0; i < n; i++)
    {
        perm[i]=i;
        for (int j = i+1; j < n; j++)
        {
            int dx = abs(towns[i].first - towns[j].first);
            int dy = abs(towns[i].second - towns[j].second);
            dis[i][j] = sqrt(dx*dx + dy*dy);
        }
    }
    
    double sum = 0;
    do{ 
        for (int i = 1; i < n; i++)
        {
            sum += dis[perm[i-1]][perm[i]];
        }
    }while(next_permutation(perm.begin(),perm.end()));

    int div = n;
    for (int j = n-1; j > 0; j--)
    {
        div *= j;
    }
    ave = sum*2/div;
    cout << ave <<endl;
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

char get_wb(int i){
    if(i == 0){
        return '.';
    }else
    {
        return '#';
    }
}

int a[110][110];
int h_white[110];
int w_white[110];


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;

    string tmp_s;
    for(int i = 0; i < H; i++){
        cin >> tmp_s;
        for(int j = 0; j < W; j++){
            if(tmp_s[j] == '.'){
                a[i][j] = 0;
            }else{
                a[i][j] = 1;
            }
        }
    }


    int tmp_sum = 0;
    for(int i = 0; i < H; i++){
        tmp_sum = 0;
        for(int j = 0; j < W; j++){
            tmp_sum += a[i][j];
        }
        if(tmp_sum==0){
            h_white[i] = 1;
        }else{
            h_white[i] = 0;
        }
    }

    for(int j = 0; j < W; j++){
        tmp_sum = 0;
        for(int i = 0; i < H; i++){
            tmp_sum += a[i][j];
        }
        if(tmp_sum==0){
            w_white[j] = 1;
        }else{
            w_white[j] = 0;
        }
    }

    vector<string> ans;
    for(int i = 0; i < H; i++){
        tmp_s = "";
        for(int j = 0; j < W; j++){
            if(w_white[j] == 0){
                tmp_s.push_back(get_wb(a[i][j]));
            }
        }
        if(h_white[i] == 0){
            ans.push_back(tmp_s);
        }
    }

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main()
{
	while(1)
	{
		int r[10],v1,v2,len=0,i;
		double temp,t2=0.0;
		for(i=0;i<10;i++)
		{
			if(scanf("%d,",&r[i])==EOF)
				return 0;
			len+=r[i];
		}
		scanf("%d,%d",&v1,&v2);
		temp=(double)len/(v1+v2)*v1;
		i=0;
		while(i < 10 && temp > 0.0)
			temp-=r[i++];
		printf("%d\n",i);
	}
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int f[25][(1<<20)+10];
int g[25][(1<<20)+10];
int n, m;
char s[(1<<20)+10];
int main () {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for(i = 0; i <= n; i++){
		scanf("%s", s);
		for(j = 0; j < 1<<i; j++){
			if(s[j] == '1') f[i][j] = 1;
		}
	}
	for(i = 1; i <= n; i++){
		for(j = 0; j < 1<<i; j++){
			int p = (j>>(i-1))&1;
			for(k = 0; k < i; k++) if(((j>>i-k-1)&1) != p) break;
			if(k == i) g[i][j] = -1;
			else g[i][j] = k;
		}
	}
	int ansi = 0, ansj;
	for(i = 0; i <= n; i++){
		for(j = 1; i+j <= n; j++){
			for(k = 0; k < 1<<i+j; k++){
				f[i][k>>j] += f[i+j][k];
				int p = g[j][k&((1<<j)-1)];
				if(p != -1) f[i+j-p][(k>>j<<(j-p))|(k&((1<<(j-p))-1))] += f[i+j][k];
			}
		}
		for(j = (1<<i)-1; j >= 0; j--){
			if(f[i][j] >= m) ansi = i, ansj = j;
		}
	}
	for(i = ansi-1; i >= 0; i--) printf("%d", (ansj>>i)&1);
	printf("\n");
	return 0;
}

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

int main()
{
	int H;
	int W;
	int i;
	int j;
	int x;
	
	while(true){
	
		// H,W???????????\???
		cin >> H >> W ;
	
		//??\??????0?????´???????????¢
		if( H==0 && W==0 )break;
	
		//W?????°????????????????????????#?????????H?????????
		for(j=0 ; j < H ; j++){
	
			//W?????°?????????#???????????????????????????
			for(i=0 ; i < W ; i++){
				cout << "#" ;
			}
			cout << "\n";
		}
		x++;
		cout << "\n";
	}
}

Measured memory_bytes: 3020
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();
            string ans;
            if(x == "0")
            {
                ans = "1";
            }
            else
            {
                ans = "0";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25876
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  char ch;
  IN(ch);
  printf("%c\n", ch+1);
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b = map(int, input().split())
    s = input()
    for i in range(a + b + 1):
        if i != a and s[i] == '-':
            print("No")
            return
        elif i == a and s[i] !='-':
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61796
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s;cin>>s;
	ll n = s.size();
	ll k;cin>>k;
	set<string> M;
	For(t,1,6) For(i,0,n) M.insert(s.substr(i,t));

	ll count=0;
	string ans;
	for(string t:M){
		count++;
		ans = t;
		if(count==k) break;
	}
	cout<<ans<<endl;











	
}

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

using namespace std;

#define repeat(n) for(int _______ = (n); _______ > 0; --_______)
#define loop(i, l, r) for(auto i = (l), __r = decltype(i)(r); i <= __r; ++i)
#define iloop(i, l, r) for(auto i = (l), __r = decltype(i)(r); i < __r; ++i)
#define rloop(i, r, l) for(auto i = (r), __l = decltype(i)(l); i >= __l; --i)

using LL = long long;

template<typename Container>
inline
int size(const Container& x)
{ return x.size(); }

#ifdef CAI_WEI_HAN

#include "my_print.h"
#include "LOG.h"

#else

#define LOG(...)

#endif

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	constexpr char endl = '\n';
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
	register auto program_start_time = clock();
	#define cout cerr
#endif
	
	int n;
	cin >> n;
	
	cout << max((LL)n * (n-1) / 2, (LL)n * (n+1) / 2 - 2 * (int)ceil((n+1) / 2.0));
	
#ifdef CAI_WEI_HAN
	cout << "\n\n--------------------------------\n"
		 << "time:   " << double(clock() - program_start_time) / CLOCKS_PER_SEC;
#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
vector<int>adj[100005];
int dist[100005];
vector<bool>vis(100005,false);
void dfs(int v)
{
    dist[v] = 0;
    vis[v] = true;
    for(int u : adj[v])
    {
        if(!vis[u])dfs(u);
        dist[v] = max(dist[v],dist[u]+1);
    }
}
int main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(i);
        ans = max(ans,dist[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8192
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
    print("%d+%d+%d+%d=7"%(a,b,c,d))
elif a+b+c-d==7:
    print("%d+%d+%d-%d=7"%(a,b,c,d))
elif a+b-c+d==7:
    print("%d+%d-%d+%d=7"%(a,b,c,d))
elif a-b+c+d==7:
    print("%d-%d+%d+%d=7"%(a,b,c,d))
elif a-b+c-d==7:
    print("%d-%d+%d-%d=7"%(a,b,c,d))
elif a+b-c-d==7:
    print("%d+%d-%d-%d=7"%(a,b,c,d))
elif a-b-c+d==7:
    print("%d-%d-%d+%d=7"%(a,b,c,d))
elif a-b-c-d==7:
    print("%d-%d-%d-%d=7"%(a,b,c,d))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long x = sc.nextLong(), y = sc.nextLong();
		if (x % y == 0) {
			System.out.println(-1);
		} else {
			System.out.println(x);
		}
	}
}

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

vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
ll sum = 0;

void dfs(int now,vector<int> sw){
        bool ok=true;
        if(now==n+1){
                for(int i=0;i<m;i++){
                        int count = 0;
                        for(int j=0;j<k[i];j++){
                                if(sw[s[j][i]]==1){
                                        count++;
                                }
                        }
                        if(p[i]!=(count%2)){
                                return;
                        }
                }
                
                sum++;
                return;
        }

        dfs(now+1, sw);
        sw[now] = 1;
        dfs(now+1, sw);
}

int main(){
        cin >> n >> m;
        vector<int> swt(n+1,0);

        rep(i,0,m){
                cin >> k[i];
                rep(j,0,k[i]){
                        cin >> s[j][i];
                }
        }
        rep(i,0,m){
                cin >> p[i];

        }
        dfs(1, swt);

        cout << sum << endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 200005;
int a[nax],suff[nax],n;
void solve()
  {
   int ans = 0;
   cin>>n;
   loop(i,0,n)
    cin>>a[i];
   suff[n] = 0;
   loopb(i,n-1,-1)
    suff[i] = (suff[i+1] + a[i]%mod)%mod;
   loop(i,0,n)
    {
      int now = (a[i]%mod * suff[i+1])%mod;
      ans += now;
      ans %= mod;
    }
    cout<<ans;
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 6732
N = int(input())
XY = [tuple(map(int,input().split())) for _ in range(N)]

def f(x,y):
  mx = 0
  for x1,y1 in XY:
    if ((x1-x)**2+(y1-y)**2)**0.5 > mx:
      mx = ((x1-x)**2+(y1-y)**2)**0.5
  return mx

def g(x):
  l = 0.0
  r = 1000.0
  for i in range(80):
    c1 = (l*2+r)/3
    c2 = (l+r*2)/3
    if f(x,c1) > f(x,c2):
      l = c1
    else:
      r = c2
  return f(x,l)

l = 0.0
r = 1000.0
for i in range(80):
  c1 = (l*2+r)/3
  c2 = (l+r*2)/3
  if g(c1) > g(c2):
    l = c1
  else:
    r = c2

print(g(l))

Measured memory_bytes: 43496
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int n,c;
int a[33];
int b[33];
int memo[31][1 << 16 + 1];
int dp(int index,int bit);

int main(){
	while(1){
		cin >> n >> c;
		if(n == 0 && c == 0) break;
		for(int i=0;i<n;i++){
			a[i] = 0;
			for(int j=0;j<16;j++){
				int aa;
				cin >> aa;
				if(aa) a[i] |= 1 << j;
			}
		}
		for(int i=0;i<c;i++){
			b[i] = 0;
			for(int j=0;j<16;j++){
				int bb;
				cin >> bb;
				if(bb) b[i] |= 1 << j;
			}
		}

		memset(memo,0,sizeof(memo));
		cout << dp(0,a[0]) << endl;

	}
}

int dp(int index,int bit){
	if(index == n) return 0;
	if(memo[index][bit]) return memo[index][bit];

	int ans = 0;
	for(int i=0;i<c;i++){
		ans = max(ans,dp(index+1,(bit & ~b[i]) | a[index+1]) + __builtin_popcount(bit & b[i]));
	}
	return memo[index][bit] = ans;
}

Measured memory_bytes: 17044
#解説参照
#構成が無理
#テストどうやってんだろ
n = int(input())
a = list(map(int, input().split( )))

a.sort()
from bisect import bisect_left

j = bisect_left(a,0)
if j==0:
    j+=1
elif j==n:
    j-=1
print(sum(a[j:])-sum(a[:j]))
for i in range(j,n-1):
    print(a[0],a[i])
    a[0]-=a[i]

for i in range(j):
    print(a[-1],a[i])
    a[-1]-=a[i]


Measured memory_bytes: 59356
from itertools import combinations
while True:
    n, p = [int(x) for x in input().split()]
    if n == 0 and p == 0:
        break
    L = [int(x) for x in input().split()]
    m = -1
    for i, j in combinations(L,2):
        if i+j <=p:
            m = max(m,i+j)
    if m > 0:
        print(m)
    else:
        print("NONE")


Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000005;

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    int ans=n/(a+b)*a;
    int r=n%(a+b);
    if(r>a) ans+=a;
    else ans+=r;
    cout<<ans;
}


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

int main(){
  std::map<int,int>a;
  int n,b;
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>b;
    if(a[b]==1)a.erase(b) ;
    else a[b]++;
  }
  std::cout<<a.size()<<std::endl;
  return 0;
}

Measured memory_bytes: 8052
<?php
    $array = explode(" ", trim(fgets(STDIN)));

    $a = (int)$array[0];
    $b = (int)$array[1];
    $price = 0;

    if ($a >= 13){
        $price = $b;
        echo "{$price}\n";
    }elseif($a >= 6 && $a <= 12){
        $price = $b/2;
        echo "{$price}\n";
    }else{
        $price = 0;
        echo "{$price}\n";
    }
?>

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    double t,x;
    cin >> t >> x;
    
    cout << t/x << endl;
 
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int X, cnt[31], ans;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		X = X ^ a;
		int res = 0;
		res = __builtin_ctz(a);
		cnt[res]++;
	}
	
	for(int i = 30; i >= 0; i--) {
		if((X >> (i)) & 1) {
			if(cnt[i] > 0) {
				X = X ^ ((1LL << (i + 1) )- 1);
				ans++;
			}
			else 
				return cout << -1, 0;
		}
	}
	return cout << ans, 0;
}

Measured memory_bytes: 256
def floyd(n)
  n.times do |k|
    n.times do |i|
      if $d[i][k] == Float::INFINITY
        next
      end
      n.times do |j|
        if $d[k][j] == Float::INFINITY
          next
        end
        $d[i][j] = [$d[i][j], $d[i][k] + $d[k][j]].min
      end
    end
  end
end

n, e = gets.split.map(&:to_i)
$d = Array.new(n) { Array.new(n) }
n.times do |i|
  n.times do |j|
    $d[i][j] = i == j ? 0 : Float::INFINITY
  end
end

e.times do
  s, t, d = gets.split.map(&:to_i)
  $d[s][t] = d
end

floyd(n)

n.times do |i|
  if $d[i][i].negative?
    puts "NEGATIVE CYCLE"
    exit
  end
end

n.times do |i|
  n.times do |j|
    unless j.zero?
      print ' '
    end
    if $d[i][j] == Float::INFINITY
      print 'INF'
    else
      print $d[i][j]
    end
  end
  puts
end


Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  int ans = 1;
  rep(i, 0, N) {
    if (ans * 2 < ans + K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  for (int itr = 0; itr < k; ++itr) {
    vector<int> b(n, 0);
    for (int i = 0; i < n; ++i) {
      int l = max(0, i - a[i]), r = min(n - 1, i + a[i]);
      b[l]++;
      if (r < n - 1) b[r + 1]--;
    }
    for (int i = 1; i < n; ++i) b[i] += b[i - 1];
    if (a == b) break;
    swap(a, b);
  }
  for (int &x : a) cout << x << ' ';
  cout << '\n';
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int cnt1 = (c + b - 1) / b;
    int cnt2 = (a + d - 1) / d;

    if(cnt1 <= cnt2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    //cout << cnt1 << cnt2 << endl;

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  
  ll x=n+1;
  ll cnt=0;
  ll a=0;
  while(x>0){
    cnt++;
    if(x/10==0)
      a=x;
    x/=10;
  }
  cnt--;
  
  ll ans;
  ans= 9*cnt+a-1;
  
  cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N, M;

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    ll nsum = 0, nans = 0;
    for (int i = 0; i < N; i++)
    {
        ll x;
        cin >> x;
        nans += (x * i - nsum);
        nans %= MOD;
        nsum = (nsum + x) % MOD;
    }
    ll msum = 0, mans = 0;
    for (int i = 0; i < M; i++)
    {
        ll x;
        cin >> x;
        mans += (x * i - msum);
        mans %= MOD;
        msum = (msum + x) % MOD;
    }

    cout << (nans * mans) % MOD << "\n";
}

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

const int INF=1e9+5;
const int N=3000+5;
const int mod=1e9+7;

void add_self(int& a,int b){
	a+=b;
	if(a>=mod) a-=mod;
}

void sub_self(int &a,int b){
	a-=b;
	if(a<0) a+=mod;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> dp(k+1); // dp[i] number of ways such that using i candies so far
	dp[0]=1;
	for(int child =0;child<n;++child){
		int x;
		cin>>x;
		vector<int> fake_add(k+1);
		for(int used=k;used>=0;--used){
			int add=dp[used];
			int l=used+1;
			int r=used+min(x,k-used);
			if(l<=r){
				add_self(fake_add[l],add);
				if(r+1<=k) sub_self(fake_add[r+1],add);
			}	
		}
		int cur_add=0;
		for(int i=0;i<=k;++i){
			add_self(cur_add,fake_add[i]);
			add_self(dp[i],cur_add);
		}
	}	
	cout<<dp[k];
	return 0;
}
		


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

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

int main() {
    int A, N;
    std::cin >> N >> A;
    if(N % 500 <= A) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  if(N % 2 == 0)cout << (N-1)/2 << endl;
  else cout << N/2 << endl;
}

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

int move_cnt[200005];

int main(void){
    string S;
    cin >> S;
    S.push_back('A');
    
    int N = S.length();
    int BC_cnt = 0;
    long long ans = 0;
    for (int i = N-1; 0 <= i; i--) {
        if (0 < i && S[i-1] == 'B' && S[i] == 'C') {
            BC_cnt++;
            i--;
        } else if (S[i] == 'A') {
            move_cnt[i] = BC_cnt + move_cnt[i + 2*BC_cnt + 1];
            BC_cnt = 0;
        } else {
            BC_cnt = 0;
        }
        ans += move_cnt[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1412
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = x = 1
  try:
    for i in range(1, n):
      p = x; x = c.get(i)
      r = r * pow(p, x, M) % M
      n -= x
  except:
    pass
print((r, 0)[n > 1])

Measured memory_bytes: 22636
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	cnts := f(n)
	for i := 1; i <= n; i++ {
		fmt.Println(cnts[i])
	}
}

func f(n int) map[int]int {
	cnts := make(map[int]int)
	for x := 1; x*x <= n; x++ {
		for y := 1; y*y <= n; y++ {
			for z := 1; z*z <= n; z++ {
				a := x*x + y*y + z*z + x*y + y*z + z*x
				cnts[a]++
			}
		}
	}
	return cnts
}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF INT_MAX
#define fi first
#define se second
using namespace std;

int main() 
{
	string s; cin>>s;
	
	int res = 1;
	if (s=="SUN") res = 7;
	else if (s=="MON") res = 6;
	else if (s=="TUE") res = 5;
	else if (s=="WED") res = 4;
	else if (s=="THU") res = 3;
	else if (s=="FRI") res = 2;
	else if (s=="SAT") res = 1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256