akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

long long n, m;
vector<vector<vector<ModInt<>>>> dp;

ModInt<> solve();

int main() {
  cin >> n >> m;
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 0;
  dp.assign(2, vector(n + 1, vector<ModInt<>>(2, 0)));
  for (int i = 0; i <= n; ++i) dp[0][i][0] = 1;
  for (int i = 0; i < m; ++i) {
    dp[(i + 1) & 1].assign(n + 1, vector<ModInt<>>(2, 0));
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k < 2; ++k) {
        // fi: red
        if (j != 0) {
          int num = k || (j == n);
          // se : red
          dp[(i + 1) & 1][j - 1][num] += dp[i & 1][j][k];
          // se : blue
          dp[(i + 1) & 1][j][num] += dp[i & 1][j][k];
        }
        // fi : blue
        if (j != n) {
          int num = k || (j == 0);
          // se : red
          dp[(i + 1 & 1)][j][num] += dp[i & 1][j][k];
          // se : blue
          dp[(i + 1) & 1][j + 1][num] += dp[i & 1][j][k];
        }
      }
  }
  for (int i = 0; i <= n; ++i) res += dp[m & 1][i][1];
  return res;
}

Measured memory_bytes: 4032
import numpy as np

n = int(input())
r = []
b = []

for i in range(n):
    x,y = map(int,input().split())
    r.append([x,y])

for i in range(n):
    x,y = map(int,input().split())
    b.append([x,y])



r.sort(key=lambda x:[x[0],x[1]])
b.sort(key=lambda x:[x[1],x[0]])


ans = 0
for i in range(n):
    x,y = b[i][0],b[i][1]
    tar = 0
    flag = False
    # print(r)
    # print(b)
    for j in range(len(r)):
        if r[j][0] < x and r[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans += 1
        r.pop(tar)

print(ans)

Measured memory_bytes: 14432
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n; cin >> n;
  int num[n][3];
  FOR(i,0,n) FOR(j,0,3) cin >> num[i][j];
  int ans[n]; FOR(i,0,n) ans[i] = 0;
  FOR(i,0,3) {
    int cnt[101]; FOR(j,0,101) cnt[j] = 0;
    FOR(j,0,n) cnt[num[j][i]]++;
    FOR(j,0,n) if(cnt[num[j][i]] == 1) ans[j] += num[j][i];
  }
  FOR(i,0,n) cout << ans[i] << endl;
  return 0;
}

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

int main() {
	int h,a;
  	cin>>h>>a;
  
  	int kaisuu=0;
  
  while(h>0){
    kaisuu++;
    h -= a;
  }
  
  cout<<kaisuu<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,m; cin >> n >> m;
  vl cnt(n);
  
  rep(i,2*m){
    ll x; cin >> x;
    cnt[x-1]++;
  }
  
  for(ll x :cnt){
    cout << x << endl;
  }
  
  
}

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

chomp (my $s = <STDIN>);
my $next_perm = sub {
  my $t = shift;
  my $f = -1;
  for my $i (0..length($t)-1) {
    if (ord(substr($t, length($t)-1-$i, 1)) > ord(substr($t, length($t)-2-$i, 1))) {
      $f = length($t) - 2 - $i;
      last;
    }
  }
  return -1 if $f == -1;
  my @w = split '', substr($t, $f+1);
  my @x = sort {$a cmp $b} grep {ord($_) > ord(substr($t, $f, 1))} @w;
  my $r = shift @x;
  push @w, substr($t, $f, 1);
  @w = sort {$a cmp $b} grep {$_ != $r} @w;
  return substr($t, 0, $f).$r.join('', @w);
};
my $ans;
if (length($s)==26) {
  $ans = $next_perm->($s);
} else {
  my %h;
  $h{$_}++ for ('a'..'z');
  $h{$_}++ for split('', $s);
  my @w = sort {$a cmp $b} grep {$h{$_}==1} keys %h;
  $ans = $s . $w[0];
}
say $ans;

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
const ll INF = 1e18;

ll K;
vector<edge> G[100000];
ll d[100000];

