akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
void solve()
{
    ll l,r,d,count=0;
    cin>>l>>r>>d;
    fo(i,l,r+1)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout<<count<<endl;

}
int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,W;
	cin>>n>>W;
	int w[n],v[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	long long int ans[n+1][W+1];
	ans[0][0]=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			if(i==0||j==0){
				ans[i][j]=0;
				continue;
			}
			if(w[i-1]<=j){
				ans[i][j]=max(ans[i-1][j],ans[i-1][j-w[i-1]]+v[i-1]);
			}
			else
				ans[i][j]=ans[i-1][j];
		}
	}
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=W;j++){
	// 		cout<<ans[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<ans[n][W]<<endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#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 all(v) v.begin(),v.end()

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    ll S = n;
    ll cc = m/2;
    ans = min(S,cc);
    cc -= ans;
    ans += max(0ll,cc/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::{max, min};
use std::i32;

fn solve(a: i32, b: i32, c: i32, x: i32, y: i32) -> i32 {
    let mut ans = i32::MAX;
    for nc in 0..(max(2 * x, 2 * y) + 1) {
        let na = max(0, x - nc / 2);
        let nb = max(0, y - nc / 2);
        let price = a * na + b * nb + c * nc;
        ans = min(ans, price);
    }
    ans
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut iter = s.split_whitespace().map(|w| w.trim().parse().ok().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let c = iter.next().unwrap();
    let x = iter.next().unwrap();
    let y = iter.next().unwrap();
    let r = solve(a, b, c, x, y);
    println!("{}", r);
}


Measured memory_bytes: 4352
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


int main()
{
    char C[6];
    REP(i, 6)
    {
        cin >> C[i];
    }

    REP(i, 3)
    {
        if (C[i] != C[5 - i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()
    t=readline().strip()

    cnt=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            cnt+=1

    print(cnt)
    
if __name__=="__main__":
    main()

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

int main(){
    long long n;
    cin >> n;  //input

    long long ans = 0;  //main start
    for (int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }  //main end

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

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  
  string S;
  cin >> S;


  int Ans = 0;
  for (int i = 0; i < S.length()/2; i++) {
    if (S[i] != S[S.length() - (i+1)]) {
      Ans++; 
    }
  }

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


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

pair<int, int> a[NAX];
pair<int, int> b[NAX];
int p[NAX];
int n;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        cin >> n;
        for (size_t i = 0; i < n; i++)
        {
            cin >> a[i].f;
            a[i].s = i;
        }
        for (size_t i = 0; i < n; i++)
        {
            cin >> b[i].f;
            b[i].s = i;
        }
        sort(a, a + n);
        sort(b, b + n);
        for (size_t i = 0; i < n; i++)
        {
            if (a[i].f > b[i].f)
            {
                cout << "No\n";
                return;
            }
        }
        for (size_t i = 0; i + 1 < n; i++)
        {
            if (a[i + 1].f <= b[i].f)
            {
                cout << "Yes\n";
                return;
            }
        }
        for (size_t i = 0; i < n; i++)
            p[a[i].s] = b[i].s;
        int x = 0, len = 0;
        do
        {
            x = p[x];
            len++;
        } while (x != 0);
        if (len == n)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 2176
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

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

        
	int n,m;
	cin>>n>>m;

	if(n*500 >= m)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
        
        












    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<int> c(n),v(n);
  for(int i=0; i<n; ++i) cin >>v[i];
  for(int i=0; i<n; ++i) cin >>c[i];
  
  int ret=0;
  for(int i=0; i<n; ++i){
    if ((v[i]-c[i]) > 0){
      ret += (v[i] - c[i]);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int MAX_N = 2000005;

ll inv[MAX_N], fac[MAX_N], fiv[MAX_N];

void COMinit() {
    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD; // n!
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
    }
}

ll com(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * fiv[k] % MOD * fiv[n-k] % MOD;
}

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

    int B, W;
    cin >> B >> W;

    COMinit();

    ll b = 1, w = 1, base = 1;
    for (int i = 1; i <= B+W; i++) {
        ll ans = (b - w * fiv[2]) % MOD;
        ans = (ans + MOD) % MOD;
        ans = (ans * base) % MOD;
        cout << ans << "\n";

        base = (base * fiv[2]) % MOD;
        b = (b * 2) % MOD;
        w = (w * 2) % MOD;

        if (i >= B) {
            b = (b + MOD - com(i-1, B-1)) % MOD;
            w = (w + MOD - com(i-1, B-1)) % MOD;
        }

        if (i >= W) {
            w = (w + MOD - com(i-1, i-W)) % MOD;
        }
    }

    return 0;
}

Measured memory_bytes: 49024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

void dfs(ll s, ll cur_sum, ll parent)
{
    ans[s] = update[s] + cur_sum;
    for(auto u : adj[s])
    {
        if(u == parent) continue;
        dfs(u, update[s]+cur_sum, s);
    }
}

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

    for(int i=0;i<n-1;i++)
    {
        int a, b;
        cin >> a >> b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    for(int i=0;i<q;i++)
    {
        int p,x;
        cin >> p >> x;

        update[p] += x;
    }

    dfs(1, 0, -1);

    for(int i=1;i<=n;i++)
        cout << ans[i] << " ";

    cout << "\n";
}




Measured memory_bytes: 25600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		}
		

	}




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

int main(){
  int n, S;
  int t[20002];

  while(cin >> n >> S, n || S){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    sort(t, t + n);

    int sum = 0;

    for(int i = 0; i < n; i++){
      int rem = S - t[i] + 1;
      int pos = max((int)(lower_bound(t, t + n, rem) - t), i + 1);

      sum += n - pos;
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int N;
const int B=5000;
int x[2][B],y[2][B];
main()
{
	cin>>N;
	for(int c=0;c<N;c++)
	{
		int X,Y;cin>>X>>Y;
		for(int i=0;i<B;i++)x[1][i]=x[0][i],y[1][i]=y[0][i];
		if(X||Y)
		{
			for(int i=0;i<B;i++)
			{
				int tx=x[0][i]+X,ty=y[0][i]+Y;
				double theta;
				if(ty==0&&tx<0)theta=M_PI;
				else
				{
					if(ty<0)theta=atan2(ty,tx)+2*M_PI;
					else theta=atan2(ty,tx);
				}
				int id=floor(theta*B/(2*M_PI));
				if(hypot(x[1][id],y[1][id])<hypot(tx,ty))
				{
					x[1][id]=tx;
					y[1][id]=ty;
				}
			}
		}
		for(int i=0;i<B;i++)x[0][i]=x[1][i],y[0][i]=y[1][i];
	}
	double ans=0;
	for(int i=0;i<B;i++)ans=max(ans,hypot(x[0][i],y[0][i]));
	cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {

	int n,m;
	cin >> n >> m;
	int l,r,li,ri;
	l = 1;
	r = n;
	REP(i,m){
		cin >> li >> ri;
		l = max(l,li);
		r = min(r,ri);
	}
	println(max(r-l+1,0));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ax[100000];
int main()
{
    int n,sum=0;
    cin>>n;
    int ax[100000];
    for(int i=0;i<n;i++)
    {
          cin>>ax[i];
    }
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
    {
          sum+=ax[i]*ax[j];
    }
      cout<<sum<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
string s;
int n;

signed main(){

    cin >> n >> s;
    int x = 0;

    rep(i,s.size()){
        if(s[i] == ')' && x == 0) cout << '(';
        else if(s[i] == ')' ) x--;
        else if(s[i] == '(') x++;
    }

    cout << s;
    rep(i,x) cout << ')'; 
    cout << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, i, mny = 100000;

  scanf("%d", &n);
  for (i = 0; i < n; i++){
    mny *= 1.05;
    if (mny % 1000 != 0) {
      mny += 1000 - (mny % 1000);
    }
  }
  printf("%d\n", mny);

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
    int f;
    double r;
    scanf("%lf", &r);
    double f1, f2;
    f1 = r * r * 3.141592653589;
    f2 = 2 * r * 3.141592653589;
    printf("%.6lf %.6lf\n", f1, f2);
    
    return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    int x(0), y(0), z(Y);

    for(int i = 0; i <= 2000; ++i) {
        for(int j = 0; j <= 2000; ++j) {
            if (z-10*i-5*j >= 0 && (z-9*i-4*j == N)) {
                cout << i << " " << j << " " << z-10*i-5*j << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

even = odd = 0
for i in range(N):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1

if odd % 2 != 0:
    print("NO")
else:
    print("YES")


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

#define loop(n) for(int  i= 0 ; i< (n) ; i++)
#define ll long long
#define vi vector<int>
#define inf 1000000009

using namespace std;

ll dp[100] ;

ll sol(ll a){

    if(dp[a]!=-1)return dp[a] ;

    if(a==1)return dp[a]=1;
    if(a==2)return dp[a]=3 ;

    return dp[a] = sol(a-1)+ sol(a-2);
}

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

    memset(dp,-1,sizeof(dp));
    cout << sol(n) ;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;


int main() {
  int A,B,M;
  cin >> A >> B >> M;
  int a[A],b[B];
  int amin=INF,bmin=INF,ans=INF;
  int x[M],y[M],c[M];
  REP(i,A) {
    cin >> a[i];
    amin = min(amin,a[i]);
  }
  REP(i,B) {
    cin >> b[i];
    bmin = min(bmin,b[i]);
  }
  REP(i,M) {
    cin >> x[i] >> y[i] >> c[i];
  }
  ans = amin+bmin;

  REP(i,M) {
    ans = min(ans,a[x[i] - 1] + b[y[i] - 1] - c[i]);
  }
  cout << ans;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<string,int>P;
int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};
int n,pp;
int h=5,w=4;
string a;
map<string,int>used;
int bfs(){
  int ans=20;
  queue<P>q;
  used[a]=1;
  q.push(P(a,1));
  while(!q.empty()){
    P p=q.front();q.pop();
    string now=p.first;
    int cost=p.second;
    int b[5][4],t=0;
    r(i,5)r(j,4)b[i][j]=(int)now[t++];
    r(i,5)r(j,4){
      r(k,8){
	int y=i+dy[k];
	int x=j+dx[k];
	if(y<0||x<0||x>=w||y>=h)continue;
	if(b[i][j]==b[y][x]&&b[i][j]){
	  int c[5][4];
	  r(i1,5)r(j1,4)c[i1][j1]=b[i1][j1];
	  c[i][j]=c[y][x]=0;
	  string next;
	  r(i1,5)r(j1,4)if(c[i1][j1])next+=(char)c[i1][j1];
	  ans=min(ans,(int)next.size());
	  while(next.size()<20)next+=(char)0;
	  if(used[next])continue;
	  used[next]=1;
	  q.push(P(next,1));
	}
      }
    }
  }
  return ans;
}
int main(){
  cin>>n;
  while(n--){
    a="";
    used.clear();
    r(i,5)r(j,4){
      cin>>pp;
      a+=pp;
    }
    cout<<bfs()<<endl;
  }
}

Measured memory_bytes: 3256
sss = input().lower()
alphas = [chr(i) for i in range(97, 97+26)]
counter = [0 for _ in range(len(alphas))]
while True:
	for i, a in enumerate(alphas):
		counter[i] += sss.count(a)
	try: sss = input().lower()
	except EOFError:
		break
for i, num in enumerate(counter):
	print(alphas[i], ':', num)


Measured memory_bytes: 7480
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	int aneed = a-b;
	c-=aneed;
	if(c<0)cout<<"0"<<endl;
	else cout<<c<<endl;	
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int n; cin>>n;

	vector<int> d(n+1);

	for(int i=1; i<=n; i++){
		cin>>d[i];
	}
	int cnt =0;
	for(int i=1; i<=n; i++){
		if(d[i] != i)cnt++;
	}

	if(cnt ==0 || cnt == 2){
		writeln("YES");
	}else {
		writeln("NO");
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X)< 0 ? -(X): (X))
#define LCM(X, Y)  ( ( (X) / (GCD( (X)  , (Y) ))) * (Y) )
#define MEM( A,  B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL ) fill( V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A,I) cout<<"at pos "<< I <<"  value is: "<< A[I]
#define TURBO ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0)
const double EPS =1e-9 ;
const double PI = 3.1415926535897932384626433832795 ;
using namespace std ;
inline ll GCD(ll A, ll B){
      if ( B == 0 ) return A;
      return GCD( (B) ,  (A % B) );
}
inline ll POW(ll BASE, ll EXP) {
   ll RES = 1;
   for(ll I= 0; I < EXP; I++) RES *= BASE ;
   return RES;
}

inline ll BIGMOD  ( ll a, ll p, ll m ) {
   ll res = 1 % m;
   ll x = a % m;
   while ( p > 0 ) {
       if ( (p & 1) > 0 ) res = ( res * x ) % m;
       x = ( x * x ) % m; p >>= 1;
   }
   return res;
}
inline void FILE_HANDLE( ){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

int main()
{
            TURBO;
            //FILE_HANDLE() ;
            ll n , x , t ;
            cin >> n >> x >> t ;

            cout << (int)(ceil(n / (double) x) * t )<< endl ;
}



Measured memory_bytes: 3648
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  print $ solve n

solve n = f n 1 0 -2
  where
    f n a acc
      | a * a > n = acc
      | n `mod` a == 0 = f n (a + 1) (a + n `div` a)
      | otherwise = f n (a + 1) acc

Measured memory_bytes: 508
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << (a-1) * (b-1) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int f=0;
  int N;
  string C;
  cin >> N ;
  for(int i=0; i < N ; i++){
  cin >> C ;
    
    if (C == "Y"){
    cout << "Four" <<endl;
      f=1;
      break;
   
    }
  }
  if (f==0)
  {cout << "Three" <<endl;
  }
}

Measured memory_bytes: 3560
// Aizu Vol-2 0202: At Boss's Expense
// 2017.9.5 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX  1000000
#define SQRT 1000     // sqrt(MAX)
char prime[MAX + 5], *p, *q, *pmax = prime + MAX;

int v[35];
char mk[MAX+3];

int main()
{
	int n, x;
	int i, k, ans;

	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2)
		if (!*p) for (q = p + k; q <= pmax; q += k) *q = 1;

	while (scanf("%d%d", &n, &x) && n) {
		memset(mk, 0, x+1);
		for (i = 0; i < n; i++) scanf("%d", v + i);
		for (mk[0] = 1, k = 0; k < x; k++) {
			if (mk[k]) for (i = 0; i < n; i++) if (k+v[i] <= x) mk[k+v[i]] = 1;
		}
		ans = -1;
		if (x <= 2) { if (mk[x]) ans = x; }
		else {
			if (!(x & 1)) x--;
			for ( ; x > 0; x -= 2) if (mk[x]  && !prime[x]) { ans = x; break; }
		}
		printf(ans < 0 ? "NA\n" : "%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>

int zei(int nuki,int ritu) {
	return nuki*(100+ritu)/100;
}

int main(void) {
	int x,y,s;
	while(scanf("%d%d%d",&x,&y,&s)==3 && (x|y|s)!=0) {
		int answer=0;
		int p1,p2;
		for(p1=1;p1<s;p1++) {
			for(p2=1;p2<s;p2++) {
				if(zei(p1,x)+zei(p2,x)==s) {
					int np=zei(p1,y)+zei(p2,y);
					if(np>answer)answer=np;
				}
			}
		}
		printf("%d\n",answer);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll mod = 998244353;



ll N,ans;

int main() {
	cin >> N;

	for (ll i = 1; i*i <= N; i++) {
		
			if (N % (i + 1) == 0) {
				ll K = N / (i + 1);
				if (abs(K - i-1) <= 1)continue;
				if (i > (N / K))ans += i;
				else  if(K*K!=N)ans+=K-1;

			}
		
	}
	if(N>2)ans += N - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i;
ll x,tot1,tot2,sum1,sum2;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)
	{
		cin>>x;
		sum1+=x,sum2+=x;
		if(i%2)
		{
			if(sum1>=0)tot1+=sum1+1,sum1=-1;
			if(sum2<=0)tot2+=1-sum2,sum2=1;
		}
		else
		{
			if(sum1<=0)tot1+=1-sum1,sum1=1;
			if(sum2>=0)tot2+=sum2+1,sum2=-1;
		}
	}
	cout<<min(tot1,tot2)<<endl;
	return 0;
}

Measured memory_bytes: 256
def bellman_ford(edges, num_v, start, end):
    """
    ベルマンフォード法
    :param edges: (from, to, cost)のリスト
    :param num_v: 頂点の数
    :param start: 始点
    :param end: 終点
    :return: 最小コスト
    """
    inf = float("inf")
    dist = [inf] * num_v
    dist[start - 1] = 0
    ans = -1

    for i in range(num_v):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                if i == num_v - 1 and ans != dist[end - 1]:
                    return -1
        if i == num_v - 2:
            ans = dist[end - 1]

    return ans


def abc061_d():
    n, m = map(int, input().split())
    edges = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        edges.append((a, b, -c))

    ans = bellman_ford(edges, n, 1, n)
    print(-ans if ans != -1 else "inf")


if __name__ == '__main__':
    abc061_d()


Measured memory_bytes: 3296
import re

_S = input()
T = input()

lenS = len(_S)
lenT = len(T)

if lenT > lenS:
	print("UNRESTORABLE")
else:
	S = re.split("([?" + "][?".join(T[::-1]) + "])", _S[::-1])
	if len(S) == 1:
		print("UNRESTORABLE")
	else:
		S[1] = T[::-1]
		S = "".join(S)
		print(S[::-1].replace("?", "a"))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int N,A,B;
int Delete(int x,int p) {
    int d = x & (1 << p) - 1;
    int u = x & (1 << 20) - (1 << p + 1);
    return (u >> 1) + d;
}
int Insert(int x,int p,int v) {
    int d = x & (1 << p) - 1;
    int u = x & (1 << 20) - (1 << p);
    return (u << 1) + v + d;
}
vector<int> Calc(int s,int t,int n) {
    if(n == 1) {
        vector<int> v;v.pb(s);v.pb(t);
        return v;
    }
    int x = 1,p = 0;
    while(1) {
        if((s & x) != (t & x)) break;
        x <<= 1;++p;
    }
    int a,b;
    a = Delete(s,p);b = Delete(t,p);
    int c = a ^ 1;
    vector<int> f = Calc(a,c,n - 1),h = Calc(c,b,n - 1);
    for(int i = 0 ; i < (1 << n - 1) ; ++i) {
        f[i] = Insert(f[i],p,(s & x));
        h[i] = Insert(h[i],p,(t & x));
    }
    f.insert(f.end(),h.begin(),h.end());
    return f;
}
int count(int x) {
    int res = 0;
    while(x) {
        res += (x & 1);
        x >>= 1;
    }
    return res;
}
void Solve() {
	scanf("%d%d%d",&N,&A,&B);
    if(!(count(A^B) & 1)) {puts("NO");return;}
    puts("YES");
    vector<int> ans = Calc(A,B,N);
    for(int i = 0 ; i < (1 << N) ; ++i) {
		printf("%d ",ans[i]);
    }
}
int main() {
    Solve();
}

Measured memory_bytes: 1648
#include<iostream>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int X;
	cin >> X;
	for (int i = 0; i <= X; i++){
		int tmp = X - i * 100;
		if (0 <= tmp && tmp <= i * 5) {
			cout << "1" << endl;
			return 0;
		}
		if (tmp < 0) {
			break;
		}
	}
	cout << "0" << endl;

	return 0;
}

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

using namespace std;

int N;
int ans;

void input(){
  cin >> N;
}

void solve(){
    for(int i=1;i<=N;i++){
      if(i%2!=0){
	int tmp=0;
	for(int j=1;j<=i;j++){
	  if(i%j==0){
	    tmp+=1;
	  }
	}
	//	cout << i <<" " << tmp << endl;;
	if(tmp==8){
	  ans+=1;
	}
      }
    }
}

int main(){
  input();
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;


	int main() {

		string s;
		cin >> s;

		bool ans = s.compare(0, 4, "YAKI") == 0;

		cout << (ans ? "Yes" : "No") << "\n";

		return 0;
	}




Measured memory_bytes: 256
N, W = map(int, input().split())
V0, V1, V2, V3 = [], [], [], []
w0 = 0
for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        V0.append(v)
        w0 = w
    elif w0 == w:
        V0.append(v)
    elif w0 + 1 == w:
        V1.append(v)
    elif w0 + 2 == w:
        V2.append(v)
    else:
        V3.append(v)

V0 = sorted(V0, reverse=True)
V1 = sorted(V1, reverse=True)
V2 = sorted(V2, reverse=True)
V3 = sorted(V3, reverse=True)
vl0 = len(V0)
vl1 = len(V1)
vl2 = len(V2)
vl3 = len(V3)
V0_sum = [0] * (vl0 + 1)
V1_sum = [0] * (vl1 + 1)
V2_sum = [0] * (vl2 + 1)
V3_sum = [0] * (vl3 + 1)
for i in range(1, vl0 + 1):
    V0_sum[i] = V0_sum[i - 1] + V0[i - 1]
for i in range(1, vl1 + 1):
    V1_sum[i] = V1_sum[i - 1] + V1[i - 1]
for i in range(1, vl2 + 1):
    V2_sum[i] = V2_sum[i - 1] + V2[i - 1]
for i in range(1, vl3 + 1):
    V3_sum[i] = V3_sum[i - 1] + V3[i - 1]
w1, w2, w3 = w0 + 1, w0 + 2, w0 + 3
num = 0

for v0 in range(vl0 + 1):
    for v1 in range(vl1 + 1):
        for v2 in range(vl2 + 1):
            for v3 in range(vl3 + 1):
                w = v0 * w0 + v1 * w1 + v2 * w2 + v3 * w3
                if w <= W:
                    q = V0_sum[v0] + V1_sum[v1] + V2_sum[v2] + V3_sum[v3]
                    num = max(num, q)

print(num)


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	string s;
	
	cin >> s;
	if ((*(--s.end()) == *s.begin()) ^ (s.size() % 2 == 0)) puts("Second");
	else puts("First");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, w, n;
    cin >> h >> w >> n;

    ll res = 0, b = 0;
    while (1) {
        if (b >= n) break;
        b += max(h, w);
        res++;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;
constexpr ll MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    using pss=pair<char, char>;
    map<pss, int> m;

    vii t(10, vi(10));
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);

        int first = *s.begin() - '0';
        int last = *(prev(s.end(), 1)) - '0';
        if (last == 0) {
            continue;
        }
        t[first][last]++;
    }

    ll ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            ans += t[i][j] * t[j][i];
        }
    }

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


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

int main()
{
    int N; cin>>N;
    vector<int> b(N-1);
    for(int i=0;i<N-1;i++){
        cin>>b[i];
    }
    
    int sum=0;
    sum+=b[0];
    for(int i=1;i<N-1;i++){
        sum+=min(b[i-1],b[i]);
    }
    sum+=b[N-2];

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int i, j;
  int h, w;

  while(1) {
    scanf("%d %d", &h, &w);

    if (h == 0 && w == 0) {
      break;
    } else {
      for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
          if (i == 0 || j == 0 || i == h - 1 || j == w - 1) {
            putchar('#');
          } else {
            putchar('.');
          }
        }
        putchar('\n');
      }
      putchar('\n');
    }
  }

  return 0;
}



Measured memory_bytes: 2060
import sys
nyu = sys.stdin.read()
nyu = map(int,nyu.split())
for n in nyu:
   	ans = []
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans

Measured memory_bytes: 4232
a11, a12, a13 = input().split()
a21, a22, a23 = input().split()
a31, a32, a33 = input().split()
n = int(input()) 
b = []
for _ in range(n):
    b.append(input())
if a11 in b and a12 in b and a13 in b:
  print("Yes")
elif a21 in b and a22 in b and a23 in b:
  print("Yes")
elif a31 in b and a32 in b and a33 in b:
  print("Yes")
elif a11 in b and a21 in b and a31 in b:
  print("Yes")
elif a12 in b and a22 in b and a32 in b:
  print("Yes")
elif a13 in b and a23 in b and a33 in b:
  print("Yes")
elif a11 in b and a22 in b and a33 in b:
  print("Yes")
elif a13 in b and a22 in b and a31 in b:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = map(int, input().split())
i = 1
while i<=b:
    if (a*i-c)%b != 0: i+=1
    else:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 9516
#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>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)


int main() {
    int n; cin >> n;
    vector<int> A(n);
//    rep(i,n-1) cin >> A[i+2];

    rep(i,n-1){
        int in; cin >> in;
        ++A[in-1];
    }
    rep(i,n) cout << A[i] << endl;
}





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


int main() {
    ll n;
    cin>>n;
    vector<char> c;
    while(n>=1){
        n--;
        int x=n%26;
        if(x==-1){
            c.push_back('z');
            n/=26;
            
        }else{
        char a='a';
        a+=x;
        c.push_back(a);
        n/=26;
        }
    }
    reverse(begin(c),end(c));
    rep(i,c.size()){
        cout<<c[i];
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int N;
    cin >> N;
    int D[N][2];
    for (int i = 0; i < N; i++) {
        cin >> D[i][0] >> D[i][1];
    }

    bool isTripleZorome = false;
    int countZorome = 0;
    for (int i = 0; i < N; i++) {
        if (D[i][0] == D[i][1]) {
            countZorome += 1;
        } else {
            countZorome = 0;
        }
        if (countZorome == 3) {
            isTripleZorome = true;
            break;
        }
    }

    cout << (isTripleZorome ? "Yes" : "No") << endl;

}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = LINF;
  for(ll i = 1; i * i <= n; ++i) {
    if(n % i == 0) ans = min(ans, (i - 1) + (n / i - 1));
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//qsort(配列, 長さ, sizeof(int), compare_int);

int N;
int A[100010];
int B[100010];

int main(){
    scanf("%d",&N);
    long int sum = 0;
    for(int i = 0;i < N;i++){
        scanf("%d",&A[i]);
        sum += (long int)A[i];
    }
    long int sum2 = 0;
    for(int i = 0;i < N;i++){
        scanf("%d",&B[i]);
        sum2 += (long int)B[i];
    }
    if(sum2 > sum){
        printf("%d\n",-1);
        return 0;
    }
    int count = 0;

    long int S = 0;
    int sa[N];
    for(int i = 0;i < N;i++){
        sa[i] = A[i] - B[i];
        if(sa[i] < 0){
            S -= (long int)sa[i];
            count++;
        }
    }

    if(S == 0){
        printf("0\n");
        return 0;
    }

    qsort(sa, N, sizeof(int), compare_int);

    int toru = N-1;

    while(1){
        S = S - (long int)sa[toru];
        toru--;
        count++;
        if(S <= 0)break;
    }

    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 1788
n=int(input())
import numpy as np
a=np.array(input().split(),dtype=int)
i=0
ans=0
while i<a.size:
  if a[i]==i+1:
    ans+=1
    if i+1 < a.size and a[i+1]==i+2:
      i+=2
      continue
  i+=1
print(ans)


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int main(void){
    // map<int,int> m;
    int n,in,ans=0,k;
    // vector<int> v;
    cin>>n>>k;
    // for(int i=0;i<n;i++){
    //     cin>>in;
    //     if(m.count(in)){
    //         m[in]++;
    //     }
    //     else{
    //         m[in]=1;
    //     }
    // }
    // for(pair<int ,int> x:m){
    //     v.push_back(m[x.first]);
    // }
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>in;
        v[in-1]++;
    } 
    sort(v.rbegin(),v.rend());
    for(int i=0;i<k;i++){
        ans+=v[i];
    }
    cout<<n-ans;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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;
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, 0, N) {
    cin >> H[i];
  }
  sort(All(H));
  int ans = 1e9+1;
  rep(i, 0, N) {
    if (i + K - 1 > N - 1) {
      break;
    }
    ans = min(ans, H[i + K - 1] - H[i]);
  }

  cout << ans << endl;
};


Measured memory_bytes: 640
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;

void CollectingBalls() {
	int n, k;
	cin >> n >> k;
	int sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		sum += min(x * 2, (k - x) * 2);
	}
	cout << sum << endl;
}

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



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

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      foreach (var co in ReadNumbers())
      {
        var det = (double)co[0] * co[4] - co[1] * co[3];
        var x = (1.0 / det) * co[4] * co[2] + (1 / det) * -co[1] * co[5];
        var y = (1.0 / det) * -co[3] * co[2] + (1 / det) * co[0] * co[5];
        Console.WriteLine("{0:F3} {1:F3}", x, y);
      }
    }

    static IEnumerable<int[]> ReadNumbers()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return line.Split(' ').Select(s => int.Parse(s)).ToArray();
    }
  }
}

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

  for (int i = 1; i < 9999999; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256