akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n,m;
	cin >> n >> m;
	vector<PII> v(m);
	REP(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		v[i] = (MP(min(a, b), max(a, b)));
	}
	SORT(v);
	int r = 0;
	int ret = 0;
	REP(i, m) {
		if (v[i].first >= r) {
			ret++;
			r = v[i].second;
		}
		else {
			r = min(r, v[i].second);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, maxval = -1, sum = 0;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
    sum += l[i];
    maxval = max(maxval, l[i]);
  }

  if (sum - maxval > maxval) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
while 1:
    n, m = map(int, input().split())
    if n == 0:
        break

    data = []
    for _ in range(n):
        d, p = map(int, input().split())
        data.append([d, p])

    data = sorted(data, key=lambda x: -x[1])
    for d in data:
        if m <= 0:
            break
        if d[0] <= m:
            m -= d[0]
            d[0] = 0
        else:
            d[0] -= m
            m = 0

    ans = 0
    for d in data:
        ans += d[0] * d[1]

    print(ans)


Measured memory_bytes: 7124
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var a = new int[3];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(strs[i]);

            Console.WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N;
  vector<int> d;

  cin >> N;
  for(int i=0;i<N;i++){
    int temp;
    cin >> temp;
    d.push_back(temp);
  }

  sort(d.begin(),d.end(),greater<int>());
  
  int count=0,num=0;
  for(auto it=d.begin();it!=d.end();it++){
    if(num!=*it){
      count++;
      num=*it;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c) cout << a << " " << b << " " << c << endl;
    else if (c <= b && b <= a) cout << c << " " << b << " " << a << endl;
    else if (c <= a && a <= b) cout << c << " " << a << " " << b << endl;
    else if (b <= c && c <= a) cout << b << " " << c << " " << a << endl;
    else if (b <= a && a <= c) cout << b << " " << a << " " << c << endl;
    else cout << a << " " << c << " " << b << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	n = n%10;
	if (n == 3) {
		cout << "bon";
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon";
	}
	else cout << "hon";
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s, S, T;
	cin >> s;
	int res = s.size()-1;
	for(int i = 0; i < 26; i++) {
		S = s;
		while(S.size()) {
			bool f = true;
			rep(j,S.size()) {
				if(S[j] != 'a'+i) f = false;
			}
			if(f) {
				res = min<int>(res, s.size()-S.size());
			}
			
			T = "";
			rep(j,S.size()-1) {
				if(S[j] == 'a'+i || S[j+1] == 'a'+i) {
					T += 'a'+i;
				}
				else {
					T += 'A';
				}
			}
			S = T;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Q
{
    public int x { get; set; }
    public int y { get; set; }
    public int L { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var n = int.Parse(line[2]);
        var map = new int[h, w];
        var d = new Dictionary<int, P>();
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
            {
                if (s[j] == 'S') { d[0] = new P { x = i, y = j }; map[i, j] = -10; }
                else if (s[j] == 'X') map[i, j] = -1;
                else if (s[j] == '.') map[i, j] = -10;
                else
                {
                    var wt = int.Parse(s[j].ToString());
                    map[i, j] = -10;
                    d[wt] = new P { x = i, y = j };
                }
            }
        }
        var count = 0;
        for (int i = 1; i <= n; i++)
        {
            var start = new P { x = d[i - 1].x, y = d[i - 1].y };
            var g = new P { x = d[i].x, y = d[i].y };
            count += goBfs(map, start, g);
        }
        Console.WriteLine(count);
    }
    public static int goBfs(int[,] map, P s, P g)
    {
        var h = map.GetLength(0);
        var w = map.GetLength(1);
        var map2 = new int[h, w];
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        var q = new Queue<Q>();
        q.Enqueue(new Q { x = s.x, y = s.y, L = 0 });
        map2[s.x, s.y] = 1;
        while (q.Count() > 0)
        {
            var t = q.Dequeue();
            if (t.x == g.x && t.y == g.y) return t.L;
            for (int i = 0; i < 4; i++)
            {
                var nx = t.x + dx[i];
                var ny = t.y + dy[i];
                if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == -10 && map2[nx,ny] == 0)
                { map2[nx, ny] = 1; q.Enqueue(new Q { x = nx, y = ny, L = t.L + 1 }); }
            }
        }
        return 0;
    }
}






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

answer = []
for i in range(N):
    A = int(input())
    tmp = []
    for j in range(A):
        xy = list(map(int, input().split()))
        tmp.append(xy)
    answer.append(tmp)

count = 0
for i in range(2 ** N):
    YorN = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            YorN[N - 1 - j] = 1
        True_people = []
    for j in range(N):
        if YorN[j] == 1:
            True_people.append(answer[j])
    flag = True
    for ans in True_people:
        for k in ans:
            if YorN[k[0]-1] != k[1]:
                flag = False
    if flag == True:
        if count <= sum(YorN):
            count = sum(YorN)

print(count)   

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve()
{
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a[0] >> a[1];
  if (n == 2)
  {
    cout << max(a[0], a[1]);
    return;
  }

  cin >> a[2];
  int gcd0 = gcd(a[1], a[2]);
  int gcd1 = gcd(a[0], a[2]);
  int gcd2 = gcd(a[0], a[1]);

  int now_gcd = max({gcd0, gcd1, gcd2});
  int may_waste_gcd = gcd(gcd0, a[0]);

  for(int i = 3; i < n; ++i)
  {
    cin >> a[i];
    if (a[i] % now_gcd == 0) continue;

    int tmp_gcd = gcd(a[i], now_gcd);
    now_gcd = max(tmp_gcd, may_waste_gcd);
    may_waste_gcd = gcd(a[i], may_waste_gcd);
  }
  cout << now_gcd;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3708
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools
 
setrecursionlimit(10**7)
 
def input():
  return stdin.readline().strip()
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
MOD = 10**6 + 3
 
fact = [1] * MOD
for i in range(1, MOD):
  fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MOD; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MOD-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD
# print(invfact[:10])
 
def inv(n):
  return pow(n, MOD-2, MOD)
 
def solve(x, d, n):
  if x == 0:
    return 0
  if d == 0:
    return pow(x, n, MOD)
  k = x * inv(d) % MOD
  if n + k - 1 >= MOD:
    return 0
  return fact[n + k - 1] * invfact[k-1] % MOD * pow(d, n, MOD) % MOD
 
Q = read()
for _ in range(Q):
  x, d, n = reads()
  ans = solve(x, d, n)
  print(ans)

Measured memory_bytes: 69852
#include <stdio.h>
#include <string.h>

int main(void)
{
  char c[256] = {['a'] = 2, ['b'] = 3, ['c'] = 5};
  char s[3 + 1];
  int ans = 1;

  if (scanf("%3s%*[^\n]%*c", s) > 0) {
    for (int i = 0; i < strlen(s); i++) {
      ans *= c[s[i]];
    }
    puts(ans == c['a'] * c['b'] * c['c'] ? "Yes" : "No");
  }
}


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


int main() {
  int H, W;
  cin >> H >> W;
  for(int i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
  vector<char> vec(W);
  for(int k=0; k<H; k++){
    for (int i=0; i<W; i++){
      if (i == 0)
        cout << "#";
      cin >> vec.at(i);
      cout << vec.at(i);
      if (i == W-1)
        cout << "#" << endl;
    }  
  }
  for(int i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    int ans = 0;
    for(int i=0; i<10; i++)
      for(int j=0; j<10; j++)
	for(int k=0; k<10; k++)
	  if(n-i-j-k>=0 && n-i-j-k<10) ans++;
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    rep(i,n){
        if(s[i]!=',') cout << s[i];
        else cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    
    s < t ? cout << "Yes" << endl
          : cout << "No"  << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int r;
    cin >>r;
    r = pow(r,2);
    cout<<r<<endl;
}
    



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

using namespace std;

typedef pair<int, int> pii;

int mat[502][502];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> mat[i][j];
		}
	}
	vector< pii > dirs = {pii(0, 1), pii(1, 0), pii(0, -1), pii(-1, 0)};
	vector< pair<pii, pii> > res;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (mat[i][j] % 2 == 0) continue;
			if (j-1 >= 0 && mat[i][j-1] % 2 == 1) {
				res.push_back(make_pair(pii(i+1, j+1), pii(i+1, j)));
				mat[i][j]--;
				mat[i][j-1]++;
				continue;	
			}
			if (i-1 >= 0 && mat[i-1][j] % 2 == 1) {
				mat[i][j]--;
				mat[i-1][j]++;
				res.push_back(make_pair(pii(i+1, j+1), pii(i, j+1)));
				continue;	
			}
			if (j + 1 < W) {
				mat[i][j]--;
				mat[i][j+1]++;
				res.push_back(make_pair(pii(i+1, j+1), pii(i+1, j+2)));
				continue;
			}
			if (i + 1 < H) {
				mat[i][j]--;
				mat[i+1][j]++;
				res.push_back(make_pair(pii(i+1, j+1), pii(i+2, j+1)));
			}
		}
	}
	cout << res.size() << endl;
	for (auto p : res) {
		cout << p.first.first << " " << p.first.second << " " << p.second.first << " " << p.second.second << endl;
	}

}

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

int N;
int M;
int A[1000];
int B[1000];
int cnt[1000000];

long long mo=(long long)1e9+7;

int main(){
  std::cin>>N>>M;
  std::priority_queue<std::pair<int,int>> pq;
  for(int i=0;i<N;++i){
    std::cin>>A[i];
    --A[i];
    ++cnt[A[i]];
    pq.push(std::make_pair(A[i],0));
  }
  for(int i=0;i<M;++i){
    std::cin>>B[i];
    --B[i];
    ++cnt[B[i]];
    pq.push(std::make_pair(B[i],1));
  }
  std::sort(A,A+N);
  std::sort(B,B+M);
  for(int i=0;i+1<N;++i){
    if(A[i]==A[i+1]){
      std::cout<<0<<std::endl;
      return 0;
    }
  }
  for(int i=0;i+1<M;++i){
    if(B[i]==B[i+1]){
      std::cout<<0<<std::endl;
      return 0;
    }
  }
  long long ans=1;
  int cnt0=0;
  int cnt1=0;
  int pre=N*M;
  while(!pq.empty()){
    std::pair<int,int> v=pq.top();pq.pop();
    while(pre>v.first+1){
      ans=ans*(cnt0*cnt1-(N*M-pre))%mo;
      --pre;
    }
    if(cnt[v.first]==1){
      if(v.second==0){
		ans=ans*cnt1%mo;
      }else if(v.second==1){
		ans=ans*cnt0%mo;
      }
    }
    if(v.second==0){
      ++cnt0;
    }else{
      ++cnt1;
    }
    pre=v.first;
  }
  while(pre>0){
    ans=ans*(cnt0*cnt1-(N*M-pre))%mo;
    --pre;
  }
  std::cout<<ans<<std::endl;
  return 0; 
}


Measured memory_bytes: 384
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N;
  cin >> N;
  vec<int> L(N, 0);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  int triangles = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      for(int k = j+1; k < N; k++){
        vec<int> l = {L[i], L[j], L[k]};
        sort(l.begin(), l.end());
        // 長さが違う
        if(l[0] == l[1] || l[1] == l[2]){
          continue;
        }

        //三角形
        if(l[2] < l[1] + l[0]){
          triangles++;
          //printf("(%d, %d, %d) -> ", i, j, k);
          //printf("(%d, %d, %d)\n", l[0], l[1], l[2]);
        }
      }
    }
  }
  cout << triangles << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
	char a;
	while(1){
		scanf("%c",&a);
		if(isalpha(a)){
			if(islower(a))cout<<(char)toupper(a);
			else if(isupper(a))cout<<(char)tolower(a);
		}
		else {cout<<a;}
		if(a=='\n')break;
	}