void dijkstora(ll s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d+K, INF);
  d[s] = 0;
  que.push(P(0,s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (ll i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> K;
  for (ll i = 0; i < K; i++) {
    G[i].push_back({(i+1)%K, 1});
    G[i].push_back({10*i%K, 0});
  }
  dijkstora(1);
  cout << d[0]+1 << endl;
}

Measured memory_bytes: 9208
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main(){
  int ans=0;
  int N;cin>>N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }

  ans += B.at(0)+B.at(N-2);
  for(int i=1;i<N-1;i++){
    ans += min(B.at(i),B.at(i-1));
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
def main():
    A,B,H,M= map(float, input().split())
    mkaku = M*6
    hkaku = H*30+M*0.5
    Co = abs(mkaku-hkaku)
    if Co > 180:
        Co = 360 - Co
    ans2 = A*A + B*B - 2*A*B*math.cos(math.radians(Co))
    print (math.sqrt(ans2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		String N = sc.nextLine();
		String[] Narray = N.split("");
		int ns = 0;
		for (String n : Narray) {
			int n_ = Integer.parseInt(n);
			ns += n_;
		}

		int N_ = Integer.parseInt(N);
		
		if(N_ % ns == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
taro = 0
hanako = 0
for i in range(int(input())):
    line = str(input()).split()
    t = line[0]
    h = line[1]
    if (t == h):
        taro += 1
        hanako += 1
    elif (t < h):
        hanako += 3
    elif (t > h):
        taro += 3

print('{} {}'.format(taro, hanako))



Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int n,t,a,h,p;
double k,ans=1000001;

int main()
{
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	{
		cin>>h;
		k=(double)t-(double)h*0.006-a;
		if((k=(k>0?k:(-k)))<ans)
		{
			ans=k;
			p=i;
		}
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    vector<int> a(S.size(), 0);
    double cntR = 0.0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'R') cntR++;
        else {
            a[i - 1] += ceil(cntR / 2);
            a[i ] += floor(cntR / 2);
            cntR = 0;
        }
    }
    double cntL = 0.0;
    for (int i = S.size() - 1; i >= 0; i--) {
        if (S[i] == 'L') cntL++;
        else {
            a[i + 1] += ceil(cntL / 2);
            a[i] += floor(cntL / 2);
            cntL = 0;
        }
    }
    for (int ai : a) cout << ai << ' ';
    cout << '\n';
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    a = list(map(int, input().split()))

    l, r = [-1 for i in range(n)], [n for i in range(n)]
    for i in range(n):
        if i == 0:
            continue
        elif a[i] > a[i-1]:
            l[i] = i - 1
        else:
            idx = l[i-1]
            while idx != -1 and a[i] < a[idx]:
                idx = l[idx]
            l[i] = idx

    for i in range(n-1, -1, -1):
        if i == n-1:
            continue
        elif a[i] > a[i+1]:
            r[i] = i + 1
        else:
            idx = r[i+1]
            while idx != n and a[i] < a[idx]:
                idx = r[idx]
            r[i] = idx

    ans = 0
    for i in range(n):
        ans += a[i] * (i-l[i]) * (r[i]-i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		sc.close();

		BigDecimal high = BigDecimal.valueOf(H);
		BigDecimal wide = BigDecimal.valueOf(W);
		BigDecimal check = BigDecimal.valueOf(2);

		BigDecimal mass = high.multiply(wide);
		BigDecimal result = mass.remainder(check);
		BigDecimal tmpAns = mass.divide(check);

		if(H == 1 || W == 1) {
			System.out.println(1);
		}else if(result.intValue() == 0) {
			long ans = tmpAns.longValue();
			System.out.println(ans);
		}else {
			long ans = tmpAns.longValue() + 1;
			System.out.println(ans);
		}
	}

}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int res = 0;
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            for (int i = k; i <= n; i++)
            {
                res++;
            }
            Console.WriteLine(res);

        }
    }
}

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

int main(){
  int N ;
  cin >> N ;
  vector<int> A(300000);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int minv = 300000;
  int ans =0;
  for(int i=0;i<N;i++){
    minv = min(minv,A[i]);
    if(minv==A[i]) ans++ ;
  }
  
  cout << ans << endl;
  
}
  



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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define ss second
#define ff first 


int main(){
    string s;
    cin >> s;

    int ans=0;
    bool ok=false;
    for(int i=0; i<(int)s.length(); ++i){
        if(ok){
            ans++;
            ok = false;
        }
        else{
            if(s[i] != s[i+1]){
                ans++;
                continue;
            }
            else{
                ans++;
                ++i;
                ok=true;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3744
#include <cstring>
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;

const int n_max = 301;
const double eps = 5e-7;
vector<vector<vector<double> > > dp(n_max, vector<vector<double> >(n_max, vector<double>(n_max, -1)));
int n;

double solve(int x, int y, int z) {
	if(x<0 || y<0 || z<0) return 0;
	if(dp[x][y][z] != -1) return dp[x][y][z];
	
	double ones = x*solve(x-1, y, z);
	double twos = y*solve(x+1, y-1, z);
	double threes = z*solve(x, y+1, z-1);
	return dp[x][y][z] = (n+ones+twos+threes)/(x+y+z);
}

int main() {
	dp[0][0][0] = 0.0;
	cin>>n;
	
	vector<int> counts(4, 0);
	for(int i=0; i<n; i++) {
		int sushi;
		cin>>sushi;
		counts[sushi]++;
	}
	
	cout<<fixed<<setprecision(10)<<solve(counts[1], counts[2], counts[3])<<endl;
	return 0;
}


Measured memory_bytes: 219008
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;

int fa(int b){
    int _b = b;
    for(int i=1; i<_b; i++) b+=i;
    return b;
}


int main() {
    int a, b; cin >> a >> b;
    cout << fa(b-a)-b<< endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
char s[N]; int n;
int main(){
    scanf("%s",s); n=strlen(s);
    for(int i=0;i<n;++i) if(s[i]=='?') s[i]='D';
    printf("%s\n",s);
}

Measured memory_bytes: 3876
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cctype>
#include <stack>
#define mst(a,b) memset(a,b,sizeof(a));
const int mod = (int)1e9+7;
const int maxn = 1e5+5;
const int INF = 0x3f3f3f3f;
typedef long long LL;

using namespace std;

vector<LL> pq, a;
LL ans = 0;
int wei[50];

int gcd(int a, int b)
{
    return (b==0)?a:gcd(b, a%b);
}

bool cmp(LL a, LL b)
{
    return a>b;
}

int main()
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    x-=a;
    printf("%d", x%b);
    return 0;
}

/*
0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

10
11
100 1 1 1 1 1 1 1 1 1 1

1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648

*/




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	ll f[4]={0};
	f[a]=1;
	f[b]=1;
	for(int i=1;i<=3;i++)if(f[i]==0)cout<<i;
	cout<<endl;
}/*『你强归你强，我永不示弱』*/





Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int LSC_Length(char[], char[]);

int main(){
  int n,i;
  char X[1001],Y[1001];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
  scanf("%s",&X[0]);
 
  scanf("%s",Y);
  LSC_Length(X,Y);
  }
  //  printf("%s\n", X);
  // printf("%s\n", Y);

  return 0;
}

int LSC_Length(char X[],char Y[]){
  int m,n,i,j;
  m=strlen(X);
  n=strlen(Y);
  int c[m+1][n+1];
  for(i=1;i<=m;i++)
    c[i][0]=0;
  for(j=0;j<=n;j++)
    c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])
	c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
	c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n", c[m][n]);
  return 0;
}

Measured memory_bytes: 4524
N, M = map(int, input().split())
x = [0]
y = [0]
memo = [1] * (N + 1) #各箱の中のボールの数
flag = [0] * (N + 1) #赤ボールがある可能性
for _ in range(M):
    _x, _y = map(int, input().split())
    x.append(_x)
    y.append(_y)

flag[1] = 1
for i in range(1, M + 1):
    if memo[x[i]] == 0: #移動するボール無し
        continue
    memo[x[i]] -= 1
    memo[y[i]] += 1
    if flag[x[i]] == 1:
        flag[y[i]] = 1
    if memo[x[i]] == 0:
        flag[x[i]] = 0

ans = 0
for i in range(1, N + 1):
    if memo[i] <= 0:
        continue
    if flag[i] == 1:
        ans += 1
#print(memo)
#print(flag)
print(ans)


Measured memory_bytes: 87112
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	string s;
	cin>>s;
	if(s.back()=='s')s+="es";
	else s+="s";
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3628
from collections import deque

def main():
    n, q = map(int, input().split())
    Qt = [deque() for _ in range(n)]

    for _ in range(q):
        para = [int(a) for a in input().split()]

        if para[0] == 0:
            Qt[para[1]].append(para[2])
        if para[0] == 1:
            if len(Qt[para[1]]) != 0:
                print(Qt[para[1]][0])
        if para[0] == 2:
            if len(Qt[para[1]]) != 0:
                Qt[para[1]].popleft()
main()



Measured memory_bytes: 14532
n=int(input())
a=eval('list(input()),'*n)
if all(t.count('#')<1for t in a):
  print(-1)
  exit()
f=sum(n==t.count('#')for t in zip(*a))
c=10**18
for i,b in enumerate(a):
  v=b.count('#')
  t=0
  if b[i]!='#':
    for j in range(n):
      if a[j][i]=='#':
        break
    else:
      t+=1
    t+=n-v
  else:
    t+=n-v
  c=min(c,t+n-f)
print(c)

Measured memory_bytes: 49776
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int l;
  while (cin >> l, l) {
    vi v(12);
    rep(i, 12) {
      int m, n;
      cin >> m >> n;
      v[i] = m - n;
    }
    int s = 0;
    rep(i, 12) {
      s += v[i];
      if (s >= l) {
        cout << i + 1 << endl;
        goto next;
      }
    }
    cout << "NA" << endl;
  next:;
  }
}

Measured memory_bytes: 3048
from math import sqrt
def distance2(x, y, p='infinite'):
    if p == 'infinite':
        return max([abs(dx - dy) for dx, dy in zip(x,y)])
    else:
        return sum([(abs(dx - dy)**p) for dx, dy in zip(x, y)])**(1/p)

if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))[0:n]
    y = list(map(int, input().split()))[0:n]
    print(distance2(x, y, 1))
    print(distance2(x, y, 2))
    print(distance2(x, y, 3))
    print(distance2(x, y))



