akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a) distance((v).begin(),upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a) distance((v).begin(),lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};

void Main(){
  int h,w;
  cin>>h>>w;
  v(string) s(h);
  cin>>s;

  vvi dp(h,vi(w,0));
  bool f = false;
  rep(i,h){
    if(s[i][0] == '#') f = true;
    if(f) dp[i][0] = 0;
    else  dp[i][0] = 1;
  }
  f = false;
  rep(j,w){
    if(s[0][j] == '#') f = true;
    if(f) dp[0][j] = 0;
    else  dp[0][j] = 1;
  }

  rep(i,h-1){
    rep(j,w-1){
      dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
      if(dp[i+1][j+1]>MOD) dp[i+1][j+1]-=MOD;
      if(s[i+1][j+1] =='#') dp[i+1][j+1] = 0;
    }
  }
  cout<<dp[h-1][w-1]<<endl;
  
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

typedef long long ll;

int main(){
	const int mod = 2019;
	ll L,R;
	cin >> L >> R;

	ll ans=1e9;
	ll range = min(R,L+mod);
	for(ll i=L; i<range; i++){
		for(ll j=i+1; j<=range; j++){
			ans = min(ans,i*j%mod);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n, m, k; cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i*j + (n - i)*(m - j) == k) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n"; return 0;
}

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

using namespace std;

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

  int n, r;
  cin >> n >> r;
  if (n < 10) {
    cout << 100 * (10 - n) + r;
  } else {
    cout << r;
  }

  return 0;
}

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

  
int main()
{     int n;
      vector<int> h;
      cin>>n;
      h.push_back(0);
      for(int i=0;i<n;i++)
      { int x;
        cin>>x;
        h.push_back(x);
      } 
     int dp[n+1]={0};
     dp[2]=abs(h[1]-h[2]);
    
     for(int i=3;i<=n;i++)
      {  dp[i]= min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
       }
      cout<<dp[n];

      return 0;
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

int main(){
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for(int i = d; i <= 100; i += d) if(l <= i && i <= r) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	HashMap<String, Integer> map;
	LinkedList<String> que;

	void run() {
		map = new HashMap<String, Integer>();
		que = new LinkedList<String>();
		int cnt = 0;
		que.add("01234567");
		map.put("01234567", cnt);
		while (!que.isEmpty()) {
			cnt++;
			int size = que.size();
			for (int i = 0; i < size; i++) {
				String now = que.poll();
				int zero = now.indexOf('0');
				if (zero != 0 && zero != 4) {
					char[] next = now.toCharArray();
					char t = next[zero - 1];
					next[zero] = t;
					next[zero - 1] = '0';
					setParam(next, cnt);
				}
				if (zero != 3 && zero != 7) {
					char[] next = now.toCharArray();
					char t = next[zero + 1];
					next[zero] = t;
					next[zero + 1] = '0';
					setParam(next, cnt);
				}
				char[] next = now.toCharArray();
				char t = next[(zero + 4) % 8];
				next[zero] = t;
				next[(zero + 4) % 8] = '0';
				setParam(next, cnt);
			}
		}
		while (sc.hasNext()) {
			String key = "";
			for (int i = 0; i < 8; i++) {
				key += sc.nextInt();
			}
			System.out.println(map.get(key));
		}
	}

	void setParam(char[] next, int cnt) {
		String nextS = String.valueOf(next);
		if (!map.containsKey(nextS)) {
			map.put(nextS, cnt);
			que.add(nextS);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 39752
use std::cmp;
use std::collections::*;

pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn lower_bound<T: std::cmp::Ord>(v: &Vec<T>, val: &T) -> usize {
    let mut lb: isize = -1;
    let mut ub: isize = v.len() as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        if *val <= v[mid as usize] {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub as usize;
}


fn dfs(u: usize, p: usize, dp: &mut Vec<i32>, ans: &mut Vec<usize>, a: &Vec<i32>, edge: &Vec<Vec<usize>>) {
    let idx = lower_bound(dp, &a[u]);
    let prev = dp[idx];
    dp[idx] = a[u];
    ans[u] = lower_bound(dp, &i32::max_value());

    for v in &edge[u] {
        if *v == p {
            continue;
        }
        dfs(*v, u, dp, ans, a, edge);
    }
    dp[idx] = prev;
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<i32> = scan.next_vec(n);
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u: usize = scan.next();
        let v: usize = scan.next();
        let (u, v) = (u - 1, v - 1);
        edge[u].push(v);
        edge[v].push(u);
    }
    let mut dp: Vec<i32> = vec![i32::max_value(); n];
    let mut ans: Vec<usize> = vec![0; n];
    dfs(0, 0, &mut dp, &mut ans, &a, &edge);
    for x in ans {
        println!("{}", x);
    }
}


Measured memory_bytes: 33260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC121A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
 
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);
 
            string[] str2 = Console.ReadLine().Split();
 
            int h = int.Parse(str2[0]);
            int w = int.Parse(str2[1]);
 
            int x = H * W - h * W - (H - h) * w;
 
            Console.WriteLine(x);
 
            Console.ReadKey();
 
        }
    }
}

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

ll n,m;
Vi a,b,c;
ll aa,bb,cc;

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

graph g;

matrix warshall_floyd(graph _g){
    matrix dis(_g.size(),vector<ll>(_g.size(),INF));
    rep(i,dis.size())dis[i][i]=0;
    rep(i,_g.size()){
        rep(j,_g[i].size()){
            edge e = _g[i][j];
            dis[i][e.to] = e.cost;
        }
    }
    rep(i,_g.size()){
        rep(j,_g.size()){
            rep(k,_g.size()){
                chmin(dis[j][k],dis[j][i]+dis[i][k]);
            }
        }
    }
    return dis;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m;
    g.resize(n);
    rep(i,m){
        cin>>aa>>bb>>cc;
        g[aa-1].pb(edge(bb-1,cc));
        g[bb-1].pb(edge(aa-1,cc));
    }
    matrix dis = warshall_floyd(g);
    matrix ck(n,Vi(n,0));
    rep(i,n){
        rep(j,g[i].size()){
            edge e = g[i][j];
            if(dis[e.to][i] == e.cost){
                ck[i][e.to] = 1;
            }
        }
    }
    ll ans = 0;
    rep(i,n){
        rep(j,n){
            if(ck[i][j]){
                if(i==j)continue;
                ans++;
            }
        }
    }
    m *= 2;
    m -= ans;
    print(m/2);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

 

using namespace std;

 

int main()
{
    int a ,b, c, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a == 0 && b == 0)
            break;

        if ( a > b)
        {
            c = a;
            a = b;
            b = c;
        }
       cout << a << " " << b << endl;
    }
}




