akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mkpr make_pair
#define ft first
#define sd second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>
inline void read(T &x) {
    x=0; int f=0; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') f=1; if(ch==EOF) return; ch=getchar();}
    while(isdigit(ch)) {x=x*10+(ch-'0'); ch=getchar();} if(f) x=-x;
}

/***********************************************************/

LL price[5], n;
LL ans;

int main() {
    for(int i=1;i<=8;i<<=1) {
        scanf("%lld", &price[i]);
    }
    scanf("%lld", &n);
    n*=4ll;
    while(n) {
        int mid=1;
        double mn=price[1];
        for(int i=2;i<=8 && i<=n;i<<=1) {
            if(mn>(double)price[i]/i) {
                mn=(double)price[i]/i;
                mid=i;
            }
        }
        ans+=1ll*(n/mid)*price[mid];
        n%=mid;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

keys = [True] * N

l1 = 1
r1 = N

for i in range(M):
    l, r = map(int, input().split())
    if (l1 < l):
        l1 = l
    if (r < r1):
        r1 = r

if (r1 - l1 + 1 > 0):
    print(r1 - l1 + 1)
else:
    print(0)


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define M 1000000007
#define pb push_back

ll dp[105][100005]; 


int main()
{
    ll n,k; cin>>n>>k; vc<ll> v1(n); input(v1);
    
    rep(i,0,v1[0]) dp[0][i]=1; 
    
    rep(i,1,n-1)
    {
        vc<ll> v2(k+1); v2[0]=dp[i-1][0];
        rep(j,1,k) v2[j]=(v2[j-1] + dp[i-1][j])%M;
        rep(j,0,k)
        {
            if(j-v1[i] > 0)
            { ll a1=(v2[j]%M - v2[j-v1[i]-1]%M)%M; if(a1>=0) dp[i][j]=a1; else dp[i][j]=a1+M; }
            else 
            dp[i][j]=v2[j];
        }
    }
    
    cout<<dp[n-1][k];
    
}

Measured memory_bytes: 82372
#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() {
  ll L, R;
  cin >> L >> R;

  int L_mod = L % 2019;
  int R_mod = R % 2019;


  if((R - L) >= 2019) cout << 0 << endl;
  else{
    if(R_mod > L_mod){
      int N = R_mod - L_mod;
      int min = 200000;
      rep(i, N){
        for(int j = i+1; j < N+1; j++){
          ll W = (L_mod + i) * (L_mod + j);
          int min2 = W % 2019;
          if (min2 < min) min = min2;
        }
      }
      cout << min << endl;
    }
    else  cout << 0 << endl;
  }

}


Measured memory_bytes: 256
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable(crn, data)
  tc, xc, yc = crn
  tn, xn, yn = data
  d = (xn-xc).abs+(yn-yc).abs
  t = tn-tc
  return false if d>t
  (d-t).even?
end

crn = [0, 0, 0]
data.each do |d|
  unless is_reachable(crn, d)
    puts 'No'
    exit 0
  end
  crn = d
end

puts 'Yes'

Measured memory_bytes: 9468
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a[i])

ct1=0
if a[0]<=0:
  ct1+=1-a[0]
  a[0]=1
x=a[0]
for i in range(1,n):
  y=x+a[i]
  if i%2==1:
    if y>=0:
      ct1+=y+1
      a[i]=-x-1
  else:
    if y<=0:
      ct1+=1-y
      a[i]=-x+1
  x+=a[i]

ct2=0
if b[0]>=0:
  ct2+=b[0]+1
  b[0]=-1
x=b[0]
for i in range(1,n):
  y=x+b[i]
  if i%2==0:
    if y>=0:
      ct2+=y+1
      b[i]=-x-1
  else:
    if y<=0:
      ct2+=1-y
      b[i]=-x+1
  x+=b[i]

print(min(ct1,ct2))

Measured memory_bytes: 14332
N = int(input())
x, y = map(int, input().split())
A = [x + y, x + y, y - x, y - x]
for i in range(N - 1):
  x, y = map(int, input().split())
  p = x + y
  q = y - x
  A[0] = max(A[0], p)
  A[1] = min(A[1], p)
  A[2] = max(A[2], q)
  A[3] = min(A[3], q)