Measured memory_bytes: 5700
import sys
sys.setrecursionlimit(10**6)
#import numpy as np
#N = map(int, input().split())
N = int(input())
h = list(map(int,input().split()))

# メモ化再帰
#memo = np.full(N, -1)
memo = [-1]*N
def func(i):
    if memo[i] != -1:
        return memo[i]
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[1]-h[0])
    a = func(i-1) + abs(h[i]-h[i-1])
    b = func(i-2) + abs(h[i]-h[i-2])
    memo[i] = min(a,b)
    return min(a,b)
print(func(N-1))

# pythonの問題はfuncの呼び出し回数
# 10^50に耐えられない
# sys.setrecursionlimit(10**6)で回避可能

Measured memory_bytes: 94100
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

pos = [0] * (N + 1)
pos[0] = -1
for i, a in enumerate(A):
    pos[a] = i

ans = 0
lefts = [0] * N
rights = [0] * N
for i in reversed(range(1, N + 1)):
    p = pos[i]
    if p + 1 < N and A[p + 1] > i:
        # 右とつながった
        right = rights[p + 1]
    else:
        right = p
    if p - 1 >= 0 and A[p - 1] > i:
        # 左とつながった
        left = lefts[p - 1]
    else:
        left = p
    lefts[right] = left
    rights[left] = right
    ans += (p - left + 1) * (right - p + 1) * i
