akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use std::io::*;
use std::str::*;
use std::collections::BinaryHeap;


macro_rules! get{
    ($t:ty) => {
        {
            let cin = stdin();
            let mut cin = cin.lock();
            
            let token =
                cin.by_ref().bytes().map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<$t>().ok()
        }
    }
}

macro_rules! input{
    ($($id:ident: $t:ty),*) => {
        $(
            let $id = get!($t).unwrap();
        )*;
    }
}

macro_rules! input_vec{
    ($id:ident: Vec<$t:ty>, $n:expr) => {
        let $id = (0..$n).map(|_| get!($t).unwrap()).collect::<Vec<$t>>();
    }
}

fn solve(n: u32, m: u32, a: Vec<u64>){
    let mut heap = BinaryHeap::new();

    for x in a {
        heap.push(x);
    }

    for _ in 0..m {
        match heap.pop() {
            Some(x) => {
                heap.push(x / 2);
            },
            None => ()
        }
    }

    let ans: u64 = heap.into_vec().iter().sum();
    println!("{}", ans);
}



fn main(){
    input!(n: u32, m: u32);
    input_vec!(a: Vec<u64>, n);

    solve(n,m,a);
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;


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

    int P[N];
    for(int i=0; i<N; i++){
        cin >> P[i];
    }

    int ans = 0;
    int last = 100000000;
    for(int i=0; i<N; i++){
        if(last >= P[i]){
            ans += 1;
            last = P[i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
 
vector<ll> dijkstra(int N, vector<vector<edge> >& G, int s) {
	vector<ll> d(N, LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
	return d;
}
 
int main() {
	int N, M; cin >> N >> M;
	vector<int> a(M), b(M), c(M);
	vector<vector<int> > cs(N);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		a[i]--; b[i]--;
		cs[a[i]].push_back(c[i]);
		cs[b[i]].push_back(c[i]);
	}
	int n = N;
	vector<vector<int> > index(N);
	for (int u = 0; u < N; u++) {
		sort(cs[u].begin(), cs[u].end());
		cs[u].erase(unique(cs[u].begin(), cs[u].end()), cs[u].end());
		for (int k = 0; k < cs[u].size(); k++)
			index[u].push_back(n + k);
		n += cs[u].size();
	}
	vector<vector<edge> > G(n);
	for (int i = 0; i < M; i++) {
		int x = index[a[i]][lower_bound(cs[a[i]].begin(), cs[a[i]].end(), c[i]) - cs[a[i]].begin()];
		int y = index[b[i]][lower_bound(cs[b[i]].begin(), cs[b[i]].end(), c[i]) - cs[b[i]].begin()];
		G[x].push_back(edge{y, 0});
		G[y].push_back(edge{x, 0});
	}
	for (int u = 0; u < N; u++)
		for (int k = 0; k < cs[u].size(); k++) {
			int x = index[u][k];
			G[u].push_back(edge{x, 1});
			G[x].push_back(edge{u, 0});
		}
	vector<ll> d = dijkstra(n, G, 0);
	ll mi = LLONG_MAX;
	for (int k = 0; k < cs[N - 1].size(); k++)
		mi = min(mi, d[index[N - 1][k]]);
	if (mi == LLONG_MAX) mi = -1;
	cout << mi << endl;
}

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

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int a){
  Node *y=NIL, *x=root, *z;
  z = (Node *)malloc(sizeof(Node));
  z->key=a;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node *p){
  if(p==NIL) return;
  inorder(p->left);
  cout << " " << p->key;
  inorder(p->right);
}

void preorder(Node *p){
  if(p==NIL) return;
  cout << " " << p->key;
  preorder(p->left);
  preorder(p->right);
}

int main(){
  int n,x;
  string str;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> str;
    if(str=="insert"){
      cin >> x;
      insert(x);
    }
    else if(str=="print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 26584
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int N, A;
	cin >> N >> A;

	cout << N * N - A << endl;

}

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

bool isPrime(int x) {
  if (x <= 1) {
    return false;
  }
  for (int i=2; i*i<=x; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
  int count = 0;
	for (int i=0; i<n; ++i) {
		int x;
		cin >> x;
    if (isPrime(x)) {
      ++count;
    }
	}
  cout << count << endl;

  return 0;
}



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

using namespace std;


#define DEBUG false

#define LL long long int 

#define watch(x) if(DEBUG) cout << (#x) << " is " << (x) << endl

const int MAX = 1e6 + 6;
const int MOD = 1e9 + 7;

int dp[101][101][101];

int a, b, c;

int func(int x, int y, int z) {
	
	if((x < a) || (y < b) || (z < c)) return INT_MAX;
	

	if((x == a) && (y == b) && (z == c)) return 0;

	if(dp[x][y][z] != -1) return dp[x][y][z];

	int result = INT_MAX;

	int value;

	value = func(x-1, y-1, z);
	if(value != INT_MAX) result = min(result, 1 + value);

	value = func(x, y-1, z-1);
	if(value != INT_MAX) result = min(result, 1 + value);
	

	value = func(x-1, y, z-1);
	if(value != INT_MAX) result = min(result, 1 + value);
	

	value = func(x-2, y, z);
	if(value != INT_MAX) result = min(result, 1+ value);


	value = func(x, y-2, z);
	if(value != INT_MAX) result = min(result, 1+ value);


	value = func(x, y, z-2);
	if(value != INT_MAX) result = min(result, 1+ value);
	
	return dp[x][y][z] = result;
}

int main() {

	memset(dp, -1, sizeof(dp));

	cin>>a>>b>>c;


	int result = INT_MAX;

	result = min(result, func(a, a, a));
	result = min(result, func(a+1, a+1, a+1));
	result = min(result, func(b, b, b));
	result = min(result, func(b+1, b+1, b+1));
	result = min(result, func(c, c, c));
	result = min(result, func(c+1, c+1, c+1));

	cout<<result<<endl;

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair


struct Union_Find
{
    vector <int> parent;
    Union_Find(int N) : parent(N)
    {
        for(int i = 0; i < N; i++) parent[i] = i;
    }
    int root(int n)
    {
        if (parent[n]==n) return n;
        else
        {
            return root(parent[n]);
        }
    }

    void unite(int i,int j)
    {
        int rx,ry;
        rx=root(i);
        ry=root(j);
        if (rx==ry) return;
        else
        {
            
            if (rx<ry)
            {
                parent[ry]=rx;
                return;
            }
            else
            {
                parent[rx]=ry;
                return;
            }
        }
    }
    bool same(int i, int j)
    {
        if (root(i)==root(j)) return true;
        else return false;
    }
};

int main()
{
    int N;
    while (true)
    {
        cin >> N;
        if (N==0) break;
        priority_queue<pair<double,pair<int,int>>,vector<pair<double,pair<int,int>>>,greater<pair<double,pair<int,int>>>> que;
        vector<tuple<double,double,double,double>> cells(N);
        double x,y,z,r;
        for (int i=0;i<N;i++)
        {
            cin >> x >> y >> z >> r;
            cells[i]=make_tuple(x,y,z,r);
        } 
        for (int i=0;i<N;i++)
        {
            for (int j=i+1;j<N;j++)
            {
                double x1,x2,y1,y2,z1,z2,r1,r2;
                x1=get<0>(cells[i]);
                y1=get<1>(cells[i]);
                z1=get<2>(cells[i]);
                r1=get<3>(cells[i]);
                x2=get<0>(cells[j]);
                y2=get<1>(cells[j]);
                z2=get<2>(cells[j]);
                r2=get<3>(cells[j]);
                double R=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
                R=R-r1-r2;
                if (R<0) R=0;
                que.push(mp(R,mp(i,j)));
            }
        }
        int a,b;
        Union_Find solve(N);
        double ans=0;
        while (!que.empty())
        {
            a=que.top().second.first;
            b=que.top().second.second;
            if (!solve.same(a,b))
            {
                solve.unite(a,b);
                ans+=que.top().first;
            }
            que.pop();
        }
        cout <<fixed <<setprecision(3) << ans << endl;
    }
return 0;
}



Measured memory_bytes: 3368
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    int n, m, cnt=0;
    int prob[110];
    int ans[110];

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> prob[i];
    }
    cin >> m;
    int index, val, sum;
    for(int j=0; j<m; j++){
        cin >> index >> val;
        index--; //0にあわせる

        int tmp = prob[index]; //一時的に保存

        prob[index] = val;
        for(int k=0; k<n; k++) sum += prob[k];

        ans[cnt] = sum;
        prob[index] = tmp;
        sum = 0; cnt++;
    }

    for(int l=0; l<cnt; l++){
        cout << ans[l] << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

constexpr int MOD = 1000000007;

int mod(ll x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(ll x,ll m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 200005;
    int fact[N];
    fact[0] = 1;
    FOR(i,1,N) fact[i] = modm(fact[i-1],i);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int ha = h - a, wb = w-b;

    vector<int> v(ha);

    auto comb = [&](int x,int y) {
        int ret = fact[x]; ret = modd(ret,fact[y]); ret = modd(ret,fact[x-y]); return ret;
    };

    int ans = 0;
    REP(i,v.size()) {
        // 下+右の個数から下を選ぶ個数（列ごと）
        v[i] = modm(comb(i+b-1,i),comb(h-i-1+wb-1,h-i-1));
        ans = mod(ans + v[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
	int matrix[100][100];
	int vector[100];
	int vector2[100];
	int n,m;
	cin>>n >>m;
	for(int i=0;i<n;i++){
		for(int k=0;k<m;k++){
			cin >> matrix[i][k];
		}
	}
	for(int i=0;i<m;i++){
		cin >> vector[i];
	}
	//input end
	//caliculation start
	
	
	for(int i=0;i<n;i++){
		int x=0;
		for(int k=0; k<m ;k++){
			x += matrix[i][k]*vector[k];
		}
		vector2[i] = x;
	}
    //	caliculation end;
	//output
	for(int i=0;i<n;i++){
		cout<< vector2[i] <<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



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

  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  ll mod = 1e9+7;
  for(ll i = k; i<=n+1; i++){
    ans += (n-i+1)*i +1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
    

}


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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define precise(x) cout<<fixed<<setprecision(12)<<x
#define test cout<<"#";

const ll INF = 1e18L + 5;

ll ans[3001][3001][2];
ll solve(vector<ll> &v, ll s, ll e, ll turn)
{
	if(s>e)
		return 0;
	if(ans[s][e][turn]!=-1)
		return ans[s][e][turn];
	if(turn == 0)
		return ans[s][e][turn] = min(solve(v, s+1, e, 1), solve(v, s, e-1, 1));
	else
		return ans[s][e][turn] = max(solve(v, s+1, e, 0)+v[s-1], solve(v, s, e-1, 0)+v[e-1]);	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n);
	ll sum = 0;
	for(ll x = 0; x < n; x++)
	{
		cin>>v[x];
		sum+=v[x];
	}
	memset(ans, -1, sizeof(ans));
	ll x = solve(v, 1, n, 1);
	ll y = sum-x;
	cout<<x-y;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
 
int h, w;
int ch, cw;
int dh, dw;
string s[1005];
int dp[1005][1005];
 
void init_dp() {
  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      dp[i][j] = -1;
    }
  }
}

bool pos_ok(int cur_i, int cur_j) {
  if ( cur_i < 0 || h <= cur_i ) { return false; }
  if ( cur_j < 0 || w <= cur_j ) { return false; }
  if ( s[cur_i][cur_j] == '#' )  { return false; }
  if ( dp[cur_i][cur_j] != -1 )  { return false; }
  return true;
}
 
int main() {
  cin >> h >> w;
  cin >> ch >> cw; ch--; cw--;
  cin >> dh >> dw; dh--; dw--;
  for ( int i = 0; i < h; i++ ) { cin >> s[i]; }
 
  init_dp();

  deque<pair<int, int>> dq;
  deque<int> dist;
  dq.push_back(make_pair(ch, cw));
  dist.push_back(0);
  while ( dp[dh][dw] == -1 && !dq.empty() ) {
    int cur_i = dq.front().first;
    int cur_j = dq.front().second;
    dq.pop_front();
    int wp = dist.front(); dist.pop_front();
    dp[cur_i][cur_j] = wp;
    // walk
    int dir_x[4] = {1, 0, -1, 0};
    int dir_y[4] = {0, 1, 0, -1};
    for ( int i = 0; i < 4; i++ ) {
      int now_i = cur_i + dir_x[i];
      int now_j = cur_j + dir_y[i];
      if ( pos_ok(now_i, now_j) ) {
        dq.push_front(make_pair(now_i, now_j));
        dist.push_front(wp);
      }
    }
    // warp
    for ( int i = cur_i-2; i <= cur_i+2; i++ ) {
      for ( int j = cur_j-2; j <= cur_j+2; j++ ) {
        if ( pos_ok(i, j) ) {
          dq.push_back(make_pair(i, j));
          dist.push_back(wp+1);
        }
      }
    }
  }
 
  cout << dp[dh][dw] << endl;
  return 0;
}


Measured memory_bytes: 14984
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include<cmath>
using namespace std;
int a[505][5];

int main()
{
   int n;
   scanf("%d",&n);
   for(int i=1;i<n;i++)
    for(int j=1;j<4;j++)
    scanf("%d",&a[i][j]);

   for(int i=1;i<=n-1;i++)
   {
       int ans=0;
       ans=ans+a[i][1]+a[i][2];
       for(int j=i+1;j<n;j++)
       {
           if(ans<a[j][2])
            ans=a[j][2];
           if(ans%a[j][3]!=0)
           {
               ans=(ans/a[j][3]+1)*a[j][3];
           }
           ans+=a[j][1];
       }
       printf("%d\n",ans);


   }
   cout<<0<<endl;


    return 0;
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://abc058.contest.atcoder.jp/tasks/abc058_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d %d", $a, $b, $c);

if ($b - $a == $c - $b) {
    echo "YES\n";
} else {
    echo "NO\n";
}


Measured memory_bytes: 4856
import heapq

K =int(input())

pque = []
for i in range(1, 10):
    heapq.heappush(pque, i)

for i in range(K):
    tmp = heapq.heappop(pque)
    if tmp % 10 == 0:
        heapq.heappush(pque, tmp * 10)
        heapq.heappush(pque, tmp * 10 + 1)
    elif tmp % 10 == 9:
        heapq.heappush(pque, tmp * 10 + 9)
        heapq.heappush(pque, tmp * 10 + 8)
    else:
        next_ = tmp % 10
        heapq.heappush(pque, tmp * 10 + next_ - 1)
        heapq.heappush(pque, tmp * 10 + next_)
        heapq.heappush(pque, tmp * 10 + next_ + 1)

print (tmp)
         
        
        

Measured memory_bytes: 11796
#include<stdio.h>
    #include<string.h>
    int main(void){
    int A,B,C,D,E,N,M,x,y,i,j,cou=0,cou2=99999999,v[1000000],w[1000000],min_i,en=0;
        char S[100],W[100],s[10],X,Y;
    scanf("%s",&S);
    A=strlen(S);
    for(i=0;i<A-2;i++){
        cou=(S[i]-48)*100+(S[i+1]-48)*10+S[i+2]-48;
        if(cou<753){
        if((753-cou)<cou2){
            cou2=753-cou;
        }}else{
            if((cou-753)<cou2){
            cou2=cou-753;
        }
        }
    }
    printf("%d",cou2);
    return 0;
    }

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

        String s = sc.nextLine();

        s = s.replaceAll("eraser",  "-");
        s = s.replaceAll("erase",   "-");
        s = s.replaceAll("dreamer", "-");
        s = s.replaceAll("dream",   "-");
        s = s.replaceAll("-", "");

        if (s.equals("")) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 30632
import copy
N = int(input())
A = [int(input()) for _ in range(N)]

max_A = max(A)
B = copy.deepcopy(A)
B.remove(max_A)
max_B = max(B)
#print(max_A, max_B)

for i in range(N):
    if A[i] == max_A:
        print(max_B)
    else:
        print(max_A)

Measured memory_bytes: 14568
N, M = map(int, input().split())
cake = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
cake.sort(key=lambda x: x[0] + x[1] + x[2], reverse=True)
ans = max(ans, sum([x[0] + x[1] + x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: x[0] + x[1] - x[2], reverse=True)
ans = max(ans, sum([x[0] + x[1] - x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: x[0] - x[1] + x[2], reverse=True)
ans = max(ans, sum([x[0] - x[1] + x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: -x[0] + x[1] + x[2], reverse=True)
ans = max(ans, sum([-x[0] + x[1] + x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: x[0] - x[1] - x[2], reverse=True)
ans = max(ans, sum([x[0] - x[1] - x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: -x[0] - x[1] + x[2], reverse=True)
ans = max(ans, sum([-x[0] - x[1] + x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: -x[0] + x[1] - x[2], reverse=True)
ans = max(ans, sum([-x[0] + x[1] - x[2] for x in cake[0:M]]))
cake.sort(key=lambda x: -x[0] - x[1] - x[2], reverse=True)
ans = max(ans, sum([-x[0] - x[1] - x[2] for x in cake[0:M]]))

print(ans)


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(LL i = (l)    ; i <  (r); i++) // LL
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define SI(v) static_cast<int>(v.size())

int main() {
	LL n, k;
	cin >> n >> k;
	
	vector<pair<LL, LL>> v(n);
	inc(i, n) { cin >> v[i].FI >> v[i].SE; }
	sort(RALL(v));
	
	vector<LL> x, y;
	inc(i, SI(v)) { (i == 0 || v[i].FI != v[i - 1].FI ? x : y).PB(v[i].SE); }
	sort(RALL(x));
	sort(RALL(y));
	
	vector<LL> sx(SI(x) + 1);
	vector<LL> sy(SI(y) + 1);
	inc(i, SI(x)) { sx[i + 1] = sx[i] + x[i]; }
	inc(i, SI(y)) { sy[i + 1] = sy[i] + y[i]; }
	
	LL ans = 0;
	incII(i, 0, k) {
		if(i > SI(x) || k - i > SI(y)) { continue; }
		setmax(ans, sx[i] + sy[k - i] + i * i);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
	int a,b,c,p=0;
	int x[20];
	int s=1;
	cin>>a>>b;
	if(a<=0&&b>=0)
	cout<<"Zero"<<endl;
	if(a>0&&b>0)
	cout<<"Positive"<<endl;
	if(a<0&&b<0)
	{
		for(int i=a;i<=b;i++)
		{
			if(i<=b) p++;
		}
		if(p%2==0)
		cout<<"Positive"<<endl;
		 else cout<<"Negative"<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    S = list(input().strip("\n"))
    N = len(S)
    mod = 2019
    D = [0] * (N + 1)
    D[N] = 0
    D[N-1] = int(S[N-1])
    modType = dict()
    modType[D[N-1]] = 1
    modType[0] = 1
    ans = 0
    for i in reversed(range(N - 1)):
        D[i] = (D[i + 1] + int(S[i]) * pow(10, N - i - 1, mod)) % mod
        if D[i] in modType:          
            ans += modType[D[i]]   
            modType[D[i]] += 1
        else:
            modType[D[i]] = 1
    print(ans)
    #print(D)
    
    return 0

if __name__ == "__main__":
    solve()

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


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a < b && b < c) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

int main()
{
  int n,x;
  cin>>n>>x;
  
  int l[n];
  for(int i= 0;i<n;i++){
    cin>>l[i];
  }
    
  int d = 0;
   int cnt = 1;
   for(int i  =2;i<=n+1;i++){
     d = d + l[i-2];
     if(d <=x)
       cnt++;
   }
    cout<<cnt;
    return 0;
  }

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

int main()
{
    cin.tie(0);
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<(int) s.length();i++){
        if(s[i]=='x') ans++;
    }
    if(ans<8) cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	int a,b,c=9;
	string s;
	while(c--){
		cin>>s>>a>>b;
		cout<<s<<' '<<a+b<<' '<<a*200+b*300<<endl;
	}
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 15) {
    cout << '+' << endl;
  }else if(a * b == 15) {
    cout << '*' << endl;
  }else {
    cout << 'x' << endl;
  }
}


Measured memory_bytes: 764
#include "bits/stdc++.h"

using namespace std;
static const int INF =(1<<21);


int main(){	
	int N, A[10],d=1,cnt=1;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		cnt *= 3;
		if (A[i] % 2 == 0) d *= 2;
	}
	cout << cnt-d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n;
if(n<=1000)
cout<<1000-n<<endl;
else{
k=n%1000;
if(k==0)
cout<<k<<endl;
else
cout<<1000-k<<endl;
}
}

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def calc(n):
    ans=0
    tmp=0
    c=1
    while(1):
        tmp+=c
        if tmp>n:
            break
        ans=c
        c+=1
    return ans

L=factorization(N)
if N==1:
    print(0)
    exit()
ans=0
for i in range(len(L)):
    val=L[i][0]
    cnt=L[i][1]
    ans+=calc(cnt)

print(ans)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    ll h;cin >> h;
    if(h == 1){
        cout << 1 << endl;
        return 0;
    }
    if(h % 2 != 0)h--;

    ll p;
    for(int i=1;;i++){
        if((ll)pow(2,i) == h){
            p = i;
            break;
        }else if((ll)pow(2,i) > h){
            i--;
            p = i;
            break;
        }
    }

    ll ans = 1;
    for(int i=1;i<=p;i++){
        ans += pow(2,i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int i,a,b,c;
    scanf("%d",&i);
    for(;i!=0;i--){
        scanf("%d%d%d",&a,&b,&c);
        if(a*a+b*b==c*c){
            printf("YES\n");
        }
        else if(a*a+c*c==b*b){
            printf("YES\n");

        }
        else if(b*b+c*c==a*a){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N+1);
    for(int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        a.at(x)++;
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < K; ++i) {
        N -= a.at(i);
    }
    if(N <= 0) N = 0;
    cout << N << endl;

}

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

int main(){
    int N, M;
    cin >> N >> M;
    int k[M];
    vector<vector<int>> s(M);
    vector<int> p(M);
    for(int i=0; i<M; i++){
        cin >> k[i];
        s[i].resize(k[i]);
        for(int j=0; j<k[i]; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,M) cin >> p[i];

    int ans=0;
    for(int i=0; i<(1<<N); i++){
        bool ok = true;
        for(int j=0; j<M; j++){
            int c=0;
            for(int id : s[j]){
                if((i >> id) & 1){
                    c++;
                }
            }
            c%=2;
            if(c != p[j]){
                ok = false;
            }
        }
        if(ok){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private fun solve() {
    val n = nextInt()
    val s = next()
    var res = 0
    for (i in 0 until n) {
        if (s[i] != 'A') {
            continue
        }
        if (i + 2 < n && s[i + 1] == 'B' && s[i + 2] == 'C') {
            ++res
        }
    }
    println(res)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 31256
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define INF 1e18
#define EPS 1e-9
#define bitcount __builtin_popcount
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define LSOne(S) (S & (-S))
#define PI acos(-1.0)
#define P(x) cout << #x << " = { " << x << " }\n"
#define tests()  \
    int tttt;    \
    cin >> tttt; \
    while (tttt--)
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
typedef long long ll;
int dcmp(long double x, long double y)
{
    return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
const int MAX = 1e5 + 10;
int n, m;
int dp[MAX];
vector<vector<int>> adj;
bool vis[MAX];
void read();
void solve();
void clear();
void dfs(int node);
int main()
{
#ifndef ONLINE_JUDGE
    file_IO;
#else
    fast_IO;
#endif

    solve();
}
void read()
{
    cin >> n >> m;
    adj = vector<vector<int>>(n);
    lp(i, m)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
    }
}
void clear()
{
    clr(dp, -1);
}
void solve()
{
    read();
    //clear();
    lp(i, n)
    {
        if (!vis[i])
            dfs(i);
    }
    cout << *max_element(dp, dp + n) << '\n';
}
void dfs(int node)
{
    vis[node] = 1;
    if (adj[node].size() == 0)
    {
        dp[node] = 0;
        return;
    }
    int mx = 0;
    rep(i, adj[node])
    {
        int child = adj[node][i];
        if (!vis[child])
        {

            dfs(child);
            mx = max(mx, dp[child] + 1);
        }
        else
        {
            mx = max(mx, dp[child] + 1);
        }
    }

    dp[node] += mx;
}

Measured memory_bytes: 12428
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		println(readInt() == 2 || readInt() == 2 ? "No" : "Yes");
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 21332
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

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

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=3100;
const int inf=0x3f3f3f3f;
const int mod=1000000007;

int n;
ll f[Maxn][Maxn],a[Maxn];

signed main() {
//	freopen("test.in","r",stdin);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++) {//[j-i+1,j]
			int l=j-i+1,r=j,len=n-i;
			f[l][r]=max(a[l]-f[l+1][r],a[r]-f[l][r-1]);
		}
	printf("%lld",f[1][n]);
	return 0;
}



Measured memory_bytes: 73856
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int x, i = 0;
        while(true) {
            x = sc.nextInt();
            if(x == 0) break;
            System.out.println("Case " + (++i) + ": " + x);
        }
    }
}



Measured memory_bytes: 42132
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x < 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(y) - abs(x)
        x += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x > 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(x) - abs(y)
        x += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

vector <ll> v(25);
vector <ll> c(25);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    ll N;
    cin >> N;

    for(ll i=0; i<N; i++)
    {
        cin >> v[i];
    }

    for(ll i=0; i<N; i++)
    {
        cin >> c[i];
    }      

    ll ans = 0;
    for(ll i=0; i<N; i++)
    {
        if(v[i]>c[i])
        {
            ans+=(v[i]-c[i]);
        }
    }   

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1234567;
int main(){
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int s = 0;
	while(n--){
		int l = 0, r = 0;
		cin>>l>>r;
		if(r==0)r = l;
		s  = s+ (r - l)+1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    vector<bool>v(201);
    v[3*5*7]=1;
    v[3*5*11]=1;
    v[3*3*3*5]=1;
    v[3*3*3*7]=1;
    v[3*5*13]=1;
    int n;
    cin>>n;
    cout<<accumulate(v.begin(),v.begin()+1+n,0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, l;
  int sum = 0;
  int i, j, k;
  
  scanf("%d %d", &n, &l);
  
  if (l >= 0)
    j = 2, k = n;
  else if (l + n - 1 <= 0)
    j = 1, k = n - 1;
  else
    j = 1, k = n;
  
  for (i = j; i <= k; i++)
    sum += l + i - 1;
  
  printf("%d", sum);
  
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  long counter = 0;
  for (int i = 0; i <= (s.size()-1)/2; i++){
    if (s[i] == 'p') counter--;
  }
  for (int i = (s.size()+1)/2; i < s.size(); i++){
    if (s[i] == 'g') counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, A, B;

int main(void){
    
    scanf("%d %d %d", &N, &A, &B);
    
    int ans = 0;
    for(int i = 1; i <= N; ++i){
        string temp = to_string(i);
        int sum = 0;
        for(int i = 0; i < temp.size(); ++i) sum += temp[i] - '0';
        if(A <= sum && sum <= B) ans += i;
    }
    printf("%d\n", ans);
	
    return 0;
}


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

for i in range(N):
  A[i]=A[i]-i
  

A.sort()

if len(A)%2!=0:
  b=A[len(A)//2]
else:
  b=(A[len(A)//2]+A[len(A)//2-1])//2
  
ans=0
for i in range(N):
  ans+=abs(A[i]-b)
print(ans)
  


Measured memory_bytes: 26836
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int N,S[110];
	int bob=0;
	int alice=0;
	
	cin>>N;
	for(int i = 0;i<N;i++)
	{
		cin>>S[i];
	}
	sort(S,S+N,greater<int>());
	for(int i = 0;i<N;i++){
		if(i%2==0)
		{
		alice +=S[i];
		}
		else
		{
		bob +=S[i];
		}
	}

	
	

 cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
#include<cstdlib>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x=a+b,y=b+c,z=c+a;
  if(c==x||a==y||b==z){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  

  return 0;
  
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	static Scanner sc;
	static int num;
	static int dp[] = new int[31];
	
	public static void main(String[] args) {
		
		new Main();
	}
	
	Main(){
		
		dp[1]=1;
		dp[2]=2;
		dp[3]=4;
		
		for(int i=4; i<=30; i++){
			dp[i]=dp[i-1] + dp[i-2] + dp[i-3];
		}
		
		sc = new Scanner(System.in);
		
		solve();
		
	}	
	void solve(){
		
		while (sc.hasNext()) {
			
			num = sc.nextInt();;
			
			if(num==0) break;
			
			System.out.println((dp[num]/3650)+1);
		}
	}
}

Measured memory_bytes: 17192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vvl vector<vl>

int main() {

    ll N;
    cin >> N;

    vl A(20);
    vvl x(20, vl(20)), y(20, vl(20));
    ll tx, ty;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> tx >> ty;
            x[i][j] = tx - 1;
            y[i][j] = ty;
        }
    }

    ll num = 1;
    for (int i = 0; i < N; i++) {
        num *= 2;
    }

    ll tn, ti;
    int B[20];
    string ts;
    ll ans = 0;
    ll t_ans;
    bool is_ok;

    for (ll i = 0; i < num; i++) {
        ts = bitset<20>(i).to_string();
        for (int j = 0; j < N; j++) {
            if (ts[19 - j] == '1') B[j] = 1;
            else B[j] = 0;
        }

        is_ok = true;
        for (int j = 0; j < N; j++) {
            if (B[j] == 1) {
                for (int k = 0; k < A[j]; k++) {
                    if (B[x[j][k]] != y[j][k]) {
                        is_ok = false;
                        break;
                    }
                }
            }
        }

        if (is_ok) {
            t_ans = 0;
            for (int j = 0; j < N; j++) {
                t_ans += B[j];
            }
            ans = max(ans, t_ans);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin>>a>>b;
	int d[3]={0, 0, 0};
	for(int i=0;i<3;i++)
	{
		if(a==i+1||b==i+1)
		{
			d[i]=1;
		}
	} 
	for(int i=0;i<3;i++)
	{
	 	if(d[i]==0)
	 	{
	 		cout<<i+1<<endl;
	 		return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    cin >> N;
    cout << N*N*N << endl;
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  int counter = 0;
  for (int i = 100; 1 <= i; i--) {
    if (A % i == 0 && B % i == 0) counter++;
    if (counter == K) {
      cout << i << endl;
      return 0;
    }
  }
}


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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

int needed_kaisu(long long a, long long N, long long *A) {
	int count = 0;
	for (long long i = 0; i < N; i++) {
		count += (A[i]+a-1) / a -1;
	}
	return count;
}


int main() {


	int N,X,T,ans;

	cin >> N >> X >> T;
	ans = ((N-1)/X+1)*T;
	cout << ans;

	cin >> N;

	return 0;


}



Measured memory_bytes: 3608
#include<stdio.h>
int main(){
	
	int a,b,c,i;
	int d=0;
	
	scanf("%d %d %d\n",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		if(c%i==0){
			d++;
		}
	}
	
	printf("%d\n",d);
	
	return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

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

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

    int res = 0;
    for (map<int, int>::iterator i = cnt.begin(); i != cnt.end(); i++) {
        if (i->first > i->second) {
            res += i->second;
        } else {
            res += i->second - i->first;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
using namespace std;

int n,tep,num1,num2;
string s;
char ch1[10000],ch2[10000];

int main()
{
	cin>>n;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='(')tep++;
		if(s[i]==')')tep--;
		if(tep<0)
		{
			ch1[++num1]='(';
			tep++;
		}
	}
	while(tep>0)
	{
		tep--;
		ch2[++num2]=')';
	}
	for(int i=1;i<=num1;i++)putchar(ch1[i]);
	for(int i=0;i<s.length();i++)putchar(s[i]);
	for(int i=1;i<=num2;i++)putchar(ch2[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
long sum(long);
long sum(long n) {
    if (n == 0)
        return 0;
    return n / 5 + sum(n / 5);
}
 
int main()
{
    long n;
    cin >> n;
    if ((n & 1) == 0)
        n = sum(n/10)+n/10;
    else
        n = 0;
    cout << n << endl;
 }

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;

    int count=0;
    for (int i = a; i <= b; i++) {
        string s;
        s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector


// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    char s[n+1],t[n+1];
    scanf("%s %s", s,t);
    char ans[2*n+1];
    int i,j=0;
    for(i=0;i<n;i++){
        ans[j++]=s[i];
        ans[j++]=t[i];
    }
    ans[j]='\0';
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    using namespace std;
    #define INF 10000000;
     
    int main() {
        int k,s,cnt = 0;
        cin >> k >> s;

        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-x-y;
              	//cout <<z<<endl;
                if(z<=k && z>=0)cnt++;
            }
        }
        cout << cnt <<endl;
    }

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

#define	mp			make_pair
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

pair<bool,string> subst(const string &s,const string &a,const string &b){
	int slen=s.length(),alen=a.length();
	string t;
	bool changed=false;
	rep(i,slen){
		int cnt=0;
		if(i+alen<=slen)rep(j,alen){
			if(s[i+j]!=a[j])	break;
			cnt++;
		}
		if(cnt==alen)	t+=b,i+=alen-1,changed=true;
		else			t+=s[i];
	}
	return mp(changed,t);
}

int main(){
	for(int n;cin>>n,n;){
		string a[10],b[10];
		rep(i,n)	cin>>a[i]>>b[i];
		string src,dst;	cin>>src>>dst;

		int ans=-1;
		queue< pair<int,string> > qu;	qu.push(mp(0,src));
		while(!qu.empty()){
			pair<int,string> d=qu.front();	qu.pop();
			int cnt=d.first;
			string s=d.second;
			if(s==dst){ ans=cnt; break; }
			if(s.length()>=dst.length())	continue;

			rep(i,n){
				pair<bool,string> ret=subst(s,a[i],b[i]);
				if(ret.first)	qu.push(mp(cnt+1,ret.second));
			}
		}

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0