akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <set>

std::multiset<int> edges[100005];

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    int A,B;
    scanf("%d %d",&A,&B);
    A--,B--;
    edges[A].insert(B);
    edges[B].insert(A);
  }
  for(int i=0;i<N;i++){
    if(edges[i].size()&1){
      printf("No\n");
      return 0;
    }
  }
  std::vector<int> four;
  for(int i=0;i<N;i++){
    if(edges[i].size()>=6){
      printf("Yes\n");
      return 0;
    }
    if(edges[i].size()==4){
      four.push_back(i);
    }
  }
  if(four.size()>=3){
    printf("Yes\n");
    return 0;
  }else if(four.size()<=1){
    printf("No\n");
    return 0;
  }
  for(int i=0;i<N;i++){
    if(edges[i].size()==2){
      int A=*edges[i].begin();
      int B=*edges[i].rbegin();
      edges[A].erase(edges[A].find(i));
      edges[B].erase(edges[B].find(i));
      edges[A].insert(B);
      edges[B].insert(A);
    }
  }
  if(edges[four[0]].count(four[0])){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 14336
#include <stdio.h>

int main(){
	
	int x, y, i = 1;
	
	while(1){
		scanf("%d", &x);
		scanf("%d", &y);
		if(x == 0&& y == 0)
			break;
		if(x <= y)
			printf("%d %d\n",x ,y);
		else
			printf("%d %d\n",y ,x);
		i++;
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int res = 0;
		int barray[] = new int [m];
		for(int i = 0;i<m;i++) {
			barray[i] = sc.nextInt();
		}
		int array[][] = new int [n][m];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<m;j++) {
				array[i][j] = sc.nextInt();
			}
		}
		for(int i = 0;i<n;i++) {
			int sum = 0;
			for(int j = 0;j<m;j++) {
				sum += array[i][j]*barray[j];
			}
			if(sum+c>0) res++;
		}
			System.out.println(res);
		sc.close();
	}
	public static void main(String[] args) {
		solve();

	}

}

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

using namespace std;

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

long long find_gcd(int  a,  int  b,  int  c){
    long long result = a;
    result = gcd(b, result);
    result = gcd(c, result);
    return result;
}


