akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
    int i, j;
    string s;
    cin >> s;
    if((s[0]=='A' && s[1]=='A' && s[2]=='A') ||
      (s[0]=='B' && s[1]=='B' && s[2]=='B') )
    {
        cout << "No";
    } 
    else
    {
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	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*(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;
	}
	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;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    mint sum = 0;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    mint ans = 0;
    rep(i,n){
        ans += (sum + mod - a[i]) * a[i];
        sum = sum + mod - a[i];
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.size(),l=0,o=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		l++;
		else
		o++;
	}
	if(l>o)
	{
		cout<<n-l+o;
		return 0;
	}
	cout<<n-o+l;
	return 0;
}

Measured memory_bytes: 512
// 2020-08-04 17:10:54
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k, c = 0;
  cin >> n >> k; 
  while (n > 0) n /= k , c++;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        String S = reader.next();
        if (S.length() < 4) {
            System.out.println("No");
            return;
        }
        if (S.charAt(0) == 'Y' &&
            S.charAt(1) == 'A' &&
            S.charAt(2) == 'K' &&
            S.charAt(3) == 'I') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};

int N, K, C;
string S;

vector<int> o_pos;  // 'o' の位置
vector<int> l_cnt;  // [0, i] までで働ける最大回数
vector<int> r_cnt;  // [i, N-1] までで働ける最大回数

// [lb, ub] で働ける最大回数
int GetMax(int lb, int ub) {
    if(ub < 0 || lb < 0) { return 0; }
    if(lb > ub) { return 0; }
    if(lb >= N || ub >= N) { return 0; }
    if(lb == 0) { return l_cnt[ub]; }
    return r_cnt[lb];
}

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

    cin >> N >> K >> C >> S;

    CumulativeSum<int> cs(N);

    l_cnt.resize(N);
    r_cnt.resize(N);
    int cur = 0;
    int cnt = 0;
    REP(i, N) {
        if(S[i] == 'o') {
            o_pos.push_back(i);
            if(cnt == 0) {
                cur++;
                cnt = C + 1;
            }
            cs.Add(i, 1);
        }
        l_cnt[i] = cur;
        if(cnt > 0) { cnt--; }
    }
    cs.Build();
    cur = 0;
    cnt = 0;
    for(int i = N - 1; i >= 0; --i) {
        if(S[i] == 'o') {
            if(cnt == 0) {
                cur++;
                cnt = C + 1;
            }
        }
        r_cnt[i] = cur;
        if(cnt > 0) { cnt--; }
    }

    int ans_cnt = 0;
    for(auto& pos : o_pos) {
        int sum = GetMax(0, pos - 1) + GetMax(pos + 1, N - 1);
        if(sum < K) {
            printf("%lld\n", pos + 1);
            ans_cnt++;
        }
    }
    if(ans_cnt == 0) {
        printf("\n");
    }

    return 0;
}


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


#define INF 1000000000000


