akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n;
    n=s.size();

    char ri_s,le_s;
    le_s=s[0];
    ri_s=s[n-1];
    if(s[0]!=s[n-1]){
        ll ri=0;
        ll le=0; 
        FOR(i,0,n){
            if(s[i]==ri_s)ri++;
            if(s[i]==le_s)le++;
        }
        if((n-2*min(ri,le))%2==0)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }else{
        if(n%2==1)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    public static int fib(int n, int num[], boolean data[]){
        if(!(data[n])){
            data[n] = true;
            num[n] = fib(n-1,num,data) + fib(n-2,num,data);
            return num[n];
        }
        else
            return num[n];
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n+1];
        boolean data[] = new boolean[n+1];
        num[0] = num[1] = 1;
        data[0] = data[1] = true;
        System.out.println(fib(n,num,data));
    }
}


Measured memory_bytes: 26156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void NO(){cout<<"NO"<<endl;exit(0);}
ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll lcm(ll x, ll y){return x/gcd(x,y)*y;}
int main(){
ll n;cin>>n;ll a=1;for(int i=0;i<n;++i){ll x;cin>>x;a=lcm(a,x);}cout<<a<<endl;
return 0;}

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

const int mxN=100, mxK=1e5;
int n, a[mxN], k;
bool dp[mxK+1];

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

	cin >> n >> k;
	for(int i=0; i<n; ++i)
		cin >> a[i];
	for(int i=0; i<=k; ++i) {
		for(int j=0; j<n; ++j)
			if(i-a[j]>=0&&!dp[i-a[j]])
				dp[i]=1;
	}
	cout << (dp[k]?"First":"Second");
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int ans = 0;
        string s,t;
        cin >> s >> t;
        for(int i = 0; i < 3; ++i){
            ans += (s[i] == t[i]);
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int num=0;
    int ans=1;
    for(int i=0;i<n;i++){
        num+=a[i];
        if(num<=x)ans++;
    }
    cout << ans<<endl;
    return 0;
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

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

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string s = readString();
  auto isEvenString = [](string &s) {
    if (s == "abcabc")
      if (s.size() & 1)
        return false;
    if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2))
      return true;
    return false;
  };
  s.pop_back();
  while (!isEvenString(s))
    s.pop_back();
  std::cout << s.size() << std::endl;
}


Measured memory_bytes: 2304
"use strict";

function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  var P = 1e9 + 7;

  function* rangeRev(start, end) {
    for (var i = start - 1; i >= end; i--) {
      yield i;
    }
  }

  function makeArr(size, defaultValue) {
    if (!Array.isArray(size)) size = [size];
    if (1 === size.length) return new Array(size[0]).fill(defaultValue);

    var _size = size,
        _size2 = _toArray(_size),
        here = _size2[0],
        rest = _size2.slice(1);

    return new Array(here).fill(null).map(function () {
      return makeArr(rest, defaultValue);
    });
  }

  !function (input) {
    var L = input.split("\n")[0];
    var len = L.length;
    var dp = makeArr([2, len], 0);
    dp[0].push(1);
    dp[1].push(1);
    var _iteratorNormalCompletion = true;
    var _didIteratorError = false;
    var _iteratorError = undefined;

    try {
      for (var _iterator = rangeRev(len, 0)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
        var i = _step.value;
        if (0 == +("1" === L[i])) dp[0][i] = dp[0][i + 1];else {
          var nrm = 2 * dp[0][i + 1] % P;
          dp[0][i] = (nrm + dp[1][i + 1]) % P;
        }
        dp[1][i] = 3 * dp[1][i + 1] % P;
      }
    } catch (err) {
      _didIteratorError = true;
      _iteratorError = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion && _iterator.return != null) {
          _iterator.return();
        }
      } finally {
        if (_didIteratorError) {
          throw _iteratorError;
        }
      }
    }

    console.log(dp[0][0]);
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


Measured memory_bytes: 33816
import math

K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(1, K + 1):
        ab_gcd = math.gcd(a, b)
        for c in range(1, K + 1):
            ans += math.gcd(ab_gcd, c)
print(ans)


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

const int MAX_N=100005;
const int INT_MAX=2147483647;
int n,dat[4*MAX_N];

void init(int n_){
	n=1;
	while(n<n_)n*=2;
	for(int i=0;i<2*n-1;i++)dat[i]=INT_MAX;
}

void update(int k,int x){
	k+=n-1;
	dat[k]=x;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[2*k+1],dat[2*k+2]);
	}
}

int query(int a,int b,int k,int l,int r){
	if(r<=a||b<=l)return INT_MAX;
	if(a<=l && b>=r)return dat[k];
	int vl=query(a,b,2*k+1,l,(l+r)/2);
	int vr=query(a,b,2*k+2,(l+r)/2,r);
	return min(vl,vr);
}

