akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc083_a solver = new abc083_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc083_a {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int a = in.scanInt();
            int b = in.scanInt();
            int c = in.scanInt();
            int d = in.scanInt();
            if (a + b > c + d) out.println("Left");
            else if (a + b == c + d) out.println("Balanced");
            else out.println("Right");
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 22228
#include <cstdio>
#include <algorithm>

#define N 100

using namespace std;

int
main ( )
{
  int res = 0;
  int d[ N ];
  int n;
  int i, j;

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

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

    for ( j = i + 1; j < n; ++j )
    {
      if ( d[ mini ] > d[ j ] )
      {
        mini = j;
      }
    }

    if ( i != mini )
    {
      swap ( d[ i ], d[ mini ] );
      ++res;
    }
  }

  for ( i = 0; i < n; ++i )
  {
    if ( i ) putchar ( ' ' );
    printf ( "%d", d[ i ] );
  }
  printf ( "\n%d\n", res );

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i,j;
        while(true){
            int H =sc.nextInt();
            int W =sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(i%2==1){
                        if(j%2==1){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }else{
                        if(j%2==1){
                            System.out.printf(".");
                        }else{
                            System.out.printf("#");
                        }
                    }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }

        }
    }


Measured memory_bytes: 62776
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

const LL MOD=998244353;
LL pow2(LL base, LL cnt){
    for(LL i = 0; i < cnt; ++i){
        base = (base*2) % MOD;
    }
    return base;
}

