akhauriyash/Code-Regression huggingface dataset:
while True:
    (H,W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        if hc == 0 or hc == H -1:
            print("#" * W)
        else:
            print("#" + "." * (W-2) + "#")
    print()

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

using namespace std;

long long n, m, k;

int main()
{
    cin >> n >> m >> k;
    long long ans = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            ans = i * m + j * n - i * j * 2;
            //cout << i << " " << j <<  "   " << ans << endl;
            if(ans == k){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[21],ans;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
    cin>>a[i];
for(ll i=1;i<n-1;i++)
if(a[i]>a[i-1]&&a[i]<a[i+1]){
    ans++;
}else if(a[i]<a[i-1]&&a[i]>a[i+1]){
ans++;
}
cout<<ans<<endl;
}


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

#define MAX 2000000000

int main()
{
	int i, j;
	int n, num;

	while (cin>>n) {
		if (n == 0) break;
		num = 0;
		j = 1;
		for (i = 0; i < 9; i++) {
			j *= 5;
			num += n/j;
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def resolve():
    a,b,c = map(int, input().split())
    k=int(input())
    while True:
        if a<b and b<c:
            print("Yes")
            break
        elif k==0:
            print("No")
            break
        elif a>=b:
            b*=2
            k-=1
        elif b>=c:
            c*=2
            k-=1
resolve()

Measured memory_bytes: 61728
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,m;
  cin >> n >> m;
  if(n == m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
double A[200000];
ll a[200000];

// b/c
ll b[200000], c[200000];

const ll M = 1e9;
const double eps = 0.1;

template <typename T>
T gcd(T a, T b) {
	if (a < b) swap(a, b);
		while (b != 0) {
			T tmp = b;
			b = a % b;
			a = tmp;
		}
	return a;
}

map<P, int> mp;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    ll cnt_z = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        a[i] = (ll)(A[i]*M+eps);
        ll g = gcd<ll>(a[i], M);
        b[i] = a[i]/g;
        c[i] = M/g;
        if(c[i] == 1) cnt_z++;
        int cnt2 = 0, cnt5 = 0;
        ll b_ = b[i];
        while(b_%2 == 0){
            cnt2++;
            b_ /= 2;
        }
        while(b_%5 == 0){
            cnt5++;
            b_ /= 5;
        }
        ll c_ = c[i];
        while(c_%2 == 0){
            cnt2--;
            c_ /= 2;
        }
        while(c_%5 == 0){
            cnt5--;
            c_ /= 5;
        }
        P p = P(cnt2, cnt5);
        if(mp.count(p) == 0) mp[p] = 1;
        else mp[p]++;
    }
    ll ans = 0;
    for(auto i : mp){
        for(auto j : mp){
            P p1 = i.first;
            P p2 = j.first;
            ll c1 = i.second;
            ll c2 = j.second;
            if((p1.first+p2.first >= 0) && (p1.second+p2.second >= 0)) ans += c1*c2;
        }
    }
    ans -= cnt_z;
    cout << ans/2 << endl;
}

Measured memory_bytes: 9920
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
long long t[1002],a[1002];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&t[i],&a[i]);
		if(t[i]>=t[i-1]&&a[i]>=a[i-1])continue;
		else
		{
			long long bt=t[i-1]/t[i],ba=a[i-1]/a[i],b;
			if(t[i-1]%t[i])bt++;
			if(a[i-1]%a[i])ba++;
			b=max(bt,ba);
			t[i]*=b;
			a[i]*=b;
		}
	}
	printf("%lld",a[n]+t[n]);
	//return 0;
}

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

using namespace std;


typedef long long ll;
const ll maxn=1e5;
string str[maxn];
int idex;
void solve(string a ){
	int len=a.length();
	for(int i=0;i<len-2;i++){
		if(a[i]=='A'&&a[i+1]=='B') idex++;
	}
}
int main()
{
	int n;
	cin>>n;
	idex=0;
	int ta=0,tb=0;
	int ans;
	int res=0;
	for(int i=0;i<n;i++){
		cin>>str[i];
		int len=str[i].length();
		if(str[i][0]=='B') tb++;
		if(str[i][len-1]=='A') ta++;
		if(str[i][0]=='B'||str[i][len-1]=='A') res+=1;
 	}
	for(int i=0;i<n;i++){
		solve(str[i]);
	}	
	if(res==0) ans=min(ta,tb); 
	else ans=min(min(ta,tb),res-1);
	idex+=ans;
	cout<<idex<<endl;
	return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  set<int> s, t, ans;
  for (int i = a; i < b; i++) {
    s.insert(i);
  }
  for (int i = c; i < d; i++) {
    t.insert(i);
  }
  set_intersection(s.begin(), s.end(), t.begin(), t.end(), inserter(ans, ans.end()));
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define MOD 1000000007
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define FOR(a,n) for(int i=a;i<n;++i)
#define arrin(n) for(int i=0; i < n; ++i) cin>>arr[i];
#define arrout(n) for(int i=0; i < n; ++i) cout<<arr[i]<<" ";cout<<nl;
#define nl "\n"
#define mp make_pair
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;


int main(){  
	fastio();
	int a,b,c;
  cin>>a>>b>>c;
  cout<<(a^b^c);
  return 0;
}	



  

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    imfor(i, n) {
        int a;
        cin >> a;
        if (mp.find(a) == mp.end()) {
            mp[a] = 1;
        }
        else {
            mp[a] += 1;
        }
    }
    int f = true;
    int checkVal = n - 1;
    while (checkVal >= 0) {
        if (checkVal == 0) {
            if (mp[checkVal] != 1) {
                f = false;
            }
        }
        else {
            if (mp[checkVal] != 2) {
                f = false;
            }
        }
        checkVal -= 2;
    }
    if (f) {
        int ans = 1;
        if (n % 2 == 0) {
            for (int i = 0; i < n / 2; i++) {
                ans = (ans * 2) % MOD;
            }
        }
        else {
            for (int i = 0; i < (n - 1) / 2; i++) {
                ans = (ans * 2) % MOD;
            }
        }
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<utility>
#include<queue>
using namespace std;
int main(){
  int n,q,time,cnt_time = 0;
  string name;
  queue<pair<string,int> > que;
  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin >> name >> time;
    que.push(make_pair(name,time));
  }
  while(!que.empty()){
    pair<string,int> top = que.front();
    que.pop();
    if(top.second <= q){
      cnt_time += top.second;
      cout << top.first << " " << cnt_time << endl;
    }else{
      cnt_time += q;
      que.push(make_pair(top.first,top.second-q));
    }
  }
}



Measured memory_bytes: 6320
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-19 20:38:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  int n, m; cin >> n >> m;
  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

class dice{
	private:
		int top;
		int front;
		int right;
		int left;
		int back;
		int bottom;
	public:
		dice();
		dice(int top,int front,int right,int left,int back,int bottom);
		void roll(char ch);
		//void changstatus(side new_top,side new_front);
		int gettop();
		int getfront();
		int getright();
		int getleft();
		int getback();
		int getbottom();
		int compare(dice another_dice);
		void getallsides();
};

dice::dice(){
	this->top = 1;
	this->front = 2;
	this->right = 3;
	this->left = 4;
	this->back = 5;
	this->bottom = 6;

}

dice::dice(int top,int front,int right,int left,int back,int bottom){
	this->top=top;
	this->front=front;
	this->right=right;
	this->left=left;
	this->back=back;
	this->bottom=bottom;
}

void dice::roll(char ch){
	int temp;
	switch (ch){
		case 'E':
			temp = this->top;
			this->top = left;
			this->left = bottom;
			this->bottom = right;
			this->right = temp;
			break;
		case 'W':
			temp = this->top;
			this->top = right;
			this->right = bottom;
			this->bottom = left;
			this->left = temp;
			break;
		case 'S':
			temp = this->top;
			this->top = back;
			this->back = bottom;
			this->bottom = front;
			this->front = temp;
			break;
		case 'N':
			temp = this->top;
			this->top = front;
			this->front = bottom;
			this->bottom = back;
			this->back = temp;
			break;
	}
}

void dice::getallsides(){
	cout << top << " "<<front<<" "<<right<<" "<<left<<" "<<back<<" "<<bottom<<endl;
}

int dice::gettop(){
	return this->top;
}

int dice::getbottom(){
	return this->bottom;
}

int dice::getfront(){
	return this->front;
}

int dice::getback(){
	return this->back;
}

int dice::getleft(){
	return this->left;
}

int dice::getright(){
	return this->right;
}

int dice::compare(dice another_dice){
	string method[]={"","N","N","N","EN","WN"};
	string temp;
    bool flag;
    dice temp_dice=another_dice;
    
	flag = false;
	for(int i=0;i<6;i++){
		temp=method[i];
		if(i==4||i==5){
			temp_dice = another_dice;
		}		
		for(int j=0;j<temp.length();j++){
			temp_dice.roll(temp[j]);
		}

		for(int j=0;j<4;j++){
			temp_dice.roll('E');
			//temp_dice.getallsides();
			if(this->gettop()==temp_dice.gettop()&&
			   this->getfront()==temp_dice.getfront()&&
			   this->getright()==temp_dice.getright()&&
			   this->getleft()==temp_dice.getleft()&&
			   this->getback()==temp_dice.getback()&&
			   this->getbottom()==temp_dice.getbottom()){
				flag = true;
				break;
			}
		}

		if (flag==true){
			return 1;
		}
	}

	return -1;
	
}


int main(){

	int top,front,right,left,back,bottom;
	dice dice1,dice2;

	cin >>top>>front>>right>>left>>back>>bottom;
	dice1 = dice(top,front,right,left,back,bottom);
	cin >>top>>front>>right>>left>>back>>bottom;
	dice2 = dice(top,front,right,left,back,bottom);
	
	if(dice1.compare(dice2)==1){
		cout<<"Yes"<<endl;
	}	
	else{
		cout<<"No"<<endl;
	}



	return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>
const int N=1e5+10;
int main(){
    int n,a[N],now[N],k,to,temp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        now[i]=0;
        scanf("%d",&a[i]);
    }
    scanf("%d",&n);
    while(n--){
        scanf("%d%d%d",&k,&to,&temp);
        if(k==1){
            if(now[to]+temp>a[to]){
                printf("%d\n",to);
                return 0;
            }
            else now[to]+=temp;
        }
        else{
            if(now[to]<temp){
                printf("%d\n",to);
                return 0;
            }
            else now[to]-=temp;
        }
    }
    printf("0\n");
}


Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define en           "\n" 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

const int maxn = 2e5 + 4;
int a[maxn+4];

void solve()
{
    int n;rd(n);
    fo(i,1,n-1){
        int x;cin>>x;
        x--;
        a[x]++;
    }
    show(a,n);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio;

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

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

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

using namespace std;
#define ll long long
int N;
int A[20], x[20][20], y[20][20];

int counter(int x) {
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}


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

    cin >> N;
    int res = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    for (int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            if (!(bits & (1 << i))) continue;
            for (int j = 0; j < A[i]; j++) {
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if (ok) {
            res = max(res, counter(bits));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
S=list(input())
flag=0
for i in range(len(S)):
    if i%2==0:
        if S[i]=="L":
            flag=1
            break
    elif i%2==1:
        if S[i]=="R":
            flag=1
            break

if flag==1:
    print("No")
elif flag==0:
    print("Yes")


Measured memory_bytes: 2940
n, x, y = map(int, input().split())
ans = [0 for _ in range(n-1)]
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-i, abs(x-i) + abs(y-j) + 1)
        ans[d-1] += 1

print(*ans, sep='\n')

Measured memory_bytes: 45660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, left, right, result;
  cin >> N;
  
  result = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> left >> right;
  	result += (right - left + 1);
  }
  cout << result << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int a, b; cin >> a >> b;
    if(a+b == 15) cout << '+' << endl;
    else if(a*b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

struct best{
    vector<ll> vals = vector<ll>(4);
};

vector<best> rowvals;

vector<vector<ll>> grid;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int r,c,n; cin >> r >> c >> n;
    rowvals.resize(r+1);
    grid.resize(r+1,vector<ll>(c+1));
    FOR(i,n){
        int x,y,v; cin >> x >> y >> v;
        grid[x][y] = v;
    }
    F0R(j,1,c) F0R(i,1,r){
        rowvals[i].vals[0] = max(rowvals[i].vals[0],rowvals[i-1].vals[3]);
        for(int k = 3; k > 0; k--) rowvals[i].vals[k] = max(rowvals[i].vals[k],rowvals[i].vals[k-1]+grid[i][j]);
        F0R(k,1,3) rowvals[i].vals[k] = max(rowvals[i].vals[k],rowvals[i].vals[k-1]);
    }
    cout << rowvals[r].vals[3] << "\n";
    return 0;
}


Measured memory_bytes: 73736
N = int(input())
T = [[] for k in range(N)]
for k in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1].append([v-1,w])
    T[v-1].append([u-1,w])

kyori = [-1 for k in range(N)]
kyori[T[0][0][0]] = 0
que = [T[0][0][0]]

while len(que) > 0:
    now = que.pop()
    for tsugi in T[now]:
        if kyori[tsugi[0]] == -1:
            kyori[tsugi[0]] = kyori[now] + tsugi[1]
            que.append(tsugi[0])

for a in kyori:
    print(a%2)

Measured memory_bytes: 82080
import queue
k = int(input())

q = queue.Queue()
for i in range(1, 10):
    q.put(i)

for i in range(k):
    x = q.get()
    if i == k-1:
        print(x)
        break
    if x%10 != 0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+x%10)
    if x%10 != 9:
        q.put(10*x+(x%10)+1)


Measured memory_bytes: 18908
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    int n;string s;
    cin>>n>>s;
    int count=1;
    rep(i,n-1){
        if(s[i]!=s[i+1])count++;
    }
    cout<<count<<endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int n = 0; n < N; n++) {
		cin >> d.at(n);
	}
	for (int n = 0; n < N; n++) {
		for (int m = n + 1; m < N; m++) {
			if (d.at(n) < d.at(m)) {
				int t = d.at(n);
				d.at(n) = d.at(m);
				d.at(m) = t;
			}
		}
	}
	int answer = 1;
	for (int n = 1; n < N; n++) {
		if (d.at(n) < d.at(n - 1)) {
			answer++;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] counts = new int[26];
        while(scanner.hasNext()) {
            String word = scanner.nextLine().toLowerCase();
            for (int i = 0; i < word.length(); i++) {
                char c = word.charAt(i);
                if (97 <= c && c <= 122) {
                    counts[c - 97] += 1;
                }
            }
        }

        for (int i = 0; i < 26; i++) {
            char c = (char)(97 + i);
            System.out.printf("%c : %d\n", c, counts[i]);
        }
        
        scanner.close();
    }
}



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

