akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> l_switch(m);
    rep(i,m){
        int k;
        cin >> k;
        rep(j, k){
            int s;
            cin >> s; 
            s--;
            l_switch[i].push_back(s);
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];

    int ans = 0;
    rep(i, 1<<n){
        int led_on = 0;
        rep(j, m){
            int on = 0;
            for(int s : l_switch[j]){
                if (i>>s&1) on++;
            }
            if (on % 2 == p[j]) led_on++;;
        }
        if (led_on == m) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.1415;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	int N, K; cin >> N >> K;
	ll minN = 0;
	ll maxN = 0;
	ll ans = 0;
	for (int i = 0; i < K;++i) {
		minN += i;
		maxN += (N - i);
		ans = maxN - minN + 1;
	}
	for (int i = K; i < N + 1; ++i) {
		minN += i;
		maxN += (N - i);
		ans = (ans + (maxN - minN + 1)) % MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 5440
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] likes  = new int[30];

        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                likes[sc.nextInt() - 1]++;
            }
        }
        long cnt = Arrays.stream(likes)
                .filter(x -> x == n)
                .count();

        System.out.println(cnt);

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 27348
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
#include <stack>
#include <iomanip>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};

const int N = 3e3 + 5;

int n;
double a [N], dp [N][N]; 

