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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a[1000];

signed main() {
	while (1) {
		cin >> n >> m;
		if (n==0) break;
		rep(i,n) cin >> a[i];
		int res = 0;
		rep(i,n) rep(j,n) if (i!=j && a[i]+a[j]<=m) chmax(res,a[i]+a[j]);
		if (res==0) cout << "NONE" << ln;
		else cout << res << ln;
	}
}


Measured memory_bytes: 3188
import itertools

N = int(input())
P = ' '.join(list(input().split()))
Q = ' '.join(list(input().split()))
perm = [1 + i for i in range(N)]
for i, v in enumerate(itertools.permutations(perm)):
    v = ' '.join(list(map(str, v)))
    if v == P:
        p = i
    if v == Q:
        q = i
print(abs(p - q))


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define yzh 2333333
#define bql 2147483647
using namespace std;
int n,a[25],b[25],sum;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for (int i=1;i<=n;i++)
	  cin>>b[i];
	for (int i=1;i<=n;i++)
	   sum+=max(a[i]-b[i],0);
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int Length=S.length();
      	char tmp[];
      	tmp =new char[Length];
      	for(int i=0 ;i<Length;i++)
        {
          	tmp[i]='x';
        }
      	System.out.println(tmp);
	}
}

Measured memory_bytes: 22996
from collections import deque


def main():
    # BLACK = 1
    WHITE = 0
    EDGE = 0
    WEIGHT = 1
    N = int(input())
    graph = [[] for i in range(N+1)]
    colors = [-1] * (N + 1)

    for i in range(N-1):
        u, v, w = map(int, input().split())
        graph[u].append((v, w))
        graph[v].append((u, w))

    q = deque()
    q.append(1)
    colors[1] = WHITE
    visited = [False] * (N + 1)
    while len(q) != 0:
        parentIdx = q.popleft()
        parent = graph[parentIdx]
        # print(u+1, [i + 1 for i in q])
        for v, e in enumerate(parent):
            if not visited[e[EDGE]]:
                q.append(e[EDGE])
                visited[e[EDGE]] = True
                if e[WEIGHT] % 2 == 0:
                    colors[e[EDGE]] = colors[parentIdx]
                else:
                    colors[e[EDGE]] = 1 - colors[parentIdx]
                # print(colors)

    for i in range(1, len(colors)):
        print(colors[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 75040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    cout<<"unsafe";
    else
    cout<<"safe";
    return 0;
}
//make all values ll

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int a = (s[0] - '0') * 10 + s[1] - '0';
  int b = (s[2] - '0') * 10 + s[3] - '0';
  bool c = 1 <= a && a <= 12;
  bool d = 1 <= b && b <= 12;

  if (c) {
    if (d) {
      cout << "AMBIGUOUS";
    }
    else {
      cout << "MMYY";
    }
  }
  else {
    if (d) {
      cout << "YYMM";
    }
    else {
      cout << "NA";
    }
  }
}
#endif


Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int main()
{
    string A,B,C;
    cin>>A>>B>>C;
    A[0]=65+A[0]-97;
     B[0]=65+B[0]-97;
      C[0]=65+C[0]-97;
     cout<<A[0]<<B[0]<<C[0]<<endl;

}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064
L = int(input())

def decompose(L):
    if L < 3:
        return [L]
    r = L % 3
    return [r] + decompose((L - r) // 3)

dec = decompose(L)

N = len(dec) + 1
edge = []

for w in range(dec[-1]):
    edge.append((N-1, N, w))

base = dec[-1]
for i in range(len(dec) - 2, -1, -1):
    for w in range(3):
        edge.append((i+1, i+2, w * base))
    base = 3 * base
    for w in range(dec[i]):
        edge.append((i+1, N, base + w))
    base += dec[i]

M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))

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