print(ans)


Measured memory_bytes: 23572
#include <iostream>

using namespace std;

int SolveTaxIncrease(int A, int B) {
  for (int p = 10 * B; p <= 10 * B + 9; ++p) {
    const int tax = 8 * p / 100;
    if (tax == A) return p;
  }
  return -1;
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << SolveTaxIncrease(A, B) << endl;

  return 0;
}


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

const long long int MOD = 1e9 + 7;

long long int dfs(const int &K, const vector<vector<int>> &graph, const int &now, const int &from){

    int can_use_color_num;
    if(from == -1){
        can_use_color_num = K - 1;
    }else{
        can_use_color_num = K - 2;
    }

    if(K < graph[now].size()){
        return 0;
    }else{
        long long int case_num = 1;
        //現在地から子の方向に繋がっているnodeの数を積の形で数えてる
        for(auto e: graph[now]){
            if(e == from) continue;

            case_num *= can_use_color_num;
            can_use_color_num--;
            case_num %= MOD;
        }
        //dfsでさらに深く潜る
        for(auto e: graph[now]){
            if(e == from) continue;
            case_num *= dfs(K, graph, e, now);
            case_num %= MOD;
        }
        return case_num;
    }
}

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

    vector<vector<int>> graph(N);
    for(int i = 0; i < N - 1; i++){
        int a, b; cin >> a >> b;a--, b--;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int answer = K * dfs(K, graph, 0, -1);
    answer %= MOD;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h1,m1,h2,m2,k;
	scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
	int tot = (h2-h1)*60+m2-m1;
	printf("%d",tot-k);
}

