akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

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

vector<int> distT(100000, 0);
vector<int> distA(100000, 0);
vector<int> H(100000, 0);
vector<int> G[100000];

void dfs(int v, int p, vector<int> &dist) {
  if (p == -1) dist[v] = 0;
  else dist[v] = dist[p] + 1;

  for (auto &u: G[v]) {
    if (u == p) continue;
    dfs(u, v, dist);
  }
}

template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ' ';  } return os;  }


int main() {
  int n, ts, as; cin >> n >> ts >> as;
  ts--;as--;
  distA.resize(n);
  distT.resize(n);
  H.resize(n);
  loop(i,0,n-1) {
    int a,b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(ts, -1, distT);
  dfs(as, -1, distA);
  int f_i = -1;
  int f_d = -1;
  loop(i,0,n) {
    if (distT[i] >= distA[i]) continue;
    if (f_d < distA[i]) {
      f_d = distA[i];
      f_i = i;
    }
  }
  cout << f_d-1 << endl;
  return 0;
}


Measured memory_bytes: 13660
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <math.h>
using namespace std;


int main() {
	int n,d;
	cin >> n >> d;
 	
 	int point[n][d];
	
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin >> point[i][j];
		}
	} 

	int ans = 0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			double sum = 0;
			for(int k=0;k<d;k++){
				sum += (point[i][k]-point[j][k])*(point[i][k]-point[j][k]);
			}
			sum = sqrt(sum);
			if(floor(sum) == sum) ans++;
		}
	}


    cout << ans << endl;
}

    



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,i;
    char op;    
    
    for(i=1;;i++){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?') break;
    if(op=='+') printf("%d\n",a+b);
    if(op=='-') printf("%d\n",a-b);
    if(op=='*') printf("%d\n",a*b);
    if(op=='/') printf("%d\n",a/b);
    
    }
    return 0;
}


Measured memory_bytes: 2096
n = int(input())
arr = list(map(int,input().split()))
tmp = [float('inf') for i in range(n)]

tmp[0] = 0
tmp[1] = abs(arr[0] - arr[1])
for j in range(2,n):
	tmp[j] = min(tmp[j],tmp[j-2]+abs(arr[j-2]-arr[j]))
	tmp[j] = min(tmp[j],tmp[j-1]+abs(arr[j-1]-arr[j]))
print(tmp[-1])





Measured memory_bytes: 13900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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


int main()
{
    IOS;
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    ll p[n+1];
    p[0]=0;
    for(int i=0;i<s.size()-1;i++)
    {
        p[i+1]=p[i];
        if(s[i]=='A'&&s[i+1]=='C') p[i+1]+=1;
    }
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<p[r-1]-p[l-1]<<endl;
    }
    

}

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



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

    int l = s.length();

    rep(i,l){
        if((i+1)%2==1) cout<<s[i];
    }
    cout<<endl;


    return 0;
}

Measured memory_bytes: 512
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var s2 = new string(s.Reverse().ToArray()).Replace('b','x').Replace('d','b').Replace('x','d').Replace('p', 'x').Replace('q', 'p').Replace('x', 'q');
        if (s == s2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
        Console.ReadLine();
    }

    public static long f(long n,long b)
    {
        if (n < b)
        {
            return n;
        }
        else
        {
            return f((long)Math.Floor((double)n/b),b) + n % b;
        }
    }

    public static string N(long n,long b)
    {
        var sb = new StringBuilder();
        while (true)
        {
            sb.Append((n % b).ToString());
            n /= b;
            if (n < b)
            {
                sb.Append(n.ToString());
                break;
            }
        }
        return new string( sb.ToString().Reverse().ToArray() );
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    public const int Mod1e9 = 1000000007;
    

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 16096
import sys
input=sys.stdin.readline

n=int(input())

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

ans=0
pointx.sort()
pointy.sort()
ans=pointx[-1]-pointx[0]
ans=max(ans,pointy[-1]-pointy[0])

print(ans)

Measured memory_bytes: 90488
N = int(input())
S = str(input())

abc =list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
rot = []
for s in S:
    for a in abc:
        if s == a:
            r = abc.index(a) + N
            if r >= 26:
                r = r - 26 
            rot.append(abc[r])
print("".join(rot))

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

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

const long long inf = 1e18;

int n, m, adj[15 + 5][15 + 5];
long long dp[(1 << 15) + 5][15 + 5];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w), --x, --y;
		adj[x][y] = adj[y][x] = w;
	}