int main(){
	int n,t,a[100],sum = 0;
	cin >> n;
	for(int i = 0;i<n;i++)cin >> a[i];
	if(n==1)cout << a[0] << "\n" << "0" << endl;
	else{
		for(int i = 0;i<n;i++){
			for(int j = 0;j<n-1;j++){
				if(a[j]>a[j+1]){
					t = a[j];
					a[j] = a[j+1];
					a[j+1] = t;
					sum++;
				}
			}
		}
	for(int i = 0;i<n-1;++i)cout << a[i] << " " ;
	cout << a[n-1] << "\n" << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long long
//#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int32_t main()
{
    // FIO;
    // int t;
    // cin >> t;
    // while (t--)
    // {
        // int n;
        // cin >> n;
        // int arr[n];
        // for (int i = 0; i < n; i++)
        // {
        //     cin >> arr[i];
        // }
        float d,t,s;cin>>d>>t>>s;
        if(d/s<=t)
        cout<<"Yes";
        else
        {
            cout<<"No";
        }
        
    // }
}

Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int N, cnt = 0;
	veci p, _p;
	cin >> N;
	rep(i, N) {
		int x;
		cin >> x;
		p.push_back(x);
		_p.push_back(x);
	}

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

	rep(i, N) {
		if (p[i] != _p[i]) cnt++;
	}
	string ans = cnt == 2 || cnt == 0 ? "YES" : "NO";
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;
 
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>
 
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};
 
int a[2010][2010];
int imos[2010][2010] = {};
vector<int> Zx,Zy;
int n,w,h;
int x[1002][2],y[1002][2];
 
int dfs(int s,int t){
    if(a[s][t] != 0)return 0;
    a[s][t] = 1;
    rep(i,4){
        dfs( s+dir_4[i][0] , t+dir_4[i][1] );
    }
    return 1;
}
 
void init(){
    rep(i,2010)rep(j,2010)a[i][j] = 0;
    rep(i,2010)rep(j,2010)imos[i][j] = 0;
	Zx.clear();
	Zy.clear();
}
 
int main(){
    while(1){
        init();
         
        scanf("%d%d",&w,&h); if(w == 0 && h == 0)break;
        scanf("%d",&n);
        rep(i,n){
            scanf("%d",&x[i][0]);
            scanf("%d",&y[i][0]);
            scanf("%d",&x[i][1]);
            scanf("%d",&y[i][1]);
        }
         
        Zx.pb( 0 ); Zx.pb( w );
        Zy.pb( 0 ); Zy.pb( h );
        rep(i,n){
            Zx.pb( x[i][0] );
            Zx.pb( x[i][1] );
            Zy.pb( y[i][0] );
            Zy.pb( y[i][1] );
        }
        sor(Zx); uniq(Zx);
        sor(Zy); uniq(Zy);
         
        rep(i,n){
            int x1 = lb(Zx,x[i][0]) - Zx.begin();
            int x2 = lb(Zx,x[i][1]) - Zx.begin();
            int y1 = lb(Zy,y[i][0]) - Zy.begin();
            int y2 = lb(Zy,y[i][1]) - Zy.begin();
            imos[x1][y1] ++;
            imos[x1][y2] --;
            imos[x2][y1] --;
            imos[x2][y2] ++;
        }
         
        rep1(i,2009)rep(j,2010)imos[i][j] += imos[i-1][j];
        rep(i,2010)rep1(j,2009)imos[i][j] += imos[i][j-1];
         
        rep(i,2010)rep(j,2010)a[i][j] = 1;
        rep1(i,Zx.size()-1){
            rep1(j,Zy.size()-1){
                a[i][j] = imos[i-1][j-1];
            }
        }
         
        static int ret = 0;
    	ret = 0;
        rep(i,2010){
            rep(j,2010){
                ret += dfs(i,j);
            }
        }
         
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 34928
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1001001001001001;

int main() {
    int V,E;
    cin >> V >> E;
    vector<long long> a(V,INF);
    vector< vector<long long> > d(V,a);
    for(int i=0; i<V; i++) d[i][i] = 0;
    for(int i=0; i<E; i++) {
        long long s,t,w;
        cin >> s >> t >> w;
        d[s][t] = w;
    }

    for(int k=0; k<V; k++) {
        for(int i=0; i<V; i++) {
            for(int j=0; j<V; j++) {
                if(d[i][k] != INF && d[k][j] != INF) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }

    for(int i=0; i<V; i++) {
        if(d[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for(int i=0; i<V; i++) {
        for(int j=0; j<V-1; j++) {
            if(d[i][j] == INF) cout << "INF ";
            else cout << d[i][j] << " "; 
        }
        if(d[i][V-1] == INF) cout << "INF" << endl;
        else cout << d[i][V-1] << endl;
    }
    return 0;
}


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

lastans = -1e20

for i in range(n):
    now = p[i] - 1 
    score = [c[now]]
    while True:
        now = p[now] - 1
        score.append(score[-1] + c[now])
        if now == i:
            break
    loopsum = score[-1]
    looplen = len(score)
#    print(score)
    if looplen >= k:
        ans = max(score[:k])
    elif loopsum <= 0:
        ans = max(score)
    else:
        loopnum = k//looplen
        loopnum_mod = k % looplen
        ans1 = loopsum * (loopnum - 1) + max(score)
        ans2 = loopsum * loopnum
        if loopnum_mod != 0:
            ans2 = ans2 +max(0,max(score[:loopnum_mod]))
        ans =max(ans1,ans2)
    lastans = max(lastans,ans)

print(lastans)



Measured memory_bytes: 97844
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c,d,e,x,y,z=0;
    cin >> a;
  	if(a<=5){
    for(int i=0;i<a;i++){
      cout << 0 <<endl;
    }
  	}else{
    for(int i=0;i<5;i++){
      cout << 0 <<endl;
    }
    for(int i = 6;i <= a;i++){
      c= sqrt(i);
        for(x=1;x<=c;x++){
            for(y=1;y<=x;y++){
                for(z=1;z<=y;z++){
                    if(x*x+y*y+z*z+x*y+y*z+x*z==i){
 						if(x==y&&y==z){
                          e++;
                        }else if(x!=y&&y!=z){
                          e+=6;
                        }else{
                          e+=3;
                        }
                	}
                }
            }
        }
        cout <<e<<endl;
        e = 0;
    }
  }
 
}

Measured memory_bytes: 3496
#ABC090-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(0,n-2,m-2))
else:
    print(max(0,(n-2)*(m-2)))

Measured memory_bytes: 38256
#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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[200001];
set<int> st;
int main(){
    int n,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        --ai;
        a[ai]=i;
    }
    st.insert(n);st.insert(-1);
    ll sum=0;
    rep(i,n){
        auto it=st.lower_bound(a[i]);
        ll r=*it;
        --it;
        ll l=*it;
        sum+=(i+1)*(a[i]-l)*(r-a[i]);
        st.insert(a[i]);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		s += ' ';
		stack<double>stk;
		string str;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == ' ') {
				if (str == "+") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop(); 
					stk.push(a + b);
				}
				else if (str == "-") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a - b);
				}
				else if (str == "*") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a * b);
				}
				else if (str == "/") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a / b);
				}
				else stk.push(stoi(str));
				str = "";
			}
			else str += s[i];
		}
		printf("%.10f\n", stk.top());
	}
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//main definations
#define endl "\n"
#define UI unsigned int
#define LLI long long int
#define ULLI unsigned long long int
#define PI 3.14159258