#define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("agc018f.in","r",stdin);
	freopen("agc018f.out","w",stdout);
}

template<typename T>void read(T &_){
	T __=0,mul=1; char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')mul=-1;
		ch=getchar();
	}
	while(isdigit(ch))__=(__<<1)+(__<<3)+(ch^'0'),ch=getchar();
	_=__*mul;
}

const int maxn=3e5+10;
int n,f[maxn],g[maxn],sf[maxn],sg[maxn],rf,rg;
int beg[maxn],las[maxn<<1],to[maxn<<1],cnte=1;
int euler[maxn],cnt,ans[maxn];
bool vis[maxn<<1];

void add_edge(int u,int v){
	las[++cnte]=beg[u]; beg[u]=cnte; to[cnte]=v;
	las[++cnte]=beg[v]; beg[v]=cnte; to[cnte]=u;
}

int s[maxn],tp;
void dfs(int u){
	s[++tp]=u;
	for(int &i=beg[u];i;i=las[i]){
		if(vis[i/2])continue;
		vis[i/2]=1;
		dfs(to[i]);
	}
	euler[++cnt]=u;
}

int main(){
	//File();
	read(n);
	REP(i,1,n){
		read(f[i]);
		if(f[i]>0){
			++sf[f[i]];
			add_edge(f[i],i);
		}
		else rf=i;
	}
	REP(i,1,n){
		read(g[i]);
		g[i]+=n;
		if(g[i]>n){
			++sg[g[i]];
			add_edge(g[i],i+n);
		}
		else rg=i+n;
	}

	REP(i,1,n)if(sf[i]%2!=sg[i+n]%2)
		return puts("IMPOSSIBLE"),0;

	add_edge(rf,rg);
	REP(i,1,n)if(sf[i]%2==0)
		add_edge(i,i+n);

	dfs(1);
	//REP(i,1,cnt)cout<<euler[i]<<endl;
	//cout<<endl;
	REP(i,1,cnt-1)if(abs(euler[i]-euler[i+1])==n){
		int id=min(euler[i],euler[i+1]);
		if(sf[id]%2==1)continue;
		if(euler[i]<=n)ans[id]=1;
		else ans[id]=-1;
	}

	puts("POSSIBLE");
	REP(i,1,n)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 23936
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    int MaxIndex(IReadOnlyList<long> xs)
    {
        var max = long.MinValue;
        var maxIndex = 0;

        for (var i = 1; i < xs.Count; i++)
        {
            if (max < xs[i])
            {
                max = xs[i];
                maxIndex = i;
            }
        }

        return maxIndex;
    }

    public void Run()
    {
        var k = ReadLine(long.Parse)[0];
        const int N = 50;

        var m = k / N;
        var xs = Enumerable.Range(0, N).Select(i => i + m).ToArray();

        var l = (int)(k % N);
        for (var j = 0; j < l; j++)
        {
            for (var i = 0; i < N; i++)
            {
                if (i == j)
                {
                    xs[i] += N;
                }
                else
                {
                    xs[i]--;
                }
            }
        }

        WriteLineOne(N);
        WriteLineOne(string.Join(" ", xs));
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for (int i=0; i<N; i++) cin >> H[i];
  double min=1000;
  int ans = 0;

  for (int i=0; i<N; i++) {
    if (min > abs(A-(T-H[i]*0.006))) {
      min = abs(A-(T-H[i]*0.006));
      ans = i+1;
    }
  }
  cout << ans << endl;
}

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

int main() {
    char X;
    cin >> X;

    if(X == 'a' || X == 'i' || X == 'u' || X == 'e' || X == 'o'){
        cout << "vowel" << endl;
    }
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  ll sum=0,cnt=0;
  for(int i=1;i<=n;i++){
    sum+=i;
    if(sum>=n){cout<<i<<endl;return 0;}
    
  }
  return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "vector"
# define lowbit(x) (x&-x)

using namespace std;

const int maxm=3e5+10;

int N,M,Tree[maxm<<1],Ans[maxm];
vector<int> L[maxm],H[maxm];

inline void Update(int x,int Value){
	while(x<=M){
		Tree[x]+=Value;
		x+=lowbit(x);
	}
	return;
}

inline int Ask(int x){
	if(x>M) return 0;
	register int Result=0;
	while(x){
		Result+=Tree[x];
		x-=lowbit(x);
	}
	return Result;
}

int main(){
	register int i,j;
	int x,y;
	scanf("%d%d",&N,&M);
	for(i=1;i<=N;i++){
		scanf("%d%d",&x,&y);
		L[x].push_back(y);
	}
	for(i=1;i<=M;i++){
		for(j=i;j<=M;j+=i){
			H[j].push_back(i);
		}
	}
	for(i=1;i<=M;i++){
		for(j=0;j<L[i].size();j++){
			Update(i,1);
			Update(L[i][j]+1,-1);
		}
		for(j=0;j<H[i].size();j++){
			Ans[H[i][j]]+=Ask(i)-Ask(i+H[i][j]);
		}
	}
	for(i=1;i<=M;i++){
		printf("%d\n",Ans[i]);
	}
	return 0;
}

Measured memory_bytes: 27904
s=input()
s1=int(s[0:2])
s2=int(s[2:4])
if (0<=s1<=99 and 1<=s2<=12) and (0<=s2<=99 and 1<=s1<=12):
    print('AMBIGUOUS')
elif (0<=s1<=99 and 1<=s2<=12):
    print('YYMM')    
elif (0<=s2<=99 and 1<=s1<=12):
    print('MMYY')    
else:
    print('NA')        

Measured memory_bytes: 3060
#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>;

double TIME_LIMIT = 3;

//状態
struct STATE {
  int Type;
  int D;
  map<int, int> c;
  map<P, int> s;
};

struct SCHEDULE {
  vector<int> t;
  int current_day() {
    return t.size();
  }
  int type(int day) {
    return t[day-1];
  }
  int calc_score(STATE& state, int max_day) {
    int score = 0;
    int m_day = min(max_day, (int)t.size());
    map<int, int> last_day;
    for(int day=1;day<=m_day;day++) {
      int type = t[day-1];
      int ps = state.s[P(day, type)];
      int ng = 0;
      last_day[type] = day;
      for(int t=1;t<=state.Type;t++) {
        ng += state.c[t] * (day - last_day[t]);
      }
      score = score + ps - ng;

    }
    return score;
  }
  void held(int type) {
    t.push_back(type);
  }
};

// 状態の初期化
void init (STATE& state, SCHEDULE& schedule) {
  int Type = 26;

  int D;
  cin >> D;
  state.Type = 26;
  state.D = D;
  rep(i, Type) {
    int c_i;
    cin >> c_i;
    state.c[i + 1] = c_i;
  }
  rep(d, D) {
    rep(t, Type) {
      int s_dt;
      cin >> s_dt;
      state.s[P(d+1, t+1)] = s_dt;
    }
  }
}

int main() {
  STATE state;
  SCHEDULE schedule;
  init(state, schedule);

  // while (true) {
  //   if ((double)clock() / CLOCKS_PER_SEC > TIME_LIMIT) break;

  //   STATE new_state = state;
  //   modify(new_state);
  //   int new_score = calc_score(new_state);
  //   int pre_score = calc_score(state);

  //   if (new_score > pre_score) {
  //     state = new_state;
  //   }
  // }

  rep(i, state.D) {
    int type;
    cin >> type;
    schedule.held(type);
  }
  for(int day=1;day<=state.D;day++){
    cout << schedule.calc_score(state, day) << endl;
  }
  return 0;
}


Measured memory_bytes: 4192
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <stack>
#include <map>

const int MaxN = 1e5;
typedef long long LL;
using namespace std;

int n, d,x;
int a[105];

int main()
{
	cin >> n;
	cin >> d >> x;
	int y = 0;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		y++;
		for(int j = 1;j <= d + 5;j++)
		{
			if(j * a[i] + 1 <= d)
			{
				y++;
			}
			else break;
		}
	}
	cout << y +x<< endl;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f

typedef pair<int, int> P;

int f[200][10];
int p[200][20];

int main()
{
  // input
  int n;
  cin >> n;
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];
  int Max = INT_MIN;

  // find max
  // 10^2　通り　（１、０）
  rep(i, 1 << 10)
  {
    if (i == 0)
      continue;
    int ans = 0;
    rep(j, n)
    {
      int cnt = 0;
      rep(k, 10)
      {
        // 1 だったら
        if ((i >> k & 1) && f[j][k] == 1)
          cnt++;
      }
      // 利益
      ans += p[j][cnt];
    }
    // find max
    Max = max(Max, ans);
  }
  cout << Max << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

vll memo(2e5+10, 0);
vll c(2e5+10, 0);

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
} 

ll mod_inv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

const int MAX = 5e5+10;
const int MOD = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main()
{
    ll n, a, b; cin >> n >> a >> b;
    ll sum = modpow(2, n, 1e9+7) - 1;
    ll nca = 1, den = 1;
    for (int i = n - a + 1; i <= n; i++) nca = (nca * i) % MOD;
    for (int i = 1; i <= a; i++) den = (den * i) % MOD;
    sum = (sum - (nca * mod_inv(den, MOD)) % MOD + MOD) % MOD;
    ll ncb = 1; den = 1;
    for (int i = n - b + 1; i <= n; i++) ncb = (ncb * i) % MOD;
    for (int i = 1; i <= b; i++) den = (den * i) % MOD;
    sum = (sum - (ncb * mod_inv(den, MOD)) % MOD + MOD) % MOD;
    cout << (sum + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>
#include <ctype.h> //toupper case
#include <tuple>


using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
const ll W = 1000000007;
const int alphacount = 26;
const string atcoyes = "Yes";
const string atcono = "No";



void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
}

class Main{
public:
    
    int N,M;
    Main(){
        cin>>N>>M;
    }
    void run(){
        ll ans = (M * 1900LL + (N-M ) * 100 )  * pow(2.0 , M) ;
        cout<<ans<<endl;
    }
};

#ifndef gtest
int main(){
    omajinai();
    Main().run();
    return 0;
}
#endif


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

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut ab = vec![(0, 0); n];

    for i in 0..n {
        ab[i].1 = read::<i64>();
        ab[i].0 = read::<i64>();
    }
    ab.sort_by(|a, b| a.cmp(b));

    let mut cg :Vec<usize> = Vec::new();
    cg.push(0);
    for i in 1..n {
        if ab[i].0 != ab[i-1].0 {
            cg.push(i);
        }
    }
    cg.push(ab.len());

    let mut time = 0;
    for i in 1..cg.len() {
        for j in (cg[i-1]..cg[i]).rev() {
            time += ab[j].1;
            if time > ab[j].0 {
                println!("No");
                return;
            }
        }
    }

    println!("Yes");
}

Measured memory_bytes: 12540
N, T = map(int, input().split())

X = [[int(a) for a in input().split()] for i in range(N)]

min = 1001

for i in range(N):
    hako = X[i]
    if hako[1] <= T and hako[0] <= min:
        min = hako[0]

if min == 1001:
    print("TLE")
else:
    print(min)


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

import fileinput
import math

def main():

    for line in fileinput.input():
        W, H, x, y, r = map(int, line.strip().split())

        #if((x <= 0 or x >= W) or (y <= 0 or y >= H)):
        #    print('No')

        if((x-r) < 0 or (x+r) > W or (y-r) < 0 or (y+r) > H):
            print('No')
        else:
            print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 6536
var
  s:string;
  a,b,i:longint;
begin
  read(s); 
  for i:=1 to length(s) do
    if s[i]='Z'then b:=i;
  for i:=length(s) downto 1 do
    if s[i]='A'then a:=i;
  writeln(b-a+1);
 end.

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> Pn(N);

  int count = 0;
  int min = 200000;
  for (int i=0; i<N; ++i)
  {
    std::cin >> Pn[i];
    if (Pn[i] <= min)
    {
      min = Pn[i];
      count++;
    }
  }

  std::cout << count;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 1000000

int main(){
  int i, j, n, q, count=0, S[MAX],T[MAX], r=0;

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

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

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
      if(S[i] == T[j]) {
	count++;
        if(r < S[i]){
          r = S[i];
            }
        break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2096
#include <stdio.h>
#define MOD 2019
#define NUM


int main(void)
{
    
    long long int a,b,i,j,L,R;
    scanf("%lld%lld",&L,&R);
    
    b=2020;
    for(i=L;i<=(R-1);i++){
        if(i%MOD==0){
            printf("0\n");
            return 0;
        }
        for(j=(i+1);j<=R;j++){
            if(j%MOD==0){
                printf("0\n");
                return 0;
            }
            a=(i*j)%MOD;
            if(a<b)
                b=a;
        }
    }
   
    printf("%lld\n",b);
    return 0;
}

Measured memory_bytes: 128
n = int(raw_input())

t = ['AC', 'WA', 'TLE', 'RE']
d = {}
for _ in xrange(n):
    s = raw_input()
    d[s] = d.get(s, 0) + 1
for k in t:
    print '%s x %d' % (k, d.get(k, 0))

Measured memory_bytes: 84920
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int m, d;
 
bool read() {
    if (!(cin >> m >> d))
        return false;
 
    return true;
}
 
void solve() {
    int ans = 0;

    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= d; ++j)
            if (j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i)
                ++ans;

    cout << ans << endl;
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    while (read())
        solve();
 
    return 0;
}
 


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int64_t a, b, k;
	std::cin >> a >> b >> k;
	int64_t min = std::min(k, a);
	a -= min;
	k -= min;
	if (k) b = std::max<int64_t> (0, b - k);
	std::cout << a << " " << b << std::endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){
    long D,T,S;
    std::cin >> D >> T >> S;
    if(T*S>=D){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3128
import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

S=input()
xlist=[]
for i in range(len(S)-2):
    X=int(S[i])*100+int(S[i+1])*10+int(S[i+2])
    xlist.append(X)

print(abs(getNearestValue(xlist,753)-753))


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

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

    cout << max(2 * A - 1, max(2 * B - 1, A + B)) << '\n';

    return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 3007;

int f[MX][MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            f[i][j] = max(f[i - 1][j], f[i][j - 1]);
            if (s[i - 1] == t[j - 1]) {
                f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
            }
        }
    }

    int x = n, y = m;
    string res;
    while (x > 0 && y > 0) {
        if (f[x][y] == f[x - 1][y]) {
            x--;
        } else if (f[x][y] == f[x][y - 1]) {
            y--;
        } else {
            res += s[x - 1];
            x--;
            y--;
        }
    }

    reverse(res.begin(), res.end());

    cout << res << "\n";
    return 0;
}



Measured memory_bytes: 35584
#include<iostream>
using namespace std;
int main()
{
    int n;
    int g,s;
    cin>>n;
    g=n%10;
    s=n/10;
    if (g==9||s==9)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n ;
  string s;
  cin >> n >> s;
  int left = 0, right = n - 1;
  int res = 0;
  while(left < right) {
      while(left < right && s[left] == 'R') left++;
      while(left < right && s[right] == 'W') right--;
      if(left != right) res++;
      left++;
      right--;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <stdio.h> 
 
int main() {
  int x,i,n;
 
  scanf("%d",&n);
   
  for(i=1; i<=n; i++) {
    x = i;
     
    if(x %3 == 0) {
      printf(" %d",i);
    } else if(x % 10 == 3) {
      printf(" %d",i);
    } else { 
      while(x != 0) {
    x /=10;
    if(x % 10 == 3) {
      printf(" %d",i);
      break;
    }
      }
    }
     
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2072
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}



int main()
{
	char c;

	cin >> c;

	cout << (char)(c + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) *min_element(ALL((vec)))
#define MAX(vec) *max_element(ALL((vec)))
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define zero_pad(num) setfill('0') << std::right << setw(num)

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);
int sum_digit(int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int N;
    cin >> N;
    int f_N = sum_digit(N);
    if (N % f_N == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') REP(i, vec.size()) vec.at(i) += num;
    else if (ch == '-') REP(i, vec.size()) vec.at(i) -= num;
    else if (ch == '*') REP(i, vec.size()) vec.at(i) *= num;
    else if (ch == '/') REP(i, vec.size()) vec.at(i) /= num;
    else if (ch == '%') REP(i, vec.size()) vec.at(i) %= num;
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int sum_digit(int num) {
    int sum = 0;
    while (num > 0) {
        sum += num%10;
        num /= 10;
    }
    return sum;
}


Measured memory_bytes: 768
#include <iostream>

int main(){
  int i, j;
  std::cin >> i >> j;
  int ans;
  if(i+j<i-j)
    ans = i-j;
  else
    ans = i+j;
  if(ans<i*j)
    ans = i*j;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define P 1000000007
#define N_MAX 200001

using namespace std;

long inv[N_MAX];
long fac[N_MAX];
long finv[N_MAX];

void init(){
    inv[0] = 1;
    fac[0] = 1;
    finv[0] = 1;
    inv[1] = 1;
    fac[1] = 1;
    finv[1] = 1;
    for(int i = 2; i < N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

long comb(int n, int m){
    long ans;
    ans = fac[n]*finv[m];
    ans %= P;
    ans *= finv[n-m];
    ans %= P;
    return ans;
}

int main(){
    init();
    int N, M, K;
    cin >> N >> M >> K;
    long sum = 0;
    for(long i = 1; i <= N; i++){
        for(long j = 1; j <= M; j++){
            long a = (i*(i-1)+(N-i)*(N-i+1))/2;
            long b = (j*(j-1)+(M-j)*(M-j+1))/2;
            a *= M;
            b *= N;
            sum += ((a%P)+(b%P));
            sum %= P;
        }
    }
    
    sum *= inv[2];
    sum %= P;
    long cmb = comb(N*M-2, K-2);
    long ans = sum*cmb;
    ans %= P;
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		StringBuffer s;
		
		while (true) {
			n = sc.nextInt();
			if (n == -1) {
				break;
			}
			
			s = new StringBuffer("");
			while (true) {
				s.append(Integer.toString(n % 4));
				n /= 4;
				if (n == 0) {
					break;
				}
			}
			System.out.println(s.reverse());
		}
	}
}

Measured memory_bytes: 12000