int main(){
    LL n, m;
    cin >> n >> m;
    vector<vector<LL>> a(n, vector<LL>(m, 0));
    for(LL i = 0; i < n; ++i){
        for(LL j = 0; j < m; ++j){
            cin >> a[i][j];
        }
    }
    sort(a.begin(), a.end(), greater<vector<LL>>());
    LL cnt = 0;
    for(LL i = 0; i < n; ++i){
        if(accumulate(a[i].begin(), a[i].end(), 0) == 0){
            cnt += 1;
        }else{
            LL one_pos = 0;
            for(LL k = 0; k < m; ++k){
                if(a[i][k] == 1){
                    one_pos = k;
                    break;
                }
            }
            for(LL j = i+1; j < n; ++j){
                if(a[j][one_pos] == 0) continue;
                for(LL k = 0; k < m; ++k){
                    a[j][k] = (a[j][k] + a[i][k]) % 2;
                }
            }
        }
    }

    cerr << "cnt=" << cnt << endl;
    LL base = pow2(1, m+n-1);
    LL part = pow2(1, m+cnt-1);
    LL ans = (base + MOD - part) % MOD;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

def main():
    N, P = map(int, input().split())
    A = list(map(int, input().split()))

    A = list(map(lambda x: x % 2, A))
    if A.count(1):
        ans = pow(2,N-1)
    else:
        if P == 0:
            ans = pow(2,N)
        else:
            ans = 0

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,p,y;
    cin>>n>>m;
    vector<pll> v[n+1];
    string ans[m+1];
    rep(i,0,m)
    {
    	cin>>p>>y;
    	v[p].pb({y,i});
    }
    rep(i,1,n+1)
    {
    	sort(all(v[i]));
    	string a=to_string(i);
    	while(sz(a)!=6)
    		a='0'+a;
    	rep(j,0,sz(v[i]))
    	{
    		string b=to_string(j+1);
    		while(sz(b)!=6)
    			b='0'+b;
    		ans[v[i][j].S]=a+b;
    	}
    }
    rep(i,0,m)
    cout<<ans[i]<<"\n";
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,p[N],fa[N];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
vector <int> a[N],b[N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d",&p[i]),fa[i]=i;
	for (int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		fa[getf(a)]=getf(b);
	}
	for (int i=1;i<=n;i++)
		a[i].clear(),b[i].clear();
	int ans=0;
	for (int i=1;i<=n;i++)
		a[getf(i)].push_back(i),b[getf(i)].push_back(p[i]);
	for (int i=1;i<=n;i++)
		if (a[i].size()){
			sort(a[i].begin(),a[i].end());
			sort(b[i].begin(),b[i].end());
			for (int j=0,k=j;j<a[i].size();j++){
				while (k<a[i].size()&&a[i][j]>b[i][k])
					k++;
				if (k<a[i].size()&&a[i][j]==b[i][k])
					ans++;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e7 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long a, v, b, w, t; cin >> a >> v >> b >> w >> t;

    if((v - w) * t >= abs(a - b)){
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 3640
N = int(input())
xs = [[] for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        xs[i].append((x-1,y))
ans = 0
for b in range(1<<N):
    mujun = False
    for k,z in enumerate(xs):
        for x,y in z:
            if b&(1<<k):
                if b&(1<<x):
                    if y==0:
                        mujun = True
                else:
                    if y==1:
                        mujun = True
            if mujun:
                break
        if mujun:
            break
    if not mujun:
        tmp = bin(b).count('1')
        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		int N=sc.nextInt();
		int[] T =new int[N];
		int sum=0;
		for(int i=0;i<N;i++) {
			T[i]=sc.nextInt();
			sum+=T[i];
		}
		int M=sc.nextInt();
		int[] P=new int[M];
		int[] X=new int[M];
		
		int[] rep = new int[M];
		
		for(int i=0;i<M;i++) {
			P[i]=sc.nextInt();
			X[i]=sc.nextInt();
			
			rep[i]=X[i]-T[P[i]-1];
		}
		
		for(int i=0;i<M;i++) {
			System.out.println(sum+rep[i]);
		}
		
		
	}

}

Measured memory_bytes: 23124
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace soundhound_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int w = int.Parse(Console.ReadLine());

            Write(str[0]);
            for(int i=w; i<str.Length; i++){
                if(i % w == 0) Write(str[i]);
            }
            WriteLine();
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#define BIG 2000000000
#define white 0
#define gray 1
#define black 2

int n,c[100][100];

int prim() {
    int i, d[100], p[100], color[100], sum, minconst, u;
    for (i = 0; i < n; ++i) {
        color[i] = white;
        d[i] = BIG;
    }
    d[0] = 0;
    p[0] = -1;
    
    while(1){
        minconst = BIG;
        for (i = 0; i < n; ++i){
            if (color[i] != black && d[i] < minconst){
                minconst = d[i];
                u = i;
            }
        }
        
        if (minconst == BIG) break;
        
        color[u] = black;
        
        for (i = 0; i < n; ++i) {
            if (color[i] != black && c[u][i] != BIG) {
                if (c[u][i] < d[i]){
                    d[i] = c[u][i];
                    p[i] = u;
                    color[i] = gray;
                }
            }
        }
    }
    
    sum = 0;
    for (i = 0; i < n ; ++i) {
        if( p[i] != -1) sum += c[i][p[i]];
    }
    return sum;
}

int main() {
    int i, j;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            scanf("%d", &c[i][j]);
            if (c[i][j] == -1) c[i][j] = BIG;
        }
    }
    
    printf("%d\n", prim());
    return 0;
}

Measured memory_bytes: 1760
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt(), x = sc.nextInt();
        int[] a = new int[n];
        long total = 0;
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
            total += a[i];
        }
        Arrays.sort(a);
        int count = 0;
        if(x==total){
            System.out.println(n);
        } else if(x>total){
            System.out.println(n-1);
        } else {
            for(int i = 0;i<a.length;i++){
                if(x>=a[i]){
                    x -= a[i];
                    count ++;
                } else {
                    break;
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 23764
n=int(input())
S = input()
 
ans = 0
for i in range(1000):
    a, b, c = map(str, list(str(i).zfill(3)))
    mode = 'a'
    for j in S:
        if mode == 'a' and j == a:
            mode = 'b'
        elif mode == 'b' and j == b:
            mode = 'c'
        elif mode == 'c' and j == c:
            ans += 1
            break
print(ans)

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

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

int main(void) {
    int n;
    char s;
    bool four_flg = false;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> s;
        if (s == 'Y') {
            four_flg = true;
        }
    }
    
    cout << (four_flg? "Four" : "Three") << "\n";
    return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
if l == 1:
	ans = int(s)
elif s[1:].count("9") == l-1:
	ans = int(s[0]) + 9 * (l-1)
else:
	ans = (l-1)*9 + (int(s[0])-1)

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>

int main(void)
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) break;

    std::map<char, char> table;
    for (int i = 0; i < n; i++) {
      char c1, c2;
      std::cin >> c1 >> c2;
      table[c1] = c2;
    }

    int m;
    std::cin >> m;
    std::string str;
    for (int i = 0; i < m; i++) {
      char c;
      std::cin >> c;
      if (table.count(c) > 0) c = table[c];
      str.push_back(c);
    }

    std::cout << str << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int box;

		if (a > b) {
			box = a;
			a = b;
			b = box;
		}

		if (b > c) {
			box = b;
			b = c;
			c = box;
		}

		if (a > b) {
			box = a;
			a = b;
			b = box;
		}

		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 17320
h, w = map(int, raw_input().split())
arr = []
del_row = 0
for i in range(h):
    row = raw_input()
    if row != ("."*w):
        arr.append(row)
    else:
        del_row += 1
ans = []
for j in range(w):
    column = []
    for k in range(h-del_row):
        column.append(arr[k][j])
    if column != ["." for i in range(h-del_row)]:
        ans.append(column)
for num in range(h-del_row):
    str = ""
    for lst in ans:
        str += lst[num]
    print str

Measured memory_bytes: 2692
import math
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,10**6+1))
    while True:
      if search_list[0] > math.sqrt(number):
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

x = int(input())
h = get_primenumber(x)
for i in h:
    if i >= x:
        print(i)
        exit()

Measured memory_bytes: 50676
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int N, M;
    cin >> N >> M;
    string s = N == M ? "Yes" : "No";
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

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

	vector<vector<int>> Mat(N, vector<int>(N, 0));

	rep(i, N)
	{
		for(int k = 1; i + k < N; k++)
		{
			if (S[i] == S[k+i])
			{
				Mat[k][i] = 1;
			}
		}
	}

	int ans = 0;

	for(int k = 1; k < N; k ++)
	{
		int combo = 0;
		for(int i = 0; i < N - 1; i++)
		{
			if (Mat[k][i + 1])
			{
				Mat[k][i + 1] += Mat[k][i];
				if (Mat[k][i + 1] > k) Mat[k][i + 1] = k;
				chmax(ans, Mat[k][i + 1]);
			}
		}
	}

	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
void solve(){
    int n,w;
    cin>>n>>w;
    vector<ll> dp(w+1, 0);
    while(n--){
        int wt, val;
        cin>>wt>>val;
        for(ll i=w-wt; i>=0; i--){
            dp[i+wt] = max(dp[i+wt], dp[i] +val);
        }
    }
    cout<<dp[w]<<"\n";
}

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

    // int t; cin>>t;
    // while(t--)
        solve();
}

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