return 0;
}



Measured memory_bytes: 3132
N = int(input())
W = list(map(int, input().split()))

# print(W)
sm_list = list()

for a in range(0, N-1):
    S1 = sum(W[0:a+1])
    S2 = sum(W[a+1:N])
    #print(S1, S2)
    sm_list.append(abs(S1-S2))

print(min(sm_list))


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

ll N,M; 
ll h[300000];
vector<int> cnct[300000];


int main(){
    cin>>N>>M;
    for(int i=1;i<=N;++i){ cin >> h[i]; }
    REP(count,M){
        ll a,b; cin>>a>>b;
        cnct[ a ].push_back(b);
        cnct[ b ].push_back(a);
    }
    ll ans = 0;
    for(int i=1;i<=N;++i){
        bool ok = true;
        for(int x:cnct[i]){
            if(h[i]<=h[x]){ ok = false; break;}
        }
        if(ok){ ++ans;}
    }
    cout << ans <<"\n";
    
}

Measured memory_bytes: 14192
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    ll b; cin >> b;
    ll c; cin >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vec a(n),b(n);
  REP(i, n) cin >> a[i] >> b[i];

  int cnt = 0;
  RREP(i, n){
    int tmp = ( a[i] + cnt ) % b[i];
    cnt += b[i] - ( tmp == 0 ? b[i] : tmp );
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int cnt=0;
  string s; cin >> s;
  if(s[0]=='R'){
      if(s[1]=='R'){
          if(s[2]=='R'){
              cnt=3;
          }else{
              cnt=2;
          }
      }else{
          cnt=1;
      }
  }else{
      if(s[1]=='R'){
          if(s[2]=='R'){
              cnt=2;
          }else{
              cnt=1;
          }
      }else{
          if(s[2]=='R'){
              cnt=1;
          }else{
              cnt=0;
          }
      }
  }
  
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int x[5];
    int i,j=0;
    for(i=0;i<5;i++){
        cin >> x[i];
        if(x[i]==0)j=i+1;
    }
    
    cout << j << endl;
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = IOUtils.ReadInt();

            var n1 = n % 10;

            var res = n1 == 3 ? "bon"
                    : new[]{ 0,1,6,8}.Contains(n1) ? "pon"
                    : "hon";
            System.Console.WriteLine(res);

        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 27856
//Chat I am Trash
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define debug(x) cout<<x<<endl
#define all(x) x.begin(),x.end()

using namespace std;
int main()
{
    FASTIO
    ll n,k;
    cin>>n>>k;
    if(n%2!=0)n++;

    if(n>=2*k)
    cout<<"YES";
    else
    cout<<"NO";


return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  map<char, int> point;
  point['r'] = P;
  point['s'] = R;
  point['p'] = S;
  string T;
  cin >> T;
  int res = 0;
  vector<bool> used(N, false);
  for (int i = 0; i < N; i++) {
    if (i - K >= 0 && T[i] == T[i - K] && used[i - K]) continue;
    res += point[T[i]];
    used[i] = true;
  }
  cout << res << '\n';
  return 0;
}


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

int h,w;
string grid[10];
bool used[10][10];

int dfs(int y,int x){
    used[y][x] = true;
    int ret = 1;
    if(y+1 < h && grid[y+1][x]=='#' && !used[y+1][x]) ret += dfs(y+1,x);
    if(x+1 < w && grid[y][x+1]=='#' && !used[y+1][x]) ret += dfs(y,x+1);
    return ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> h >> w;
    REP(i,h) cin >> grid[i];
    int way = 0, ans = 0;
    REP(i,h) REP(j,w) if(grid[i][j]=='#') ++way;
    ans = dfs(0,0);
    if(ans==way) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
class Dice(object):
  def __init__(self, List):
    self.face = List

  def n_spin(self, List):
    temp = List[0]
    List[0] = List[1]
    List[1] = List[5]
    List[5] = List[4]
    List[4] = temp

  def s_spin(self, List):
    temp = List[0]
    List[0] = List[4]
    List[4] = List[5]
    List[5] = List[1]
    List[1] = temp

  def e_spin(self, List):
    temp = List[0]
    List[0] = List[3]
    List[3] = List[5]
    List[5] = List[2]
    List[2] = temp

  def w_spin(self, List):
    temp = List[0]
    List[0] = List[2]
    List[2] = List[5]
    List[5] = List[3]
    List[3] = temp

dice = Dice(map(int, raw_input().split()))
command = list(raw_input())
for c in command:
  if c == "N":
    dice.n_spin(dice.face)
  elif c == "S":
    dice.s_spin(dice.face)
  elif c == "E":
    dice.e_spin(dice.face)
  elif c == "W":
    dice.w_spin(dice.face)

print dice.face[0]

Measured memory_bytes: 6472
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
 

void solve()
{
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	if(s1[s1.sz-1]==s2[0] && s2[s2.sz-1]==s3[0])
		cout<<"YES";
	else
		cout<<"NO";
	return;	
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

int mod=1e9+7;
struct Mint {
    int val;
    Mint inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x){if((val=x%mod)<0)val+=mod;}
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int n; vector<int> g[100010];
Mint dp[100010],ans[100010];
void dfs1(int v,int pre){dp[v]=1; for(int to:g[v])if(to!=pre){dfs1(to,v); dp[v]*=(dp[to]+1);}}
void dfs2(int v,int pre,Mint coeff){
    ans[v]=dp[v]*coeff;
    vector<Mint> dps;
    for(int to:g[v])if(to!=pre)dps.push_back(dp[to]+1);
    dps.push_back(coeff);
    vector<Mint> l(dps.size()+1,1),r(dps.size()+1,1);
    rep(i,0,dps.size())l[i+1]=l[i]*dps[i];
    rrep(i,dps.size()-1,-1)r[i]=r[i+1]*dps[i];
    int idx=0;
    for(int to:g[v])if(to!=pre){
        dfs2(to,v,l[idx]*r[idx+1]+1); idx++;
    }
}

int main(){
    scanf("%d%d",&n,&mod);
    rep(i,0,n-1){
        int a,b; scanf("%d%d",&a,&b); a--; b--;
        g[a].push_back(b); g[b].push_back(a);
    }
    dfs1(0,-1); dfs2(0,-1,1);
    rep(i,0,n)printf("%d\n",ans[i].val);
    return 0;
}

Measured memory_bytes: 24448
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N, M;
  cin >> N >> M;
  int count = 0;
  if (1 < N)
  {
    count += (N * (N - 1)) / 2;
  }
  if (1 < M)
  {
    count += (M * (M - 1)) / 2;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int mod = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
*/
int dx[] = { -1,-1,-1,0,+1,+1,+1,0 };   // direction array
int dy[] = { -1,0,+1,+1,+1,0,-1,-1 };


int main()
{
    ios::sync_with_stdio(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    clock_t START_TIME = clock();
#endif*/
    ll n,m;
    cin>>n>>m;
    ll d=m/n;
    for(ll i=d;i>=1;i--)
        if(m%i==0)
         return cout<<i,0;
/*#ifndef ONLINE_JUDGE
    cout << endl << "// Time taken = " << fixed << setprecision(5) << (clock() - START_TIME) * 1e3 / CLOCKS_PER_SEC << " ms";
#endif*/
}


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

int main(void){
	long N,P,ans=1;
	scanf("%ld %ld",&N,&P);
	
	if(N==1){
		printf("%ld",P);
		return 0;
	}
	
	int div=0;
	
	for(int i=2;P>1&&i<=sqrt(P);i++){
		div=0;
		while(P%i==0){
			P/=i;
			div++;
			if(div>=N) {
				ans*=i;
				div-=N;
			}
		}
		
	}
	
	printf("%ld",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int i,j,k;
	cin>>i>>j>>k;
	if(i==j && i!=k)
	{
		cout<<"Yes";
	}
	else if(k==j && i!=k)
	{
		cout<<"Yes";
	}
	else if(i==k && i!=j)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys

s = {}
t = {}
for _ in range(int(input())):
  st = str(input())
  if st not in s:
    s[st] = 1
  else:
    s[st] += 1
for _ in range(int(input())):
  st = str(input())
  if st not in t:
    t[st] = 1
  else:
    t[st] += 1


ans = 0
for st in s:
  if st not in t:
    ans = max(ans,s[st])
  else:
    ans = max(ans,s[st]-t[st])

print(ans)

Measured memory_bytes: 38384
#[0,0]が白い一辺Kの四角の左下隅にあるとして，全部の希望ますが，市松模様のどの位置にいるか調べる？
#各希望マスに関して，[0,0]がどの範囲で動いても大丈夫かを調べる（グリッドが固定されているイメージ？）
#2次元累積和

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
S=[[0]*(2*K+1) for _ in range(2*K+1)]


#スタート位置9箇所
dx=[0,0,K,2*K,K,0,-K,-2*K,-K,2*K,2*K,-2*K,-2*K]
dy=[0,2*K,K,0,-K,-2*K,-K,0,K,2*K,-2*K,2*K,-2*K]

#点aが(2K-1)の正方形の中にあるか?
def ch(a):
    ax=a[1]
    ay=a[0]
    if 0<=ax and ax<=2*K-1:
        if 0<=ay and ay<=2*K-1:
            return True
    return False

#4点a,b,c,dのいずれかは正方形内にある？
def ch4(a,b,c,d):
    Li=[a,b,c,d]
    for i in range(4):
        if ch(Li[i]):
            return True
    return False

#最小を0，最大を2K-1に丸める．
def app(a):
    aa=[0,0]
    for i in range(2):
        aa[i]=a[i]
        if aa[i]<0:
            aa[i]=0
        elif aa[i]>2*K-1:
            aa[i]=2*K-1
    return aa
    
#点aに対応するところにbwを与える
def paint(a,bw):
    S[a[0]][a[1]]+=bw
    return 0
    
    
    


for _ in range(N):
    sx,sy,sc=input().split()
    x=int(sx)%(2*K)
    y=int(sy)%(2*K)
    if sc=="W":
        bw=1
    else:
        bw=-1#該当箇所を-1する
        
    #スタート位置12箇所
    s=(x-(K-1),y-(K-1))
    for i in range(len(dx)):
        ld=[s[0]+dx[i],s[1]+dy[i]]#左下
        ru=[ld[0]+(K-1),ld[1]+(K-1)]#右上
        lu=[ru[0],ld[1]]
        rd=[ld[0],ru[1]]
        
        if ch4(ld,ru,lu,rd):#4点のどれかが正方形内なら
            ld=app(ld)
            ru=app(ru)
            ru[0]+=1#累積和で-1するところは領域外（1つ奥のところ）
            ru[1]+=1
            lu=[ru[0],ld[1]]
            rd=[ld[0],ru[1]]
            paint(ld,bw)
            paint(ru,bw)
            paint(lu,bw*-1)
            paint(rd,bw*-1)
            
    if bw==-1:#該当箇所が-1されているので，全部を+1する
        S[0][0]+=1
        S[-1][-1]+=1
        S[0][-1]-=1
        S[-1][0]-=1
            
            

#累積    
for i in range(2*K+1):
    for j in range(2*K):
        S[i][j+1]+=S[i][j]
        
for j in range(2*K+1):
    for i in range(2*K):
        S[i+1][j]+=S[i][j]
        
        
ans=0
for i in range(2*K+1):
    for j in range(2*K+1):
        if S[i][j]>ans:
            ans=S[i][j]
          
        
print(ans)
        



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

using namespace std;

void solve() {
    long long h, n;
    cin >> h >> n;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        long long v; cin >> v; sum += v;
    }
    if (sum >= h) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

tmp = 0
for a in A[1:]:
    tmp += a
    tmp %= MOD

ans = 0
for i in range(N - 1):
    ans += (A[i] * tmp) % MOD
    ans %= MOD

    tmp -= A[i + 1]

print(ans)

Measured memory_bytes: 94120
O,E = input(),input()
ans = ''

if (len(O)+len(E))%2==0:
    for i in range(len(E)):
        ans += O[i] + E[i]
else:
    for i in range(len(E)):
        ans += O[i] + E[i]
    ans+=O[-1]
    
print(ans)


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




Measured memory_bytes: 1932
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
  vector<int> vec;
  int a, b, c;

  cin >> a >> b >> c;
  vec.push_back(a);  vec.push_back(b);  vec.push_back(c);
  std::sort(vec.begin(), vec.end());

  cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
  return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<cstdio>
using namespace std;
#define N 300012
int n,co[2],a[N],s[N],ans=0;
inline bool can(int mid){int i,v=0;for(i=2;i<=n;i+=2)if(s[i-1]>=(mid+v))v=min(v,s[i]);return (s[n]>=(mid+v));}
int main(){
	scanf("%d",&n);int i,l,r,mid;for(i=1;i<=n;i++){scanf("%d",&a[i]);co[i&1]+=a[i];}
	if(!(n&1)){printf("%d %d",max(co[0],co[1]),min(co[0],co[1]));return 0;}
	for(i=1;i<=n;i++)s[i]=s[i-1]+((i&1)?a[i]:(-a[i]));l=1;r=1e9;
	while(l<=r){mid=(l+r)>>1;if(can(mid)){ans=mid;l=mid+1;}else r=mid-1;}printf("%d %d",co[0]+ans,co[1]-ans);return 0;
}

Measured memory_bytes: 5564
K = int(input())
i=1
addNum = 1
ans = []
while(K!=0):
        print(i)
        K-=1
        S1 = 0
        S2 = 0
        for j in list(str(i+addNum)):
                S1 += int(j)
        for j in list(str(i+addNum+addNum)):
                S2 += int(j)
        if (i+addNum)/S1 > (i+addNum+addNum)/S2:
                addNum *= 10
        i += addNum

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

using namespace std;

int main(){

  int K;cin>>K;
  vector<int>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a.at(K-1)<<endl;

}

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



int main(){
  int n,d,x,p[10][10];
  cin>>n>>d>>x;
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin>>p[i][j];
    }
  }
  
  for(int cn=0;cn<d-1;cn++){
    int ma=x;
    int dp[11][111111];
    fill_n(*dp,11*111111,-1);
    dp[0][x]=0;
    for(int i=0;i<n;i++){
      for(int j=111110;j>=0;j--){
	if(dp[i][j]==-1)continue;
	dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
	
	if(j-p[cn][i]<0)continue;
	
	dp[i+1][j-p[cn][i]]=max(dp[i+1][j-p[cn][i]],dp[i][j]+p[cn+1][i]);
	dp[i][j-p[cn][i]]=max(dp[i][j-p[cn][i]],dp[i][j]+p[cn+1][i]);
      }
    }
    for(int i=0;i<111111;i++){
      if(dp[n][i]==-1)continue;
      ma=max(ma,dp[n][i]+i); 
    }
    x=ma;
  }
  cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 7912
#!/usr/bin/env pypy3

import sys


def minimize(n, xs):
    cost = sys.maxsize // 2
    for p in range(min(xs), max(xs) + 1):
        new_cost = sum((x - p) * (x - p) for x in xs)
        cost = min(cost, new_cost)
    return cost


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    opt_cost = minimize(n, xs)
    print(opt_cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()


int main(int argc, char const *argv[]) {
vector<ll> v(5);
ll N;
cin>>N;
REP(i,5){
  cin>>v[i];
}
sort(ALL(v));
ll mod=N%v[0];
ll ans=(N-mod)/v[0];
if(mod==0){
  ans--;
}
cout<<ans+5<<endl;

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;
int N, M;

int G[50][50];

int a[50], b[50];

void dfs(int i, bool visited[]){
    for(int j = 0;j < N;++j){
        if(!G[i][j])continue;
        if(visited[j])continue;
        visited[j] = true;
        dfs(j, visited);
    }
}

int main(){
    cin >> N >> M;
    rep(i, M){
        cin >> a[i] >> b[i];
        --a[i];--b[i];
        G[a[i]][b[i]] = 1;
        G[b[i]][a[i]] = 1;
    }
    int ans = 0;
    rep(i, M){
        bool visited[N];
        rep(i, N)visited[i] = false;
        visited[0] = true;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;
        dfs(0, visited);
        bool flg = false;
        rep(j, N)if(!visited[j])flg = true;
        if(flg)ans += 1;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }
    cout << ans;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

A = [0 for i in range(N)]
B = [0 for i in range(N)]
C = [0 for i in range(N)]

for i in range(N):
    A[i], B[i] = map(int, input().split())
    C[i] = A[i] + B[i]

C.sort(reverse=True)

ans = 0

for i in range(N):
    if i % 2 == 0:
        ans += C[i]

print(ans - sum(B))


Measured memory_bytes: 24552
n = gets.to_i

ac = 0
wa = 0
tle = 0
re = 0

n.times do 
  case gets.chomp
  when "AC"
    ac += 1
  when "WA"
    wa += 1
  when "TLE"
    tle += 1
  when "RE"
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 14280
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int s[50001], t[50001], e[50001];
int b[10001], c[10001];

int main()
{
	int n, m,l,size=0;
	cin >> n >> m;

	while (cin >> s[size] >> t[size] >> e[size]) {
		if (s[size]== 0 && t[size] == 0 && e[size] == 0)break;
		s[size]--, t[size]--;
		size++;
	}
	
	cin >> l;
	rep(i, l) {
		rep(j, 10001)c[j] = 0;
		rep(j, m)cin >> b[j];
		rep(j, size) 
			c[s[j]] += b[t[j]] * e[j];

		rep(j, n) {
			cout << c[j];
			if (j != n - 1)cout << " ";
		}
		cout << endl;
	}

	return	0;
}

Measured memory_bytes: 3748
class Array
	def accum
		inject([0]){|a, x| a + [a[-1] + x]}
	end

	def accum!
		(1..size-1).each{|i|
			self[i] += self[i-1]
		}
		self.unshift(0)
	end

	def accum_2d
		ac = map{|r| r.accum}
		(1..size-1).each{|i|
			(1..ac[0].size-1).each{|j|
				ac[i][j] += ac[i-1][j]
			}
		}
		ac.unshift([0] * ac[0].size)
		ac
	end

	def accum_2d!
		each{|r| r.accum!}
		(1..size-1).each{|i|
			(1..self[0].size-1).each{|j|
				self[i][j] += self[i-1][j]
			}
		}
		unshift([0] * self[0].size)
	end
		
	def bsearch_first_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_first_index(l, c-1, &pred) || c
		else
			bsearch_first_index(c+1, r, &pred)
		end
	end

	def bsearch_first_item(l = 0, r = size - 1, &pred)
		i = bsearch_first_index(l, r, &pred)
		i ? self[i] : nil
	end

	def bsearch_last_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_last_index(c+1, r, &pred) || c
		else
			bsearch_last_index(l, c-1, &pred)
		end
	end

	def bsearch_last_item(l = 0, r = size - 1, &pred)
		i = bsearch_last_index(l, r, &pred)
		i ? self[i] : nil
	end
end

class IntervalTree
	def initialize(l, r)
		@l = l
		@r = r
		@c = (l + r) / 2
		@left_child = @right_child = nil
		@start_sorted = []
		@end_sorted = []
	end

	def add(l, r, x)
		if r < @c
			@left_child ||= self.class.new(l, @c - 1)
			@left_child.add(l, r, x)
		elsif @c < l
			@right_child ||= self.class.new(@c + 1, r)
			@right_child.add(l, r, x)
		else
			i = @start_sorted.bsearch_first_index{|p, q, _| p >= l} || @start_sorted.size
			@start_sorted.insert(i, [l, r, x])
			i = @end_sorted.bsearch_first_index{|p, q, _| q >= r} || @end_sorted.size
			@end_sorted.insert(i, [l, r, x])
		end
	end

	def query(x)
		if x < @c
			ans = @start_sorted.take_while{|l, r| l <= x} 
			ans += @left_child.query(x) if @left_child
			ans
		elsif x > @c
			ans = []
			ans += @right_child.query(x) if @right_child
			i = @end_sorted.bsearch_first_index{|l, r| x <= r}
			ans += @end_sorted[i..-1] if i
			ans
		else
			@start_sorted
		end
	end
end

d, n = gets.split.map &:to_i
temp = (1..d).map{ gets.to_i }

t = IntervalTree.new(0, 60)

n.times {
	a, b, c = gets.split.map &:to_i
	t.add(a, b, c)
}

hash1 = Hash.new(0)
t.query(temp[0]).each{|_, _, c|
	hash1[c] = 0
}
temp.shift

temp.each{|x|
	hash2 = Hash.new(0)
	cloths = t.query(x)
	hash1.each{|c1, v1|
		cloths.each{|_, _, c2|
			value = v1 + (c1 - c2).abs
			hash2[c2] = value if value > hash2[c2]
		}
	}
	hash1 = hash2
}
p hash1.values.max

Measured memory_bytes: 6436
S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

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

int main() {
    string s, ans = "";
    cin >> s;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == '0')ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans.length() >= 1)ans.pop_back();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256