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

typedef pair<int, int> P;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  vector<P> a;
  int temp1, temp2;

  for(int i = 0;i < 6;++i){
    cin >> temp1 >> temp2;
    if(temp1 > temp2){
      a.push_back(P(temp1, temp2));
    }else{
      a.push_back(P(temp2, temp1));
    }
  }

  sort(a.begin(), a.end());

  if(a[0] == a[1] && a[2] == a[3] && a[4] == a[5]){
    bool flag = false;
    if(a[0].first == a[2].first && a[0].second == a[4].second && a[2].second == a[4].first) flag = true;
    if(a[0].second == a[2].first && a[0].first == a[4].second && a[2].second == a[4].first) flag = true;
    if(a[0].first == a[2].second && a[0].second == a[4].second && a[2].first == a[4].first) flag = true;
    if(a[0].second == a[2].second && a[0].first == a[4].second && a[2].first == a[4].first) flag = true;
    if(a[0].first == a[2].first && a[0].second == a[4].first && a[2].second == a[4].second) flag = true;
    if(a[0].second == a[2].first && a[0].first == a[4].first && a[2].second == a[4].second) flag = true;
    if(a[0].first == a[2].second && a[0].second == a[4].first && a[2].first == a[4].second) flag = true;
    if(a[0].second == a[2].second && a[0].first == a[4].first && a[2].first == a[4].second) flag = true;

    if(flag){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }

  }else{
    cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string s1 = "maerd";
    string s2 = "remaerd";
    string s3 = "esare";
    string s4 = "resare";
    reverse(s.begin(), s.end());
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'm' && i + 4 < s.length())
        {
            if (s[i + 1] == 'a' && s[i + 2] == 'e' && s[i + 3] == 'r' && s[i + 4] == 'd')
            {
                i += 4;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        else if (s[i] == 'e' && i + 4 < s.length())
        {
            if (s[i + 1] == 's' && s[i + 2] == 'a' && s[i + 3] == 'r' && s[i + 4] == 'e')
            {
                i += 4;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        else if (s[i] == 'r' && i + 5 < s.length() && s[i + 1] == 'e')
        {
            if (s[i + 2] == 'm' && i + 6 < s.length())
            {
                if (s[i + 3] == 'a' && s[i + 4] == 'e' && s[i + 5] == 'r' && s[i + 6] == 'd')
                {
                    i += 6;
                }
                else
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
            else if (s[i + 2] == 's')
            {
                if (s[i + 3] == 'a' && s[i + 4] == 'r' && s[i + 5] == 'e')
                {
                    i += 5;
                }
                else
                {
                    cout << "NO" << endl;
                    return 0;
                }
            } else {
                cout << "NO" << endl;
                return 0;
            }
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine();
            long ans = 0;
            long w = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'W')
                {
                    ans += i - w;
                    w++;
                }
            }
            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
    string S;
    cin >> S;
    for(int i=0; i < S.size(); i++){
        if(i%2==0){
            if(S[i] == 'L'){
                cout << "No";
                return 0;
           }
        }else{
            if(S[i] == 'R'){
                cout << "No";
                return 0;
           }
        }
    }
    cout << "Yes";
}

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

#define N 100
 
int main(void) {
 
  int n,p[N],m[N][N];
  int i,j,k,l,q;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d",&p[i],&j);
 
  p[n] = j;
  for(i=1;i<=n;i++)
    m[i][i] = 0;
   
  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++) {
      j = i + l - 1;
      m[i][j] = 100000;
      for(k=i;k<=j-1;k++) {
    q= m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
     
    if(m[i][j] > q)
      m[i][j]=q;
      }
    }
  }
  printf("%d\n",m[1][n]);
 
 return 0;
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();

        for (int i = 1; i <= n; i++) {
            out.println(f(i));
        }
    }

    private static int f(int n) {
        int ret = 0;
        int max = (int) Math.ceil(Math.sqrt(n));
        for (int x = 1; x <= max; x++) {
            for (int y = 1; y <= max; y++) {
                // integer root of z^2 + bz + c = 0
                int b = x + y;
                int c = x * x + y * y + x * y - n;
                if (b * b - 4 * c < 0) continue;
                double d = Math.sqrt(b * b - 4 * c);
                int r1 = (int) Math.round((-b + d) / 2);
                int r2 = (int) Math.round((-b - d) / 2);

                if (r1 >= 1 && ok(x, y, r1, n)) {
                    ret++;
                }
                if (r2 >= 1 && ok(x, y, r2, n)) {
                    ret++;
                }
            }
        }
        return ret;
    }

    private static boolean ok(int x, int y, int z, int n) {
        return x * x + y * y + z * z + x * y + y * z + z * x == n;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 27148
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int n;
  char str[10];
  scanf("%d",&n);
      scanf("%s", str);
if(n>=3200){
  printf("%s",str);
}else{
  printf("red");
}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, res = 0;

ll power(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1) res=res*x;
		x=x*x;
		k>>=1;
	}
	return res;
}