int main(){
	int N,Q;
	cin>>N>>Q;
	init(N);
	for(int i=0;i<Q;i++){
		int c,x,y;
		scanf("%d%d%d",&c,&x,&y);
		if(c==0)update(x,y);
		else printf("%d\n",query(x,y+1,0,0,n));
	}
}

Measured memory_bytes: 2256
n,k=map(int,input().split())
l=[]
c=0
a=[ i+1 for i in range(n)]
#print(a)
for i in range(k):
    d=int(input())
    l1=list(map(int,input().split()))
    for j in l1:
        l.append(j)

        

print(len(set(a)-set(l)))
  


Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
	//単位いらねえとか思ってタカをくくって課題遅刻しました。
	//
	int a,b;
	cin >> a;
	cin >> b;
	printf("%d %d\n",a*b,a*2+b*2);
	return 0;
}



Measured memory_bytes: 3228
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Data
{
	int num;
	int val;
}b[100005];
int n,m,a[100005],maxx[100005];
bool cmp1(int a,int b)
{
	return a>b;
}
bool cmp(Data x,Data y)
{
	return x.val>y.val;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=m;i++)scanf("%d%d",&b[i].num,&b[i].val);
	sort(b+1,b+m+1,cmp);
	ll sum=0;
	int rest=n;
	int nowa=1,nowb=1;
	while(rest)
	{
		if(a[nowa]>b[nowb].val)
		{
			sum+=a[nowa];
			nowa++;
			rest--;
		}
		else
		{
			sum+=1ll*b[nowb].val*min(b[nowb].num,rest);
			rest-=b[nowb].num;
			if(rest<0)rest=0;
			nowb++;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1280
N, M = map(int, input().split())
rec = [[0,0] for _ in range(N)]
AC = 0
pe = 0

for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        rec[p-1][1] = 1
    else:
        if rec[p-1][1] == 0:
            rec[p-1][0] += 1

for i in range(N):
    if rec[i][1] == 1:
        AC += 1
        pe += rec[i][0]

print(AC,pe)

Measured memory_bytes: 13172
<?php
class Dice{
  public $label=[1,2,3,4,5,6];#index+1????????¢?????????
  public $pos=[0,1,2];#?????¢,?????¢,??\??¢???index ???????????¢???5-index
  function __construct($sLabel){$this->label=explode(' ',$sLabel,6);}
  function move($s){
    $x=$this->pos[0];
    if($s=='E'){
      $this->pos[0]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
    elseif($s=='W'){
      $this->pos[0]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='N'){
      $this->pos[0]=$this->pos[1];
      $this->pos[1]=5-$x;
    }
    elseif($s=='S'){
      $this->pos[0]=5-$this->pos[1];
      $this->pos[1]=$x;
    }
  }
  function spin($s){
    $x=$this->pos[1];
    if($s=='L'){
      $this->pos[1]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='R'){
      $this->pos[1]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
  }
  function toTop($label){
    $move=array('','N','W','W','W','N');#1 2 3 5 4 6
    for($i=0;$i<6;$i++){
      $this->move($move[$i]);
      if($this->top()==$label) return 1;
    }
    return 0;
  }
  function toSpin($label){
    for($j=0;$j<4;$j++){
      if($this->front()==$label) return 1;
      $this->spin('L');
    }
    return 0;
  }
  function isSame($dice){
    $move=array('','N','W','W','W','N');#1 2 3 5 4 6
    $end=[];
    for($i=0;$i<6;$i++){
      $this->move($move[$i]);
      $top=$this->top();
      if(isset($end[$top])) continue;
      $end[$top]=1;
      if(!$dice->toTop($top)) continue;
      if(!$dice->toSpin($this->front())) continue;
      if($dice->right()!=$this->right()) continue;
      if($dice->bottom()!=$this->bottom()) continue;
      if($dice->back()!=$this->back()) continue;
      if($dice->left()!=$this->left()) continue;
      return 1;
    }
    return 0;
  }
  function top(){return $this->label[$this->pos[0]];}
  function front(){return $this->label[$this->pos[1]];}
  function right(){return $this->label[$this->pos[2]];}
  function bottom(){return $this->label[5-$this->pos[0]];}
  function back(){return $this->label[5-$this->pos[1]];}
  function left(){return $this->label[5-$this->pos[2]];}
}

$n=trim(fgets(STDIN));
$d=[];
for($i=0;$i<$n;$i++) $d[]=new Dice(trim(fgets(STDIN)));

$l=$n-1;
$F=1;
for($i=0;$i<$l;$i++){
  for($j=$i+1;$j<$n;$j++){
    if($d[$i]->isSame($d[$j])){$F=0;break;}
  }
}
echo ($F)?'Yes':'No';
?>

Measured memory_bytes: 15596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

const ll INF = 1e18;
vector<int> pow2(16, 1);

int main () {
    for (int i = 0; i <= 14; i++) {
        pow2[i+1] = pow2[i] * 2;
    }

    int n; cin >> n;
    vector<ll> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];
    
    vector<vector<ll>> ver(1<<n, vector<ll> (n)), hor(1<<n, vector<ll> (n));
    rep(i, 1<<n) {
        vector<int> c;//路線通す都市
        rep(j, n) {
            if ((i >> j) & 1) c.push_back(j);
        }
        rep(j, n) {
            {
                ll cost = min(abs(x[j]) * p[j], abs(y[j]) * p[j]);
                for (int q : c) {
                    cost = min(cost, abs((x[j] - x[q]) * p[j]));
                }
                ver[i][j] = cost;
            }
            {
                ll cost = min(abs(x[j]) * p[j], abs(y[j]) * p[j]);
                for (int q : c) {
                    cost = min(cost, abs((y[j] - y[q]) * p[j]));
                }
                hor[i][j] = cost;
            }
            
        }
    }

    vector<ll> ans(n+1, INF);
    for (int i = 0; i < (1 << n); i++) {
        int k = _popcnt32(i);
        vector<int> city;
        rep(j, n) {
            if ((i >> j) & 1) city.push_back(j);
        }
        for (int j = 0; j < (1 << k); j++) {
            int _ver = 0, _hor = 0;
            rep(l, k) {
                if ((j >> l) & 1) _ver += pow2[city[l]];
                else _hor += pow2[city[l]];
            }
            ll cost = 0;
            rep(l, n) {
                cost += min(ver[_ver][l], hor[_hor][l]);

            }
            ans[k] = min(ans[k], cost);
        }
    }
    for (int k = 0; k <= n; k++) cout << ans[k] << endl;
    return 0;
}

Measured memory_bytes: 13012
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	string s,ans="Yes";
	cin >> s;
	rep(i, s.size()) {
		if (s.at(i) == 'U' || s.at(i) == 'D') {
			continue;
		}
		if (i % 2 == 0) {
			if (s.at(i) == 'L') {
				ans = "No";
			}
		}
		else {
			if (s.at(i) == 'R') {
				ans = "No";
			}

		}
	}

	cout << ans;

}

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

int main() {
	int R;
	cin >> R;
	string contest = R < 1200 ? "ABC" : (R < 2800 ? "ARC" : "AGC");
	cout << contest << endl;

	return 0;
}

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

int main(){
	int n;
  	long x=0 ,y=0;
  	cin >> n;
  	vector<long> a(n);
  	for(int i = 0 ; i < n;i++)
      	cin >> a[i];
  	sort(a.begin(),a.end());
  	int tmp = a[n-1];
  	bool xnow = true;
  	for(int i = n-2; i >= 0; i--) {
      	if(tmp == a[i]) {
        	if(xnow) {
              	x = tmp;
              	xnow=false;
            } else {
            	y = tmp; 
              	break;
            }
          	tmp = 0;
        } else {
        	tmp = a[i]; 
        }
    }
  	cout << x*y << endl;
}


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


int main(){
  ll a,b,c,k;
  cin >>a>>b>>c>>k;

  ll sum = k;
  ll count =0 ;
  if(sum<=a){
    cout <<k<<endl;
    return 0;
  }
  count +=a;
  sum-=a;
  if(sum<=b){
    cout <<count<<endl;
    return 0;
  }
  sum-=b;

  if(sum>=c){
    count-=c;
    cout<<count<<endl;
    return 0;
  }
  else{
    count-=sum;
    cout <<count<<endl;
    return 0;
  }



}



Measured memory_bytes: 3616
#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 MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll t;
	cin >>n >>t;
	VL p(n);
	rep(i, n) cin >>p[i];
	ll ans = 0, bgn = 0;
	rep2(i, 1, n){
		if(p[i] - p[i-1] >= t){
			ans += t;
		}else{
			ans += p[i] - bgn;
		}
		bgn = p[i];
	}
	
	cout << ans + t <<"\n";

	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

void printVector(const vector<string>& vec) {
  for (auto value : vec) {
    cout << value << "";
  }
  cout << endl;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  vector<string> ans(s.size());
  for (int i = 0; i < s.size(); i++) {
    if (i >= k) {
      ans[i] = "...";
      break;
    } else
      ans[i] = s[i];
  }

  printVector(ans);
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, N;
    cin >> H >> N;

    ll sum = 0;
    rep (i, N) {
        ll A;
        cin >> A;
        sum += A;
    }

    if (sum >= H) {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

for i in range(n):
    for j in range(n):
        if j+m <= n and i+m <= n:
            if [a[i+k][j:j+m] for k in range(m)] == b:
                print('Yes')
                exit()
else:
    print('No')


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
const int mod=1e9+7;


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

    string k;
    cin>>k;

    int d;
    cin>>d;


    vector<vector<int>>dp(d,vector<int>(2));

    int n=k.length();
    dp[0][0]=1;

    for(int i=0;i<n;i++){

	vector<vector<int>>dp1(d,vector<int>(2));

       for(int j=0;j<d;j++){

	for(bool small:{false,true}){

         for(int digit=0;digit<10;digit++){


                        if(digit>k[i]-'0' && !small){
			    break;
			}


                        dp1[(j+digit)%d][(digit<k[i]-'0') || (small)] = (dp1[(j+digit)%d][(digit<k[i]-'0') || (small)] + dp[j][small])%mod;


		  }



	    }
	}



	dp=dp1;

	debug()<<imie(dp);


    }



        int answer = (dp[0][false] + dp[0][true]) % mod;



        --answer;
    if(answer == -1) {
        answer = mod - 1;
    }
    printf("%d\n", answer);















}


Measured memory_bytes: 3680
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let vs: Vec<i32> = s.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = vs[0];
    let b = vs[1];
    let c = vs[2];

    println!("{}", if a == b {c} else if b == c {a} else {b});
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace  std;
using ll = long long;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
signed main(){
    int N, x;
    cin >> N >> x;
    if(N==2 and x!=2){
        cout << "No" << endl;
        return 0;
    }
    if(x == 2*N-1 or x == 1){
        cout << "No" << endl;
        return 0;
    }
    else {
        cout << "Yes" << endl;
    }
    vector<ll> res(2*N-1);
    vector<ll> used(2*N+10, 0);
    res[N-2] = x+1;
    res[N-1] = x;
    res[N] = x-1;
    used[x+1] = 1;
    used[x] = 1;
    used[x-1] = 1;
    int idx = 1;
    for(int i=0; i<2*N-1; i++){
        if(i==N or i==N-1 or i==N-2) continue;
        while(used[idx] and idx<2*N) idx++;
        res[i] = idx; 
        used[idx] = 1;
        idx++;
    }
    REP(i, 2*N-1) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 4608
/**
 * @file main.cpp
 * @author tarotene (tarotene@gmail.com)
 * @brief Insertion Sort (ALDS1_1_A)
 * @version 0.1
 * @date 2019-03-30
 * 
 * @copyright Copyright (c) 2019
 * 
 */

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

static const int MAX = 100000;

int main(int argc, char const *argv[])
{
    vector<int> A(MAX, 0);

    int n = 0;
    cin >> n;

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

    cout << A[0];
    for (int k = 1; k < n; ++k)
    {
        cout << " " << A[k];
    }
    cout << endl;

    for (int i = 1; i < n; ++i)
    {
        int v = A[i];

        int j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        cout << A[0];
        for (int k = 1; k < n; ++k)
        {
            cout << " " << A[k];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	
	cout << (min(A, B) + min(C, D)) << endl;
	
	
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> C(n);
    vector<int> S(n);
    vector<int> F(n);
    for (int i = 1; i < n; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }
    for (int i = 1; i < n; i++) {
        int time = 0;
        for (int j = i; j < n; j++) {
            while(1){
                if(time >= S[j] && time % F[j] == 0){
                    time += C[j];
                    break;
                }
                if(time < S[j]) time = S[j];
                if(time % F[j] != 0) time += F[j] - (time % F[j]);
            }
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}


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

using namespace std;


int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  vector<pii> ss;
  int x;
  for(int i = 0 ;i  < n; i ++ ){
    cin >> x;
    ss.push_back(mp(x,i));
  }
  sort(ss.begin(), ss.end());
  int res = 0;
  for(int i = 0 ; i < n; i ++ ){
    res += (i % 2) != (ss[i].se % 2);
  }
  cout << res/2;
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 250005;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int n, l, a[MAXN];
lint d[2 * MAXN];
lint s1[MAXN * 2], s2[MAXN * 2];

lint gsum(int s, int e){
	return s1[e] - s1[s];
}

lint linsum(int s, int e){
	return s2[e] - s2[s];
}

lint solve(){
	sort(a, a + n);
	a[n] = l;
	for(int i=0; i<n; i++){
		d[i] = a[i+1] - a[i];
	}
	d[n] = a[0];
	for(int i=0; i<n-1; i++) d[i+n+1] = d[i];
	for(int i=0; i<2*n; i++){
		s1[i+1] = s1[i] + d[i];
		s2[i+1] = s2[i] + 1ll * d[i] * i;
	}
	lint dap = 0;
	for(int i=0; i<=n; i++){
		int min_len = min(n - i, i);
		lint ret = 0;
		ret += linsum(i, i + min_len) * 2 + (1 - 2 * i) * gsum(i, i + min_len);
		ret += (2 * n + 2 * i) * gsum(n + i - min_len, n + i) - 2 * linsum(n + i - min_len, n + i);
		/*
		for(int j=i; j<i+min_len; j++){
			ret += ((j - i) * 2 + 1) * d[j];
		}
		for(int j=n+i-min_len; j<n+i; j++){
			ret += ((n + i - j) * 2) * d[j];
		}*/
		lint tmp = gsum(i + min_len, n + i - min_len);
		if(i + min_len != n){
			ret += tmp * (2 * min_len + 1);
		}
		else{
			ret += tmp * (2 * min_len);
		}
		dap = max(dap, ret);
	}
	return dap;
}

int main(){
	cin >> l >> n;
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	lint ret = solve();
	for(int i=0; i<n; i++) a[i] = l - a[i];
	ret = max(ret, solve());
	cout << ret << endl;
}


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

using Graph = vector< vector<int> > ;
const int64_t MOD = 1000000007;

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

  Graph G(N+1);
  vector<int> seen(N+1,-1);
  for (int i=0;i<N-1;++i ) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
//  for( int i=0;i<N;++i) {
//    cout << i << " :";
//    for( auto g0 : G[i] ) {
//      cout << " " << g0;
//    }
//    cout << endl;
//  }

  int64_t ans = K;
  int64_t child = K-1;
  
  queue<int> q;
  q.push(0);
  seen[0] = K-1;
  while( !q.empty() ) {
    int v = q.front(); q.pop();
    child = seen[v];
//    cout << v << ":";
    for ( auto a: G[v] ) {
//      cout << a << "-";
      if ( seen[a] != -1) continue;
//      cout << a << " " << child << ", ";
      q.push(a);
      ans = (ans * child) % MOD;
      child--;
      seen[a] = K-2;
    }
//    cout << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define enter putchar('\n')
#define space putchar(' ')
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
vector<pii> E[500005];
set<pii> s;
int n, m, ncnt, d[500005], id[500005][2];
struct EDGE {
	int l, r, c;
} e[200005];
template <class T> int read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (c > -1 && c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
	if (c == -1) return 0;
	while (c >= '0' && c <= '9') { x = x * 10 + c - 48; c = getchar(); }
	return x *= f, 1;
}
template <class T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
bool cmp(EDGE a, EDGE b) {
	return a.c < b.c;
}
int main() {
	while (read(n), read(m)) {
		ncnt = n;
		for (int i = 1; i <= n; ++i)
			E[i].clear();
		for (int i = 1; i <= m; ++i)
			read(e[i].l), read(e[i].r), read(e[i].c);
		sort(e + 1, e + m + 1, cmp);
		for (int i = 1; i <= n; ++i)
			id[i][0] = 0;
		for (int i = 1; i <= m; ++i) {
			if (id[e[i].l][0] != e[i].c) {
				id[e[i].l][0] = e[i].c;
				id[e[i].l][1] = ++ncnt;
				E[ncnt].clear();
				E[ncnt].pb(mp(e[i].l, 1));
				E[e[i].l].pb(mp(ncnt, 1));
			}
			if (id[e[i].r][0] != e[i].c) {
				id[e[i].r][0] = e[i].c;
				id[e[i].r][1] = ++ncnt;
				E[ncnt].clear();
				E[ncnt].pb(mp(e[i].r, 1));
				E[e[i].r].pb(mp(ncnt, 1));
			}
			E[id[e[i].l][1]].pb(mp(id[e[i].r][1], 0));
			E[id[e[i].r][1]].pb(mp(id[e[i].l][1], 0));
		}
		fill(d, d + ncnt + 1, -1);
		d[1] = 0;
		s.insert(mp(d[1], 1));
		while (!s.empty()) {
			int u = s.begin() -> se;
			s.erase(s.begin());
			for (int i = 0; i < E[u].size(); ++i) {
				int v = E[u][i].fi;
				if (d[v] > d[u] + E[u][i].se || d[v] == -1) {
					s.erase(mp(d[v], v));
					d[v] = d[u] + E[u][i].se;
					s.insert(mp(d[v], v));
				}
			} 
		}
		write(d[n] >> 1), enter;
	}
	return 0;
}

Measured memory_bytes: 41312
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n,k;string s;
  cin>>n>>k>>s;
  --k;
  switch(s[k]){
    case 'A':
      s[k]='a';
      break;
    case 'B':
      s[k]='b';
      break;
    case 'C':
      s[k]='c';
      break;
  }
  cout<<s;
  return 0;
}

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  const int inf = (int) 1e9;
  vector<int> dp(n, inf);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), (i - 2 < 0 ? inf : dp[i - 2] + abs(h[i] - h[i - 2])));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

 #define rep(i, a, b) for (int i = a; i <= b; i++)
 #define dep(i, a, b) for (int i = a; i >= b; i--)
 #define vep(i, v) for (int i = 0; i < (int)v.size(); i++)
 #define fill(a, x) memset(a, x, sizeof(a))
 #define pb push_back

 typedef vector<int> Vi;

 const int N = 2000 + 5, M = N * N, INF = 0x3f3f3f3f;

 int n, es;
 int a[N], pre[N];
 Vi all, cur;
 bool vis[N];

 struct Edge { int from, to, pre; } e[M];
 inline void init_graph() { es = 0; fill(vis, 0); fill(pre, 0); }
 inline void ine(int a, int b) {
 	int i = ++es;
 	e[i].from = a; e[i].to = b; e[i].pre = pre[a];
 	pre[a] = i;
 }
 inline void ine2(int a, int b) { ine(a, b); ine(b, a); }
 #define reg(i, x) for (int i = pre[x]; i; i = e[i].pre)

 inline bool cmp(int x, int y) { return x >= y; }
 inline int gcd(int x, int y) { return (!y) ? x : gcd(y, x % y);}

 inline void merge(Vi &v1, Vi v2) {
 	Vi tmp;
 	int p1 = 0, p2 = 0, s1 = v1.size(), s2 = v2.size();
 	tmp.clear();
 	while (p1 < s1 && p2 < s2) {
 		int x = v1[p1], y = v2[p2];
 		if (a[x] > a[y]) tmp.pb(x), p1++; else tmp.pb(y), p2++;
 	}
 	if (p1 < s1) rep(i, p1, s1 - 1) tmp.pb(v1[i]);
 	else rep(i, p2, s2 - 1) tmp.pb(v2[i]);
 	v1 = tmp;
 }

 inline Vi dfs(int x) {
 	vis[x] = true;
 	Vi ret, cur;
 	ret.clear();
 	ret.pb(0);
 	reg(i, x) {
 		int y = e[i].to;
 		if (!vis[y]) {
 			cur = dfs(y);
 			merge(ret, cur);
 		}
 	}
 	ret[0] = x;
 	// printf("ret[%d] = ", x); vep(i, ret) printf("%d ", ret[i]); puts("");
 	return ret;
 }

int main()
{
	// freopen("atc2306.in", "r", stdin);

	scanf("%d", &n);
	a[0] = INF;
	rep(i, 1, n) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, cmp);

	init_graph();
	rep(i, 1, n - 1) rep(j, i + 1, n)
		if (gcd(a[i], a[j]) > 1) ine2(i, j);

	all.clear();
	dep(i, n, 1) if (!vis[i]) {
		cur = dfs(i);
		merge(all, cur);
		// printf("i = %d :: ", i);
		// vep(i, all) printf("%d ", a[all[i]]); puts("");
	}
	// vep(i, all) printf("%d ", a[all[i]]); puts("");
	rep(i, 0, n - 2) printf("%d ", a[all[i]]);
	printf("%d\n", a[all[n - 1]]);
	return 0;
}


Measured memory_bytes: 31232
from decimal import *
num1, num2, num3 = map(int, input().split())
num1 = Decimal(num1)
num2 = Decimal(num2)
num3 = Decimal(num3)
if (num1.sqrt() + num2.sqrt() < num3.sqrt()):
  print("Yes")
else:
  print("No")

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

int N;
int t[100003];
int x[100003];
int y[100003];

int abs(int x){
  if(x > 0){
    return x;
  }
  else{
    return -x;
  }
}

bool f(int a, int b, int c, int d, int t){
  if((abs(a - c) + (b - d) - t) % 2== 0 and abs(a-c) + abs(b-d) <= t){
    return true;
  }
  else{
    return false;
  }
}

int main(void){
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  for(int i = 1; i <= N; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  bool flag = true;

  for(int i = 0; i < N; i++){
    flag = flag and f(x[i], y[i], x[i + 1], y[i + 1], t[i + 1] - t[i]);
  }

  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
package main

import "fmt"

func main() {
	var n int
	var k int64
	fmt.Scan(&n)
	fmt.Scan(&k)

	a := make([]int, n, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a[i] = tmp - 1
	}

	v := make([]bool, n, n)
	t := make([]int, n, n)

	h := 0
	i := 1
	for !v[h] {
		t[h] = i
		v[h] = true

		h = a[h]

		if int64(i) == k {
			fmt.Println(h + 1)
			return
		}

		i++
	}

	p := int64(i - t[h])
	q := (k-int64(t[h]))%p + int64(t[h])

	answer := 0
	for i := int64(0); i < q; i++ {
		answer = a[answer]
	}
	fmt.Println(answer + 1)
}


Measured memory_bytes: 8204
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> r(a), g(b), col(c);
    priority_queue<ll, vector<ll>, greater<ll> > pq;

    rep (i, 0, a-1) cin >> r[i];
    rep (i, 0, b-1) cin >> g[i];
    rep (i, 0, c-1) cin >> col[i];

    sort(r.begin(), r.end(), greater<int>());
    sort(g.begin(), g.end(), greater<int>());
    sort(col.begin(), col.end(), greater<int>());

    int tot = x + y, ct = 0;
    ll ans = 0;
   	for (int i=0; i<min(x, a); i++) { 
   		pq.push(r[i]);
   		ans += r[i];
   		ct++;
   	}
   	for (int i=0; i<min(y, b); i++) {
   		pq.push(g[i]);
   		ans += g[i];
   		ct++;
   	}

   	int k=0;
    while (ct < tot && k < c) {
    	pq.push(col[k++]);
    	ct++;
    }
    rep (i, k, c-1) {
    	//db2(pq.top(), col[i]);
    	if (pq.top() < col[i]) {
    		ans -= pq.top();
    		pq.pop();
    		ans += col[i];
    		pq.push(col[i]);
    	} else {
    		break;
    	}
    }
    cout << ans;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll a[200100];
int main(void){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  ll ans=0;
  for(int i=1;i<n;i++){
    if(a[i-1]>a[i]){
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  cout<<ans<<endl;
}

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

int main(){
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int count=0;
  for(int i=1;i<3;i++){
    count+=abs(A[i-1]-A[i]);
  }
  cout<<count<<endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

#define INF 1LL<<60

// graph by adjacency matrix

template <typename T>
struct Graph {
  int V;
  vector<vector<T>> adj;

  Graph(int V) : V(V) {
    adj.resize(V, vector<T>(V, INF));
    for (int i = 0; i < V; i++) adj[i][i] = 0;
  }

  void add_edge(int src, int dst, T weight) {
    adj[src][dst] = weight;
  }

};

template <typename T>
struct AllPairsShortestPath {
  Graph<T> g;
  vector<vector<T>> dist;

  AllPairsShortestPath(const Graph<T> &g) : g(g) {
    dist.resize(g.V, vector<T>(g.V));
    for (int i = 0; i < g.V; i++) {
      for (int j = 0; j < g.V; j++) dist[i][j] = g.adj[i][j];
    }
  }


  void warshall_floyd() {
    for (int k = 0; k < g.V; k++) {
      for (int i = 0; i < g.V; i++) {
	for (int j = 0; j < g.V; j++) {
	  if (dist[i][k] != INF and dist[k][j] != INF) {
	    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	  }
	}
      }
    }
  }

  bool has_negative_loop() {
    for (int i = 0; i < g.V; i++) {
      if (dist[i][i] < 0) return true;
    }
    return false;
  }
};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int V, E; cin >> V >> E;
  Graph<ll> g(V);
  REP(i, E) {
    int s, t, d; cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }
  AllPairsShortestPath<ll> apsp(g);
  apsp.warshall_floyd();
  if (apsp.has_negative_loop()) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, g.V) {
      REP(j, g.V) {
	if (apsp.dist[i][j] == INF) {
	  cout << "INF" << (j == g.V-1 ? '\n' : ' ');
	} else {
	  cout << apsp.dist[i][j] << (j == g.V-1 ? '\n' : ' ');
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3348
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

x = []

res = True
for i in range(N):
    w = input()
    w = w[:(len(w)-1)]
    if w in x:
        res = False
    x.append(w)
    if i > 0: 
        if w[0] != x[i-1][-1]:
            res = False
        

if res:print("Yes")
else:print("No")


Measured memory_bytes: 21748
from collections import deque

n = int(input())
g = [None] * (n+1)
ans = [0] * (n+1)

for _ in range(n):
    u,k,*vk = map(int,input().split())
    g[u] = vk

def bfs(now):
    que = deque()
    que.append(now)
    while que.__len__() != 0:
        now = que.popleft()
        for ne in g[now]:
            if ans[ne] != 0:
                continue
            ans[ne] = ans[now]+1
            que.append(ne)

bfs(1)
ans = [i if i != 0 else -1 for i in ans]
ans[1] = 0

print("\n".join("{} {}".format(*args) for args in zip(range(1, n+1), ans[1:])))


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#include <string.h>
#define ll  long long int



int main(void)
{


    int x,y,m,n;
    bool arr[105]={false};

    cin>>x>>y;

    for(int i=0;i<y;i++)
    {
        cin>>m;
        arr[m]=true;
    }
    if(arr[x]==false)
    {
        cout<<x<<endl;
        return 0;
    }
    int s=x-1,l=x+1;
    while(arr[s]!=false && s>0)
    {
        s--;
    }
    while(arr[l]!=false && l<101)
    {
        l++;
    }
    if(abs(x-s)<=abs(x-l))
    {
        cout<<s<<endl;
    }
    else
    {
        cout<<l<<endl;
    }



    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
#define ll long long
ll gcd(ll a, ll b) {
	if(b==0) return -1;
	if(a<b) swap(a,b);
	while(b) {
		ll t = a / b;
		swap(a-=t*b,b);
	}
	return a;
}
ll lcm(ll a, ll b) {
	ll c = gcd(a,b);
	return a * b / c;
}
int main(){
	int n;
	while(cin >> n, n) {
		ll d[10], v[10];
		rep(i,n) {
			cin >> d[i] >> v[i];
		}
		ll tr = d[0], td = v[0];
		rep2(i,1,n) {
			tr = lcm(tr * v[i], td * d[i]);
			td *= v[i];
			ll div = gcd(tr,td);
			tr /= div, td /= div;
		}
		rep(i,n) {
			cout << (tr*v[i]) /(d[i]*td) << endl;
		}
	}
}

Measured memory_bytes: 1164
import java.util.Scanner;
public class Main {
     public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int d;
        int ans = 0;
        
        int[] C = new int[(int) N];
        for(int i = 0; i < N ; i++){
            C[i] = 1;
        }
        for(int n = 0; n < K ; n++){
            d = sc.nextInt();
            int[] A = new int[(int)d];
                for(int i = 0 ; i < d ; i++){
                    A[i] = sc.nextInt();
                    C[A[i] - 1] = 0;
                    
                }
        }
        
        for(int i = 0; i < N ;i++){
            ans = ans + C[i];
        }        
        System.out.println(ans);
    
    }
}

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

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
	 //降順ならreturn *(int*)b - *(int*)a;
}
int hikaku(int a, int b, int c)
{
	if (a+b<=c)return -1;
	if (b+c<=a)return -1;
	if (c+a<=b)return -1;
	return 0;
}
int main()
{
	int N,i,j,k,ans=0;
	scanf("%d", &N);
	int(*L)= (int(*))
		malloc(N * sizeof(int));
	for (i = 0;i < N;i++)scanf("%d", &L[i]);
	qsort(L, N, sizeof(int), cmp);
	for (i = 0;i < N;i++)
	{
		for (j = i+1;j < N;j++) {
			for (k = j + 1;k < N;k++)
			{
				if (hikaku(L[i], L[j], L[k]) == 0)ans++;
				else break;
			}
		}
	}
	printf("%d\n", ans);
	free(L);
	return 0;
}

Measured memory_bytes: 128
import collections
N = int(input())
W = list(map(int, input().split()))
c = dict(collections.Counter(W))

if len(c.keys()) == 1:
  if c.get(0, False) == False:
    print('No')
  else:
    print('Yes')
if len(c.keys()) == 2:
  num = list(c.values())
  num = sorted(num)
  if 0 in c:
    if c[0]*2 == num[1]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
if len(c.keys()) == 3:
  num = list(c.values())
  key = list(c.keys())
  if num[0] == num[1]:
    if num[0] == num[2]:
      if bin(key[0]^key[1]) == bin(key[2]):
        print("Yes")
      else:
        print("No")
    else:
      print("No")
  else:
    print("No")
if len(c.keys()) >= 4:
  print("No")

Measured memory_bytes: 16932
#include<stdio.h>

#define N 500000
#define INFTY 1000000000

void mergeSort(int S[],int n,int left,int right);
void merge(int S[],int n,int left,int mid,int right);

int L[N/2 + 2],R[N/2 + 2];
int count;

int main(void)
{
  int S[N],n;
  int i;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,n,0,n);

  printf("%d",S[0]);
  for(i = 1;i < n;i++){
    if(i != n) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}
    




void merge(int S[],int n,int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  for(i = 0;i < n1;i++){
    L[i] = S[left+i];
  }
  for(i = 0;i < n2;i++){
    R[i] = S[mid+i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  i = 0;
  j = 0;
  
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    } else {
      S[k] = R[j];
      j++;
    }
    count++;
  }
}



void mergeSort(int S[],int n,int left,int right){
  int m;
  
  if(left+1 < right){
    m = (left + right)/2;
    
    mergeSort(S,n,left,m);
    mergeSort(S,n,m,right);
    merge(S,n,left,m,right);
  }
}



Measured memory_bytes: 5672
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        int cnt = 1, x = 7, MAX = 1e8;
        while (x % n > 0) {
            cnt++;
            x = (x * 10 + 7) % n;
            if (cnt == MAX) {
                cout << "-1\n";
                return 0;
            }
        }

        cout << cnt << '\n';
    }
    
    return 0;
}



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

using namespace std;

bool alloc(const vector<int> &ws, int k, int p) {
    int cur = 0;
    int use = 0;
    for(auto&& w : ws) {
        if(w > p) return false;
        if(cur + w > p) {
            use++;
            cur = 0;
            if(use>=k) return false;
        }
        cur += w;
    }
    return true;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> ws(n);
    int min_w = 100000;
    int sum_w = 0;
    for(int i=0; i<n; i++) {
        cin >> ws[i];
        sum_w += ws[i];
        min_w = min(min_w, ws[i]);
    }
    int ng = 0;
    int ok = sum_w;
    
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(alloc(ws, k, mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    
    
}


Measured memory_bytes: 3100
// abc135_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    auto P = A;
    sort(ALL(P));

    int tmp = 0;
    REP(i, N){
        if (A[i] != P[i]){
            tmp++;
        }
    }
    if (tmp == 2 || tmp == 0){
        print("YES");
    }else {
        print("NO");
    }


    return 0;
}


Measured memory_bytes: 256