akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(ll i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO;
    ll n,x,y,cnt=0,a;
    long double d;
    cin>>n>>a;
    REP(i,0,n){
      cin>>x>>y;
      d=sqrt(x*x+y*y);
      if(d<=a) cnt++;
    }
    cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int, int> pii;

int main(){
    int n;
    cin >> n;
    vector<int> r(n);
    for(int i=0; i<n; i++){
        cin >> r[i];
    }
    vector<vector<int>> p(3, vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> p[j][i];
        }
    }
    for(int d=0; d<=101; d++){
        for(int k=0; k<3; k++){
            vector<vector<pii>> pp(3, vector<pii>(n));
            for(int i=0; i<3; i++){
                for(int j=0; j<n; j++){
                    int add = (k==i and j==0)? d: 0;
                    pp[i][j] = pii(p[i][j]+add, j);
                }
                sort(pp[i].begin(), pp[i].end(), greater<pii>());
            }
            vector<pii> score(n);
            for(int i=0; i<n; i++){
                score[i] = pii(0, i);
            }
            for(int i=0; i<3; i++){
                for(int j=0; j<n; j++){
                    int s = r[j];
                    score[pp[i][j].second].first += s;
                    while(j<n-1 and pp[i][j].first==pp[i][j+1].first){
                        j++;
                        score[pp[i][j].second].first += s;
                    }
                }
            }
            sort(score.begin(), score.end(), greater<pii>());
            vector<int> ord(n);
            for(int i=0; i<n; i++){
                int curr = i;
                ord[score[i].second] = curr; 
                while(i<n-1 and score[i].first==score[i+1].first){
                    i++;
                    ord[score[i].second] = curr;
                }
            }
            if(ord[0] < 8){
                cout << d << endl;
                return 0;
            }
        }
    }
    cout << "Saiko" << endl;
    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    string s;
    cin >> s;
    string s2 = "";
    if(s.size()<=2){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < s.size()-1; i++){
        if(s[i]=='B' && s[i+1]=='C'){s2 += 'D'; i++;}
        else{s2 += s[i];}
    }
    if(s[s.size()-2]=='B' && s[s.size()-1]=='C'){;}
    else{s2 += s[s.size()-1];}

    ll a = 0, d = 0;
    ll ans = 0;
    for(int i = 0; i < s2.size(); i++){
        if(s2[i]=='B' || s2[i]=='C'){
            ans += d;
            a = 0; d = 0;
        }else if(s2[i]=='A'){
            a++;
        }else if(s2[i]=='D'){
            d += a;
        }

    }
    ans += d;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    int N, L;
    cin >> N >> L;

    vector<string> v(N);
    for(auto& e : v)
        cin >> e;
    
    sort(v.begin(), v.end());

    for(auto& e : v)
        cout << e;
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 888
n,m=list(map(int,input().split()))
road=[[] for i in range(n)]
#隣接行列表現だとo(n^2)で間に合わないので隣接リスト表現でいく
for i in range(m):
  a,b=list(map(int,input().split()))
  road[a-1].append(b)
  road[b-1].append(a)
from collections import deque
q=deque([1])
check=[0 for i in range(n)]
check[0]=1
ans=[0 for i in range(n)]
while len(q)>0:
  p=q.popleft()
  for i in range(len(road[p-1])):
    if check[road[p-1][i]-1]==0:
      q.append(road[p-1][i])
      check[road[p-1][i]-1]=1
      ans[road[p-1][i]-1]=p
      
      
print("Yes")
for i in range(1,n):
  print(ans[i])
  
 

      
  
  

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

int main(){
   ll a,b,c,d;
   cin >> a >> b >> c >> d;
   cout << max({a*c,a*d,b*c,b*d}) << endl;
}

Measured memory_bytes: 3632
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N, K = MI()
H = LI()

ans = 0

for h in H:
    if h >= K:
        ans += 1

print(ans)


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

int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
  }
  else if(a.size()<b.size()){
    cout<<"LESS"<<endl;
  }
  else{
    if(a>b){
      cout<<"GREATER"<<endl;
    }
    else if(a<b){
      cout<<"LESS"<<endl;
    }
    else{
      cout<<"EQUAL"<<endl;
    }
  }
}
  


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main()
{     long long n,m;
      cin>>n>>m;
	  cout<<(n-1)*(m-1)<<endl; 
	  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int x;
	cin >> x;
	int ans = 0;
	for(int i = 0; i * 100 <= x; ++i){
		int t = x - i * 100;
		if(t <= 5 * i){ ans = 1; }
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
from collections import deque

k = int(input())
ans = [i for i in range(1, 10)]
cal1 = [str(i) for i in range(1, 10)]
cal = deque(cal1)

cnt = 0
while (1):
    tmp = cal.popleft()
    last = tmp[-1]
    flag = False
    if last == '0':
        tmp1 = tmp + '0'
        tmp2 = tmp + '1'
    elif last == '9':
        tmp1 = tmp + '8'
        tmp2 = tmp + '9'
    else:
        flag = True
        down = tmp + str(int(last) - 1)
        middle = tmp + last
        up = tmp + str(int(last) + 1)

    if flag:
        ans.append(int(down))
        ans.append(int(up))
        ans.append(int(middle))
        cal.append(down)
        cal.append(up)
        cal.append(middle)
        cnt += 3
    else:
        ans.append(int(tmp1))
        ans.append(int(tmp2))
        cal.append(tmp1)
        cal.append(tmp2)
        cnt += 2

    if cnt > 10**6:
        break
ans.sort()
# print(ans)
print(ans[k - 1])


Measured memory_bytes: 90536
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=200010;
int n,m,kq,tmp;
int T[4*N],B[4*N];
#define goc 1,0,n
#define lef 2*s,l,mid
#define rig 2*s+1,mid+1,r
#define mid (l+r)/2
void trans(int s)
{
  if(!B[s]) return;
  T[2*s]+=B[s];   T[2*s+1]+=B[s];
  B[2*s]+=B[s];   B[2*s+1]+=B[s];
  B[s]=0;
}
void up(int s,int l,int r,int u,int v,int x)
{
  if(l>v||u>r) return;
  if(u<=l&&r<=v)
  {
    T[s]+=x;
    B[s]+=x;
    return;
  }
  trans(s);
  up(lef,u,v,x);
  up(rig,u,v,x);
  T[s]=max(T[2*s],T[2*s+1]);
}
int get(int s,int l,int r,int u,int v)
{
    if(l>v||u>r) return -1e18;
    if(u<=l&&r<=v) return T[s];
    trans(s);
    return max(get(lef,u,v),get(rig,u,v));
}
struct w{int l,r,x;}q[N];
vector<int> s[N],t[N];
int l,r,x;
main()
{
  ios_base::sync_with_stdio(false),cin.tie(nullptr);
  cin>>n>>m;
  for(int i=1;i<=m;++i)
  {
    cin>>l>>r>>x;
    q[i]={l,r,x};
    s[l].push_back(i);
    t[r].push_back(i);
  }
  for(int i=1;i<=n;++i)
  {
    for(auto&j:s[i]) up(goc,0,q[j].l-1,q[j].x);
    tmp=get(goc,0,i-1);
    kq=max(kq,tmp);
   	up(goc,i,i,tmp);
   	for(auto&j:t[i]) up(goc,0,q[j].l-1,-q[j].x);
  }
  cout<<kq;
}
/**
  f[i] : max value 1->n with ans[i] = 1;
  	   = max f[j] + a[t] for t with l[t]<=i<=r[t];
         			           and !l[t]<=j<=r[t];
  n^2 can be done iterating through all posibilities;
  we speed up the algo with a seg : seg[i] as f[i]
  while iterating through a position : i,
  all query with start point at i , we update the range [0,i-1] : a[t];
  same as if we meet a end point  , we update the range [0,i-1] : -a[t];
*/


Measured memory_bytes: 37376
#include<bits/stdc++.h>
using namespace std;
int DP[10010][100][2];
int main()
{
	string S;
	int N;
	cin>>S>>N;
	DP[0][0][1]=1;
	for(int i=0;i<S.length();i++)
		for(int j=0;j<N;j++)
		{
			for(int k=0;k<10;k++)
				DP[i+1][(j+k)%N][0]=(DP[i+1][(j+k)%N][0]+DP[i][j][0])%1000000007;
			for(int k=0;k<S[i]-'0';k++)
				DP[i+1][(j+k)%N][0]=(DP[i+1][(j+k)%N][0]+DP[i][j][1])%1000000007;
			DP[i+1][(j+S[i]-'0')%N][1]=(DP[i+1][(j+S[i]-'0')%N][1]+DP[i][j][1])%1000000007;
		}
	cout<<(DP[S.length()][0][0]+DP[S.length()][0][1]+1000000006)%1000000007;
	return 0;
}

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



int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  string s, t; cin >> s >> t;
  for (int i = 0; i < N; i++) {
    bool found = true;
    for (int j = i; j < N; j++) {
      if (s.at(j) != t.at(j - i)) {
	found = false;
	break;
      }
    }
    if (found) {
      cout << N+i << endl;
      return 0;
    }
  }
  cout << 2*N << endl;

  return 0;
}



Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use num_traits::{pow, One};
use proconio::{fastout, input};
use std::ops::{Add, Div, Mul, Sub};

const MODULUS: usize = 1000000007;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

#[fastout]
fn main() {
    input! {
        h :usize,
        w :usize,
        a :usize,
        b :usize,
    }

    // prepare a table of factorials
    let mut fac_vec: Vec<ModP> = Vec::new();
    let mut fac_inv_vec: Vec<ModP> = Vec::new();
    fac_vec.push(ModP(1));
    fac_inv_vec.push(ModP(1));
    for i in 1..=h+w {
        fac_vec.push(ModP(i) * fac_vec[i - 1]);
        fac_inv_vec.push(ModP(1) / fac_vec[i]);
    }
    let fac_vec = fac_vec;
    let fac_inv_vec = fac_inv_vec;

    let mut total = ModP(0);
    for j in b + 1..=w {
        let tate1 = ModP(h - a - 1);
        let yoko1 = ModP(j - 1);
        let tate2 = ModP(a - 1);
        let yoko2 = ModP(w - j);
        total = total
            + combination(tate1 + yoko1, tate1, &fac_vec, &fac_inv_vec)
                * combination(tate2 + yoko2, tate2, &fac_vec, &fac_inv_vec);
    }
    println!("{}", total.0);
}

fn combination(n: ModP, r: ModP, fac_vec: &Vec<ModP>, fac_inv_vec: &Vec<ModP>) -> ModP {
    return fac_vec[n.0] * fac_inv_vec[(n - r).0] * fac_inv_vec[r.0];
}

#[derive(Clone, Copy, PartialEq, Debug)]
struct ModP(usize);

impl One for ModP {
    fn one() -> Self {
        return ModP(1);
    }
}
impl Add for ModP {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        return ModP((self.0 + rhs.0) % MODULUS);
    }
}
impl Sub for ModP {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {
        return ModP((self.0 + MODULUS - rhs.0) % MODULUS);
    }
}
impl Mul for ModP {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        return ModP((self.0 * rhs.0) % MODULUS);
    }
}
impl Div for ModP {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        if rhs.0 == 0 {
            panic!("Tried to divide by ModP(0)!");
        }
        let rhs_inv = pow(rhs, MODULUS - 2);
        return self * rhs_inv;
    }
}


Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,cx,cy,H;
  cin>>n;
  vector<vector<int>> hxy(n,vector<int>(3));
  for(i=0;i<n;i++) cin>>hxy.at(i).at(1)>>hxy.at(i).at(2)>>hxy.at(i).at(0);
  sort(hxy.begin(),hxy.end());
  reverse(hxy.begin(),hxy.end());
  for(cx=0;cx<=100;cx++){
    for(cy=0;cy<=100;cy++){
      H=-1;
      for(i=0;i<n;i++){
        if(hxy.at(i).at(0)>0){
          if(H==-1) H=hxy.at(i).at(0)+abs(hxy.at(i).at(1)-cx)+abs(hxy.at(i).at(2)-cy);
          else if(H!=hxy.at(i).at(0)+abs(hxy.at(i).at(1)-cx)+abs(hxy.at(i).at(2)-cy)) break;
        }
        else if(hxy.at(i).at(0)==0){
          if(H-abs(hxy.at(i).at(1)-cx)-abs(hxy.at(i).at(2)-cy)>0) break;
        }
      }
      if(i==n){
        cout<<cx<<' '<<cy<<' '<<H<<endl;
        cx=100; cy=100;
      }
    }
  }
}

