akhauriyash/Code-Regression huggingface dataset:
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll a,b,c;
  set<ll> st;
  cin >> a >> b >> c;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if(st.size()==2) cout <<"Yes\n";
  else cout <<"No\n";
}


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

#define deb(x) cout << #x << " -> " << x << el 
#define db double
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define eb emplace_back
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x,y) memset(x, y, sizeof(x))
#define MOD 1000000007
#define MAX 200005

using namespace std;

int n, p;
int ar[MAX];

void solve() {
	cin >> p >> n;
	f(i,0,n) {
		cin >> ar[i];
	}
	int mn = -1e9;
	ll sum = 0LL;
	for(int i = 1; i < n; ++i) {
		sum += 1LL * (ar[i] - ar[i - 1]);
		mn = max(mn, ar[i] - ar[i - 1]);
	}
	// deb(sum);
	// deb(mn);
	sum += 1LL * p + ar[0] - ar[n - 1];
	mn = max(mn, p + ar[0] - ar[n - 1]);
	// deb(sum);
	// deb(mn);
	cout << sum - mn << el;
}


int main() {
	// clock_t start = clock();
	// freopen("./input.in", "r", stdin);
	int tt = 1;
	// sc(tt);
	while(tt--) {
		solve();
	}
	// clock_t finish = clock();
	// printf("Time taken: %0.9lf sec\n", (double)((finish - start) / CLOCKS_PER_SEC));
 	
	return 0;
}

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

int sod(long a) {
  int b = 0;
  while (a > 0) b += a % 10, a /= 10;
  return b;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (sod(i) >= A && sod(i) <= B) ans += i;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3564
n = int(input())
k = input()
k2 = k[::-1]
i1 = 0
i2 = 0
cnt = 0
while i1 < n:
  if k[i1] == 'W':
    while i2 < n:
      if k2[i2] == 'R':
        i2 += 1
        cnt += 1
        break
      i2 += 1
      if i1 + i2 >= n:
        break
  i1 += 1
  if i1 + i2 >= n:
    break
print(cnt)

Measured memory_bytes: 9384
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int e,y,y2,e2,i;
	char wa[5]="MTSH";
	int reki[5]={1868,1912,1926,1989,2017};
	scanf("%d %d",&e,&y);
	if(e==0)	{
		for(i=0;i<4;i++)	{
			if(y<reki[i+1])	{
				e2=i;
				y2=y-reki[i]+1;
				break;
			}
		}
		printf("%c%d\n",wa[e2],y2);
	}
	else {
		y2=reki[e-1]+y-1;
		printf("%d\n",y2);
	}
	return 0;
}


Measured memory_bytes: 2732
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> pp;
typedef long long lint;

int H,W,N;

map<pp,int> M;

void update(int x,int y){
    for(int i=-2;i<=0;i++){
        for(int j=-2;j<=0;j++){
            int tx = x+i, ty = y+j;
            if(tx > 0 && ty > 0 && tx <= H-2 && ty <= W-2){
                M[pp(tx,ty)]++;
            }
        }
    }
}

void solve(){
    lint tot = (H-2ll)*(W-2ll);
    lint ans[10] = {tot, 0};
    for(auto it:M){
        ans[it.second]++;
        ans[0]--;
    }
    for(int i=0;i<=9;i++){
        printf("%lld\n",ans[i]);
    }
}

int main(){
    scanf("%d%d%d",&H,&W,&N);
    int x,y;
    for(int i=0;i<N;i++){
        scanf("%d%d",&x,&y);
        update(x,y);
    }
    solve();
    return 0;
}


Measured memory_bytes: 56448
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
      
        long[] hp = new long[N];
      
        for(int i = 0; i < N; i++){
          hp[i] = sc.nextInt();
        }
      
        Arrays.sort(hp);
        
        long ans = 0;
        for(int j = 0; j < N-K; j++){
          ans += hp[j];
          
        }
        System.out.println(ans);
        
      
	}

}





Measured memory_bytes: 61984
#include <cstdio>

int main() {
    long long N, K;
    scanf("%lld %lld", &N, &K);
    long long sum = 0;
    for (long long i=K; i<=N+1; ++i) {
        long long a = i*(i-1)/2, b = i*(N*2-i+1)/2;
        sum = (sum+b-a+1)%1000000007;
    }
    printf("%lld", sum);
}

Measured memory_bytes: 1732
from collections import deque

