akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var S string
	fmt.Scanf("%s\n", &S)

	l := len(S)
	r := []rune(S)
	var a, b, c bool
	left := r[:l/2]
	right := r[l/2+1:]
	if string(left) == Reverse(string(right)) {
		a = true
	}
	piv1 := len(left) / 2
	if len(left)%2 != 0 {
		if string(left[:piv1]) == Reverse(string(left[piv1+1:])) {
			b = true
		}
    } else {
      	if string(left[:piv1]) == Reverse(string(left[piv1:])) {
			b = true
		}
    }


	piv2 := len(right) / 2
	if len(right)%2 != 0 {
		if string(right[:piv2]) == Reverse(string(right[piv2+1:])) {
			c = true
		}
    } else {
      	if string(right[:piv2]) == Reverse(string(right[piv2:])) {
			c = true
		}
    }


	if a && b && c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123456];
signed main() {
    int n, a, b; cin >> n;
    for (int h = n; h < n + 100000; h++) {
        if (h < 2) continue;
        else if (h == 2) { cout << 2 << endl; return 0; }
        else if (h % 2 == 0) continue; // 偶数はあらかじめ除く
        int c = 0;
        double sqrth = sqrt(h);
        for (int i = 3; i <= sqrth; i += 2) {
            if (h % i == 0) {
                // 素数ではない
                c++;
            }
        }
        if (c == 0) {
            // 素数である
            cout << h << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	long long ans=1;
	for(int i=1;i<=N;i++){
		ans=ans*i%MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());
        if(Math.max(a*c,Math.max(a*d,Math.max(b*c,b*d))) < 0) {
            if(a <= 0 && b >= 0 || c <= 0 && d >= 0) {
                System.out.println(0);
            }else {
                System.out.println(Math.max(a*c,Math.max(a*d,Math.max(b*c,b*d))));
            }
        }else {
            System.out.println(Math.max(a*c,Math.max(a*d,Math.max(b*c,b*d))));
        }
    }
}



Measured memory_bytes: 35820
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int N;


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

    
    std::cout << 180 * (N - 2) << std::endl;

    return 0;
}

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

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i,_n) for(ll _i = 0; _i < _n; _i++)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define findMaxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
#define append(_x) push_back(_x)
#define mapLoop(_i, _name) for(auto i = _name.begin(); i != _name.end(); i++)