int main() {
  int i, N, K, l[110], count=0, A=0, B=0;
  
  cin >> N >> K;
  rep(i,N) cin >> l[i];
  
  sort(l,l+N,greater<int>());
  
  rep(i,K) count+=l[i];
  
  cout << count;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int x;
  
  vector<int> a(n+1,0);
  
  for(int i=2;i<=n;i++)
  {
    cin>>x;
    
    a[x]++;
  }
  
  for(int i=1;i<n+1;i++)
  cout<<a[i]<<endl;
  
return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
int main() {
  int ans=700;
  string s;
  cin>>s;
  rep(i,s.size()) if(s[i]=='o') ans+=100;
  cout<<ans<<endl;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
#define ll long long int
#define mod 998244353
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;

void add_self(long long &a, long long b)
{
	 a += b;
	 if(a > mod)
	 {
		 a -= mod;
	 }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> a(k);
	for(int i = 0; i < k; i++)
	{
		cin >> a[i].first >> a[i].second;
	}
	vector<long long> dp(n);
	dp[0] = 1;
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < k; j++)
		{
			int l = a[j].second;
			int r = a[j].first;
			l = max(0, i - l);
			r = i - r;
			if(r < 0 or l > r)
				continue;
			add_self(dp[i], (dp[r] - (l > 0 ? dp[l - 1] : 0ll) + mod) % mod);
		}
		if(i != n - 1)
			add_self(dp[i], dp[i - 1]);
	}
	cout << dp[n - 1];
	
	
	return 0;
}


