akhauriyash/Code-Regression huggingface dataset:
#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<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

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 int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    ll N, M, K, mod = 998244353;
    cin >> N >> M >> K;
    
    ll ans = 0;
    vector<ll> color_combs(N);
    color_combs[0] = M;
    FOR(i, 1, N-1) {
        color_combs[i] = color_combs[i-1] * (M-1);
        color_combs[i] %= mod;
    }

    REP(x, K+1) {
        ll tmp = 1;
        tmp *= COM(N-1, x);
        tmp *= color_combs[N-x-1];
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16724
N = int(input())
ans = []
while(True):
  m = N % 26
  if m == 0:
    m = 26
  ans.append(m)
  N -= m
  N = N // 26
  if N == 0:
    break

# print(ans)

ans.reverse()
print(''.join(map(lambda i: chr(96 + i), ans)))

Measured memory_bytes: 8912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int ans = inf;
	rep(i, (1 << (h - 1))) {
		bool flag = true;
		int cnt = 0;
		rep(j, h - 1) if ((i >> j) & 1) cnt++;
		vector<vector<int>> pl(cnt + 1, vector<int>());
		int idx = 0; pl[0].pb(0);
		rep(j, h - 1) {
			if ((i >> j) & 1) idx++;
			pl[idx].pb(j + 1);
		}
		vector<int> check(cnt + 1);
		int res = cnt;
		rep(j, w) {
			bool update = false;
			rep(x, cnt + 1) {
				int here = 0;
				for (int y : pl[x]) {
					if (s[y][j] == '1') here++;
				}
				if (here > k) flag = false;
				else if (check[x] + here > k) update = true;
			}
			rep(x, cnt + 1) {
				int here = 0;
				for (int y : pl[x]) {
					if (s[y][j] == '1') here++;
				}
				if (update) check[x] = here;
				else check[x] += here;
			}
			if (update) res++;
		}
		if (flag) chmin(ans, res);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N = int(input())
    Ss = [input() for _ in range(N)]

    num_ab = 0
    num_a = 0
    num_b = 0
    num_b_a = 0

    for line in Ss:

        num_ab += line.count('AB')
        if line[0] == 'B' and line[-1] == 'A':
            num_b_a += 1
        elif line[-1] == 'A':
            num_a += 1
        elif line[0] == 'B':
            num_b += 1
        
    res = num_ab
    if num_b_a > 0:
        res += num_b_a -1

        if num_a > 0:
            res += 1
            num_a -= 1

        if num_b > 0:
            res += 1
            num_b -= 1

    res += min(num_a, num_b)
    print(res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9676
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int K,S;
    cin >> K >> S;
    int cnt[3] = {};
    // i <= j <= kにしたい
    for(int i = 0;i <= K;i++){
        for(int j = i;j <= K;j++){
            int k = S - i - j;
            if(k < 0 || k > K || j > k)continue;
            if(i == j && j == k)cnt[0]++;
            else if(i != j && j != k && k != i)cnt[2]++;
            else cnt[1]++;
        }
    }
    cout << cnt[0] + cnt[1]*3 + cnt[2]*6 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, b;
    scanf("%d %d %d",&n, &a, &b);
    if(n == 1)
    {
        if(a == b)
            printf("1\n");
        else
            printf("0\n");
    }
    else
    {
        if(a > b)
            printf("0\n");
        else
            printf("%lld\n",(long long int)(b-a)*(n-2)+1);
    }
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
hash = {}
s1 = 0
s2 = N
loop do
    mid = (s1+s2)/2
    [s1, mid, s2].each do |s|
        next if hash[s%N]
        puts s%N
        $stdout.flush
        result = gets.chomp
        exit if result == 'Vacant'
        hash[s%N] = result
    end
    if (hash[s1%N] == hash[mid%N]) == ((s1-mid)%2 == 1)
        s2 = mid
    else
        s1 = mid
    end
end

Measured memory_bytes: 4172
#include<cstdio>
#include<map>
using namespace std;

map<long long,int> m1,m2;

int main(void)
{
    int n; scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        long long c; scanf("%lld",&c);
        ++m1[i+c];
        ++m2[i-c];
    }
    long long ans = 0;
    for(map<long long,int>::iterator it = m1.begin(); it != m1.end(); ++it){
        long long v = it->first;
        ans += (long long)m1[v]*m2[v];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 37608
H,W = map(int,input().split())
#l = sorted([int(input()) for i in range(N)],reverse=True)
def three(h,w):
    ans = h*w
    for i in range(h//3,h//3+2):
        A = w*i
        B = w*((h-i)//2)
        C = w*((h-i+1)//2)
        ans = min(ans,max(A,B,C)-min(A,B,C))
    return ans
def onetwo(h,w):
    ans = h*w
    for i in range(h//3,h//3+2):
        A = w*i
        B = (h-i)*(w//2)
        C = (h-i)*((w+1)//2)
        ans = min(ans,max(A,B,C)-min(A,B,C))
    return ans
print(min(three(H,W),three(W,H),onetwo(H,W),onetwo(W,H)))

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

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

		if(a[i - 1] <= a[i])
			continue;
		if(a[i - 1] - 1 > a[i]) {
			cout << "No" << endl;
			return 0;
		}
		else {
			a[i - 1]--;
		}

	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  if ((a[0]==a[1] && a[1]!=a[2]) || (a[0]!=a[1] && a[1]==a[2])) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
num = list(input())
n = len(num) - 1

for i in range(2**n):
    temp = [0]*(len(num)+n)
    lst = ["-"]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    temp[::2] = num
    temp[1::2] = lst
    wa = eval("".join(temp[:]))
    if wa == 7:
        print("".join(temp[:]) + "=7")
        exit()

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

typedef pair<int,int> pii;

int solve(){
  int n,m;
  scanf("%d",&m);
  if(m==0) return 0;
  pii seiza[200];
  scanf("%d %d",&seiza[0].first,&seiza[0].second);
  for(int i=1;i<m;i++){
    scanf("%d %d",&seiza[i].first,&seiza[i].second);
    seiza[i].first-=seiza[0].first;
    seiza[i].second-=seiza[0].second;
  }
  scanf("%d",&n);
  pii stars[1000];
  set<pii> sky;
  for(int i=0;i<n;i++){
    scanf("%d %d",&stars[i].first,&stars[i].second);
    sky.insert(stars[i]);
  }
  for(int i=0;i<n;i++){
    bool flag = true;
    for(int j=1;j<m;j++){
      int x = stars[i].first+seiza[j].first;
      int y = stars[i].second+seiza[j].second;
      if(sky.find(pii(x,y))==sky.end()){
        flag = false;
        break;
      }
    }
    if(flag){
      printf("%d %d\n",stars[i].first-seiza[0].first,stars[i].second-seiza[0].second);
      break;
    }
  }
  return 1;
}

int main(){
  while(true) if(!solve()) return 0;
}

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

map<char, int> si;
map<char, map<int,int> > ni;

int dfs(string str){
    int ret = 0;
    if('0' <= str[0] && str[0] <= '9'){
        rep(i,str.size()){
            ret = ret*10+str[i]-'0';
        }
        return ret;
    }
    char x = str[0];
    int y = dfs(str.substr(2,str.size()-3));
    if(si.count(x) == 0) return -1;
    if(ni.count(x) == 0) return -1;
    if(ni[x].count(y) == 0) return -1;
    return ni[x][y];
}

void solve(string str){
    si.clear();
    ni.clear();
    int ans = 0;
    bool end = false;
    do{
        ans++;
        if(str == ".") break;
        if(end) continue;
        bool eq = false;
        rep(i,str.size()) if(str[i] == '=') eq = true;
        if(!eq){
            int num = 0;
            for(int i = 2;;i++){
                if('0' > str[i] || str[i] > '9') break;
                num = num*10+str[i]-'0';
            }
            si[str[0]] = num;
        } else{
            char x = str[0];
            int xpos;
            int bla = 0;
            string s;
            int i;
            for(i = 2;; i++){
                if(str[i] == '[') bla++;
                if(str[i] == ']') bla--;
                if(bla < 0){
                    xpos = dfs(s);
                    break;
                }
                s.push_back(str[i]);
            }
            int val = dfs(str.substr(i+2));
            if(xpos == -1 || val == -1){
                cout << ans << endl;
                end = true;
                continue;
            }
            if(xpos >= si[x]){
                cout << ans << endl;
                end = true;
                continue;
            }
            ni[x][xpos] = val;
        }
    } while(cin >> str);
    if(!end) cout << 0 << endl;
}

int main(){
    string str;
    while(cin >> str){
        if(str == ".") break;
        solve(str);
    }
}

Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
   	int n;
   	cin >> n;
   	int sum = 0;
   	int maxx = 0;
   	while (n--) {
   		int x;
		cin >> x;
		sum += x;
		maxx = max(maxx, x);	
	}
   	if (sum-maxx > maxx) {
   		cout << "Yes";
	}
	else {
		cout << "No";
	}
   	
	return 0;
}


Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in A:
    X=max(X,i)
for i in B:
    Y=min(Y,i)
if(X<Y):
    print("No War")
else:
    print("War")
    

Measured memory_bytes: 2940
<?php
class Line {
    protected $lineData;
    protected $pointer;
    public function __construct(array $line)
    {
        $this->lineData = $line;
        $this->pointer = 0;
        $this->count = count($line);
    }

    public function next()
    {
        if ($this->count > $this->pointer) {
            return $this->lineData[$this->pointer++];
        }
        return false;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }
}

class IOW {
    /**
     * @return Line
     */
    public static function nl()
    {
        $str = trim(fgets(STDIN));
        return new Line(explode(' ', $str));
    }

    public static function out($data)
    {
        echo $data . PHP_EOL;
    }
}

$count = (int)IOW::nl()->next();
$tree = [];

for ($i = 1; $i < $count; $i++) {
    $line = IOW::nl();
    $u = $line->nextInt();
    $v = $line->nextInt();
    $mod = $line->nextInt() % 2;
    $tree[$u][$v] = $mod;
    $tree[$v][$u] = $mod;
}

$ans[1] = 0;
$queue = [1];

$i = 0;
while (list(, $v) = each($queue)) {
    foreach ($tree[$v] as $u => $w) {
        if (isset($ans[$u])) {
            continue;
        }
        $ans[$u] = ($ans[$v] + $w) % 2;
        $queue[] = $u;
    }
}

ksort($ans);
foreach ($ans as $color) {
    IOW::out($color);
}

Measured memory_bytes: 87156
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false;}
int lcs_len(string a, string b){
	vector<vector<int>> dp(a.size()+1, vector<int>(b.size()+1, 0));
	REP(i,a.size()){
		REP(j,b.size()){
			if(a[i-1] == b[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			}else{
				chmax(dp[i][j], dp[i-1][j]);
				chmax(dp[i][j], dp[i][j-1]);
			}
		}
	}
	return dp[a.size()][b.size()];
}

int main(){
	int Q;
	cin >> Q;
	vector<pair<string, string>> input(Q);
	rep(i,Q)cin >> input[i].first >> input[i].second;
	rep(i,Q){
		cout << lcs_len(input[i].first, input[i].second) << endl;
	}
	return 0;
}



Measured memory_bytes: 6916
six=[6**i for i in range(1,7)][::-1]
nine=[9**i for i in range(1,6)][::-1]
N=int(input())

ans=[]
def find(n,a):
    if n<6:
        ans.append(n+a)
        return
    for s in six:
        if s<=n:
            find(n-s,a+1)
            break
    for s in nine:
        if s<=n:
            find(n-s,a+1)
            break
find(N,0)
print(min(ans))

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

int main() {
	int n;
	cin >> n;
	vector<ll> march(5);
	rep(i, n) {
		string s;
		cin >> s;
		switch(s[0]) {
			case 'M':
				march[0]++;
			break;
			case 'A':
				march[1]++;
			break;
			case 'R':
				march[2]++;
			break;
			case 'C':
				march[3]++;
			break;
			case 'H':
				march[4]++;
			break;
		}
	}
	ll ans = 0;
	rep(i, 3) {
		for(int j = i+1; j < 5-1; j++) {
			for(int k = j+1; k < 5; k++) {
				ans += march[i] * march[j] * march[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

string s[200000];
int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b != c) {
		cout << "Yes" << endl;
	}
	else if (b == c && c!= a) {
		cout << "Yes" << endl;
	}
	else if (c == a && a != b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

	//B
	/*int n;
	int a[100];
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0) {

			}
			else if (a[i] % 5 == 0) {

			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
	*/
	//C
	/*int i, n;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	//cout<< endl << "sort" << endl;
	//for (i = 0; i < n; i++) {
	//	cout << s[i] << endl;
	//}
	//cout << "sort" << endl << endl;
	string t;
	t = s[0];
	int counter = 1, maxc = 0;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter > maxc)maxc = counter;
			counter = 1;
		}

	}
	if (counter > maxc)maxc = counter;

	t = s[0]; counter = 1;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter  == maxc)cout << s[i-1] << endl;
			counter = 1;
		}

	}
	if (counter == maxc) {
		cout << s[n - 1] << endl;
	}
	return 0;*/

	//D
	/*int n,k;
	cin >> n >> k;
	int i;
	long long int a[200000];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}*/
	//E
	/*string s;
	cin >> s;
	int i, j;
	int flag = 0;
	long long int sum = 0;
	for (i = s.size() - 1; i >= 0; i--) {
		j = s[i] - '0' + flag;
		if (j == 10) {
			j = 0;
			flag = 1;
		}
		else {
			flag = 0;
		}
		if (j <= 5) {
			sum = sum + j;
		}
		else {
			sum = sum + 10 - j;
			flag = 1;
		}
	}
	cout << sum + flag << endl;
	return 0;*/


}

Measured memory_bytes: 9772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll dp[60][2];
    rep(i,n) {
        cin>>a[i];
        a[i];
    }
    rep(j,60) rep(i,2) dp[j][i] = 0;
    rep(i,n) rep(j,60) {
        ll p = 1;
        rep(k,j) {
            p *= 2;
        }
        if(a[i] & p) dp[j][1]++;
        else dp[j][0]++;
    }
    ll ans = 0;
    rep(j,60) {
        ll p = 1;
        rep(i,j) {
            p *= 2;
            p %= mod;
        }
        ans =  ans + (dp[j][0] )  * (dp[j][1]) %mod * p % mod;
        ans %= mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
N, W = map(int, input().split())
A = []
V = []
for i in range(N):
  a, v = map(int, input().split())
  A.append(a)
  V.append(v)

dp = [0] * (W+1)
for i in range(N)[::-1]:
  a = dp[:]
  for w in range(W+1):
    if A[i] <= w and a[w] < dp[w-A[i]] + V[i]:
      a[w] = dp[w-A[i]] + V[i]
  dp = a

print(dp[W])

Measured memory_bytes: 66580
#include <iostream>

using namespace std;

int main(){
  int r, c, sum=0, m[101][101];

  cin >> r >> c;
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> m[i][j];
      sum += m[i][j];
    }
    m[i][c] = sum;
    sum = 0;
  }
  for(int i = 0; i < c+1; i++){
    for(int j = 0; j < r; j++){
      sum += m[j][i];
    }
    m[r][i] = sum;
    sum = 0;
  }

  for(int i = 0; i <= r; i++){
    for(int j = 0; j <= c; j++){
      cout << m[i][j];
      if(j != c){ cout << " "; }
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
int f(const int n)
{

	switch (n & 3)
	{
	case 0: return n;
	case 1: return 1;
	case 2: return n + 1;
	case 3: return 0;
	}
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int A, B; cin >> A >> B;
	if (A == 0)A++;
	int x = f(B);
	int y = f(A - 1);
	cout << (x^y) << endl;

	return 0;
}


Measured memory_bytes: 256
/// same problem as Knapsack 1, but now W can be 1e9 max.
#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int maxV = 1e3;
const ll inf = 1e18l;

void min_self(ll &a, ll b){
    a = min(a, b);
}

void solve(){
    ll n, W;
    cin>>n>>W;

    /// dp[i] = the min. total weight required with total value exactly i
    vector<ll> weight(n), val(n);
    fr(i, n) cin>>weight[i]>>val[i];
    ll sum = 0ll;
    for(auto x: val) sum += x;

    vector<ll> dp(sum + 1ll, inf);
    dp[0] = 0ll;    /// not taking any element, we can get val 1

    fr(item, n){
        for(ll value_already = sum - val[item]; value_already >= 0; value_already--){
            min_self(dp[value_already + val[item]], dp[value_already] + weight[item]);
        }
    }

    ll ans = 0;
    for(ll v = 0ll; v <= sum; v++){
        if(dp[v] <= W){
            ans = v;
        }
    }

    cout<<ans;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

using namespace std;

#define INF 1e9

class Fraction{
public:;
  double numerator,denominator;
  double div();
};

double Fraction::div(){
  return numerator/denominator;
}

ostream &operator << (ostream &os,const Fraction &f){
  os << f.numerator << '/' << f.denominator;
  return os;
}

int main(){
  double p;
  int n;
  while(cin >> p >> n, p){
    p = sqrt(p);
    Fraction a = (Fraction){-1,1};
    Fraction b = (Fraction){INF,1};
    for(int den = 1 ; den <= n ; den++){
      int l = 0, r = n+1;
      while(l < r){
        double mid = (l + r) / 2;
        if(mid < p*den){
          if(mid/den > a.div()){
            a = (Fraction){mid,den};
          }
          l = mid+1;
        }else{
          r = mid;
        }
      }
      l = 0, r = n+1;
      while(l < r){
        double mid = (l + r) / 2;
        if(mid > p*den){
          if(mid/den < b.div()){
            b = (Fraction){mid,den};
          }
          r = mid;
        }else{
          l = mid+1;
        }
      }
    }
    cout << b << " " << a << endl;
  }
  return 0;
}

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

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  
  if ( a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
    cout << 0 << endl;
  }else{
    cout << min( a * b, min( a * c, b * c ) ) << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 15 + 5;
const int ALL = (1<<15) + 5;
const int inf = 0x3f3f3f3f;

inline void chk_max(int &a,int b){ if(a<b) a=b;}

int lb[ALL];
#define bit(x,i) (((x)>>(i))&1)
#define lowbit(x) ((x)&-(x))

int a[MAXN][MAXN];
int cost[ALL],f[ALL][MAXN],g[ALL][MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; ++i)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		a[u][v]=a[v][u]=w;
	}
	
	int all = (1<<n)-1;
	
	for(int mask=0; mask<=all; ++mask)
	{
		for(int i=1; i<=n; ++i) if(bit(mask,i-1))
			for(int j=1; j<i; ++j) if(bit(mask,j-1))
				cost[mask]+=a[i][j];
	}
	
	for(int mask=0; mask<=all; ++mask)
	{
		for(int i=1; i<=n; ++i) f[mask][i]=g[mask][i]=-inf;
		if(mask&1) f[mask][1]=cost[mask];
	}
	g[1][1]=0;
	
	int ans=0;
	for(int mask=1; mask<=all; mask+=2)
	{
		for(int i=1; i<=n; ++i) if(bit(mask,i-1))
		{
			if(g[mask][i]!=-inf)
			{
				for(int mask2=all^mask; ; mask2=(mask2-1)&(all^mask))
				{
					chk_max(f[mask|mask2][i], g[mask][i]+cost[mask2|(1<<(i-1))]);
					if(!mask2) break;
				}	
			}
			if(f[mask][i]!=-inf)
			{
				for(int j=1; j<=n; ++j)
					if(!bit(mask,j-1) && a[i][j]>0)
					{
						chk_max(g[mask|(1<<(j-1))][j], f[mask][i]+a[i][j]);
						if((mask|(1<<(j-1)))==3 && j==1) printf("qwq\n");
					}
						
			}
		}
		if(bit(mask,n-1))
			chk_max(ans,f[mask][n]);
	}
	
	printf("%d",cost[all]-ans);
	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 60;
const int INF = 0x7FFFFFFF/2;
typedef pair<int, int> state;
bool f[N][N][N][N];
int n, m, k, sx, sy, ex, ey;

int calc_dist()
{
	static int dist[N][N];
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			dist[i][j] = INF;
	dist[sx][sy] = 0;
	queue<state> q;
	q.push(make_pair(sx, sy));
	while (!q.empty()) {
		state now = q.front();
		int x = now.first, y = now.second;
		if (x - 1 >= 0 && dist[x - 1][y] == INF) {
			if (f[x][y][x][y + 1]) {
				dist[x - 1][y] = dist[x][y] + 1;
				q.push(make_pair(x - 1, y));
				if (x - 1 == ex && y == ey) break;
			}
		}
		if (x + 1 < n && dist[x + 1][y] == INF) {
			if (f[x + 1][y][x + 1][y + 1]) {
				dist[x + 1][y] = dist[x][y] + 1;
				q.push(make_pair(x + 1, y));
				if (x + 1 == ex && y == ey) break;
			}
		}
		if (y - 1 >= 0 && dist[x][y - 1] == INF) {
			if (f[x][y][x + 1][y]) {
				dist[x][y - 1] = dist[x][y] + 1;
				q.push(make_pair(x, y -1));
				if (x == ex && y - 1 == ey) break;
			}
		}
		if (y + 1 < m && dist[x][y + 1] == INF) {
			if (f[x][y + 1][x + 1][y + 1]) {
				dist[x][y + 1] = dist[x][y] + 1;
				q.push(make_pair(x, y + 1));
				if (x == ex && y + 1 == ey) break;
			}
		}
		q.pop();
	}
	return dist[ex][ey];
}

int main()
{
	ios::sync_with_stdio(false);
	memset(f, true, sizeof(f));
	cin >> n >> m >> k;
	for (int i = 1; i <= k; ++i) {
		int x1, x2, y1, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (x1 > x2) swap(x1, x2);
		if (y1 > y2) swap(y1, y2);
		if (y1 == y2) {
			for (int x = x1; x < x2; ++x) {
				f[x][y1][x + 1][y1] = false;
				f[x + 1][y1][x][y1] = false;
			}
		} else if (x1 == x2) {
			for (int y = y1; y < y2; ++y) {
				f[x1][y][x1][y + 1] = false;
				f[x1][y + 1][x1][y] = false;
			}
		}

	}
	cin >> sx >> sy;
	cin >> ex >> ey;
	int ori_dist = calc_dist();
	int next_dist, ans = -1;
	

	for (int x = 0; x < n; ++x)
		for (int y = 0; y < m; ++y) {
			if (f[x][y][x][y + 1]) {
				f[x][y][x][y + 1] = false;
				next_dist = calc_dist();
				if (next_dist != INF) {
					ans = max(ans, next_dist);
				}
				f[x][y][x][y + 1] = true;
			}
			if (f[x][y][x + 1][y]) {
				f[x][y][x + 1][y] = false;
				next_dist = calc_dist();
				if (next_dist != INF) {
					ans = max(ans, next_dist);
				}
				f[x][y][x + 1][y] = true;
			}
		}
	if (ans == -1)
		cout << 0 << endl;
	else {
		cout << ans - ori_dist << endl;
	}
	return 0;
}

Measured memory_bytes: 13892
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pb(a) push_back(a)
#define in(a) insert(a)
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;


void Main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  int a[n][m];
  memset(a,-1,sizeof(a));
  rep(i,n) {
    rep(j,m) {
      if(s[i][j]=='c') a[i][j]=0;
      else if(j && a[i][j-1]>=0) a[i][j]=a[i][j-1]+1;
    }
  }
  rep(i,n) PR(a[i],m);
}

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


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n=0,i;
    cin>>a>>b;

    vector<int>v;
    for(i=0;i<a;i++){
    cin>>c;
    v.push_back(c);
    }
    sort(v.rbegin(),v.rend());
    for(i=0;i<b;i++){
        n+=v[i];
    }
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l long long
const l e=1e9+7;
int main()
{
  int n,m,d;
  cin>>n>>m;
  int a[n+1]={0};
  for(int i=0;i<m;i++)
  {
    cin>>d;
    a[d]=1;
  }
  l dp[n+1]={0};
  dp[0]=1;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<=min(n,i+2);j++)
    {
      if(a[j]==0)
      {
        dp[j]+=dp[i];
        dp[j]%=e;
      }
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1408
n = int(input())
dp = [[0] * 3 for i in range(n+1)]
for i in range(1,n+1):
  a,b,c = map(int,input().split())
  dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[-1]))

Measured memory_bytes: 24180
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int n,a,b;
    cin >> n ;

    if(n==1){
        cout << "Hello World" << endl;
        return 0;
    }

    cin >> a >> b;
    cout << a+b << endl;
}

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

int main()
{
    int N, M, C;

    cin >> N >> M >> C;

    int B[M + 1];
    int A[N + 1][M + 1];

    for (int i = 1; i <= M; i++)
    {
        cin >> B[i];
    }

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= M; j++)
        {
            cin >> A[i][j];
        }
    }

    int source;
    int count = 0;
    for (int i = 1; i <= N; i++)
    {
        source = C;
        for (int j = 1; j <= M; j++)
        {
            source = source + A[i][j] * B[j];
        }
        if (source > 0)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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;}

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n, k, d;
  set<int> all;

  cin >> n >> k;

  rep(i, n) {
    all.insert(i+1);
  }

  rep(i, k) {
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      all.erase(a);
    }
  }

  cout << all.size();
  return 0;
};

Measured memory_bytes: 3632
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}




Measured memory_bytes: 2688
k,n=map(int, raw_input().split())
houses=map(int, raw_input().split())
maxd=0
l=-1
r=-1
for i in xrange(1, n):
    maxd=max(maxd, houses[i]-houses[i-1])

maxd=max(maxd, k-houses[-1]+houses[0])
# print maxd
print k-maxd

Measured memory_bytes: 51872
#include <iostream>
 
int kk[100000];
 
int main(){

while(1){

int s=0;
int n,k;
std::cin>>n>>k;
 
if(n==0&&k==0)
break;

for(int i=0;i<k;i++){
std::cin>>kk[i];
s+=kk[i];
}
 
int st=s;
 
for(int i=k;i<n;i++){
std::cin>>kk[i];
s+=kk[i]-kk[i-k];
if(s>st)
st=s;
}
 
std::cout<<st<<std::endl;

}

}
 

Measured memory_bytes: 1548
#include <stdio.h>

int main()
{
  int H,W;
  scanf("%d %d", &H, &W);
  char c[100][100];
  for(int i=0;i<H;i++){
    scanf("%s", &c[i]);
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      printf("%c", c[i][j]);
    }
    putchar('\n');
    for(int j=0;j<W;j++){
      printf("%c", c[i][j]);
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;


typedef long long lint, ll;
typedef long double ldouble, ld;

#ifdef LOCAL
	#define dbg(expr) cerr << "[" << __LINE__ << "] " << #expr << " = " << (expr) << '\n';
#else
	#define dbg(expr) (void) 0;
#endif


const lint inf = 1e18;


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

    int n;
    cin >> n;
    vector<double> t(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        t[i] *= 2;
    }
    for (int i = 0; i < n; i++)
        cin >> v[i];
    double sum = 0;
    for (auto e : t)
        sum += e;
    double cur = 0;
    double dist = 0;
    for (int i = 1; i <= sum; i++) {
        double bound = (sum - i) * 0.5;
        double acc = 0;
        for (int j = 0; j < n; j++) {
            auto e = t[j];
            if (acc <= i && i <= acc + e)
                bound = min(bound, v[j]);
            if (acc >= i)
                bound = min(bound, v[j] + (acc - i) * 0.5);
            acc += e;
        }
        double new_cur = min(bound, cur + 0.5);
        dist += (double)(cur + new_cur) / 2;
        cur = new_cur;
    }
    cout << fixed << setprecision(8);
    cout << dist / 2 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final long[][] dp = new long[n + 1][4];// 0 -> ok, 1 -> 0-included, 2 -> 9-included, 3 -> ng
        dp[1][0] = 0;
        dp[1][1] = 1;
        dp[1][2] = 1;
        dp[1][3] = 8;
        for (int i = 2; i <= n; i++) {
            dp[i][0] = (dp[i - 1][0] * 10 + dp[i - 1][1] + dp[i - 1][2]) % MOD;
            dp[i][1] = (dp[i - 1][1] * 9 + dp[i - 1][3]) % MOD;
            dp[i][2] = (dp[i - 1][2] * 9 + dp[i - 1][3]) % MOD;
            dp[i][3] = dp[i - 1][3] * 8 % MOD;
        }

        System.out.println(dp[n][0]);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 99660
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register int
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		re x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {re a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		re y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {re l=strlen(s);for(re i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
#define pb push_back
const int N=2e5+5;
int n,m,d[N],fa[N],tot;ll ans;
struct did{int u,v;ll w;in bool operator<(did a)const{return w<a.w;}}e[N<<3];
int getfa(re x) {return fa[x]^x?fa[x]=getfa(fa[x]):x;}
in int merge(re x,re y)
{
	re u=getfa(x),v=getfa(y);
	return u^v?fa[u]=v,1:0;
}
int main()
{
	n=read(),m=read();memset(d+1,63,4*n);
	for(re i=1,u,v,w;i<=m;i++)
	{
		u=read()+1,v=read()+1,w=read();e[++tot]={u,v,w};
		d[u]=min(d[u],w+1);d[v]=min(d[v],w+2);
	}
	for(re i=1;i<=n;i++) d[i%n+1]=min(d[i%n+1],d[i]+2);
	for(re i=1;i<=n;i++) d[i%n+1]=min(d[i%n+1],d[i]+2);
	for(re i=1;i<=n;i++) e[++tot]={i,i%n+1,d[i]},fa[i]=i;
	sort(e+1,e+tot+1,[](did a,did b){return a.w<b.w;});
	for(re i=1,cnt=n;i<=tot&&cnt>1;i++) if(merge(e[i].u,e[i].v)) cnt--,ans+=e[i].w;
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

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

int main(){
   int count=0,x=0;
   string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
       if(s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C'){
           count=0;
       }
        else {
            count++;
    }
    x=max(count,x);
   }
   cout<<x<<endl;
   return 0;
}

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

int main(){
char a[6];
  int flag = 0;
  for(int S = 0; S < 6;S++){
  cin >> a[S];
  }
  
  if(a[0] != a[5]){
  flag = 1;
  }
  
  if(a[1] != a[4]){
  flag = 1;
  }
  
  if(a[2] != a[3]){
  flag = 1;
  }
  
  
  if(flag == 1){
  cout << "NO" << endl;
  }
  else {
  cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main()
{
    char str[100005];
    int num[30];
    memset (num,0,sizeof(num));
    scanf("%s",str);
    int flag=0;
    for (int i=0;i<strlen(str);i++)
    {
        num[str[i]-'a'+1]++;
    }

    for (int i=1;i<=26;i++)
    {
       // cout << i << endl;
        if (num[i]==0)
        {
            printf("%c\n",i+97-1);
            flag=1;
            break;
        }
    }
    if (flag==0)
        printf("None\n");

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();

		int ans = 0;
		int iN = 0;
		for(int i=0; i<N.length(); i++) {
			iN = Integer.parseInt(String.valueOf(N.charAt(i)));
			ans = (ans+ iN)%9;
		}

		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 51220
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = max(max(a, b), c) - min(min(a, b), c);
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    int n ; cin >> n ;

    vi v ( n + 1 ) ;
    for ( int i=1 ; i < n + 1 ; i++ )
    {
        int temp ;
        cin >> temp ;

        v[temp] = i ;
    }

    for ( int i=1 ; i < n + 1 ; i++ ) cout << v[i] << " " ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 1152