print(max(A[0] - A[1], A[2] - A[3]))

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

int main (){
	int i,o,x,y;
	double a,b,p;
	while ( cin >> a >> b){		
		p = a / b;
		i = a / b;
		x = a;
		y = b;
		o = x % y;
		printf ("%d %d %f\n",i,o,p);
	}
	return 0;
}


Measured memory_bytes: 3300
n=int(input())
a=n*3//4+3
for i in range(max(n//4,1),a):
    for j in range(a-3,3501):
        k=4*i*j-n*(i+j)
        if k==0:
            continue
        x,y=divmod(n*i*j,4*i*j-n*(i+j))
        if y==0 and x>0:
            print(i,j,x)
            exit()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
    int c[4];
    for(int i=0;i<4;i++)c[i] = 0;
    int n;cin >> n;
    for(int i=0;i<n;i++){
        string s; cin >> s;
        if(s == "AC")c[0]++;
        if(s == "WA")c[1]++;
        if(s == "TLE")c[2]++;
        if(s == "RE")c[3]++;
    }
    printf("AC x %d\n",c[0]);
    printf("WA x %d\n",c[1]);
    printf("TLE x %d\n",c[2]);
    printf("RE x %d\n",c[3]);
    return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 310
using namespace std;
int dp[MAXN][MAXN][MAXN];
char s[MAXN];
int t,n;
int main(){
    SF("%s",s);
    SF("%d",&t);
    n=strlen(s);
    for(int i=0;i<n;i++)
        dp[i][i][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j+i<n;j++)
            for(int k=0;k<=t;k++){
                int l=j,r=j+i;
                if(s[l]==s[r])
                    dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k]+2);
                else{
                    if(k!=0)
                        dp[l][r][k]=max(dp[l+1][r-1][k-1]+2,dp[l][r][k]);
                    dp[l][r][k]=max(dp[l+1][r][k],dp[l][r][k]);
                    dp[l][r][k]=max(dp[l][r-1][k],dp[l][r][k]);
                }
            }
    int ans=0;
    for(int i=0;i<=t;i++)
        ans=max(ans,dp[0][n-1][i]);
    PF("%d",ans);
}


Measured memory_bytes: 112768
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int[] card = new int[n];
			for(int i = 0;i < n;i++){
				card[i] = scan.nextInt();
			}
			for(int i = 1;i < n;i++){
				for(int k = 0;k < n;k++){
					System.out.print(card[k] + ((k==n-1)?"\n":" "));
				}
				int key = card[i];
				int j = i - 1;
				while(j >= 0 && card[j] > key){
					card[j+1] = card[j];
					j -= 1;
				}
				card[j+1] = key;
			}
			for(int k = 0;k < n;k++){
				System.out.print(card[k] + ((k==n-1)?"\n":" "));
			}
		}
	}
}

Measured memory_bytes: 24276
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	//変数の宣言
	int n;
	int a[100010];
	long long int min,max;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	//データの読み込み
	scanf("%d",&n);
	
	for(i=n-1;i>=0;i--){
		scanf("%d",&a[i]);
	}
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	min=2;
	max=2;
	
	for(i=0;i<n;i++){
		if((min+a[i]-1)/a[i]>max/a[i]){
			printf("-1");
			return 0;
		}
		min=((min+a[i]-1)/a[i])*a[i];
		max=(max/a[i])*a[i]+a[i]-1;
//		printf("min=%lld,max=%lld\n",min,max);
	}
	
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%lld %lld",min,max);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1005;

struct E{
    int m, l, k;
} e[N];

int del[N], cnt[N], T, n;
bool check(int u){
    memset(cnt, 0, sizeof(cnt));
    memset(del, 0, sizeof(del));
    cnt[0] = u;
    int t, i;
    for(t = 0; t <= T; ++t) if(cnt[t]){
        for(i=1;i<=n;++i) if(!del[i] && t%(e[i].l+e[i].k)<=e[i].l){
            if(t+e[i].m > T) return 0;
            cnt[t+e[i].m]++;
            del[i] = 1;
            cnt[t]--;
            if(!cnt[t]) break;
        }
        cnt[t+1] += cnt[t];
    }
    for(i=1;i<=n;++i) if(!del[i]) return 0;
    return 1;
}

