akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ins(S , T);
  inl(N , M);
  ins(U);
  if(U == S) out(N - 1 , M);
  else out(N , M - 1);
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = [0]*(n+1)

for i in range(1,n+1) :
    h[i] = int(input())

h.sort()
c = h[n] #highest

for j in range(1,n-k+2) :
    d = h[j+k-1] - h[j]
    c = d + 0 if c > d else c + 0

print(c)

Measured memory_bytes: 7472
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   long long a,b,c;
 
   cin >> a >> b >> c;
   long long ans = 0;
  
   
   if (a < c){
     
     c = c - a;
     a = 0;
     if (b < c){
       b = 0;
       cout << a << " "<< b << endl;
     }else {
       b = b - c;
       cout << a << " "<< b << endl;
     }
     
   }else {
     a = a - c;
      cout << a << " "<< b << endl;
   }
   
   
  
  
   
  return 0;
}

Measured memory_bytes: 3632
import heapq

N, M = map(int, input().split())
AB = [[] for _ in range(M + 1)]

for n in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    AB[a].append(0-b)

earn = 0
q = []

for m in range(1, M + 1):

    for job in AB[m]:
        heapq.heappush(q, job)

    if q != []:
        earn += heapq.heappop(q)

print(0-earn)


Measured memory_bytes: 17604
import copy
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
A = [a, b, c, d, e]

def dfs(ordered, remain, tim):
    if len(remain) == 0:
        #print("o", ordered, tim)
        return tim

    tims = []
    for r in remain:
        o = copy.copy(ordered)
        o.append(r)
        r2 = copy.copy(remain)
        r2.remove(r)
        t3 = (10 - tim % 10)
        t4 = 0 if t3 == 10 else t3
        tim2 = tim + t4  + r
        #print("tim", tim, t4, r)
        tims.append(dfs(o, r2, tim2))
    return min(tims)

print(dfs([], A, 0))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  cout << N*N*N << '\n';
  return 0;
}

Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (1000010)
int n,a[N],b[N],c[N],p[N],m,sb;
char s[N];
signed main(){
	Rd(n),Mst(c,0x3f);
	Frn1(i,1,n){
		cin>>s+1,m=strlen(s+1);
		Frn1(j,1,m){
			if(s[j]=='(')++a[i];
			else if(a[i]>0)--a[i];
			else ++b[i];
			c[i]=min(c[i],a[i]-b[i]);
		}
		p[i]=i;
	}
	sort(p+1,p+n+1,[](int x,int y){
		if(!b[x]&&!b[y])return a[x]>a[y];
		if(b[x]&&b[y]){
			if(a[x]>b[x]&&a[y]>b[y])return b[x]<b[y];
			if(a[x]>b[x])return true;
			if(a[y]>b[y])return false;
			return a[x]>a[y];
		}
		return !b[x];
	});
	Frn1(i,1,n){
		if(sb+c[p[i]]<0)printf("No"),exit(0);
		sb+=a[p[i]]-b[p[i]];
	}
	printf(sb?"No":"Yes"),exit(0);
}


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