Measured memory_bytes: 3760
import sys
import numpy as np
input = sys.stdin.readline


N, K = map(int, input().split())
h = np.array(list((map(int,input().split()))))


dp = np.ones(N)
dp = dp * 10000
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for n in range(2, N):
    start = max(0, n - K)
    dp[n] = (dp[start:n] + np.abs(h[start:n]-h[n])).min()

print(int(dp[N-1]))






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

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;

    rep(i, n){
        int temp;
        cin >> temp;
        if(temp >= k)ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;




int main() {
    ll n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    unordered_map<ll, ll> b;
    ll ans = 0LL;
    rep(i, n) {
        if (b.count(i - a[i])) ans += b[i - a[i]];
        else b[i - a[i]] = 0LL;
        if (b.count(i + a[i])) b[i + a[i]] += 1LL;
        else b[i + a[i]] = 1LL;
    }
    print(ans);
}

Measured memory_bytes: 20108
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout <<"DEBUG>>"<< e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }

//-----CODE------//

void solve(void)
{
  int N,K,S;
  cin>>N>>K>>S;

  vector<int> ANS(N,0);
  if(K == N)
  {
    for (int i = 0; i < N; i++)
    {
      if(i!=0)cout<<" ";
      cout<<S;
    }
    cout<<endl;
    return;
  }

  for (int i = 0; i < N; i++)
  {

    if(i <= K)
    {
    ANS[i] =  S/2;
    if(S%2 == 1)
    {
      if(i%2 == 1)
      {
        
        ANS[i]++;
      }
    }
      if((K == 0)&&(S == 1e9))
      {
        ANS[i] = 999999999;
      }
    }
    else
    {
      if(S != 1e9)
      {
        ANS[i] = 1e9;
      }
      else
      {
        ANS[i] = 999999999;
      }
      
    }
  }

  if(S==1)
  {
    int COUNT = 0;
    for (int i = 0; i < N; i++)
    {
      if((i%2 == 0)&&(COUNT < K))
      {
        ANS[i] = 1;
        COUNT++;
      }
      else
      {
        ANS[i] = 1e9;
      }
      
    }
    
  }

  for (int i = 0; i < N; i++)
  {
    if(i!= 0)cout<<" ";
    cout<<ANS[i];
  }
  cout<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);
  solve();

 
  return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string S;
    int N, K;
    char ch;
    std::cin >> N >> S >> K;
    ch = S[K - 1];
    for (char c : S)
    {
        if (c != ch) { std::cout << '*'; }
        else
        {
            std::cout << ch;
        }
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int &i:A)
    cin>>i;
  B[0]=0,B[1]=abs(A[0]-A[1]);
  for(int i=2;i<N;i++)
    B[i]=min(B[i-2]+abs(A[i]-A[i-2]),B[i-1]+abs(A[i]-A[i-1]));
  cout<<B[N-1]<<endl;
}

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