Measured memory_bytes: 3652
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long dp[3100][3100];
long long tmp[3100];
int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	dp[a][b]=1;
	for(int i=a;i<c;i++){
		long long cur=0;
		for(int j=b;j<=d;j++){
			// printf("%d %d: %lld\n",i,j,dp[i][j]);
			dp[i+1][j]=cur;
			cur=(cur+dp[i][j])%mod;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
			cur=cur*i%mod;
		}
	}
	for(int i=b;i<=d;i++){
		ret=(ret+dp[c][i]*pw(c,d-i))%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 74264
#include <iostream>

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if (a >= b) {
        cout << "delicious" << endl;
    } else if (a+x < b) {
        cout << "dangerous" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<string> vec;
    short n, m;
    cin >> n >> m;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        vec.push_back(s);
    }
    sort(vec.begin(), vec.end());

    for (size_t i = 0; i < n; i++)
    {
        cout << vec[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<math.h>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll n, cost[30], m, a[100001], k, d;
vector<vector<ll>> v(39);
bool f[200001], fl[200001];
//-------------------関数----------------------//


int main() {
	cin >> n >> m;
	REP(i, m) {
		ll hoge, piyo; cin >> hoge >> piyo;
		if (hoge == 1) {
			f[piyo] = true;
		}
		if (piyo == 1) {
			f[hoge] = true;
		}
		if (hoge == n) {
			fl[piyo] = true;
		}
		if (piyo == n) {
			fl[hoge] = true;
		}
	}
	REP(i, 200001) { if (f[i] == true && fl[i]) { cout << "POSSIBLE" << endl; return 0; } }
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int asize=2e5+5;

int main(){
	long long a,b,x,res;
	cin>>x;
	for(a=0;a<=100;a++){
		for(b=0;b<=100;b++){
			if(a*a*a*a*a+b*b*b*b*b==x){
				cout<<a<<" "<<-b;
				return 0;
			}
		}
	}
	for(a=0;a<=1e3;a++){
		for(b=a-1;b>=a-101&&b>=0;b--){
			if(a*a*a*a*a-b*b*b*b*b==x){
				cout<<a<<" "<<b;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int partition(int *,int,int);
void swap(int *,int *);

int main(){
  int n,i;
  int A[100001];
  int t;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  t=partition(A,0,n-1);
  
  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",A[i]);
    else if(i==t) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  return 0;
}

int partition(int *A,int p,int r){
  int x,i,j;
  
  x=A[r];
  i=p-1;
  
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
  
    swap(&A[i],&A[j]);
    }
    
  }
 
  swap(&A[i+1],&A[r]);
 
  return i+1;

}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
  return;
}





Measured memory_bytes: 2960
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void solve() {
	int n, m; scanf("%d %d", &n, &m); if (n == 0 and m == 0) exit(0);
	vector<int> s(m);
	for (int i = 0; i < n; i++) {
		int d, v; scanf("%d %d", &d, &v);
		d--;
		chmax(s[d], v);
	}
	int sum = 0; for (int i = 0; i < m; i++) sum += s[i];
	printf("%d\n", sum);
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int N;

int main() 
{
	cin >> N;
	int a[N];
	
	//input diameter of mochi
	for (int i = 0; i < N; i++) cin >> a[i];
	
	sort(a, a + N, greater<int>()); //sort in order of max -> min
	
	int count;
	for (int i=0;i<N;i++)
	{
		if (a[i+1]==a[i])
		continue;
		else count++;
	}
	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int lr = 0;
  int rl = 0;
  int ans = 0;
  rep(i, N - 1) {
    if (S[i] == 'R' && S[i + 1] == 'L')
      rl++;
    if (S[i] == 'L' && S[i + 1] == 'R')
      lr++;
    if (S[i] == S[i + 1])
      ans++;
  }
  rep(i, K) {
    if (lr > 0 && rl > 0) {
      ans += 2;
      lr--;
      rl--;
    } else if (lr + rl == 1) {
      ans++;
      break;
    } else
      break;
  }
  cout << ans << endl;
}

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

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

idx = 0
for i in range(N):
    if(abs(A - (T - 0.006 * H[i])) < abs(A - (T - 0.006 * H[idx]))):
        idx = i

print(idx + 1)

Measured memory_bytes: 3060
import sys
import math

MAXNUM=1000000
SQRT=math.sqrt(MAXNUM)

def eratosthenes():
    l = [1]*MAXNUM
    l[0:2]=[0]*2
    l[4:MAXNUM:2] = [0]*len(l[4:MAXNUM:2])

    for i in range(3,1000,2):
        l[i*i:MAXNUM:i*2] = [0]*len(l[i*i:MAXNUM:i*2])

    return l

primes = eratosthenes()
for i in sys.stdin:
    n = int(i)
    print(sum(primes[0:n+1]))


Measured memory_bytes: 24400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var d = ReadInts();
            Array.Sort(d);
            var z = (n / 2)-1;
            WriteLine(d[z + 1] - d[z]);

        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;

vector <int> g[MAXN];
bool visited[MAXN];
ll f[MAXN];
ll a[MAXN];

bool dfs(int v)
{
	visited[v] = true;
	if (g[v].size() == 1)
	{
		f[v] = a[v];
		return true;
	}

	ll cnt = 0;
	ll mx = 0;
	for (int i = 0; i < g[v].size(); i++)
	{
		if (!visited[g[v][i]])
		{
			if (!dfs(g[v][i]))
			{
				return false;
			}
            cnt += f[g[v][i]];
            mx = max(f[g[v][i]], mx);
		}
	}

	if (a[v] > cnt) return false;

    ll mxop = min(cnt - mx, cnt/2);

	if (cnt - a[v] > mxop) return false;

	f[v] = a[v] - (cnt - a[v]);
	return true;
}

int main()
{
    int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	if (n == 2)
	{
		if (a[1] == a[2]) cout << "YES";
		else cout << "NO";
		return 0;
	}

	for (int i = 0; i < n-1; i++)
	{
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	int r = 1;
	while(g[r].size() == 1) r++;

	visited[r] = true;
	ll cnt = 0;
	for (int i = 0; i < g[r].size(); i++)
	{
		if (!dfs(g[r][i]))
		{
			cout << "NO";
			return 0;
		}

		cnt += f[g[r][i]];
	}

	/*for (int i = 1; i <= n; i++)
        cout << f[i] << " ";
    cout << endl;*/
	if (cnt == 2 * a[r]) cout << "YES";
	else cout << "NO";

	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main() {
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double th = double(h*60+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th);
  double yh = a*sin(th);
  double xm = b*cos(tm);
    double ym = b*sin(tm);
  double dx = xh - xm;
    double dy = yh - ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}



Measured memory_bytes: 4020
n = int(input())
t = list(map(int,input().split()))
m = int(input())
arr = [list(map(int,input().split())) for _ in range(m)]
for i in range(len(arr)):
  sums = 0
  sums += sum(t) - t[arr[i][0]-1] + arr[i][1]
  print(sums)
  

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

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

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <stdio.h>
#include <sstream>      // std::ostringstream

int main()
{
    string str_n;
    cin >> str_n;
    int n = stoi(str_n);
    string target = "AB";
    int count=0;
    int count_a=0;
    int count_b=0;
    int count_ab=0;
    for(int i=0;i<n;i++){
        string tmp;
        cin >> tmp;
        string tmp_cp(tmp);
        while(true) {
            int h = tmp_cp.find(target);
            if(h == std::string::npos) break;
            count++;
            tmp_cp = tmp_cp.substr(h+1,tmp_cp.length()-h);
        }
        if("A" == tmp.substr(tmp.length()-1,1)&&tmp.find("B")== 0){
            count_ab++;
        }else
        {
            if ("A" == tmp.substr(tmp.length()-1,1))
                count_a++;
            if (tmp.find("B") == 0)
                count_b++;
        }

    }

    if(count_ab>0) {
        count+=count_ab-1;
        if (count_a > count_b) {
            count += count_b+1;
        } else if (count_a < count_b) {
            count += count_a+1;
        } else {
            if(count_a + count_b>0)
                count += count_a+1;
            else{
                count += count_a;
            }
        }
    }else if(count_ab==0){
        if (count_a > count_b) {
            count += count_b;
        }else {
            count += count_a;
        }
    }
    cout << count << endl;
    return 0;

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int Z;
  if (A == B){
    Z++;
  }
  if (A == C){
    Z++;
  }
  if (B == C){
    Z++;
  }
  if (Z == 1){
        cout << "Yes"<< endl;
      	}else{
        cout << "No"<< endl;
    }

}

Measured memory_bytes: 256
def main():
    n,m,k = map(int,input().split())
    # frend = [[10**6] * n for i in range(n)]
    # block = [[0] * n for i in range(n)]
    # f = [[0]*n for i in range(n)]
    fq = []
    # b = [[0]*n for i in range(n)]
    bq = []
    uf = UnionFind(n)
    dame = [0] * n

    for _ in range(m):
        a,bb = map(int,input().split())
        # f[a-1][bb-1] = 1
        # f[bb-1][a-1] = 1
        uf.union(a-1,bb-1)
        fq.append([a-1,bb-1])

    for _ in range(k):
        c,d = map(int,input().split())
        # b[c-1][d-1] = 1
        # b[d-1][c-1] = 1
        bq.append([c-1,d-1])
        if uf.same(c-1,d-1):
            dame[c-1] += 1
            dame[d-1] += 1


    for i, ff in enumerate(fq):
        if uf.same(ff[0],ff[1]):
            dame[ff[0]] += 1
            dame[ff[1]] += 1



    for i in range(n):
        print(str(uf.size(i)-dame[i]-1 ), end = " ")
    print("")

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


if __name__=='__main__':
    main()


Measured memory_bytes: 123736
/*input
10 0 12 0 120

*/
#include <bits/stdc++.h>

using namespace std;

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

  int h1, m1, h2, m2, k;
  cin >>  h1 >> m1 >> h2 >> m2 >> k;

  int R = (h2 - h1) * 60 + m2 - m1;
  cout << max(0, R - k);
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-') f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}
 
const int N=1e5+50;
int n,cnt,L,T,a[N],b[N],w[N];
int main() {
	n=rd(), L=rd(), T=rd();
	for(int i=1;i<=n;i++) {
		a[i]=rd(), w[i]=(rd()==1 ? 1 : -1);
		b[i]=((a[i]+(LL)T*w[i])%L+L)%L;
		int dis=(w[i]>0 ? L-a[i] : a[i])+1;
		if(T>=dis) {
			cnt+=w[i]; int res=T-dis;
			cnt+=(res/L)*w[i];
			cnt=(cnt%n+n)%n;
		}
	} sort(b+1,b+n+1);
	for(int i=1;i<=n;i++) 
		printf("%d\n",b[(i+cnt-1)%n+1]);
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
       int s,h,m;
       scanf("%d",&s);

       h=s/3600;
       s=s-h*3600;
       m=s/60;
       s=s-m*60;
       printf("%d:%d:%d\n",h,m,s);
       return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a,b;cin>>a>>b;
    if(b >= a) cout << a << endl;
    else cout << (a-1) << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);


    let (a, b, c): (i64, i64, i64) = (sc.input(), sc.input(), sc.input());

    let ans = if a + b == c || b + c == a || c + a == b {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


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

int main() {
  int n;cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        cnt+=__gcd(i,__gcd(j,k));
      }
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3544
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


A = sorted(LI())
cnt = 0
ans = 0
for i in range(n):
    cnt += 1
    if i == n - 1 or A[i] != A[i + 1]:
        ans = (ans + (comb(i + 1, k) - comb(i + 1 - cnt, k)) * A[i] % mod) % mod
        cnt = 0


for i in range(n - 1, -1, -1):
    cnt += 1
    if i == 0 or A[i] != A[i - 1]:
        ans = (ans - (comb(n - i, k) - comb(n - i - cnt, k)) * A[i] % mod) % mod
        cnt = 0


print(ans)





Measured memory_bytes: 62960
n, m = map(int, input().split())
counts = [0] * n
ac = 0
penalty = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if counts[p] == -1:
        continue
    if s == 'WA':
        counts[p] += 1
    else:
        ac += 1
        penalty += counts[p]
        counts[p] = -1

print(ac, penalty)

Measured memory_bytes: 3828
# include<bits/stdc++.h>
using namespace std;
int main(){
int n, m;
  cin >> n >> m;
  int L[m], R[m];
  for (int i = 0; i < m; i++){
  	cin >> L[i] >> R[i];
  }
  cout << max(0,*min_element(R,R+m)-*max_element(L,L+m)+1)<<'\n';

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int l, r;
   int d;
   cin >> l >> r >> d;
   int cnt = 0;
   for(int i = l;i <=r;i++) {
      if(i%d==0)cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int main(){
	int n,d[10],v[10],t;
	while(cin>>n,n){
		rep(i,n)cin>>d[i]>>v[i],t=gcd(d[i],v[i]),d[i]/=t,v[i]/=t;
		ll a=d[0],b=v[0];
		rep(i,n)a=lcm(a,d[i]),b=gcd(b,v[i]);
		rep(i,n)cout<<a*v[i]/d[i]/b<<endl;
	}
	return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	int h, w; cin >> h >> w;
	vector<string> g(h);
	rep(i, 0, h) cin >> g[i];
	bool isbad = false;
	rep(i, 0, h) rep(j, 0, w) if (g[i][j] == '#') {
		bool gd =
			i > 0 && g[i - 1][j] == '#' ||
			i < h - 1 && g[i + 1][j] == '#' ||
			j > 0 && g[i][j - 1] == '#' ||
			j < w - 1 && g[i][j + 1] == '#';
		if (!gd) isbad = true;
	}
	cout << (isbad ? "No" : "Yes") << endl;
}


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

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  if(h2 == 0) h2 += 24;
  
  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
 
using namespace std;
 
int main(){
    int m,f,r;
    char grade;
    while(true){
        scanf("%d %d %d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1){
            grade = 'F';
        }else if(m+f >= 80){
            grade = 'A';
        }else if(m+f >= 65){
            grade = 'B';
        }else if(m+f >= 50){
            grade = 'C';
        }else if(m+f >= 30){
            grade = (r >= 50)? 'C':'D';
        }else{
            grade = 'F';
        }
        printf("%c\n",grade);
    }
}


Measured memory_bytes: 2664
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
// #pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
// char buf[1<<20],*p1=buf,*p2=buf;
// #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
bool v[120];
signed main(){
#ifdef LOCAL_LIGEN
	freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	int n=read();
	FOR(i,1,9)FOR(j,1,9)v[i*j]=1;
	if(v[n])puts("Yes");else puts("No");
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}


Measured memory_bytes: 256
/* Author:bhagatsunny96
         JGEC
	   template__
	lets_code_it_ */
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
#define loopr(n) for(long long int i=n-1;i>=0;i--)
#define lrp(a,b) for(long long int i=a;i<=b;i++)
#define lrn(a,b) for(long long int i=b;i>=a;i--)
#define endl '\n'
#define vec vector<ll>v;
#define imap map<ll,ll>mip;
#define umap unordered_map<ll,ll>ump;
#define sett set<ll>st;
using namespace std;
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);  
 }
 ll power(ll x, unsigned ll y) 
 { 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++) 
    {
       if(num%i==0) 
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) 
{ 
    return (a.first > b.first); 
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
string sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   return str;
} 
void countSort(ll arr[], ll n, ll exp) 
{ 
	ll output[n];
	ll i, count[10] = {0}; 
	for (i = 0; i < n; i++) 
		count[ (arr[i]/exp)%10 ]++; 
	for (i = 1; i < 10; i++) 
		count[i] += count[i - 1]; 
	for (i = n - 1; i >= 0; i--) 
	{ 
		output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; 
		count[ (arr[i]/exp)%10 ]--; 
	} 
	for (i = 0; i < n; i++) 
		arr[i] = output[i]; 
} 
void radixsort(ll arr[], ll n) 
{
    ll mx = arr[0]; 
	for (ll i = 1; i < n; i++) 
		if (arr[i] > mx) 
			mx = arr[i];
	ll m =mx;
	for (ll exp = 1; m/exp > 0; exp *= 10) 
		countSort(arr, n, exp); 
} 
void print(ll arr[], ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
} 
int main() 
{
    fIO
    ll n,a,b;
    ll ans=0;
    cin>>n>>a>>b;
    ll s=a+b;
    if(n>=s)
    {
    if(n%s==0)
    {
        ans=n/s;
        ans=ans*a;
    }
    else
    {
        ans=(n/s);
        ans=ans*a;
        if(n%s>=a)
        ans=ans+a;
        else
        ans=ans+(n%s);
    }
    }
    else
    {
        ans=min(n,a);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

def rev(s):
    new_s = list(reversed(s))
    return new_s

S = deque(input())
N = int(input())
r_flag=False
for _ in range(N):
    Q = input()
    if Q.isdigit():
        r_flag=not r_flag
    else:
        q = Q.split()
        if r_flag:
            if q[1]=="1":
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if q[1]=="1":
                S.appendleft(q[2])
            else:
                S.append(q[2])
if r_flag:
    print(''.join(reversed(S)))
else:print(''.join(S))


Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int main(){
	int s;
	bool upperisYY = false;
	bool lowerisYY = false;

	// read values
	cin >> s;

	// some processing here
	if (s % 100 == 0 || s % 100 > 12) {
		lowerisYY = true;
	}
	if (s < 100 || s > 1299) {
		upperisYY = true;
	}

	if (lowerisYY && upperisYY) {
		cout << "NA" << endl;
	} else if (lowerisYY) {
		cout << "MMYY" << endl;
	} else if (upperisYY) {
		cout << "YYMM" << endl;
	} else {
		cout << "AMBIGUOUS" << endl;
	}

	return 0;
}

Measured memory_bytes: 256