int main(){
    int i;
    while(scanf("%d%d",&n,&T)&&(n+T)){
        for(i=1;i<=n;++i)
            scanf("%d%d%d",&e[i].m, &e[i].l, &e[i].k);
        //int l = 1, r = n;
        for(i=1;i<=n;++i) if(check(i)) break;
        printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 1044
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc =  new Scanner(System.in);

        int i ,j ,k ,count;

        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            count = 0;

            if(n == 0 && x == 0)break;

            for(i = 1;i <= n;i++){
                for(j = i + 1;j <= n;j++){
                    for(k = j + 1;k <= n;k++){
                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }

            System.out.printf("%d\n",count);

        }
    }
}


Measured memory_bytes: 27004
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    map<string, int> yoko;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
        auto s = S[i];
        sort(s.begin(), s.end());
        yoko[s]++;
    }
    map<string, int> tate;
    for (int i = 0; i < W; i++) {
        string s;
        for (int j = 0; j < H; j++) {
            s.push_back(S[j][i]);
        }
        sort(s.begin(), s.end());
        tate[s]++;
    }
    int todd = 0;
    for (const auto& t : tate) {
        if (t.second % 2 == 1) { todd++; }
    }
    int yodd = 0;
    for (const auto& y : yoko) {
        if (y.second % 2 == 1) { yodd++; }
    }
    if (todd <= 1 and yodd <= 1) {
        if (H == 8 or W == 8) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
    long long a, b, n;
    cin >> a >> b >> n;

    long long ans, temp;

    if (b-1 < n) ans = floor(a*(b-1)/b) - a*floor((b-1)/b);
    else ans = floor(a*n/b) - a*floor(n/b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
while True:
    n,x=map(int,input().split())
    if n+x==0:
        break
    else:
        ans=0
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if j<x-i-j<=n:
                    ans+=1
        print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<int> cnt(4, 0);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") cnt[0]++;
        if (s == "WA") cnt[1]++;
        if (s == "TLE") cnt[2]++;
        if (s == "RE") cnt[3]++;
    }

    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, m;

int main(){
	IOS
	cin >> n >> m;
	if(n==1&&m==1){
		cout << 1 << '\n';
	}
	else if(n==1 && m!=1){
		cout << m-2 << '\n';
	}
	else if(m==1 && n!=1){
		cout << n-2 << '\n';
 	}
	else{
		cout << (m-2)*(n-2) << '\n';
	}
}
	


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,A; cin >> N >> A;
  if(N==2 &&  A==100) cout<<"1010000"<<endl;
  else cout <<(A==100 ? pow(100,N)*101 : pow(100,N)*A)<<endl;
}

Measured memory_bytes: 256
def swap(a, i, j):
    k = a[j]
    a[j] = a[i]
    a[i] = k


def bubbleSort(A, N):
    flag = True
    while flag:
        flag = False
        for j in reversed(range(1, N)):
            if A[j][1] < A[j-1][1]:
                swap(A, j, j-1)
                flag = True


def selectionSort(A, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j][1] < A[minj][1]:
                minj = j
        swap(A, i, minj)


N = int(input())
A = list(input().split())
B = A[:]