void dp(ll nb, ll ind, ll test)
{
    // cout << nb << endl;
    if (nb<=n)
    {
        if (test)
        {
            res++;
            dp(power(10,ind)*3+nb, ind+1, 1);
            dp(power(10,ind)*5+nb, ind+1, 1);
            dp(power(10,ind)*7+nb, ind+1, 1);
        }
        else 
        {
            ll x = nb;
            ll test3=0, test5=0, test7=0;
            while(x!=0)
            {
                ll y = x%10;
                x = x/10;
                if (y==3) test3=1;
                if (y==5) test5=1;
                if (y==7) test7=1;
            }
            if (test3 && test5 && test7)
            {
                res++;
                dp(power(10,ind)*3+nb, ind+1, 1);
                dp(power(10,ind)*5+nb, ind+1, 1);
                dp(power(10,ind)*7+nb, ind+1, 1);
            }
            else
            {
                dp(power(10,ind)*3+nb, ind+1, 0);
                dp(power(10,ind)*5+nb, ind+1, 0);
                dp(power(10,ind)*7+nb, ind+1, 0);
            }
        }
    }
}

int main() 
{
    cin >> n;
    dp(3,1,0);
    dp(5,1,0);
    dp(7,1,0);
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int inf = 0x3f3f3f3f;
ll P=1e9+7;
 void solve()
 {
     ll i,j,k,l,m,n,o,p,q,r,a[300001],prefix[300001];
    
     ll s=0;
     cin>>n;
     prefix[0]=0;
     for(i=1;i<=n;i++)
     {
         cin>>a[i];
         k=(a[i]*prefix[i-1])%P;
         s=(s+k)%P;
         prefix[i]=(prefix[i-1]+a[i])%P;
     }
     cout<<s<<endl;
 }
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     ll t=1;
    // cin>>t;
     while(t--)
     {
         solve();
     }
    return 0;
}