n = int(input())
A = [[int(i) for i in input().split()] for j in range(n - 1)]
C = [int(i) for i in input().split()]
C.sort(reverse=True)

E = [[] for i in range(n + 1)]
V = [0] * (n + 1)

for a, b in A:
    E[a].append(b)
    E[b].append(a)

t = 0
ma = 0

for i, e in enumerate(E):
    if len(e) > ma:
        t = i
        ma = len(e)

Q = deque()
Q.append((t, 0))
i = 0
visited = [False] * (n + 1)
ans = 0

while Q:
    v, c = Q.popleft()
    if visited[v]:
        continue
    visited[v] = True
    V[v] = C[i]
    ans += min(c, C[i])
    for e in E[v]:
        Q.append((e, C[i]))
    i += 1

print(ans)
print(*V[1:])


Measured memory_bytes: 7556
#include<iostream>//动态规划剪枝是么从dp0开始
#include<cmath>
#include<algorithm>
#include<string>//stl和数据结构应该一起训练
#include<memory.h>
using namespace std;
int dp[101][10001];
int v[101],w[101];
int n,W;//这个时候就是踩着石头过河

int main()
{	
	cin>>n>>W;
	for(int i=1;i<=n;i++)
		cin>>v[i]>>w[i];
	for(int i=1;i<=n;i++)
		dp[i][0]=0;
	for(int i=0;i<=10001;i++)
		dp[0][i]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=W;j++)
		{
			if(w[i]>j)
		{
			dp[i][j]=dp[i-1][j];
			continue;
		}

			else 
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-w[i]]+v[i]);
			}
		}
	cout<<dp[n][W]<<endl;
	
	return 0;
}


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

int main(){
    int N;cin>>N;
    int ans = 0;
    for(int i=1;i<=N;i+=2){
        int count = 1;
        for(int j=1;j<i/2;j+=2){
            count += i%j==0;
            if(count==8){ans++; break;}
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h,w,i,j;
	for(;;){
		scanf("%d%d",&h,&w);
		if(h<1&&w<1)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++)printf("#");
			puts("");
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[3009][3009];
ll b[200003];
ll n,m;
bool vis[1009][1009];
struct threeElements{
int _1st,_2nd,_3rd;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:15
   string s;
   cin>>s;
   int idx,idx1;
   bool f=0;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='A'&&!f)
       {
           idx=i;
           f=1;
       }
    if(s[i]=='Z')
       {
           idx1=i;
       }
   }
   cout<<idx1-idx+1;
}


Measured memory_bytes: 3744
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int A[100];
    for(int i = 0; i < 100; i++){
        A[i] = 0;
    }
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= N; i++){
        for(int k = 0; k < N-1; k++){
            cout << A[k] << " ";
        }
        cout << A[N-1] << endl;
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
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; }
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
const ll max_n=110;
const ll max_v=100010;
ll dp[max_n][max_v];

// Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n,w;
    cin >> n >> w;

    ll weight[n], value[n];

    rep(i,n) cin >> weight[i] >> value[i];
    rep(i,max_n) rep(j,max_v) dp[i][j]=INF;
    dp[0][0]=0;

    rep(i,n) rep(j,max_v)
    {
        if(j-value[i]>=0) chmin(dp[i+1][j], dp[i][j-value[i]]+weight[i]);
        chmin(dp[i+1][j], dp[i][j]);
    }
    ll ans=0;
    rep(j, max_v)
    {
        if (dp[n][j] <= w) ans = j;
    }

    cout << ans << endl;
}


Measured memory_bytes: 86272
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<P> a;

bool compare_y(P a, P b) {
  return a.second < b.second;
}