int main()
{
    ll N, M;
    cin >> N >> M;
    vec <ll> H(N);
    vec <int> still(N, 1);
    rep(i, N){
      cin >> H[i];
    }
    ll ans = N;
    rep(i, M){
      ll A, B;
      cin >> A >> B;
      A--;
      B--;
      if(still[B] == 1 && H[A] >= H[B]){
        still[B] = 0;
        //cout << "DEL" << B << endl;
        ans--;
      }
      if(still[A] == 1 && H[A] <= H[B]){
        still[A] = 0;
        //cout << "DEL" << A << endl;
        ans--;
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4516
#include<stdio.h>
int  main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	a=a+b;
	b=a-b;
	a=a-b;
	a=a+c;
	c=a-c;
	a=a-c;
	printf("%d %d %d",a,b,c);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;

ld dp[3001][3001];

ld f(vector<ld>&a, int i, int x) {
	if (x == 0) return 1;
	if (i == 0) return 0;
	if (dp[i][x] > -0.9) return dp[i][x];
	return dp[i][x] = a[i] * f(a, i - 1, x - 1) + (1 - a[i]) * f(a, i - 1, x);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif
	int n; cin >> n;
	memset(dp, -1, sizeof(dp));
	vector<ld>a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	cout << fixed << setprecision(10) << f(a, n, (n + 1) / 2);
	return 0;
}

Measured memory_bytes: 141312
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstring>

using namespace std;

typedef long long LL;
const LL maxx = 1000000 + 10;
char H[maxx][15];

LL ChatToInt(char ch)
{
	if (ch == 'A') return 1;
	if (ch == 'C') return 2;
	if (ch == 'G') return 3;
	if (ch == 'T') return 4;

	return 0;
}

// 将字符串转成数值并生成key
LL GetKey(const char value[])
{
	LL sum = 0, p = 1;
	int len = strlen(value);
	for (int i = 0; i < len; ++i)
	{
		sum += p * ChatToInt(value[i]);
		p *= 5;
	}

	return sum;
}

LL h1(LL key)
{
	return key % maxx;
}

LL h2(LL key)
{
	return 1 + (key % (maxx - 1));
}

bool Find(const char value[])
{
	LL key, h;
	key = GetKey(value);
	for (LL i = 0; ; ++i)
	{
		h = (h1(key) + i * h2(key)) % maxx;
		//找到key
		if (0 == strcmp(H[h], value)) return true;
		// key不存在
		else if (strlen(H[h]) == 0) return false;
	}

	return false;
}

void Insert(const char value[])
{
	LL key, h;
	key = GetKey(value);
	for (LL i = 0; ; ++i)
	{
		h = (h1(key) + i * h2(key)) % maxx;
		//找到key
		if (0 == strcmp(H[h], value)) return;
		// key不存在
		else if (strlen(H[h]) == 0)
		{
			strcpy(H[h], value);
			return;
		}
	}
}

int main()
{
	int n; cin >> n;
	string command;
	string value;
	for (int i = 0; i < n; ++i)
	{
		cin >> command;
		cin >> value;
		if (command.compare("insert") == 0) 
			Insert(value.c_str());
		else if (command.compare("find") == 0)
		{
			if (Find(value.c_str())) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 17624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
class Project
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        int[] A = Console.ReadLine().Split(' ').Select(s => Int32.Parse(s)).ToArray();
        int min = 0;
        int count = 0;
        int Ans = 0;

        Array.Sort(A);

        for(int i = 0; i < K; i++)
        {
            Ans += A[i];
        }
        Console.WriteLine(Ans);
    }
}

Measured memory_bytes: 28588
s = input()

if s == "KIHBR" or s == "KIHABARA" or s == "AKIHBARA" or s == "AKIHABRA" or s == "AKIHABAR" or \
    s == "AKIHABARA" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or \
        s == "AKIHABR" or s == "AKIHBAR" or s == "AKIHBRA" or s == "KIHABAR" or s == "KIHABRA" or s == "KIHBARA":
        print("YES")
else:
    print("NO")

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

uint64_t lucas(int n) {
  vector<int64_t> L(86+1);
  L[0] = 2LL;
  L[1] = 1LL;
  if (n==0) return L[0];
  if (n==1) return L[1];
  for (int i=2; i<=n; i++) {
    L[i] = L[i-1] + L[i-2];
  }
  return L[n];
}

int main(){
  int n;
  cin >> n;
  cout << lucas(n) << endl;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<pair<ll,ll>> C(N),D(N);
    rep(i,N){
        cin >> A[i] >> B[i];
        C[i] = make_pair(A[i] + B[i], i);
        //D[i] = make_pair(B[i] - A[i], i);
    }
    sort(C.begin(), C.end(), greater<pair<ll,ll>>());
    //sort(D.begin(), D.end(), greater<pair<ll,ll>>());
    ll L = 0;
    ll R = N-1;
    ll tak = 0;
    ll aok = 0;
    rep(i,N){
        if(i % 2 == 0){
            tak += A[C[i].second];
        }else if(i % 2 == 1){
            aok += B[C[i].second];
        }
    }
    cout << tak - aok << endl;
}

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




int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    limit = k ** 0.5
    while 1 < k and i <= limit:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
                limit = k ** 0.5
            else:
                break
        i += 2
    if k > 1:
        f[k] = 1
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx - 1, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1]
    ans %= MOD
    ans *= r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)


Measured memory_bytes: 11252
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define MAX 10001
#define INF (1<<29)
 
int main()
{
    int Tc,N;
    string s;
    cin >> Tc;
    while(Tc--)
    {
        cin >> N >> s;
        bool b[2][MAX] = {{}};
        for(int i = 0 ; i <= N ; i++)
        {
            if(i != 0 && s[2*i-1] == 'Y') b[0][i] = 1;
            if(i != N && s[2*i] == 'Y') b[0][i] = 1;
            if(i != 0 && s[2*i-1+2*N] == 'Y') b[1][i] = 1;
            if(i != N && s[2*i+2*N] == 'Y') b[1][i] = 1;
        }
         
        auto solve = [=]()
            {
                vector<vector<int>> dp(2, vector<int>(MAX, INF));
                if(b[0][0] == 1 && b[1][0] == 1)
                {
                    dp[1][0] = 2;
                }
                if(b[0][0] == 1 && b[1][0] == 0)
                {
                    dp[0][0] = 1;
                    dp[1][0] = 1;
                }
                if(b[0][0] == 0 && b[1][0] == 1)
                {
                    dp[1][0] = 2;
                }
                if(b[0][0] == 0 && b[1][0] == 0)
                {
                    dp[0][0] = 0;
                    dp[1][0] = 1;
                }
                     
                for(int i = 1 ; i <= N ; i++)
                {
                    if(b[0][i] == 1 && b[1][i] == 1)
                    {
                        dp[0][i] = min(dp[0][i],dp[0][i-1]+4);
                        dp[0][i] = min(dp[0][i],dp[1][i-1]+3);
                        dp[1][i] = min(dp[1][i],dp[0][i-1]+3);
                        dp[1][i] = min(dp[1][i],dp[1][i-1]+3);
                    }
                    if(b[0][i] == 1 && b[1][i] == 0)
                    {
                        dp[0][i] = min(dp[0][i],dp[0][i-1]+2);
                        dp[0][i] = min(dp[0][i],dp[1][i-1]+2);
                        dp[1][i] = min(dp[1][i],dp[0][i-1]+2);
                        dp[1][i] = min(dp[1][i],dp[1][i-1]+2);
                    }
                    if(b[0][i] == 0 && b[1][i] == 1)
                    {
                        dp[0][i] = min(dp[0][i],dp[0][i-1]+4);
                        dp[0][i] = min(dp[0][i],dp[1][i-1]+3);
                        dp[1][i] = min(dp[1][i],dp[0][i-1]+3);
                        dp[1][i] = min(dp[1][i],dp[1][i-1]+2);
                    }
                    if(b[0][i] == 0 && b[1][i] == 0)
                    {
                        dp[0][i] = min(dp[0][i],dp[0][i-1]+1);
                        dp[0][i] = min(dp[0][i],dp[1][i-1]+2);
                        dp[1][i] = min(dp[1][i],dp[0][i-1]+2);
                        dp[1][i] = min(dp[1][i],dp[1][i-1]+1);
                    }
                }
                return dp[0][N];
            };
         
        cout << solve() << endl;
    }   
    return 0;
}

Measured memory_bytes: 3292
L, R = map(int, input().split())

dl, ml = divmod(L, 2019)
dr, mr = divmod(R, 2019)

if dl < dr:
    ans = 0
else:
    ans = 10 ** 18
    for x in range(L, R):
        for y in range(x + 1, R + 1):
            ans = min(ans, (x * y) % 2019)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n) for(int i=a; i<n; i++)
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	float a,b,c,d;
	cin>>a>>b>>c;
	d=max(a,b);
	cout<<ceil(c/d);
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def init_unionfind(N):
    global parent, rank
    parent = [-1] * N
    rank = [0] * N


def find_root(x):
    p = parent[x]
    if p == -1:
        return x
    p2 = find_root(p)
    parent[x] = p2
    return p2


def unite(x, y):
    x = find_root(x)
    y = find_root(y)
    if x == y:
        return  # already united
    if rank[x] < rank[y]:
        parent[x] = y
    else:
        parent[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


def is_connected(x, y):
    return (find_root(x) == find_root(y))


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, M, edges):
    init_unionfind(N)
    for e in edges:
        unite(e[0] - 1, e[1] - 1)

    s = set(find_root(x) for x in range(N))

    return len(s) - 1


def main():
    # parse input
    N, M = map(int, input().split())
    edges = []
    for _i in range(M):
        edges.append(tuple(map(int, input().split())))

    print(solve(N, M, edges))


# tests
T1 = """
3 1
1 2
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 86176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
char s[3][2005];
int out[3][5005], len[3], ans = 6000;
int main(){
	rep(i,3){
		scanf("%s", s[i]);
		len[i] = strlen(s[i]);
	}
	rep(u,3){
		int i = u == 0 ? 1 : 0, j = u == 2 ? 1 : 2;
		rep(k,len[i]) rep(l,len[j]) if(s[i][k] != '?' && s[j][l] != '?' && s[i][k] != s[j][l]){
			out[u][k-l+2500] = true;
		}
	}
	for(int i=-4000; i<=4000; i++) for(int j=-4000; j<=4000; j++){
		bool ok = true;
		if(-len[1] < i && i < len[0] && out[2][i+2500]) ok = false;
		if(-len[2] < j && j < len[0] && out[1][j+2500]) ok = false;
		if(-len[2] < j-i && j-i < len[1] && out[0][j-i+2500]) ok = false;
		if(ok) ans = min(ans, max({len[0],i+len[1],j+len[2]}) - min({0,i,j}));
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, M; cin >> N >> M;
    vector<int> S(M), P(M);
    for (int i = 0; i < M; i++) {
        int K; cin >> K;
        for (int j = 0; j < K; j++) {
            int s; cin >> s; s--;
            S[i] |= (1 << s);
        }
    }
    for (auto &p : P) cin >> p;
    int end = 1 << N;
    int ans = 0;
    for (int i = 0; i < end; i++) {
        for (int j = 0; j < M; j++) {
            if (__builtin_popcount(S[j] & i) % 2 != P[j]) {
                goto NEXT;
            }
        }
        ans++;
        NEXT:;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Max 500000
vector<int> prim;
vector<bool> res(Max+1,true);
void aris(int n){
res[0]=res[1]=false;
	for(int i=2;i<=n;i++){
		if(res[i]){
			prim.push_back(i);
			int k=2;
			while(i*k<=n){
			res[i*k]=false;
			k++;
			}
		}
	}
	return ;
}

int main(){
int n,p;

aris(Max);
while(1){
cin>>n;
if(n==0)break;
int ans=0;
for(int i=n+1;i<=2*n;i++)
if(res[i])ans++;
cout<<ans<<endl;
		}
return 0;
}



Measured memory_bytes: 3244
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h;
    int w;
    while ((h = sc.nextInt()) != 0 | (w = sc.nextInt()) != 0){
      for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
          if(i != 0 && i != h-1){
            if(j != 0 && j != w-1){
              System.out.print(".");
            }else{
              System.out.print("#");
            }
          }else{
            System.out.print("#");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}



Measured memory_bytes: 34504
#include <bits/stdc++.h>
#include <assert.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 200010;
int n, k;


void solve(){
	cin>>n>>k;
	vi a(n);
	rep(i, 0, n)cin>>a[i];
	vector<bool> dp(k+1);

	rep(stones, 0, k+1)
	{
		rep(i, 0, n)
		{
			if(stones >= a[i] && !dp[stones-a[i]])
				dp[stones] = true;
		}
	}
	if(dp[k])cout<<"First";
		else cout<<"Second";



}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
     //cin>>t;
 
    while(t--)
        solve();
    
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<pair<long long, long long>> A(n); // {a + b, b}
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        A[i].first = a + b;
        A[i].second = b;

    }

    sort(A.begin(), A.end(), greater<pair<long long, long long>>());

    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            ans += A[i].first - A[i].second;
        }else{
            ans -= A[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include <chrono>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 998244353
#define ll long long
#define vll vector<long long>  
#define all(c) c.begin(), c.end()
// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())
// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;
using namespace std::chrono; 

const ll INF = 1e13;
int n , k;
// void dfs(int v, vector<vector<int> >& adj, vector<bool> visited){
//     visited[v] = true;
//     for(int u: adj[v]){
//         if(!visited[u])
//             dfs(u, adj, visited);
//     }
// }

int solve(int val, vector<int>& dp, vector<int>& arr){
    if(dp[val] != -1)return dp[val];
    int flag = 1;
    for(int i=0;i<n;i++){
        if(arr[i] <= val){
            flag = 0;
            break;
        }
    }
    if(flag)return 0;

    for(int i=0;i<n;i++){
        if(arr[i] <= val){
            if(solve(val-arr[i], dp, arr) == 0){
                dp[val] = 1;
                return dp[val];
            }
        }
    }
    return 0;

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    cin>>n>>k;
    vector<int> dp(k+1, -1);
    dp[0] = 0;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    if(solve(k, dp, arr))cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    

    return 0;
}


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

namespace ABC071
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            var charList = new List<int>();
            for (int i = 0; i < input.Length; i++)
            {
                charList.Add(input[i]);
            }

            charList.Sort();
            int differentAmount = 0;
            char minWord = 'a';
            bool setMinWord = false;
            if (charList[0] != 'a')
            {
                setMinWord = true;
            }
            for (int i = 0; i < charList.Count - 1; i++)
            {
                if (charList[i] != charList[i + 1])
                {
                    differentAmount++;
                    if (charList[i + 1] >= charList[i] + 2 && !setMinWord)
                    {
                        minWord = (char)(charList[i] + 1);
                        setMinWord = true;
                    }
                }
            }

            if (differentAmount == 25)
            {
                Console.WriteLine("None");
            }
            else if (!setMinWord)
            {
                Console.WriteLine((char)(charList[charList.Count - 1] + 1));
            }
            else
            {
                Console.WriteLine(minWord);
            }
        }
    }
}

Measured memory_bytes: 12384
my $S = <>;
chomp $S;

my $count = 0;

my $num0 = ( () = $S =~ /(?:0)/g );
my $num1 = ( () = $S =~ /(?:1)/g );

my $min = $num0 > $num1 ? $num1 : $num0;
print $min * 2;

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >> a;
   
 vector<long long> L(87);
  
  L.at(0)=2;
  L.at(1)=1;
  
  for (int i=2; i<=86; i++) {
  L.at(i) = L.at(i-1)+L.at(i-2); 
  }
   
  cout << L.at(a) << endl; 
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<int> G[220000];
int ans[220000];
bool reached[220000];

void bfs(int ini) {
    queue<int> q;
    q.push(ini);
    while (q.size()) {
        int p = q.front();
        q.pop();
        for (int to : G[p]) {
            if (reached[to]) continue;
            reached[to] = true;
            ans[to] = p;
            q.push(to);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[b].push_back(a);
        G[a].push_back(b); 
    }
    bfs(0);
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 13476
N=int(input().strip())

def getMaxBit(x):
    if x==0:
        return None
    elif x>0:
        s=0
        i=0
        while s<x:
            s+=2**i
            i+=2
        return i-2
    else:
        s=0
        i=1
        while s>x:
            s-=2**i
            i+=2
        return i-2
ans=set()
while N!=0:
    a=getMaxBit(N)
    ans.add(a)
    N-=(-2)**a
S=""
if len(ans):
    for i in range(max(ans)+1):
        S=("1" if i in ans else "0")+S
else:
    S="0"
print(S)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  long long a;
  cin >> a;
  long long best = 0;
  for(long long i = 1; i <= sqrt(a); i++){
    if(a % i == 0){
      best = i;
    }
  }
  cout << (best + a/best - 2) << endl;
}

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

void solve(){
  int n, m; cin >> n >> m;
  long long int a[n];
  int b[n];
  map<long long int, int> mp;
  for(int i = 0; i < n; i++){
    long long int ai;
    int bi;
    cin >> ai >> bi;
    mp[ai] += bi;
  }
  long long int sum = 0, money = 0;
  for(auto iter = mp.begin(); iter != mp.end(); iter++){
    //cout << iter->first << " " << iter->second << endl;
    sum += iter->second;
    money += iter->first * iter->second;
    if(sum >= m){
      sum -= iter->second;
      money -= iter->first * iter->second;
      for(int i = 1; sum < m; i++){
        sum++;
        money += iter->first;
      }
      cout << money << endl;
      return;
    }
  }
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int f[200010];
int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}



int comb(int a, int b) {
	if (b > a - b) return comb(a, a - b);


	int ansMul = 1;
	int ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}

	int ans = ansMul * modpow(ansDiv, mod - 2) % mod;

	return ans;
}

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

	int N;
	cin >> N;
	vector<pii> V;
	REP(i, N) {
		int a;
		cin >> a;
		V.push_back(make_pair(a,0));
	}
	REP(i, N) {
		int a;
		cin >> a;
		V.push_back(make_pair(a, 1));
	}
	SORT(V);
	int acnt = 0, bcnt = 0, ans = 1;
	REP(i, V.size()) {
		if (V[i].second == 0) {
			if (bcnt > 0) {
				ans *= bcnt;
				bcnt--;
			}
			else {
				acnt++;
			}
		}
		else {
			if (acnt > 0) {
				ans *= acnt;
				acnt--;
			}
			else {
				bcnt++;
			}
		}
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 6256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int S,s,m,h;
	cin >> S;

	h = S / 3600;
	m = ( S - (h * 3600) ) / 60;
	s = ( S - (h * 3600) )% 60;

	cout << h << ":" << m << ":" << s << endl;


	return 0;
}


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

using namespace std;
long long n,d,ans=0;
long double x,y;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin>>x>>y;
        double len=sqrt(x*x+y*y);
        if(len<=d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
#include<string.h>
int main()
{
    int i,count,j=0,s1=0,k;
    char s[5];
    scanf("%s", s);
    for(i=j;i<3;i++)
    {
        count=0;
        for(k=i+1;k<4;k++)
        {
            if(s[i]==s[k])count=1;
        }
        j++;
        s1=s1+count;
    }
    if(s1==2)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int fix[100004];
int main ()
{
	int x, i=0, j=0;
	for(i=2; i<=100003; i++){
		if(fix[i]==1)
		continue;
		for(j=2*i; j<=100003; j+=i){
			fix[j]=1;
		}
	}
	cin>>x;
	while(true){
		if(fix[x]==0)
		break;
		x++;
	}
	cout<<x;
}

Measured memory_bytes: 640
use std::io;

fn main() {
    let mut S = String::new();
    io::stdin().read_line(&mut S);
    let vecS :Vec<&str> = S.trim().split_whitespace().collect();
    let A :usize = vecS[0].parse().unwrap();
    let B :usize = vecS[1].parse().unwrap();
    println!("{}",A*B)
}


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

int main() {
  int n, h, h2, a, ans = 0;
  cin >> n;
  h2 = 0;
  a = 0;
  rep(i,n)
  {
    cin >> h;
    if (h2 >= h) {
      a++;
    } else {
      ans = max(ans, a);
      a = 0;
    }
    h2 = h;
  }
  ans = max(ans, a);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = scan.nextInt();
		int x = scan.nextInt();

		int d = 0;
		int count = 1;

		while (count < (n + 1)) {
			d = d + scan.nextInt();
			if (d > x) {
				break;
			}
			count++;
		}

		System.out.println(count);

		scan.close();
	}

}

Measured memory_bytes: 23124
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args){

		String S,T;
		

		//////入力/////////
		Scanner stdIn = new Scanner(System.in);
		S = stdIn.next();
		T = stdIn.next();

		char[] S_char = S.toCharArray();
		char[] T_char = T.toCharArray();

		int ans = 0;

		for(int i = 0;i < 3;i++){
			if(S_char[i] == T_char[i]){
				ans++;
			}
		}

		System.out.println(ans);
		
		
	}
}

Measured memory_bytes: 22868
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

const int MAXN = (int)1e5 + 5;
int p[MAXN];
bool vis[MAXN];
vector<int> adjList[MAXN];
set<int> st;

void dfs(int u) {
    vis[u] = 1;
    st.insert(u);
    for (int v : adjList[u])
        if (!vis[v])
            dfs(v);

}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        adjList[u].push_back(v);
        adjList[v].push_back(u);
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs(i);
            for (auto it : st) {
//                cout << it << endl;
                if (st.find(p[it]) != st.end())
                    ++ans;
            }
            st.clear();
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;

LL gcd(LL m, LL n) // Greatest Common Diviser
{
  LL temp;
  if (m < n) {temp = n; n = m; m = temp;}
  if (n == 0) return m;
  while (m % n != 0)
    {
      temp = n;
      n = m % n;
      m = temp;
    }
  return n;
}

int main() {
  LL N;
  cin >> N;
  vector<LL> A(N+2);
  for (int i = 1; i <= N; i++)
    cin >> A[i];
  
  vector<LL> pre(N+2);
  for (int i = 1; i <= N; i++) {
    pre[i] = gcd(pre[i-1], A[i]);
  }
  
  vector<LL> suf(N+2);
  for (int i = N; i >= 1; i--) {
    suf[i] = gcd(suf[i+1], A[i]);
  }
  
  LL answer = 1;
  for (int i = 1; i <= N; i++) {
    answer = max(answer, gcd(pre[i-1], suf[i+1]));
  }
  cout << answer << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=3; i<=N; i=i+2){
    int numcg=0;
    for(int j=1; j<=i; j++){
      if(i%j==0) numcg++;
    }
    if(numcg==8) ans++;
  }
  cout << ans << endl;

}

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


long int lcm(long int a,long int b){
  return a/gcd(a,b)*b;
}


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,k;
  scanf("%d%d",&n,&k);

  printf("%d\n",!!(n%k));

  return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
int n,a[N],mi=inf,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)if(a[i+1]^a[i])mi=min(mi,a[i+1]-a[i]);
	for(int i=1;i<=n;i++)if(a[i]>=k&&(a[i]-k)%mi==0)return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int h, w;
char mp[300][300];
int num[301][301];
int dp[301][301];
int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> mp[i][j];
		}
	}
	ll ans = 0;
	rep(i, w - 1) {
		rep(j, h + 1) {
			rep(k, h + 1) {
				num[j][k] = 0;
			}
		}
		rep(j, h) {
			rep(k, h - j) {
				if (mp[j+k][i] == mp[k][i+1]) {
					num[j +k+ 1][k + 1] = num[j+k][k] + 1;
				}
				else {
					num[j +k+ 1][k + 1] = num[j+k][k];
				}
			}
		}
		rep(k, h) {
			rep(j, h - k) {
				if (mp[j][i] == mp[j + k][i + 1]) {
					num[j + 1][j+k + 1] = num[j][j+k] + 1;
				}
				else {
					num[j+1][j+k+1] = num[j][j+k];
				}
			}
		}
		rep(j, h + 1) {
			rep(k, h + 1) {
				dp[j][k] = mod;
			}
		}
		dp[h][h] = 0;
		per(j, h+1) {
			per(k, h+1) {
				if (j > 0) {
					dp[j - 1][k] = min(dp[j - 1][k], dp[j][k] + num[j][k]);				
				}
				if (k > 0) {
					dp[j][k - 1] = min(dp[j][k - 1], dp[j][k] + num[j][k]);
				}
			}
		}
		ans += dp[0][0];
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

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

   int ans = 0;
   for(int i=0; i<N-2; ++i){
      if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ++ans;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int N, W;
ll w[105];
ll v[105];

ll dp[105][100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> W;

  REP(i, N) cin >> w[i] >> v[i];

  REP(i, N) REP(j, W + 1) {
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    if(j + w[i] <= W) {
      dp[i + 1][j + w[i]] = max(dp[i][j] + v[i], dp[i + 1][j + w[i]]);
    }
  }

  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
ifChecked = [0 for _ in range(N)]
path = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    # ここのindexには気をつける
    path[A-1].append(B)
    path[B-1].append(A)

count = 0
for i in range(1, N+1):
    # このifCheckはLowestとして計上されているかどうかのもの
    my_height = H[i-1]
    ifHighest = True
    if path[i-1] == []:
        count += 1
        continue
    for to in path[i-1]:
        if my_height <= H[to-1]:
            ifHighest = False
    if ifHighest:
        count += 1

print(count)


Measured memory_bytes: 30256
import collections
N = int(input())
listA = []
listB = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
listB.append(c[0][0])
A = len(c)
for i in range(1,A):
    if max_number == c[i][1]:
        listB.append(str(c[i][0]))
    else:
        break
listB.sort()
for i in listB:
    print(i)

Measured memory_bytes: 45044
import sys
mod = 7 + 10 ** 9

def comb(n, r, fact, revfact):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod
def solve():
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    fact = [1] * (N * M + 1)
    for i in range(1, N * M + 1): fact[i] = (fact[i-1] * i) % mod
    revfact = [1] * ( N * M + 1)
    revfact[N * M] = pow(fact[N * M], mod-2, mod)
    for i in reversed(range(1, N * M)): revfact[i] = ((i + 1) * revfact[i+1]) % mod

    others = comb(N * M - 2, K - 2, fact, revfact)
    pair_type = 0
    for i in range(N): #縦の距離がi
        if i == 0:
            for j in range(1, M): #横の距離がj
                pair_type += (i + j) * (N - i) * (M - j) % mod
                pair_type %= mod
        else:
            for j in range(M):
                if j == 0: pair_type += (i + j) * (N - i) * (M - j) % mod
                else: pair_type += 2 * (i + j) * (N - i) * (M - j) % mod
                pair_type %= mod
    
    print(pair_type * others % mod)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder_754
{
    class Program
    {
        const int A = 753;

        static void Main(string[] args)
        {
            string input_S = Console.ReadLine();
            string input_num3;
            int result = 1000;
            int t_result = 0;
            for (int i =0; i<input_S.Length-2;i++)
            {
                //3つの数字を取得
                input_num3 = input_S.Substring(i, 3);
                t_result = Math.Abs(A - int.Parse(input_num3));
                if (t_result < result) result = t_result;

            }

            Console.WriteLine(result);
        }

    }
}


Measured memory_bytes: 13140
//B - A to Z String:
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    int ans, aux = 0;
    bool start = false;

    cin >> s;
    loop(i, 0, s.size()) {
        if(!start and s[i] == 'A') {
            start = true;
        }
        if(start) aux++;
        if(s[i] == 'Z') ans = aux;
    }
    cout << ans << '\n';
}

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

int main(void){
  int N;
  cin >> N;
  for(int i=1;; i++){
    int cnt = 0;
    int b = 1;
    for(int j=b;; j++){
      if(j > i) break;
      if(i % j == 0){
        cnt++;
        b = j;
      }
    }
    if(cnt == N){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 14 21:00:01 JST 2020
 **/

vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main() {
    int i;
    cin >> i;
    cout << a[i - 1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

int main(int argc, char const* argv[])
{
  int64_t N, Q;
  scanf("%ld %ld%*c", &N, &Q);

  char S[N + 1];
  fgets(S, N + 1, stdin);
  
  int64_t sum[N];
  memset(sum, 0, sizeof(int64_t) * N);
  for (int i = 0; i < N - 1; i++)
    sum[i + 1] = sum[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);

  int64_t l, r;
  for (int i = 0; i < Q; i++) {
    scanf("%ld %ld%*c", &l, &r);
    printf("%ld\n", sum[r - 1] - sum[l - 1]);
  }

  return 0;
}



Measured memory_bytes: 1664
from heapq import*
n=int(input())
A=[[]for _ in[0]*n]
for _ in[0]*n:
 e=list(map(int,input().split()))
 for i in range(e[1]):k=2*-~i;A[e[0]]+=[(e[k],e[k+1])]
H=[[0,0]]
d=[0]+[1e6]*n
c=[1]*n
while H:
 f=heappop(H)
 u=f[1]
 c[u]=0
 if d[u]>=f[0]:
  for s in A[u]:
   v=s[0]
   if c[v]and d[v]>d[u]+s[1]:
    d[v]=d[u]+s[1]
    heappush(H,[d[v],v])
for i in range(n):print(i,d[i])


Measured memory_bytes: 69044
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; int N; int count;
  cin >> N >> S;
  for (int i=0;i<1000;i++){
    int a[3]={i/100, (i/10)%10, i%10};
    // 100の桁、10の桁、1の桁
    int kakutei=0;
    for (int j=0; j<N;j++){
      if(S[j]==('0'+a[kakutei])){
        kakutei++;
      }
        //a[0]と同じ文字があれがa[1]を探しに行く
        if(kakutei==3){
          break;
        }
    }
        if(kakutei==3){
          count++;
        }
    
  }
    cout << count << endl;
  }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int n,i;
	//cout<< "1000*100 = " << 1000*100 << "\n" << "int_max = " << INT_MAX << "\n";
    while(cin >> n,n){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		int total = 0;
        //if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<climits>

#define MAX 100001

int n,k;
int a[MAX];

using namespace std;

void solve(){
	int ans=n+1;
	int l=0,r=0;
	map<int,int> m;
	while(1){
		while(r<n&&m.size()<k){
			if(a[r]<=k) m[a[r]]++;
			r++;
		}
		if(m.size()<k) break;
		ans=min(ans,r-l);
		if(a[l]<=k){
			if(m[a[l]]==1) m.erase(a[l]);
			else m[a[l]]--;
		}
		l++;
	}
	if(ans>n) ans=0;
	printf("%d\n",ans);
}

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

Measured memory_bytes: 8272