akhauriyash/Code-Regression huggingface dataset:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a,b = cin()
    l = []
    for i in range(a):
        c = list(input())
        l.append(c)
    # print(l[1][0])
    for i in range(2*a):
        for j in range(b):
            print(l[i//2][j],end="")
        print("")


if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
  int N, L;
  string temp;
  vector<string> word;
  cin >> N >> L;
 
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    word.push_back(temp);
  }

  sort(word.begin(), word.end());
  for(int i = 0; i < word.size(); ++i){
    cout << word[i];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
const int INF = 100000000, mod = 1000000007;
using namespace std;



int main() {
    int n, s[110], sum = 0, hasuu = INF;
    bool hasuucheck = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sum += s[i];
        if (s[i] % 10 != 0) {
            hasuu = min(hasuu, s[i]);
            hasuucheck = true;
        }
    }

    if (sum % 10 != 0) cout << sum << endl;
    else {
        if (hasuucheck) cout << sum - hasuu << endl;
        else cout << '0' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = []
for h in range(H):
    aw = input()
    if '#' not in aw:
        continue
    a.append(aw)

skip = []
counter = 0
for i in range(W):
    if '#' not in [x[i] for x in a]:
        skip.append(i)

for row in a:
    for i in range(len(row)):
        if i not in skip:
            print(row[i], end='')
    print()

Measured memory_bytes: 4468
#include<stdio.h>
 
int main() {
  int a;
  int b;
  int t;
  int result;
  
  scanf("%d %d %d", &a, &b, &t);
  
  result = (int)(((float)t + 0.5) / (float)a) * b;
  printf("%d", result);
}

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

#define N 100000

int main(void){
    bool prime[N+1];
    for (size_t i = 2; i <= N; i++)
    {
        prime[i]=true;
    }
    for (size_t i = 0; i <= sqrt(N); i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N]={};
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&prime[i]&&prime[(i+1)/2])
        {
            likeCnt[i]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l[q],r[q];
    for (size_t i = 0; i < q; i++)
    {
        cin >>l[i]>>r[i];
    }
    for (size_t i = 0; i < q; i++)
    {
        cout << likeCnt[r[i]]-likeCnt[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
int w=ir.nextInt();
int h=ir.nextInt();
int x=ir.nextInt();
int y=ir.nextInt();
int r=ir.nextInt();
out.println(x>=r&&w-x>=r&&y>=r&&h-y>=r?"Yes":"No");
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24524
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;

char march[] = {'M','A','R','C','H'};

int main() {
    int N;
    cin >> N;
    
    map<char, int> names;
    string s;
    rep(i,N) {
        cin >> s;
        names[s[0]]++;
    }
    
    ll ans = 0;
    
    for ( int i = 0; i < 3; i++ ) {
        for ( int j = i+1; j < 4; j++ ) {
            if ( i==j ) continue;
            for ( int k = j+1; k < 5; k++ ){
                if ( i==k || j==k) continue;
                ans += (ll)( names[march[i]] * names[march[j]] * names[march[k]] );
            }
        }
    }
    cout1(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	vector<ll> v;
	for(int i=1; i<n; i++){
		if(a[i]!=a[i-1]) v.push_back(a[i]-a[i-1]);
	}
	int ans=0;
	for(int i=0; i<v.size(); i++){
		if(v[i]*v[i+1]<0){
			ans++;
			i++;
		}
	}
	cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 2168
package main

import "fmt"

func main() {
	group := make(map[int]int)
	group[1] = 0
	group[3] = 0
	group[5] = 0
	group[7] = 0
	group[8] = 0
	group[10] = 0
	group[12] = 0

	group[4] = 1
	group[6] = 1
	group[9] = 1
	group[11] = 1

	group[2] = 2

	x := 0
	y := 0
	fmt.Scan(&x, &y)
	if group[x] == group[y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
def d_rgb_triplets():
    N = int(input())
    S = input()

    red, green, blue = 0, 0, 0
    for ch in S:
        if ch == 'R':
            red += 1
        elif ch == 'G':
            green += 1
        elif ch == 'B':
            blue += 1
    total = red * green * blue

    sub = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = 2 * j - i  # j-i = k-j を満たす k
            if j < k < N and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                sub += 1
    return total - sub

print(d_rgb_triplets())

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

int main() {
  int n,x;
  cin >> n >> x;
  while(n!=0 || x!=0) {
      int count=0;
      for (int i=1; i<=n; i++) {
          for (int j=1; j<i; j++) {
              for (int k=1; k<j; k++) {
                  if (i+j+k==x) count++;
              }
          }
      }
      cout << count << endl;
      cin >> n >> x;
  }
}


Measured memory_bytes: 3096
g1 = [4, 6, 9, 11]
g2 = [1, 3, 5, 7, 8, 10, 12]

x, y = map(int, input().split())

if x == 2 and y == 2:
    print('Yes')
elif x in g1 and y in g1:
    print('Yes')
elif x in g2 and y in g2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std;
#define ll long long
 
int n, f[10][10];
ll ans;
int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        int x=i;
        while(x>=10) x/=10;
        ++f[x][i%10];
    }
    for(int i=1; i<=n; ++i){
        int x=i;
        while(x>=10) x/=10;
        ans+=f[i%10][x];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define endl '\n'
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define cans cout<<ans<<endl
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}

//}}}
const ll maxn=2005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

int main(){
    IOS;
    ll a[3];
    rep(i,3){
        cin>>a[i];
    }
    sort(a,a+3);
    ll ans=a[2]-a[1];
    a[0]+=ans;
    if((a[2]-a[0])%2)
        ans+=((a[2]+1-a[0])/2+1);
    else ans+=((a[2]-a[0])/2);
    cans;
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  int m; cin >> m;

  ll sum = accumulate(all(t),0LL);
  rep(i, m) {
    int p, x; cin >> p >> x;
    
    cout << sum - (t[p-1] - x) << endl;
  }
  
  return (0);
}

Measured memory_bytes: 3664
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()))
point = []
for _ in range(N):
    point.append(K)
for a in A:
    point[a-1] += 1
for n in range(0,N):
    point[n] -= Q

for p in point:
    if p <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 11784
//verify http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
using cost_t=int;

struct Edge {
    int from, to;
    cost_t cost;
    Edge(int from, int to, cost_t cost) : from(from), to(to), cost(cost) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

const cost_t INF=1e9;
void spfa(int s,Graph& g,vector<cost_t>& d){
    int n=g.size();
    d.assign(n,INF);
    vector<int> used(n);
    used[s]=true;
    d[s]=0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        used[v]=false;
        for(auto& e:g[v]){
            cost_t tmp = d[v]+e.cost;
            if(!used[e.to] && tmp<d[e.to]){
                que.push(e.to);
                used[e.to]=true;                
            }
            d[e.to]=min(d[e.to],tmp);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int V,E,r;
    cin>>V>>E>>r;
    Graph g(V);
    for(int i=0;i<E;i++){
        int s,t,d;
        cin>>s>>t>>d;
        g[s].push_back(Edge{s,t,d});
    }
    vector<cost_t> d;
    spfa(r,g,d);
    for(int i=0;i<V;i++){
        if(d[i]<INF) cout<<d[i]<<"\n";
        else cout<<"INF"<<"\n";
    }
    
    return 0;
}



Measured memory_bytes: 15128
#Byakko Delivery Company: ?
from heapq import heappop, heappush
from string import ascii_lowercase as al
dic = dict([(c,i) for i, c in enumerate(al)])
f = lambda (h, v):(dic[h], int(v) - 1)
g = lambda s:f(s.split("-"))

def solve():
    hq = [(0, start[0], start[1])]
    while len(hq) != 0:
        cost, cy, cx = heappop(hq)
        if (cy, cx) == goal:
            return cost
        if (cost, cy, cx) in memo:
            continue
        memo[(cost, cy, cx)] = True
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if 0 <= ny < M and 0 <= nx < N:
                nc = condition[ny][nx][cy][cx] + D + cost
                if field[ny][nx] == 0:
                    heappush(hq, (nc, ny, nx))
                else:
                    if dy == 0:
                        if (nc / field[ny][nx]) % 2 == 1:
                            heappush(hq, (nc, ny, nx))
                    else:
                        if (nc / field[ny][nx]) % 2 == 0:
                            heappush(hq, (nc, ny, nx))
while True:
    M, N = map(int, raw_input().split())
    if M | N == 0:
        break
    memo = {}
    D = input()
    field = [[0] * N for _ in xrange(M)]
    condition = [[[[0] * N for _ in xrange(M)] for _ in xrange(N)] for _ in xrange(M)]
    for _ in xrange(input()):
        p, k = raw_input().split()
        h, v = g(p)
        field[h][v] = int(k)

    for _ in xrange(input()):    
        (h1, v1), (h2, v2) = map(g, raw_input().split())
        condition[h1][v1][h2][v2] = condition[h2][v2][h1][v1] = 1 << 30

    for _ in xrange(input()):
        p1, p2, d = raw_input().split()
        h1, v1 = g(p1)
        h2, v2 = g(p2)
        condition[h1][v1][h2][v2] = condition[h2][v2][h1][v1] = int(d)

    start, goal = map(g, raw_input().split())
    print solve()

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2);
    res=((res)*(res)) ;
    if(p%2)
        res=(res*n) ;
    return res ;
}

// freopen ("myfile.txt","w",stdout);
    ll n , m , arr[2005] , brr[2005] , com[2005];

int main()
{
    ENGZ;
    cin>>n >>m ;
    for(int i=0 ; i<n ; i++)cin>>arr[i] ;
    for(int i=0 ; i<m ;i++)cin>>brr[i] ;

    for(int i=0 ; i<m ; i++)
    {
        ll tmp = 0 ;
        for(int j=0 ; j<n ; j++)
        {
            if(j>0)
            {
                if(arr[j] == brr[i])
                {
                    ll tt = tmp+ com[j] ;
                    com[j] += (tmp+1)%mod;
                    tmp = tt ;
                }
                else
                {
                    tmp+=com[j] ;
                }
                continue;
            }
            tmp += com[j] ;
            if(arr[j] == brr[i])
                com[j]++ ;
        }
    }
    ll ans = 0;
    for(int i=0 ; i<n ; i++)
    {
        ans+=com[i] ;
        ans %= mod ;
    }
    cout<<ans+1 <<endl ;
    return 0;
}


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

int n, x, cnt, a, b, c;

int main() {

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x);

        cnt = 0;
        while (x % 2 == 0)
            x /= 2, ++cnt;

        if (cnt == 1)
            ++a;
        else if (cnt >= 2)
            ++b;
        else if (cnt == 0)
            ++c;

    }

    c += (a % 2);
    puts(b - c >= -1 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
 int alice, bob;
 scanf("%d%d", &alice, &bob);
 if(alice == 1) alice = 14;
 if(bob == 1) bob = 14;
 if(alice > bob) printf("Alice\n");
 else if(alice < bob) printf("Bob\n");
 else printf("Draw");
}

Measured memory_bytes: 128
#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");}
/* }}} */

signed main() 
{
    string s;
    cin >> s;
    bool flag=true;
    string d1="maerd",d2="remaerd",e1="esare",e2="resare";
    reverse(ALL(s));
    while(flag)
    {
        if(s.substr(0,5)==d1) s.erase(s.begin(),s.begin()+5);
        else if(s.substr(0,5)==e1) s.erase(s.begin(),s.begin()+5);
        else if(s.substr(0,7)==d2) s.erase(s.begin(),s.begin()+7);
        else if(s.substr(0,6)==e2) s.erase(s.begin(),s.begin()+6);
        else if(s.empty()) break;
        else flag=false;
    }
    flag? print("YES") : print("NO");
    
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define FOREQ(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const ll MOD = 1e+9 + 7;
void Mul(ll lhs[4], ll rhs[4]) {
  ll temp[4];
  MEMSET(temp, 0);
  REP(y, 2) {
    REP(x, 2) {
      REP(k, 2) {
        temp[y * 2 + x] = (temp[y * 2 + x] + lhs[y * 2 + k] * rhs[k * 2 + x]) % MOD;
      }
    }
  }
  memcpy(lhs, temp, sizeof(temp));
}

ll Fib(ll x) {
  ll ret[4] = { 1, 0, 0, 1 };
  ll base[4] = { 1, 1, 1, 0 };
  while (x > 0) {
    if (x & 1) { Mul(ret, base); }
    Mul(base, base);
    x >>= 1;
  }
  return ret[0];
}

ll Sum(ll x) {
  ll ret = ((x + 1) / 2) * ((x + 1) / 2 + 1);
  if (x & 1) { ret -= (x + 1) / 2; }
  return ret;
}

ll n;
int main() {
  while (scanf("%lld", &n) > 0) {
    ll ans = 0;
    ll index = sqrt(n) * 2;
    index = max(0LL, index - 3);
    while (Sum(index) < n) { index++; }
    ll offset = n - Sum(index - 1) - 1;
    ll w = (index + 1) / 2;
    if (offset <  (w + 1) / 2) {
      ll x = index - offset * 2;
      ll y = 1 + offset * 2;
      ans = Fib(x) * Fib(y) % MOD;
    } else {
      offset -= (w + 1) / 2;
      ll x = index - w + 1;
      ll y = w;
      if (w % 2 == 1) { y--; x++; }
      x += 2 * offset;
      y -= 2 * offset;
      ans = Fib(x) * Fib(y) % MOD;
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 0
import numpy as np

MOD = 1000000007
S = input()[::-1]

a = 10 ** np.arange(6) % 13
b = np.tile(np.arange(10),(6, 1))
c = a * b.T % 13
c = c.T
f = np.zeros((6, 13, 13), dtype=np.int64)
for i in range(6):
    f[i, 0, c[i]] = 1
    for j in range(12):
        f[i, j + 1] = np.roll(f[i, j], 1)

prev = np.zeros(13, dtype=np.int64)
prev[0] = 1
digit = 0

for i, c in enumerate(S):
    k = i % 6
    if c == '?':
        cur = np.dot(prev, f[k]) % MOD
        prev, cur = cur, prev
    else:
        digit += a[k] * (ord(c) - ord('0'))

m = (5 - digit) % 13
print(prev[m])

Measured memory_bytes: 12620
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

class Main {
  private static class Node {
    public long val = 0;
    public boolean checked = false;
    public List<Node> children = new ArrayList<>();
  }
  private static void solve(int n, int q, int[][] edges, int[][] operations) {
    Node[] nodes = new Node[n];
    for (int i = 0; i < n; i++) {
      nodes[i] = new Node();
    }
    for (int i = 0; i < n - 1; i++) {
      int edge1 = edges[i][0] - 1;
      int edge2 = edges[i][1] - 1;
      nodes[edge1].children.add(nodes[edge2]);
      nodes[edge2].children.add(nodes[edge1]);
    }
    for (int i = 0; i < q; i++) {
      int p = operations[i][0];
      int x = operations[i][1];
      nodes[p - 1].val += x;
    }
    Deque<Node> queue = new ArrayDeque<>();
    queue.offer(nodes[0]);
    nodes[0].checked = true;
    while (!queue.isEmpty()) {
      Node node = queue.poll();
      for (Node child : node.children) {
        if (child.checked) continue;
        child.val += node.val;
        child.checked = true;
        queue.add(child);
      }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      if (i > 0) sb.append(" ");
      sb.append(nodes[i].val);
    }
    System.out.println(sb.toString());
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] nums = sc.nextLine().split(" ");
    int n = Integer.parseInt(nums[0]);
    int q = Integer.parseInt(nums[1]);
    int[][] edges = new int[n - 1][2];
    for (int i = 0; i < n - 1; i++) {
      String[] edge = sc.nextLine().split(" ");
      edges[i][0] = Integer.parseInt(edge[0]);
      edges[i][1] = Integer.parseInt(edge[1]);
    }
    int[][] operations = new int[q][2];
    for (int i = 0; i < q; i++) {
      String[] operation = sc.nextLine().split(" ");
      operations[i][0] = Integer.parseInt(operation[0]);
      operations[i][1] = Integer.parseInt(operation[1]);
    }
    sc.close();
    solve(n, q, edges, operations);
  }
}

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

void rec(int i, int j = -1) {
  for(int k : v[i]) {
    if(k == j) continue;
    ans[k] += ans[i];
    rec(k, i);
  }
}


void solve() {
  int n, q;
  cin >> n >> q;
  v.resize(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  rec(0);
  rep(i,n) cout << ans[i] << " ";
}

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

Measured memory_bytes: 45312
#include<bits/stdc++.h>
using namespace std;
int n,k,t,a[4010],vis[4010][2];
long long fac[4010],g[4010],ans,f[4010][4010][2],p=924844033;
int main() {
    //freopen("permutation.in","r",stdin);
    //freopen("permutation.out","w",stdout);
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        for(int j=0; j<2; j++)
            if(!vis[i][j]) {
                int x=i,y=j,len=0;
                while(x<=n) {
                    vis[x][y]=1;
                    len++;
                    x+=k;
                    y^=1;
                }t+=len;
                a[t]=1;
            }
    f[1][0][0]=1;
    for(int i=1; i<=t; i++)
        for(int j=0; j<=n; j++) {
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%p;
            if(!a[i]) f[i+1][j+1][1]=f[i][j][0];
        }
    for(int i=1; i<=n; i++) g[i]=(f[t][i][0]+f[t][i][1])%p;
    fac[0]=1;
    for(int i=1; i<=n; i++) fac[i]=fac[i-1]*i%p;
    ans=fac[n];
    for(int i=1,j=-1; i<=n; i++,j=-j) ans=(ans+p+j*g[i]*fac[n-i])%p;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 249728
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    d = 2 * (x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3 + x1 * y2 - x2 * y1)
    px = ((y2 - y3) * (x1 ** 2 + y1 ** 2) + (y3 - y1) * (x2 ** 2 + y2 ** 2) + (y1 - y2) * (x3 ** 2 + y3 ** 2)) / d
    py = -1 * ((x2 - x3) * (x1 ** 2 + y1 ** 2) + (x3 - x1) * (x2 ** 2 + y2 ** 2) + (x1 - x2) * (x3 ** 2 + y3 ** 2)) / d
    print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, ((x1 - px) ** 2 + (y1 - py) ** 2) ** 0.5))

Measured memory_bytes: 7596
n,m,q=map(int,input().split())
P=[]
for inp in range(q):
    a,b,c,d=map(int,input().split())
    P.append((a,b,c,d))

now=[]
stc=[now[:]]
res=[]

def saiki(x,c,ma,n):
    if c== n:
        #print(now)
        res.append(now[:])
        return
    
    for i in range(x,ma+1):
        now.append(i)
        saiki(i,c+1,ma,n)
        now.pop()

saiki(1,0,m,n)  

max_score=0
for C in res:
    score=0
    for i in range(q):
        if C[P[i][1]-1]-C[P[i][0]-1]==P[i][2]:
            score+=P[i][3]
    max_score=max(score,max_score)

print(max_score)
        

Measured memory_bytes: 22888
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

int main() {
	int h, w;
	char input;
	int in[300] = { 0 };
	//int count2 = 0;
	int count4 = 0;
	bool isOdd = false;


	cin >> h >> w;
	REP(i, h*w) {
		cin >> input;
		in[(int)input]++;
	}
	if (h*w % 2 == 1) {
		isOdd = true;
	}

	int tmp;
	for(int i = (int)'a'; i <= (int)'z'; i++) {
		tmp = in[i];
		if (tmp >= 4) {
			count4 += tmp/4;
			tmp %= 4;
		}
		if (tmp % 2 == 1) {
			if (isOdd) {
				isOdd = false;
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	if (count4 < (h / 2)*(w / 2)) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner ac = new Scanner(System.in);

		int a = ac.nextInt();
		ac.close();
		int h = a / 3600;
		int m = ( a % 3600) / 60;
		int s = a % 60;
		
		System.out.println(h + ":" + m + ":" + s);

	}

}



Measured memory_bytes: 26276
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W;
	char A[10][10];
	scan(H);scan(W);
	int l=0;
	int ans=1;
	rep(i,H){
		scan(A[i]);
		rep(j,W){
			if(A[i][j]=='#'){
				if(j<l) ans=0;
				l=max(j,l);
			}
		}
	}
	if(ans) prin("Possible");
	else prin("Impossible");
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int max_s, min_s, sum;
        cin >> max_s >> min_s;
        sum = max_s + min_s;
        if(max_s<min_s) swap(max_s, min_s);
        for(int i=2; i<n; i++)
        {
            int s;
            cin >> s;
            sum += s;
            if(max_s<s) max_s = s;
            if(min_s>s) min_s = s;
        }
        cout << (sum - max_s - min_s) / (n - 2) << endl;
    }
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdlib>
using namespace std;

int N;

vector<int> mem;
vector<int> mas;


int w[16];
int h[16];
int a[4][4];

int memo[1<<16];

int main(){
	for(int i = 0 ; i < (1<<16) ; i++) memo[i] = -1;
	int N;
	cin >> N;
	for(int i = 0 ; i < N ; i++){
		cin >> w[i];
		cin >> h[i];
	}
	for(int i = 0 ; i < 4 ; i++)
		for(int j = 0 ; j < 4 ; j++){
			char c;
			cin >> c;
			if( c == 'R') a[i][j] = 0;
			if( c == 'G') a[i][j] = 1;
			if( c == 'B') a[i][j] = 2;
		}
		
	for(int i = 0 ; i < N ; i++){
		for(int c = 0 ; c < 3 ; c++){
			for(int j = -4 ; j < 4 ; j++){
				for(int k = -4 ; k < 4 ; k++){
					int mask = 0;
					int res = 0;
					for(int l = 0 ; l < h[i] ; l++){
						for(int m = 0 ; m < w[i] ; m++){
							int tx = j + l;
							int ty = k + m;
							if( tx < 0 || tx >= 4 || ty >= 4 || ty < 0 ) continue;
							mask |= 1 << (ty * 4 + tx);
							res  |= ( a[ty][tx] == c ) << (ty * 4 + tx );
							
						}
					}
					mem.push_back(res);
					mas.push_back(mask);
				}		
			}
		}
	}
	queue<int> Q;
	
	Q.push(0);
	while(Q.size()){
		int q = Q.front(); Q.pop();
		for(int i = 0 ; i < mas.size() ; i++){
			int next = q & ~mas[i];
			next |= mem[i];
			if( memo[next] == -1){
				memo[next] = memo[q]+1;
				Q.push(next);
			}
		}
	}
	cout << memo[(1<<16)-1] << endl;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a=0;
  cin>>N;
  int T[N];
  for(int i=0;i<N;i++){
    cin>>T[i];
    a+=T[i];
  }
  int M;
  cin>>M;
  int P[M],X[M],A[M];
  for(int i=0;i<M;i++){
    cin>>P[i]>>X[i];
    A[i]=a-T[P[i]-1]+X[i];
  }
  for(int i=0;i<M;i++) cout<<A[i]<<endl;
}

Measured memory_bytes: 256
import           Data.Bits ((.&.), bit)
import           Data.List (inits, tails, foldl')

main :: IO ()
main = do
  [n, k] <- take 2 . map read . words <$> getLine
  as <- take n . map read . words <$> getLine
  print $ f k as

-- C004_scrambled 以降 TLE
f :: Int -> [Int] -> Int
f k as =
  let
    aaa = beautifullnesses as
    bSize = bitSize $ maximum aaa
  in
    fst $ foldl' g (0, aaa) $ map bit [bSize, bSize - 1 .. 0]
  where
    g (acc, bbb) i =
      let
        bb = filter (\b -> b .&. i == i) bbb
      in
        if length bb >= k then (acc + i, bb) else (acc, bbb)

beautifullnesses :: [Int] -> [Int]
beautifullnesses =
  map sum .
  concatMap (tail . inits) .
  init . tails

bitSize :: Int -> Int
bitSize n = fst $ head $ dropWhile ((n >=) . snd) $ zip [0..] $ iterate (2 *) 1


Measured memory_bytes: 43388
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    string s;
    cin >> s;
    bool flag = false;
    int c = 0;
    int ans = 0;
    for(int i = 0; i < 3; ++i){
        if(flag){
            if(s[i] == 'R') ++c;
            else{
                chmax(ans, c);
                c = 0;
                flag = false;
            }
        }
        else{
            if(s[i] == 'R'){
                c = 1;
                flag = true;
            }
        }
    }
    chmax(ans, c);
    cout << ans << endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
	class Program
	{
		/*
			string s = Console.ReadLine();
			string[] ST = Console.ReadLine().Split(' ').ToArray();
			string S = strArray[0];
			string T = strArray[1];

			int[] HWN = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int H = intArray[0];
			int W = intArray[1];
			int N = int.Parse(Console.ReadLine());

			List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList());
			
			double[] R = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

			Boolean ok = false;
			
			List<int> dp = Enumerable.Repeat(値, 個数).ToList();
			
			Console.WriteLine(ans);
			Console.WriteLine("Yes");
			Console.WriteLine("No");
			Console.ReadKey();
			Console.WriteLine(cnt);

			for(int i= 0; i < N; i++)
		*/

		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int[] P = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int cnt = 0;

			for (int i = 0; i < N; i++)
				if (P[i] != i + 1)
					cnt++;
			if(cnt == 0 ||cnt == 2)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");
		}

		class Item : IComparable
		{
			public string A;
			public int B;
			public Item(string a, int b)
			{
				this.A = a;
				this.B = b;
			}
			public int CompareTo(object obj)
			{
				return B - ((Item)obj).B;
			}
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			char[] val1 = word1.ToCharArray();
			char[] val2 = word2.ToCharArray();
			Array.Sort(val1);
			Array.Sort(val2);
			word1 = new string(val1);
			word2 = new string(val2);

			return word1 == word2;
			//return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}

		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 28152
#include<stdio.h>
	int main(){
		int a;
		scanf("%d",&a);
		
		for (int i =1 ;i<=9 ; i++){
			for(int j=1;j<=9;j++){
				if(i*j==a){
					puts("Yes");
					return 0;
				}
			}
		}

	puts("No");
}

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


int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
	int n;
	cin >> n;
	vector<int> height;
	int h;
	for (int j = 0; j < n; j++){
	    cin >> h;
	    height.push_back(h);
	}
	vector<int> diff;
	for (int j = 0; j < n-1; j++){
	    diff.push_back(height[j+1] - height[j]);
	}
	sort(diff.begin(), diff.end());
	if (diff[diff.size()-1] >= 0) cout << diff[diff.size()-1] << " ";
	else cout << 0 << " ";
	if (diff[0] <= 0) cout << -diff[0] << endl;
	else cout << 0 << endl;

    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#define MAX_N 1000001
const unsigned long long int modNum = 1e9+7;

int main()
{
	int N,M;
	cin>>N>>M;
	unsigned long long int *ans = new unsigned long long int[N+1];
	set<int> brokenStairs;
	for(int i = 0; i <M;i++){
		int num;
		cin>>num;
		brokenStairs.insert(num);
	}
	ans[0] = 1;
	if(brokenStairs.count(1) == 0){
		ans[1] = 1;
	}else{
		ans[1] = 0;
	}
	for(int i = 2; i <= N; i++){
		if( brokenStairs.count(i) == 1){
			ans[i] = 0;
		}else{
			ans[i] = ans[i-1] + ans[i-2];
		}
		ans[i]%=modNum;
	}
	cout<<ans[N]<<endl;
	return 0;
}



Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int dy[] = {1, 0, -1, 0};
int dx[] = {0, -1, 0, 1};
bool used[2][502][502];
int office[2][502][502];
int cost[2][110000];
int w[2];
int h[2];
int x[2];
int y[2];

int main(){
	int R;
	while(cin >> R && R){
		fill(&office[0][0][0], &office[1][501][501] + 1, INF);
		fill(&cost[0][0], &cost[1][109999] + 1, INF);
		memset(used, false, sizeof(used));
		for(int i = 0; i < 2; i++){
			cin >> w[i] >> h[i] >> x[i] >> y[i];
			for(int j = 1; j <= h[i]; j++){
				for(int k = 1; k <= w[i]; k++){
					cin >> office[i][j][k];
				}
			}
		}
		for(int i = 0; i < 2; i++){
			priority_queue<PP, vector<PP>, greater<PP> > que;
			cost[i][0] = 0;
			int m_cost = 0;
			int count = 1;
			que.push(PP(1, P(y[i], x[i])));
			while(!que.empty()){
				PP pp = que.top();
				que.pop();
				int c = pp.first;
				if(c == INF || count >= R + 10 || count > h[i] * w[i]) break;
				m_cost = max(m_cost, c);
				int y1 = pp.second.first;
				int x1 = pp.second.second;
				if(used[i][y1][x1]) continue;
				used[i][y1][x1] = true;
				cost[i][count++] = m_cost;
				for(int j = 0; j < 4; j++){
					int y2 = y1 + dy[j];
					int x2 = x1 + dx[j];
					if(used[i][y2][x2]) continue;
					que.push(PP(office[i][y2][x2], P(y2, x2)));
				}
			}
		}
		int res = INF;
		for(int i = 0; i <= R; i++){
			res = min(res, cost[0][i] + cost[1][R-i]);
		}
		cout << res << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define SZ(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
using namespace std;

typedef long long ll;
typedef pair<int,int> PI;
typedef unsigned long long ull;

#define PR(...) do{cerr << "line : " << __LINE__ << endl; pr(#__VA_ARGS__, __VA_ARGS__);}while(0);
template<class T>
void pr(const string& name, T t){
  cerr << name << ": " << t << endl;
}

template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto comma_pos = names.find(',');
  cerr << names.substr(0, comma_pos) << ": " << t << ", ";
  
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest ...);
}

template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
template<class T> ostream& operator<< (ostream& o, const set<T> &v){o << "{";for(auto e : v) o << e << ", ";return o << "}";}
template<class T, class U> ostream& operator<< (ostream& o, const map<T,U> &v){o << "{";for(auto e : v) o << e.F << ": " << e.S << ", ";return o << "}";}

//                < v > ^
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
#define endl '\n'


int main(int argc, char *argv[])
{
  int x, y, s;
  while(cin >> x >> y >> s && x){
    int ans = 0;
    for(int i = 1; i < s; ++i)
      for(int j = 1; j < s; ++j){
	if(i * (100 + x) / 100 + j * (100 + x) / 100 == s){
	  ans = max(ans, i * (100 + y) / 100 + j * (100 + y) / 100);
	}
      }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
//https://atcoder.jp/contests/abc179/tasks/abc179_
#include <iostream>
 
using namespace std;
 
int main() {
    int n;
    cin>>n;

    unsigned long long ans=0;
    for (int a=1; a<n; a++) {
        for (int b=1; b<=n/a; b++) {
            int c=n-a*b;
            if (c>0 && n==a*b+c) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	/* vector<long long> f(n+1);
	for(long long i=0;i<=n;i++)
	{
		if(i<2)
			f[i]=1;
		else
			f[i]=i*f[i-2];
		cout << i << " : " << f[i] << endl;
	}
	*/

	if(n%2==1)
		cout << 0 << endl;
	else
	{
		long long cnt=0;
		long long div=5;
		while(div<=n)
		{
			cnt+=(n/div)/2;
			div*=5;
		}
		cout << cnt << endl;
	}
}


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

int main(){
    ll A,B,K;
    cin >> A >> B >> K;
    if (K <= A){
        cout << A - K << " " << B << endl;
    }
    else if (K <= A + B){
        cout << 0 << " " << B -(K - A) << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
        }
        if (h > sum) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 48956
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		int N = S.length();
		String S1 = S.substring(0, N / 2);
		String S2 = S.substring(((N + 3) / 2) - 1 , N);
		System.out.println(S1.equals(S2) ? "Yes" : "No");

		stdIn.close();
	}
}

Measured memory_bytes: 35652