int main( ) {
  int a, b;
  cin >> a >> b;
  int h = 1; // height
  for(int i = 2; i < 1000; i++){
    h += i;
    if (b - a == i){
      cout << h - b << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>

int exch(int ch){
	if(ch=='I') return (1);
	else if(ch=='V') return (5);
	else if(ch=='X') return (10);
	else if(ch=='L') return (50);
	else if(ch=='C') return (100);
	else if(ch=='D') return (500);
	else if(ch=='M') return (1000);
	else return (0);
}

int main(void){
	int i,sum,max;
	char str[101]; char ch;
	int temp[101];
	
	while(scanf("%s", str)!=EOF){
	sum=0;i=0;
	while(str[i]) { 
		ch=str[i];
	temp[i]=exch(ch); i++;};
	max=i-1;
	for(i=1;i<=max;i++){
	if(temp[i-1]<temp[i]) sum-=temp[i-1];
	else sum+=temp[i-1];
	};
	sum+=temp[max];
	printf("%d\n", sum);
	};

	return (0);
}

Measured memory_bytes: 540
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $p) = split / /, <STDIN>);
chomp (my @a = split / /, <STDIN>);
my $q = grep {$_%2==0} @a;
my $ans = 0;
for my $j (0..$q) {
  for (my $i=$p; $i<=$n-$q; $i+=2) {
    $ans += choose($n-$q, $i) * choose($q, $j);
  }
}
say $ans;

sub choose {
  my ($n, $k) = @_;
  my ($r, $j) = (1, 1);
  return 0 if $k > $n || $k < 0;
  $k = ($n - $k) if ($n - $k) < $k;
  while ($j <= $k) {
    $r *= $n--;
    $r /= $j++;
  }
  $r;
}

Measured memory_bytes: 896
/*
AIZU ONLINE 0511

Is it a Right Triangle?
*/

#include <stdio.h>

main()
{       int i;
	int no;
	int submit[30];

	for(i=0;i<30;i++)
          submit[i] = 0;
        for(i=0;i<28;i++)
	{	scanf("%d",&no);
                submit[no-1] = 1;
        }
        for(i=0;i<30;i++)
          if(submit[i]==0)
            printf("%d\n",i+1);


        return(0);
}

Measured memory_bytes: 0
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::cmp::min;

fn calc(l: usize, r: usize, x: u64, y: u64, a: &Vec<u64>) -> u64 {
    if l > r {
        return 0;
    }
    let mut ans = 1_000_000_000_000_000_000;
    for i in l..(r + 1) {
        let v = a[i] * (x + y) + calc(l, i - 1, x, x + y, &a) + calc(i + 1, r, x + y, y, &a);
        ans = min(ans, v);
    }
    ans
}

fn run() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let ans = calc(1, n - 2, 1, 1, &a) + a[0] + a[n - 1];
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint n;
vector<lint> a;

int main() {
    cin >> n;
    a.resize(n);
    for (lint i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<lint> b(n), c(n);
    for (lint i = 0; i < n; i++) {
        b[i] = a[i] + i;
        c[i] = i - a[i];
    }
    map<lint, lint> count;
    count[b[0]]++;
    lint ans = 0;
    for (lint i = 1; i < n; i++) {
        ans += count[c[i]];
        count[b[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 30652
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        long c = 0;
        while(n != 0){
        	n /= 2;
            ans += (long)Math.pow(2, c);
            c++;
        }
        System.out.println(ans);
	}
}

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

int main(){
    int n,m; cin>>n>>m;
    vector<int> x(m);
    for(int i=0;i<m;i++) cin>>x[i];
    sort(x.begin(),x.end());
    vector<int> d(m-1);
    for(int i=0;i<m-1;i++){
        d[i]=x[i+1]-x[i];
    }
    sort(d.begin(),d.end());
    int ans=0;
    for(int i=0;i<m-n;i++){
        ans+=d[i];
    }
    cout<<ans<<endl;
}

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

int main() {
    vector<int> card(3);
    for (int i = 0; i < 3; i++) cin >> card[i];
    sort(card.begin(), card.end());
    cout << card[0] + card[1] + card[2] * 10 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
	while ( !cin.eof() )
	{
		long long a, b;

		cin >> a >> b;
		if ( cin.eof() )
			break;
		long long sum = a + b;

		int cnt = 0;
		while ( sum >= 10 )
		{
			sum /= 10;
			cnt++;
		}
		
		int kotae = cnt + 1;
		cout << kotae << endl;

	}
	return 0;
}

Measured memory_bytes: 0
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        mut n: usize,
        m: usize,
        h: [usize; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut g = vec![true; n];
    for (a, b) in ab {
        if h[a] <= h[b] {
            g[a] = false;
        }
        if h[a] >= h[b] {
            g[b] = false;
        }
    }

    println!("{}", g.into_iter().filter(|&gi| gi).count());
}


Measured memory_bytes: 6680
/*
 * https://atcoder.jp/contests/abc152/tasks/abc152_e
 * Flatten.
 */

# include<iostream>
# include<vector>
# include<algorithm>

const long long MOD = 1e9+7;
const long long MAX_N = 1e6+5;

long long gcd(long long a, long long b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

long long inverse(long long a, long long b, long long& x, long long& y)
{
    if( b == 0)
    {
        x = 1;
        y = 0;

        return a;
    }
    
    long long x1, y1;
    long long d = inverse(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);

    return d;
}


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

long long modinv(long long a, long long mod=MOD)
{
    return modpow(a, mod - 2, mod);
}

std::vector<std::pair<long long, long long>> prime_devisor(long long n)
{
    std::vector<std::pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; p++)
    {
        if(n % p != 0) continue;
        
        long long num = 0;
        while(n % p == 0)
        {
            ++num;
            n /= p;
        }
        res.push_back(std::make_pair(p, num));
    }
    if(n != 1) res.push_back(std::make_pair(n, 1));

    return res;
}

long long solve(std::vector<long long>& a)
{
    std::vector<long long> mem(MAX_N, 0);

    for(int i = 0; i < a.size(); i++)
    {
        auto pd = prime_devisor(a[i]);
        for(auto p: pd) mem[p.first] = std::max(mem[p.first], p.second);
    }

    long long lcm = 1;
    for(int i = 2; i < MAX_N; i++) lcm = lcm*modpow(i, mem[i]) % MOD;

    long long ans = 0;
    for(int i = 0; i < a.size(); i++)
    {
        ans += lcm*modinv(a[i])%MOD;
    }

    return ans % MOD;
}

int main()
{
    int n;
    long long num, index = 0;
    std::cin>>n;

    std::vector<long long> a(n);
    while(n--)
    {
        std::cin>>num;
        a[index++] = num;
    }
    std::cout<<solve(a)<<std::endl;
    //std::cout<<MOD<<" "<<MAX_N;

    return 0;
}


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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

int X1[1005], X2[1005], Y1[1005], Y2[1005], w, h, n, dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
bool field[1001 * 6][1001 * 6];
vector<int> tv;

int compress(int *p1, int *p2, int w) {
  tv.clear();

  for (int i = 0; i < n; ++i) {
    for (int j = -1; j <= 1; ++j) {
      int tp1 = p1[i] + j, tp2 = p2[i] + j;

      if (0 <= tp1 && tp1 < w - 1) tv.PB(tp1);
      if (0 <= tp2 && tp2 < w - 1) tv.PB(tp2);
    }
  }

  sort(tv.begin(), tv.end());

  tv.erase(unique(tv.begin(), tv.end()), tv.end());

  for (int i = 0; i < n; ++i) {
    p1[i] = find(tv.begin(), tv.end(), p1[i]) - tv.begin();
    p2[i] = find(tv.begin(), tv.end(), p2[i]) - tv.begin();
  }

  return tv.size();
}

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

  while (cin >> w >> h, w) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    }

    w = compress(X1, X2, w);
    h = compress(Y1, Y2, h);

    memset(field, 0, sizeof(field));
    for (int i = 0; i < n; ++i) {
      for (int y = Y1[i]; y < Y2[i]; ++y) {
        for (int x = X1[i]; x < X2[i]; ++x) {
          field[x][y] = true;
        }
      }
    }

    int ans = 0;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (field[x][y]) continue;
        ans++;
        queue<pii> q;
        q.push(pii(x, y));

        while (q.size()) {
          pii p = q.front();
          q.pop();
          int tx = p.first, ty = p.second;
          if (field[tx][ty]) continue;
          field[tx][ty] = true;

          for (int i = 0; i < 4; ++i) {
            int nx = tx + dx[i], ny = ty + dy[i];
            if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            q.push(pii(nx, ny));
          }
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 36556
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n), c(n), cnt(n);
    rep(i, 0, n){
        cin >> v[i];
    }
    rep(i, 0, n){
        cin >> c[i];
    }
    int ans = 0;
    rep(i, 0, n){
        cnt[i] = v[i] - c[i];
        if(cnt[i] > 0){
            ans += cnt[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=2e5+5;
const ll inf=1e9;
void solve(){
    int n;
    cin>>n;
    set<string> s;
    while(n--){
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 19080
from collections import defaultdict, deque
N = int( input())
d = defaultdict( int)
E = [ [] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map( int, input().split())
    u = u-1
    v = v-1
    E[u].append(v)
    E[v].append(u)
    d[(u,v)] = w%2
    d[(v,u)] = w%2
V = [-1]*N
V[0] = 0
q = deque([0])
while q:
    v = q.popleft()
    l = V[v]
    for t in E[v]:
        if V[t] == -1:
            V[t] = (l+d[(v,t)])%2
            q.append(t)
for i in range(N):
    print(V[i])


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

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

    int n;
    cin >> n;
    vector<ll> a(n + 2), s(n + 2);
    vector<vector<ll>> dp(n + 2, vector<ll>(n + 2, 1e15));
    forx(i, 1, n + 1)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
        dp[i][i] = 0;
    }

    forx(i, 1, n)
    {
        forx(l, 1, n - i + 1)
        {
            int r = l + i;
            forx(m, l, r)
            {
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r] + s[r] - s[l - 1]);
            }
        }
    }

    cout << dp[1][n] << endl;

    return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
bool is_prime[55555 + 1];
int main() {
	memset(is_prime, -1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= 55555; i++) {
		if (!is_prime[i]) continue;
		for (int j = i * 2; j <= 55555; j += i) is_prime[j] = 0;
	}
	vector<int> prime;
	for (int i = 2; i <= 55555; i++) {
		if (!is_prime[i]) continue;
		if (i % 5 == 1) prime.push_back(i);
	}
	int N;
	cin >> N;
	cout << prime[0];
	for (int i = 1; i < N; i++) cout << " " << prime[i];
	cout << endl;
}

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

int main() {
	string st;
	int n;
	string::size_type id;
	cin >> n;
	getchar();
	for (n;n>0;n--) {
		getline(cin,st);
		id=0;
		while(true) {
			id=st.find("Hoshino",id);
			if (id==string::npos) break;
			st.replace(id,7,"Hoshina");
			id++;
		}
    cout << st << endl;  
	}
	return 0;
	}

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

int main() {
  int A, B, C, D;
  cin >> A >>B >>C >>D;
  if (A+B== C+D) {
    cout << "Balanced" << endl;
  }
  else if(A+B > C+D) {
    cout << "Left" << endl;
  }
  else cout << "Right" <<endl;
}

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

int main() {
	int a, b;

	cin >> a >> b;

	cout << a / b << " ";
	cout << a % b << " ";
	cout << fixed << setprecision(10) <<(double)a / (double)b << endl;

	return 0;

}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n, x, y; cin >> n >> x >> y;
    vector<int> ans(n, 0);

    for(int i=1; i<=n; ++i) for(int j=i+1; j<=n; ++j) {
        int val1 = j-i;
        int val2 = abs(i-x) + 1 + abs(j-y);
        int val3 = abs(i-y) + 1 + abs(j-x);
        int k = min(val1, min(val2, val3));
        ans[k]++;
    }

    for(int i=1; i<n; ++i) cout << ans[i] << endl;


    return 0;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().strip().split(' ')]

if N >= 1000:
    for i in range(M//N):
        n = (M//N)-i
        if M % n == 0:
            print(n)
            break
else:
    x = M//(M//N)
    for i in range(M):
        i = x +i
        if M % i == 0:
            print(M//i)
            break


Measured memory_bytes: 2940
#include <stdio.h>

int loan=100000;

int main(void) {
    int n, i;

    scanf("%d", &n);
    for (i=0;i<n;i++) {
        loan=loan*(1.05);
        if (loan%1000!=0) {
            loan=loan/1000;
            loan++;
            loan=loan*1000;
        }
    }
    printf("%d\n", loan);

    return 0;
}



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

int main()
{
	int age;
  	cin>>age;
  	if(age==1)
    {
    	cout<<"Hello World"<<endl;
        return 0;
    }
	int a,b;
  	cin>>a>>b;
  	cout<<a+b<<endl;
  	return 0;
}

Measured memory_bytes: 256
## B - Iron Bar Cutting
N = int(input())
A = list(map(int, input().split()))
L = 0
R = sum(A)
ans = sum(A)
for n in range(N):
    L += A[n]
    R -= A[n]
    if ans > abs(L-R):
        ans = abs(L-R)
print(ans)

Measured memory_bytes: 31528
n = int(input())
s = input()
list_s = list(s)
cnt = 0

for si in list_s:
    if si == ')':
        if cnt <= 0:
            s = '(' + s
        else :
            cnt -= 1
    
    if si == '(':
        cnt += 1
    
for _ in range(cnt):
    s += ')'

print(s)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using lint = long long ;
using ldouble = long double;

void err(istream_iterator<string> _it) {}
template<typename T,typename... Args>
void err(istream_iterator<string> _it, T a,Args... args) {cerr<<"\n"<<*_it<<" is "<<a<<endl;err(++_it,args...);}

//#define __debug true; // c++17
const bool _debug = true;
#define cerr if(_debug)cerr
#define eb emplace_back
#define error(args...) if(_debug){string _s = #args; replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s); istream_iterator<string> _itt(_ss);err(_itt,args);} 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char temp;
    lint ans = 0;
    while(cin >> temp)
    {
        ans += temp - '0';
    }
    if(ans % 9 == 0) cout << "Yes\n";
    else cout << "No" << "\n";
    
    return 0;
}



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

int main() {
  ll n; cin>>n;
  vector<ll> capacity(6);
  for(int i=1; i<=5; i++) cin>>capacity[i];
  vector<ll> dp(7,0);
  ll minCapacity;
  for(int i=2; i<=6; i++) {
    // 最初の移動は、全員をキャパで割った回数かかる
    if(i==2) {
      dp[i] = ceil((double)n/capacity[i-1]);
      minCapacity = capacity[i-1];
    }
    else {
      // 前の交通機関より、次に使う交通機関のほうがキャパが大きいなら、最終グループはすぐ次に行ける
      if(capacity[i-1]>=minCapacity) dp[i] = dp[i-1]+1;
      else {
        // そうでないならば、1回目の移動と同じ計算をする
        dp[i] = (i-2)+ceil((double)n/capacity[i-1]);
        minCapacity = capacity[i-1];
      }
    }
  }
  cout << dp[6] << endl;
}


Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int res1 = ceil((double)A / D);
  int res2 = ceil((double)C / B);

  if (res2 <= res1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979

int main()
{
	long long int** list;
	int n;
	int* data;
	int i,j;
	long long int count = 1;
	scanf("%d",&n);
	data = mem(int,n-1);
	list = mem(long long int*,n-1);
	for(i = 0;i < n-1;i++)
	{
		scanf("%d",&data[i]);
		list[i] = mem(long long int,21);
		if(i)
		{
			for(j = 0;j < data[i];j++)
			{
				list[i][j] = list[i-1][j+data[i]];
			}
			for(;j <= 20-data[i];j++)
			{
				list[i][j] = list[i-1][j+data[i]]+list[i-1][j-data[i]];
			}
			for(;j <= 20;j++)
			{
				list[i][j] = list[i-1][j-data[i]];
			}
		}
		else
		{
			for(j = 0;j <= 20;j++)
			{
				list[0][j] = 0;
			}
			list[0][data[0]] = 1;
		}
	}
	int ans;
	scanf("%d",&ans);
	printf("%lld\n",list[n-2][ans]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e5;
const ll INF=1e18;
int N;
ll psm[MAX_N+1];
int main(){
	cin>>N;
	psm[0]=0;
	REP(i,N){
		ll a;
		cin>>a;
		psm[i+1]=psm[i]+a;
	}
	ll ans=INF;
	REP(i,N-1){
		ans=min(ans,llabs(psm[i+1]-(psm[N]-psm[i+1])));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i);
    }

    vector<int> order(n);
    for (int i = 0; i < n; i++) {
        order.at(i) = i;
    }
    long double sum = 0;
    int count = 0;
    do {
        for (int i = 1; i < n; i++) {
            double dx = x.at(order.at(i-1)) - x.at(order.at(i));
            double dy = y.at(order.at(i-1)) - y.at(order.at(i));
            double tmp = pow(dx, 2) + pow(dy, 2);
            sum += sqrt(tmp);
        }
        count++;
    } while (next_permutation(order.begin(), order.end())); // 順列作成

    long double ans = sum / count;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    string yohou, tenki;
    cin >> yohou;
    cin >> tenki;
    int ret = 0;
    rep(i, 3)
    {
        if (yohou[i] == tenki[i])
            ret++;
    }
    cout << ret << endl;
}


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

int main()
{
	int a, b, c, d, p, r;

	cin >> a >> b >> c >> d >> p;

	if (p <= c) {
		if (a * p <= b)
			r = a * p;
		else
			r = b;
	}
	else {
		if (a * p <= b + (p - c) * d)
			r = a * p;
		else
			r = b + (p - c) * d;
	}

		cout << r << endl;

	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long b[100001];
	long long a[100001];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
		if(a[i]==a[i-1]){
			for(int j=i;j<n-1;j++)
				a[j]=a[j+1];
			n--;		
		}
			
	int sum=1;	
	for(int i=1;i<n-1;i++){
		if((a[i]>a[i-1]&&a[i]>a[i+1])||(a[i]<a[i-1]&&a[i]<a[i+1])){
			sum++;a[i]=a[i+1];
		}
	}			
	cout<<sum;		
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;
	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	if (any_of(A.begin(), A.end(), [](auto& a) {return a == 0; })) {
		cout << 0 << "\n";
		return 0;
	}

	const lint mx = 1e18;
	lint ans = 1;
	for (int i = 0; i < N; i++) {

		if (ans > 1.0L * mx / A[i]) {
			cout << -1 << "\n";
			return 0;
		}

		ans *= A[i];

	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3968
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3,greater<ll>());
  ll ans = 0;
  ll d1 = a[0]-a[1];
  ll d2 = a[0]-a[2];
  if(d1>2){
    ans += (d1-1)/2;
    d1 = (d1+1)%2+1;
  }
  if(d2>2){
    ans += (d2-1)/2;
    d2 = (d2+1)%2+1;
  }
  if(d1==0&&d2==1) ans += 2;
  if(d1==1&&d2==0) ans += 2;
  if(d1==1&&d2==1) ans += 1;
  if(d1==0&&d2==2) ans += 1;
  if(d1==2&&d1==0) ans += 1;
  if(d1==1&&d2==2) ans += 3;
  if(d1==2&&d2==1) ans += 3;
  if(d1==2&&d2==2) ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
using namespace std;
int main(int argc, char const *argv[])
{
 string s,l;
 cin >>s>>l;
 s+=s;
 int i,j,n;
 i = 0;
 n =l.size();
 while(l[0] != s[i])
 {
   i++;
 }
 j = 0;
 while(j < n)
 {
   if(s[i] != l[j])
   {
     cout<<"No"<<endl;
     return 0;
   }
   j++;
   i++;

 }

 cout<<"Yes"<<endl;

return 0;

}



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

int main(void){
    int k, ans=0;
    cin >> k;
    for (int i=1; i<k; i++){
        for (int j=i+1; j<=k; j++){
            if ((i%2 == 0 && j%2 == 1) || (i%2 == 1 && j%2 == 0)) ans++; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int b[55],p[55],c[55];
int id1[55],id2[55];
int s1,s2;
int main()
{
    int n,m;

    while(~scanf("%d%d",&n,&m))
    {
        s1=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",b+i);
            s1+=b[i];
        }
        for(int i=0;i<m;i++)
        {
            scanf("%d",p+i);
        }
        int Ans=1e9;
        for(int num=0;num<2;num++)
        {

            s2=0;

            int cnt=0;
            for(int i=0;i<m;i++)
            {
                for(int j=0;j<p[i];j++)
                {
                    if(i%2==0)
                    {
                        c[cnt++]=num;
                    }
                    else
                    {
                        c[cnt++]=1-num;
                    }
                }
            }

            int ans=0;
             for(int i=0;i<cnt;i++)
            {
               s2+=c[i];
            }
            if(s1!=s2)continue;
            int cnt1=0;
            int cnt2=0;
            for(int i=0;i<cnt;i++)
            {
                if(c[i]==1)id2[cnt2++]=i;
            }
            for(int i=0;i<n;i++)
            {
                if(b[i]==1)id1[cnt1++]=i;
            }
            for(int i=0;i<cnt1;i++)
            {
                ans+=abs(id2[i]-id1[i]);
            }
            Ans=min(Ans,ans);
        }
        cout<<Ans<<endl;
    }
return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

void solve() {
	int h1, m1, h2, m2, k;
	read(h1), read(m1), read(h2), read(m2), read(k);
	int t1 = h1 * 60 + m1, t2 = h2 * 60 + m2;
	print(std::max(t2 - t1 - k, 0));
}

int main() {
	int T = 1;
	// read(T);
	while (T--) {
		solve();
	}
}


Measured memory_bytes: 3004
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    K = input()

    ans = len(K)
    K = int(K)
    x = int("7" * ans)

    use = set()
    while 1:
        if x % K == 0:
            break
        x = (x % K) * 10 + 7

        if x in use:
            print(-1)
            return 
        use.add(x)
        ans += 1

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 208740
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){
  
  long long H,W,ans;
  
  cin >> H >> W;
  
  if(H==1 || W==1){
    ans=1;
  }else if(H*W % 2 == 0){
    ans = H*W /2;
  }else{
    ans = H*W /2 +1; 
  }
 
  cout << ans << endl;

  return 0;
}



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int H, W;
  cin >> H >> W;
  bool board[H+1][W+1];

  for(int i=0;i<H;i++){
    string s;
    cin >> s;
    for(int j=0;j<W;j++){
      if(s[j] == '#') board[i][j] = true;
      else board[i][j] = false;
    }
  }

  for(int i=0;i<=H;i++) board[i][W] = false;
  for(int i=0;i<=W;i++) board[H][i] = false;

  int cur_x, cur_y;
  cur_x = 0;
  cur_y = 0;
  while(!(cur_x == H-1 && cur_y == W-1)){
    board[cur_x][cur_y] = false;
    if(board[cur_x+1][cur_y] == false && board[cur_x][cur_y+1] == false){
      cout << "Impossible" << endl;
      return 0;
    }
    if(board[cur_x+1][cur_y] == true && board[cur_x][cur_y+1] == true){
      cout << "Impossible" << endl;
      return 0;
    }
    if(board[cur_x+1][cur_y] == true && board[cur_x][cur_y+1] == false){
      cur_x++;
    }
    else if(board[cur_x+1][cur_y] == false && board[cur_x][cur_y+1] == true){
      cur_y++;
    }
  }
  board[H-1][W-1] = false;


  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(board[i][j]){
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }


  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	int n; cin >> n;
	char y ='1';
	string ans ="";
	for(int i=0 ; i < n ; i++){
		char ch ; cin >> ch;
		if(ch!=y)
		ans += ch, y = ch;
	}
	//cout << ans << endl;
	cout << ans.size() << endl;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define ar array
#define pii pair<int, int>

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

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

    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) ans += (i % d == 0);
    cout << ans << '\n';
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    char s[100010];
    cin >> s;
    bool v[26];
    
    for (int i = 0; i < 26; i++)
    {
        v[i]=false;
    }
    for (int i = 0; s[i]!= '\0'; i++)
    {
        v[s[i]-'a']=true;
    }
    
    for (int i = 0; i < 26; i++)
    {
        if(v[i]==false){
            char ans = 'a'+i;
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

typedef string::const_iterator State;
int number(State&);
int factor(State&);
int term(State&);
int expression(State&);

// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

// ??¬??§?????°???????????????????????????????????????????????????
int factor(State &begin) {
    if (*begin == '(') {
        begin++; // '('????£???°??????
        int ret = expression(begin);
        begin++; // ')'????£???°??????
        return ret;
    } else {
        return number(begin);
    }
    return -1;
}

// ?????????????????????????????????????????????????????????????????????
int term(State &begin) {
    int ret = factor(begin);

    for (;;) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

// ?????????????????????????????????????????????????????????????????????
int expression(State &begin) {
    int ret = term(begin);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}

//begin???expected?????????????????????begin?????????????????????
void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl;
        cerr << "Rest string is '";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        //throw ParseError();
    }
}


int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        State tmp = s.begin();
        int ans = expression(tmp);
        consume(tmp, '=');
        cout << ans << endl;
    }
}

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

int d; //日数
const int z=26; //コンテスト数
vector<int> c(z); //コンテストiが開催されないペナルティ
vector<vector<int>> s; //i日目にコンテストjが開催された時の満足度

int score(vector<int> &t)
{
    int sum = 0;
    vector<int> last(z, -1); //コンテストが最後に開催された日
    for (int i = 0; i < t.size(); i++)
    {
        sum += s[i][t[i]];
        last[t[i]] = i;
        for (int j = 0; j < z; j++)
        {
            sum -= c[j] * ((i+1) - (last[j]+1));
        }
        
    }
    return sum;
}

void mix(vector<int> &a, vector<int> &b, int index)
{
    assert(index < d);
    assert(index >= 1);
    for (int i = 0; i < index; i++)
    {
        swap(a[i], b[i]);
    }
}


void Main()
{
    cin >> d;
    s = vector<vector<int>>(d, vector<int>(z));
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < z; j++)
        {
            cin >> s[i][j];
        }
    }

    const int n_sample = 64;
    const int n_change = 10;
    const int best_n = 64;
    const int mix_n = 64;

    std::mt19937 mt(rand());
    std::uniform_int_distribution<> randz(0, z-1);
    std::uniform_int_distribution<> rand_mix(1, d-1);
    std::uniform_int_distribution<> rand_sample(0, n_sample-1);

    vector<vector<vector<int>>> ts(2, vector<vector<int>>(n_sample+best_n*2, vector<int>(d)));
    for (int i = 0; i < ts[0].size(); i++)
    {
        for (int j = 0; j < d; j++)
        {
            ts[0][i][j] = randz(mt);
        }
    }

    vector<pair<int, int>> scores;
    scores.reserve(ts[0].size());
    int w0 = 0, w1 = 1;
    for (int i = 0; i < n_change; i++)
    {
        scores.resize(0);
        for (int j = 0; j < ts[w0].size(); j++)
        {
            scores.push_back(make_pair(score(ts[w0][j]), j));
        }
        sort(scores.rbegin(), scores.rend());
        // cerr << scores[0].first << endl;
        
        for (int j = 0; j < best_n; j++)
        {
            for (int k = 0; k < d; k++)
            {
                ts[w1][j][k] = ts[w0][scores[j].second][k];
            }
        }
        for (int j = 0; j < mix_n; j++)
        {
            int rand_a = rand_sample(mt);
            int rand_b = rand_sample(mt);
            for (int k = 0; k < d; k++)
            {
                ts[w1][best_n + 2*j][k] = ts[w1][rand_a][k];
                ts[w1][best_n + 2*j+1][k] = ts[w1][rand_b][k];
            }
            mix(ts[w1][best_n + 2*j], ts[w1][best_n + 2*j+1], rand_mix(mt));
        }

        swap(w0, w1);
    }

    for (int i = 0; i < d; i++)
    {
        cout << ts[w0][scores[0].second][i] + 1 << endl;
    }
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}



Measured memory_bytes: 4176
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<int> A(N);
	map<int,int> ms;
	rep(i, 0, N)
	{
		cin >> A[i];
		ms[i - A[i]]++;
	}

	int ans = 0;
	rep(i, 0, N)
	{
		ms[i - A[i]]--;
		ans += ms[i + A[i]];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 27440