double solve (int p = 0, int heads = 0) { 
  if (p >= n) return (heads > p / 2 ? 1.0 : 0.0); 
  double &res = dp[p][heads];
  if (res >= 0) return res;
  double tot = 0;
  tot += solve (p + 1, heads + 1) * a[p];
  tot += solve (p + 1, heads) * (1.0 - a[p]);
  res = tot;
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  F0R (i, n) cin >> a[i];
  F0R (i, N) F0R (j, N) dp[i][j] = -1.0;
  cout << fixed << setprecision(12) << solve () << '\n';
  return 0;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
 
using namespace std;
 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
int main() {
    //OJ;
    int X,N,temp;
    cin>>X>>N;
    set<int> S;
    if(N==0){
        cout<<X;
        return 0;
    }
    for(int i=0;i<N;i++){
        cin>>temp;
        S.insert(temp);
    }
    int u=X+1,l=X-1,c=100;
    while(N--){
        if(S.count(X)==0){
            cout<<X;
            return 0;
        }
        if(S.count(l)==0){
            cout<<l;
            return 0;
        }
        auto it2=S.find(u);
        if(S.count(u)==0){
            cout<<u;
            return 0;
        }
        u++;
        l--;
    }
	cout<<l;
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int N,M,A[105][105],B[105],i,j,t;
int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)
		for(j=0;j<M;j++)
			scanf("%d",&A[i][j]);
	for(i=0;i<M;i++)
		scanf("%d",&B[i]);
	for(i=0;i<N;i++)
	{
		for(j=t=0;j<M;j++)
			t+=A[i][j]*B[j];
		printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 644
#include<iostream>

using namespace std;

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

    int c[N],t[N];
    for(int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
    }
   
    int min = 1001;
    for(int i = 0; i < N; i ++){
       if(T >= t[i]){
        if(min > c[i]){
            min = c[i];
        }
       }
    }
    if(min == 1001){
        cout << "TLE" << endl;
    }else{
        cout << min << endl;
    }
    return 0;
}

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

int main() {
  int n, i, j;
  string s;
  cin >> n >> s;
  
  vector<vector<char>> dp(4, vector<char>(n));
  dp[0][0] = dp[0][1] = dp[1][0] = dp[2][1] = 'S';
  dp[1][1] = dp[2][0] = dp[3][0] = dp[3][1] = 'W';
  for(i = 0; i < 4; i++){
    for(j = 1; j < n - 1; j++){
      
      if(dp[i][j] == 'S'){
        if(s.at(j) == 'o') dp[i][j + 1] = dp[i][j - 1];
        else{
          if(dp[i][j - 1] == 'S') dp[i][j + 1] = 'W';
          else dp[i][j + 1] = 'S';
        }
      }
      
      if(dp[i][j] == 'W'){
        if(s.at(j) == 'x') dp[i][j + 1] = dp[i][j - 1];
        else{
          if(dp[i][j - 1] == 'S') dp[i][j + 1] = 'W';
          else dp[i][j + 1] = 'S';
        }
      }
      
    }
  }
  
  int ans = 1, ans2 = 1;
  for(i = 0; i < 4; i++){
    if(dp[i][n - 1] == 'S'){
      if(s.at(n - 1) == 'o' && dp[i][n - 2] == dp[i][0]){
        ans *= i + 2;
      }
      else if(s.at(n - 1) == 'x' && dp[i][n - 2] != dp[i][0]){
        ans *= i + 2;
      }
    }
    else{
      if(s.at(n - 1) == 'x' && dp[i][n - 2] == dp[i][0]){
        ans *= i + 2;
      }
      else if(s.at(n - 1) == 'o' && dp[i][n - 2] != dp[i][0]){
        ans *= i + 2;
      }
    }
  }
  for(i = 0; i < 4; i++){
    if(dp[i][0] == 'S'){
      if(s.at(0) == 'o' && dp[i][1] == dp[i][n - 1]){
        ans2 *= i + 2;
      }
      else if(s.at(0) == 'x' && dp[i][1] != dp[i][n - 1]){
        ans2 *= i + 2;
      }
    }
    else{
      if(s.at(0) == 'x' && dp[i][1] == dp[i][n - 1]){
        ans2 *= i + 2;
      }
      else if(s.at(0) == 'o' && dp[i][1] != dp[i][n - 1]){
        ans2 *= i + 2;
      }
    }
  }
  
  if(ans % 5 == 0 && ans2 % 5 == 0){
    for(j = 0; j < n; j++){
      cout << dp[3][j];
    }
    cout << endl;
  }
  else if(ans % 4 == 0 && ans2 % 4 == 0){
    for(j = 0; j < n; j++){
      cout << dp[2][j];
    }
    cout << endl;
  }
  else if(ans % 3 == 0 && ans2 % 3 == 0){
    for(j = 0; j < n; j++){
      cout << dp[1][j];
    }
    cout << endl;
  }
  else if(ans % 2 == 0 && ans2 % 2 == 0){
    for(j = 0; j < n; j++){
      cout << dp[0][j];
    }
    cout << endl;
  }
  else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
   string s;
   cin >> s;
   if(s == "Sunny"){
       cout << "Cloudy";
   }else if(s == "Cloudy"){
       cout << "Rainy";
   } else{
       cout << "Sunny";
   }
    return 0;
}

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

int main(){
  string s, t, r, v;
  bool flag=false;
  getline(cin, s);
  stringstream ss(s);
  while(getline(ss, t, ' ')){
    stringstream st(t);
    while(getline(st, r, ',')){
      stringstream sr(r);
      while(getline(sr, v, '.')){
        if(3<=v.length() && v.length()<=6){
          if(flag)cout<<' ';
          cout<<v;
          flag=true;
        }
      }
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func gcd(a, b int) int {
	if a < b {
		return gcd(b, a)
	}
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func solve(io *io) {
	n := io.NextInt()
	s := io.NextInt()
	g := 0
	for i := 0; i < n; i++ {
		x := io.NextInt()
		d := x - s
		if d < 0 {
			d = -d
		}
		if i == 0 {
			g = d
		} else {
			g = gcd(g, d)
		}
	}
	io.Println(g)
}

func main() {
	io := newIo()
	defer io.Flush()
	solve(io)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

using namespace std;

vector<pair<int,int> > vec1,vec2;
int n;
char str1[5050],str2[5050]; 

int main()
{
	scanf("%d %s %s",&n,str1 + 1,str2 + 1);
	for(int i = 1;i <= n; ++ i) vec1.push_back(make_pair(i & 1,0));
	if((n & 1) != str1[1] - '0') vec1.push_back(make_pair(str1[1] - '0',0));
	for(int i = 1;i <= n; ++ i)
		if(str1[i] != str1[i + 1]) vec1.push_back(make_pair((str1[i] - '0') ^ 1,i));
	for(int i = 1;i <= n; ++ i)
		vec1.push_back(make_pair(vec1[vec1.size() - 1].first ^ 1,n));
	vec2.push_back(make_pair(str2[1] - '0',0));
	for(int i = 1;i <= n; ++ i)
		if(str2[i] != str2[i + 1])
			vec2.push_back(make_pair((str2[i] - '0') ^ 1,i));
	int sz = vec2.size(),ans = 0x3f3f3f3f;
	for(int i = 0;i + sz - 1 < vec1.size(); ++ i)
	{
		int tmp = 0;
		if(vec2[0].first != vec1[i].first) continue;
		for(int j = 1;j <= sz; ++ j)
			tmp += abs(vec1[i + j - 1].second - vec2[j - 1].second);
		for(int j = 0;j < i; ++ j)
			tmp += vec1[j].second;
		for(int j = i + sz;j < vec1.size(); ++ j)
			tmp += n - vec1[j].second;
		ans = min(ans,tmp);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <stdio.h>
int m,n;
int a[200000],b[200000];
int i,j,k,l,max;
int main(void){
    scanf("%d %d",&k,&n);
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d",&a[i]); 
    }
    b[0] = k - a[n-1] + a[0];
    for (size_t i = 1; i < n; i++)
    {
        b[i] = a[i] - a[i-1];
    }
    max = b[0];
    for (size_t i = 1; i < n; i++)
    {
        if (max < b[i])
        {
            max = b[i];
        }
    }
    printf("%d\n",k - max);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int a[4];
	rep(i,4) a[i] = s[i]-'0';
	rep(b,8){
		int x = a[0];
		string ans;
		ans += s[0];
		rep(i,3){
			if((b>>i)&1){
				x += a[i+1];
				ans += '+';
				ans += s[i+1];
			}else{
				x -= a[i+1];
				ans += '-';
				ans += s[i+1];
			}
		}
		if(x==7){
			ans += "=7";
			cout<<ans<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
# Fenwick Tree
class FenwickTree
  def initialize(arg)
    if arg.is_a?(Array)
      @n   = arg.size
      @data = Array.new(@n + 1) { 0 }
      arg.each.with_index(1) { |e, i| add(i, e) }
    elsif arg.is_a?(Integer)
      @n   = arg
      @data = Array.new(@n + 1) { 0 }
    end
  end

  def add(i, x)
    while i <= @n
      @data[i] += x
      i += ( i & -i )
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i -= ( i & -i )
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }

ft = FeTree.new(a)

q.times do
  t, u, v = gets.split.map { |e| e.to_i }

  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end


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

int main()
{
	string s,t;
	cin>>s>>t;
	for(int i=0; i<s.size(); i++)
		if(s[i]!=t[i])
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
 } 

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    int N; cin >> N;
    VI P;
    int rP[112345] = {};
    multiset<LL> st;
    REP(i,N) {
        int t;
        cin >> t;
        P.eb(t);
        rP[t] = i;
    }
    st.insert(N);
    st.insert(N);
    st.insert(-1);
    st.insert(-1);
    LL ans = 0;
    for(LL i = N; i > 0; i--){
        auto litr1 = st.lower_bound(rP[i]);
        LL l1 = *litr1;
        LL l2 = *next(litr1);
        LL r1 = *(--litr1);
        LL r2 = *(--litr1);
        dump(i)
        //cout << r1 << " " << r2 << " " << l1 << " " << l2 << endl;

        st.insert(rP[i]);

        //if(l1 > MOD || l2 > MOD || r1 < -MOD || r2 < -MOD) continue;

        //ans += abs(l1-l2) * abs(r1-r2);
        ans += i * (abs(l1 - l2) * abs(r1 - rP[i]) + abs(r1-r2) * abs(l1 - rP[i]));
        dump(ans)
    }
    cout << ans << endl;


}


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

int main(){
  vector<pair<int,int>>A;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int time,sime;
    cin>>time>>sime;
    A.push_back(make_pair(sime,time));
  }
  sort(A.begin(),A.end());
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=A[i].second;
    if(sum>A[i].first){
      cout <<"No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 2420
ans = 0
a = int(input())
b = int(input())
c = int(input())
x = int(input())

for i in range(0,a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x==500*i+100*j+50*k:
                ans += 1
print(ans)

Measured memory_bytes: 39536
n = gets.split(" ").map(&:to_i)
b = readlines.map{|i| i.chomp.split.map(&:to_i)}
a = b.slice!(0,n[0])
bt = b.transpose
n[0].times do |i|
  c = []
  n[2].times do |j|
    c<<[a[i],bt[j]].transpose.map{|t| t.inject(:*)}.inject(:+)
  end
  puts c.join(" ")
end

Measured memory_bytes: 9256
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,r,a,x[N],h[N];
pair <int,int> p[N];
queue <pair <int,int>> q;
long long damage,ans;

bool cmp(pair <int,int> &a,pair <int,int> &b)
{
	if(a.first!=b.first) return a.first<b.first;
	return a.second>b.second;
}

void add(int x,int min_damage)
{
	int d=(min_damage+a-1)/a*a;
	q.push({x,d});
	damage+=d;
	ans+=d/a;
}

void remove()
{
	damage-=q.front().second;
	q.pop();
}

int main()
{
	scanf("%d%d%d",&n,&r,&a);
	for(int i=0;i<n;i++) scanf("%d%d",&p[i].first,&p[i].second);

	sort(p,p+n,cmp);
	add(p[0].first+r,p[0].second);
	for(int i=1;i<n;i++)
	{
		while(not q.empty() and p[i].first-q.front().first>r) remove();
		if(p[i].second<=damage) continue;
		add(p[i].first+r,p[i].second-damage);
	}

	printf("%lld",ans);
}

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

int c[9];
int main() {
	for (int i = 0; i < 9; i++)cin >> c[i];
	// 0 1 2
	// 3 4 5
	// 6 7 8
	bool flag = true;

	int a = c[1] - c[0];
	if (c[4] - c[3] != a || c[7] - c[6] != a)flag = false;
	int b = c[2] - c[1];
	if (c[5] - c[4] != b || c[8] - c[7] != b)flag = false;
	int d = c[3] - c[0];
	if (c[4] - c[1] != d || c[5] - c[2] != d)flag = false;
	int e = c[6] - c[3];
	if (c[7] - c[4] != e || c[8] - c[5] != e)flag = false;

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

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

long long n,m,a[100009][3],maxn = -(1LL<<60);

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++) cin>>a[i][j];
    }
    for(int i=0;i<8;i++){
        vector<long long> vec;
        for(int j=1;j<=n;j++){
            long long S = 0;
            for(int k=0;k<3;k++){
                if((i/(1<<k))%2==0)
                    S+=a[j][k];
                else
                    S-=a[j][k];
            }
            vec.push_back(S);
        }
        sort(vec.begin(),vec.end());reverse(vec.begin(),vec.end());
        long long ans = 0;
        for(int j=0;j<m;j++) ans+=vec[j];
        maxn = max(maxn,ans);
    }
    cout<<maxn<<"\n";

    return 0;
}

Measured memory_bytes: 256
line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
  if count < M:
    return broken[count]==value
  else:
    return False
for i in range(M):
  a = int(input())
  broken += [a]
if check(1):
  step+=[0]
  count += 1
else:
  step +=[1]
if check(2):
  step += [0]
  count += 1
else:
  step += [1+step[0]]
for j in range(2, N):
  if check(j+1):
    step += [0]
    count += 1
  else:
    step += [step[j-2]+step[j-1]]
ans = step[N-1]%(10**9+7)
print(ans)


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

int main(){
	int n,m ;
	cin >> n >> m ;
	vector<int> cnt(n,0) ;
	for(int i=0;i<m;i++){
		int a,b ;
		cin >> a >> b ;
		cnt.at(a-1)++ ;
		cnt.at(b-1)++ ;
	}
	for(int i=0;i<n;i++) cout << cnt.at(i) << endl ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef long long ll;

int K,R,L;
double P,E,T;

inline double dfs(int depth,double r,double l) {
    //cout<<string(depth,'\t');printf("%.8f %.8f\n",l,r);
    if(depth==K) {
        //string(depth,'\t');printf("%.8f %d\n",(l+r)/2,abs(T-(l+r)/2)<=E);
        return 1.0*(abs(T-(l+r)/2)<=E);
    }
    double h=(l+r)/2;

    if(l<T-E) return 0;
    if(r>T+E) return 0;
    if(T-E<=r&&l<=T+E) return 1;

    double ret=0.0;
    if(h>=T) {
        ret+=dfs(depth+1,r,h)*(1-P);
        ret+=dfs(depth+1,h,l)*(P);
    }
    else {
        ret+=dfs(depth+1,r,h)*(P);
        ret+=dfs(depth+1,h,l)*(1-P);
    }

    return ret;
}


int main() {
    cin>>K>>R>>L;
    cin>>P>>E>>T;

    printf("%.20f\n",dfs(0,R,L));
    return 0;
}

Measured memory_bytes: 1252
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

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

    double res = 0;
    for (auto i = 0; i < n; i += 1) {
        int num;
        cin >> num;
        res += 1.0 / num;
    }

    res = 1 / res;
    cout << fixed << setprecision(10) << res << "\n";

    return 0;
}


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

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a = vector<vector<char>>(H, vector<char>(W, 0));
	for(int h = 0; h < H; h++){
		for(int w = 0; w < W; w++){
			cin >> a[h][w];
		}
	}
	vector<bool> h_flag = vector<bool>(H, false);
	vector<bool> w_flag = vector<bool>(W, false);
	for(int h = 0; h < H; h++){
		for(int w = 0; w < W; w++){
			if(a[h][w] == '#'){
				h_flag[h] = true;
				break;
			}
		}
	}
	for(int w = 0; w < W; w++){
		for(int h = 0; h < H; h++){
			if(a[h][w] == '#'){
				w_flag[w] = true;
				break;
			}
		}
	}
	
	
	for(int h = 0; h < H; h++){
		bool flag = false;
		for(int w = 0; w < W; w++){
			if(h_flag[h] && w_flag[w]){
				cout << a[h][w];
				flag = true;
			}
		}
		if(flag)
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//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(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	cin >> N;

	vector<pair<ll, ll>> abs;
	abs.reserve(N);
	ll a, b;
	for (ll i = 0; i < N; ++i) {
		cin >> a >> b;
		abs.emplace_back(b, a);
	}
	sort(abs.begin(), abs.end());
	
	bool can_finish = true;
	ll accum = 0;
	for (ll i = 0; i < N; ++i) {
		accum += abs[i].second;
		if (accum > abs[i].first) {
			can_finish = false;
			break;
		}
	}

	cout << (can_finish ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <math.h>
int main(void) {
    int n, i;
    double data[1000], m, alpha;
 
    while (1) {
        scanf("%d ", &n);
        if (n == 0)
            break;
 
        for (m = 0.0, i = 0; i < n; i++) {
            scanf("%lf ", data+i);
            m += data[i];
        }
        m /= n;
        for (alpha = 0.0, i = 0; i < n; i++) {
            data[i] -= m;
            alpha += data[i] * data[i];
        }
        printf("%.4lf\n", sqrt(alpha / n));
    }
    return 0;
}


Measured memory_bytes: 2044
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let S = rl();

    let ok = N % 2 == 0 && S[..N / 2] == S[N / 2..];
    println!("{}", if ok { "Yes" } else { "No" })
}


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

main(){
  int N;
  cin >> N;
  int A[N],B[N],C[N-1];
  for(int ii=0;ii<N;ii++){
    cin >> A[ii];
  }
  for(int ii=0;ii<N;ii++){
    cin >> B[ii];
  }
  for(int ii=0;ii<N-1;ii++){
    cin >> C[ii];
  }
  int ans=0;
  for(int ii=0;ii<N;ii++){
    ans+=B[A[ii]-1];
    //    cout << A[ii] << endl;
  }
  //cout << ans << endl;
  int tmp=A[0];
  for(int ii=1;ii<=N;ii++){
    if(tmp+1==A[ii])ans+=C[A[ii-1]-1];// cout << ii << endl;}
    tmp=A[ii];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1ll << 60;

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

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

const ll MAX = 100100;

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll dp[MAX];
	for (ll i = 0; i < MAX; ++i) dp[i] = INF;

	dp[0] = 0;
	for (ll i = 0; i < N; ++i)
	{
		chmin(dp[i+1], dp[i] + 1);

		for (ll j = 6; i+j <= N; j*=6)
			chmin(dp[i+j], dp[i]+1);

		for (ll j = 9; i+j <= N; j*=9)
			chmin(dp[i+j], dp[i]+1);		
	}

	std::cout << dp[N] << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N,K;

  cin>>N>>K;

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

  sort(h,h+N);

  int minn=INT_MAX;
  
  for(int i=0;i<N-K+1;i++){

    minn=min(minn,h[i+K-1]-h[i]);

  }

  cout<<minn<<endl;
  
  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  int ans = 1;
  for (int i = 1; i < N; i++)
  {
    bool can = true;
    for (int j = 0; j < i; j++)
    {
      if (H.at(i) < H.at(j))
        can = false;
    }
    if (can)
      ans++;
  }
  cout << ans << endl;
}


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

int i,j,k,l;
char nyuroku[114514],m;

int main(int argc,char **argv){
  while( scanf("%s",&nyuroku[0]) != EOF ) 
    {
      l = strlen(nyuroku);
      for(i=0;i<l;i++)
	{
	  if( nyuroku[i] != '@' )
	    {
	      printf("%c",nyuroku[i]);
	    }
	  else
	    {
	      for(m='0';m<nyuroku[i+1];m++)
		{
		  printf("%c",nyuroku[i+2]);
		}
	      i = i + 2;
	    }
	}
      puts("");
  }
  return 0;
}

Measured memory_bytes: 524
N = int(input())
A = list(map(int,input().split()))
S1 = A[0]
S2 = sum(A)-A[0]
B = [abs(S1-S2)]

for i in range(N-2):
  S1 += A[i+1]
  S2 -= A[i+1]
  B.append(abs(S1-S2))

print(min(B))

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main() {
  ll a, b;
  cin >> a >> b;
  cout << a / gcd(a, b) * b << endl;
  return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int m; cin >> m;
  ll s = 0;
  ll D = 0;
  rep(i, m) {
    ll d, c; cin >> d >> c;
    D += c;
    s += d*c;
  }
  ll ans = (D-1) + (s-1)/9;
  cout << ans << endl;
}


Measured memory_bytes: 3644
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << (h) << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << (h) << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

ll L;

void Main()
{
	cin >> L;

	cout << powl(L / 3.0, 3);
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 640
from operator import itemgetter
n=int(input())
li = [list(map(int, input().split())) for i in range(n)]
li.sort(key=itemgetter(1)) 

t=0
for i in range(n):
    t+=li[i][0]
    if t>li[i][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 53732
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias SP = Tuple!(int, "idx", string, "s", int, "p");
SP[] SPS;

void main()
{
    auto N = readln.chomp.to!int;
    SPS.length = N;
    foreach (int i; 0..N) {
        auto sp = readln.split;
        SPS[i] = SP(i+1, sp[0].to!string, sp[1].to!int);
    }
    sort!"a.s == b.s ? a.p > b.p : a.s < b.s"(SPS);
    foreach (sp; SPS) writeln(sp.idx);
}

Measured memory_bytes: 256
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int dp[MAX], arr[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, k;

    cin>>n>>k;

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

    for(int i = 1; i <= k; i++){
        if(!dp[i]){
            for(int j = 0; j < n; j++){
                if((i - arr[j] >= 0) && dp[i-arr[j]] == 0){
                    dp[i] = 1;
                    break;
                }
            }
        }
    }

    (dp[k]) ? cout<<"First"<<endl : cout<<"Second"<<endl;

    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	A := nextInts(N)
	cnt := map[int]int{}
	for _, a := range A {
		cnt[a]++
	}
	sum := 0
	for _, v := range cnt {
		sum += cmb2(v)
	}
	for k := 0; k < N; k++ {
		ans := sum
		ans -= cmb2(cnt[A[k]])
		ans += cmb2(cnt[A[k]] - 1)
		fmt.Println(ans)
	}
}

func cmb2(n int) int {
	return (n * (n - 1)) / 2
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 14592
#include <iostream>

#define MAX_STONES 100000
#define MAX_INTEGERS 100

using namespace std;

// Starting from this problem I discovered it is useful to write down the definition of the DP

bool dp[MAX_STONES + 1];  // It is TRUE if first player wins with that many stones available. We don't care what the optimal steps were.
int removeChances[MAX_INTEGERS];

int main()
{
    int nIntegers, nStones, removeValue;
    cin >> nIntegers >> nStones;
    for (int i = 0; i < nIntegers; i++)
    {
        cin >> removeValue;
        removeChances[i] = removeValue;
    }
    dp[0] = false; // If there are no stones left, the first player loses
    for(int i = 0; i <= nStones; i++)
    {
        for(int j = 0; j < nIntegers; j++)
        {
            if(i >= removeChances[j]  && !dp[i - removeChances[j]])
                dp[i] = true;
        }
    }
    if(dp[nStones])
        cout << "First";
    else
        cout << "Second";
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void) {
	int n;
	int a[200000];
	cin >> n;
	int cnt[200001] = { 0 };

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

	for (int i = 0; i < n; i++) {
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << cnt[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 5196
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string>
#define ll long long
int main(){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)
     cout<<s<<endl;
     else
     {
         string str=s.substr(0,k);
         cout<<str+"..."<<endl;
     }
     return 0;
     
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>pre[i];
    ll ans=1e18;
	for(int i=-1000;i<=1000;i++) {
		ll sum=0;
		for(int j=1;j<=n;j++) {
			sum+=(i-pre[j])*(i-pre[j]);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
static const int INFTY=(1<<21);
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[102][102],color[102],d[102];
vector <int> searched;
void search(){
    int minp=0,min;
    while(1){
        min=INFTY;
        for(int i=0;i<n;i++){
            if(M[minp][i]!=INFTY&&color[i]==WHITE) color[i]=GRAY;
        }
        for(int i=0;i<searched.size();i++){
            int a=searched[i];
            for(int j=0;j<n;j++){
                if(color[j]==GRAY&&M[a][j]+d[a]<min){
                    min=M[a][j]+d[a];
                    minp=j;
                }
            }
        }
        if(min==INFTY) break;
        else{
            d[minp]=min;
            color[minp]=BLACK;
            searched.push_back(minp);
        }
    }
    for(int i=0;i<n;i++) cout<<i<<" "<<d[i]<<endl;
}
int main(){
    int u,k,v,c;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) M[i][j]=INFTY;
    }
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        d[i]=INFTY;
        cin>>u>>k;
        for(int p=0;p<k;p++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    searched.push_back(0);
    color[0]=BLACK;
    d[0]=0;
    search();
    return 0;
}


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

int main() {
  
  string s;
  
  cin >> s;
  
  int count=0;
  
  if(s[0]=='1') {
    
    count++;
    
  }
  
  if(s[1]=='1') {
    
    count++;
    
  }
  
  if(s[2]=='1') {
    
    count++;
    
  }
  
  cout << count << endl;
  
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    int64_t ans = 1000, now = 300;
    for(int i = 0; i < N; ++i) {
        if(now < A[i]) {
            int64_t k = ans / now;
            ans += k * (A[i] - now);
            now = A[i];
        }
        now = A[i];
    }
    cout << ans << '\n';
    return 0;
}


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


int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int ans = 0;
		for (int z = 1; z <= sqrt(i / 6); z++) {
			for (int y = z; y <= sqrt(i); y++) {
				for (int x = y; x <= sqrt(i); x++) {
					if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
						if (x == y && z == y && z == x) {
							ans++;
						}
						else if (x != y && z != y && z != x) {
							ans += 6;
						}
						else {
							ans += 3;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3496
n = int(input())
list = list(map(int, input().split()))
list.sort()
import bisect
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(list, list[i]+list[j])
        ans += index - j -1
print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        final int i = scanner.nextInt();
        scanner.nextLine();
        final char[] chars = scanner.nextLine().toCharArray();

        if (chars[i - 1] == 'A') {
            chars[i - 1] = 'a';
        } else if (chars[i - 1] == 'B') {
            chars[i - 1] = 'b';
        }else{
            chars[i - 1] = 'c';
        }

        System.out.println(chars);
    }
}


Measured memory_bytes: 21460
N = int(input())
blue = {}
for _ in range(N):
    s = input().rstrip()
    if blue.get(s) == None:
        blue[s] = 1
    else:
        blue[s] += 1
M = int(input())
red = {}
for _ in range(M):
    t = input().rstrip()
    if red.get(t) == None:
        red[t] = 1
    else:
        red[t] += 1
answer = 0
for i, blue_elem in blue.items():
    red_elem = red[i] if red.get(i) != None else 0
    answer = blue_elem - red_elem if answer < blue_elem - red_elem else answer
print(answer)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

int N, x, cnt;

int main()
{
  scanf("%d", &N);
  for (int i=1; i<=N; i++) 
  {
    scanf("%d", &x);
    if (x != i)
      cnt++;
  }
  puts(cnt > 2 ? "NO":"YES");
  return 0;
}

Measured memory_bytes: 128