int main(){
    long long N;
    cin >> N;
    long long sum = 0;
    for(long long i = 1; i <= N; i++){
        for(long long j = 1; j <= N; j++){
            for(long long k = 1; k <= N; k++){
                sum += find_gcd(i, j, k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}


struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};} 
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(const modint& a);
  modint operator/(modint a) {return (*this)*inv(a);}
  modint& operator+=(modint a) {
    (num += a.num)%=MOD;
    return *this;
  }
  modint& operator-=(modint a) {
    *this=*this-a;
    return *this;
  }
  modint& operator*=(modint a) {
    (num*=a.num)%=MOD;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

int main(){
  int n,k; cin >>n >>k;
  vector<modint> dp(n,0),s(k,0);
  dp[0]=1;
  vector<pair<int,int>> p(k);
  rep(i,k){
    int a,b; cin >>a >>b;
    p[i]={a,b};
  }
  rep(i,n-1){
    modint leap=0;
    rep(j,k){
      if(i+1-p[j].first>=0) s[j]+=dp[i+1-p[j].first];
      if(i-p[j].second>=0) s[j]-=dp[i-p[j].second];
      leap+=s[j];
    }
    dp[i+1]+=leap;
  }
  print(dp[n-1]);
}


Measured memory_bytes: 4840
s = list(input())
q = int(input())
front = []
end = []
flip = False
for i in range(q):
    x = input()
    if x == "1":
        flip = flip ^ True
    else:
        z,f,c = x.split()
        f = bool(int(f)-1)
        if flip ^ f:
            end.append(c)
        else:
            front.append(c)
if flip:
    s = s[::-1]
    ans = end[::-1] + s + front
else:
    ans = front[::-1] + s + end
print("".join(ans))

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

int main(){
	int sum,mus,a,b,c,d;
	cin >> a >> b >> c >> d;
	sum =a*b;
	mus=c*d;
	if (sum>=mus){
		cout << sum;
	}	
	else if(sum<mus){
		cout << mus;
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct UF{
	vector<int> p;
	vector<int> chg;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		chg.clear();
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		chg.push_back(a); chg.push_back(b);
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	vector<VI> g(m, VI(2));
	rep(i,m) cin >> g[i][0] >>g[i][1];
	vector<ll> ans(m);
	ll sp = (ll)n*(n-1)/2;
	ans[m-1] = sp;
	UF uf(n);
	VI old(n, 1);
	repr(i, m-1, 1){
		uf.unite(g[i][0]-1, g[i][1]-1);
		ll sk=0;
		//rep(i,n) if(uf.root(i)) sk += (ll)uf.size(i) * (uf.size(i) -1) /2;
		for(auto x :uf.chg){
			if(uf.p[x] < 0) sp -= (ll)uf.size(x) * (uf.size(x) -1) /2;
			if(old[x] >1)   sp += (ll)old[x] * (old[x]-1) /2;
			old[x] = uf.size(x);
		}
		ans[i-1] = sp;
	}
	
	for(auto x :ans){
		cout << x <<"\n";
	}
	return 0;
}



Measured memory_bytes: 8320
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S[10000];
string T;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> S[i];
  cin >> T;
  int b = 0, free = 0;
  rep(i, N) {
    string z = "", a = "";
    for (char c : S[i]) {
      if (c == '?') z += 'z';
      else z += c;
    }
    for (char c : S[i]) {
      if (c == '?') a += 'a';
      else a += c;
    }
    if (T >= a) {
      if (T <= z) free++;
      else b++;
    }
  }
  for (int i=b; i<=b+free; i++) {
    cout << i+1;
    if (i < b+free) cout << " ";
  }
  cout << "\n";
  return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    //if(u->key == k)return u;
    if(u->key < k) u=u->right;
    else u=u->left;
  }
return u;
 
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
   return  treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x = y->left;
  else x = y->right;

  if(x!=NIL)x->parent = y->parent;

  if(y->parent == NIL) root=x;
  else{
    if(y == y->parent->left)y->parent->left = x;
    else y->parent->right = x;
  }

  if(y!=z)z->key = y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  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 u){
  if(u->left!=NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)inorder(u->right);
			
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL)preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#!/usr/bin/perl

use strict;
use warnings;

my $c = <STDIN>;
chomp $c;
my @s = ('a' .. 'z');
my $n = @s;
for (my $i=0; $i<$n; $i++)
{
    if ($s[$i] eq $c)
    {
        my $ans = $s[$i+1];
        print "$ans\n";
        last;
    }    
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    string s, t;
    cin >> s >> t;
    map<char, char> mp;
    bool flag = true;
    for (int i = 0; i < s.length() && flag; i++)
    {
        if (mp.count(s[i]) == 0)
        {
            for (int j = 0; j < i; j++)
            {
                if (mp[s[j]] == t[i])
                {
                    flag = false;
                }
            }
            mp[s[i]] = t[i];
        }
        else
        {
            if (mp[s[i]] != t[i])
            {
                flag = false;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main() {
    string n;
    cin >> n;
    if((n[0]==n[1] && n[1]==n[2]) ||
       (n[1]==n[2] && n[2]==n[3])) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<ll, ll>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q;

#define pld pair<ld, ld>

ld dist(pld a, pld b){
	return sqrt(abs(a.f - b.f) * abs(a.f - b.f) + abs(a.s - b.s) * abs(a.s - b.s));
}

pld poz(ld dl, ld kat){
	return {sin(kat) * dl, cos(kat) * dl};
}

ld pi = acos(-1);

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

    ld a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << setprecision(12) << fixed << dist(poz(a, (c/12 + d/(12*60))*2*pi), poz(b, (d/60) * 2 * pi)) << '\n';
}   	

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

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

using namespace std;

using int64 = int64_t;

struct UnionFind {
  vector<int> p;
  vector<int> sz;
  UnionFind(int n) {
    p.resize(n, -1);
    sz.resize(n, 1);
  }

  int find(int x) {
    if (p[x] == -1) {
      return x;
    } else {
      return p[x] = find(p[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] > sz[y]) swap(x, y);
    sz[y] += sz[x];
    p[x] = y;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sz[find(x)];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> to[n];
  UnionFind uf(n);
  rep(_, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  rep(_, k) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  vector<int> ans(n);
  rep(i, n) {
    ans[i] = uf.size(i);
    ans[i]--;
    for (auto&& e : to[i]) {
      if (uf.same(i, e)) ans[i]--;
    }
  }
  cout << ans[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << ans[i];
  }
  return 0;
}

Measured memory_bytes: 10992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
int dp[1050][1050];
int dir[4][2]={{-1,0},{1,0},{0,1},{0,-1}};
char in[1050][1050];
int vis[1050][1050];
queue<pair<int,int> >qs,q;

int n,m;

void dfs(int x,int y){
	if(vis[x][y])return;
	vis[x][y]=1;
	q.push({x,y});
	for(int i=0;i<4;i++){
		if(x+dir[i][0]>=1&&x+dir[i][0]<=n&&y+dir[i][1]>=1&&y+dir[i][1]<=m){
			if(in[x+dir[i][0]][y+dir[i][1]]=='#')continue;
			dfs(x+dir[i][0],y+dir[i][1]);
		}
	}
}
void solve(int T){
	scanf("%d %d",&n,&m);
	int sx,sy,ex,ey,nowx,nowy,tmpx,tmpy;
	scanf("%d %d %d %d",&sx,&sy,&ex,&ey);
	qs.push({sx,sy});
	for(int i=1;i<=n;i++)scanf("%s",in[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j]=INF;
		}
	}
	dp[sx][sy]=0;
	while(!qs.empty()){
		nowx=qs.front().first;
		nowy=qs.front().second;
		qs.pop();
		if(vis[nowx][nowy])continue;
		dfs(nowx,nowy);
		while(!q.empty()){
			tmpx=q.front().first;
			tmpy=q.front().second;
			q.pop();
			dp[tmpx][tmpy]=dp[nowx][nowy];
			for(int i=max(1,tmpx-2);i<=min(n,tmpx+2);i++){
				for(int j=max(1,tmpy-2);j<=min(m,tmpy+2);j++){
					if(dp[i][j]!=INF)continue;
					if(in[i][j]=='#')continue;
					dp[i][j]=dp[nowx][nowy]+1;
					qs.push({i,j});
				}
			}
		}
	}
	if(dp[ex][ey]==INF)puts("-1");
	else printf("%d\n",dp[ex][ey]);
	
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 13076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#include <unordered_map>
#define int long long 
#define pi pair<int,int> 
#define endl "\n"
using namespace std ;

const int inf = 1e15 ;
const int size = 1e5 + 5 ;
int n , m ;
vector<int>g[size] ;
int dp[size];


int dfs( int u )
{
     int &ans = dp[u] ;
     if(ans!=-1) return ans ;
     ans = 0 ;
     for(auto &c :g[u])
     {
         ans = max(ans,1+dfs(c));
     }
     return ans ;
}

int32_t main() 
{


    /* #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
     memset(dp,-1,sizeof(dp));
     int x , y ;
     cin >> n >> m ;
     for(int i =1;  i<= m ; i++ )
     {
           cin >> x >> y ;
           g[x].push_back(y);
     }
     int ans = 0 ;
     for(int i = 1 ; i <= n ; i++ )
     {
         ans = max(ans,dfs(i));
     }
     cout<<ans<<endl;
    return 0 ;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

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

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

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    ll D;
    cin >> N >> D;
    int ret = 0;
    for(int i = 0;i < N;i++) {
        ll A, B;
        cin >> A >> B;
        if(A * A + B * B <= D * D) {
            ret++;
        }
    }
    cout << ret << endl;
}

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

int main() {
  int h, w;

  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) {
      break;
    }

    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
        if ((i + j) % 2 == 0) cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
import Data.List

main = do
  getLine
  ps<-map read.words<$>getLine :: IO [Int]
  print $ solve ps

solve ps = length$filter id$zipWith3 f ps (tail ps) (tail$tail ps) where
  f a b c = b /= maximum[a,b,c] && b /= minimum[a,b,c]

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    ll a; string b;
    cin >> a >> b;
    ll two, one, zero;
    two = b[3] - '0';
    one = b[2] - '0';

    ll t = one*10 + two;
    zero = b[0] - '0';

    ll ans = 0;
    ans += a * t / 100;
    ans += a * zero;

    pr(ans);

    return 0;}

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

#define N 100001
#define INFTY 1000000000

typedef struct{
  char card;
  int num;
}Record;

 
int partition(Record *, int, int);
void quicksort(Record *, int, int);
void merge(Record *, int, int, int);
void mergeSort(Record *, int, int);
int Stable(Record *, Record *);

int n;

int main () {
  int i;
  char str;
  Record data[N], smp[N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf(" %c %d",&data[i].card,&data[i].num);
    smp[i] = data[i];
  }

  
  quicksort(data, 0, n - 1);
  mergeSort(smp, 0, n);

  if(Stable(data, smp) == 1) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0 ; i < n ; i++) {
    printf("%c %d\n", data[i].card, data[i].num);
  }

  

  return 0;
}







int partition(Record *A, int p, int r) {
  int i, j, x = 0, tmp = 0;
  char str;
  Record data;

  x = A[r].num;
  i = p - 1;


  for(j = p ; j < r ; j++) {
    if(A[j].num <= x) {
      i++;
 
      data = A[i];
      A[i] = A[j];
      A[j] = data;
    }
  }

  data = A[i+1];
  A[i+1] = A[r];
  A[r] = data;
      

  return i+1;
}


void quicksort(Record *p1, int p, int r) {
  int q = 0;

  if(p < r) {
    q = partition(p1, p, r);
    quicksort(p1, p, q - 1);
    quicksort(p1, q + 1, r);
  }
  
}

void merge(Record *data, int left, int mid, int right) {
  int n1 = 0, n2 = 0, i = 0, j = 0, k =0, cnt = 0;
  Record tmp, *L, *R;

  n1 = mid - left;
  n2 = right - mid;

  L = (Record *)malloc(sizeof(Record) * (n1 + 1));
  R = (Record *)malloc(sizeof(Record) * (n2 + 1));

  for(i = 0 ; i < n1 ; i++) {
    L[i] = data[left + i];
  }

  for(i = 0 ; i < n2 ; i++) {
    R[i] = data[mid + i];
  }

  L[n1].num = INFTY;
  L[n1].card = NULL;
  R[n2].num = INFTY;
  R[n2].card = NULL;

  i = 0;
  j = 0;

  for(k = left ; k < right ; k++) {
    cnt++;
    if(L[i].num <= R[j].num) {
      data[k] =L[i];
      i++;
    }
    else {
      data[k] =R[j];
      j++;
    }
  }

  free(L);
  free(R);
  
}


void mergeSort(Record *smp, int left, int right) {
  int mid = 0;

  if(left+1 < right) {
    mid = (left + right)/2;
    mergeSort(smp, left, mid);
    mergeSort(smp, mid, right);
    merge(smp, left, mid, right);
  }
 
}










int Stable(Record *A, Record *smp) {
  int i, j, a, b;

  for(i = 0 ; i < n ; i++) {
    if(A[i].card != smp[i].card) return 0;
  }

  return 1;
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

char A[20];

int main()
{
    string S;
    cin >> S;
    int index = 0;
    REP(i, S.length())
    {
        if (S[i] == 'B')

            index = std::max(0, index - 1);
        else
            A[index++] = S[i];
    }

    REP(i, index)
    {
        cout << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  const arr = input.split(" ");
  let count5 = 0, count7 = 0;
  
  arr.map(a => {
    if(a == 5){
      count5++;
    }else if(a == 7){
      count7++;
    }
  });
 
  console.log(count5 === 2 && count7 === 1 ? 'YES' : 'NO');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    int n; 
    cin >> n; 
    int r, c;
    vector<pair<int, int>> v; 
    vector<int> dims; 
    for (int i = 0; i < n; ++i) { 
            cin >> r >> c; 
            if (i == 0) { 
                dims.push_back(r);
            } 
        dims.push_back(c);
    }
    // for (int i = 0; i < dims.size(); ++i)
    //     cout << dims[i] << " ";
    int dp[n][n];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            dp[i][j] = 0;
    
    for (int len = 2; len <= n; ++len) { 
        for (int i = 0; i <= n - len; ++i) { 
            int j = i + len-1;
            // cout << i << " " << j <<" -> ";
            dp[i][j] = INT_MAX;
            for (int k = i; k < j; ++k) { 
                // cout << dp[i][k] << " " << dims[i] << " " << dims[k+1] << " " << dims[j+1] << endl;
               int q = dp[i][k] + dp[k+1][j] + dims[i]*dims[k+1]*dims[j+1]; 
               dp[i][j] = min(q, dp[i][j]);
            }
        }
    }
    // for (int i = 0; i < n; ++i) {
    //     for (int j = 0;j < n; ++j)
    //         cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[0][n-1] << endl;
   
}


Measured memory_bytes: 3160
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

ll A[100010] = {};
ll B[100010] = {};
ll C[100010] = {};

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

  int N;
  cin >> N;
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> B[i];
  }
  REP(i, N) {
    cin >> C[i];
  }
  sort(A, A + N);
  sort(B, B + N);
  sort(C, C + N);

  ll total = 0;
  REP(i, N) {
    ll ai = lower_bound(A, A + N, B[i]) - A;
    ll ci = upper_bound(C, C + N, B[i]) - C;
    total += ai * (N - ci);
  }

  cout << total << endl;
  return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int main() {
	int a[5];
	while(scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
		bool three = false, four = false, straight = false, full = false;
		int pair = 0, count = 1;
		sort(a, a + 5);
		rep(i, 4) {
			if(a[i] == a[i+1]) ++count;
			else count = 1;
			if(count == 4) four = true;
			if(count == 3) three = true;
			else if(count == 2) ++pair;
		}
		rep(i, 4) {
			if(a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
				straight = true;
				break;
			}
			if(a[i] != a[i + 1] - 1) {
				straight = false;
				break;
			}
			else straight = true;
		}
		if(three && pair == 2) full = true;
		if(four) cout << "four card" << endl;
		else if(full) cout << "full house" << endl;
		else if(straight) cout << "straight" << endl;
		else if(three) cout << "three card" << endl;
		else if(pair == 2) cout << "two pair" << endl;
		else if(pair == 1) cout << "one pair" << endl;
		else cout << "null" << endl;
	}
	return 0;
}

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

#define NUM 1001
#define MAX 10000000
int main(void){
  char input_x[NUM][NUM];
  int sum[NUM] = {0};
  int cnt = 0;
  int i, j, temp;

  i = 0;
  do {
    scanf("%s", input_x[i]);
    // printf("%s\n", input_x[i]);
    // printf("(%d)\n", atoi(input_x[i]));
    cnt++;
    i++;
  } while (input_x[i - 1][0] != '0');

  i = 0;
  do {
    j = 0;
    temp = atoi(&input_x[i][j]);
    while (input_x[i][j] > 0) {
      // sum[i] += atoi(&input_x[i][j]) % 10;
      sum[i] += input_x[i][j] - '0';
      // printf("(%d)\n", input_x[i][j] - '0');
      // printf("[%d], [%d]", i, j);
      // sum[i] += temp % 10;
      // temp /= 10;
      j++;
    }
    i++;
  } while (i < cnt);

  i = 0;
  while (i < cnt - 1) {
    printf("%d\n", sum[i]);
    i++;
  }

  return 0;
}

Measured memory_bytes: 1100
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
# a, b, c = list(map(int, input().split()))

# 1整数
n = int(input())

# 空白区切りリスト整数
h = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()
m = 0

for i in range(n):
    if m - 1 > h[i]:
        print('No')
        exit()
    m = max(m, h[i])

print('Yes')


Measured memory_bytes: 15944
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        s: Bytes,
    }
    let mut sum = 0;
    for c in s {
        sum += (c - b'0') as usize;
    }
    let ans = if sum % 9 == 0 {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2344
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

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

const int B = 500;
int color[100010], par[100010], depth[100010];
int depthTop[100010];
int goUp[100010];
int vis[100010];
int n;
vector<vector<int>> g;

void decomp(int root){
    rep(i,n) vis[i] = false, par[i] = -1;
    vector<int> q(n+1); int l = 0, r = 0;
    q[r++] = root;
    vector<int> tord;
    while(l != r){
        int v = q[l++];
        vis[v] = true;
        tord.push_back(v);
        for(int c : g[v]){
            if(!vis[c]){
                q[r++] = c;
                par[c] = v;
                depth[c] = depth[v] + 1;
            }
        }
    }
    rep(i,n) vis[i] = false;
    int c = 0;
    for(int u : tord){
        l = 0, r = 0;
        if(vis[u]) continue;
        q[r++] = u;
        int k = 0;
        while(l != r && k < B){
            int v = q[l++];
            vis[v] = true;
            color[v] = c;
            goUp[v] = par[u];
            depthTop[v] = depth[u];
            k++;
            for(int c : g[v]){
                if(!vis[c]) q[r++] = c;
            }
        }
        c++;
    }
}

int solve(int u, int v){
    while(color[u] != color[v]){
        if(depthTop[u] > depthTop[v]) u = goUp[u];
        else v = goUp[v];
    }
    while(u != v){
        if(depth[u] > depth[v]) u = par[u];
        else v = par[v];
    }
    return u;
}

int main(){
    cin >> n;
    g.assign(n,{});
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g[i].push_back(c);
            par[c] = i;
        }
    }
    decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << solve(u,v) << endl;
    }
}

Measured memory_bytes: 9760
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
using namespace std;
ll mod = 1000000007;
ll INF = 1000000000000000000;
ll n, m;
vector<ll> v[100001];
ll dp[100001];

ll foo(ll node)
{
	if (v[node].empty()) return 0;

	if (dp[node] != -1) return dp[node];

	ll res = 0;
	for (auto i : v[node])
	{
		res = max(res, 1 + foo(i));
	}

	return dp[node] = res;
}

void solve(int t)
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		ll x, y;
		cin >> x >> y;
		v[x].pb(y);
	}

	ll ans = 0;


	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++)
	{
		if (dp[i] == -1)
		{
			ans = max(ans, foo(i));
		}
	}

	cout << ans << endl;


}

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


	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}
}


Measured memory_bytes: 8576
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,c,i,j,k,ans=0,n,l,x;
	int kari;

	cin >> x;

	while ((x>=100)and((x % 5) != 0)) {
		switch (x % 5) {
		case 1:
			x = x - 101;
			break;
		case 2:
			x = x - 102;
			break;
		case 3:
			x = x - 103;
			break;
		case 4:
			x = x - 104;
			break;

		default:
				break;
		}
	}
	if (x % 100 == 0) ans = 1;
	while (x >= 105) {
		x = x - 105;
		if (x%100 == 0) ans = 1;
	}
	

	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b==c){
    cout <<"Yes"<<endl;
  }
  else if(a+c==b){
    cout <<"Yes"<<endl;
  }
  else if(b+c==a){
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a == 1){
        a += 13;
    }
    if(b == 1){
        b += 13;
    }
    
    if(a < b){
        cout << "Bob";
    }else if(a > b){
        cout << "Alice";
    }else{
        cout << "Draw";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------
int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; string s; cin>>n>>s;
    vvi cnt(10,vi(n+1,0));
    set<int> st;
    for(int i = 0; i < n; i++) {
        int j = s[i] - '0';
        cnt[j][i+1]++;
    }
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < n; j++) {
            cnt[i][j+1] += cnt[i][j];
        }
    }
    for(int i = 1; i < n-1; i++) {
        for(int a = 0; a < 10; a++) {
            for(int c = 0; c < 10; c++) {
                if(cnt[a][i]>0&&cnt[c][n]-cnt[c][i+1]>0) st.insert(100*a+10*(s[i]-'0')+c);
            }
        }
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define F first
#define re return
#define S second
#define ll long long
#define f(i) return cout<<i<<"\n",0;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define lp(i,a,b) for (int i=(a);i<=(int)(b);++i)
#define lp2(i,a,b) for (int i=(a);i>=(b);--i)
#define clr(c,x) memset(c,x,sizeof(c))
#define allr(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
const int N=2e5+5,mod=(int)1e9+7;
vl x,y;
inline ll Manhttan(vl &v)
{
    ll res=0,sum=0;
    lp(i,0,v.size()-1)
    {
        res+=(v[i]*i-sum);
        sum+=v[i];
    }
    return (res%mod);
}
inline ll fp(int base,int po)
{
    if (!po) return 1;
    ll ret=fp(base,po/2);
    ret%=mod;
    ret*=ret;
    ret%=mod;
    if (po&1)
    {
        ret*=base;
        ret%=mod;
    }
    return ret;
}
ll fact[N]= {};
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    fact[0]=1;
    lp(i,1,n*m)
    {
        fact[i]=i*fact[i-1];
        fact[i]%=mod;
    }
    lp(i,1,n)
    {
        lp(j,1,m)
        {
            x.pb(i);
            y.pb(j);
        }
    }
    sort(all(x));
    sort(all(y));
    ll res=Manhttan(x)+Manhttan(y);
    res%=mod;
    ll z=fact[k-2]*fact[n*m-k];
    z%=mod;
    ll res2=fp(z,mod-2);
    res2*=fact[n*m-2];
    res2%=mod;
    res*=res2;
    res%=mod;
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 5220
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;
#define int long long
signed main(void)
{
	int n, m;
	cin >> n >> m;
	int pos[100004];
	for (int i = 0; i < 100003; i++) {
		pos[i] = 10000000001;
	}
	typedef pair<int, int> P;//行き先、そこまでの距離
	vector<P> graph[100004];
	int l, r, d;
	for (int i = 0; i < m; i++) {
		cin >> l >> r >> d;
		graph[l].push_back(P(r, d));
		graph[r].push_back(P(l, -d));
	}
	int judge = 0;
	for (int z = 1; z <= n; z++) {
		if (pos[z] ==10000000001)pos[z] = 0;
		queue<int> que;
		que.push(z);
		while (!que.empty()) {
			int now = que.front();
			que.pop();
			for (int i = 0; i < graph[now].size(); i++) {
				int dist=graph[now][i].first;
				if (pos[dist] ==10000000001) { pos[dist] = pos[now] + graph[now][i].second; 
				que.push(dist);
				}
				else {
					if (pos[dist] - pos[now] != graph[now][i].second) { judge = 1; break; }
				}
			}
			if (judge == 1)break;
		}

		if (judge == 1)break;
	}
	for (int i = 1; i <=n; i++) {
		for (int j = 0; j < graph[i].size(); j++) {
			int dist = graph[i][j].first;
			if (pos[dist] - pos[i] != graph[i][j].second)judge = 1;
		}
	}
	if (judge == 1)cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 14080
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=a+b;
    if(a%3==0 || b%3==0 ||c%3==0){
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    }
    sc.close();
  }
}

Measured memory_bytes: 22608
#include<iostream>
#include<string>
#include<regex>

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

using namespace std;

int main()
{
    long long a,n,k;
    long int t;
    cin >> n >> k;
    int min = n;
    a = n % k;
    t = abs(a-k);
    if(a < t) cout << a;
    else cout << t;

    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<ll> lim = {A, B, C};
    vector< vector<ll> > apples(3);
    for(int i=0; i<3; i++) {
        for(int j=0; j<lim[i]; j++) {
            ll p; cin >> p;
            apples[i].emplace_back(p);
        }
    }

    for(int i=0; i<3; i++) {
        sort(apples[i].begin(), apples[i].end());
        if(i < 2) reverse(apples[i].begin(), apples[i].end());
    }

    while((int)apples[0].size() > X) apples[0].pop_back();
    while((int)apples[1].size() > Y) apples[1].pop_back();

    ll ans = 0;
    for(int i=0; i<2; i++) {
        ans += accumulate(apples[i].begin(), apples[i].end(), 0LL);
    }
    
    while(apples[2].size()) {
        ll a0 = LONGINF, a1 = LONGINF;
        if(apples[0].size()) a0 = apples[0].back();
        if(apples[1].size()) a1 = apples[1].back();
        ll a2 = apples[2].back();
        
        if(a0 <= a1 and a0 < a2) {
            ans -= a0;
            ans += a2;
            apples[0].pop_back();
            apples[2].pop_back();
        }
        else if(a1 <= a0 and a1 < a2) {
            ans -= a1;
            ans += a2;
            apples[1].pop_back();
            apples[2].pop_back();
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3316
n, m = gets.chomp.split.map(&:to_i)

mat = Array.new(n) do
    Array.new(m)
end

vec = Array.new(m)

n.times do |i|
    mat[i] = gets.chomp.split.map(&:to_i)
end

m.times do |i|
    vec[i] = gets.chomp.to_i
end

n.times do |i|
    c = 0
    m.times do |j|
        c += mat[i][j] * vec[j]
    end
    puts c
end

Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+'){
      count++;
    }
    else {
      count--;
    }
  }
  cout << count << endl;
}
  

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

int main(){
  int a,b,c,x,y;
  int I,J;
  cin >> a >> b >> c >> x >> y;
  int rel = 10000000;
  if(a+b < c*2){
    I = a*x+b*y;
    
  }
  else{
    I = c*min(x,y)*2 + (a*(x-min(x,y)) + b*(y-min(x,y)));
    J = c*max(x,y)*2;
    I = min(I,J);
  }

  cout << I << endl;
}


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

int main() {
  int n;
  double ans = 0.0;
  cin >> n;
  if (n == 1) {
    ans = 1.0;
  }
  else if (n%2 == 0) {
    ans = 1.0/2.0;
  }
  else {
    ans = ((n+1)/2.0)/n;
  }
  
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
def func():
    return

n = int(input())
# s = input()
# a, b = map(int, input().split())
a = list(map(int, input().split()))
# a = input().split()

ascA = sorted(a)
for i in range(n-1):
    if ascA[i] == ascA[i+1]:
        print("NO")
        exit()

'''
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            print("NO")
            exit()
'''
'''
ans = [0]*(max(a)+1)
for ida in a:
    if ans[ida] > 0:
        print("NO")
        exit()
    ans[ida] += 1
'''

print("YES")

Measured memory_bytes: 87764
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    long long ans = 0;
    for(int i=0; i<n; ++i)
        ans += cnt[i + a[i]];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21136
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int s[60];
int main(){
    int n;cin>>n;
    int a[n+1];
    rep(i,n)cin>>a[i+1];
    a[0]=0;
    bool inc=true;
    rep(i,n)if(a[i]>=a[i+1])inc=false;
    if(inc){
        cout<<1<<endl;
        return 0;
    }
    int ng=1,ok=n;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        vector<pint> v;
        v.emplace_back(-1,-1);
        bool can=true;
        rep(i,n){
            if(a[i]<a[i+1])continue;
            int m=a[i+1];
            while(v.back().first>m)v.pop_back();
            while(v.back().first==m&&v.back().second==mid-1)v.pop_back(),--m;
            if(m){
                if(m==v.back().first)++v.back().second;
                else v.emplace_back(m,1);
            }
            else {
                can=false;
                break;
            }
        }
        if(can)ok=mid;
        else ng=mid;
        cout<<endl;
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A_s = list(map(int, input().split()))

seki = 1

if (A_s.count(0) > 0):
    print(0)
    exit()

for i in range(N):
    seki *= A_s[i]
    
    if (seki > 10 ** 18):
        print(-1)
        exit()

print(seki)

Measured memory_bytes: 21656
import math

d, g = map(int, input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())

ans = 10 ** 9
for bit in range(2 ** d):
    cnt = 0
    score = 0

    # ボーナス分の足し込み
    for i in range(d - 1, -1, -1):
        if bit >> i & 1 == 1:
            cnt += p[i]
            score += p[i] * (i + 1) * 100 + c[i]
    
    if score >= g:
        ans = min(ans, cnt)
    else:
        for i in range(d - 1, -1, -1):
            if bit >> i & 1 == 1:
                continue
            
            for j in range(p[i]):
                if score >= g:
                    break

                cnt += 1
                score += (i + 1) * 100
            
        if score >= g:
            ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 42224
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int k,n,i;
	string s;
	cin>>k>>s;
	n=s.length();
	if(n<=k)cout<<s;
	else{
		for(i=0;i<k;i++)
		cout<<s[i];
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll L, R;
    cin >> L >> R;
    if(R - L >= 2020){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2020;
    for(ll i = L; i <= R; i++){
        for(ll j = i + 1; j <= R; j++){
            ll tmp = (i % 2019) * (j % 2019) % 2019;
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256