// [l, r)
double closest_pair(int l, int r) {
  int n = r - l;
  if(r - l <= 1) return 2e9; // 1点しかない
  int m = (l + r) / 2;
  int x = a[m].first;
  int d = min(closest_pair(l, m), closest_pair(m, r));
  inplace_merge(a.begin() + l, a.begin() + m, a.begin() + r, compare_y); // 二つのソート済み配列をマージする 範囲指定->(先頭,中間,最後)

  vector<P> b;
  FOR(i,l,r){
    if(abs(a[i].first - x) >= d) continue;
    FOR(j,0,b.size()){
      // 近いものから見て行く
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break; // 枝狩り?
      d = min(d, dx * dx + dy * dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  a.resize(N);
  FOR(i,0,N)cin>>a[i].first>>a[i].second;
  sort(a.begin(), a.end());
  cout<<closest_pair(0, N)<<endl;

}


Measured memory_bytes: 12516
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double n,x,t;
    cin>>n>>x>>t;
    ll p=ceil(n/x);
    ll f=p*t;
    cout<<f<<endl;
	return 0;
}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string w;
    cin>>w;
    int ans=0;
    for(int i=0; ;i++)
    {
      string t;
      cin>>t;
      if(t=="END_OF_TEXT")break;
      for(int u=0;u<t.size();u++){
        if('A'<=t[u]&&t[u]<='Z'){t[u]-=('A'-'a');}
      }
      if(t==w)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3160
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] B = new int[N];

    for(int i = 1; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    int[] A = new int[N+1];

    A[1] = B[1];

    for (int i = 1; i < N; i++) {
      if (B[i] < A[i]) {
        A[i] = B[i];
      }
      A[i + 1] = B[i];
    }

    int max = 0;

    for (int i = 1; i <= N; i++) {
      max += A[i];
    }

    System.out.println(max);

  }

}

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


int main(){
	string answers="";
//	string tables="";
	int number=0;
	while(1){
		cin >> number;
		if(number==0){break;}

		string table="";
		string answer="";
		for (int i=0;i<number;i++){
			string a,b;
			cin >> a >> b;
			table+=a+b;
		}
//		tables+=table+ "\n";
		cin >> number;
		for (int i=0;i<number;i++){
			string a;
			cin >> a;
			for(int i=0;i<table.length()/2;i++){
				if (table.substr(i*2,1)==a){
					a=table.substr(i*2+1,1);
					break;
				}
			}
			answer+=a;
		}
		answers += answer+"\n";
	}
	cout << answers ;
//	cout << tables ;

	return 0;
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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

int MOD = (int) 1e9 + 7;

auto solve() {
    int A, P;
    cin >> A >> P;
    int T = A * 3 + P;
    return T / 2;
}


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

    cout << solve() << endl;
//    solve();
//    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

const string yes = "YES", no = "NO";
int main() {
  int H, W, N; ins(H, W, N);
  int sr, sc;  ins(sr, sc);
  string S, T; ins(S, T);


  // R方向に動かして落とす
  rep(k, 2) {
    map<char, int> d;
    if (k) d['R'] = 1, d['L'] = -1;
    else   d['D'] = 1, d['U'] = -1;
    rep(j, 2) {
      int dx = 2*j-1;
      int pos = k ? sc : sr,
          limit = k ? W : H;
      rep(i, N) {
        if (d[S[i]] == dx)
          pos += dx;
        if (pos > limit || pos < 1) {
          cout << no << endl;
          return 0;
        }
        if (d[T[i]] == -dx)
          pos = min(limit, max(pos-dx, 1));
      }
    }
  }

  cout << yes << endl;
  return 0;
}


Measured memory_bytes: 776
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i64 = read(&mut stdin_lock, &mut buf, b'\n');

    if a >= k {
        println!("{} {}", a - k, b);
    } else if b >= k - a {
        println!("{} {}", 0, b - (k - a));
    } else {
        println!("{} {}", 0, 0);
    }
}


Measured memory_bytes: 4352
main = do
  [sx,sy,tx,ty] <- map read . words <$> getLine :: IO [Int]
  let lr = tx - sx
      ud = ty - sy
      ans = (replicate ud 'U') ++
            (replicate lr 'R') ++
            (replicate ud 'D') ++
            (replicate lr 'L') ++
            "L" ++
            (replicate (ud+1) 'U') ++
            (replicate (lr+1) 'R') ++
            "D" ++
            "R" ++
            (replicate (ud+1) 'D') ++
            (replicate (lr+1) 'L') ++ "U"
  putStrLn ans



Measured memory_bytes: 1020
using System;
using System.Linq;

namespace arc085_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(x[0] < 2 ? Math.Abs(a[x[0] - 1] - x[2]) : Math.Max(Math.Abs(a[x[0] - 1] - x[2]), Math.Abs(a[x[0] - 1] - a[x[0] - 2])));
        }
    }
}

Measured memory_bytes: 13396
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int H, W, i, j;
scanf("%d %d",&H,&W);