//codechef only
#define TC for(UI defined_i=1;defined_i<=t;defined_i++)
//int b_s(int arr[], int n, int find);
using namespace std;
int main(){
	int n, a;
	cin>>n>>a;
	n=n*n;
	n=n-a;
	cout<<n<<endl;
	return 0;
}
/*
int b_s(int arr[], int n, int find){
	int start=0, end=n-1, mid=(start+end)/2;
	while(start<=end){
		if(arr[mid]==find){
			return mid;
		}
		else if(arr[mid]<find){
			start=mid+1;
			mid=(start+end)/2;
		}
		else{
			end=mid-1;
			mid=(start+end)/2;
		}
	}
	return -1;
}*/

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

using namespace std;
const int MAXV = 1e5 + 10;
long long dp[MAXV];

int main()
{
    int n,W;
    scanf("%d %d",&n,&W);
    int weight[n+1], value[n+1];
    int V = 0;
    for(int i=1; i<=n; i++){
        scanf("%d %d",&weight[i], &value[i]);
        V+=value[i];
    }
    
    for(int i = 1;i<=V;i++) dp[i] = INT_MAX;
    
    dp[0] = 0;
    
    for(int i=1; i<=n; i++){
        int v = value[i], w = weight[i];
        for(int j=V; j>=v; j--){
            dp[j] = min(dp[j], dp[j-v]+w);
        }
    }
    for(int i=V; i>=0; i--){
        if(dp[i]<=W){
            cout << i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(((c-a)*(c-a)<=d*d) or (((b-a)*(b-a)<=d*d) and ((c-b)*(c-b)<=d*d)))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main()
{
    int H, W;

    while(1)
    {
        int i;
        cin>>H>>W;

        if (H==0 & W==0)
            break;

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if(i*j==0 || i==H-1 || j==W-1)
                    cout<<"#";
                else
                    cout<<".";
            }
            cout<<'\n';
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3088
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
cnt4=0
for i in a:
  if i%2==1:
    cnt1+=1
  elif i%4!=0:
    cnt2+=1
  elif i%4==0:
    cnt4+=1
if cnt2==0:
  if cnt1<=cnt4+1:
    print('Yes')
  else:
    print('No')
else:
  if cnt1<=cnt4:
    print('Yes')
  else:
    print('No')

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll K; cin >> K;
	ll val = 7%K;
	for (int i = 1; i <= K*2+2; i++) {
		if (val == 0) {
			cout << i << endl;
			return;
		}
		val = (val*10 + 7) % K;
	}
	cout << -1 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int F(char x) {
  if (x == '1') return 1;
  else if (x == '2') return 2;
  else if (x == '3') return 3;
  else if (x == '4') return 4;
  else if (x == '5') return 5;
  else if (x == '6') return 6;
  else if (x == '7') return 7;
  else if (x == '8') return 8;
  else if (x == '9') return 9;
  else return 0;
}

int main() {
  long long int A;
  cin >> A;
  string B;
  cin >> B;
  int C = F(B.at(0)) * 100 + F(B.at(2)) * 10 + F(B.at(3));
  long long int ans = A * C / 100;
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
map<ll,ll> mp;
ll ask(ll n){
    if(mp.count(n))return mp[n];

    cout<<n<<endl;
    string s;cin>>s;
    if(s=="Vacant")exit(0);
    return mp[n]=(s=="Male");
}
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll s=0,e=n-1;
    while(e-s>=2){
        ll m=(s+e)>>1;
        if( (ask(m)^(m%2)) != (ask(s)^(s%2)) )e=m;
        else s=m;
    }
    for(ll i=s;i<=e;i++)ask(i);
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const int N = 1000000;
int lp[N+1];
vector<int> pr;


//O(n) 
void sieve() 
{ 
   
    for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }

} 

ll pres[1000001];
void solve(){
    ll n;
    cin >> n;
    ll a[n];
    ll g = 0;
    fo(i, n){
        cin >> a[i];
        g = __gcd(a[i], g);
        pres[a[i]]++;
    }
    if(g != 1){
        cout << "not coprime" << nl;
        return;
    }
    ll mx = *max_element(a, a+ n);
    bool pwcp = true; 
    for(ll k : pr){
        //cout << k << nl;
        if(k > mx)break;
        ll c = 0;
        for(ll j = k; j <= mx; j += k){
            c += pres[j];
        }
        if(c > 1){
            pwcp = false;
            break;
        }
    }
    if(pwcp){
        cout << "pairwise coprime\n";
    }
    else{
        cout << "setwise coprime\n";
    }
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    sieve();
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
    

Measured memory_bytes: 23460
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

string list[24] = {"012345","024135","031425","043215","103254","120534","135024","152304","201453","215043","240513","254103","304152","310542","345012","351402","402351","425031","430521","453201","513240","521430","534120","542310"};

bool used[8];
vector<string> data(8);
vector<string> puzzle(8);

// TOP FRONT RIGHT LEFT BACK BOTTOM 

int connect[8][8] = {
	{-1},
	{0,3,-1},
	{1,1,-1},
	{0,1,2,2,-1},
	{0,5,-1},
	{1,5,4,3,-1},
	{2,5,5,1,-1},
	{3,5,4,1,6,2,-1}
};
bool ok(char a,char b){
	return a != b && (a&~32) == (b&~32);
}

bool backTrack(int s){
	if(s == 8){
		//for(int i = 0 ; i < 8 ; i++)
		//	cout << "[" << puzzle[i].dice << "]"  << endl;
		return true;
	}
	for(int d = 0 ; d < 8 ; d++){
		if(used[d] != 0) continue;
		used[d] = true;
		puzzle[s] = data[d];
		for(int i = 0 ; i < 24 ; i++){
			for(int j = 0 ; j < 6 ; j++){
				puzzle[s][j] = data[d][list[i][j]]	;
			}
			bool f = true;
			for(int j = 0 ; ~connect[s][j] ; j += 2){
				int pos  = connect[s][j];
				int face = connect[s][j+1];
				if(!ok(puzzle[pos][5-face], puzzle[s][face])){
					f = false;
				}
			}
			if(f)if(backTrack(s+1))return true;
		}
		used[d] = false;
	}
	return false;
}
int main(){
	for(int i = 0 ; i < 24 ; i++)
		for(int j = 0 ; j < 6 ; j++)
			list[i][j] -= '0';
	while(1){
		string str;
		for(int i = 0 ; i < 8 ; i++){
			if(cin >> str , str == "0") return 0;
			data[i] = str;
			used[i] = 0;
		}

		cout << (backTrack(0)?"YES":"NO") << endl;
	}
}

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

int A, B, C, D;

int main() {
  cin >> A >> B >> C >> D;
  int ans = 0;
  bool a = false, b = false;
  rep(i, 101) {
    a = (A <= i && i <= B);
    b = (C <= i && i <= D);
    if (a & b) ans++;
  }
  if (ans != 0) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S;
  cin>>S;
  int N=S.size();
  int m=1000;
  for(int i=0;i<=N-3;i++){
    char a=S[i]-'0';
    char b=S[i+1]-'0';
    char c=S[i+2]-'0';
    int K=100*a+10*b+c;
    m=min(m,abs(K-753));
  }
  cout<<m;
return 0;}


Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

string a;
int sum=0,n,max1=0;

int main()
{
   cin>>n>>a;
   for(int i=0;i<n;i++)
   {
       if(a[i]=='I')
            sum++;
             if(sum>=max1)
                max1=sum;

       if(a[i]=='D')
          sum--;

   }
   cout<<max1;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cmath>
const long long mod=1e9+7;
using namespace std;
long long n,a[100001],sum;
long long po(long long a,long long b){
	long long c=1;
	while(b){
		if(b&1) c=(c*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return c%mod;
}
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	//for(int i=1;i<=n;i++) printf("%d ",a[i]);
	//printf("\n");
	if(n&1){
		if(a[1]){
			printf("%d\n",0);
			return 0;
		}
		else{
			sum=0;
			for(int i=2;i<=n;i++){
				if(!(i&1)) sum+=2;
				//printf("%d ",sum);
				//printf("\n");
				if(a[i]!=sum){
					printf("%d\n",0);
					return 0;
				}
			}
			printf("%lld\n",po((long long)2,(long long)(n-1)>>1)%mod);
			return 0;
		}
	}
	else{
		sum=-1;
		for(int i=1;i<=n;i++){
			if(!((i-1)&1)) sum+=2;
			//printf("%d ",sum);
			//printf("\n");
			if(a[i]!=sum){
				printf("%d\n",0);
				return 0;
			}
		}
		printf("%lld\n",po((long long)2,(long long)n>>1)%mod);
		return 0;
	}
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;
const ll linf = 1e18;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x; cin >> x;
  bool found = 0;
  while(!found) {
    bool primeornot = 1;
    for(int i = 2; i * i <= x; i++) {
      if(x % i == 0) {
        primeornot = 0;
      }
    }
    if(primeornot) {
      found = 1;
    }
    x++;
  }
  cout << x - 1 << endl;
}

Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main()
{
int N,Y;
cin>>N>>Y;
for(int x=0;x<=Y/10000;x++)
  for(int y=0;y<=(Y-x*10000)/5000;y++)
  {
  int z=N-x-y;
  if(z>=0 and x*10000+y*5000+z*1000==Y)
     {cout<<x<<" "<<y<<" "<<z;
      return 0;
      }
   }
cout<<"-1 -1 -1";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int l, r, d, ans = 0;
    cin>>l>>r>>d;
    f(i, l, r+1) ans += (i%d == 0);
    cout<<ans;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________

	int n, m;
	cin >> n >> m;
	int a[m];
	int ans = 0;
	int flag = 0;
	zip(i, 0, m)
	{
		cin >> a[i];
		n = n - a[i];
	}
	if (n < 0)
	{
		cout << -1 << en;
	}
	else
	{
		cout << n << en;
	}


	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a;i < n;i++)
#define INF 1e9
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin >> s;
	
	ll cnt = 0,wcnt = 0;
	rep(i,0,s.size()){
		if(s[i] == 'W'){
			cnt += abs(wcnt - i);
			wcnt++;
		}
	}
	
	cout << cnt << endl;
	return 0;
}

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

#define EPS 1e-10

class point {
public:
	double x, y;
	point() {}
	point( double x_, double y_ ) : x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); }
	point operator +( point p ) { return point( x + p.x, y + p.y ); }
	point operator *( double a ) { return point( x * a, y * a ); }
};

class segment {
public:
	point p1, p2;
	segment() {}
};

double dot( point a, point b ) { return a.x * b.x + a.y * b.y; }
double cross( point a, point b ) { return a.x * b.y - a.y * b.x; }
double norm( point a ) { return a.x * a.x + a.y * a.y; }

double distance( segment s, point p )
{
	if( dot( s.p2 - s.p1, p - s.p1 ) < 0 ) return sqrt( norm( p - s.p1 ) );
	if( dot( s.p1 - s.p2, p - s.p2 ) < 0 ) return sqrt( norm( p - s.p2 ) );;
	return fabs( cross( s.p2 - s.p1, p - s.p1 ) / sqrt( norm( s.p2 - s.p1 ) ) );
}

int ccw( point p0, point p1, point p2 )
{
	point v1 = p1 - p0;
	point v2 = p2 - p0;
	if( cross( v1, v2 ) > EPS ) return 1;
	if( cross( v1, v2 ) < -EPS ) return -1;
	if( dot( v1, v2 ) < -EPS ) return 2;
	if( norm( v1 ) < norm( v2 ) ) return -2;
	return 0;
}

bool intersect( segment s1, segment s2 )
{
	return ccw( s1.p1, s1.p2, s2.p1 ) * ccw( s1.p1, s1.p2, s2.p2 ) <= 0 &&
			ccw( s2.p1, s2.p2, s1.p1 ) * ccw( s2.p1, s2.p2, s1.p2 ) <= 0;
}

double distance( segment s1, segment s2 )
{
	if( intersect( s1, s2 ) ) return 0;
	return min( { distance( s1, s2.p1 ), distance( s1, s2.p2 ),
					distance( s2, s1.p1 ), distance( s2, s1.p2 ) } );
}

point cpoint( segment s1, segment s2 )
{
	point base = s2.p2 - s2.p1;
	double d1 = fabs( cross( base, s1.p1 - s2.p1 ) );
	double d2 = fabs( cross( base, s1.p2 - s2.p1 ) );
	double t = d1 / (d1 + d2 );
	return s1.p1 + ( s1.p2 - s1.p1 ) * t;
}

int main()
{
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		segment s1, s2;
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		point ans = cpoint( s1, s2 );

		cout << fixed << setprecision(10) << ans.x << " " << ans.y << endl;
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=2;i<(int)n;i++)
long long n;
int main(void){
    cin>>n;
    long long m = sqrt(n);
    long long ans = n-1;
    rep(i,m+1){
        if(n%i==0)ans=min(ans,i+n/i-2);
    }
    cout<<ans<<endl;
}

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

def function(n,x,list):
  count = 1
  position = 0
  for l in list:
    position += l
    
    if position > x:
      break
    count += 1
   
  return count

print(function(n,x,l))

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int h, w, a, b; cin>>h>>w>>a>>b;
    vector<vector<int>> ans(h, vector<int>(w, 0));

    for(int i=0; i<b; i++){
        for(int j=a; j<w; j++){
            ans[i][j] = 1;
        }
    }

    for(int i=b; i<h; i++){
        for(int j=0; j<a; j++){
            ans[i][j] = 1;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    cout << n - k + 1 << endl;

    return 0;
}

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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define DFor(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define read() Read<int>()

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;
	inline void flush(){fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<typename T >inline T Read() {
		T _ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __=getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		return _ *= ___;
	}
	template<typename T>inline void write(T _, char __ = '\n') {
		if(!_) *nowps ++ = '0';
		if(_ < 0) *nowps ++ = '-', _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; *nowps ++ = sta[tp --] ^ 48); 
		(*nowps ++) = __;
	}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;
ll n, m;
char S[N], T[N];
map <ll, char> F;
ll gcd(ll x,ll y) {return !y ? x : gcd(y, x % y);}
int main() {
	//file("A");
	scanf("%lld%lld",&n,&m);
	scanf("%s%s",S,T);
	ll lcm = n * m / gcd(n, m);
	bool flag = 0;
	for(ll i = 0;i < n;++i) {
		ll now = 1ll * i * lcm / n + 1;
		if(F[now] && F[now] != S[i]) {flag = 1;break;}
		else F[now] = S[i];
	}
	if(flag) return puts("-1"),0;
	for(ll i = 0;i < m;++i) {
		ll now = 1ll * i * lcm / m + 1;
		if(F[now] && F[now] != T[i]) {flag = 1;break;}
		else F[now] = T[i];
	}
	if(flag) return puts("-1"),0;
	printf("%lld\n",lcm);
	return flush(), 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    string S, T; cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) cnt++; 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(x:a) cin>>x;
  if(N%2!=0){
    a.push_back(0);
    N++;
  }
  int ans=0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<N;i+=2){
    ans+=a[i]-a[i+1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def gcd(a, b): 
    if a == 0 :
        return b 
    return gcd(b%a, a)
for _ in range(int(input())):
    a,b,c,d=[int(x) for x in input().split()]
    if a<b:
        print("No")
        continue
    if d<b:
        print("No")
        continue
    if b<=c:
        print("Yes")
        continue
    g=gcd(b,d)
    if c>=b-g+a%g:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    ll n,k;
    cin>>n>>k;
    ll A[n];
    loop(i,0,n){
        cin>>A[i];
    }
    ll cost[n] = {0};
    cost[1] = abs(A[1]-A[0]);
    loop(i,2,n){
        cost[i] = LONG_MAX;
        loop(j,1,k+1){
            if(i-j < 0){
                break;
            }
            cost[i] = min(cost[i], cost[i-j] + abs(A[i-j]-A[i]));
        }
    }
    cout<<cost[n-1]<<endl;
    return 0;
}

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

const int M = 1e9+7;
int fact[2000055] , inv[2000055];

int __power(int x , int p) {
	int res = 1;
	while(p) {
		if(p & 1) res = (res * x)%M;
		p /= 2;
		x = (x * x)%M;
	}
	return res;
}

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

	fact[0] = fact[1] = 1;
	for(int i = 2; i < 2000055; i++) fact[i] = (i * fact[i-1])%M;
	inv[2000054] = __power(fact[2000054] , M-2);
	for(int i = 2000053; i >= 0; i--) inv[i] = (inv[i+1] * (i+1))%M; 
	int r1 , r2 , c1 , c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = 0;
	for(int i = c1; i <= c2; i++) {
		int val1 = (fact[r2+i+1] * inv[r2])%M , val2 = (fact[r1+i] * inv[r1-1])%M;
		val1 = (val1 * inv[i+1])%M;
		val2 = (val2 * inv[i+1])%M;
		ans = (ans + (val1 - val2 + M)%M)%M;
	}
	cout << ans << "\n";
	
    return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s =="Sunny"){
    cout << "Cloudy" <<endl;
  }
  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int n;

int main()
{
    cin>>n;
    ll sum=0;
    loop(i,1,n+1){
        if(i%3!=0 and i%5!=0){
            sum+=i;
            // cout<<i<<endl;
        }
    }

    cout<<sum<<endl;
    return 0;

}




Measured memory_bytes: 3620
N = int(input())
C = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for _ in range(N):
    S = input()
    C[S] += 1

for t in ('AC', 'WA', 'TLE', 'RE'):
    print(t, ' x ', C[t])


Measured memory_bytes: 9180