int main(){
    int N;
    cin>>N;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

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

    long long ans=0;
    int num;
    for(int i=N-1;i>=0;i--){
        if(i==N-1){
        }else if(i==N-2){
            ans+=A[N-1];
        }else{
            num=(N-i+1)/2;
            ans+=A[N-num];
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{int to; ll cost;};

const int MAX_V = 100000;
vector<edge> es[MAX_V][2];

int main(){
    int N, M, s[2];
    cin >> N >> M >> s[0] >> s[1];
    s[0]--, s[1]--;
    rep(i, M){
        int u, v; ll a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        es[u][0].eb((edge){v, a}), es[v][0].eb((edge){u, a});
        es[u][1].eb((edge){v, b}), es[v][1].eb((edge){u, b});
    }
    ll d[N][2];
    fill(d[0], d[N], INF);
    rep(j, 2){
        priority_queue<pli, vector<pli>, greater<pli> > que;
        que.emplace(d[s[j]][j] = 0, s[j]);
        while(!que.empty()){
            ll p; int i;
            tie(p, i) = que.top(); que.pop();
            for(auto &e: es[i][j]){
                if(chmin(d[e.to][j], d[i][j]+e.cost)) que.emplace(d[e.to][j], e.to);
            }
        }
    }
    ll ans[N+1];
    fill(ans, ans+N+1, INF);
    rep3(i, N-1, 0){
        ans[i] = min(ans[i+1], d[i][0]+d[i][1]);
    }
    ll init = 1;
    rep(i, 15) init *= 10;
    rep(i, N){
        cout << init-ans[i] << endl;
    }
}

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

int main() {

	ll n; cin >> n;
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		mp[a]++;
	}
	string ans = "NO";
	if (mp.size() == n) ans = "YES";
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16080
#include<stdio.h>
int main(void){

int S,h,m,s,i;
	h=0;
	m=0;
	s=0;
	i=0;

scanf( "%d" , &S );

h = S / 3600;
i = S%3600;
	
m = i / 60;

s =i%60;

printf("%d:%d:%d\n",h,m,s);


return 0;
}


Measured memory_bytes: 1972
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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; 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 > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! { n, a: [[isize; n]; n] };
    let mut dp = vec![0; 1 << n];
    for x in 1..(1 << n) {
        for i in 0..(n - 1) {
            for j in (i + 1)..n {
                if (x >> i) & 1 == 1 && (x >> j) & 1 == 1 {
                    dp[x] += a[i][j];
                }
            }
        }
    }
    for x in 1..(1 << n) {
        let mut y = (x - 1) & x;
        while y > 0 {
            dp[x] = max(dp[x], dp[y] + dp[x ^ y]);
            y = (y - 1) & x;
        }
    }
    println!("{}", dp.last().unwrap());
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL dis[305][305];
LL n,m,l,Q;

void floyd(){
	for(LL k = 1;k <= n;k ++){
		for(LL i = 1;i <= n;i ++){
			for(LL j = 1;j <= n;j ++){
				dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
			}
		}
	}
}

int main(){
	LL u,v,w;
	memset(dis,INF,sizeof(dis));
	cin >> n >> m >> l;
	for(LL i = 1;i <= m;i ++){
		cin >> u >> v >> w;
		dis[u][v] = w;
		dis[v][u] = w;
	}
	floyd();
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			dis[i][j] = ((dis[i][j] > l) ? INF : 1);
		}
	}
	for(LL i = 1;i <= n;i ++) dis[i][i] = 1;
	floyd();
	cin >> Q;
	while(Q --){
		cin >> u >> v;
		if(dis[u][v] == INF) cout << -1 << endl;
		else cout << dis[u][v] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n==1) System.out.println(0);
		else System.out.println(1);
	}
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n;
    cin>>n;
    vector<int> c(n-1),s(n-1),f(n-1);
    rep(i,n-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    vector<int> arrive(n,0);
    //int arrive=s[0];
    rep(i,n-1){
        arrive[i] = s[i];
        for(int j=i;j<n-1;j++){
            arrive[i] += c[j];
            if(i==0){
            //cout<<"arrived at station"<<j+1<<" in"<<arrive[i]<<endl;
            }
            if(j==n-2){
                break;
            }
            //待ち時間がある場合は加算
            if(arrive[i]<s[j+1]){
                arrive[i]=s[j+1];
            }
            if((arrive[i]-s[j+1])%f[j+1]!=0){
                arrive[i] += f[j+1] - (arrive[i]-s[j+1])%f[j+1]; 
            }
        }
        cout<<arrive[i]<<endl;
    }
    cout<<0<<endl;
}

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

int main()
	{
		for (;;)
		{
			int x,y;

			cin >> x >> y;
			if (x==0 &&y==0)break;
			cout<< min(x,y) << " " << max (x,y)<<endl;
		}

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=120;
const int mod=998244353;

#define Bit bitset<101>

int p2[maxn];
int n;
char str[maxn];
Bit S;

inline void init()
{
	scanf("%s",str+1);n=strlen(str+1);
	p2[0]=1; REP(i,1,n)p2[i]=(p2[i-1]*2)%mod;
	REP(i,1,n)if(str[i]=='1')S.set(i-1);
}

ll f[maxn][maxn];

int rem[16][1<<15],rem1[16][1<<15];

int solve(int len,Bit a);
int work(int len,Bit all);

inline int solve(int len,Bit a)
{
	ll x=0;
	if(len<=15)
	{
		REP(j,0,len-1)x|=a[j]<<j;
		if(~rem[len][x])return rem[len][x];
	}
	int ans=0;
	REP(j,2,len)if(len%j==0)
	{
		Bit t;
		int nlen=len/j;
		REP(k,0,nlen-1)
		{
			int flg=1;
			REP(x,0,j-1)
			{
				flg&=a[x*nlen+k];
				//cerr<<(ll)a<<endl;
				//cerr<<(ll)(~a>>x*nlen+k&1)<<" "<<(ll)~((~a>>x*nlen+k&1)<<k)<<endl;
			}
			if(flg)t.set(k);
		}
		//cerr<<(ll)t<<endl;
		ans=(ans+work(nlen,t))%mod;
	}
	if(len<=15)rem[len][x]=ans;
	return ans;
}

int dp[maxn];

inline int work(int n,bitset<101> all)
{
	ll x=0;
	if(n<=15)
	{
		REP(j,0,n-1)x|=all[j]<<j;
		if(~rem1[n][x])return rem1[n][x];
	}
	int f[120][120]={0},dp[120]={0};
	REP(l,1,n)REP(r,l,n)
	{
		bitset<101> a=0;
		REP(k,l,r)if(all[k-1])a.set(k-l);
		f[l][r]=solve(r-l+1,a);
	}
	dp[0]=1;
	REP(i,1,n)
	{
		dp[i]=0;
		REP(j,0,i-1)
		{
			int res=0;
			DREP(k,i,j+1)
			{
				if(all[k-1])res=(ll)res*2%mod;
				res=(res+f[k][i])%mod;
			}
			dp[i]=(dp[i]+(ll)res*dp[j])%mod;
		}
	}
	int ans=dp[0];
	REP(j,1,n)ans=((ll)ans*(1+(all[j-1])) + dp[j] )%mod;
	if(n<=15)rem1[n][x]=ans;
	return ans;
//printf("%d\n",ans);
}

int main()
{
	init();
	memset(rem,-1,sizeof(rem));
	memset(rem1,-1,sizeof(rem1));
	printf("%d\n",work(n,S));
	return 0;
}


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

using namespace std;

const int INF = 1 << 29;
int N, A, B, C;
vector<int> L(8);

int f(int n, int a, int b, int c) {
  if (n == N) {
    if (min({a, b, c}) > 0)
      return abs(A - a) + abs(B - b) + abs(C - c) - 30;
    else
      return INF;
  }
  int c0 = f(n + 1, a, b, c);
  int c1 = f(n + 1, a + L[n], b, c) + 10;
  int c2 = f(n + 1, a, b + L[n], c) + 10;
  int c3 = f(n + 1, a, b, c + L[n]) + 10;
  return min({c0, c1, c2, c3});
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++)
    cin >> L[i];
  cout << f(0, 0, 0, 0) << '\n';
  return 0;
}


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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;


void solve(){
	int a,b,c;
    cin>>a>>b>>c;
    int f=0,s=0;
    if(a==5) f++;
    if(b==5) f++;
    if(c==5) f++;

    if(a==7) s++;
    if(b==7) s++;
    if(c==7) s++;
    
    if(f==2 && s==1) cout<<"YES\n";
    else cout<<"NO\n";
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
}
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/

Measured memory_bytes: 256
import math
n = int(input())
s = input().split()
t = int(s[0])
a = int(s[1])
s = input().split()
ans = 0
dis = float('inf')
for i in range(n):
	h = int(s[i])
	d = abs(a - t + 0.006 * h)
	if (d < dis):
		dis = d
		ans = i + 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] map = {1,3,1,2,1,2,1,1,2,1,2,1};
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(map[x-1] == map[y-1] ? "Yes": "No");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];

    double ans[4] = {0};
    rep(i, n) {
        ans[0] += abs(x[i] - y[i]);
        ans[1] += (x[i] - y[i]) * (x[i] - y[i]);
        ans[2] += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
        ans[3] = max(ans[3], (double)abs(x[i] - y[i]));
    }

    ans[1] = sqrt(ans[1]);
    ans[2] = pow(ans[2], 1 / 3.0);

    rep(i, 4) printf("%.7f\n", ans[i]);

    return 0;
}