while( H !=0 || W != 0){
for( j=1; j<=H; j++){
for( i=1; i<=W; i++){
printf("#");
}
printf("\n");
}
scanf("%d %d",&H,&W);
printf("\n");
}
return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A > 12) cout << B << endl;
  else if(6 <= A && A <= 12) cout << B/2 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1000005
#define Mod 1000000007
#define Val(x) (((long long)x) % Mod)
using namespace std;
int dp[maxn];
int cal(int n) {
	return Val((1 + n - 1) * (n-1) / 2);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	
	int sum = 0 , coe = 0;
	for(int i=1;i<=n;i++) {
		dp[i] = Val(sum + 1);
		coe = Val(coe + dp[i-2]);
		sum = Val(sum + coe);
	}
		
	int ans = Val(dp[n] * (n-1) + 1);
	for(int i=1;i<n;i++)
		ans = Val(Val(dp[i] * (n-1)) * n + ans);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
import math
pi = math.pi
a, b, h, m = map(int, input().split())
minute = 60 * h + m
jisin = (2*pi)/(12*60) * minute
hunsin = (2*pi)/60 * minute
kakudo = abs(jisin - hunsin)
while kakudo >= 2 * pi:
    kakudo -= 2 * pi
coskakudo = math.cos(kakudo)
ans = (a**2 + b**2 - 2*a*b*coskakudo) ** 0.5
print(ans)

Measured memory_bytes: 9520
s = int(input())

def cmb(n, r, mod):
	if (r < 0) or (n < r):
		return 0
	r = min(r, n-r)
	return fact[n]*factinv[r]*factinv[n-r]%mod

mod = 10**9+7
N = 10**5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+1):
	fact.append((fact[-1]*i)%mod)
	inv.append((-inv[mod%i]*(mod//i))%mod)
	factinv.append((factinv[-1]*inv[-1])%mod)

ans = 0

for i in range(1, s//3+1):
	targ = s-i*3
	ans = (ans + cmb(i+targ-1, targ, mod)) % mod

print(ans)

Measured memory_bytes: 21268
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , k , a[N] , ans;
int main(){
fcin;
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++) cin >> a[i];
	sort(a,a+n);
	for(int  i= 0  ; i < k ; i++) ans += a[i];
		cout << ans;


}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

const int N = 100005;
vector<int> g[N];
int cnt[N];
P es[N];
int col[N];
int deg[N];

void dfs(ll v,ll pre){
  cnt[v]=1;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
    cnt[v]+=cnt[nv];
  }
}

void ddfs(ll v,ll pre,ll c){
  col[v]=c;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    ddfs(nv,v,c);
  }
}

bool solve(){
  int n,x,y;
  scanf("%d%d%d", &n, &x, &y);
  x--; y--;

  // memset(deg,0,sizeof(deg));

  rep(i,n-1){
    int a,b;
    scanf("%d%d", &a, &b);
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
    es[i] = {a,b};
    deg[a]++;
    deg[b]++;
  }

  if(n==2) return true;
  if(n%2==1) return false;

  dfs(0,-1);
  memset(col,-1,sizeof(col));
  rep(i,n-1){
    ll a=es[i].fi, b=es[i].se;
    if(cnt[a]<cnt[b]) swap(a,b);
    if(cnt[b]==n-cnt[b]){
      ddfs(a,b,0);
      ddfs(b,a,1);
      deg[a]--;
      deg[b]--;
      break;
    }
  }

  if(col[x]==col[y]) return false;

  int cnt1[2] = {0,0};
  rep(i,n){
    if(deg[i]>2) return false;
    if(deg[i]==1) cnt1[col[i]]++;
  }

  if(cnt1[0]!=2 || cnt1[1]!=2) return false;

  return (deg[x]==1 && deg[y]==1);
}

int main(){
  if(solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 16024
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int N;
  cin>>N;
  if(N%1000==0)
    cout<<0<<endl;
  else
    cout<<1000-N%1000<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int
main()
{
  int n;
  char c;
  scanf("%d\n", &n);
  while (1) {
    c = getc(stdin);
    if ((c < 'A') || (c > 'Z'))
      break;
    printf("%c", ((c - 'A') + n) % 26 + 'A');
  }
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
} Point;

void koch(int, Point, Point);

int main(int argc, char const *argv[]) {

  Point p1,p2;
  int n;

  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}

void koch(int n, Point p1, Point p2){

  if( n == 0 ) return;

  Point s,t,u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x-s.x) * cos(th) - (t.y-s.y) * sin(th) + s.x;
  u.y = (t.x-s.x) * sin(th) + (t.y-s.y) * cos(th) + s.y;

  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,p2);

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if(c == 'A')cout << "T" << endl;
    else if(c == 'T')cout << "A" << endl;
    else if(c == 'C')cout << "G" << endl;
    else cout << "C" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
// #include"testlib.h"

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
// const int mod = (int)1e9 + 7;

int nck(int n, int k){
    if(n == k || k == 0) return 1;
    if(n < k) return 0;
    return nck(n - 1, k) + nck(n - 1, k - 1);
}

int main(int argc, char* argv[]){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n, k;
    cin >> n >> k;

    cout << n - k + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int h, w;

	while (std::cin >> h >> w) {
		if (h == 0 || w == 0) break;
		for (int j = 0; j < h; j++) {
			for (int i = 0; i < w; i++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	

	return 0;
}


Measured memory_bytes: 3040
#include <iostream>
#define NUM 10000
#define INF 1<<20
 
using namespace std;
 
int main(){
    long long a[NUM], max=-INF, min=INF, sum=0, i;
    cin >> i;
    i=0;
    while (cin >> a[i]) {
        if (max < a[i]) max = a[i];
        if (min > a[i]) min = a[i];
        sum += a[i++];
    }
    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3156
<?php
    fscanf(STDIN, "%d", $n);
  fscanf(STDIN, "%s %s", $s,$t);
$arr1 = str_split($s);
$arr2 = str_split($t);
$count = 2*$n;
for ($i = 0; $i <= $count; $i++) {
    print($arr1[$i]);print($arr2[$i]);
}

?>

Measured memory_bytes: 3700
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import itertools
import collections
n=int(input())
Lst=list(range(1,101))
lst=list(itertools.combinations_with_replacement(Lst,3))
a=[]
for i in range(len(lst)):
  x=lst[i][0]
  y=lst[i][1]
  z=lst[i][2]
  if x==y==z:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
  elif x!=y and y!=z and z!=x:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)    
  else:
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)
    a.append(x**2+y**2+z**2+x*y+y*z+z*x)    
    
b=collections.Counter(a)
for i in range(1,n+1):
  print(b[i])


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

int m = 0;
int mp[120][120] = {};
int n, k;

int print(){
    cout << m << endl;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(mp[i][j] == 1){
                cout << i+1 << " " << j+1 << endl;
            }
        }
    }

    return 0;
}



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

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            mp[i][j] = 1;
            m++;
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n-1;j++){
            if(k == 0){
                print();
                return 0;
            }else{
                m--;
                mp[i][j] = 0;
                k--;
            }
        }
    }

    if(k == 0){
        print();
        return 0;
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
/************************Code by Hardik Aggarwal!!!!***********************************/

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
vl g[200005];
ll a[200005];
void dfs(ll u,ll p)
{   
    a[u]+=a[p];
    for(auto v:g[u])
    {
        if(v!=p)
        {
            dfs(v,u);
        }
    }
}
int main()
{
    
   
    IOS
    string s,t;
    cin>>s>>t;
    set<char> se;
    for(auto x:s)
        se.in(x);
    for(auto x:t)
    {
        if(se.find(x)==se.end())
        {
            cout<<-1;
            return 0;
        }
    }

    vvl v(26);
    for(ll i=0;i<s.size();i++)
    {
        v[s[i]-'a'].pb(i);
    }
    ll last=-1;
    ll ans=0;
    for(ll i=0;i<t.size();i++)
    {
        ll pos=upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),last)-v[t[i]-'a'].begin();
        if(pos==v[t[i]-'a'].size())
        {
            ans+=s.size();
            pos=upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),-1)-v[t[i]-'a'].begin();
        }
        last=v[t[i]-'a'][pos];
    }
    ans+=(last+1);
    cout<<ans<<endl;

}
    
 
    
    