//	for (int i = 0; i < n; ++i) {
//		for (int j = 0; j < n; ++j)
//			debug("%d ", adj[i][j]);
//		debug("\n");
//	}
	for (int i = 0; i < (1 << n); ++i)
		for (int j = 0; j < n; ++j)
			dp[i][j] = inf;
	for (int i = 1; i < (1 << n); i += 2)
		dp[i][0] = 0;
	for (int i = 1; i < (1 << n); i += 2)
		for (int j = i; j; (--j) &= i) {
			if (j & 1) continue;
			int t = i ^ j;
			long long tot = 0;
			for (int k = 0; k < n; ++k) {
				if (~t & 1 << k) continue;
				for (int p = 0; p < n; ++p)
					if (j & 1 << p) tot += adj[k][p];
			}
			for (int l = 0; l < n; ++l) {
				if (~t & 1 << l) continue;
				for (int k = 0; k < n; ++k)
					if (j & 1 << k && adj[l][k])
						dp[i][k] = min(dp[i][k], dp[t][l] + tot - adj[l][k]);
			}
		}
	printf("%lld\n", dp[(1 << n) - 1][n - 1]);
}

Measured memory_bytes: 5376
#include <stdio.h>
int main()
{
    char a,b,c,d;
  scanf("%c %c %c %c",&a,&b,&c,&d);
  if ((a==b&&b==c)) {
    printf("Yes\n");
  }else if ((b==c&&c==d)) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n,m;
  cin >> n >> m;
  int a= max(n,m);
  int b = min(n,m);
  string ans = "";
  rep(i,a){
    ans.push_back('0'+b);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)

const int INF = 1e8;
int vx[] = {1, 0, -1, 0};
int vy[] = {0, 1, 0, -1};

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    vector<vector<int>> dist(h, vector<int>(w, INF));
    rep(i, h) cin >> s[i];
    deque<pair<int, int>> q;
    q.push_back({ch, cw});
    dist[ch][cw] = 0;
    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop_front();
        auto is_out = [h, w](int a, int b) {
            if (a < 0 || h <= a) return true;
            if (b < 0 || w <= b) return true;
            return false;
        };
        for (int i = 0; i < 4; ++i) {
            int nx = x + vx[i];
            int ny = y + vy[i];
            if (is_out(nx, ny)) continue;
            if (s[nx][ny] == '#') continue;
            if (dist[nx][ny] <= dist[x][y]) continue;
            dist[nx][ny] = dist[x][y];
            q.push_front({nx, ny});
        }
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                if (i == 0 && j == 0) continue;
                int nx = x + i;
                int ny = y + j;
                if (is_out(nx, ny)) continue;
                if (s[nx][ny] == '#') continue;
                if (dist[nx][ny] <= dist[x][y] + 1) continue;
                dist[nx][ny] = dist[x][y] + 1;
                q.push_back({nx, ny});
            }
        }
    }
    if (dist[dh][dw] == INF) cout << -1 << endl;
    else cout << dist[dh][dw] << endl;
}

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