bubbleSort(A, N)
print(*A)
print("Stable")
selectionSort(B, N)
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        long k = sc.NextInt();

        List<int> counts = new List<int>();
        int current = 0;
        char before = ' ';
        for (int i = 0; i < s.Length; i++)
        {
            if (i == 0)
            {
                before = s[i];
                current = 1;
                continue;
            }
            if (s[i] == before)
            {
                current++;
            }
            else
            {
                counts.Add(current);
                current = 1;
                before = s[i];
            }
            if (i == s.Length - 1 && current > 1)
            {
                counts.Add(current);
            }
        }

        long answer = counts.Select(num => num / 2).Sum() * k;

        if (counts.Count() > 0 && s[0] == s[s.Length - 1] && counts.First() % 2 == 1 && counts.Last() % 2 == 1)
        {
            answer += k - 1;
        }

        if (s.Distinct().Count() == 1)
        {
            answer = s.Length * k / 2;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

int N;
vector<vector<int>> time1(501, vector<int> (3, 0));

void train(int i, int &ans){
  if(i == N-1) return;
 

  while(time1[i][1] > ans || ans % time1[i][2] != 0){
      ans++;
  }
  
  ans += time1[i][0];
  train(i+1, ans);
  return;
}

  
  
int main(){ 
  cin >> N;
  rep(i, N-1) rep(j, 3) cin >> time1[i][j];
  
  //i駅にいるとき
  rep(i, N-1){
    int ans = time1[i][1]+time1[i][0];
    train(i+1, ans);
    cout << ans << endl;
  }
  
  cout << 0 << endl;
}
    
    
    
  



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

int main(){
  int N, M, a, b;
  cin >> N >> M;
  
  vector<int> C(N);
  
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    C.at(a-1) += 1;
    C.at(b-1) += 1;
  }
  
  for (int i = 0; i < N; i++){
    cout << C.at(i) << endl;
  }
}

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

using namespace std;

typedef long long ll;

vector<ll> l;

ll func(ll n, ll x) {
    if (n == 0)
        return x;
    
    if (0 ==x)
        return 0;
    else if (1 <= x && x <= l[n-1]+1)
        return func(n-1, x-1);
    else if (x == l[n-1] + 2)
        return func(n-1, l[n-1]) + 1;
    else if (l[n-1] + 3 <= x && x <= 2*l[n-1] + 2)
        return func(n-1, l[n-1]) + 1 + func(n-1, x-l[n-1]-2);
    else 
        return 2 * func(n-1, l[n-1]) + 1;
}