Measured memory_bytes: 4776
o[256],z[257];main(N,S,A,C,s,a,c,r,i){for(;scanf("%d",&N),N;printf("%d %d %d\n",S,A,C)){
	double H=999999999,h,n=N;
	for(i=1;i<=N;i++)scanf("%d",z+i);
	for(s=0;s<16;s++)for(a=0;a<16;a++)for(c=0;c<16;c++){
		for(r=s,h=0,i=1;i<=N;i++)o[(z[i]+(r=(a*r+c)%256))%256]++;
		for(i=0;i<256;i++)if(o[i])h-=o[i]/n*log(o[i]/n),o[i]=0;
		if(h+1e-9<H)H=h,S=s,A=a,C=c;
	}
}exit(0);}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin>>a>>b;
	if ((a*b)%2==0){
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s; cin >> s;
    int count=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='g') count++;
    if(s.size()%2) cout << count-s.size()/2-1 << endl;
    else cout << count-s.size()/2 << endl;
}

Measured memory_bytes: 512
def p(S):
    str = ""
    for s in S:
        str += chr(ord("a")+int(s))
    print(str)

N = int(input())
S = [0]*N

def up(i):
    if i == 0:
        return True
    S[i] += 1
    if S[i] == max(S[:i]) + 2:
        S[i] = 0
        return up(i-1)
    return False

while True:
    p(S)
    if up(N-1):
        break


Measured memory_bytes: 4404
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int N ;
  cin >> N ;
  string S[N] ;
  int c0=0 , c1=0 , c2=0 , c3=0 ;
  for (int i=0 ; i<N ; i++)
  {
    cin >> S[i] ;
    if (S[i]=="AC")
        c0++;
    else if (S[i]=="WA")
        c1++;
    else if (S[i]=="TLE")
        c2++;
    else if (S[i]=="RE")
        c3++;

  }

  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;

    return 0;
}

Measured memory_bytes: 6724
from collections import defaultdict

a = int(input())


d=defaultdict(int)
# d={}

for _ in range(a):
     b = input()
     c = "".join(sorted(b))
     d[c] +=1
    #  if d.get(c) == None: d[c] = 0
    #  else: d[c] +=1

sum=0
for v in d.values():
    sum+= (v*(v-1))//2


print(sum)

Measured memory_bytes: 18148
#include<iostream>
using namespace std;
int main() {
	char x, y;
	int dx, dy;
	cin >> x;
	switch (x)
	{
	case 'A':dx = 10; break;
	case 'B':dx = 11; break;
	case 'C':dx = 12; break;
	case 'D':dx = 13; break;
	case 'E':dx = 14; break;
	case 'F':dx = 15; break;
	}
	cin >> y;
		switch (y)
		{
		case 'A':dy= 10; break;
		case 'B':dy= 11; break;
		case 'C':dy= 12; break;
		case 'D':dy= 13; break;
		case 'E':dy= 14; break;
		case 'F':dy= 15; break;
	}
		if (dx < dy) cout << "<";
		else if (dx > dy) cout << ">";
		else if (dx == dy)cout << "=";

		return(0);


}