signed main()
 {
int n;
cin>>n;
cout<<800*n-n/15*200;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    int result = 1;
    int max = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        bool able = true;
        int count = 0;
        int p = i;
        while(able == true){
            if(p % 2 == 0){
                p = p / 2;
                count ++;
            }else{
                able = false;
            }
        }
        if(count > max){
            max = count;
            result = i;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<math.h>
using namespace std;

int main(){
    int N;
    map<int, int> cnt;
    cin >> N;
    int require = 1;
    if (N % 2 == 1) require--;
    for (int i=0; i<N; i++){
        int A; cin >> A;
        if (A%2 != require){
            cout << 0 << endl;
            return 0;
        }
        cnt[A]++;
        if (cnt[A] > 2){
            cout << 0 << endl;
            return 0;
        }
    }
    if (require == 0){
        if (cnt[0] == 1){
            cnt.erase(0);
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
    for (auto x : cnt){
        if (x.second != 2){
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans=1;
    for (int i=0; i< N/2; i++){
        ans *= 2;
        ans %= 1000000007; 
    }
    cout << ans << endl;
    return 0;
}

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

class mint {
  int value;
  static vector<int> *_fact;

public:
  static const int MOD = 1e9 + 7;
  mint(long long x)
      : value((x % MOD + MOD) % MOD) {}
  mint operator+(mint y) const {
    return mint(value + y.value);
  }
  mint &operator+=(mint a) {
    return *this = *this + a;
  }
  mint operator*(mint y) const {
    return mint(long(value) * y.value);
  }
  mint &operator*=(mint a) {
    return *this = *this * a;
  }
  mint operator-() const {
    return *this * mint(-1);
  }
  mint operator-(mint y) const {
    return *this + (-y);
  }
  mint &operator-=(mint a) {
    return *this = *this - a;
  }
  operator int() const {
    return value;
  }
  static mint pow(mint a, int n) {
    if (n <= 0) {
      return 1;
    }
    mint half = mint::pow(a, n / 2);
    return n % 2 ? half * half * a : half * half;
  }
  static void init(int n) {
    _fact = new vector<int>(n + 1);
    (*_fact)[0] = 1;
    mint val = 1;
    for (int i = 1; i <= n; i++) {
      val *= i;
      (*_fact)[i] = val;
    }
  }
  static mint fact(int n) {
    return (*_fact)[n];
  }
  mint inv() {
    return pow(value, MOD - 2);
  }
  static mint comb(int n, int k) {
    return fact(n) * fact(k).inv() * fact(n - k).inv();
  }
};
vector<int> *mint::_fact;

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

  string S;
  cin >> S;

  int W = S.size();
  int L = W + K;

  mint::init(L);
  mint ans = 0;
  for (int i = W - 1; i < L; i++) {
    ans += mint::pow(25, i - (W - 1)) * mint::pow(26, L - 1 - i) * mint::comb(i, W - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 12084
#include<bits/stdc++.h>
using namespace std;
int a, b, c;
int main(){
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    for(int i = 1; i <= b; ++i){
        if(a * i % b == c){
            cout << (char)89 << (char)69 << (char)83 << (char)10;
            return 0;
        }
    }
    cout << (char)78 << (char)79 << (char)10;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

int main() {
    ll n;
    cin >> n;
    VL p(n);
    REP(i,n){
        p[i] = in();
    }
    ll ans = 0;
    REP(i,n){
        ans = (ans + divll(p[i] * powll(p[i] + 1, i), powll(2, i))) % mod;
    }
    ans = (ans * powll(2, n - 1)) % mod;
    cout << ans << endl;
    return 0;
}



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BEasyLinearProgramming {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B, C, K;
        cin >> A >> B >> C >> K;
        int res = 0;
        if (K <= A+B) {
            cout << min(A, K) << endl;
        } else {
            int res = K - (A+B);
            cout << A - res << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BEasyLinearProgramming solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
        string s;
        cin >> s;
        string t = s;
        reverse(s.begin(), s.end());
        for (int i = 0; i < s.size(); i ++) {
                if (s[i] == 'b') s[i] = 'd';
                else if (s[i] == 'd') s[i] = 'b';
                else if (s[i] == 'p') s[i] = 'q';
                else if (s[i] == 'q') s[i] = 'p';
        }
        puts(s == t ? "Yes" : "No");
        return 0;
}



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

string max(string a,string b){
	int na=a.size(),nb=b.size();
	if(na>nb) return a;
	if(nb>na) return b;
	for(int i=0;i<na;i++){
		if(a[i]>b[i])
			return a;
		if(b[i]>a[i])
			return b;
	}
	return a;
}

int main(void){
	int H,W;
	string  dp[70][70];
	char table [70][70];

	while(cin >> W >> H,W|H){

		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				cin >> table[i][j],dp[i][j]='0';
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				string cur;
				if(isdigit(table[i][j]))
					cur=table[i][j];
				if(cur !="0")
					dp[i][j]=cur;
				if(i&&isdigit(table[i][j])&&dp[i-1][j]!="0")
					dp[i][j]=max(dp[i][j],(dp[i-1][j]+cur));
				if(j&&isdigit(table[i][j])&&dp[i][j-1]!="0")
					dp[i][j]=max(dp[i][j],(dp[i][j-1]+cur));
			}
		}
		string ans="0";
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
					ans=max(ans,dp[i][j]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1380
import java.util.Scanner;
import java.util.HashMap;

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

        HashMap<String,Integer> map = new HashMap<String,Integer>();

        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            if(map.containsKey(s)){
                map.replace(s, map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }

        int m = sc.nextInt();
        for(int i = 0; i < m; i++){
            String s = sc.next();
            if(map.containsKey(s)){
                map.replace(s, map.get(s)-1);
            }
        }

        int result = 0;
        for(Integer fuga : map.values()){
            if(fuga > result){
                result = fuga;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 22996
import sys
n,m=map(int,input().split())

a=[]
b=[]
l1=[False for i in range(n)]
ln=[False for i in range(n)]

for i in range(m):
    c=[int(i) for i in input().split()]
    a.append(c[0])
    b.append(c[1])
    if c[0]==1 or c[1]==1:
        l1[c[0]*c[1]]=True
    if c[0]==n or c[1]==n:
        ln[c[0]*c[1]//n]=True

for i in range(n):
    if l1[i] and ln[i]:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")
    
    

Measured memory_bytes: 23444
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		int res = 0;
		char c = '+';
		while (c != '=') {
			int tmp = sc.nextInt();

			if (c == '+') res += tmp;
			if (c == '-') res -= tmp;
			if (c == '*') res *= tmp;
			if (c == '/') res /= tmp;

			c = sc.next().charAt(0);
		}

		System.out.println(res);
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

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

int m[53][53];
int ne[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int judge(int a,int b){
	for(int i=0;i<4;++i){
		if(m[a+ne[i][0]][b+ne[i][1]]==1){
			return 0;
		}	
	}	
	return 1;
}
int main(){
	int h,w;
	int flag=0;
	cin>>h>>w;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			char a;
			cin>>a;
			if(a=='#')
				m[i][j]=1;
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(m[i][j]==1&&judge(i,j)){
				flag=1;
				break;
			}
		}
	}
	if(flag==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
N, D = map(int,input().split())
XY = [list(map(int,input().split())) for x in range(N)]
ans = 0
import math


for p in range(N):
    if math.sqrt(XY[p][0]**2 + XY[p][1]**2) <= D:
        ans += 1

print(ans)

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 3010;

int N, T;
vector<int> A, B;
int dp[MAX_N][MAX_N][2];

// i 番目の料理を見ていて、現在のコストは j、
// 最後に食べるものを選定済みなら k = 1, そうでないなら k = 0
int dfs(int i, int j, int k) {
    if(i >= N) {
        return 0;
    }

    int& ret = dp[i][j][k];
    if(~ret) { return ret; }

    // 食べない場合
    ret = dfs(i + 1, j, k);

    // 食べる場合
    if(j + A[i] < T) {
        chmax(ret, dfs(i+1, j + A[i], k) + B[i]);
    }

    // これを最後に選ぶ場合
    if(k == 0) {
        chmax(ret, dfs(i+1, j, 1) + B[i]);
    }

    return ret;
}

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

    cin >> N >> T;
    A.resize(N);
    B.resize(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    MINUS(dp);
    int ans = dfs(0, 0, 0);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 145576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var N int
var graph [][]int

func main() {
	N = ReadInt()
	graph = make([][]int, N)
	for i := 0; i < N-1; i++ {
		a, b := ReadInt()-1, ReadInt()-1
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	firstDist := make([]int, N)
	secondDist := make([]int, N)
	dfs(0, 0, make([]bool, N), firstDist)
	dfs(N-1, 0, make([]bool, N), secondDist)

	var firstCnt, secondCnt int
	for i := 0; i < N; i++ {
		if firstDist[i] <= secondDist[i] {
			firstCnt++
		} else {
			secondCnt++
		}
	}
	if firstCnt > secondCnt {
		fmt.Println("Fennec")
	} else {
		fmt.Println("Snuke")
	}
}

func dfs(u int, depth int, visited []bool, dist []int) {
	if visited[u] {
		return
	}
	visited[u] = true
	dist[u] = depth
	for _, dest := range graph[u] {
		dfs(dest, depth+1, visited, dist)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 37352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

vector<ll> p,q,r,all;

int main() {
    ll x,y,a,b,c,ans = 0;
    cin >> x >> y >> a >> b >> c;
    p.resize(a),q.resize(b),r.resize(c);
    for (int i = 0; i < a; ++i) cin >> p[i];
    for (int i = 0; i < b; ++i) cin >> q[i];
    for (int i = 0; i < c; ++i) cin >> r[i];
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    p.resize(x);
    q.resize(y);
    for (int i = 0; i < x; ++i) {
        all.push_back(p[i]);
    }
    for (int i = 0; i < y; ++i) {
        all.push_back(q[i]);
    }
    for (int i = 0; i < r.size(); ++i) {
        all.push_back(r[i]);
    }
    sort(all.begin(),all.end(),greater<ll>());
    for (int i = 0; i < x+y; ++i) {
        ans += all[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8688
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;
//initialization here


//initialization finish


// your function is here

// your function finished

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	int n, m; cin >> n >> m;

	string a[55], b[55];
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	bool check = true;
	rep(i, n - m+1)
	{
		rep(j, n - m+1)
		{
			rep(k, m)
			{
				rep(l, m)
				{
					if (a[i + k][j + l] != b[k][l])
					{
						check = false;
					}

					if (!check) break;
				}
				if (!check) break;
			}

			if (check) { Yes; return 0; }
			check = true;
		}
	}
	
	No;

	// your code finished
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

def f(S):
  count = {'W': 0, 'E': 0}
  yield count['W'], count['E']
  for c in S:
    count[c] += 1
    yield count['W'], count['E']

count = list(f(S))
print(min([count[i-1][0] + count[-1][1] - count[i][1] for i in range(1, N+1)]))


Measured memory_bytes: 46492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int[] div = new int[2];
		div[0] = 0;
		div[1] = 0;
		div[a % 2]++;
		div[b % 2]++;
		div[c % 2]++;
		if((div[0] == 2) || (div[1] == 2))
			ans++;
		if(div[a % 2] == 2) {
			a++;
		}
		if(div[b % 2] == 2) {
			b++;
		}
		if(div[c % 2] == 2) {
			c++;
		}
		int tmp = Math.max(a, Math.max(b, c));
		ans += (tmp - a) / 2;
		ans += (tmp - b) / 2;
		ans += (tmp - c) / 2;
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(c>b/a)cout<<b/a<<endl;
   else cout<<c<<endl;
    return 0;
}

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int64_t ans = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      int64_t c = j+1;
      int64_t x = vec.at(i) + vec.at(j);
      auto position_y = upper_bound(vec.begin(),vec.end(),vec.at(j) - vec.at(i));
      int64_t y = distance(vec.begin(),position_y);
      y = max(c,y);
      auto position_z = lower_bound(vec.begin(),vec.end(),x);
      int64_t z = distance(vec.begin(),position_z);
      ans += max((int64_t)0,z - y);
    }
  }
  cout << ans << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    string s;
    string word[4] = {"eraser","erase","dreamer","dream"};
    cin >> s;
    rep:if(s.empty()){
        cout << "YES" << endl;
        return 0;
    }
    for(int i = 0;i < 4;i++){
        if(s.length() < word[i].length())continue;
        if(s.rfind(word[i]) == s.length()-word[i].length()){
            s.erase(s.end()-word[i].length(),s.end());
            goto rep;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String N = sc.next();
	boolean result = false;
	for(int i=0;i<3;i++){
	    if(Character.getNumericValue(N.charAt(i)) == 7) result = true;
	}
	if(result) System.out.print("Yes");
	else System.out.print("No");
    }
}

Measured memory_bytes: 35472
#include <stdio.h>
int solve(int ,int);

int n; //n=<20
int A[20]; //

int main(void){
  int q,i,judge=0;
  int M[200];

  scanf("%d",&n);
  for( i=0 ; i<n ; i++) scanf("%d",&A[i]);
 
  scanf("%d",&q);
  for( i=0 ; i<q ; i++) scanf("%d",&M[i]);

  for( i=0 ; i<q ; i++){
    judge = solve(0, M[i]); //solve function
    if(judge == 0) printf("no\n");
    else printf("yes\n");
  }

  return 0;

}

int solve(int x,int M){
 
  if(x == n && M == 0) return 1;
 
  if(x == n && M != 0) return 0;

  else return solve(x+1,M)+solve(x+1,M-A[x]); //recursive function

}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);


int main(){
    ll N,A,B; cin>>N>>A>>B;
    if(N==1){
        if(A!=B) cout<<0;
        else cout<<1;
    }
    else{
        if(A>B) cout<<0;
        else cout<<(B-A)*(N-2)+1<<endl;
    }
}



Measured memory_bytes: 3632
import math
n = int(input())
xy = []
for i in range(n):
    x, y = [int(item) for item in input().split()]
    if x == 0 and y == 0:
        rad = 0.0
    elif x == 0:
        if y > 0:
            rad = math.pi / 2.0
        elif y < 0:
            rad = -math.pi / 2.0
    else:
        rad = math.atan2(y, x)
    deg = math.degrees(rad)
    xy.append((deg, x, y))

xy.sort()
xy2 = xy[:]
for i, (d, x, y) in enumerate(xy):
    xy2.append((d+360.0, x, y))
    if i == 0:
        xy2.append((d+720.0, x, y))
xy2.sort()

ans = 0.0
for i in range(n):
    for j in range(i+1, i+n+1):
        x = 0.0; y = 0.0
        for k in range(i, j):
            x += xy2[k][1]
            y += xy2[k][2]
        d = math.hypot(x, y)
        ans = max(ans, d)

print(ans)

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

s = list(input())

answer = True

if s[0] != "A":
    answer = False

c = 0


for i in range(2,len(s)-1):
    if s[i] == "C":
        c += 1

if c != 1:
    answer = False

capital = 0


for i in range(len(s)):
    if s[i].isupper():
        capital += 1

if capital != 2:
    answer = False

if answer:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

    int n, k[2];
    cin >> n >> k[0] >> k[1];

    UnionFind uf[2] = { n, n };
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < k[i]; j++) {
            int a, b;
            cin >> a >> b;
            a--; b--;

            uf[i].unite(a, b);
        }
    }

    vector<pair<int64_t, int>> t(n);
    for (int i = 0; i < n; i++) {
        t[i] = { (int64_t)n * uf[0].root(i) + uf[1].root(i), i };
    }
    sort(t.begin(), t.end());

    vector<int> r(n);
    int i0 = 0, c = 0;
    for (int i = 0; i <= n; i++) {
        if (i == n || t[i].first != t[i0].first) {
            for (int h = i0; h < i; h++) {
                r[t[h].second] = c;
            }
            i0 = i;
            c = 0;
        }
        c++;
    }
    for (int i = 0; i < n; i++) {
        cout << r[i] << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define int long long
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
/*int fun(string &str)
{
    int ind=-1;
    for(int i=0;i<str.size()-1;i++)
    {
        if(str[i]=='W' && str[i+1]=='R')
        {
            ind=i;
            break;
        }
    }
    if(ind==-1)
        return 1;
    return 0;
}*/
void swap(char *a,char* b)
{
    char c=(*a);
    *a=*b;
    *b=c;
}
int32_t main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    int re=0,w=0;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='R')
            re++;
        else
            w++;
    }
    int ans=min(re,w);
    int cnt=0,p=0,r=n-1;
    int ok1=0,ok2=0;
    while(p<=r)
    {
        if(str[p]=='W')
        {
            ok1=1;

        }
        if(str[r]=='R')
        {
            ok2=1;
        }
        if(ok1==1 && ok2==1)
        {
            str[p]='R';
            str[r]='W';
            cnt++;
            p++;
            r--;
            ok1=0;
            ok2=0;
        }
        else if(ok1==0 && ok2==1)
        {
            p++;
        }
        else if(ok1==1 && ok2==0)
        {
            r--;
        }
        else if(ok1==0 && ok2==0 )
        {
            p++;
            r--;
        }
    }
    cout<<min(ans,cnt);
    return 0;
}


Measured memory_bytes: 3696
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> b(n);

    rep(i,n) b[i] = a[i];

    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());

    int maf = b[0];
    int mas = b[1];

    vector<int> ans(n);

    rep(i,n){
        if(a[i] == maf){
            ans[i] = mas;
        }

        else ans[i] = maf;
    }

    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(b == 1){
      print(0);
      return 0;
    }
    if(a == b){
      print(1);
      return 0;
    }
    int tmp = 1;
    while(true){
      tmp--;
      tmp += a;
      ans++;
      if(tmp >= b) break;
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010


int main(){
	IOS;
	tihs;
	
	
	ll a[5];
	rep(i,0,5)cin>>a[i];
	ll k;cin>>k;
	bool ok=1;
	rep(i,0,5)rep(j,i+1,5)if(abs(a[i]-a[j])>k)ok=0;
	if(ok)cout<<"Yay!";
	else cout<<":(";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<pair<ll, int>> list;
	vector<pair<ll, int>> maxList(N);
	for (auto i = 0; i < N; ++i)
	{
		int t;
		ll d;
		cin >> t >> d;
		--t;
		list.push_back({ d, i });
		if (maxList[t].first < d)
		{
			maxList[t].first = d;
			maxList[t].second = i;
		}
	}

	sort(maxList.begin(), maxList.end());
	sort(list.begin(), list.end(), greater<pair<ll, int>>());
	auto ans = 0ll;
	auto sum = 0ll;
	auto kind = 0ll;
	auto num = 0ll;
	vector<bool> used(N);
	auto index2 = 0;
	for (auto i = N - 1; i >= 0 && num < K; --i)
	{
		if (maxList[i].first > 0)
		{
			used[maxList[i].second] = true;
			sum += maxList[i].first;
			++kind;
			++num;
			index2 = i;
		}
	}

	auto index1 = 0;
	for (; index1 < N; ++index1)
	{
		if (used[list[index1].second] != false)
		{
			continue;
		}

		if (num >= K)
		{
			break;
		}

		sum += list[index1].first;
		used[list[index1].second] = true;
		++num;
	}

	ans = sum + kind * kind;

	while (index1 < N && list[index1].first > maxList[index2].first)
	{
		--kind;
		sum -= maxList[index2].first;
		sum += list[index1].first;

		ans = max(ans, sum + kind * kind);
		used[list[index1].second] = true;
		used[maxList[index2].second] = false;
		++index2;
		while (index1 < N && used[list[index1].second] != false)
		{
			++index1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4084
n = int(input())

tbl = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, (input().split()))
        tbl[i].append([x, y])

ans = 0
for i in range(2 ** n):
    flg = True
    for j in range(n):
        if (i >> j) & 1 == 1:
            for k in tbl[j]:
                if (i >> (k[0] - 1)) & 1 != k[1]:
                    flg = False
    if flg == True:
        ans = max(ans, str(bin(i)).count('1'))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)

int main(void){
    int a,b;
    cin >> a >> b;
    if(a>b) swap(a,b);
    rep(_,b) cout << a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9
#define PI 3.14159265359
#define mod 1000000007

int main(){
    long long N,K;
    cin >> N >> K;
    long long res = 0;
    for(int i = K; i <= N+1; i++){
        long long temp = i*(N-i+1)+1;
        res += temp % mod ;
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    auto calc=[] (ll x) {
        return x*x*x*x*x;
    };
    ll X; cin >> X;
    vector<ll> A;
    ll x = 0;
    while (true) {
        if (calc(x) >= 1000000000000000000LL) break;
        A.emplace_back(calc(x));
        x++;
    }
    rep(i,x) {
        ll val = A[i] - X;
        bool mi = false;
        if (val < 0) mi = true;
        rep(j,x) {
            if (mi) {
                if (-val == A[j]) {
                    cout << i << " " << -j << ln;
                    return 0;
                }
            } else {
                if (val == A[j]) {
                    cout << i << " " << j << ln;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3644
fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> T.print() = println(this)

const val mod = 998244353L

fun main() {
	abc000X()
}

fun abc000X() {
	val a = str()
	val b = str()

	println(a.indices.count {a[it]!=b[it]})
}


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

int main(){
  int n,l; cin >> n >> l;
  if(l>0) cout << l*n + (1+n)*n/2 - n -l;
  else if(n+l-1<0) cout << l*n + (1+n)*n/2 - n - (l + n - 1);
  else cout << l*n + (1+n)*n/2 - n;
}

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

int main() {
    double D, T, S;
    cin >> D >> T >> S;
    if(D / S <= T) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int h,w,i=0,j=0,k=0,m,n,p,e,f=0,sum=0,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++)
	sum+=i*(n-i+1);
	for(i=0;i<n-1;i++)
	{
	    cin>>j>>k;
      if(k<j)swap(j,k);
	    sum-=j*(n-k+1);
	}
	cout<<sum;
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  


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

int main(void) {
  int n, m, tmp1, tmp2;
  cin >> n >> m;
  int a[n+1];
  fill(a, a+n+1, -1);
  for(int i=0;i<m;i++) {
    cin >> tmp1 >> tmp2;
    if(a[tmp1] == -1 ) { a[tmp1] = tmp2; }
    else if(a[tmp1] != tmp2) { cout << -1 << endl; return 0; }
  }
  if(a[1] == -1) {
    if(n==1) a[1] = 0;
    else a[1] = 1;
  }
  if(a[1] ==0 && n > 1) { cout << -1 << endl; return 0; }
  for(int i = 2;i<n+1; i++) { if(a[i] == -1) a[i] = 0; }
  for(int i=1;i<n+1; i++) cout << a[i];
  cout << endl;
}

Measured memory_bytes: 256