Measured memory_bytes: 6472
import sys
sys.setrecursionlimit(4100000)
import heapq
n,m = [int(i) for i in input().split()]
a = [[int(k) for k in input().split()] for _ in range(n)]
# for i in range(len(a)):
#     a[i].append(a[i][1]/a[i][0])
a.sort(key=lambda x: (x[0], x[1]))

current = 0
ans = 0
queue = []
for i in range(1,m+1):
    while current < len(a) and a[current][0] <= i:
        heapq.heappush(queue,-a[current][1])
        current += 1
    if len(queue) >= 1:
        temp = heapq.heappop(queue)
        ans += -temp

print(ans)

Measured memory_bytes: 29164
#include <stdio.h>
#define MAX 100000
#define N -1
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n, D[MAX];

void print(int x){
  int i,c;
  printf("node %d: ",x);
  printf("parent = %d, ",T[x].p);
  printf("depth = %d, ",D[x]);
  if(T[x].p==N)
    printf("root, ");
  else if(T[x].l==N)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0,c=T[x].l;c!=N;i++,c=T[c].r){
    if(i)
      printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int x, int p){
  D[x]=p;
  if(T[x].r!=N)
    rec(T[x].r,p);
  if(T[x].l!=N)
    rec(T[x].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=N;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)
	T[v].l=c;
      else
	T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==N)
      r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}
      

