akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N; cin >> N;
	vector<ld> xmin(3, 1e9), xmax(3, -1e9), ymin(3, 1e9), ymax(3, -1e9);
	for(int i=0; i<N; ++i){
	    ld p, q;
	    char D;
	    cin >> p >> q >> D;
	    if(D=='R'){
	        xmin[2]=min(xmin[2], p);
	        xmax[2]=max(xmax[2], p);
	        ymin[1]=min(ymin[1], q);
	        ymax[1]=max(ymax[1], q);
	    }
	    if(D=='L'){
	        xmin[0]=min(xmin[0], p);
	        xmax[0]=max(xmax[0], p);
	        ymin[1]=min(ymin[1], q);
	        ymax[1]=max(ymax[1], q);
	    }
	    if(D=='U'){
	        xmin[1]=min(xmin[1], p);
	        xmax[1]=max(xmax[1], p);
	        ymin[2]=min(ymin[2], q);
	        ymax[2]=max(ymax[2], q);
	    }
	    if(D=='D'){
	        xmin[1]=min(xmin[1], p);
	        xmax[1]=max(xmax[1], p);
	        ymin[0]=min(ymin[0], q);
	        ymax[0]=max(ymax[0], q);
	    }
	}
	vector<ld> cand;
	cand.push_back(0.0);
	if(xmin[1]<xmin[0] && xmin[0]<1e9) cand.push_back(xmin[0]-xmin[1]);
	if(xmin[2]<xmin[1] && xmin[1]<1e9) cand.push_back(xmin[1]-xmin[2]);
	if(xmin[2]<xmin[0] && xmin[0]<1e9) cand.push_back((xmin[0]-xmin[2])/2);
	if(xmax[1]<xmax[0] && xmax[1]>-1e9) cand.push_back(xmax[0]-xmax[1]);
	if(xmax[2]<xmax[1] && xmin[2]>-1e9) cand.push_back(xmax[1]-xmax[2]);
	if(xmax[2]<xmax[0] && xmin[2]>-1e9) cand.push_back((xmax[0]-xmax[2])/2);
	if(ymin[1]<ymin[0] && ymin[0]<1e9) cand.push_back(ymin[0]-ymin[1]);
	if(ymin[2]<ymin[1] && ymin[1]<1e9) cand.push_back(ymin[1]-ymin[2]);
	if(ymin[2]<ymin[0] && ymin[0]<1e9) cand.push_back((ymin[0]-ymin[2])/2);
	if(ymax[1]<ymax[0] && ymax[1]>-1e9) cand.push_back(ymax[0]-ymax[1]);
	if(ymax[2]<ymax[1] && ymin[2]>-1e9) cand.push_back(ymax[1]-ymax[2]);
	if(ymax[2]<ymax[0] && ymin[2]>-1e9) cand.push_back((ymax[0]-ymax[2])/2);
	ld ans=1e18;
	for(int i=0; i<cand.size(); ++i){
	    ld XMIN, XMAX, YMIN, YMAX, t=cand[i];
	    XMIN=min(xmin[0]-t, min(xmin[1], xmin[2]+t));
	    XMAX=max(xmax[0]-t, max(xmax[1], xmax[2]+t));
	    YMIN=min(ymin[0]-t, min(ymin[1], ymin[2]+t));
	    YMAX=max(ymax[0]-t, max(ymax[1], ymax[2]+t));
	    ans=min(ans, (XMAX-XMIN)*(YMAX-YMIN));
	}
	cout << setprecision(15) << ans << endl;
	return 0;
}


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

using namespace std;
int main(void)
{
    string n;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n.size(); i++){
        sum += stoi(n.substr(i,1));
    }

    int a = stoi(n);
    if(a % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, From, To, cost=1):
        self.graph[From].append((To,cost))

    def get_nodes(self):
        return self.graph.keys()

class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph
        self.dist = defaultdict(lambda:float('inf'))
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)
        self.Q = []
        heappush(self.Q,(self.dist[start], start))

        while  self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, cost in self.g[u]:
                alt = dist_u + cost
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q,(alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]

from math import ceil
g = Graph()
N = int(input())
for i in range(N-1):
    a,b = map(int,input().split())
    g.add_edge(a,b)
    g.add_edge(b,a)