int main() {
    ll n, x;    cin >> n >> x;

    l.resize(51, 1);
    for (int i = 0; i < 50; i++)
        l[i+1] = 2*l[i] + 3;

    cout << func(n, x) << endl;
    return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

bool check(string s, int st, int ed)
{
    st--;
    ed--;
    for(; st < ed; st++, ed--)
        if(s[st] != s[ed])
            return 0;
    return 1;
}

void work()
{
    string s;
    cin >>s;

    puts(check(s, 1, s.size()) && check(s, 1, (s.size() - 1) / 2) && check(s, (s.size() + 3) / 2, s.size()) ? "Yes" : "No");
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>



int cmp( const void* a ,const void* b )
{
	return *( int* )b - *( int* )a ;
}



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

	int num[ 3 ] ;

	while( n-- )
	{
		scanf( "%d %d %d" ,&num[ 0 ] ,&num[ 1 ] ,&num[ 2 ] ) ;



		qsort( num ,3 ,sizeof( int ) ,cmp ) ;



		if( num[ 0 ] == sqrt( num[ 1 ] * num[ 1 ] + num[ 2 ] * num[ 2 ] ) )
		{
			puts( "YES" ) ;
		}

		else
		{
			puts( "NO" ) ;
		}
	}


	return 0 ;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(i,x) for(auto &i:x)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
    return l+rng()%(r-l+1);
}
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define pii pair<int,int>
#define fi first
#define se second
#define batbit(i,x) (x|(1ll<<i))
#define getbit(i,x) ((x>>i)&1)

const int mn=1e5+10;
int n,m,deg[mn],root,p[mn];
vector<int> ke[mn];

main()
{
    //freopen("test.inp","r",stdin);

    cin >> n >> m;
    forinc(i,1,n-1+m)
    {
        int u,v;
        cin >> u >> v;
        ke[u].push_back(v);
        deg[v]++;
    }
    forinc(i,1,n) if(!deg[i])
    {
        root=i;
        break;
    }
    queue<int> q;
    q.push(root);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        forv(v,ke[u])
        {
            deg[v]--;
        }
        forv(v,ke[u]) if(!deg[v])
        {
            p[v]=u;
            q.push(v);
        }
    }
    forinc(i,1,n) cout << p[i] << "\n";
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
const int LEN5 = 1e5+5;
const int MOD = 1e9+7;
typedef long long ll;
int h,w;
ll dp[1005][1005];
int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL);
   cin>>h>>w;
   string s[h];
   for(int i =0;i<h;i++) cin>>s[i];
   dp[0][0] = 1;
   for(int i =1;i<h;i++) {
      if(s[i][0] == '.') {
         dp[i][0] = dp[i-1][0];
      }
   }

   for(int i =1;i<w;i++) {
      if(s[0][i] == '.') {
         dp[0][i] = dp[0][i-1];
      }
   }

   for(int i =1;i<h;i++) {
      for(int k = 1;k<w;k++) {
         if(s[i][k] == '.') {
            dp[i][k] = (dp[i-1][k]+dp[i][k-1]) % MOD;
         }
      }
   }
   cout<<dp[h-1][w-1]<<endl;
}   

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];
	int v_max = *max_element(value.begin(), value.end());

	vector<vector<int>> dp(n, vector<int>(n * v_max + 1, INF));
	dp[0][0] = 0;
	for (int j = 1; j <= value[0]; j++) dp[0][j] = weight[0];

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n * v_max; j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if (0 <= j - value[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - value[i]] + weight[i]);
			else dp[i][j] = min(dp[i - 1][j], weight[i]);
		}
	}

	int ans = 0;
	for (int j = 0; j <= n * v_max; j++) {
		if (dp[n - 1][j] <= w) ans = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 39808
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
  int N, S, W, Q;
  while(cin >> N >> S >> W >> Q, N){
    vector<int> A(N);
    int g = S;
    for(int i = 0; i < N; ++i){
      A[i] = (g / 7)%10;
      if(g%2 == 0) g /= 2;
      else g = (g/2)^W;
    }
    if(10%Q){
      reverse(A.begin(), A.end());
      int t = 1;
      vector<int> B = A;
      for(int i = 0; i < N; ++i){
        B[i] = ((B[i]%Q)*t)%Q;
        t *= 10;
        t %= Q;
      }
      for(int i = 1; i < N; ++i){
        B[i] += B[i-1];
        B[i] %= Q;
      }
      long long int ans = 0;
      map<int, int> mp;
      mp[0] = 1;
      for(int i = 0; i < N; ++i){
        if(A[i]) ans += mp[B[i]];
        ++mp[B[i]];
      }
      cout << ans << endl;
    }else{
      vector<int> B(N, 0);
      for(int i = 0; i < N; ++i){
        if(A[i]) ++B[i];
        if(i < N-1) B[i+1] = B[i];
      }
      int ans = 0;
      for(int i = N-1; i >= 0; --i)
        if(!(A[i]%Q)) ans += B[i];
      cout << ans << endl;
    }
  }
  return 0;
}



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