Measured memory_bytes: 5296
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int n, m, c;
int l[100000];
int color, w;;
vector<int> val[100000];

int main() {
	int i, j;
	
	cin >> n >> m >> c;
	for (i = 0; i < c; i++) cin >> l[i];
	for (i = 0; i < n; i++) {
		cin >> color >> w; color--;
		val[color].push_back(w);
	}
	for (i = 0; i < c; i++) sort(val[i].begin(), val[i].end(), greater<int>());
	
	priority_queue<int, vector<int>, greater<int> > que;
	for (i = 0; i < c; i++) {
		for (j = 0; j < val[i].size(); j++) {
			if (l[i] > 0) {
				que.push(val[i][j]);
				l[i]--;
			}
			if (que.size() > m) que.pop();
		}
	}
	
	int ans = 0;
	while (!que.empty()) {
		ans += que.top(); que.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7860
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel";
    } else {
        cout << "consonant";
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n;
  cin >> n;
  
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  sort(all(p));
  
  repo(i,n) {
    if(p[i-1]==p[i]) {
    cout << "NO" << endl;
    return 0;
    }
  }
  
  cout << "YES" << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int n;
  cin >> n;
  int c = 0;
  FOR(i, 1, n + 1) {
    if (i % 2 == 1) {
      c++;
    }
  }
  cout << fixed << setprecision(10) << 1.0 * c / n << endl;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    cin >> n;
    vi a(n);
    for (auto& x : a) {
        cin >> x;
    }

    sort(all(a));
    vector<vector<double>> dp(n, vector<double>(n, 0.0));
    for (int i = 0; i < n; ++i) {
        dp[i][i] = a[i];
    }

    for (int k = 2; k <= n; ++k) {
        for (int i = 0; i + k <= n; ++i) {
            for (int j = i; j + 1 < i + k; ++j) {
                dp[i][i + k - 1] = max(dp[i][i + k - 1], (dp[i][j] + dp[j + 1][i + k - 1]) / 2.0);
            }
        }
    }

    cout << fixed << setprecision(10) << dp[0][n - 1] << '\n';
    
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	int x; cin >> x;
	cout << ((x == 0) ? 1 : 0) << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

int main()
{
	int N = 0;
	std::map<std::string, int> S;

	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		std::string s;
		std::cin >> s;
		S[s]++;
	}
	//std::sort(S.begin(), S.end());

	int a = 0;
	for (auto itr = S.begin(); itr != S.end(); itr++)
	{
		a = std::max(a, itr->second);
	}

	for (auto itr = S.begin(); itr != S.end(); itr++)
	{
		std::string s = itr->first;
		if (itr->second == a){
			std::cout << s << std::endl;
		}
	}	
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <cstdlib> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N){cin>>A.at(i);}
  sort(all(A));
  rep(i,N){if((i<N-2)&&A.at(i)==A.at(i+1)==A.at(i+2)){A.at(i)=A.at(i+1)=0;}}
  int a=0,b=0;//aは0の数,bは二つ残ってる奴の数
  sort(all(A));
  rep(i,N){
    if(A.at(i)==0){a++;}
    else if(i<N-1&&A.at(i)==A.at(i+1)){b++;}}
  cout<<-b%2+N-a-b<<endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int r, g, b;
  cin >> r >> g >> b;
  cout << ((g * 10 + b) % 4 == 0 ? "YES" : "NO");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int a, ans;
    cin >> a;
    if (a % 2 == 0)
    {
        ans = a;
    }
    else
    {
        ans = 2 * a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
#define PIB pair<int,bool>
typedef long long ll;
using namespace std;
const int maxn=2e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-10;
int main()
{
	ll x,y,a,b,c,i,p[maxn]={0},q[maxn]={0},r[maxn]={0};
	scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
	for(i=1;i<=a;i++)scanf("%lld",&p[i]);sort(p+1,p+1+a);
	for(i=1;i<=b;i++)scanf("%lld",&q[i]);sort(q+1,q+1+b);
	for(i=1;i<=c;i++)scanf("%lld",&r[i]);sort(r+1,r+1+c);
	ll ans=0;
	for(i=a;i>a-x;i--)ans+=p[i];
	for(i=b;i>b-y;i--)ans+=q[i];
	ll l1=a-x+1,l2=b-y+1,l=c;
	while((p[l1]<r[l]||q[l2]<r[l])&&l>0)
	{
		if(l1>a&&l2>b)break;
		if(l1>a)
		{
			if(q[l2]<r[l])
			{
				ans=ans-q[l2]+r[l];l2++,l--;continue;
			}
			break;
		}
		if(l2>b)
		{
			if(p[l1]<r[l])
			{
				ans=ans-p[l1]+r[l];l1++,l--;continue;
			}
			break;
		}
		if(p[l1]<r[l]&&q[l2]<r[l])
		{
			if(p[l1]<q[l2])
			{
				ans=ans-p[l1]+r[l];
				l1++;l--;
			}
			else
			{
				ans=ans-q[l2]+r[l];
				l2++,l--;
			}
			continue;
		}
		if(p[l1]<r[l])
		{
			ans=ans-p[l1]+r[l];
			l--;l1++;continue;
		}
		ans=ans-q[l2]+r[l];
		l--;l2++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4992
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int ans = 0;

int int_sum(int n,int sum){
	vector<vector<int> > v(n+1, vector<int>(sum+1, 0));
	v[0][0] = 1;
	for (int i = 0;i <10;i++) {
		for (int j = n;j >= 1;j--) {
			for (int k = i;k <= sum;k++) {
				v[j][k] += v[j - 1][k - i];
			}
		}
	}
	return v[n][sum];
	
}
int main(){
	int n, sum;
	while (cin >> n >> sum) {
		if (n == 0 && sum == 0) break;
		else cout << int_sum(n, sum) << endl;
	}

	}
	

Measured memory_bytes: 1224
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''


S = input()

N = len(S)

# 右からi桁目までの余り
accum = [int(S[N - 1 - i]) for i in range(N)]

base = 1
for i in range(N-1):

    base*=10
    base %= 2019

    accum[i+1] = (accum[i] + base * accum[i+1]) % 2019






# 余りの整理
count = [0] * 2019

for a in accum:
    count[a] += 1



# ペア数のカウント
ans = 0
for c in count:
    ans += (c*c - c)/2

ans += count[0]

print(int(ans))

Measured memory_bytes: 18072
import sys
from random import randint
from datetime import datetime

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]

def randomize(n):
    return [ randint(1, 26) for _ in range(n) ]

def get_now():
    dt = datetime.now()
    return dt.second + dt.microsecond/1000000

def main():
    start = get_now()
    end = get_now()
    # 開催日数
    D = ii()
    # 満足度の下がりやすさ
    C = lmi()
    # 得られる満足度
    S = lmif(D)
    # 最後に開かれた日付
    last = [0]*26
    # 開催するコンテスト
    T = [ i%26+1 for i in range(D) ]

    def scoring():
        score = 0
        for i in range(D):
            score += S[i][T[i]-1]
            for j in range(26):
                score -= C[j] * (i - last[j])
        return score

    max_score = 0
    ans = T.copy()
    while end - start < 1.9:
        T = randomize(D)
        score = scoring()
        if max_score < score:
            ans = T.copy()
        # print(*T, score)
        end = get_now()
    print(*ans, sep='\n')

main()


Measured memory_bytes: 9820
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int int64_t
#define ALL(a) (a).begin(),(a).end()
signed main(){
  int N,M;
  cin>>N>>M;
  int X=N-2,Y=M-2;
  if(X<0)
    X=1;
  if(Y<0)
    Y=1;
  cout<<X*Y<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=1;
    int m=n;
    while(1){
        if(m%360==0){
            cout<<ans<<endl;
            return 0;
        }
        ans++;
        m+=n;
        m%=360;
    }
}


Measured memory_bytes: 3588