signed main(){
  int N;cin>>N;
  std::vector<int> h(N+1),dp(N+1);
  for(int i=1;i<=N;i++)cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<=N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int n,k,a[200010],b[200010];
bool check(){
	int flag=1;
	rep(i,1,n+1){
		if(a[i]!=n)
		return false;
	}
	return true;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>k;
    rep(i,1,n+1){
    	cin>>a[i];
	}
	while(k--){
		if(check()) break;
		memset(b,0,sizeof(b));
		rep(i,1,n+1){
			int l=max(1,i-a[i]),r=min(n,i+a[i]);
			b[l]++,b[r+1]--;
		}
		rep(i,1,n+1) a[i]=a[i-1]+b[i];
	}
	rep(i,1,n+1){
		cout<<a[i]<<" ";
	}
    return 0;
}



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

using namespace std;
const int N = 107;
#define inf 0x3f3f3f3f
int dis[N][N];
int main()
{
    int n;
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    while(cin >> n , n) {
        int v = 0, a, b, c;
        for(int i = 0;i < N;i ++) for(int j = 0;j < N;j ++)  dis[i][j] = (i == j) ? 0 : inf;
        for(int i = 1;i <= n;i ++) {
            cin >> a >> b >> c;
            dis[a][b] = dis[b][a] = c;
            v = max(max(v, a), b);
        }
        v ++;
        for(int k = 0;k < v;k ++) {
            for(int j = 0;j < v;j ++) {
                for(int i = 0;i < v;i ++) {
                    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
                }
            }
        }
        int ans1,ans2 = inf,x;
        for(int i = 0;i < v;i ++) {
            x = 0;
            for(int j = 0;j < v;j ++) {
                x += dis[i][j];
            }
            if(x < ans2) {
                ans1 = i, ans2 = x;
            }
        }
        cout << ans1 << " " << ans2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
using namespace std;
int main(void){

    int start_time, end_time, N, s[100]={}, f[100]={}, booking=0;
    cin >> start_time >> end_time >> N;
    for(int i=0; i<N; i++){
        cin >> s[i] >> f[i];
        if(end_time > s[i] && start_time < f[i]){
            booking = 1;
            break;
        }
    }
    if(booking == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

/*
　新しく予約を取るときに、どのように取れば既存の予約と
　かぶらないかを考える。
*/


Measured memory_bytes: 3116
h,w,k = [int(x) for x in input().split()]

mod = 10**9 + 7

def cpst(s, n):
    a = '0' * (n-len(s))
    return a + s

def makeb(n):
    l = []
    for i in range(2**n):
        tmp = bin(i)[2:]
        l.append(cpst(tmp, n))
    return l

tmp_bits = makeb(w-1)
bits = []
for x in tmp_bits:
    flag = True
    for i in range(w-2):
        if x[i] == '1' and x[i+1] == '1':
            flag = False
            break
    if flag:
        bits.append(x)

table = [[0,0,0] for _ in range(w)]

for x in bits:
    for i,y in enumerate(x):
        if y == '1':
            table[i][2] += 1
            table[i+1][0] += 1
        else:
            if i == 0:
                table[0][1] += 1
            else:
                if x[i-1] == '0':
                    table[i][1] += 1
            if i == w-2:
                table[w-1][1] += 1

dp = [[0 for _ in range(w)] for _ in range(h+1)]
dp[0][0] += 1

for i in range(h):
    for j in range(w):
        if j == 0:
            if w != 1:
                add = dp[i][j]*table[j][1] + dp[i][j+1]*table[j+1][0]
            else:
                add = dp[i][j]*table[j][1]
        elif j == w-1:
            add = dp[i][j]*table[j][1] + dp[i][j-1]*table[j-1][2]
        else:
            add = dp[i][j]*table[j][1] + dp[i][j-1]*table[j-1][2] + dp[i][j+1]*table[j+1][0]
        dp[i+1][j] = (dp[i+1][j] + add) % mod

print(dp[h][k-1])


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

using namespace std;

void imp() {
    cout << "Impossible" << endl;
    exit(0);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++cnt[a[i]];
    }


    sort(a.rbegin(), a.rend());

    int minvalue;
    int maxvalue;
    //build diametr
    maxvalue = a[0];
    minvalue = (maxvalue + 1) / 2;
    for (int i = maxvalue; i > minvalue; --i) {
        cnt[i] -= 2;
        if (cnt[i] < 0)
            imp();
    }

    if (maxvalue % 2 == 0)
        cnt[minvalue] -= 1;
    else
        cnt[minvalue] -= 2;

    if (cnt[minvalue] < 0)
        imp();

    // check other

    for (int i = 0; i < n; ++i) {
        if (a[i] <= minvalue && cnt[a[i]] > 0)
            imp();
    }

    cout << "Possible" << endl;


    return 0;
}


Measured memory_bytes: 384
import math
N, M, V, P = map(int, input().split())
A_ = list(map(int, input().split()))
A = sorted(A_)
temp = 0
requires = 0
for i in range(N-P):
  requires += A[N-P] - A[i]
for i in range(N):
  points = V - P - i
  if points < 0:
    points = 0
  requires -= A[N-P] - A[i]
  kabe = N - P - i
  if kabe == 0:
    temp = i
    break
  else:
    wall = points * M - requires
    if wall < 0:
      wall = 0
    wall_2 = math.ceil(wall / kabe)
    wall_3 = A[N-P] + wall_2
    i_points = A[i] + M
    if i_points >= wall_3:
      temp = i
      break
print(N - temp)

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

    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(to_string(i).size() % 2 != 0){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  ll n, k;
  cin>>n>>k;
  vector<ll> v;
  for(ll i=0; i<n; i++) {
    ll x;
    cin>>x;
    v.push_back(x);
  }
  ll left = 0;
  ll right = left + k-1;
  ll ans = abs(min(v[left], v[right]))+abs(v[left]-v[right]);
  for(; right<n; right++, left++) {
    ans = min(ans, abs(min(abs(v[left]), abs(v[right])))+abs(v[left]-v[right]));
  }
  std::cout << ans << std::endl;
  
  return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int P[8] = {0, 1, 2, 3, 5, 7, 8, 9};
  long long A;
  while (cin >> A, A) {
    long long q = 1, ans = 0;
    while (A != 0) {
      ans += q * P[A % 8];
      q *= 10;
      A /= 8;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mx 100005
ll dist[mx];
vector<int> adj[mx];
vector<int> cost[mx];
struct str
{
    int node;
    ll c;
    str(int a, ll b)
    {
        node = a;
        c = b;
    }
    bool operator<(const str &ob)const
    {
        return ob.c>c;
    }
};
priority_queue<str> pq;
void dij(int s)
{
    dist[s] = 0;
    pq.push(str(s,0));
    while(!pq.empty()){
        str ob = pq.top();
        pq.pop();
        for(int i=0; i<(int)adj[ob.node].size(); i++){
            int x = adj[ob.node][i];
            ll nd=0;
            nd = nd + ob.c + cost[ob.node][i];
            if(nd<dist[x]){
                dist[x] = nd;
                pq.push(str(x, nd));
            }
        }
    }
}
int main()
{
    memset(dist, 63, sizeof dist);
    int n,a,b,c,q,k;
    scanf("%d",&n);
    for(int i=1; i<n; i++){
        scanf("%d%d%d",&a,&b,&c);
        adj[a].pb(b);
        cost[a].pb(c);
        adj[b].pb(a);
        cost[b].pb(c);
    }
    scanf("%d%d",&q,&k);
    dij(k);
    while(q--){
        scanf("%d%d",&a,&b);
        ll ans = dist[a] + dist[b];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll MAX_N = ll(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  for (int i = 0; i < N ; i++)
    cin >> h.at(i);
  
  sort(h.begin(),h.end());
  
  int mini = -1;
  for (int i = 0 ; i < N - K + 1 ; i++){
    
    if (mini < 0){
      mini = h.at(i + K-1) - h.at(i);
    }
    
    else if ( mini > h.at(i + K-1) - h.at(i)){
      mini = h.at(i + K-1) - h.at(i);
    }
    
  }
  
  cout << mini << endl;
    
}

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

int main() {
	string S;
	cin >> S;
	smatch smatch;

	if(regex_search(S, smatch, regex("^A{0,1}KIHA{0,1}BA{0,1}RA{0,1}$"))) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

using namespace std;

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

  vector<char> ans(s.size() / 2 + (s.size() % 2 != 0));
  for (int i = 0; i < s.size(); i += 2) {
    ans[i / 2] = s[i];
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = n %10;
    int a[6] = {2,4,5,7,9};
    int b[5] = {0,1,6,8};
    int c = 3;
    int flag = 0;
    if(ans == 3){
        cout << "bon\n";
        flag = 1;
    }
    if(!flag){
        for(int i = 0; i < 5; i++){
            if(ans == a[i]){
                cout << "hon\n";
                flag = 1;
                break;
            }
        }
    }
    if(!flag){
        for(int i = 0; i < 4; i++){
            if(ans == b[i]){
                cout << "pon\n";
                break;
            }
        }
    }
    return 0;
}
 
 

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
int main(){
    char str1[200];
    char key[100];
    char str2[200];
    scanf("%s%s",str1,key);
    
    strcpy(str2,str1);
    strcat(str1,str2);
    
    if(strstr(str1,key)==NULL)
        printf("No\n");
    else
        printf("Yes\n");
    
}



Measured memory_bytes: 2084
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x1 = Integer.parseInt(sc.next());
        int y1 = Integer.parseInt(sc.next());
        int x2 = Integer.parseInt(sc.next());
        int y2 = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int x3 = x2 - (y2 - y1);
        int y3 = y2 + (x2 - x1);
        int x4 = x1 - (y2 - y1);
        int y4 = y1 + (x2 - x1);
        String result = x3 + " " + y3 + " " + x4 + " " + y4;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた!

# 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン
# 愚直にやると2^Nを調べねばならず無理。
# したがって「一部を調べればよい」に帰着するのが多いだろう。
# 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。

# 今回は全体集合から1つずつ取り去るのを考えるとできる。
# 全体集合である競技m0が最多の人数p0人を集めたとする。
# すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。
# ここで「m0を含む集合」について一気に計算できていることに注意! 一撃で多数の集合について計算が終わる。
# 次に全体集合からm0を取り去ったものを考える。
# ここである競技m1が最多の人数p1人を集めたとする。すると……以下同様。
# なお複数種目の競技が同率1位になった場合は全て一度に取り除いて良い。
# これで空集合までやって、最大が最小のものを出力すればOK! 

n, m = list(map(int, input().split()))
preference = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)] # 1-index → 0-index

ans = n
held_sports = set(range(m))

while held_sports:
    # 各競技に参加する人数を求める
    parti = [0] * m
    for person in range(n):
        for s in range(m):
            if preference[person][s] in held_sports:
                parti[preference[person][s]] += 1
                break
    
    temp = max(parti)
    ans = min(ans, temp)
    # 集合から最大人数を取った要素を除外
    for idx, par in enumerate(parti):
        if par == temp:
            held_sports.remove(idx)

print(ans)

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

int main(){
	int n,a,sum=0;
	cin >> n;
	vector<int> x(n+1);
	for(int i = 1 ; i <= n ; i += 1){
		cin >> x[i];
	}
	for(int i = 1 ; i <= n ; i += 1){
		if(x[i] == i){
			continue;
		}
		sum += 1;
		if(x[x[i]] != i){
			cout << "NO";
			return 0;
		}
		swap(x[i],x[x[i]]);
	}
	if(sum <= 1){
		cout << "YES";
	}else{
		cout << "NO";
	}
}

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

int main(){
    stack<int> S;
    int a, b;
    string s;

    while ( cin >> s ){
        if ( s[0] == '+' ){
            a=S.top(); S.pop();
            b=S.top(); S.pop();
            S.push(a+b);
        }else if ( s[0] == '-'){
            a=S.top(); S.pop();
            b=S.top(); S.pop();
            S.push(b-a);
        }else if ( s[0] == '*'){
            a=S.top(); S.pop();
            b=S.top(); S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }

    }

    cout << S.top() << endl;
    return 0;
}


Measured memory_bytes: 3172
i;k;t;main(n){
            int c[501],f[500],s[500];
            for(scanf("%d",&n);k<n-1;k++)scanf("%d%d%d",&c[k],&s[k],&f[k]);
            
            for(;i<n-1;i++){
                t=0;
                for(int j=i;j<n-1;j++){
                    if(t>s[j]){
                       t=s[j]+c[j]+ceil( (double)(t-s[j])/f[j] )*f[j];
                    }else{
                         t=s[j]+c[j];
                    }
                }
                printf("%d\n",t);
            }
            printf("0");
        }

Measured memory_bytes: 1696
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

bool comp(const pair<int, pair<string, int>>& p1, const pair<int, pair<string, int>>& p2){
    if(p1.second.first != p2.second.first){
        return p1.second.first < p2.second.first;
    }else{
        return p1.second > p2.second;
    }
}

void solve(){
    int n, p;
    string s;
    vector<pair<int, pair<string, int>>> v;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s >> p;
        v.push_back({i+1, {s, p}});
    }
    sort(v.begin(), v.end(), comp);
    for(auto i = v.begin(); i != v.end(); i++){
//        cout << (*i).second.first << ", " << (*i).second.second << endl;
        cout << (*i).first << endl;
    }
}

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

m = {}

for v in L:
    if m.get(v) == None:
        m[v] = 0
    m[v] += 1

if len(m) % 2 == 0:
    print(len(m) - 1)
else:
    print(len(m))

Measured memory_bytes: 18336
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
typedef long double ld;

//typedef acos(-1) PI;

#define PI acos(-1)

int main(){
	int n;
	cin>>n;
	ld ans=2*PI*n;
	printf("%.9Lf\n",ans);
	//cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3768
import math

a,b,x = map(int,input().split())

h1 = b - x/a/a
h2 = 2*x/(a*b)


if x == a*a*b:
    print(0)
elif b*a*a/2 <= x:
    radians = math.atan(a/2/h1)
    print(90 - math.degrees(radians))
else:
    radians = math.atan(h2/b)
    print(90 - math.degrees(radians))


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

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

    int table[13] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096};



    int all[N];
    int x[13];
    for(int i=0; i<13; i++)
        x[i] = 0;



    for(int i=0; i<N; i++)
        cin>>all[i];

    for(int i=0; i<N; i++)
    {
        x[all[i]]+=1;
    }


    bool check=true;
    for(int i=0; i<13; i++)
    {
        if(x[i]>2)
            check = false;

    }

    int ans = 0;
    if(check)
    {
        vector<int> test;

        for(int i=0; i< 8192; i++)
        {
            test.clear();
            for(int j=0; j<13; j++)
            {
                if( ((i-i%table[j])/table[j])%2==1 && x[j]==1)
                    test.push_back(j);
                else if( ((i-i%table[j])/table[j])%2 ==0 && x[j]==1)
                    test.push_back((24-j));
                else if(x[j]==2)
                {
                    test.push_back(j);
                    test.push_back((24-j));
                }

            }
            test.push_back(0);
            test.push_back(24);
            sort(test.begin(),test.end());
            int temp = 24;
            for(int j=0; j<test.size()-1; j++)
                temp = min(temp,test[j+1]-test[j]);


        ans = max(ans,temp);
        }
        cout<<ans<<endl;
    }


    else
        cout<<0<<endl;




    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

n = int(input())

to_battle_with = [deque([i - 1 for i in map(int, input().split())]) for _ in range(n)]


def update_battle(player, battle_set, to_battle_with):
    if not to_battle_with[player]:
        return
    next_opponent = to_battle_with[player][0]
    if not to_battle_with[next_opponent]:
        return
    if to_battle_with[next_opponent][0] == player:
        if player > next_opponent:
            player, next_opponent = next_opponent, player
        battle_set.add((player, next_opponent))


battles_today = set()
for player in range(n):
    update_battle(player, battles_today, to_battle_with)

day_count = 0
battle_count = 0
num_all_battles = (n * (n - 1)) // 2

while battles_today:
    battles_tomorrow = set()
    for p1, p2 in battles_today:
        battle_count += 1
        to_battle_with[p1].popleft()
        to_battle_with[p2].popleft()
        for p in [p1, p2]:
            update_battle(p, battles_tomorrow, to_battle_with)
    battles_today = battles_tomorrow
    day_count += 1

if battle_count == num_all_battles:
    print(day_count)
else:
    print(-1)


Measured memory_bytes: 38052
/* 162-C.cpp
 *     Created on : Apr 12, 2020 
 *     Time       : 6:08:49 PM
 *     Author     : null_ptr
 */
#include<bits/stdc++.h>

using namespace std;

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

	long long sum=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			for(int k=1;k<=n;++k)
				sum+=__gcd(__gcd(i,j),k);

	cout<<sum;
}





Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(T: "List[int]", A: "List[int]", B: "List[int]"):
    dif1 = T[0]*(A[0] - B[0])
    dif2 = T[1]*(A[1] - B[1])

    if dif1+dif2 == 0:
        print('infinity')
        return
    
    if dif1*dif2>0 or abs(dif1)>abs(dif2):
        print(0)
        return
    
    ## tが抜かれる方
    t = abs(dif1)
    a = abs(dif2)

    if t%abs(t-a)==0:
        print(2*(t//abs(t-a)))
    else:
        print(2*(t//abs(t-a))+1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    A = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(2)]  # type: "List[int]"
    solve(T, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

static const int N = 1000;

void print(int a[], int n){
	int k;
	for(k=0;k<n;k++){
		if(k>0) printf(" ");
		printf("%d", a[k]);
	}
	printf("\n");
}

int main(void){
	int n, i, j,key;
	int a[N+1];
	scanf("%d", &n);
	//input
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	print(a,n);

	//insertion 
	for(i=1; i<n; i++){
		key = a[i];
		j = i-1;
		while(j>=0 && a[j] > key){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		print(a, n);
	}

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define endl "\n"


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  ll n = s.size();
  for(int i=0;i<n-1;i++){
    if(s[i] == s[i+1]){
      cout << i+1 << " " << i+2 <<endl;
      return 0;
    }
  }
  for(int i=0;i<n-2;i++){
  	if(s[i] == s[i+2]){
    	cout << i+1 << " " << i+3 <<endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  

  return 0;
}



Measured memory_bytes: 3792
mod = 10**9 + 7


n = int(input())
s1 = input(); s2 = input()

s = ""
i = 0
while i < n:
    if s1[i] == s2[i]:
        s += "A"
        i += 1
    else:
        s += "B"
        i += 2

answer = 3 if s[0] == "A" else 6
for i in range(len(s) - 1):
    if s[i] + s[i + 1] == "AA":
        answer *= 2
    elif s[i] + s[i + 1] == "AB":
        answer *= 2
    elif s[i] + s[i + 1] == "BA":
        answer *= 1
    else:
        answer *= 3
    answer %= mod

print(answer)


Measured memory_bytes: 3064
function main()
  
  N = parse(Int, readline())
  A = map(x -> parse(Int, x), split(readline()))
  
  dict = Dict()
  
  for i in 1:N
    dict[A[i]] = get(dict, A[i], 0) + 1
  end
  
  ans_dict = Dict()
  
  for i in keys(dict)
    n = dict[i]
    ans_dict[i] = div(n * (n-1), 2)
  end
  
  ans = sum(values(ans_dict))
  
  for i in 1:N
    n = dict[A[i]]
    println(ans - (n-1))
  end
  
end

main()

Measured memory_bytes: 226296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for(int i = A; i < B+1; i++){
    string s;
    s = to_string(i);
    int s_n = s.size();
    int s_char = s.size()-1;
    int x = s_n/2-1;
    while(x  >= 0){
      char s1 = s.at(x);
      char s2 = s.at(s_char - x );
      if(s1 != s2){
        break;
      }
      if(x == 0){
        ans++;
        break;
      }
      x = x-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int i, j, k, l, m, X, N, M, flag;
	char S1[53], S2[53];
	cin >> N;
	cin >> S1 >> S2;
	k = l = 0;
	i = 0;
	flag = 0;
	long long int ans = 1;
	if (S1[0] == S2[0]) {//初期条件
		ans *= 3;
		i ++;
		flag = 0;//直前のドミノが縦に1個並んでいるときの場合
		while (i < N ) {
			if (S1[i] == S2[i]) {//次のドミノが縦に１個並んでいる時
				i += 1;
				if (flag == 0)
					ans *= 2;
				else
					ans *= 1;
				if (ans > 1000000007)
					ans %= 1000000007;
				flag = 0;
				
			}
			else {//次のドミノが横に2個並んでいるとき
				i += 2;
				if (flag == 0) {//もし直前のドミノが縦に並んでいれば
					ans *= 2;
				}
				else
					ans *= 3;
				if (ans> 1000000007)
					ans %= 1000000007;
				flag = 1;//この場合はドミノが横に二個並んでいる場合
			}

		}
		cout << ans << endl;
	}
	else {//一番最初が横に二個並んでいるとき
		ans *= 6;
		i +=2;
		flag = 1;
		while (i < N) {
			if (S1[i] == S2[i]) {//次のドミノが縦に１個並んでいる時
				i += 1;
				if (flag == 0)
					ans *= 2;
				else
					ans *= 1;
				if (ans > 1000000007)
					ans %= 1000000007;
				flag = 0;

			}
			else {//次のドミノが横に2個並んでいるとき
				i += 2;
				if (flag == 0) {//もし直前のドミノが縦に並んでいれば
					ans *= 2;
				}
				else
					ans *= 3;
				if (ans> 1000000007)
					ans %= 1000000007;
				flag = 1;//この場合はドミノが横に二個並んでいる場合
			}

		}
		cout << ans << endl;
	}


	return 0;
}





Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
check = 0
tmpmax = 0

for i in range(N):
    tmpmax = max(tmpmax, H[i])
    if tmpmax - 1 <= H[i]:
        pass
    else:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
l = input().split()

w = int(l[0])
h = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if 0 <= x-r and x+r <= w and 0 <= y-r and y+r <= h:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5596
#include <iostream>
using namespace std;
#define LL long long

#include <algorithm>
#include <vector>
void _150() {
    LL n;
    cin >> n;

    // int p[8];
    // int q[8];
    int temp;
    vector<int> p, q;
    vector<int> perm_base;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        p.push_back(temp);
        perm_base.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        q.push_back(temp);
    }

    LL a, b, index;
    a = -1;
    b = -1;
    index = 0;
    do {
        if (perm_base == p) {
            a = index;
        }

        if (perm_base == q) {
            b = index;
        }

        if (a != -1 && b != -1) {
            break;
        }

        index++;
    } while (next_permutation(perm_base.begin(), perm_base.end()));

    cout << abs(a - b) << endl;
}

#include <string>
void _151() {
    int n, m;
    cin >> n >> m;
    int p[100000] = {0};
    int correct[100000] = {0};
    int penalty_counts[100000] = {0};
    string temp;
    int correct_count = 0;
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> temp;
        if (temp == "AC") {
            if (correct[p[i] - 1] != 1) {
                correct_count++;
                correct[p[i] - 1] = 1;
            }
        } else {
            if (correct[p[i] - 1] != 1) {
                penalty_counts[p[i] - 1]++;
            }
        }
    }
    int penalty_count = 0;
    for (int i = 0; i < n; ++i) {
        if (correct[i] == 1) {
            penalty_count += penalty_counts[i];
        }
    }
    cout << correct_count << " " << penalty_count << endl;
}

// #include <math.h>
void _152() { 
    int n;
    cin >> n;
    int temp;
    vector<int> p;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        p.push_back(temp);
    }
    // for (int i = 0; i < p.size(); ++i)
    //     cout << p[i];
    // cout << endl;

    int count_ = 0;
    vector<int> q(p.size());
    vector<int>::iterator itr;
    for (int i = 1; i < n; i++) {
        q.clear();
        // cout << "ls" << endl;
        copy(p.begin(), p.begin() + i, q.begin());
        // cout << "copy" << endl;
        sort(q.begin(), q.begin() + i);
        // cout << "sort" << endl;
        if (q[0] >= p[i]) {
            count_++;
            // cout << p[i] << " " << i << " " << q[0] << " " << q[1] << endl;
            // cout << "increment" << endl;
        }
        // cout << "le" << endl;
    }
    cout << count_ + 1 << endl;


    // cout << count_ << endl;
}

#include <limits>
void _152_() { 
    int n;
    cin >> n;
    int temp;
    vector<int> p;
    int min_val = numeric_limits<int>::max();
    int count = 0;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        if (min_val >= temp) {
            min_val = temp;
            count++;
        }
    }
    cout << count << endl;
}

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



Measured memory_bytes: 256
/*If you don't know where you are going, any road will take you there.*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
struct border{
  int r1,c1,r2,c2,x,y;
};
const int mx=555;
const int oo=1e8;
char s[mx][mx];
int m1[mx][mx],m2[mx][mx],m3[mx][mx];
int col[mx][mx];
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%s",s[i]);
    for(int j=0;j<m;j++)if(s[i][j]=='#')m3[i][j]=1;
  }
  border b1={0,0,n-1,m-1,0,0};
  int color=0;
  while(true){
    color^=1;
    int ur=oo,uc=oo,br=-oo,bc=-oo;
    pair<int,int>pt(oo,oo);
    for(int r=b1.r1+1;r<b1.r2;r++){
      for(int c=b1.c1+1;c<b1.c2;c++){
        if(s[r][c]=='#'){
          ur=min(ur,r),uc=min(uc,c);
          br=max(br,r),bc=max(bc,c);
          pt=min(pt,make_pair(r,c));
        }
      }
    }
    //    cout<<"ur="<<ur<<endl;
    if(ur==oo){
      for(int i=b1.r1;i<=b1.r2;i++)
        for(int j=b1.c1;j<=b1.c2;j++)
          col[i][j]=color;
      break;
    }
    border b2={ur,uc,br,bc,pt.first,pt.second};
    for(int r=b1.r1;r<=b1.r2;r++)
      for(int c=b1.c1;c<=b1.c2;c++)
        if(r<b2.r1 || r>b2.r2 || c<b2.c1 || c>b2.c2)
          col[r][c]=color;


    int minr=min(b1.x,b2.x),maxr=max(b1.x,b2.x);
    int minc=min(b1.y,b2.y),maxc=max(b1.y,b2.y);
    for(int i=minr;i<=maxr;i++)col[i][b1.y]=color^1;
    for(int j=minc;j<=maxc;j++)col[b2.x][j]=color^1;

    b1=b2;
//    cout<<"new!"<<endl;for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<col[i][j];cout<<endl;}cout<<"---"<<endl;
  }
  for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(col[i][j]==0 || s[i][j]=='#')m1[i][j]=1;
  for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(col[i][j]==1 || s[i][j]=='#')m2[i][j]=1;
//  for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(m3[i][j]!=(m1[i][j]&m2[i][j]))cout<<"wrong:("<<endl;

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(m1[i][j]==1)putchar('#');
      else putchar('.');
    }
    puts("");
  }
  puts("");
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(m2[i][j]==1)putchar('#');
      else putchar('.');
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "E:\CP\Debugger\debugger.h"
#else 
#define debug(x...)
#endif
#define int long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TC int tc; cin>>tc; for(int cn=1; cn<=tc; ++cn) 
const int MX = 1e6+5;
#define pii pair<int, int>

vector<int> nth_prime;
bitset<MX> visited; 
void optimized_prime(){
    nth_prime.push_back(2);
    for(int i=3; i<MX; i+=2){
            if(visited[i]) 
                continue;
            nth_prime.push_back(i);
            if(1ll*i*i > MX) 
                continue;
            for(int j = i*i; j< MX; j+= i+i)
                visited[j] = true;
    }
}
signed main(){
    optimized_prime();
    int n; cin>>n;
    for(int i=0; i<nth_prime.size(); ++i){
        if(nth_prime[i] >= n){
            cout<<nth_prime[i]<<"\n";
            return 0;
        }
    }
}

Measured memory_bytes: 4284
N = int(input())
if N % 10 == 3:
  print('bon')
elif N % 10 == 0:
  print('pon')
elif N % 10 == 1:
  print('pon') 
elif N % 10 == 6:
  print('pon')
elif N % 10 == 8:
  print('pon')  
else:
  print('hon')
 

Measured memory_bytes: 9156
#include<stdio.h>

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

    int i;
    int H[N+1];
    for(i=1;i<=N;i++){
        scanf("%d",&H[i]);
    }
    H[0]=0;

    for(i=N;i>1;i--){
        if(H[i]==H[i-1]-1){
            H[i-1]--;
        }else if(H[i]<H[i-1]-1){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean aF = false;
        boolean bF = false;
        boolean cF = false;
        char[] s = sc.next().toCharArray();
        for (int i = 0; i < 3; i++) {
            if (s[i] == 'a')
                aF = true;
            else if (s[i] == 'b')
                bF = true;
            else if (s[i] == 'c')
                cF = true;

        }
        if (aF && bF && cF) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");

    }
}


Measured memory_bytes: 84052
import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if n == 1:
    print(1)
elif np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))

Measured memory_bytes: 51512
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    LL I,O,T,J,L,S,Z;cin >> I >> O >> T >> J >>L >> S >>Z;
    LL ans = O+(I/2)*2+L/2*2+J/2*2;
    if(!(I&&J&&L)){
        cout<<ans<<endl;
        return 0;
    }
    L--,I--,J--;
    ans = max(ans, 3+O+(I/2)*2+J/2*2+L/2*2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int dp[n];
  dp[0]=0;
  if(n>1) dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++) {dp[i]=INT_MAX;
  for(int j=max(0,i-k);j<i;j++) dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));}
  cout<<dp[n-1]<<endl;
}

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

int main()
{ int a,b,x,n;
while(~scanf("%d",&n))
{
    if(n==1)
        printf("Hello World\n");
    else
    if(n==2)
    {
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);

    }

}
    return 0;
}


Measured memory_bytes: 128