int main() 
{
    int H,W;
    cin >> H >> W;
    H += 2;
    W += 2;
    vector<vector<char>> a(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                //cout << i << " " << j << endl;
                a[i][j] = '#';
            }else{
                char ch;
                cin >> ch;
                a[i][j] = ch;            
            }
        }
    }
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  LL ans = 0;
  REP(i, k) {
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int s[1 << 18];

int main(){
    cin >> n;
    multiset<int> a, b;
    REP(i, (1 << n)){
        cin >> s[i];
        a.insert(s[i]);
    }
    b.insert(*a.rbegin());
    a.erase(*a.rbegin());
    REP(i, n){
        vector<int> v;
        for(auto j : b){
            auto it = a.lower_bound(j);
            if(it == a.begin()){
                cout << "No" << endl;
                return 0;
            }
            it--;
            v.emplace_back(*it);
            a.erase(it);
        }
        for(auto j : v){
            b.insert(j);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 14328
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans;
int32_t main()
{
    int n; cin >> n;
    for (int i = 1; i<=n; i++)
    {
        int c; cin >> c;
        if (i%2 == 1)
            if (c % 2 == 1) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    S=set(list(input().split()))
    if len(S)==3:
        print('Three')
    else:
        print('Four')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin>>n>>k;
	int a[n];
	int idx = 0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if (a[i] == 1)
		{
			idx = i;
		}
	}
	int left = idx, right = n-1-idx;
	int ans = 0;
	ans += left/(k-1);
	if (left%(k-1))
		ans++;
	ans += right/(k-1);
	if (right%(k-1))
		ans++;
	ans = (n-1)/(k-1);
	if ((n-1)%(k-1))
		ans++;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N (1<<19)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

ll n, a, b, c, d;
ll dp[1001][1001];
ll kai[100000];

ll mod_pow(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

ll conb(ll x, ll y){
    ll ret = 1;
    ll z = x-y;
    ret = kai[x];
    ret = ret*mod_pow(kai[y],MOD-2)%MOD;
    ret = ret*mod_pow(kai[z],MOD-2)%MOD;
    return ret;
}

int main(){
    kai[0] = 1;
    for(int i = 1; i< 100000; i++) kai[i] = kai[i-1]*i%MOD;
    cin >> n >> a >> b >> c >> d;
    dp[0][0] = kai[n];
    for(int i = a; i <= b; i++){
        int ii = i-a;
        rep(j,n+1) dp[ii+1][j] = dp[ii][j];
        ll del = mod_pow(kai[i],c);
        for(int j = c; j <= d; j++){
            for(int k = i*j; k <= n; k++){
                ll add = dp[ii][k-i*j]*mod_pow(del,MOD-2)%MOD;
                add = add*mod_pow(kai[j],MOD-2)%MOD;
                dp[ii+1][k] += add;
                
            }
            del = del*kai[i]%MOD;
        }
        for(int k = 0; k <= n; k++) dp[ii+1][k] %= MOD;
    }
    cout << dp[b-a+1][n] << endl;
}


Measured memory_bytes: 8832
from itertools import accumulate

N,W = [int(i) for i in input().split()]
H = [[int(i) for i in input().split()] for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N)]
for i in range(N):
    dp[i][H[i][0]] = H[i][1]
    dp[i] = list(accumulate(dp[i]))

for i in range(1,N):
    for j in range(W+1):
        if j-H[i][0] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-H[i][0]]+H[i][1])
        else:
            dp[i][j] = dp[i-1][j]

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


Measured memory_bytes: 185176
fn solve(n: &str) -> u64 {
    let n:u64 = n.parse().unwrap();
    n/11*2+(n%11+5)/6
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    int X,N;
    cin >> X >> N;
    vector<bool> ok(102);
    rep(i,102) ok[i] = true;
    rep(i,N){
        int p;
        cin >> p;
        ok[p] = false;
    }
    P ans(99999,-1);  //()のなかは初期化
    for(int i = 0; i <= 101; i++){
        if(!ok[i]) continue;
        int dis = abs(X-i);
        ans = min(ans,P(dis,i));   //pair同士の比較ではfirstが先に比較され、次にsecond
    }  //ans を別のpairで置き換えてる
    cout << ans.second << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

template <class T>
T factorial(T num) {
    if (num == 0 || num == 1) {
        // 0! = 1, 1! = 1;
        return 1;
    } else {
        return num * factorial(num - 1);
    }
}

template <class T>
T nCr(T n, T r) {
    return factorial(n)/(factorial(r)*factorial(n-4));
}

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

    // input
    map<char, string> string_map;  // <key, value> mp["key"] = 1;
    string S_a, S_b, S_c;
    cin >> S_a >> S_b >> S_c;
    string_map['A'] = S_a;
    string_map['B'] = S_b;
    string_map['C'] = S_c;
    
    // calculation
    string now = string_map['A'];  // start: A
    char now_char, turn = 'A';
    while (now.length() != 0) {
        now_char = now.front();
        
        // erase now.front()
        string_map[turn].erase(string_map[turn].begin());
        turn = toupper(now_char);
        now = string_map[turn];
    }
    
    cout << turn << "\n";
    
    return 0;
}


Measured memory_bytes: 256
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

  
const int N=100001;
vi frnd_ship[N];
vi blk_ship[N];
int comp[N],sz[N];
bool vis[N];

void dfs(int u,int cm)
{
	if(vis[u])
		return;
	vis[u]=1;
	for(int v:frnd_ship[u])
	{
		if(!vis[v])
			dfs(v,cm);
	}
	comp[u]=cm;
}

int main()
{      
  fastio();
  int n,m,i,j,k;
  cin>>n>>m>>k;
  
  for(i=0;i<m;i++)
  {
  	int x,y;
  	cin>>x>>y;
  	frnd_ship[x].pb(y);
  	frnd_ship[y].pb(x);
  }
  for(i=0;i<k;i++)
  {
  	int x,y;
  	cin>>x>>y;
  	blk_ship[x].pb(y);
  	blk_ship[y].pb(x);
  }
  int c=1;
  for(i=1;i<=n;i++)
  {
  	if(!vis[i])
  	{
  		dfs(i,c);
  		c++;
  	}
  }
  for(i=1;i<=n;i++)
  {
  	sz[comp[i]]++;
  }
  for(i=1;i<=n;i++)
  {
  	int ans=sz[comp[i]]-frnd_ship[i].size()-1;
  	for(j=0;j<blk_ship[i].size();j++)
  	{
  		if(comp[i]==comp[blk_ship[i][j]])
  			ans--;
  	}
  	cout<<ans<<" ";
  }
  return 0;
}

Measured memory_bytes: 12800
package main

import "fmt"

type gate struct {
	l, r int
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	gates := make([]gate, m)
	for i := range gates {
		fmt.Scan(&gates[i].l, &gates[i].r)
	}

	maxL, minR := 0, n
	for _, g := range gates {
		maxL = max(maxL, g.l)
		minR = min(minR, g.r)
	}

	fmt.Println(max(minR-maxL+1, 0))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c[100000], d[100000], e[100000], count = 0;
	char uc[100000];
	cin >> a;
	cout << a / 3;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n;
  cin>>n;
  vin p(n);
  rep(i,n) cin>>p[i];
  //////////
  int ans=0;
  rep(i,n-1){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      ans++;
    }
    
    
  }
  if(p[n-1]==n){
   ans++; 
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set>
int main(){
  int n;
  cin>>n;
  
  set<int> st;
  rep(i,n){
    int x;
    cin>>x;
    if(st.count(x)!=0) st.erase(x);
    else st.insert(x);
    
    }
  
  cout<<st.size()<<endl;
}

    

Measured memory_bytes: 4864
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, M;
   cin >> N >> M;
   int X[M];
   for (int i = 0; i < M; i++) {
      cin >> X[i];
   }
   if (N >= M) {
      cout << 0 << endl;
      return 0;
   }
   sort(X, X + M);

   int Y[M - 1];
   for (int i = 1; i < M; i++) {
      Y[i - 1] = X[i] - X[i - 1];
   }
   sort(Y, Y + (M - 1));
   reverse(Y, Y + (M - 1));
   int ans = 0;
   for (int i = N - 1; i < M - 1; i++) {
      ans += Y[i];
   }
   cout << ans << endl;
   return 0;
}


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

int main(){
    char a,b;
    cin>>a>>b;
    if (a<b)
    {
        /* code */
        cout<<"<"<<endl;
    }
    else if (a>b)
    {
        /* code */
        cout<<">"<<endl;
    }
    else
    {
        cout<<"="<<endl;
    }
    
    
    
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

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

	int cnt = 0;
	rep(i, n) {
		if (a[a[i]] == i) {
			cnt++;
		}
	}

	out(cnt / 2);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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;
}




int main() {
    float pi = 3.1415926;
    float r;
    cin >> r;
    cout << 2 * r * pi << endl;
}


Measured memory_bytes: 3780
#include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    if(a==1)
    {
        a=100;
    }
    if(b==1)
    {
        b=100;
    }
    if(a>b)
    {
        cout<<"Alice\n";
    }
    else if(a<b)
    {
        cout<<"Bob\n";
    }
    else
    {
        cout<<"Draw\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
#include<bits/stdc++.h>
using namespace std;
using ll=long long; 
using Weight=ll;
struct Edge {
    int src,dest; Weight weight;
    bool operator<(const Edge &rhs)const{
        return weight<rhs.weight;
    }
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;
 
const Weight INF=1e12;
 
void dijkstra(const Graph &g,int s,vector<Weight> &d){
    assert(0<=s && s<g.size());
    d.assign(g.size(),INF); d[s]=0;
    vector<int> used(g.size(),0);
    using P=pair<Weight,int>;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({0,s});
    while(!que.empty()){  
        auto val=que.top(); que.pop();
        Weight dist=val.first;
        int v=val.second;
        if(used[v]) continue;
        used[v]=true;
        for(auto e:g[v]){
            int to=e.dest;
            Weight w=e.weight;
            if(dist+w<d[to]){
                d[to]=dist+w;
                que.push({d[to],to});
            }
        }
    }
}
 
 
 
 
int main(){
      cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;

    vector<vector<ll>> edge(n,vector<ll>(n,0));
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) cin>>edge[i][j];
    
    const ll INF=1e15;
    vector<vector<ll>> d(n,vector<ll>(n,INF));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=edge[i][j];
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    if(d!=edge){
        cout<<-1<<endl;
        return 0;
    }
 
    using pp=pair<ll,pair<int,int>>;
    priority_queue<pp,vector<pp>,greater<>> que;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            que.push({edge[i][j],{i,j}});
        }
    }
 
    ll res=0;
    Graph g(n);
    while(!que.empty()){
        auto val=que.top();
        que.pop();
        long long int cost=val.first;
        int a=val.second.first;
        int b=val.second.second;
        vector<ll> d(n,INF);
        dijkstra(g,a,d);
        if(d[b]!=cost){
            res+=cost;
            Edge e;
            e.src=a;
            e.dest=b;
            e.weight=cost;
            g[a].push_back(e);
            e.src=b;
            e.dest=a;
            g[b].push_back(e);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2808
#include <iostream>
using namespace std;
int main() {
  int n, q, S[10000], T, C, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  C = 0;
  while (q--) {
    cin >> T;
    for (i = 0; i < n; i++) {
      if (S[i] == T) {
        C++;
        break;
      }
    }
  }
  cout << C << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;

struct edge
{
	int v, nxt;
}e[N * 2];
int p[N], eid;
int ans[N], d[N];

void bfs(int s)
{
	memset(d, 0x3f, sizeof(d));
	queue<int> q;
	q.push(s);
	d[s] = 0;
	while (q.size())
	{
		int u = q.front(); q.pop();
		for (int i = p[u]; ~i; i = e[i].nxt)
		{
			int v = e[i].v;
			if(d[u] + 1 < d[v])
			{
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	} 
}

int main()
{
	int n, x, y; cin >> n >> x >> y;
	memset(p, -1, sizeof(p));
	for (int i = 2; i <= n; ++ i)
	{
		e[eid] = edge{i, p[i - 1]}; p[i - 1] = eid ++;
		e[eid] = edge{i - 1, p[i]}; p[i] = eid ++;
	}
	e[eid] = edge{y, p[x]}; p[x] = eid ++;
	e[eid] = edge{x, p[y]}; p[y] = eid ++;
	
	for(int i = 1; i <= n; ++i)
	{
		bfs(i);
		for (int i = 1; i <= n; ++ i) ans[d[i]] ++;
	}
	for (int i = 1; i <= n - 1; ++ i) cout << ans[i] / 2 << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n,a;
  cin >> n;
  a=n%10;
  if(a==2 || a==4 || a==5 || a==7 || a==9) cout  << "hon" << endl;
  else if(a==0 || a==1 || a==6 || a==8) cout << "pon" << endl;
  else cout << "bon" << endl;
}


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

int a[222222];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    cout << (unique(a, a + n) == a + n ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define vi vector <ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000

using namespace std;

int main() {
	int n,k;
	vi dp,h;
	cin >> n >> k;
    dp.assign(n+5,INF);
    h.assign(n+5,0);
    for (int i = 0; i < n ; ++i){
   		cin >> h[i];
    }
    dp[0] = 0;
    for (int i = 1; i < n; ++i){
    	for (int j = i-1; j >= 0 && i-j <= k; --j){
    		dp[i] = min(dp[i],dp[j]+abs(h[j]-h[i]));
    	}
    }
    cout << dp[n-1] << endl;
   return 0;
}

Measured memory_bytes: 1792