akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#define mp make_pair
#define INF 1e+9
using namespace std;

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

typedef pair<int,int> PP;
typedef pair<int,PP> P;

int main(){
	int n,m;
	while(cin >> m >> n,m){
		int sx,sy,d[100][100];
		string field[100];
		for(int i = 0;i < n;i++){
			cin >> field[i];
			for(int j = 0;j < m;j++){
				if(field[i][j] == '&'){
					sx = i;
					sy = j;
					d[i][j] = 0;
					field[i][j] = '.';
				}else d[i][j] = INF;
			}
		}
		priority_queue<P,vector<P>,greater<P> > que;
		que.push(mp(0,mp(sx,sy)));
		while(!que.empty()){
			P p = que.top();que.pop();
			int cost = p.first,x = p.second.first,y = p.second.second;
			if(d[x][y] < cost) continue;
			for(int i = 0;i < 4;i++){
				int nx = x + dx[i],ny = y + dy[i],next = d[x][y];
				if(nx >= 0 && nx < n && ny >= 0 && ny < m){
					if(field[nx][ny] == '.' && field[x][y] == '#') next++;
					if(d[nx][ny] > next){
						d[nx][ny] = next;
						que.push(mp(next,mp(nx,ny)));
					}
				}
			}
		}
		int mi = INF;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(!i || !j || i == n - 1 || j == m - 1) {
					if(field[i][j] == '#') d[i][j]++;
					mi = min(mi,d[i][j]);
				}
			}
		}
		cout << mi << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if c-b<=0{"delicious"}else if c-b<=a{"safe"}else{"dangerous"})
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
const int INF = 1e9;
// const LL INF = 1e17;

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    vector<int> v(D);
    iota(all(v), 1);

    int ans = INF;
    do{
        int now = 0, score = 0;
        for(auto i : v){
            if(score + i*100*p[i-1] + c[i-1] <= G){
                now += p[i-1];
                score += i*100*p[i-1] + c[i-1];
            }else{
                int less = G-score;
                if(less == 0) break;
                now += min(p[i-1], (less-1)/(i*100) + 1);
                break;
            }
        }
        ans = min(ans, now);
    }while(next_permutation(all(v)));
    cout << ans << endl;

}

Measured memory_bytes: 384
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
Y,Z=0,0
V,W=0,0
T,U=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  Y,Z=-1,-10**20
  V,W=Y,Z
  T,U=V,W
  for j in range(26):
    if Y==-1:
      Y,Z=0,X[0]+S[i][0]
    if Z<X[j]+S[i][j]:
      T,U=V,W
      V,W=Y,Z
      Y,Z=j,X[j]+S[i][j]
    elif W<X[j]+S[i][j]:
      T,U=V,W
      V,W=j,X[j]+S[i][j]
    elif T<X[j]+S[i][j]:
      T,U=j,X[j]+S[i][j]
  XX[Y]-=X[Y]
  X[Y]=0
  P.append([Y,V,T])
  if randrange(0,50)==0:
    P[i][1]=randrange(0,26)
  if randrange(0,5)==0:
    P[i][2]=randrange(0,26)
  P[i]=tuple(P[i])
SCORE=0
X=[0]*26
for i in range(D):
  SCORE+=S[i][P[i][0]]
  for j in range(26):
    X[j]+=C[j]
  X[P[i][0]]=0
  SCORE-=sum(X)