d = Dijkstra(g,1)
path = d.shortest_path(N)
n = ceil(len(path)/2)
flist = path[:n]
slist = path[n:]
a = flist[-1]
b = slist[0]
g.graph[a].pop(g.graph[a].index((b,1)))
g.graph[b].pop(g.graph[b].index((a,1)))
d = Dijkstra(g,1)
f = len(d.dist)
s = N-f

if f > s:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 68460
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    rep(i, 5){
        if(a[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3624
def manhattan(a, b)
  return a.zip(b).map {|ax, bx| (bx - ax).abs }.inject(:+)
end

n, m = gets.chomp.split.map(&:to_i)
st = Array.new(n) { gets.chomp.split.map(&:to_i) }
cp = Array.new(m) { gets.chomp.split.map(&:to_i) }

n.times do |i|
  t = 0
  dist = manhattan(st[i], cp[0])
  (m - 1).times do |j|
    cd = manhattan(st[i], cp[j + 1])
    if dist > cd
      t = j + 1
      dist = cd
    end
  end
  puts t + 1
end

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

int main(){
  
  int N,K,A = 1;
  cin >> N >> K;
  
  for(int i = 0;i < N;i++){
    
    if(A + K > A * 2){
      A *= 2;
    }else{
      A += K;
    }
    
  }
  cout << A << endl;
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;

int a,b,c,x,y;
int sum(int d,int e,int f){
  return a*d + b*e + c*f;
}

int main(){
  cin >> a >> b >> c >> x >> y;
  if(a+b <= 2*c){
    cout << sum(x,y,0) << endl;
    return 0;
  }
  int piza1 = sum(0,0,2*max(x,y));
  int m = min(x,y);
  int piza2 = sum(x-m,y-m,2*m);
  int ret = min(piza1,piza2);
  cout << ret << endl;
  return 0;
}


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

int main(){
    int year, month, day;
    char S[100];
    char s2[] = "/";
    scanf("%s", S);
    char *tok;
    tok = strtok( S, s2 );
    year = atoi(tok);
    tok = strtok( NULL, s2 );
    month = atoi(tok);
    tok = strtok( NULL, s2 );
    day = atoi(tok);
    if(year < 2019 || (year == 2019 && month <= 4)){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int n, count = 1;
    cin >> n;
    int order[n];
    for (int i = 0, k; i<n; i++){
        cin >> k;
        order[k-1] = count;
        count++;
    }
    for (int i: order){
        cout << i << " ";
    }
}


Measured memory_bytes: 1152
s=list(input())
a=len(s)
z=0
for i in range(len(s)):
    if(s[i]=="A"):
        a=i
    if(a!=len(s)):
        break
for i in range(len(s)):
    if(s[len(s)-1-i]=="Z"):
        z=len(s)-1-i
    if(z!=0):
        break
print(z-a+1)






Measured memory_bytes: 4840
//https://atcoder.jp/contests/abc159/tasks/abc159_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N,M; cin>>N>>M;
  ll ans= N*(N-1)/2 + M*(M-1)/2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	string ans = "No";
	vector<int> p(3);
	for (int i = 0; i < 3; i++) {
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	if (p.at(0) + p.at(1) == p.at(2)) {
		ans = "Yes";
	}
	cout << ans << endl;
}

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

#define ll long long
#define uint unsigned int
#define vi vector<int>
#define pii pair<int,int>

#define for0(i,n) for(int i=0; i<(n); i++)
#define for1(i,n) for(int i=1; i<=(n); i++)
#define from(i,a,b) for(int i=(a); i<=(b); i++)
#define forr(i,a,b) for(int i=(a); i>=(b); i--)

#define PB push_back
#define MP make_pair
#define FI first
#define SE second

#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()

#define safe_map unordered_map<long long, int, custom_hash>

#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main

void amax(int& x, int y){if(x<y)x=y;}
void amin(int& x, int y){if(x>y)x=y;}
int gcd(int a, int b){if(b){return gcd(b,a%b);}return a;}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {  // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};








void solve1(){
int n; cin>>n;
    if(n<600)
        n=8;
    else if(n<800)
        n=7;
    else if(n<1000)
        n=6;
    else if(n<1200)
        n=5;
    else if(n<1400)
        n=4;
    else if(n<1600)
        n=3;
    else if(n<1800)
        n=2;
    else
        n=1;
    cout << n << '\n';
}


void solve2(){
    int a,b,c,k; cin >> a >> b >> c >> k;
    
    while(c<=b||b<=a){
        if(k==0){
            cout<<"No\n";
            return;
        }
        if(b<=a){
            b<<=1;
        }else{
            c<<=1;
        }
        k--;
    }
    cout << "Yes\n";
}


void solve(){

    int n,k; cin >> n >> k;
    int a[n];
    for0(i,n) cin >> a[i];

    from(i,k,n-1){
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1; //cin >> t;
    while(t--) solve();
}



Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s;
    cin >> s;
    int n=0;
    rp(i,4){
        if(s[i]=='+') n++;
        else n--;
    }
    print(n);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
//Maximum Profit

#include<stdio.h>

int main(void){
    int n,i;
    long min, x;
    long difference = 0;
    
    scanf("%d", &n);
    
    scanf("%ld", &x); min = x;
    scanf("%ld", &x);
    difference = x -min;
    if(min > x) min = x;
    
    for(i = 2; i < n; i++){
        scanf("%ld", &x);
        if(min > x) 
            min = x;
        else if(x - min > difference) difference = x - min;
        
    }
    
    printf("%ld\n", difference);
    
    return 0;
}

Measured memory_bytes: 596
#%%
a = [0] * 3
b = [0] * 3
c = []
d = [0] * 3

for i in range(3):
    a[i], b[i] = map(int, input().split())
    c.append(a[i])
    c.append(b[i])
    d[i] = ''.join(str(a[i])+str(b[i]))
    if a[i] == b[i] :
        flag = False

flag = True

if 1 <= c.count(1) <= 2 and 1 <= c.count(2) <= 2 and 1 <= c.count(3) <= 2 and 1 <= c.count(4) <= 2:
     pass
else:
    flag = False

if len(list(set(d))) == 3:
    pass
else:
    flag = False

if flag:
    print('YES')
else:
    print('NO')

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  string s,t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  char smin='z',tmax='0';
  rep(i,s.size()) smin=(char)min(smin,s[i]);
  rep(i,t.size()) tmax=(char)max(tmax,t[i]);
  if(smin<tmax) print("Yes");
  else if(equal(ALL(s),t.begin())||equal(ALL(t),s.begin()))
    s.size()<t.size()?print("Yes"):print("No");
  else if(s==t) print("Yes");
  else print("No");
  return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU
function solve(lines: string): void {
  const s = lines[0].trim();
  let len = s.length;
  let bi = 0;
  let ei = len - 1;
  let bc = 0;
  let ec = 0;
  let ans = 0;
  for (;;) {
  while (bi < len && s[bi] === 'x') {
    bi++; bc++;
  }
  while (ei > bi && s[ei] === 'x') {
    ei--; ec++;
  }
  if (ei < bi) {
    break;
  }
    // console.log([bi,bc,ei,ec]);
  if (s[bi] !== s[ei]) {
    console.log('-1'); return;
  }
  ans += Math.abs(bc - ec);
    bc = 0; ec = 0; 
    bi++; ei--;
    if (bi >= ei) { break; }
  }
  console.log(ans);
}
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  const s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  solve(buf.trim().split("\n"));
});

Measured memory_bytes: 7628
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n,m,tm;
int d[105];
int tx[105];

int main(void){
	scanf("%d%d",&n,&m);
	int ki=0;
	rep(i,m){
		scanf("%d",&d[i]);
		if(d[i]%2!=0)ki++;
	}
	if(ki>2){
		printf("Impossible\n");
		return 0;
	}
	if(ki==0){
		tm=m+1;
		tx[0]=1;
		rep(i,m-1)tx[i+1]=d[i];
		tx[m]=d[m-1]-1;
	}
	else{
		reg(i,1,m-2){
			if(d[i]%2==1){
				if(d[0]%2==0)swap(d[0],d[i]);
				else swap(d[m-1],d[i]);
			}
		}
		if(ki==1){
			if(d[m-1]%2==0)swap(d[0],d[m-1]);
			tx[0]=1;
			rep(i,m-1){
				tx[i+1]=d[i];
			}
			if(d[m-1]!=1){
				tm=m+1;
				tx[m]=d[m-1]-1;
			}
			else tm=m;
		}
		else{
			if(d[0]==1){
				tm=m-1;
				rep(i,m-1)tx[i]=d[i+1];
				tx[tm-1]++;
			}
			else{
				tm=m;
				tx[0]=d[0]-1;
				rep(i,m-1)tx[i+1]=d[i+1];
				tx[tm-1]++;
			}
		}
	}
	
	rep(i,m)printf("%d%c",d[i],i+1==m?'\n':' ');
	printf("%d\n",tm);
	rep(i,tm)printf("%d%c",tx[i],i+1==tm?'\n':' ');
	return 0;
}






Measured memory_bytes: 256
from math import sqrt
n=int(input())
for i in range(n,n*10000):
    a=1
    if i%2!=0:
        a=0
        for j in range(3,round(sqrt(n))+1,2):
            if i%j==0:
                a+=1
                break
    elif i==2:
        print(2)
        break
    if a==0:
        print(i)
        break


Measured memory_bytes: 3060
from itertools import product

n = int(input())

info = []

for i in range(n):
    info.append(list(map(int,input().split())))

info.sort(reverse=True,key=lambda x:x[2])

for x,y in product(range(101),repeat=2):
    h=-1
    flag=True
    for i in info:
        if h==-1:
            h=abs(i[0]-x)+abs(i[1]-y)+i[2]
        else:
            if i[2] != max(0,h-abs(i[0]-x)-abs(i[1]-y)):
                flag=False
    if flag:
        X=x
        Y=y
        H=h
        break

print(X,Y,H)

Measured memory_bytes: 42608
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int x, y;
    cin >> x >> y;

    cout << (x * 2 <= y && y <= x * 4 && y % 2 == 0 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;



int main() {

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

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vl v(n + 1, 2);
		v[1] = 1;

		for (int i = 2; i  <= n / 2; i++) {
			for (int j = 2 * i; j <= n; j += i) {
				v[j]++;
			}
		}
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += i * v[i];
		}
		//cout << v[100] << "\n";
		cout << ans << "\n";
	}


	return 0;
}

Measured memory_bytes: 81316
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

int main() {
    string s, s_temp;
    int k;
    cin >> s >> k;
    set<string> se;
    for (int i = 0; i < s.length(); i++) {
        s_temp = "";
        for (int j = i; j < s.length(); j++) {
           s_temp += s[j];
           //cout << s_temp << endl;
           if (s_temp.length() <= 5) se.insert(s_temp);
        }
    }
    int i = 0;
    for(auto f: se) {
       i++;
       if (i == k) cout << f << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);

$answer = PHP_INT_MAX;

$max9 = floor($N / 9);
for ($i = $max9; $i >= 0; $i--) {
    $newN = $N;
    $newN -= 9 * $i;
    $ret9 = getLog($i * 9, 9);
    $num6 = floor($newN / 6);
    $ret6 = getLog($num6 * 6, 6);
    $newN -= 6 * $num6;
    $ret1 = $newN;
    $sum = $ret9 + $ret6 + $ret1;
    $answer = min($sum, $answer);
    if (DEBUG) printf("9:%d 6:%d 1:%d sum:%d answer:%d\n", $ret9, $ret6, $ret1, $sum, $answer);
}
echo $answer . PHP_EOL;

function getLog($n, $base) {
    if (DEBUG) echo "{$n} {$base}\n";
    $l = log($n, $base);
    $tmp = intval($l);

    $ret = 0;
    for ($i = $tmp + 1; $i >= 1; $i--) {
        $num = floor($n / pow($base, $i));
        $n -= $num * pow($base, $i);
        if (DEBUG) printf("base:%d number:%d proc:%d rest:%d\n", $base, pow($base, $i), $num, $n);
        $ret += $num;
    }
    return $ret;
}

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

int mymax(vector<int> a) {
  int maxarg = 0;
  for (int i = 1; i < a.size(); i++) {
    if (a.at(i) > a.at(maxarg)) {
      maxarg = i;
    }
  }
  return maxarg;
}

int main() {
  int n, maxarg, alice = 0, bob = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    maxarg = mymax(a);
    if (i % 2 == 0) {
      alice += a.at(maxarg);
    } else {
      bob += a.at(maxarg);
    }
    a.erase(a.begin() + maxarg);
  }
  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;
int main() {
    cin>>n>>m;

    vector<ll> divisor;
    for(ll i=1; i*i<=m; i++){
        if(m%i==0){
            divisor.emplace_back(i);
            divisor.emplace_back(m/i);
        }
    }
    sort(divisor.begin(), divisor.end());
    
    RREP(i, 0, divisor.size()){
        if(divisor[i] <= m/n){
            cout<<divisor[i]<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int zero=0,one=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			zero++;
		}else{
			one++;
		}
	}
	cout<<s.size()-(max(zero,one)-min(zero,one))<<endl;
}

Measured memory_bytes: 512
def experiment(xlist, coordinate):
    return sum( (xi-coordinate)**2 for xi in xlist)

N = input()
xlist = sorted([int(i) for i in input().split()])
s, l = xlist[0], xlist[-1]

min_stamina = float("inf")

for cord in range(s, l+1):
    min_stamina = min(min_stamina, experiment(xlist, cord))

print(min_stamina)

Measured memory_bytes: 38640
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const A = arr.shift() * 1;
    const B = arr.shift() * 1;
    const C = arr.shift() * 1;
    const K = arr.shift() * 1;
    if (K <= A) {
        console.log(K);
    } else if (K <= A + B) {
        console.log(A);
    } else {
        console.log(A - (K - A - B));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  vector<int> vec(5);
  vector<int> rest(5);
  vector<int> max(5);
  int sum=0;
for (int i = 0; i < 5; i++) {
  cin >> vec.at(i);
  if(vec.at(i)%10==0) rest.at(i)=0;
  else rest.at(i) = 10-(vec.at(i)%10);
  max.at(i) = vec.at(i) + rest.at(i);
  sum += max.at(i);
}
 sort(rest.begin(), rest.end());
  cout << sum-rest.at(4) <<endl;
}  

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

using namespace std;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define ar array
#define forn(i, n) for(int i = 0; i < n ; ++i)

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int > pii;
typedef vector<pii> vpi;
const ll MOD =1e9+7;

void solve(){
	string s,t; cin >> s>> t;
	vector<vi> dp(sz(s)+1,vi(sz(t)+1,0));
	forn(i,sz(s))
		forn(j,sz(t)){
			if(s[i] == t[j])
				dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1);
			else
				dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
		}
	string str;
	int l= sz(s),m=sz(t);
	while(l > 0 && m > 0){
		if(s[l-1] == t[m-1])
			str += s[l-1],l--,m--;
		else if(dp[l-1][m] > dp[l][m-1])
			l--;
		else
			m--;
	}
	reverse(all(str));
	cout << str;
	
}
int main(){
	int t=1;
#ifdef LOCAL
	freopen("input.txt","r",stdin);
#endif
	//cin >> t;
	while(t--){
		solve();
		cout <<'\n';
	}
}


Measured memory_bytes: 38548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int h = sc.nextInt(), a = sc.nextInt();
		pw.print((int)Math.ceil((double)h/a));
		pw.close();
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

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

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

int main(){
    int N;
    cin >> N;
    int V[100], C[100];
    for (int i = 0; i < N; i++){
        cin >> V[i];
    }
    for (int i = 0; i < N; i++){
        cin >> C[i];
    }
    int differ[100];
    for (int i = 0; i < N; i++){
        differ[i] = V[i] - C[i];
    }
    sort(differ, differ, greater<int>());
    int total = 0; 
    for (int i = 0; i < N; i++){
        if (differ[i] > 0) total += differ[i];
    }
    cout << total << endl;
    return 0;
}

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

int main() {
  long long a,b;
  cin >> a >> b;
  
  int d,r;
  double f;
  d = a / b;
  r = a % b;
  f = (double)a / b;
  
  cout << d << ' ' << r << ' ';
  printf("%.8lf\n", f);
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int mod = 1e9 + 7;
using namespace std;
const int N = 5005;
ll n, m, a[N], b[N], ma[N][N], k, T, tong, d[N][N], ans, t, s;
;
bool ck;
map<ll, ll> mp;
inline void sol()
{
	cin >> m >> n;
	for(int i = 1; i <= n; i ++)
    {
        cin >> k;
        mp[k] = 1;
    }
    ll i = m, j = m;
    while(true)
    {
        if(mp[i] == 0)
        {
            cout << i;
            return;
        }
        if(mp[j] == 0)
        {
            cout << j;
            return ;
        }
        --i;
        ++j;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();

}
/*
3 11
4 1 3 7 8
5 2 3 4 5 6
4 11 10 9 8
4 9
*/


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;


int main(){
  int s;cin>>s;
  map<int,bool> m;
  int ans=0;
  while(!m[s]){
      m[s]=1;
      if(s%2)s=3*s+1;
      else s/=2;
      ans++;
  }
  cout<<ans+1;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=get_nsp
ans=""
n.each do|x|
    if x=="1"
        ans+="9"
    else
        ans+="1"
    end
end
puts ans

Measured memory_bytes: 1788
def main():
    from itertools import permutations
    n=int(input())
    a=tuple(map(int,input().split()))
    b=tuple(map(int,input().split()))
    
    p=list(permutations(range(1,n+1)))
    d={i:j for j,i in enumerate(p)}
    print(abs(d[a]-d[b]))


main()


Measured memory_bytes: 10924
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] k = new int[m];
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            k[i] = Integer.parseInt(sc.next());
            List<Integer> sList = new ArrayList<>();
            for (int j = 0; j < k[i]; j++) {
                int s = Integer.parseInt(sc.next()) - 1;
                sList.add(s);
            }
            list.add(sList);
        }
        int[] p = new int[m];
        for (int i = 0; i < m; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        long ans = 0;
        for (int i = 0; i < (1 << n); i++) {
            boolean isOk = true;
            for (int j = 0; j < m; j++) {
                int cnt = 0;
                for (int l = 0; l < k[j]; l++) {
                    int temp = list.get(j).get(l);
                    if ((i >> temp & 1) == 1) {
                        cnt++;
                    }
                }
                if (cnt % 2 != p[j]) {
                    isOk = false;
                }
            }
            if (isOk) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using lint = long long;
using P = pair<int, int>;

int F, H, I, J, K, L, M, N, S, T, U;
// lint F, H, I, J, K, L, M, N, S, T, U;
// string A, B;
int ans = 0;

vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	cin >> N;

	cout << a[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N string
	fmt.Scanf("%s", &N)

	c, _ := strconv.Atoi(string(N[len(N)-1]))
	a := c
	b := 10 - c

	for i := len(N) - 2; i >= 0; i-- {
		c, _ := strconv.Atoi(string(N[i]))
		a, b = min(a+c, b+c+1), min(a+(10-c), b+(10-(c+1)))
	}
	fmt.Println(min(a, b+1))
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 5504
#include <iostream>
#include <cmath>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int maxi = 0;
    REP(i, n - 1) maxi = max(maxi, abs(a[i] - a[i+1]));

    int tmp = k - a[n-1] + a[0];
    maxi = max(maxi, tmp);

    cout << k - maxi << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
 
long long x[100050];
long long nxt[100050][31];
int main()
{
    long long n, q, l;
    scanf("%lld", &n);
    for(long long i = 0; i < n; ++i)
        scanf("%lld", &x[i]);
    scanf("%lld", &l);
    for(long long j = 0; j < 20; ++j)
    {
        for(long long i = 0; i < n; ++i)
        {
            if(j == 0)
                nxt[i][j] = upper_bound(x + i, x + n, x[i] + l) - x - 1;
            else
                nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
        }
    }
    scanf("%lld", &q);
    while(q--)
    {
        long long a, b;
        scanf("%lld%lld", &a, &b);
        --a;
        --b;
        if(a > b)
            swap(a, b);
        long long ans = 0;
        for(long long i = 19; i >= 0; --i)
        {
            if(a == b)
                break;
            if(nxt[a][i] < b)
            {
                ans += 1 << i;
                a = nxt[a][i];
            }
        }
        printf("%lld\n", ans + 1);
    }
    return 0;
}

Measured memory_bytes: 25728
#include<iostream>
using namespace std;
int main()
{
	int A,B,M,a[100005],b[100005],i,j,m[100005],x[100005],y[100005];
	cin>>A>>B>>M;
	for(i=1;i<=A;i++)
	cin>>a[i];
	for(i=1;i<=B;i++)
	cin>>b[i];
	for(i=1;i<=M;i++)
	{
	cin>>x[i]>>y[i]>>m[i];
	}
	int mina=a[1],minb=b[1],s,c;
	for(i=1;i<=A;i++)
	{
		if(a[i]<mina)
		mina=a[i];
	}
	for(i=1;i<=B;i++)
	{
		if(b[i]<minb)
		minb=b[i];
	}
	s=mina+minb;
	for(i=1;i<=M;i++)
	{
		int h=a[x[i]]+b[y[i]]-m[i];
		 if(s>h)
		s=h;
	 } 
	 cout<<s;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	priority_queue<int, vector<int>, greater<int>>pq;
	for (int i = 0; i<n; i++) { int a, b; cin >> a >> b; pq.push(a + b); }
	while (pq.size() > 0) {
		int p = pq.top(); pq.pop();
		if (pq.size() == 0)cout << p << " 0\n";
		else if (p == pq.top()) {
			pq.pop(); pq.push(++p);
		}
		else cout << p << " 0\n";
	}
	return 0;
}


Measured memory_bytes: 3508
N = input()
if int(N[-1]) == 2 or int(N[-1]) == 4 or int(N[-1]) == 5 or int(N[-1]) == 7 or int(N[-1]) == 9:
    print("hon")

elif int(N[-1]) == 3:
    print("bon")

else:
    print("pon")


Measured memory_bytes: 9176
s = input().strip()
ans = 0
tmp = 0
for _, x in enumerate(s):
    if x == "A" or x == "C" or x == "G" or x == "T":
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0

if tmp != 0:
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 38256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int N;
    cin >> N;

    string S;
    cin >> S;

    int ans = 0;
    REP(i, S.size() - 2) {
        if (S.substr(i, 3) == "ABC") ++ans;
    }

    cout << ans << endl;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << (min(b, d) < max(a, c) ? 0 : min(b, d) - max(a, c)) << "\n";
}


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

namespace practice
{
    class MainClass
    {
        public static void DrawChessboard(int H,int W)
        {
            for(int y = 0;y < H; y++)
            {
                if (y % 2 == 0)
                {
                    for (int x = 0; x < W; x++)
                    {
                        if (x % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                else
                {
                    for (int x = 0; x < W; x++)
                    {
                        if (x % 2 == 0)
                        {
                            Console.Write(".");
                        }
                        else
                        {
                            Console.Write("#");
                        }
                    }
                    Console.WriteLine();
                }
            }
            Console.WriteLine();
        }
        public static void Main(string[] args)
        {
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                List<int> sizes = new List<int>();
                for (int i = 0; i < input.Length; i++)
                {
                    sizes.Add(int.Parse(input[i]));
                }
                int H = sizes[0];
                int W = sizes[1];
                if(H == 0 && W == 0)
                {
                    break;
                }
                DrawChessboard(H, W);
            }
        }
    }
}


Measured memory_bytes: 17960
N, M, *XY = map(int, open(0).read().split())

red = [False] * (N + 1)
red[1] = True

box = [1] * (N + 1)

for x, y in zip(XY[::2], XY[1::2]):
    if red[x]:
        red[y] = True
    box[y] += 1
    box[x] -= 1
    if box[x] == 0:
        red[x] = False

print(red.count(True))

Measured memory_bytes: 25076
import sys
input = sys.stdin.readline

def main():
    X = int(input())

    if X < 100:
        print(0)
        exit()
    modx = X % 100
    warix = X // 100



    for i in range(warix + 1):
        if i > warix:
            break
        for j in range(warix + 1):
            if i + j > warix:
                break
            for k in range(warix + 1):
                if i + j + k > warix:
                    break
                for l in range(warix + 1):
                    if i + j + k + l > warix:
                        break
                    for m in range(warix + 1):
                        if i + j + k + l + m > warix:
                            break
                        for n in range(warix + 1):
                            if i + j + k + l + m + n > warix:
                                break
                            if i + 2 * j + 3 * k + 4 * l + m * 5 > 99:
                                break
                            if (i + 2 * j + 3 * k + 4 * l + m * 5) == modx and warix == (i + j + k + l + m + n):
                                print(1)
                                exit()

    print(0)



if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
 int N,A,rem;
 scanf("%d %d",&N,&A);
 rem = (N%500);
 if(rem==0)
 {
     printf("Yes");
 }
 else if(rem<=A)
 {
     printf("Yes");
 }
    else
        {
         printf("No");
        }




return 0 ;
}

Measured memory_bytes: 1696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
                System.out.println("Possible");
            } else {
                System.out.println("Impossible");
            }
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(a.at(i)<a.at(i+1)&&a.at(i+1)<a.at(i+2)){
      ans++;
    }else if(a.at(i)>a.at(i+1)&&a.at(i+1)>a.at(i+2)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  double A[1000];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  double sum=0;
  for(int i=0;i<N;i++){
    sum += 1/A[i];
  }
  printf("%lf\n", 1/sum);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main(){
     int N,Q=0;
     cin>>N;
     int test[N];
     for(int i=0; i<N; i++){
         cin>>test[i];
     }
     for(int j=0; j<N; j++){
         switch(test[j]%2)
             case 0:
             if(test[j]%3!=0&&test[j]%5!=0){
                 Q++;
                 continue;
             }
             else{
                 continue;
             }
         
     }
    if(Q==0){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }
    
 }

     
 


Measured memory_bytes: 384
N,M,S=map(int,input().split())
from heapq import heappop,heappush 

inf = float('inf')
cost=[[] for _ in range(N)]
exc=[]


for _ in range(M):
    u,v,a,b=map(int,input().split())
    u,v=u-1,v-1
    cost[u].append((v,a,b))
    cost[v].append((u,a,b))
for _ in range(N):
    c,d=map(int,input().split())
    exc.append((c,d))

S=min(S,2450)
di=[inf]*2451*N
di[S]=0
hq=[(0,S)] #時間,都市名*2451+銀貨

while hq:
    t,v=heappop(hq)
    u=v//2451 #都市名
    s=v%2451 #所持金
    if t>di[v]:
        continue

    for x,a,b in cost[u]:
        if s>=a:
            v_new=x*2451+s-a
            t_new=t+b
            if t_new<di[v_new]:
                di[v_new]=t_new
                heappush(hq,(t_new,v_new))
    
    c,d=exc[u]
    c=min(c,2450-s)
    v_new=v+c
    t_new=t+d
    if t_new<di[v_new]:
        di[v_new]=t_new
        heappush(hq,(t_new,v_new))

for i in range(1,N):
    m=min(di[i*2451:(i+1)*2451])
    print(m)

Measured memory_bytes: 24144
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <string.h>
using namespace std;
typedef pair<int,int> P;

#define INF 1000000
int cost[10][10];
int n,m;

int main(){
  while(1){
    cin >> n;
    if(!n)break;

    m = 0;
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        if(i==j){
          cost[i][j] = 0;
        }else{
          cost[i][j] = INF;
        }
      }
    }
    for(int i=0;i<n;i++){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      if(m<x||m<y){
        m = max(x,y);
      }
      cost[x][y] = z;
      cost[y][x] = z;
    }
    m++;

    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
        }
      }
    }

    int mini = INF;
    int index;
    for(int i=0;i<m;i++){
      int sum = 0;
      for(int j=0;j<m;j++){
        sum += cost[i][j];
      }
      if(mini>sum){
        mini = sum;
        index = i;
      }
    }
    cout << index << " " << mini << endl;
  }
}

Measured memory_bytes: 1244
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	private static void core() {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		System.out.println(Pattern.matches("^(dream|dreamer|erase|eraser)*$", s) ? "YES" : "NO");
	}

	/*
	 * Scanner sc = new Scanner(System.in);
	 */

	public static void main(String[] args) {
		core();
	}

}


Measured memory_bytes: 24852