Measured memory_bytes: 3344
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    vector<ll> c(n, 0);
    c[0] = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i - 1] < a[i]) {
            c[i] = a[i];
        }
    }
    for (int i = 0; i < n; i++) cerr << c[i] << " ";
    cerr << endl;
    if (c[n - 1] != 0 && c[n - 1] != b[n - 1]) {
        cout << 0 << endl;
        return 0;
    }
    else c[n - 1] = b[n - 1];
    for (int i = 0; i < n - 1; i++) {
        if (b[i] > b[i + 1]) {
            if (c[i] == 0) c[i] = b[i];
            else if (c[i] != b[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
        else {
            if (c[i] != 0 && c[i] > b[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n; i++) cerr << c[i] << " ";
    cerr << endl;

    ll ans = 1, mod = 1e9 + 7;
    for (int i = 0; i < n; i++) {
        if (c[i] == 0) ans = ans * min(a[i], b[i]) % mod;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
}

Measured memory_bytes: 256
#n=int(input())
h,w=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
v1=h//2
v2=w//2
if h==1 or w==1:
    ans=1
elif h%2==0:
    ans=v1*w
else:
    if w%2==0:
        ans=(v1+1)*v2+(v1)*v2
    else:
        t=v1+1
        ans=v2*(v1)+(v2+1)*(v1+1)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define M 1000000007
using namespace std;




int main()
{
	int t=1;
	//cin>>t;
	
	while(t--)
	{
		int n,m;
		cin>>n>>m;
		
		string grid [n];
		for(int i=0;i<n;i++)
		{
			cin>>grid[i];
		}
		
		int **dp=new int*[n];
		for(int i=0;i<n;i++)
		{
			dp[i]=new int[m];
		}
		
		for(int i=0;i<n;i++)
		{
			if(grid[i][0]=='#')
			{
				for(int j=i;j<n;j++)
				{
					dp[j][0]=0;
				}
				break;
			}else
			{
				dp[i][0]=1;
			}
		}
		
		for(int i=0;i<m;i++)
		{
			if(grid[0][i]=='#')
			{
				for(int j=i;j<m;j++)
				{
					dp[0][j]=0;
				}
				break;
			}else
			{
				dp[0][i]=1;
			}
		}
		
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<m;j++)
			{
				if(grid[i][j]=='#')
				{
					continue;
				}
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
			}
		}
		cout<<dp[n-1][m-1]%M<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 9436