Measured memory_bytes: 3012
from collections import defaultdict 
N = int(input())
A = [int(v) for v in input().split()]
 
ans = 0
dic = defaultdict(int)
 
for i,a in enumerate(A):
    dic[i+a] += 1

for j,a in enumerate(A):
    ans += dic[j-a]

print(ans)

Measured memory_bytes: 61568
from sys import stdin
input = stdin.readline
import copy as cp
from collections import deque, OrderedDict

LINF = 1001002003004005006
INF = 1001001001

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

A = 0
B = 0
C = 0
D = 0

mp = OrderedDict({})

def dfs(N):
  global A, B, C, D

  if N in mp:
    return mp[N]

  cost = LINF
  if LINF//D > N:
    cost = D * N

  l = N//2*2
  r = l+2
  if (l//2 < N):
    cost = min(cost, A+(N-l)*D+dfs(l//2))
  if (r//2 < N):
    cost = min(cost, A+(r-N)*D+dfs(r//2))

  l = N//3*3
  r = l+3
  if (l//3 < N):
    cost = min(cost, B+(N-l)*D+dfs(l//3))
  if (r//3 < N):
    cost = min(cost, B+(r-N)*D+dfs(r//3))

  l = N//5*5
  r = l+5
  if (l//5 < N):
    cost = min(cost, C+(N-l)*D+dfs(l//5))
  if (r//5 < N):
    cost = min(cost, C+(r-N)*D+dfs(r//5))

  mp[N] = cost
  return cost


T = int(input().rstrip())

for _ in range(T):
  N, A, B, C, D = map(int, input().rstrip().split())
  mp.clear()
  mp[0] = 0
  mp[1] = D
  ans = dfs(N)
  print(ans)


Measured memory_bytes: 90728
import math

n = input()

main = input().split()
main.insert(0,int(n))

del n

for i in range(1,main[0]+1):
	print("node " + str(i) + ": key = " + str(main[i]),end=", ")

	if i != 1:
		a = math.floor(i/2)
		print("parent key = " + main[a],end=", ")

	if i*2 <= main[0]:
		print("left key = " + str(main[i*2]),end=", ")
		a = i*2
		a += 1
		if a <= main[0]:
			print("right key = " + str(main[a]),end=", ")
	print()


Measured memory_bytes: 5788
#include <bits/stdc++.h>
    using namespace std;
    #define all(x) (x).begin(),(x).end() 
    #define int long long
    #define vi vector<int>
    #define pii pair<int,int>
    #define F first
    #define S second
    #define pb push_back
    #define rep(i, a, b) for(int i = a; i < b; i++)
    #define repr(i, a, b) for(int i = a - 1; i >= b; i--)
    #define iter(m) for(auto it = m.begin(); it != m.end(); it++)
    #define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
    #define N 500500
    #define PI 3.14159265358979323846264338327950L
    #define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        speed;
        int x; cin >> x;
        x += 1;
        cout << x % 2;
        return 0;
    }

Measured memory_bytes: 3608
class Node:
    def __init__(self, k, p):
        self.k, self.p = k, p
        self.left, self.right = None, None

class Treap:
    def __init__(self):
        self.root = None
    
    def insert(self, k, p):
        self.root = self.__insert(self.root, k, p)

    def rightRotate(self, t):
        s = t.left
        t.left = s.right
        s.right = t
        return s
    
    def leftRotate(self, t):
        s = t.right
        t.right = s.left
        s.left = t
        return s

    def __insert(self, t, k , p):
        if t == None:
            return Node(k, p)
        if k == t.k:
            return t
        
        if k < t.k:
            t.left = self.__insert(t.left, k, p)
            if t.p < t.left.p:
                t = self.rightRotate(t)
        else:
            t.right = self.__insert(t.right, k, p)
            if t.p < t.right.p:
                t = self.leftRotate(t)
        return t
    
    def delete(self, k):
        self.root = self._delete(k)
        
    def _delete(self, k, t = -1):
        if t == -1:
            t = self.root
        
        if t == None:
            return None
        if k < t.k:
            t.left = self._delete(k, t.left)
        elif k > t.k:
            t.right = self._delete(k, t.right)
        else:
            return self.__delete(t, k)
        return t
    
    def __delete(self, t, k):
        if t.left == None and t.right == None:
            return None
        elif t.left == None:
            t = self.leftRotate(t)
        elif t.right == None:
            t = self.rightRotate(t)
        else:
            if t.left.p > t.right.p:
                t = self.rightRotate(t)
            else:
                t = self.leftRotate(t)
        return self._delete(k, t)

    def find(self, k, t = -1):
        if t == -1:
            t = self.root
        if t == None:
            return None
        if k < t.k:
            return self.find(k, t.left)
        elif k > t.k:
            return self.find(k, t.right)
        else:
            return t
    
    def preOrder(self, r = -1):
        if r == -1: r = self.root
        if r == None:   return
        print("", r.k, end = '')
        self.preOrder(r.left)
        self.preOrder(r.right)
    
    def inOrder(self, r = -1):
        if r == -1: r = self.root
        if r == None:   return
        self.inOrder(r.left)
        print("", r.k, end = '')
        self.inOrder(r.right)
    
    def print(self):
        self.inOrder()
        print()
        self.preOrder()
        print()

tree = Treap()
for _ in range(int(input())):
    In = input().split()
    if In[0][0] == 'i':
        tree.insert(int(In[1]), int(In[2]))
    elif In[0][0] == 'p':
        tree.print()
    elif In[0][0] == 'f':
        print(['no', 'yes'][tree.find(int(In[1])) != None])
    elif In[0][0] == 'd':
        tree.delete(int(In[1]))



Measured memory_bytes: 52344
S = input()

if S[0] != "A":
  print("WA")
  exit()
if S[1] == "C":
  print("WA")
  exit() 
if S[-1] == "C":
  print("WA")
  exit() 
if "C" not in S:
  print("WA")
  exit()
x = S.index("C")
if "C" in S[x+1:]:
  print("WA")
  exit()
if S[1:x]+S[x+1:] != (S[1:x]+S[x+1:]).lower():
  print("WA")
  exit()

print("AC")


Measured memory_bytes: 38256
# 0 と 1 のみからなる3桁の番号 s が与えられます。
# 1 が何個含まれるかを求めてください。

# 3桁の番号を取得
s = gets.chomp

# 1が何個含まれているか数える変数を定義
count = 0

# 1が何個含まれているか検証
3.times do |i|
  if s[i].to_i == 1
    count += 1
  end
end

# 結果を出力
puts count

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int bits = 0;
	for (auto i : s)
		bits += i == '1';
	int mod0 = bits+1, mod1 = max(1, bits-1);
	int pw0 = 1, pw1 = 1;
	int rem0 = 0, rem1 = 0;
	for (int i = n-1; i >= 0; --i) {
		if (s[i] == '1') {
			rem0 += pw0; rem0 %= mod0;
			rem1 += pw1; rem1 %= mod1;
		}
		pw0 = (pw0*2)%mod0;
		pw1 = (pw1*2)%mod1;
	}
	pw0 = pw1 = 1;
	vector<int> out;
	for (int i = n-1; i >= 0; --i) {
		if (s[i] == '0') {
			int rem = rem0 + pw0; rem %= mod0;
			int ans = 1;
			while (rem) {
				int m = __builtin_popcount(rem); 
				rem %= m;
				++ans;
			}
			out.push_back(ans);
			// cout << ans << '\n';
		}
		else {
			if (bits == 1) out.push_back(0);
			else {
				int rem = rem1 + mod1 - pw1; rem %= mod1;
				int ans = 1;
				while (rem) {
					int m = __builtin_popcount(rem); 
					rem %= m;
					++ans;
				}
				out.push_back(ans);
			}
		}
		pw0 = (pw0*2)%mod0;
		pw1 = (pw1*2)%mod1;
	}
	reverse(begin(out), end(out));
	for (auto x : out)
		cout << x << '\n';
}

Measured memory_bytes: 4472
#include<iostream>
#include "math.h"
#include<vector>
#include<queue>	
using namespace std;
vector<vector<int>> edges;
vector<int> mark;
vector<int> d;
queue<int> q;
int n,m;
void BFS(int start){
	q.push(start);
	d[start]=0;
	mark[start]=1;
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(int i=0;i<edges[v].size();i++){
			if(mark[edges[v][i]]!=1){
				d[edges[v][i]]=d[v]+1;
				mark[edges[v][i]]=1;
				q.push(edges[v][i]);
			}

		}

	}
}
using namespace std;
int main(){
	cin>>n>>m;
	edges.resize(n);
	mark.resize(n);
	d.resize(n);
	for(int i=0;i<n;i++){
		d[i]=4;
	}
	int p,q;
	for(int i=0;i<m;i++){
		cin>>p>>q;
		p--;
		q--;
		edges[p].push_back(q);
		edges[q].push_back(p);
	}
	BFS(0);
	
	if(d[n-1]<3){
		cout<<"POSSIBLE";
	}
	else{
		cout<<"IMPOSSIBLE";
	}
	cin>>d[n-1];
}

Measured memory_bytes: 13936
o = input()
e = input()
d = ""
if len(o) == len(e):
  for i in range(len(o)):
    d += o[i]
    d += e[i]
  print(d)
else:
  for i in range(len(e)):
    d += o[i]
    d += e[i]
  d += o[-1]
  print(d)

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
ll dp[MAX][3];
ll dfs(int i, int j, vector<vector<ll>> &v, ll n, ll m){
    if(i<0 || j<0 || i>=n || j>=m)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ans = INT_MIN;
    for(int k=0;k<3;k++){
        if(k!=j)
            ans=max(ans,v[i][j]+dfs(i+1,k,v,n,m));
    }
    return dp[i][j]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,tmp;
    cin>>n;
    vector<vector<ll>> v(n+1,vector<ll>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>v[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    ll ans = 0;
    for(int i=0;i<3;i++){
        ans=max(ans,dfs(0,i,v,n,3));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 21868
program ABC148E
    integer(16) N
    integer(16) ans
    integer(16) i,div
    read*,N
    if(mod(N,2)==1)then
        print"(i0)",0
        stop
    endif
    ans=0;div=10
    do i=1,30
        ans=ans+N/div
        div=div*5
    end do
    print"(i0)",ans
    contains
end program

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
chiz = [[] for _ in range(w)]
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        chiz[i].append(tmp_list[i])
def bfs(i,j):
    ds = [[-1]*h for _ in range(w)]
    dq = deque([(i,j)])
    ds[i][j] = 0
    res = -1
    while dq:
        i,j = dq.popleft()
        for move in [(1,0),(-1,0),(0,-1),(0,1)]:
            if i+move[0] >= 0 and i+move[0] < w and j+move[1] >= 0 and j+move[1] < h:
                if chiz[i+move[0]][j+move[1]]=='.' and ds[i+move[0]][j+move[1]] == -1:
                    ds[i + move[0]][j + move[1]] = ds[i][j] + 1
                    res = max(res,ds[i + move[0]][j + move[1]])
                    dq.append((i + move[0],j + move[1]))
    return res
res = -1
for j in range(h):
    for i in range(w):
        if chiz[i][j]=='.':
            res = max(res, bfs(i,j))
print(res)

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

int main(){
  cout<<"1x1=1"<<endl;
  cout<<"1x2=2"<<endl;
  cout<<"1x3=3"<<endl;
  cout<<"1x4=4"<<endl;
  cout<<"1x5=5"<<endl;
  cout<<"1x6=6"<<endl;
  cout<<"1x7=7"<<endl;
  cout<<"1x8=8"<<endl;
  cout<<"1x9=9"<<endl;
  cout<<"2x1=2"<<endl;
  cout<<"2x2=4"<<endl;
  cout<<"2x3=6"<<endl;
  cout<<"2x4=8"<<endl;
  cout<<"2x5=10"<<endl;
  cout<<"2x6=12"<<endl;
  cout<<"2x7=14"<<endl;
  cout<<"2x8=16"<<endl;
  cout<<"2x9=18"<<endl;
  cout<<"3x1=3"<<endl;
  cout<<"3x2=6"<<endl;
  cout<<"3x3=9"<<endl;
  cout<<"3x4=12"<<endl;
  cout<<"3x5=15"<<endl;
  cout<<"3x6=18"<<endl;
  cout<<"3x7=21"<<endl;
  cout<<"3x8=24"<<endl;
  cout<<"3x9=27"<<endl;
  cout<<"4x1=4"<<endl;
  cout<<"4x2=8"<<endl;
  cout<<"4x3=12"<<endl;
  cout<<"4x4=16"<<endl;
  cout<<"4x5=20"<<endl;
  cout<<"4x6=24"<<endl;
  cout<<"4x7=28"<<endl;
  cout<<"4x8=32"<<endl;
  cout<<"4x9=36"<<endl;
  cout<<"5x1=5"<<endl;
  cout<<"5x2=10"<<endl;
  cout<<"5x3=15"<<endl;
  cout<<"5x4=20"<<endl;
  cout<<"5x5=25"<<endl;
  cout<<"5x6=30"<<endl;
  cout<<"5x7=35"<<endl;
  cout<<"5x8=40"<<endl;
  cout<<"5x9=45"<<endl;
  cout<<"6x1=6"<<endl;
  cout<<"6x2=12"<<endl;
  cout<<"6x3=18"<<endl;
  cout<<"6x4=24"<<endl;
  cout<<"6x5=30"<<endl;
  cout<<"6x6=36"<<endl;
  cout<<"6x7=42"<<endl;
  cout<<"6x8=48"<<endl;
  cout<<"6x9=54"<<endl;
  cout<<"7x1=7"<<endl;
  cout<<"7x2=14"<<endl;
  cout<<"7x3=21"<<endl;
  cout<<"7x4=28"<<endl;
  cout<<"7x5=35"<<endl;
  cout<<"7x6=42"<<endl;
  cout<<"7x7=49"<<endl;
  cout<<"7x8=56"<<endl;
  cout<<"7x9=63"<<endl;
  cout<<"8x1=8"<<endl;
  cout<<"8x2=16"<<endl;
  cout<<"8x3=24"<<endl;
  cout<<"8x4=32"<<endl;
  cout<<"8x5=40"<<endl;
  cout<<"8x6=48"<<endl;
  cout<<"8x7=56"<<endl;
  cout<<"8x8=64"<<endl;
  cout<<"8x9=72"<<endl;
  cout<<"9x1=9"<<endl;
  cout<<"9x2=18"<<endl;
  cout<<"9x3=27"<<endl;
  cout<<"9x4=36"<<endl;
  cout<<"9x5=45"<<endl;
  cout<<"9x6=54"<<endl;
  cout<<"9x7=63"<<endl;
  cout<<"9x8=72"<<endl;
  cout<<"9x9=81"<<endl;

return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n, x; cin >> n;
    rep2(i, 1, sqrt(n)+1){
        if(n%i == 0) x = i;
    }

    cout << x-1 + n/x-1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    string s,t;cin>>s>>t;
    const ll MOD=1000000007;
    ll res=(s[0]==t[0]?3:6);
    s=s+'#';
    t=t+'#';
    REP(i,N-1){
        if(s[i+1]==s[i])continue;
        else{
			if(s[i]!=t[i] && s[i+1]==t[i+1])continue;
            else if(s[i]!=t[i] && s[i+1]!=t[i+1]){res*=3;res%=MOD;}
          else if(s[i]==t[i] && s[i+1]==t[i+1]){res*=2;res%=MOD;}
          else {res*=2;res%=MOD;}
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;

    int a[n];
    rep(i,n){
        cin >> a[i];
    }

    int res = 0;

    while(1){
        bool exist_odd = false;
        rep(i,n){
            if(a[i]%2 != 0){
                exist_odd = true;//奇数発見
            }
        }

        if(exist_odd == true){//奇数発見したら終了
            break;
        }

        //奇数が発見できなかったら2で割る
        rep(i,n){
            a[i] /= 2;
        }

        res++;
    }

    cout << res << endl;
}

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

int main(void) {
	int a;
	string S;
	cin >> a >> S;
	if (a >= 3200) {
		cout << S << endl;
	}
	else {
		cout << "red" << endl;
	}
	return 0;

}

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

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 3e3 + 7;
const int mod = 1e9 + 7;

int dp[MAX][MAX], pre[MAX][MAX];

void add(int& a, int b)
{
    a += b;
    if(a >= mod)
        a -= mod;
}

int sub(int a, int b)
{
    a -= b;
    if(a < 0)
        a += mod;
    return a;
}

int main() {
    _boost;

    int n;  string s;
    cin >> n >> s;

    dp[1][1] = 1;
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j < i; j++)
            pre[i-1][j] = (pre[i-1][j-1] + dp[i-1][j]) % mod;

        for(int j = 1; j <= i; j++)
        {
            int l, r;
            if(s[i-2] == '<')
                l = 1, r = j - 1;
            else
                l = j, r = i - 1;
            if(l <= r)
                add(dp[i][j], sub(pre[i-1][r], pre[i-1][l-1]));
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        add(ans, dp[n][i]);

    cout << ans;

    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, m);
  vector<vector<pair<int, int>>> v(n);
  rep(i, m) {
    in(int, p, y);
    v[p - 1].push_back({y, i});
  }
  for (auto& vi : v) sort(all(vi));
  vector<pair<int, int>> px(m);
  rep(i, n) rep(x, v[i].size()) { px[v[i][x].second] = {i, x}; }
  for (auto [p, x] : px) printf("%06d%06d\n", p + 1, x + 1);
}


Measured memory_bytes: 9504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int N, X, T;
	cin >> N >> X >> T;
	int S = 0;
	S += N / X * T;
	if (N % X >= 1) {
		S += T;
	}
	cout << S << endl;
}

Measured memory_bytes: 3604
/*

A：1...n
B：1...n

dp[i][j][k]：考虑完前i个，还有j个留着没配，已经confirm了k分的方案

*/
#include<bits/stdc++.h>
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const ll MAXN=2e5+5;
const ll INF=1e18;
const ll MOD=1e9+7;
ll n,a[MAXN],mid,sum;
ll calc(ll x)
{
    ll ret=0;
    for(ll i=1;i<=n;i++)
    {
        ret+=abs(a[i]-x);
    }
    return ret;
}
void solve()
{
    sort(a+1,a+1+n);
    ll mid1=a[n/2];
    ll mid2=a[n/2+1];
    ll ans=INF;
    ans=min(ans,calc(mid1));
    ans=min(ans,calc(mid2));
    printf("%lld\n",ans);
}
int main()
{
    while(~scanf("%lld",&n))
    {
        for(ll i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
            a[i]-=i;
            sum+=a[i];
        }
        solve();
    }
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
output = 0
output += B[A[0]-1]
for i in range(1,N):
    output += B[A[i]-1]
    if A[i]-1 == A[i-1]:
        output += C[A[i-1]-1]
print(output)


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

vector<vint> a;
int w = 0, h = 0;
int ret;
int dfs(int i, int j, int t) {
	if (ret <= t)	return ret;
	int res = ret;
	rep(k, 4) {
		int cy = i, cx = j;
		int ny = cy + dy[k], nx = cx + dx[k];
		while (0 <= ny&&ny < h && 0 <= nx&&nx < w&&a[ny][nx] == 0) {
			cy = ny;	cx = nx;
			ny += dy[k];	nx += dx[k];
		}
		if (ny < 0 || h <= ny || nx < 0 || w <= nx)	continue;
		else if (a[ny][nx] == 3) {
			res = min(ret, t + 1);
		}
		else if (cy == i&&cx == j)	continue;
		else if (a[ny][nx] == 1) {
			a[ny][nx] = 0;
			res = min(res, dfs(cy, cx, t + 1));
			a[ny][nx] = 1;
		}
	}
	return res;
}


int main() {
	while (true) {
		cin >> w >> h;
		if (w == 0)	break;
		a = vector<vint>(h, vint(w, 0));
		rep(i, h)	rep(j, w)	cin >> a[i][j];
		rep(i, h)	rep(j, w) {
			if (a[i][j] == 2) {
				a[i][j] = 0;
				ret = 11;
				ret = dfs(i, j, 0);
				ret = (ret == 11 ? -1 : ret);
				cout << ret << endl;
				goto next;
			}
		}
		next:;
	}
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    ll a[n];
    REP(i,n) cin >> a[i];
    ll sum = 0;
    REP(i,n) sum += a[i];
    double d = sum / (double)n;
    double dif = 1000000;
    ll res = 0;
    REP(i,n){
        if(dif > abs(d - a[i])){
            dif = abs(d - a[i]);
            res = i;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
    int first = 0, second = 0, third = 0, input;

    for(int i=0; i<10; i++)
    {
        scanf("%d", &input);
        if(input > first)
        {
            third = second;
            second = first;
            first = input;
        }
        else if(input > second)
        {
            third = second;
            second = input;
        }
        else if(input > third)
            third = input;
    }
    printf("%d\n%d\n%d\n", first, second, third);

    return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <complex>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
ll MOD = 1000000007;

 ll mod(ll val) {
     ll res = val % MOD;
     if (res < 0) res += MOD;
     return res;
 }

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

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

int main() {
    ll N; std::cin >> N;
    ll n_zero = 0;
    map<pll, pll> m;
    for (int i = 0; i < N; ++i) {
        ll x, y; std::cin >> x >> y;
        if (x == 0 && y == 0) {
            n_zero++;
            continue;
        }
        if (y < 0) x = -x, y = -y;
        if (x < 0 && y == 0) x = -x;
        auto g = gcd(x, y);
        x /= g;
        y /= g;
        if (x > 0 && y >= 0) m[{x, y}].first++;
        else m[{y, -x}].second++;
    }
    ll ans = 1;
    for (const auto kv: m) {
        auto key = kv.first;
        auto val = kv.second;
        auto s = val.first;
        auto t = val.second;
        // cout << key.first << " " << key.second << " " << s << " " << t << endl;
        ll tmp = 1;
        tmp = mod(tmp + modpow(2, s) - 1);
        tmp = mod(tmp + modpow(2, t) - 1);
        ans = mod(ans * tmp);
    }
    ans = mod(ans - 1);
    ans = mod(ans + n_zero);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19200
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0105&lang=jp
"""
import sys


def compile_index(dict, word, page):
    if word in dict:
        temp = dict[word]
        temp.append(page)
        temp.sort()
        dict[word] = temp
    else:
        temp = [page]
        dict[word] = temp


def main(args):
    index = {}
    for line in sys.stdin:
        word, page = line.strip().split(' ')
        page = int(page)
        compile_index(index, word, page)

    result = []
    for k, v in index.items():
        result.append((k, v))
    result.sort()
    for ele in result:
        print(ele[0])
        print(*ele[1])



if __name__ == '__main__':
    main(sys.argv[1:])

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

const int MOD = 1000000007;
const int MAXN = 1000005;

int N, H, D;
long long dp[MAXN], sum[MAXN];

int main(){
    scanf("%d %d %d", &N, &H, &D);

    long long t = 0, p = 1;
    for(int i = 1; i <= N; i++){
        p = (p * i) % MOD;
        t = (t + p) % MOD;
    }

    //cout << t << ' ' << p << endl;

    sum[H + 1] = 0;
    for(int i = H; i >= 0; i--){
        if(i == H)dp[i] = 1;
        else{
            dp[i] = (sum[i + 1] - sum[min(H + 1, i + D + 1)] + MOD) % MOD;
        }
        sum[i] = (sum[i + 1] + t * dp[i]) % MOD;
    }

    long long r = 0;
    for(int i = 1; i <= D; i++)
        r = (r + dp[i]) % MOD;
    printf("%lld\n", (r * p) % MOD);

    return 0;
}


Measured memory_bytes: 15872
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		in.nextLine();
		while (n-- > 0) {
			out.println(in.nextLine().replaceAll("Hoshino","Hoshina"));
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 26340
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;
ll x[500005],y[500005],z[100005];
char s[100005],t[100005];
vector <ll> aa,bb;
bool ok=false;
bool check[100005];

int main(){
    cin>>n;
    for(i=0;i<n;i++)cin>>x[i];
    cin>>m;
    for(i=0;i<m;i++)cin>>y[i];
    sort(x,x+n);
    sort(y,y+m);
    a=0;b=0;
    while(1+1==2){
        if(y[b]==x[a]){
            a++;
            b++;
        }else if(x[a]<y[b]){
            a++;
        }else{
            p("NO");
            return 0;
        }
        if(b==m){
            p("YES");
            return 0;
        }
    }
   
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 n;
  cin >> n;
  vector<int64> a(n);
  int64 mn = INF_LL, mx = -INF_LL, sum = 0;
  REP(i, n) {
    cin >> a[i];
    chmin(mn, a[i]);
    chmax(mx, a[i]);
    sum += a[i];
  }
  cout << mn << " " << mx << " " << sum << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
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; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,l; cin>>n>>m>>l;
    vector <vector<int>> d(n,vector <int>(n, INF));
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        a--;b--;
        d[a][b] = d[b][a] = c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                chmin(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    vector <vector<int>> d2(n,vector <int>(n, INF));
    rep(i,n){
        rep(j,n){
            //cout<<d[i][j]<<endl;
            if(d[i][j] <= l){
                d2[i][j] = 1;
            }
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                chmin(d2[i][j],d2[i][k]+d2[k][j]);
            }   
        }
    }
    int q; cin>>q;
    rep(i,q){
        int s,t; cin>>s>>t;
        s--; t--;
        if(d2[s][t] >= INF) cout<<-1<<endl;
        else cout<<d2[s][t] - 1<<endl;
    }
}


Measured memory_bytes: 2048
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

#include <bits/stdc++.h>
#include <set>
using namespace std;

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/
/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

bool FAT_chk(ll n)
{
    for (ll i = 2; i*i <= n; i += 1){
        if (n%i==0) rn false;
    }
    rn true;
}

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;
    ll n;
    cin>>n;
    ll a1[n+5];
    ll c1 = 0;
    for (ll i = 0; i < n; i += 1){
        cin>>a1[i];
       if (FAT_chk(a1[i])) c1+=1;
    }
    cout << c1 << endl;

   // main();

    rn0;
}

Measured memory_bytes: 3180