SCORE2=0
YY=[]
for i in range(D):
  for k in range(2):
    d,q=i,P[i][k+1]
    SCORE2=SCORE
    YY=XX[:]
    SCORE2-=S[d][P[d][0]]
    SCORE2+=S[d][q]
    for j in range(26):
      X[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      X[P[d][0]]+=C[P[d][0]]
      X[q]+=C[q]
      X[Z]=0
      YY[P[d][0]]+=X[P[d][0]]
      YY[q]+=X[q]
    if SCORE2-sum(YY)>SCORE-sum(XX):
      z=[P[i][k+1]]
      for l in range(3):
        if l!=k:
          z.append(P[i][l])
      P[i]=tuple(z)
      XX=YY[:]
      SCORE=SCORE2
for i in range(D):
  print(P[i][0]+1)


Measured memory_bytes: 85116
<?php
while(1){
    fscanf(STDIN,"%d %d %d\n",$n,$m,$p);
    if($n==0 && $m==0 && $p==0)
        break;

    $sum=0;
    for($i=0;$i<$n;$i++){
        fscanf(STDIN,"%d\n",$x[$i]);
        $sum+=$x[$i];
    }
    if($x[$m-1]==0)
        echo "0\n";
    else
        echo floor(($sum*100*(100-$p)*0.01)/$x[$m-1])."\n";
}
?>

Measured memory_bytes: 6632
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	if(N == M){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MOD 1000000007
void clear(int i);
void plus_i(char s);
void plus(int i);
void times10();

int ans[0][13]={};
int main(){
  char s[100010];
  scanf("%s",s);
  int i,len=strlen(s);
  ans[1][0]=1;
  for(i=0;i<len;i++){
    clear(0);
    plus_i(s[i]);
    if(df){
      int k;
      printf("[ ");
      for(k=0;k<13;k++){
	printf("%d ",ans[0][k]);
      }
      printf("]\n");
    }
    clear(1);
    times10();
    if(df){
      int k;
      printf("[ ");
      for(k=0;k<13;k++){
	printf("%d ",ans[1][k]);
      }
      printf("]\n");
    }
  }

  printf("%d",ans[0][5]);
  return 0;
}
void clear(int i){
  int k;
  for(k=0;k<13;k++)
    ans[i][k]=0;
}


void plus_i(char s){
  if(s=='?'){
    int i;
    for(i=0;i<10;i++){
      plus(i);
    }

  }
  else{
    int i=s-'0';
    plus(i);
  }
}

void plus(int i){
  int a;
  for(a=0;a<13;a++){
    ans[0][(a+i)%13]+=ans[1][a];
    ans[0][(a+i)%13]%=MOD;
  }
}

void times10(){
  int k;
  for(k=0;k<13;k++){
    ans[1][10*k%13]=ans[0][k]%MOD;
  }
}


/// confirm df==0 ///


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

struct qq{
  int cnt,f;
  char c;
  qq(int a,int b,char x):cnt(a),f(b),c(x){
  }
};
void solve(){
  string s;
  cin>>s;
  int q;
  cin>>q;
  vector<qq>v;
  string fr="",bc="";
  int cnt=0;
  rep(i,q){
    int query;
    cin>>query;
    if(query==1){
      ++cnt;
    }
    else{
      int f;
      char c;
      cin>>f>>c;
      f--;
      v.eb(cnt,f,c);
    }
  }
  if(cnt%2)reverse(all(s));
  rep(i,v.size()){
    if((cnt-v[i].cnt)%2==1)v[i].f^=1;
    if(v[i].f==0)fr+=v[i].c;
    else bc+=v[i].c;
  }
  reverse(all(fr));
  cout<<fr+s+bc;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
#define MaxLen 100003

int N;
long long f, g;
const int Mod = 1e9 + 7;
char a[MaxLen];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline void ChkMax(int &aa, int bb) {
	if(aa < bb) aa = bb;
	return;
}
inline void ChkMin(int &aa, int bb) {
	if(aa > bb) aa = bb;
	return;
}

int main() {
	register int i, j, k;
	scanf("%s", a + 1), N = strlen(a + 1);
	f = 1;
	for(i = 1; i <= N; ++i) {
		if(a[i] == '1')
			g = (g * 3 + f) % Mod, f = f * 2 % Mod;
		else
			g = g * 3 %  Mod;
	}
	cout << (f + g) % Mod << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

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


// 68 11 55 - rank 3
// 69 12 19

int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    int f = 0, o = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        f += (a % 4) == 0;
        o += a % 2;
    }
    if (f >= o || (f + o == n && o == f + 1)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }



}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int h; cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,ans=0,i=2,j;
	char s[201];
	scanf("%s", s);
	n=strlen(s);
	while(ans==0)
	{
		for(j=0; j<(n-i)/2; j++)
		{
			if(s[j]!=s[j+(n-i)/2])
			break;
			if(j==(n-i)/2-1)
			ans=n-i;
		}
		i+=2;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 

int32_t main()
{
    fast;
    int l,r;cin>>l>>r;
    if((r-l+1)>=2019)
    {
        cout<<0;
        return 0;
    }

    int ans=1e18;
    for(int i=l;i<=r;i++)
    {
        for(int j=i+1;j<=r;j++)
            ans=min(ans,(i*j)%2019);
    }

    cout<<ans;

}

Measured memory_bytes: 256
dir = ["U", "R", "D", "L"]
wall = [[0,0,0,0,0]]
9.times do |i|
  if i % 2 == 0
    wall << ("0" + gets.chomp + "0").split(//).map(&:to_i)
  else
    wall << gets.chomp.split(//).map(&:to_i)
  end
end
wall << [0,0,0,0,0]
route = []
position = Array.new(6){|i|Array.new(6)}
t, y = 0, 0
position[t][y] = 1
while t != 0 or y != 0 or route.size == 0
  if position[t][y] % 2 == 0
    if wall[2 * t + position[t][y] - 1][y] == 0
      position[t + position[t][y] - 1][y] = (position[t][y] + 1) % 4
      t += position[t][y] - 1
    else
      position[t][y] = (position[t][y] - 1) % 4
      route << dir[position[t][y]]
    end
  else
    if wall[2 * t][y + (3 - position[t][y]) / 2 - 1] == 0
      position[t][y - position[t][y] + 2] = (position[t][y] + 1) % 4
      y -= position[t][y] - 2
    else
      position[t][y] = (position[t][y] - 1) % 4
      route << dir[position[t][y]]
    end
  end
end
puts route.join

Measured memory_bytes: 6132
h,w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]
r = [c[x][1] for x in range(10)] + [0]
done = [0]*10
done[1] = 1
ans = 0
while not all(done):
  mm = 10**5
  cur = -1
  for i in range(10):
    if not done[i] and r[i]<mm:
      mm = r[i]
      cur =  i
  done[cur] = 1
  for x in range(10):
    if r[x] > c[x][cur] + r[cur]:
      r[x] = c[x][cur] + r[cur]
for x in a:
  for y in x:
    ans += r[y]
print(ans)

Measured memory_bytes: 3444
N = int(input())

num8 = 0
for i in range(1,N+1,2):
    dividend = i
    divisor = 2
    count = 0
    while dividend != 1 and divisor <= (i//2):
        if dividend % divisor == 0:
            dividend = dividend // divisor
            count += 1

        divisor += 1
    
    if count == 3:
        num8 += 1

print(num8)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [usize; n]
    };

    if av.iter().any(|&a| a % 2 == 1) {
        println!("0");
        return;
    }
    let res = av
        .into_iter()
        .map(|a| {
            let mut n = a;
            let mut c = 0;
            while n % 2 == 0 {
                c += 1;
                n /= 2;
            }
            c
        })
        .min()
        .unwrap();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2240
#include <iostream>

int main() {
    int S, h, m, s;
    std::cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 60);
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    int i, t, n;
    scanf("%d", &n);

    int *sub = (int*)calloc(n, sizeof(int));
    for(i = 0; i < n-1; ++i) {
        scanf("%d", &t);
        sub[t-1]++;
    }
    for(i = 0; i < n; ++i) {
        printf("%d\n", sub[i]);
    }
    return 0;
}


Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int a,b;
    cin >> a>>b;
    string s;
    cin >> s;
    bool flag=true;
    for(int i=0;i<s.size();i++){
        if((0<=i&&i<a) || (a+1<=i&&i<a+b+1)){
            if('0'>s[i]||s[i]>'9') flag=false; 
        }
        if(i==a){
            if(s[i]!='-') flag=false;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No" <<endl;
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B; cin >> A >> B;
    int ans = max(A+B, A-B);
    ans = max(ans, A*B);
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
mi = min(a)
ma = max(a)

dis = 10 ** 9
for idx in range(mi, ma+1):
  tmp_dis = 0
  for e in a:
    tmp_dis += (e - idx) ** 2
  dis = min(dis, tmp_dis)
print(dis)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val args = readLine()!!.split(" ")
    val takahashiMonsterHitPoint = args[0].toInt()
    val takahashiMonsterPower = args[1].toInt()
    val aokiMonsterHitPoint = args[2].toInt()
    val aokiMonsterPower = args[3].toInt()

    val aokiAttackTimes = computeAttackTimes(takahashiMonsterHitPoint, aokiMonsterPower)
    val takahashiAttackTimes = computeAttackTimes(aokiMonsterHitPoint, takahashiMonsterPower)

    if (takahashiAttackTimes <= aokiAttackTimes) println("Yes") else println("No")
}

fun computeAttackTimes(hitPoint: Int, power: Int): Int {
    var attackTimes = hitPoint / power
    if ((hitPoint % power) > 0) {
        attackTimes++
    }

    return attackTimes
}

Measured memory_bytes: 35576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n); cin>>a;
	int cnt=0;
	rep(i,n){if(a[i]!=i+1)cnt++;}
	if(cnt==0 or cnt==2)puta("YES"); else puta("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int H, N;
  cin >> H >> N;
  vector <int> A(N);
  rep(i,N) cin >> A.at(i);

  int sum = accumulate(A.begin(), A.end(), 0);
  if (sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

int main(){
  int k, x;
  cin >> k >> x;
  for(i, x-k+1, x+k) cout << i << endl;
}

Measured memory_bytes: 256
using System;

class sample6{
    static void Main(string[] args){

            string[] str_number = Console.ReadLine().Split(' ');
            int[] sort_number = new int[3];

            for(int i = 0 ; i < 3 ; i++ ){
                
                sort_number[i] = int.Parse(str_number[i]);
                
                if(sort_number[i] < 1 ||sort_number[i] > 10000 ){
                    
                    Console.WriteLine("数字が測定範囲外です。");
                    Environment.Exit(0);
                }
                
                
            }
                Array.Sort(sort_number);
                Console.WriteLine("{0} {1} {2}", sort_number[0], sort_number[1], sort_number[2]);
    }
}


Measured memory_bytes: 15972
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    target = LI()

    ans = 0
    sums = [0] * N
    sum_all = target[0]
    sums[0] = target[0]
    for i in range(1, N):
        sum_all += target[i] % MOD
        sums[i] = sums[i-1] + target[i]

    for i in range(N):
        ans += target[i] * (sum_all - sums[i])
        ans = ans % MOD

    print(ans)


main()


Measured memory_bytes: 104580
N = gets.to_i

s = N.times.map{|_| gets.chomp}

group = s.group_by{|i| i.split("").sort.join}

ans = 0
group.each do |k, v|
  len = v.length
  ans += len * (len - 1) / 2 if len > 1
end
p ans

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-c)<=d)||(abs(b-c)<=d&&abs(a-b)<=d)) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
module ABC133

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT32) :: num_traveler
    integer(INT32) :: cost_train
    integer(INT32) :: cost_taxi

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) num_traveler, cost_train, cost_taxi

    ! STEP.02
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)') min(num_traveler * cost_train, cost_taxi)

    ! STEP.END
    return

  end subroutine task_A