Measured memory_bytes: 6792
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
  vector<int> pana(32);
  pana={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K=0;
  cin>>K;
  cout<<pana.at(K-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MM 100000
using namespace std;
int harm[MM+11];
int main()
{
	long long h,total=0;
	int n;
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	    cin>>harm[i];
	for(int i=1;i<=n;i++)
	{
		total+=harm[i];
		if(total>=h)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
vector<long long> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  assert(!(n<k));
  assert(!(n<0 || k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int main(){
  int N,K,ans=0;
  cin>>N>>K;
  init_nCk(N);
  vector<long long> vec(min(N-1,K)+1);
  for(int i=0;i<=min(N-1,K);i++){
    vec.at(i)=nCk(N,i);
  }
  init_nCk(N-1);
  for(int i=0;i<=min(N-1,K);i++){
    vec.at(i)*=nCk(N-1,i);
    vec.at(i)%=MOD;
  }
  for(int i=0;i<=min(N-1,K);i++){
    ans+=vec.at(i);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int main(void) {
  int i,j;
  int l;
  while(1){
    cin>>l;
    if(l==0)break;
    vi m(12);
    vi n(12);
    rep(i,12)
      cin>>m[i]>>n[i];
    rep(i,12){
      l-=m[i]-n[i];
      if(l<=0)break;
    }
    if(i<12)
      cout<<i+1<<endl;
    else
      cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 3072
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        this.Items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).OrderBy(a => a).ToArray();
        Target = Items.Last() / 2m;
        int idx = GetAns(0, itemCount - 2);

        Console.WriteLine(Items.Last() + " " + Items[idx]);
    }

    private long[] Items;
    private decimal Target;
    private int GetAns(int min, int max) {
        if(max-min<=2) {
            int mid = (max + min) / 2;
            decimal diff1 = GetDiff(min);
            decimal diff2 = GetDiff(mid);
            decimal diff3 = GetDiff(max);

            decimal temp = Math.Min(diff1, Math.Min(diff2, diff3));
            if(temp == diff1) {
                return min;
            } else if(temp == diff2) {
                return mid;
            } else {
                return max;
            }
        } else {
            int mid1 = min + (max - min) / 3;
            int mid2 = min + (max - min) * 2 / 3;
            decimal diff1 = GetDiff(min);
            decimal diff2 = GetDiff(mid1);
            decimal diff3 = GetDiff(mid2);
            decimal diff4 = GetDiff(max);

            decimal temp = Math.Min(Math.Min(diff1, diff2), Math.Min(diff3, diff4));
            if(temp == diff1) {
                return GetAns(min, mid1);
            } else if(temp == diff2) {
                return GetAns(min, mid2);
            } else if(temp == diff3) {
                return GetAns(mid1, max);
            } else {
                return GetAns(mid2, max);
            }
        }
    }

    private decimal GetDiff(int idx) {
        return Math.Abs(Items[idx] - Target);
    }

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


5
6 9 4 2 11


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 26208
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin >> s;
    if(s[0]==s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint A, B;
	cin >> A >> B;
	cout << A * B / __gcd(A, B) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int A[3][3];
  rep(i, 3)
  {rep(j, 3)
  {
  cin >> A[i][j];
  }
  }
  int N;
  cin >>N;
  
    int a;
  rep(b, N){
    cin >>a
    rep(i, 3)
  {rep(j, 3)
  {
    if(a==A[i][j]) A[i][j]=-1;
  }
  }
  }
  
  if(A[0][0]==-1&&A[0][1]==-1){
  if(A[0][2]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[1][0]==-1&&A[1][1]==-1){
  if(A[1][2]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[2][0]==-1&&A[2][1]==-1){
  if(A[2][2]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[0][0]==-1&&A[1][0]==-1){
  if(A[2][0]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[0][1]==-1&&A[1][1]==-1){
  if(A[2][1]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[0][2]==-1&&A[1][2]==-1){
  if(A[2][2]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[0][0]==-1&&A[1][1]==-1){
  if(A[2][2]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }  
  if(A[0][2]==-1&&A[1][1]==-1){
  if(A[2][0]==-1){
  cout << "Yes" << endl;
    return 0;
  }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}

ll gcd(ll a, ll b) {
  if(a%b==0) return b;
  else return gcd(b, a%b);
}

int main(void) {
  ll a, b;
  cin >> a >> b;
  
  factrization(gcd(a, b));
  
  pt(prime.size()+1);
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 0;
    rep(i, n - k) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005  //check the limits, man
ll dp[N],sum[N];
ll pro(ll a,ll b)
{
    return (a*b)%M;
}
int main()
{
    int i,n;
    llin(n);
    dp[0]=1,dp[1]=n,dp[2]=pro(n,n);
    sum[0]=1,sum[1]=n+1,sum[2]=(sum[1]+dp[2])%M;
    lp(i,3,n+1)
    {
        dp[i]=dp[i-1]+pro(n-1,n-1)+sum[i-3]+n-i+1;
        dp[i]%=M;
        sum[i]=(sum[i-1]+dp[i])%M;
    }
    llout(dp[n]);
}








Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main() {

	int a, b;
	cin >> a >> b;

	if (a > b) swap(a, b);

	rep(i, b) cout << a;
	cout << endl;

}

Measured memory_bytes: 256
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw)])
while dq:
    h, w = dq.popleft()

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] == -1 or dst[h][w] < dst[nh][nw]:
            dst[nh][nw] = dst[h][w]
            dq.appendleft((nh, nw))

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        if dst[nh][nw] == -1:
            dst[nh][nw] = dst[h][w] + 1
        elif dst[h][w] + 1 < dst[nh][nw]:
            dst[nh][nw] = min(dst[nh][nw], dst[h][w] + 1)
        else: continue
        dq.append((nh, nw))

print(dst[eh][ew])


Measured memory_bytes: 88568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, r[100];
    vector<P> p;
    cin >> n;
    p.resize(n);
    REP(i,n){
        p[i].first = 0;
        p[i].second = i;
    }
    REP(i,n*(n-1)/2){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        if(c > d) p[a].first += 3;
        if(c < d) p[b].first += 3;
        if(c == d){
            p[a].first += 1;
            p[b].first += 1;
        }
    }
    SORTR(p);
    REP(i,n){
        if(i>0 && p[i-1].first==p[i].first){
            r[p[i].second] = r[p[i-1].second];
        }
        else r[p[i].second] = i+1;
    }
    REP(i,n){
        cout << r[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
# coding: utf-8

N = int(input())
B = list(map(int, input().split()))

A_sum = 0;
A_sum += B[0]
for i in range(N-2):
    if(B[i]>=B[i+1]):
        A_sum+=B[i+1]
    else:
        A_sum+=min(B[i],B[i+1])
A_sum+=B[N-2]
print(A_sum)

Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

//data types

type set map[int]struct{}

type pair struct {
	first  int
	second int
}

func main() {
	sc.Split(bufio.ScanWords)
	s, _ := next(), next()
	a, b := nextInt(), nextInt()

	if s == next() {
		a--
	} else {
		b--
	}

	fmt.Print(a, b)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	a=min(a,b);
	b=max(a,b);
	long long int d=b-a;
	if(d%2==0)
	cout<<d/2<<endl;
	else{
		long long int ans1,ans2;
		ans1=a+(b-a-1)/2;
		ans2=n-b+1+(b-a-1)/2;
		cout<<min(ans1,ans2)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  ll ans = 0;
  int cnt1 = 0, cnt0 = 0, prec = 0, pos = 0;
  for (int i = 0; i < s.length(); ++i) {
    pos ^= 1;
    if (s[i] == '0') {
      ++cnt0;
      ans += prec;
    } else {
      if (i > 0 && s[i - 1] == '0')
        pos = 1;
      if (pos == 1) {
        ++prec;
      }
      ++cnt1;
      ans += (i + 2) / 2;
    }
  }
  cout << ans << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
using namespace std;
long long a[200010],b[200010],s1[200010],s2[200010],s;
int n,m,ans;
int main()
{
    int i,l,r,m0;
    cin>>n>>m>>s;
    for(i=1;i<=n;i++) 
    {
        cin>>a[i];
        s1[i]=s1[i-1]+a[i];
    }
    for(i=1;i<=m;i++) 
    {
        cin>>b[i];
        s2[i]=s2[i-1]+b[i];
    }
    for(i=0;i<=n;i++)
    {
        l=0;
        r=m;
        if(s1[i]>s) break;
        while(l<r-1)
        {
            m0=(l+r)/2;
            if(s2[m0]+s1[i]>s) r=m0;
            else l=m0;
        }
        if(s2[r]+s1[i]<=s) ans=max(ans,r+i);
        else ans=max(ans,l+i);
    }
    cout<<ans;
    cin>>i;
}


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

int main(){
  string s;
  int64_t n;
  cin >> s >> n;
  n--;
  int z=0;
  while(z<s.size()&&s.at(z)=='1')
    z++;
  int ans=0;
  if(z>n)
    ans=1;
  else
    ans=s.at(z)-48;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <map>
#include <algorithm>
#include <numeric>

#define M 100000

using namespace std;

int main() {
    int n, a, ans = 0;
    scanf("%d", &n);
    map<int, int> d;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        ++d[a];
    }
    for (int i = 0; i < M - 2; ++i) ans = max(ans, d[i] + d[i + 1] + d[i + 2]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4992
N, X = map(int, input().split())
def f(n):
    return abs(X-int(n))
x = list(map(f, input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
if N > 1:
    res = gcd(x[0], x[1])
    for i in range(2, N):
        res = gcd(x[i], res)
    print(res)
else:
    print(x[0])


Measured memory_bytes: 14212
#include<bits/stdc++.h>
#define L long long
#define M 100005
#define N 2154
using namespace std;

L pri[M]={0},use=0;
bool isp(L x){
	for(L j=2;j*j<=x;j++)
	if(x%j==0) return 0;
	return 1;
}
void init(){
	for(L i=2;i<=N;i++)
	if(isp(i)) pri[++use]=i;
}

L f(L x){
	for(L i=1;i<=use;i++){
		L iii=pri[i]*pri[i]*pri[i];
		while(x%iii==0) x/=iii;
	}
	return x;
}
L cnt=0,mi[M]={0},p[M]={0};

L g(L x){
	cnt=0;
	for(L i=1;i<=use;i++){
		while(x%pri[i]==0){
			if(p[cnt]==pri[i]) mi[cnt]++;
			else p[++cnt]=pri[i],mi[cnt]=1;
			x/=pri[i];
		}
	}
	L hh=sqrt(x);
	if(hh*hh==x){
		mi[++cnt]=2; p[cnt]=hh;
	}else mi[++cnt]=1,p[cnt]=x;
	L res=1;
	for(L i=1;i<=cnt;i++){
		if(mi[i]==1) res*=p[i]*p[i];
		if(mi[i]==2) res*=p[i];
	}
	return res;
}

map<L,L> mp;
int main(){
	init();
	L n; scanf("%lld",&n);
	for(L i=1;i<=n;i++){
		L x; scanf("%lld",&x);
		x=f(x);
		mp[x]++;
	}
	L ans=0;
	for(map<L,L>::iterator it=mp.begin(); it!=mp.end();it++){
		L now=it->first,nowp=g(now);
		if(now==1) {ans++; continue;}
		if(mp[now]>mp[nowp]) ans+=mp[now];
		else ans+=mp[nowp];
		mp[now ]=mp[nowp]=0;
	}
	cout<<ans<<endl;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'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'};

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

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    vector<int> lis;
    int count = 0;
    REP(i, 0, s.size()){
        if(s[i] == 'T'){
            lis.pb(count);
            count = 0;
            lis.pb(-1);
        }else{
            count++;
        }
    }
    if(count > 0){
        lis.pb(count);
    }
    /*REP(i, 0, lis.size()){
        cout << lis[i];
    }
    cout << endl;*/
    vector<set<int>> xdp(lis.size()+1, set<int>()), ydp(lis.size() + 1, set<int>());
    xdp[0].insert(lis[0]);
    if(lis.size() < 3){
        if(y == 0 && x == lis[0]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }
    ydp[2].insert(lis[2]);
    ydp[2].insert(-1 * lis[2]);
    int xkey = 0, ykey= 2;
    REP(i, 4, lis.size()){
        if(i % 4 == 0){
            //cout << lis[i] << endl;
            for(auto x:xdp[i-4]){
                xdp[i].insert(x + lis[i]);
                xdp[i].insert(x - lis[i]);
            }
           xkey = i;    
        }else if(i % 2 == 0){
            //cout << lis[i] << endl;
            for(auto x:ydp[i-4]){
                ydp[i].insert(x + lis[i]);
                ydp[i].insert(x - lis[i]);
            }   
            ykey = i;
        }
    }
    //cout << xkey << ykey << endl;
    if(xdp[xkey].find(x) != xdp[xkey].end() && ydp[ykey].find(y) != ydp[ykey].end()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 232576
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	ll x,ans;
	cin>>x;
	ans=1000*(x/500)+5*((x%500)/5);
	cout<<ans;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		
		double ans = 0;
		for(int i=0;i<n;i++) {
			a[i] = s.nextInt();
			ans+=(1.0/a[i]);
		}
		
		System.out.format("%.10f",1.0/ans);
		
		
		
		
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
int main(){

  int x,y,s;
  int max;
  int price1,price2;

  while(1){
    
    cin >>x>>y>>s;

    if(x==0 && y==0 && s==0)break;

    max=0;

    for(int i=1 ; i < s ; i++){
      for(int j=1 ; j < s ; j++){
	price1=i+i*x/100;
	price2=j+j*x/100;
	if(price1+price2 == s){
	  price1=i+i*y/100;
	  price2=j+j*y/100;
	  if(price1+price2 > max)max=price1+price2;
	}
      }
    }
    
    cout <<max<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N, D;
    cin>>N>>D;
    vector<int> X(N), Y(N);
    rep(i,N){
        cin >> X.at(i)>>Y.at(i);
    }
    int count=0;
    rep(i,N){
        double d;
        d=sqrt(pow(X.at(i),2)+pow(Y.at(i),2));
        if(d<=D){
            count++;
        }
    }

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


Measured memory_bytes: 4904
N=int(input())
binaly=[int(s) for s in input().split()]

boxes=[0 for _ in range(N)]
ans=set()

for i in range(N-1,-1,-1):
  if sum(boxes[i::i+1])%2!=binaly[i]:
    boxes[i]=1
    ans.add(i+1)
print(len(ans))
print(*ans)

Measured memory_bytes: 21320
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

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

    string s;
    cin >> s;

    int res = 0;
    for (int i = 0; i < 3; i++) {
        res += s[i] == '1';
    }

    out(res);

    int ttttttt;
    cin >> ttttttt;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

#define BV_SIZE 64ULL // 64bit
#define MAX_BV_NUM 100 // m <= 100*64 = 6400

unsigned long long Peq[MAX_BV_NUM][0x100];
int levenshteinDistance(string a,string b) {
  int m=a.size(),n=b.size();
  int num_of_bv = (m + BV_SIZE -1) / BV_SIZE;

  for (int i = 0; i < m; i++) {
    Peq[i / BV_SIZE][a[i]] |= 1ULL << ((unsigned long long)i % BV_SIZE);
  }

  int score = m;
  unsigned long long Pv[MAX_BV_NUM], Mv[MAX_BV_NUM], Ph[MAX_BV_NUM], Mh[MAX_BV_NUM], Xv[MAX_BV_NUM], Xh[MAX_BV_NUM], Eq[MAX_BV_NUM], Xt[MAX_BV_NUM], Xa[MAX_BV_NUM];
  unsigned long long top = 1ULL << (((unsigned long long)m - 1ULL) % BV_SIZE);

  for(int i = 0; i < num_of_bv; i++) {
    Pv[i] = ~0ULL; Mv[i] = 0ULL;
  }

  for (int j = 0; j < n; j++) {
    for(int i = 0; i < num_of_bv; i++){
      Eq[i] = Peq[i][b[j]];
      Xv[i] = Eq[i] | Mv[i];
      Xt[i] = Eq[i] & Pv[i];
    }

    unsigned long long carry = 0ULL;

    for(int i = 0; i < num_of_bv; i++){
      Xa[i] = Xt[i] + Pv[i] + carry;

      unsigned long long cXt = Xt[i] + carry;
      carry = (((Xt[i] & carry) | ((Xt[i] | carry) & ( ~ (Xt[i] + carry) ))) >> 63ULL) | (((cXt & Pv[i]) | ((cXt | Pv[i]) & ( ~ (cXt + Pv[i]) ))) >> 63ULL);
    }

    for(int i = 0; i < num_of_bv; i++){
      Xh[i] = (Xa[i] ^ Pv[i]) | Eq[i];

      Ph[i] = Mv[i] | ( ~ (Xh[i] | Pv[i]) );
      Mh[i] = Pv[i] & Xh[i];
    }

    if((Ph[num_of_bv - 1] & top) != 0ULL)score++;
    else if((Mh[num_of_bv - 1] & top) != 0ULL)score--;    

    unsigned long long Ph_carry = 1ULL;
    unsigned long long Mh_carry = 0ULL;

    for(int i = 0; i < num_of_bv; i++){
      unsigned long long nxt_Ph_carry = (Ph[i] >> 63ULL) & 1ULL;
      Ph[i] = (Ph[i] << 1ULL) | Ph_carry;
      Ph_carry = nxt_Ph_carry;

      unsigned long long nxt_Mh_carry = (Mh[i] >> 63ULL) & 1ULL;
      Pv[i] = ((Mh[i] << 1ULL) | Mh_carry ) | ( ~ (Xv[i] | Ph[i]) );
      Mh_carry = nxt_Mh_carry;

      Mv[i] = Ph[i] & Xv[i];
    }

  }
  return score;
}

int main(){
	string a,b;
  cin>>a>>b;
  cout<<levenshteinDistance(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 3240
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int x, i=0;
    
    while (1) {
        scanf("%d", &x);
        
        if (x == 0) {
            break;
        }
        
        printf("Case %d: %d\n", i+1, x);
        
        i++;
    }
    
    return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N;
  
  if(N==1){
    cout << "Hello World" << endl;
  }else if(N==2){
    cin >> A >> B;
    cout << A+B << endl;
  }
}

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

int main(void){
    int n; cin >> n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2; i<=n; i++) F[i]=F[i-1]+F[i-2];

    cout << F[n] << endl;
}


Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template <typename T>
class stack {
 private:
  vector<T> _vec;

 public:
  stack(){};

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() { return _vec.size(); }

  T top() { return _vec[this->size() - 1]; }
  bool empty() { return _vec.empty(); }
};

bool isOk(string s) {
  if (s.size() % 2 == 1){ 
    return false;
  }
  string pre = s.substr(0, s.size() / 2);
  string suf = s.substr(s.size() / 2, s.size() / 2);
  return pre == suf;
}
int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<char>> pixel(H, vector<char>(W));

  for (ll i = 0; i < H; i++)
  {
    string s;
    cin >> s;
    for (ll j = 0; j < W; j++)
    {
      pixel[i][j] = s[j];
    }
  }

  for (ll i = -1; i < H + 1; i++)
  {
    for (ll j = -1; j < W + 1; j++)
    {
      if (i == -1 || i == H || j == -1 || j == W) {
        cout << "#";
        continue;
      }
      cout << pixel[i][j];
    }
    cout << endl;
  }
    
}

Measured memory_bytes: 3612
import java.util.Scanner;


class Main{
  public static void main(String[] args){

    double debt = 100000;
    double mo = 0.05;
    int turm = new Scanner(System.in).nextInt();
    while(turm>0){
      debt = debt*1.05;
      debt = Math.ceil(debt/1000)*1000;
      turm--;
    }
    System.out.println((int)debt);

  }
}

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

using namespace std;

const long long MOD=1000000007;

vector<long long> fac;
vector<long long> ifac;

template<typename T>
T modpow(T a,T n,T mod=MOD){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

template <typename T>
T comb(T a, T b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    long long tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

int main(){
    fac.resize(3000);
    ifac.resize(3000);
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i<3000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD;
        ifac[i+1] = ifac[i]*modpow(i+1, MOD-2) % MOD;
    }
    int n,k;
    cin>>n>>k;
    long long b=k,r=n-k;
    for (long long i = 1; i <= k; ++i) {
        long long t=b-i;
        long long ans=comb(r+1,i);
        ans=ans*comb(t+i-1,t);
        ans=ans%MOD;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, n) = readLine()!!.split(" ").map{ it.toLong() }

    val x = if(b > n) n else b - 1
    val value = Math.floor(a * x.toDouble() / b) - a * Math.floor(x.toDouble() / b)
    println(value.toInt())
}

Measured memory_bytes: 36344
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stack>
#include <utility>
using namespace std;

long long gcd(long long a, long long b){
	long long c;
	while(b){
		c = a;
		a = b;
		b = c % b;
	}
	return a;
}

char s[100001], t[100001];

int main()
{
	long long N, M; scanf("%lld %lld %s %s", &N, &M, s, t);
	long long g = gcd(N, M);
	long long L = (N * M) / g;
	long long ni = 0, mi = 0, nd = L / N, md = L / M;
	while(ni < L && mi < L){
		if(ni < mi) ni += nd;
		else if(mi < ni) mi += md;
		else{
			if(s[ni / nd] != t[mi / md]) return !printf("-1\n");
			ni += nd; mi += md;
		}
	}
	printf("%lld\n", L);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

template<typename T>
void chmax(T& a,const T& b)
{
	a=max(a,b);
}

int main()
{
	for(int c,d,w,x;scanf("%d%d%d%d",&c,&d,&w,&x),c|d|w|x;){
		static int e[30][15],f[30][15];
		rep(i,c) rep(j,d) scanf("%d",&e[j][i]);
		rep(i,c) rep(j,d) scanf("%d",&f[j][i]);
		
		static int dp[31][6][1000]; // [日][2回以上ライブを行った回数][疲労]
		memset(dp,-1,sizeof dp);
		
		dp[0][0][0]=0;
		rep(i,d) rep(j,x+1) rep(k,w+1){
			if(dp[i][j][k]==-1) continue;
			rep(l,c){
				chmax(dp[i+1][j][k],dp[i][j][k]);
				chmax(dp[i+1][j][k+f[i][l]],dp[i][j][k]+e[i][l]);
			}
			if(j==x) continue;
			rep(l,c){
				if(e[i][l]==0) continue;
				int esum=e[i][l],fsum=f[i][l];
				repi(r,l+1,c){
					if(e[i][r]==0) break;
					esum+=e[i][r];
					fsum+=f[i][r];
					chmax(dp[i+1][j+1][k+fsum],dp[i][j][k]+esum);
				}
			}
		}
		
		int res=0;
		rep(i,x+1) rep(j,w+1)
			chmax(res,dp[d][i][j]);
		printf("%d\n",res);
	}
	
	return 0;
}

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

int n;

int main() {
	cin>>n;
	if(n == 3) {
		cout<<2<<" "<<5<<" "<<63<<endl;
		return 0;
	}
	for(int i = 2; i < n; i += 2)
		if(n - i <= 15000 && (n - i)%3 != 1) {
			for(int j = 1; j <= i; j++)
				cout<<(j - 1)*6 + 3<<" ";
			for(int j = 1; j <= n - i; j++)
				cout<<2*j<<" ";
			return 0;
		}
}

Measured memory_bytes: 384
N = int(input())
card_num = list(map(int, input().split()) )
card_num.sort(reverse=True)

alice = 0
bob = 0

for i in range(0,N):
  if i %2 == 0:
    alice += card_num[i]
  else:
    bob   += card_num[i] 
ans = int(alice - bob)

print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long

using namespace std;

signed main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int sum[N];
  vector<int> v;
  int tmp_sum=0;
  char before_char='1';
  char first_char;
  rep(i, N){
    if(i==0 && S[i]=='0') v.push_back(0);
    if(tmp_sum==0){
      before_char = S[i];
      tmp_sum++;
    }else{
      if(before_char==S[i]){
        tmp_sum++;
      }else{
        v.push_back(tmp_sum);
        tmp_sum = 1;
        before_char=S[i];
      }
    }
    if(i==N-1){
      v.push_back(tmp_sum);
    }
  }
  int res;
  int tmp_res = 0;
  int length = v.size();
  for(int i=0;i<v.size();i+=2){
    for(int j=i;j<min(length, i+1+2*K);j++){
      //cout << v[j];
      tmp_res+=v[j];
    }
    //cout << endl;
    res = max(res, tmp_res);
    tmp_res = 0;
  }
  cout << res << endl;
  return 0;
}


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

int n;
int a[1010];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += (double)(1/(double)a[i]);
    }
    ans = 1/ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

C = []
max_A = max(A)
max_idx = A.index(max_A)
min_A = min(A)
min_idx = A.index(min_A)

if abs(max_A) >= abs(min_A):
    for i in range(n):
        A[i] += max_A
        C.append([max_idx+1, i+1])
    for i in range(1, n):
        A[i] += A[i-1]
        C.append([i, i+1])
else:
    for i in range(n):
        A[i] += min_A
        C.append([min_idx+1, i+1])
    for i in range(n, 1, -1):
        A[i-2] += A[i-1]
        C.append([i, i-1])

#print(A)
print(len(C))
for i, j in C:
    print('{0} {1}'.format(i, j))


Measured memory_bytes: 3064
#include <cstdlib>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <ctime>

using namespace std;

int main(){
    int n;
    int num[200];
    int min = 2147483647;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> num[i];
    }
    for(int i=0;i<n;i++){
        int count = 0;
        while(num[i]>0)
        {
            if(num[i]%2 == 0){
                count++;
                num[i] /= 2;
            }else{
                break;
            }

        }
        num[i] = count;
    }
    for(int i=0;i<n;i++){
        if(min>num[i]){
            min = num[i];
        }
    }
    cout << min << "\n";
}


Measured memory_bytes: 256