Measured memory_bytes: 256
N,Y=map(int,input().split())
A=[]
for i in range(Y//10000+1):
    for j in range((Y-i*10000)//5000+1):
        c1=(Y-10000*i-5000*j)/1000
        c2=N-i-j
        if c1==c2:
            A=[i,j,c1]
            break
        if c1!=c2:
            continue
if len(A)==0:
    print("-1 -1 -1")
else:
    A[2]=int(A[2])
    #intは整数、floatは少数
    print(str(A[0])+" "+str(A[1])+" "+str(A[2]))


Measured memory_bytes: 40684
#include <stdio.h>


int main(void){
    int N, i,a,b,c,d,j;
    int p[50], y=0, n=0;

    scanf("%d",&N);
    for( i=0; i<N;i++)
    scanf("%d",&p[i]);

    b=0;
    for(i=0; i<N-1;i++){
         if(p[i]>p[i+1] && b ==0 ){
            a=p[i];
            b=1;
            j=i;
         }
         else if( p[i]>p[i+1] && b==1){
             c=p[i+1];    
             p[i+1]=a;
             p[j]=c;
             b = 2;
         }
    }

    for(i=0; i < N-1;i++){
        if(p[i]>p[i+1])
            n=1;        
    }

    if ( N == 2)
        n = 0;

    if ( N == 3){
        for (i = 0; i<N;i++)
            if ( p[i]<p[i+1])
                n = 0;
    }

    if (n==1)
        printf("NO\n");
        else
        {
            printf("YES\n");
        }
        
//for (i=0;i<N;i++)
 //   printf("%d ", p[i]);
    


}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    int k=gi();
	    
        //System.out.println(a[2]-a[0]);
        if (n%k==0) {
        	System.out.print(0);
        }else {
        	System.out.print(1);
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35680
#include <bits/stdc++.h>
using namespace std;
long long int solve(vector<int>&weight,vector<long long int>&value,int w){
    vector< long long int>dp(w+1,0);
    
    for(int i=0;i<weight.size();i++){
        for(int j=w;j>=0;j--){
            if(j>=weight[i])
            dp[j]=max(dp[j],value[i]+dp[j-weight[i]]);
            
            
            // cout<<dp[i][j]<<" ";
        
        }
        // cout<<endl;
    }
    return dp[w];
}





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    int w;
    cin>>n>>w;
    vector<int>weight;
    vector<long long int>value;
    while(n-->0){
        int a,b;
        cin>>a>>b;
        
        weight.push_back(a);
        value.push_back(b);
    }
    cout<<solve(weight,value,w)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(void){
  int N;
  vector<int> neko;
  cin >> N;
  for(int i =0; i < N; i++){
    int tmp;
    cin >> tmp;
    neko.push_back(tmp);
  }

  neko.push_back(0);
  int cnt = 0;
  for(int i =1; i <= N; i ++){
    if(neko[i-1] == i ){
      int tmp = neko[i-1];
      neko[i-1] = neko[i];
      neko[i] = tmp;
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

typedef struct node{
  int key;
  struct node *prev;
  struct node *next;
}Node, *NodePointer;



NodePointer nil;

void init(){
  nil = malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int k){
  NodePointer x = malloc(sizeof(Node));

  x->key = k;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

NodePointer listSearch(int key){
  NodePointer ser;
  ser = nil->next;
  while(ser != nil && ser->key != key){
    ser = ser->next;
  }
  return ser;
}

void deleteNode(NodePointer del){
  if(del == nil)return;

  del->prev->next = del->next;
  del->next->prev = del->prev;
  free(del);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}
void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void print(){
  NodePointer prt = nil->next;
  while(1){
    if(prt == nil)break;
    printf("%d",prt->key);
    if(prt->next != nil){printf(" ");}
    prt = prt->next;
  }
  printf("\n");
}

int main(){
  int n, k,i;
  char com[11];

  scanf("%d",&n);

  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&k);

    if(com[0] == 'i'){
      insert(k);
    }else if(com[0] == 'd'){
      if(com[6] == 'F'){
        deleteFirst();
      }else if(com[6] == 'L'){
        deleteLast();
      }else{
        deleteKey(k);
      }
    }

  }
   print();
  return 0;
}

Measured memory_bytes: 31788
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        while(x != 0 || y != 0) {
            if(x < y){
                System.out.println(x + " " + y);
            }
            else{
                System.out.println(y + " " + x);
            }
            x = scan.nextInt();
            y = scan.nextInt();
        }
    }
}


Measured memory_bytes: 35868
n, q = map(int, input().split())
s = input()
sum = [0]
for i in range(n):
	sum += [sum[-1] + (1 if s[i : i + 2] == 'AC' else 0)]
for _ in range(q):
	l, r = map(int, input().split())
	print(sum[r-1] -sum[l-1])


Measured memory_bytes: 7688
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> vi;

int main()
{
    int a, b, c, d, e, f, g, h, i;
    if (scanf("%d%d%d%d%d%d%d%d%d",
        &a, &b, &c, &d, &e, &f, &g, &h, &i) < 9) return 0;

    bool flg = false;

    if ((a - b == d - e) && (d - e == g - h)
        && (b - c == e - f) && (e - f == h - i)) flg = true;

    printf("%s\n", flg ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BComparingStrings
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            var list = new List<string> { new string(a.ToString().ToCharArray()[0], b), new string(b.ToString().ToCharArray()[0], a) };
            list.Sort();

            Console.WriteLine(list[0]);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13408
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, before = -1, now, ans = 0;
    cin >> N;
    REP(i, N) {
        cin >> now;
        if (before == now) {
            ans++;
            before = -1;
        }
        else {
            before = now;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = input().split()
n = int(a[0])
x = int(a[1])
l_str_list = input().split()
d = 0
answer = n + 1

for i in range(n):
  d += int(l_str_list[i])
  if d > x:
    answer = i + 1
    break
  if d == x:
    answer = i + 2
    break
print(answer)


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

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

  vector< vector<int> > x(n,vector<int>(d));

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

  int ret = 0;
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      int dist = 0;
      for(int k = 0;k < d;k++){
        dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      int sqr = 0;
      while(sqr*sqr < dist){
        sqr++;
      }
      if(sqr*sqr == dist){
        ret++;
      }
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	string ans = "second";
	rep(i,n){
		if(a[i]%2){
			ans = "first";
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef __int128_t i128;
typedef long long i64;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
  FPEN;
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  int a,b;cin>>a>>b;
  cout<<a*b<<endl;
  
  return 0;
}
//2020.05.31 20:00:51


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

//#define INF 1000000000;
//#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

typedef pair<int, int> P;

int main()
{
    int a, b, c; cin >> a >> b >> c;
    string ans = (b - a == c - b) ? "YES" : "NO";
    cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
ans = 0
for i in range(M):
  uf = UnionFind(N)
  for j, (a, b) in enumerate(ab):
    if i == j:
      continue
    uf.union(a-1, b-1)
  root = set([uf.find(j) for j in range(N)])
  if len(root) >= 2:
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int H, W; cin >> H >> W;
  bool h[110] = {}, w[110] = {}; char S[H][W];
  rep(i, H){
    rep(j, W){
      cin >> S[i][j];
      if(S[i][j]=='#') {h[i]=true; w[j]=true;}
    }
  }
  rep(i, H){
    if(!(h[i])) continue;
    rep(j, W){
     if(!(w[j])) continue;
     cout << S[i][j];
    }
    cout << endl;
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S;
  //S.reserve(100000);
  int Q;
  cin >> S >> Q;
  deque<char> D(S.begin(), S.end());

  bool flag = false;
  int T;
  int F;
  char C;

  for(int i = 0; i < Q; i++){
    cin >> T;
    if(T == 1){
      flag = !flag;
    }else{
      cin >> F >> C;
      if((!flag && F == 1) || (flag && F == 2)){
        D.push_front(C);
      }else{
        D.push_back(C);
      }
    }
  }
  if(flag){
    reverse(D.begin(), D.end());
  }
  for(char c : D) {
    cout << c;
  }
  cout << endl;  
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int main(){
	double l;
	cin >> l;
	l /= 3;
	printf("%f\n", l * l * l);
}


Measured memory_bytes: 256
n_1,n_2,n_3 = gets.strip.split('').map(&:to_i)

  if n_1 == 1
    n_1 = 9
  else
    n_1 = 1
  end
  if n_2 == 1
    n_2 = 9
  else
    n_2 = 1
  end
  if n_3 == 1
    n_3 = 9
  else
    n_3 = 1
  end


puts 100 * n_1 + 10 * n_2 + n_3

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include<string>
#include<stack>

using namespace std;
typedef long long ll;

int main(){
    int x,n;
    cin>>x>>n;
    unordered_set<int> record;
    for(int i=0;i<n;i++){
        int el;
        cin>>el;
        record.insert(el);
    }
    
    int answer = x;
    if(!record.count(answer)){
        cout<<answer;
    }
    else{
        int low = x-1;
        int high = x+1;
        bool cond = true;
        while(cond){
            if(!record.count(low) && !record.count(high)){
                // both are not present
                answer = low;
                cond = false;
            }
            else{
                if(!record.count(low)){
                    // high is present
                    answer = low;
                    cond = false;
                }
                else if(!record.count(high)){
                    // low is present
                    answer = high;
                    cond = false;
                }
                else{
                    // both are present
                    low--;
                    high++;
                }
            }
        }
        cout<<answer;
    }
    
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  int64_t ans=0;
  rep(i,n){
    int64_t y=i+1;
    if(y%3==0||y%5==0)continue;
    else ans+=y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int INF = 1e9+7;

int main() {
    int N;
    scanf("%d", &N);

    vector<int> a(N);
    rep(i, 0, N) scanf("%d", &a[i]);
    a.push_back(INF);

    sort(a.begin(), a.end());
    int ans = 0;
    int i = a[0];
    int cnt = 1;
    rep(j, 1, N + 1) {
        if (i == a[j]) {
            cnt++;
        }
        else {
            if (cnt > i) ans += cnt - i;
            if (cnt < i) ans += cnt;
            i = a[j];
            cnt = 1;
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/
const int MAX = 1e5 + 1;
int cache[MAX];
vector<int> a;
bool isWinning(ll k) {
    if (k == 0) return false;
    if (cache[k] != -1) return cache[k];
    ll yes = false;
    for (int e : a) {
        if (k >= e && !isWinning(k - e)) {
            yes = true;
        }
    }
    return cache[k] = yes;
}

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    ll n, k;
    memset(cache, -1, sizeof cache);
    cin >> n >> k;
    a = vector<int>(n);
    for (auto &e : a) {
        cin >> e;
    }
    cout << ((isWinning(k)) ? "First" : "Second");
}
/************************************** END OF PROGRAM ******************************************/


Measured memory_bytes: 5376
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ANumberOfMultiples {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int l, r, d; cin >> l >> r >> d;
      int ans = 0;
      for(int i=l; i<=r; i++) {
        if (i%d == 0) {
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  ANumberOfMultiples solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3612
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i,k,s=0;cin>>n>>k;vi v(n);
	for(i=0;i<n;i++) cin>>v[i];sort(rall(v));
	for(i=k;i<n;i++) s+=v[i];cout<<s<<endl;
}



Measured memory_bytes: 1792
var s,t:String;i:Longint;
begin
	readln(s);
	readln(t);
	if length(s)<>length(t) then
		if length(s)<length(t) then writeln('LESS')else writeln('GREATER')
	else begin
		for i:=1 to length(s) do
			if s[i]<>t[i] then begin
				if s[i]<t[i] then writeln('LESS')else writeln('GREATER');
				exit;
			end;
		writeln('EQUAL');
	end;
end.


Measured memory_bytes: 128
s = gets.chomp

words  = ['dreamer', 'eraser', 'dream', 'erase']

words.permutation(4) do |arr|
  tmp_s = s.dup
  arr.each do |word|
    while tmp_s.include?(word)
      tmp_s.gsub!(word, '')
    end
  end
  if tmp_s == ''
    puts 'YES'
    exit
  end
end

puts 'NO'


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

int main(){
	string a;
	cin >> a;
//	ifstream file("Input.txt");
	string b;
	int counter = 0;
	while(cin >> b){
		if(b.compare("END_OF_TEXT") == 0)
			break;
		for(int i = 0; i < b.length(); i++){
			if(b[i] < 91 && b[i] > 64){
				b[i] += 32;
			}
		}
		if(a.compare(b) == 0)
			counter++;
	}
	cout << counter << endl;
}


Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
using namespace std;

int main()
{
    int N, i, j;
    cin>>N;
    vector<int> S(N+1);
    S[0] = S[1] = S[2] = 0;
    S[3] = S[4] = S[5] = 1;
    for(i=6;i<=N;i+=1)
    {
        S[i]= 1;
        for(j=3;j<=i-3;j+=1)
        {
            S[i] = (S[i] + S[j])%1000000007;
        }
    }
    cout<<S[N]<<endl;
}


Measured memory_bytes: 3596