end module ABC133

program main

  ! <module>s to import
  use, non_intrinsic :: ABC133

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if(s[i] == 'R') a[i]=0;
    if(s[i] == 'G') a[i]=1;
    if(s[i] == 'B') a[i]=2;
  }
  vector<int> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans=1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j){
    int k = j + (j-i);
    if(k < n){
      if(s[i] == s[j]) continue;
      if(s[i] == s[k]) continue;
      if(s[k] == s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int64_t res = 1;
  vector<int> X(N + 1, 0);
  for (int i = 2; i < N + 1; i++) {
    for (int j = i; j < N + 1; j += i) {
      X[j]++;
    }
    res += static_cast<int64_t>(i) * (X[i] + 1);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 42268
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  int n,m;
  while(cin>>n>>m,n||m){
    int f,g;
    cin>>f>>g;
    f--;
    g--;
    int a[30][30],b[30][30];
    memset(a,-1,sizeof(a));
    for(i=0;i<m;i++){
      int p,q,r,s;
      cin>>p>>q>>r>>s;
      p--;
      q--;
      a[p][q]=a[q][p]=r;
      b[p][q]=b[q][p]=s;
    }
    int c[31][30][30];
    memset(c,-1,sizeof(c));
    priority_queue<pair<pair<double,int>,pair<int,int> >,vector<pair<pair<double,int>,pair<int,int> > >,greater<pair<pair<double,int>,pair<int,int> > > > d;
    for(i=0;i<n;i++){
      if(a[f][i]!=-1)
	d.push(make_pair(make_pair(a[f][i],1),make_pair(f,i)));
    }
    while(d.empty()==0){
      double p;
      int q,r,s;
      p=d.top().first.first;
      q=d.top().first.second;
      r=d.top().second.first;
      s=d.top().second.second;
      if(q==1&&s==g)
	break;
      d.pop();
      if(c[q][r][s]){
	c[q][r][s]=0;
	for(i=0;i<n;i++){
	  if(i!=r&&a[s][i]!=-1){
	    for(j=-1;j<=1;j++){
	      if(1<=q+j&&q+j<=b[s][i]&&c[q+j][s][i]) 
		d.push(make_pair(make_pair(p+(double)a[s][i]/(q+j),q+j),make_pair(s,i)));
	    }
	  }
	}
      }
    }
    if(d.empty())
      cout<<"unreachable"<<endl;
    else
      cout<<d.top().first.first<<endl;
  }
  return 0;
}

Measured memory_bytes: 7824
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use maplit::hashmap;
use proconio::marker::*;
use proconio::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: String,
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let s: String = s;
    let c = s.chars().collect_vec();

    let mut table = vec![hashmap! {'R'=> 0, 'G'=> 0, 'B'=> 0}; n];
    let mut ans = 0u64;
    for i in 0..n {
        if i != 0 {
            table[i] = table[i - 1].clone();
        }
        *table[i].entry(c[i]).or_default() += 1;
    }
    //println!("{:?}", table);
    for i in 0..n - 2 {
        for j in i + 1..n - 1 {
            if c[i] == c[j] {
                continue;
            }
            //println!("{}{}", i, j);
            let cc = "RGB"
                .replace(c[i], "")
                .replace(c[j], "")
                .chars()
                .next()
                .unwrap();
            let ex = j + j - i;
            ans += if ex > n - 1 {
                table[n - 1][&cc] - table[j][&cc]
            } else {
                table[n - 1][&cc] - table[j][&cc] - (table[ex][&cc] - table[ex - 1][&cc])
            };
        }
    }

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


Measured memory_bytes: 2532
n = int(input())
l0 = 2
l1 = 1
for i in range(3, n+2):
    if i%2 == 1:
        l0 = l0 + l1
    else:
        l1 = l0 + l1
print(l1) if n%2 == 1 else print(l0)


Measured memory_bytes: 2940
<?php
    while(true){
        list($n, $x) = explode(" ", trim(fgets(STDIN)));
        if($n + $x == 0) exit;
        
        $count = 0;
        for($i = 1; $i <= $n - 2; $i++) {
            for($j = $i + 1; $j <= $n - 1; $j++) {
                for($k = $j + 1; $k <= $n; $k++) {
                    if($i + $j + $k == $x){
                        $count++;
                    }
                }
            }
        }
        
        echo $count."\n";
    }

Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n; int ar[n]; for(int i=0;i<n;i++) cin>>ar[i];   
  
  sort(ar,ar+n);
  long long cnt(0);
  
  if(n%2==0)
  for(int i=0; i<n; i++){
  if(i%2==0) cnt-=ar[i];
  else cnt+=ar[i]; }
  
  else if(n%2==1)
  for(int i=0;i<n;i++){
  if(i%2==0) cnt+=ar[i];
  else cnt-=ar[i];
   }
  
  cout<<cnt;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void count(int map[400][400]){
	int x,y;
	int fg=400;
	for(int i=400-1;i>=0;i--){
		for(int j=0;j<400;j++){
			if(fg==400 && map[j][i]==1){
				fg=i;
				i=-1;
				break;
			}
		}
	}
	x=fg;
	fg=-1;
	for(int i=0;i<400;i++){
		for(int j=0;j<400;j++){
			if(fg==-1 && map[j][i]==1){
				fg=i;
				i=400;
				break;
			}
		}
	}
	x-=fg;

	fg=400;
	for(int i=400-1;i>=0;i--){
		for(int j=0;j<400;j++){
			if(fg==400 && map[i][j]==1){
				fg=i;
				i=-1;
				break;
			}
		}
	}
	y=fg;
	fg=-1;
	for(int i=0;i<400;i++){
		for(int j=0;j<400;j++){
			if(fg==-1 && map[i][j]==1){
				fg=i;
				i=400;
				break;
			}
		}
	}
	y-=fg;

	cout << y+1 <<" ";
	cout << x+1 << endl;

}

int main(void){
	int n;
	int map[400][400];
	int pos[200][2];
	int np,dp;
		//left0 riht2 under1 top3

	while(1){
		cin >> n;
		if(n==0) return 0;
		for(int i=0;i<200;i++){
			pos[i][0]=-20;
			pos[i][1]=-20;
		}
		for(int i=0;i<400;i++){
			for(int j=0;j<400;j++) map[i][j]=0;
		}
		pos[0][0]=200;
		pos[0][1]=200;
		map[pos[0][1]][pos[0][0]]=1;

		for(int i=1;i<n;i++){
			cin >> np;
			cin >> dp;
			switch(dp){
				case 0://left
					pos[i][0]=pos[np][0]-1;
					pos[i][1]=pos[np][1];
					break;
				case 1://under
					pos[i][0]=pos[np][0];
					pos[i][1]=pos[np][1]+1;
					break;
				case 2://riht
					pos[i][0]=pos[np][0]+1;
					pos[i][1]=pos[np][1];
					break;
				case 3: // top
					pos[i][0]=pos[np][0];
					pos[i][1]=pos[np][1]-1;
					break;
			}
			map[pos[i][0]][pos[i][1]]=1;
		}
		count(map);
	}

	return 0;
}

Measured memory_bytes: 1784
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
using oppo = set<int>;

int main() {
	// read two dices
	int d1[6],d2[6];
	for (int i = 0;i < 6;++i) cin >> d1[i];
	for (int i = 0;i < 6;++i) cin >> d2[i];
	oppo o105 {d1[0],d1[5]},o114 {d1[1],d1[4]},o123 {d1[2],d1[3]};
	oppo o205 {d2[0],d2[5]},o214 {d2[1],d2[4]},o223 {d2[2],d2[3]};
	set<oppo> s1 {o105,o114,o123};
	set<oppo> s2 {o205,o214,o223};
	bool same = false; // default to not the same
	if (s1 == s2) {
		if (o105 == o205 || o105 == o214) {
			while (!(d1[0] == d2[0] && d1[5] == d2[5])) {
				// roll dice 2 in direction of north
				int temp = d2[0];
				d2[0] = d2[1];
				d2[1] = d2[5];
				d2[5] = d2[4];
				d2[4] = temp;
			}
		} else if (o105 == o223) {
			while (!(d1[0] == d2[0] && d1[5] == d2[5])) {
				// roll dice 2 in direction of east
				int temp = d2[0];
				d2[0] = d2[3];
				d2[3] = d2[5];
				d2[5] = d2[2];
				d2[2] = temp;
			}
		}
		while (!(d1[1] == d2[1] && d1[4] == d2[4])) {
			// rotate dice 2
			int temp = d2[1];
			d2[1] = d2[2];
			d2[2] = d2[4];
			d2[4] = d2[3];
			d2[3] = temp;
		}
		if (d1[2] == d2[2]) {
			same = true;
		} else if (d1[0] == d1[5] && d1[2] == d2[3]) {
			same = true;
		}
	} 
	cout << (same ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3112
/*
 * MatrixMultiplication.cpp
 *
 *  Created on: 2014/08/03
 *      Author: WanWan1985
 */
#include <iostream>
#include <vector>
using namespace std;

// for util
#define FOR(i, a, b) 	for(int i = (a); i < (b); i++)
#define REP(i, n)		FOR(i, 0, n)
#define PB				push_back
#define MP				make_pair

typedef long long ll;

template<class T>
class C_Matrix {
private:
	vector<vector<T> > m_val;
public:
	C_Matrix(T n, T m) {
		vector<T> vecZeros;
		REP(i, m) vecZeros.PB(0);
		REP(i, n) m_val.PB(vecZeros);
	}

	T GetRow() const {
		return m_val.size();
	}

	T GetCol() const {
		return m_val.at(0).size();
	}

	C_Matrix operator* (const C_Matrix a_Matrix) {
		const T n = this->GetRow();
		const T l = this->GetCol();
		const T m = a_Matrix.GetCol();
		C_Matrix RetMatrix(n, m);
		REP(i, n)REP(j, m)REP(k, l)
				RetMatrix.m_val[i][j] += this->m_val[i][k] * a_Matrix.m_val[k][j];
		return RetMatrix;
	}

	void SetMatrixElement(const vector<vector<T> > a_val) {
		m_val = a_val;
	}

	vector<vector<T> > GetMatrixElement() {
		return m_val;
	}

};

int main(void) {
	ll n, m, l;
	cin >> n >> m >> l;

	vector<vector<ll> > vecMatrix1;
	vector<ll> InputVal1;
	REP(i, n) {
		REP(j, m) {
			ll a = 0;
			cin >> a;
			InputVal1.PB(a);
		}
		vecMatrix1.PB(InputVal1);
		InputVal1.clear();
	}
	C_Matrix<ll> Matrix1(n, m);
	Matrix1.SetMatrixElement(vecMatrix1);

	vector<vector<ll> > vecMatrix2;
	vector<ll> InputVal2;
	REP(i, m) {
		REP(j, l) {
			ll b = 0;
			cin >> b;
			InputVal2.PB(b);
		}
		vecMatrix2.PB(InputVal2);
		InputVal2.clear();
	}
	C_Matrix<ll> Matrix2(m, l);
	Matrix2.SetMatrixElement(vecMatrix2);

	C_Matrix<ll> RetMatrix = Matrix1 * Matrix2;
	vector<vector<ll> > MatrixVal = RetMatrix.GetMatrixElement();

	REP(i, RetMatrix.GetRow()) {
		vector<ll> tmp = MatrixVal.at(i);
		REP(j, RetMatrix.GetCol()) {
			cout << tmp.at(j);
			if (j != RetMatrix.GetCol() - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1736
/*One touch and i IGNITE*/
#include<bits/stdc++.h>
using namespace std;
#define cloud_007 ios_base::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define F first
#define S second
#define endl "\n"
#define Endl "\n"

ll a, b, c, d;

int main()
{
#ifdef cloud007
    //freopen ( "in.txt", "r", stdin );
#endif // cloud007
    cloud_007;
    cin >> a>> b >> c>> d;
    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>
 
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
 
int main()
{
    int h,w;
    cin >> h >> w;
    vector<string> array(h);
    for (int i = 0; i < h; i++)
    {
        cin >> array[i];
    }
    /*for (int i = 0; i < h; i++)
    {
        cout << array[i] << endl;
    }*/
    int** temp;
    temp = new int*[h];
     for (int i = 0; i < h; i++)
     {
         temp[i] = new int[w];
     }
     int index =0;
     int counter = 0;
     int j = 0;
    for (int i = 0; i < h; i++)
    {
        index = 0;
        counter = 0;
        for (int j = 0; j < w; j++)
        {
            if (array[i][j]=='.')
            {
                counter++;
                if(j==w-1)
                {
                    for (int k = index; k < j+1; k++)
                    {
                        temp[i][k] = counter;
                    }
                }
            }else
            {
                temp[i][j] = -1;
                for (int k = index; k < j; k++)
                {
                    temp[i][k] = counter;
                }
                index = j+1;
                counter = 0;
            }
        }
        
    }
    for (int i = 0; i < w; i++)
    {
        index = 0;
        counter = 0;
        for (int j = 0; j < h; j++)
        {
            if (array[j][i]=='.')
            {
                counter++;
                if(j==h-1)
                {
                    for (int k = index; k < j+1; k++)
                    {
                        temp[k][i] += counter;
                    }
                }
            }else
            {
                temp[j][i] = -1;
                for (int k = index; k < j; k++)
                {
                    temp[k][i] += counter;
                }
                index = j+1;
                counter = 0;
            }
        }
        
    }

    

    /*for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << temp[i][j] << " ";
        }
        cout << endl;
    }*/

    int ans = -100;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(temp[i][j]>ans)ans=temp[i][j];
        }
    }
    cout << ans-1 <<endl;
}


Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

/********************Template********************/

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

	string s;
	int cnt = 0;
	cin >> s;
	REP(i, 6){
		if(s[i] == '1') cnt++;
	}
	cout << cnt << endl;
	rtn 0;
}

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

using namespace std;

bool isPali (string input) {
    for (int i = 0; i < input.size() / 2; i++) {
        if (input[i] != input[input.size() - 1 - i]) return false;
    }
    return true;
}
int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (isPali(s) && isPali(s.substr((n + 3) / 2 - 1)) &&
    isPali(s.substr(0, (n - 1) / 2))) {
        cout << "Yes";
    } else cout << "No";
    return 0;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
wa = Array.new(n,0)
ans = []
n.downto(1) do |i|
  sum = 0
  j = 1
  while i * j <= n
    sum += wa[i*j-1]
    j += 1
  end
  if a[i-1] != sum % 2
    ans.push(i)
    wa[i-1] += 1
  end
end
puts ans.length
ans.reverse.each do |x|
  print "#{x} "
end


Measured memory_bytes: 22588
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int n, h, w;
    int count = 0;
    int a[1000];
    int b[1000];

    cin >> n >> h >> w;

    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    for(int i = 0; i < n; i++){
        if(a[i] >= h && b[i] >= w){
            count++;
        }
    }

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

Measured memory_bytes: 256
function Main(input) {
  // 入力
  input = input.split('\n');
	tmp = input[0].split(' ');
	var n = parseInt(tmp[0], 10);
  var h = parseInt(tmp[1], 10);
  var w = parseInt(tmp[2], 10);
  var count = 0;

  // 計算
  for (var i = 1; i <= n; i++) {
    var num = input[i].split(' ');
    var a = parseInt(num[0], 10);
    var b = parseInt(num[1], 10);
    if (a >= h && b>= w) {
      count++;
    }
  }
  
	//出力
	console.log('%d', count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21952
#include <iostream>
#include <cstdio>
#include <string>
#include <math.h>
using namespace std;
int main() {
	long N;
	long sum=0;
	long count=0;
	string result="";
	
	cin >> N;
	long *a = new long[N];
	long *b = new long[N];
	
	for(size_t m = 0; m < N; m++){
	    cin >> a[m];
	}
	for(size_t m = 0; m < N; m++){
	    cin >> b[m];
	}
	
	for(size_t m = 0; m < N; m++){
	   // sum+=b[m]-a[m];
	    if(a[m]-b[m]>0){
	        sum+=a[m]-b[m];
	    }else{
	        count+=(b[m]-a[m])/2;
	    }
	}
	

	if(count<sum){
	    result="No";
	}else{
	    result="Yes";
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

typedef long long ll;

const int MAX_N = 200000;

int main() {
	int n;
	int r[MAX_N];

	scanf("%d", &n);

	REP(i, n) {
		scanf("%d", &r[i]);
	}
	
	int maxv = -2000000000;
	int minv = r[0];

	FOR(i, 1, n) {
		maxv = max(r[i] - minv, maxv);
		minv = min(r[i], minv);
	}

	printf("%d\n", maxv);
}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (a.at(i - 1) == 1000)continue;
		else if (a.at(i - 1) == a.at(i)) {
			a.at(i) = 1000;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def q3():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    min_p = P[0]
    for i in range(N):
        if P[i] <= min_p:
            min_p = P[i]
            ans += 1
    print(ans)


if __name__ == '__main__':
    q3()


Measured memory_bytes: 25768
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};


int main(){
  ll n,a,b,c,d;
  cin>>n;
  a = n%10;
  n /= 10;
  b = n%10;
  n /= 10;
  c = n%10;
  n /= 10;
  d = n%10;
  if(a==b&&b==c){
    cout<<"Yes"<<endl;
  }else if(b==c&&c==d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){

	int a,b;
	cin >> a >> b;

	if(a == b) cout << "a == b"<< "\n";
	else if(a < b) cout  << "a < b" << "\n";
	else if(a > b) cout  << "a > b" << "\n";

	return 0;
}




Measured memory_bytes: 3036
def isqrt(n):
	L = 0
	R = n
	while R-L > 2:
		M = (L+R)//2
		if M*M==n:
			return M
		elif M*M < n:
			L = M
		else:
			R = M 
	for ans in range(R,L-1,-1):
		if ans*ans <= n:
			return ans
	assert(False)
	return -1
def count(n,A,B):
	ans = 0

	limit = isqrt(n)
	# x = A + 1
	# while True:
	# 	if x*x <= n:
	# 		if n//x < B:
	# 			ans += 1
	# 		x += 1
	# 	else:
	# 		return ans + min(n//x,B-1)
	return max(0,limit-A) + min(n//(limit+1),B-1)
for _ in range(int(input())):
	A, B = map(int,input().split())
	print(count(A*B-1,A,B)+count(A*B-1,B,A))

Measured memory_bytes: 9196
let n=Int(readLine()!)!
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
var pp=readInts()
let ppw=pp.sorted()
var count=0
for i in 0...n-1{
  if pp[i] != ppw[i]{
    count+=1
  }
}
if count==2 || count==0{
  print("YES")
}else{
  print("NO")
}
  



Measured memory_bytes: 8344
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,c;
  cin>>n;
  int max=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>max){
      max=a;
      c=a+b;
    }
  }
  cout<<c;
}


Measured memory_bytes: 3588
from collections import defaultdict
import bisect

s = input()
t = input()

n = len(s)
m = len(t)

d = defaultdict(list)

for i,c in enumerate(s):
    if c in t:
        d[c].append(i)

for i,c in enumerate(s):
    if c in t:
        d[c].append(i+n)

pos = -1
ans = 0

for c in t:
    l = d[c]
    if l:
        ind = bisect.bisect_right(l, pos)
        ans += l[ind]-pos
        if l[ind] >= n:
            pos = l[ind] - n
        else:
            pos = l[ind]    
    else:
        ans = -1
        break

print(ans)




Measured memory_bytes: 12148
import sys
def f0070(A,n,s):
  if n==1:
    if s in A:f=1
    else:f=0
    return f
  c=0
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  N=range(n)
  def f(A):
    return sum([(i+1)*A[i] for i in N])
  if f(A1)<=s<=f(A2):
    for i in range(len(A)):
      b=s-A[i]*n
      c+=f0070(A[:i]+A[i+1:],n-1,b)
  return c

for a in sys.stdin:
  n,s=map(int,a.split())
  print f0070(range(10),n,s)

Measured memory_bytes: 4252
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  string s;cin>>s;
  int k;cin>>k;
  k=min(100,k);
  rep(i,k){
    if(s[i]!='1') {cout<<s[i];return 0;}
  }
  cout<<'1';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long D;
  cin >> N >> D;

  int count = 0;
  
  for (int i = 0; i < N; i++) {
  	long long x = 0;
    long long y = 0;
    
    cin >> x >> y;
    
    long long point = (x * x) + (y * y);
    long double s = sqrt(point);
    
    if (D >= s) {
    	count++;
    }
    
  }

    cout << count << endl;
    
  }

Measured memory_bytes: 3672
n,x,y=map(int, input().split())
ans=[0]*n

for i in range(1,n):
	for j in range(i+1,n+1):
		a = min(j-i, abs(x-i)+1+abs(y-j))
		ans[a-1] += 1
		
for i in range(n-1):
	print(ans[i])

Measured memory_bytes: 3444
a, b, c = input(), input(), input()
ref = a[0]
a = a[1:]
if len(a) == 0:
    print("A")
    exit()
for _ in range(len(a)+len(b)+len(c)):
    if ref == "a":
        if len(a) == 0:
            print("A")
            exit()
        ref = a[0]
        a = a[1:]

    elif ref == "b":
        if len(b) == 0:
            print("B")
            exit()
        ref = b[0]
        b = b[1:]
        
    else:
        if len(c) == 0:
            print("C")
            exit()
        ref = c[0]
        c = c[1:]

Measured memory_bytes: 9160
s = list(input())

l = len(s)
max = 1000

for i in range(l-2):
    a = s[i:i+3]
    b = ''.join(a)
    c = int(b)
    d = 753 - c
    if d < 0:
        d = -d
    if d < max:
        max = d

print(max)

Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
h, w = map(int, input().split())

# 縦か横がどちらかの値が1の場合、角はどこにも行けないので常に１
if h == 1 or w == 1:
    print(1)
    exit()

# 総マス数が偶数になる場合、半数が答え
total = h * w
if total % 2 == 0:
    print(int(total / 2))
    exit()

# 問題は奇数の場合
# 高さが奇数の場合、奇数列はh//2+1 偶数列はh//2
odd_column = (h//2 + 1) * (w//2 + 1)
even_column = (h//2) * (w//2)
res = odd_column + even_column

print(int(res))



Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    lli m = s.length(), n = t.length(); 
    lli lcs[m + 1][n + 1];
    for(lli i = 0; i <= m; i++)
    {
        for(lli j = 0; j <= n; j++)
        {
            if(i == 0 || j == 0)
                lcs[i][j] = 0;
            else if(s[i - 1] == t[j - 1])
                lcs[i][j] = 1 + lcs[i - 1][j - 1];
            else
                lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
        }
    }
    string l;
    lli i = m, j = n, index = lcs[m][n];
    while(i > 0 && j > 0)
    {
        if(s[i - 1] == t[j - 1])
        {
            l = s[i - 1] + l;
            i--;
            j--;
        }
        else if(lcs[i - 1][j] > lcs[i][j - 1])
            i--;
        else
            j--;
    }
    cout << l;
    
    return 0;
}

Measured memory_bytes: 70656