akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n;
    cin>>n;
    n=n%1000;
    n=1000-n;
    n=n%1000;
    cout<<n;

    return (0);
}


Measured memory_bytes: 3652
n = gets.strip.to_i
abc = (n-1).times.map { gets.strip.split.map(&:to_i) }
q, k = gets.strip.split.map(&:to_i)
xy = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << [b, c]
  graph[b] << [a, c]
end

q = [[k,0]]
dist = [10**15] * (n+1)
dist[k] = 0
until q.empty?
  from, past_cost = q.shift
  next if dist[from] < past_cost

  graph[from].each do |to, cost|
    current_cost = dist[from] + cost
    next if dist[to] < current_cost
    dist[to] = current_cost
    q.push([to, current_cost])
  end
end

xy.each do |x, y|
  p dist[x] + dist[y]
end


Measured memory_bytes: 58972
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int L = -INF, R = INF;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    L = max(L, x);
    R = min(R, y);
  }
  int ret = max(0, R - L + 1);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	if resolve() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func resolve() bool {
	x := scanInt(sc)
	return x >= 30
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
N, K = list(map(int, input().split()))

child_r = 1
parent_r = 1
child_b = 1
parent_b = 1
for i in range(1, K+1):
    child_r *= N - K + 1 - (i - 1)
    parent_r *= i
    if(i > 1):
        child_b *= K - 1 - (i - 2)
        parent_b *= i - 1
    print((child_r // parent_r *  child_b // parent_b) % (10**9 + 7))

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

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

using namespace std;

int matrix_rank(vector<unsigned long long> A){
	int n=A.size(),r=0;
	rep(i,64){
		int piv=-1;
		for(int j=r;j<n;j++) if(A[j]>>i&1) {
			piv=j;
			break;
		}
		if(piv==-1) continue;

		for(int j=r;j<n;j++) if(j!=piv && A[j]>>i&1) {
			A[j]^=A[piv];
		}
		swap(A[r],A[piv]);
		r++;
	}
	return r;
}

void solve(){
	int n; cin>>n;
	vector<unsigned long long> a(n);
	rep(i,n) cin>>a[i];
	string s; cin>>s;

	vector<unsigned long long> B;
	for(int i=n-1;i>=0;i--){
		auto v=a[i];
		for(auto b:B) v=min(v,v^b);
		if(v!=0){
			if(s[i]=='1'){
				puts("1");
				return;
			}
			B.emplace_back(v);
		}
	}
	puts("0");
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}


Measured memory_bytes: 3692
O=list(map(int, input().split()))
N = O[0]
K = O[1]
L = []
for i in range(N):
    L.append(1)
    

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(len(A)):
        L[A[j]-1]= 0

sumx = 0

for i in range(N):
    sumx+=L[i]
    
print(sumx)


Measured memory_bytes: 9196
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i = 0; i < n; i++){
			String s1 = in.next();
			String s2 = in.next();
			int a = getValue(s1);
			int b = getValue(s2);
			System.out.println(getMCXI(a+b));
		}
		in.close();
	}
	int getValue(String a){
		int num = 0;
		int x = 1;
		for(int i = 0; i< a.length(); i++){
			
			switch (a.charAt(i)){
			case 'm':
				num += x * 1000;
				x = 1;
				break;
			case 'c':
				num += x * 100;
				x = 1;
				break;
			case 'x':
				num += x * 10;
				x = 1;
				break;
			case 'i':
				num += x;
				x = 1;
				break;
			default:
				x = Integer.parseInt("" + a.charAt(i));
			}
		}
		return num;
	}
	String getMCXI(int a){
		String s = "";
		s += addMCXI(a,1000,"m");
		a -= a/1000 * 1000;
		s += addMCXI(a,100,"c");
		a -= a/100 * 100;
		s += addMCXI(a,10,"x");
		a -= a/10 * 10;
		s += addMCXI(a,1,"i");
		return s;
	}
	String addMCXI(int a, int b, String x){
		String s = "";
		if(a/b > 1){
			s += a/b + x;
		}else if(a/b == 1){
			s += x;
		}
		return s;
	}

}

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

typedef long long ll;
typedef pair<int,int> ii;

int gcd(int a, int b) {
	if(!b) return a;
	return gcd(b,a%b);
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout << lcm(n,2) << endl;
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> AC(N + 1);
    vector<long long> WA(N + 1);
    for (int i = 0; i < M; i++) {
        int p;
        string S;
        cin >> p >> S;
        if (S == "WA") {
            if (!AC[p]) WA[p]++;
        } else {
            AC[p] = true;
        }
    }

    long long cnt_WA = 0, cnt_AC = 0;
    for (int i = 1; i <= N; i++) {
        if (AC[i]) {
            cnt_AC++;
            cnt_WA += WA[i];
        }
    }

    cout << cnt_AC << " " << cnt_WA << endl;
    return 0;
}

Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

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

	int a,p;
	cin >> a >> p;
	
	int all = 3*a+p;
	
	cout << int(all/2) << endl;
	
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
int fl[40];
char ch;


int main() {

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		vl[0].push_back(A[i]);
	}

	sort(vl[0].begin(), vl[0].end());
	reverse(vl[0].begin(), vl[0].end());

	a = 1;
	b = 0;
	for (int i = 1; i < N; i++) {
		if (vl[0][i] == vl[0][i - 1]) {
			a *= vl[0][i];
			b++;
			i++;
			if (b >= 2) {
				break;
			}
		}
	}

	if (b < 2) {
		a = 0;
	}

	cout << a << endl;

	return 0;

}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//幅優先探索
//children:各頂点の子の配列
//start:始点
//visit:1:訪問済み
//task:訪問予定
//pushしたマスは訪問済みにすること
void bfs(ll n, vector<vll> &children, vll &cnt, ll start) {
  vll visit(n, 0);
  queue<ll> task;
  task.push(start);
  visit.at(0) = 1;
  ll depth = 0;
  while (task.size() > 0) {
    ll sz = task.size();
    for (ll i = 0; i < sz; i++) {
      for (ll j = 0; j < children.at(task.front() - 1).size(); j++) {
        if (visit.at(children.at(task.front() - 1).at(j) - 1) == 0) {
          cnt.at(children.at(task.front() - 1).at(j) - 1) += cnt.at(task.front() - 1);
          task.push(children.at(task.front() - 1).at(j));
          visit.at(children.at(task.front() - 1).at(j) - 1) = 1;
        }
      }
      task.pop();
    }
    depth++;
  }
  return;
}

int main() {
  ll n, q;
  cin >> n >> q;
  vector<ll> a(n - 1), b(n - 1), p(q), x(q), cnt(n);
  for (ll i = 0; i < n - 1; i++) cin >> a.at(i) >> b.at(i);
  for (ll i = 0; i < q; i++) cin >> p.at(i) >> x.at(i);
  for (ll i = 0; i < q; i++) cnt.at(p.at(i) - 1) += x.at(i);
  vector<vector<ll>> children(n);
  for (int i = 0; i < n - 1; i++) {
    children.at(a.at(i) - 1).push_back(b.at(i));
    children.at(b.at(i) - 1).push_back(a.at(i));
  }
  bfs(n, children, cnt, 1);
  for (ll i = 0; i < n - 1; i++) cout << cnt.at(i) << " ";
  cout << cnt.at(n - 1) << endl;
}

Measured memory_bytes: 24148
import itertools

a=[]

for i in range(3):
    a.append(list(map(int,input().split())))

temp=[]
temp.append((a[0][0],a[0][1],a[0][2]))
temp.append((a[1][0],a[1][1],a[1][2]))
temp.append((a[2][0],a[2][1],a[2][2]))
temp.append((a[0][0],a[1][0],a[2][0]))
temp.append((a[0][1],a[1][1],a[2][1]))
temp.append((a[0][2],a[1][2],a[2][2]))
temp.append((a[0][0],a[1][1],a[2][2]))
temp.append((a[0][2],a[1][1],a[2][0]))

n=int(input())

num=[]
for i in range(n):
    b=int(input())
    num.append(b)

res=list(itertools.permutations(num,3))
flag=0
for i in range(len(temp)):
    for j in range(len(res)):
        if temp[i] == res[j]:
            flag=1
            break
        else:
            continue

if flag == 1:
    print("Yes")
else:
    print("No")
            


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

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

    int n;
    cin >> n;

    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    

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

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    

    return 0;
}

Measured memory_bytes: 3664
import fractions
def main():
    N,M = map(int,input().split())
    A = [int(x)//2 for x in input().split()]
    # check
    ls = []
    for i in range(N):
        now = A[i]
        cnt = 0
        while 1:
            if now%2==0:
                now = now//2
                cnt +=1
            else:
                ls.append(cnt)
                break

    ls = set(ls)
    if len(ls)!=1:
        print(0)
        exit()


    sub = A[0]
    for i in range(1,N):
        sub = sub*A[i]//fractions.gcd(sub,A[i])
    B = M//sub
    print((B-1)//2+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 90336
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

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

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

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
	}

	sum := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if i != j {
				sum += a[i] * a[j]
			}
		}
	}
	fmt.Fprintln(write, sum)

}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define INF (1 << 28)
#define MAX_V 1000

int d[MAX_V][MAX_V];

void warshall_floyd(int n){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
	
	int N, M, R;
	int r[10];

	cin >> N >> M >> R;

	for(int i = 0; i < R; i++){
		cin >> r[i];
		r[i]--;
	}

	sort(r, r + R);

	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}

	for(int i = 0; i < M; i++){
		int A, B, C;
		cin >> A >> B >> C;
		A--;
		B--;
		d[A][B] = C;
		d[B][A] = C;
	}

	warshall_floyd(N);
	
	int ans = INF;

	do{
		int sum = 0;
		for(int i = 0; i < R - 1; i++){
			sum += d[r[i]][r[i + 1]];
		}
		ans = min(ans, sum);
	}while(next_permutation(r, r + R));

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
	fastio;
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	    cin>>h[i];
	long dp[n];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++)
	    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
    int w=1,c,ret;
    while((c=getchar())> '9'||c< '0')
    w=(c=='-'?-1:1); ret=c-'0';
    while((c=getchar())>='0'&&c<='9')
    ret=ret*10+c-'0';
    return ret*w;
}
LL a,b,c;
int main(){
    a=qread(),b=qread(),c=qread();
    puts((c>a+b&&(c-a-b)*(c-a-b)>4ll*a*b)?"Yes":"No");
    return 0;
}

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

int main(){
  int x;
  cin >> x;
  int sum = 0;
  long long ans=0;
  while(sum != 360){
    sum += x;
    ans++;
    if(sum > 360){
      sum = sum - 360;
    }
  }
  
  cout << ans << endl;
}
    

Measured memory_bytes: 3632
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ll n, w[14];
char ans[20];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
   
inline void Solve () {
   w[0] = 1;
   for (int i = 1; i <= 13; i ++) w[i] = w[i - 1] * 26;
   int len = 0;
   ll sum = 1;  
   cin >> n;
   for (int i = 1; i <= 13; i ++) {
      if (sum <= n && n <= w[i] + sum - 1) {
         n -= sum - 1;
         len = i;
         break;
      }
      sum += w[i];
   }
   for (int i = len; i >= 1; i --) {
      ans[i] = 'a';
      if (i == 1) {
         while (n > w[i - 1]) ans[i] ++, n -= w[i - 1];
         break;
      }
      while (n > w[i - 1]) ans[i] ++, n -= w[i - 1];
   }
   reverse (ans + 1, ans + len + 1);
   for (int i = 1; i <= len; i ++) cout << ans[i];
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   


Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,sz[SZ],mi[SZ],fc[SZ],fa[SZ]; Edgc
void dfs(int x,int f=0)
{
	sz[x]=1; mi[x]=0; fa[x]=f;
	for esb(x,e,b) if(b!=f)
	{
		fc[b]=vc[e]; dfs(b,x);
		sz[x]+=sz[b];
		mi[x]=max(mi[x],sz[b]);
	}
	mi[x]=max(mi[x],n-sz[x]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b,c;i<n;++i)
		scanf("%d%d%d",&a,&b,&c),adde(a,b,c);
	dfs(1);
	ll ans=0;
	for(int i=2;i<=n;++i)
		ans+=(ll)fc[i]*min(sz[i],n-sz[i]);
	ans*=2;
	for(int i=2;i<=n;++i)
		if(sz[i]+sz[i]==n)
		{
			printf("%lld\n",ans-fc[i]);
			return 0;
		}
	int gg=1e9,r;
	for(int i=1;i<=n;++i)
		if(mi[i]<gg) gg=mi[i],r=i;
	int aa=fc[r];
	for esb(r,e,b) if(b!=fa[r]) aa=min(aa,fc[b]);
	printf("%lld\n",ans-aa);
}


Measured memory_bytes: 23424
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	string in;
	vector <string>s;
	vector <int>a;
	int maxH = 0, maxL = 0;
	while (cin >> in) {
		s.push_back(in);
		a.push_back(0);
	}
	for (int i = 0; i < s.size(); i++) {
		if (a[i] == 0) {
			for (int j = i + 1; j < s.size(); j++) {
				if (s[i] == s[j])
					a[j] = ++a[i];
			}
			if (maxH < a[i])
				maxH = a[i];
		}
		if (maxL < s[i].length())
			maxL = s[i].length();
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxH == a[i]) {
			cout << s[i] << " ";
			break;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxL == s[i].length())
			cout << s[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3148
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  string s;
  cin >> s;
  for(ll i = 0; i < 3; i++) {
   if(s[i] == s[i+1]){
    cout << "Bad" ;
    return 0;
  }
  }
  cout << "Good" ; 
  return 0;
} //good night.

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


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            /*var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}",a*b,(a+b)*2);
            Console.ReadLine();
            var a = int.Parse(Console.ReadLine());
            var b = a / 60;
            var c = b / 60;
            Console.WriteLine("{0}:{1}:{2}", c, b % 60, a % 60);
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            {
            if (a > b) 
            Console.WriteLine("a > b");
            if (a < b) 
            Console.WriteLine("a < b");
            if (a == b)
            Console.WriteLine("a == b");

            }*/
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
                if (a<b && b<c) 
                {
                Console.WriteLine("Yes");
               }
            else
                Console.WriteLine("No");
        }









        }
    }

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    string a;

    cin >> a;

    if(count(a.begin(),a.end(),'A')==1 or count(a.begin(),a.end(),'B')==1) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N;
	cin >> N;


	vvll start_end(10);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			start_end[i].emplace_back(0);
		}
	}

	for (int i = 1; i <= N; i++) {

		vint kurai;
		int last = 0;
		for (int j = 0; j < 6; j++) {
			kurai.emplace_back((i % ll(pow(10, j+1))) / (ll(pow(10, j))));
			if (kurai[j] != 0) {
				last = j;
			}
		}



		/*for (int k = 0; k <= last; k++) {
			cout << kurai[k];
		}
		cout << endl;*/


		if (kurai.size() == 1) {
			start_end[kurai[0]][kurai[0]] ++;
		}
		else {
			start_end[kurai[last]][kurai[0]] ++;
		}


	}


	ll ans = 0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans += start_end[i][j] * start_end[j][i];
		}
	}


	cout << ans;


}


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll a, b;

int main() {
    fast_io; cout_precision;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b) {
        cout << "Alice" << endl;
    } else if (a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def fast_pow(num, kata, mod):
        if kata == 0:
            return 0

        res = 1
        while kata > 0:
            if kata & 1 == 1:
                res = res * num % mod
            num = num * num % mod

            kata >>= 1
        return res

    def choose(l, r):
        res = 1
        fac = 1
        for j in range(r):
            res *= l - j
            fac *= j + 1
        return res // fac

    n, p = ns()
    a = na()

    cnt = [0, 0]

    for ai in a:
        if ai % 2:
            cnt[1] += 1
        else:
            cnt[0] += 1

    zero_choice = 2 ** cnt[0]
    one_choice = 0
    for i in range(p, cnt[1] + 1, 2):
        one_choice += choose(cnt[1], i)

    print(zero_choice * one_choice)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main() {
    int n; ll t;
    cin >> n >> t; t++;
    using P = pair<ll, ll>;
    vector<P> f;
    vector<ll> ones;
    FOR(i,0,n) {
        ll a, b;
        cin >> a >> b; a++; b++;
        if (a == 1) {
            ones.push_back(b);
        } else {
            f.push_back({a, b});
        }
    }
    sort(f.begin(), f.end(), [&](P x, P y) {
        // fx -> fy
        ll z0 = x.second * y.first + y.second;
        // fy -> fx
        ll z1 = y.second * x.first + x.second;
 
        return z0 < z1;
    });
 
    sort(ones.begin(), ones.end());
 
    vector<ll> dp(50, 1000000000 + 10);
    dp[0] = 1;
    for (auto p: f) {
        IFOR(i,0,49) {
            dp[i + 1] = min(dp[i + 1], dp[i] * p.first + p.second);
        }
    }
 
    int ans = 0;
    FOR(i,0,50) {
        ll now = dp[i];
        if (t < now) continue;
        int cnt = i;
        for (ll x: ones) {
            if (t < now + x) break;
            cnt++;
            now += x;
        }
        ans = max(ans, cnt);
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6384
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){    
  long long N;
  cin >> N;
  long long sum=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0){
    sum += i;
    }
  }

  cout << sum << endl;
 
}


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

int main()
{
	string s;
	while (getline(cin, s)) {
		int n = s.size();
		for (int i = 0; i < 26; i++) {
			bool flag = false;
			for (int j = 0; j + 3 <= n; j++) {
				if (s.substr(j, 3) == "the" && (j == 0 || s[j - 1] < 'a' || s[j - 1] > 'z') && (j + 3 == n || s[j + 3] < 'a' || s[j + 3] > 'z')) {
					flag = true;
				}
			}
			for (int j = 0; j + 4 <= n; j++) {
				if (s.substr(j, 4) == "this" && (j == 0 || s[j - 1] < 'a' || s[j - 1] > 'z') && (j + 4 == n || s[j + 4] < 'a' || s[j + 4] > 'z')) {
					flag = true;
				}
			}
			for (int j = 0; j + 4 <= n; j++) {
				if (s.substr(j, 4) == "that" && (j == 0 || s[j - 1] < 'a' || s[j - 1] > 'z') && (j + 4 == n || s[j + 4] < 'a' || s[j + 4] > 'z')) {
					flag = true;
				}
			}
			if (flag) {
				cout << s << endl;
				break;
			}
			for (int j = 0; j < n; j++) {
				if (s[j] >= 'a' && s[j] <= 'z') {
					s[j] = s[j] == 'z' ? 'a' : s[j] + 1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3116
n = int(input())
ll = []
for i in range(n):
	s, p = list(input().split())
	ll.append((s,-int(p),i+1))
ll1 = sorted(ll, key = lambda x:x[1])
ll2 = sorted(ll1, key = lambda x:x[0])

for i in range(n):
	print(ll2[i][2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x,data[200001]={};
    stack<int>s;
    cin>>n>>m;
    for(int i=n;i>=1;--i) s.push(i);
    for(int i=0;i<m;++i){
	cin>>x;
	s.push(x);
    }
    for(int i=1;i<=n;++i){
	if(data[s.top()]==0){
	    cout<<s.top()<<endl;
	    data[s.top()]=1;
	}else --i;
	s.pop();
    }
    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, all = 0;
  cin >> N;
  ll a[N];
  rep(i, N) cin >> a[i];

  rep(i, N) all ^= a[i];
  rep(i, N-1) printf("%lld ", all ^ a[i]);
  printf("%lld\n", all ^ a[N-1]);
  return 0;
}



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

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair

const int N = 2e5+10;
const ll MAX = ll(1e18) + 111;
const ll MOD = 1e9+7;

int a[N], n, m;

vector<int> g[N];

bool used[N];

int C = 0;

vector<int> cs[N];

void dfs(int v){
    if(used[v]) return;
    used[v] = 1;
    cs[C].push_back(v);
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        dfs(to);
    }
}

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

    for(int i = 0; i < n; i++){
        if(!used[i]){
            dfs(i);
            C++;
        }
    }
    cerr << "components: " << C << endl;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < cs[i].size(); j++){
            cerr << cs[i][j] << ' ' ;
        }
        cerr << endl;
    }

    vector<pair<int, int> > order;
    for(int i = 0; i < C; i++){
        order.push_back(mp(-cs[i].size(), i));
    }
    sort(all(order));

    multiset<int> costs;
    int prev_used = -1;

    ll ans = 0;
    bool can = 1;

    for(int i = 0; i < C-1; i++){
        int cur_c = order[i].sc;
        int next_c = order[i+1].sc;
        for(int j = 0; j < cs[cur_c].size(); j++){
            int v = cs[cur_c][j];
            if(v != prev_used)
                costs.insert(a[v]);
        }

        if(costs.empty()) {
            can = 0;
            break;
        }

        int min_val = 2e9;
        for(int j = 0; j < cs[next_c].size(); j++){
            int v = cs[next_c][j];
            if(a[v] < min_val)
                min_val = a[v], prev_used = v;
        }

        cerr << "to add: " << min_val << ' ' << *costs.begin() << endl;

        ans += min_val;
        ans += *costs.begin();
        costs.erase(costs.begin());

    }
    if(can){
        cout << ans;
    } else cout << "Impossible";
	return 0;
}


Measured memory_bytes: 18684
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

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

	int n;
	cin >> n;
	int c = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans = add(ans, mul(c, x));
		c = add(c, x);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

namespace INPUT{
	const int L=1<<15;
	char _buf[L],*S,*T,c;
	char _gc(){
		if(S==T){
			T=(S=_buf)+fread(_buf,1,L,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
	void readi(int &X){
		for(c=_gc();c<'0'||c>'9';c=_gc());X=c&15;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
	}
}
using INPUT::readi;

const int Maxn=1E5+5;

int N;
struct E{
	int v,nxt;
}adj[Maxn<<1];
int hed[Maxn],TE;

void addedge(int u,int v){
adj[++TE].v=v,adj[TE].nxt=hed[u],hed[u]=TE;}

int Dfs(int u,int Fa){
	int Val=0;
	for(int k=hed[u];~k;k=adj[k].nxt)
		if(adj[k].v!=Fa) Val^=(Dfs(adj[k].v,u)+1);
	return Val;
}

int main(){
	readi(N);
	memset(hed,-1,sizeof(hed));
	for(int u,v,i=1;i<N;++i)
		readi(u),readi(v),
		addedge(u,v),addedge(v,u);
	if(Dfs(1,0)==0) puts("Bob"); else puts("Alice");
	return 0;
}


Measured memory_bytes: 6912
from collections import Counter
MOD = 2019
s = input()[::-1]
n = len(s)
l = [0] * (n + 1)
t = 1
for i in range(n):
    l[i + 1] = ((ord(s[i]) - ord('0')) * t + l[i]) % MOD
    t = t * 10 % MOD
c = Counter(l)
ans = 0
for v in c.values():
    ans += (v - 1) * v // 2
print(ans)


Measured memory_bytes: 75804
"""
AOJ 2426  Treasure Hunt


座標圧縮を二次元でやるっぽい
上の問題たちとちがうのは、ここからここまでが領域１です、みたいな形になっている点か。
また、例４をみると、ある領域の内側に小さな領域があるパターンもあり、小さいほうに入っている宝は両方に所属していることになるっぽい。

さっぱりなので写経
http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2963309#1

二次元累積和がはじめてなので、そっちの練習がまず先に必要っぽい
"""

from bisect import bisect_left

def main():

    N,M = map(int, input().split())
    treasures = []

    # 宝のx,yの位置（ある宝のx,yの組ではなく、x,y座標的にどこに位置するか）
    Xs = set()
    Ys = set()

    for _ in range(N):
        x,y = map(int, input().split())
        treasures.append((x,y))
        Xs.add(x)
        Ys.add(y)


    # x,yそれぞれで座圧
    Xs = list(Xs)
    Xs.sort()
    Ys = list(Ys)
    Ys.sort()
    

    # 座標xはO番目、みたいな情報を作る
    Xd = {}
    Yd = {}
    for i,x in enumerate(Xs):
        Xd[x] = i
    for i,y in enumerate(Ys):
        Yd[y] = i


    lx = len(Xs)
    ly = len(Ys)
    # ここに宝があるよ、を座圧した情報にする
    compressd_treasures = [[0 for _ in range(lx + 1)] for _ in range(ly + 1)]
    for x,y in treasures:
        # yyy番目のy座標とxxx番目のxxx座標に宝があるよ
        compressd_treasures[Yd[y] + 1][Xd[x] + 1] += 1

    # 左下から右上に向かって、「下や左から（南から？）進んできて何個宝があるか」の累積和をとる
    # ここの操作後、comp~[y][x]で、（一番左下の座標（原点ではない））~(x,y)の長方形の中にある宝の数が得られるから、
    # うまいことやると(x1,y1)~(x2,y2)の範囲の宝の数が得られる
    for y in range(1, ly + 1):
        acc = 0
        for x in range(1, lx + 1):
            # accに足しておいて、xが進むごとに左から右へも累積和をとれる
            acc += compressd_treasures[y][x]
            # 下の所から積み上げて累積和
            compressd_treasures[y][x] = acc + compressd_treasures[y-1][x]

    for _ in range(M):
        x1, y1, x2, y2 = map(int, input().split())
        # それぞれの座標について、何番目の宝まで含みうるか考える
        idx_x1 = bisect_left(Xs, x1)
        idx_x2 = bisect_left(Xs, x2)
        idx_y1 = bisect_left(Ys, y1)
        idx_y2 = bisect_left(Ys, y2)

        # 宝が領域の境界線上にあるとき、加算する(bisectした値と同じものがXs,Ysにあるとき)
        if idx_x2 < lx and Xs[idx_x2] == x2:
            idx_x2 += 1
        if idx_y2 < ly and Ys[idx_y2] == y2:
            idx_y2 += 1
        
        # 累積和で出す。l~r = 0~r - 0~l-1　を二次元にしたバージョン
        ans = compressd_treasures[idx_y2][idx_x2] - compressd_treasures[idx_y2][idx_x1] - compressd_treasures[idx_y1][idx_x2] + compressd_treasures[idx_y1][idx_x1]
        print(ans)


if __name__ =="__main__":
    main()


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

int main() {
  int n, a, b;
  cin >> n >> a;
  
  if (a >= 500){
    cout << "Yes" << endl;
  }
  
  else {
    b = n % 500;
    
    if (a >= b){
      cout << "Yes" << endl;
    }
    
    else {
      cout << "No" << endl;
    }
    
  }
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int MaxN = 1e5;
char S[MaxN + 5];
int flag = 0;
int cnt[30];
int main()
{
	scanf("%s",&S);
	int len = strlen(S);
	for(int i = 0; i < len; i++){
		cnt[S[i] - 'a'] = 1;
	}
	for(int i = 0; i < 26; i++){
		if(cnt[i] == 0) {printf("%c\n",i + 'a'); flag = 1;break;}
	}
	if(flag == 0) printf("None\n");
}

Measured memory_bytes: 256
N = int(input())
x = N % 10
#xはNを10で割ったあまり

if x == 2 or x == 4 or x == 5 or x == 7 or x == 9:
    k = 'hon'
elif x == 0 or x == 1 or x == 6 or x == 8:
    k = 'pon'
elif x == 3:
    k = 'bon'

print(k)


Measured memory_bytes: 9084
#include <stdio.h>
#include <stdlib.h>

int main(void) {

  long n,z,w;
  scanf("%ld %ld %ld", &n, &z, &w);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long score = labs(a[n-1]-w);
  if (n != 1) {
    if (labs(a[n-1]-a[n-2]) > score) {
      score = labs(a[n-1]-a[n-2]);
    }
  }
  printf("%ld\n", score);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 200010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


class CumulativeSum{
public:
  vector<int> sum;
  CumulativeSum(){}
  CumulativeSum(vector<int> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += sum[i-1] + A[i-1];
  }
  int get(int l,int r){return sum[r] - sum[l];} //[)
};

CumulativeSum sum;


int n;
vector<int> A;
vector<char> op;
int f[2] = {1,-1};

int used[N][3],mem[N][3];

int dfs(int idx,int cnt){
  if(cnt == 2) return sum.get(idx,n);
  if(idx == n) return 0;
  if(used[idx][cnt]++) return mem[idx][cnt];
  
  char ch = op[idx-1];
  cnt += ch == '-';
  int res = 0;
  int val = f[cnt%2] * A[idx];
  if(cnt) Max(res,val + dfs(idx+1,cnt-1));
  Max(res,val + dfs(idx+1,cnt));
  return mem[idx][cnt] = res;
}


signed main(){
  cin>>n;
  A.resize(n);
  op.resize(n);
  for(int i=0;i<n;i++) {
    cin>>A[i];
    if(i!=n-1) cin>>op[i];
  }
  sum = CumulativeSum(A);
  cout<<A[0] + dfs(1,0)<<endl;
  return 0;
}


Measured memory_bytes: 16368
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

int modpow(int a, int n, int p) {
    int b = 1;
    while (n) {
        if (n & 1) {
            b = 1LL * a * b % p;
        }
        a = 1LL * a * a % p;
        n >>= 1;
    }
    return b;
}

int inverse(int a, int p) {
    return modpow(a, p - 2, p);
}

int brute(string s, int n, int p) {
    long long answer = 0;
    for (int i = 0; i < n; ++i) {
        int u = 0;

        for (int j = i; j < n; ++j) {
            u = (u * 10 % p + s[j] - '0') % p;
            if (u == 0)
                answer++;
        }
    }
    return answer;
}

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

    int n, p;
    cin >> n >> p;

    string s; cin >> s;

    long long answer = 0;

    if (p == 2 || p == 5) {

        for (int i = 0; i < n; ++i) {
            if ( (s[i] - '0') % p == 0) {
                answer += i + 1;
            }
        }

    } else {
        auto iten = inverse(10 % p, p);
        map<int,int> freq;
        freq[0]++;

        int cur = 0, t = 1;

        for (int i = 0; i < n; ++i) {
            t = 1LL * t * iten % p;
            cur = (cur * 10 % p + s[i] - '0') % p;
            auto num = 1LL * cur * t % p;
            answer += freq[num]++;
        }
    }

    cout << answer << endl;
    // if (answer != brute(s, n, p)) {
    //     cout << brute(s, n, p) << endl;
    // }

    return 0;
}

Measured memory_bytes: 916
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::greater;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    int n;
    int ans_char;
    int times;
    while (1) {
        cin >> n;
        if (n == 0) {
            break;
        }
        ans_char = -1;
        vector<char> vote(n, '0');
        for (int i = 0; i < n; i++) {
            cin >> vote[i];
        }
        vector<int> vote_num(26, 0);
        for (int i = 0; i < n; i++) {
            vote_num[vote[i] - 'A']++;
            vector<int> temp = vote_num;
            sort(temp.begin(), temp.end(), greater<int>());
            int top = temp[0];
            int semitop = temp[1];
            int rest = n - i - 1;
            if (top > semitop + rest) {
                for (int j = 0; j < 26; j++) {
                    if (top == vote_num[j]) {
                        ans_char = j;
                        times = i + 1;
                        i = n; //??????for??????????????¬??????
                        break;
                    }
                }
            }
        }
        if (ans_char == -1) {
                cout << "TIE" << endl;
        } else {
        cout << (char)(ans_char + 'A') << " " << times << endl;
        }

    }
    return 0;
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {
	
	private void doit(){
		
		
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			long sum = 0;
			long nsum = 0;
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
				sum += data[i];
				nsum += i + 1;
			}
			if(sum % nsum !=  0){
				System.out.println("NO");
				continue;
			}
			
			int [] diff = new int[n];
			for(int i = 0; i < n; i++){
				diff[i] = data[(i + 1) % n] - data[i];
			}
			
			long res = 0;
			boolean flg = false;
			for(int i = 0; i < n; i++){
				long temp = (sum / nsum + diff[i] * -1);
				if(temp % n  != 0 || temp / n < 0){
					flg = true;
					break;
				}
				res += (temp/ n);
			}
			if(res == sum /nsum && !flg){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
			
			
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 33540
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int main()
{
    abdelrahman010
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
local r, c = io.read("*n", "*n", "*l")
for i = 1, r do
  local s = io.read()
  local j = 64
  for v in s:gmatch("%w+") do
    j = j + 1
    if v == "snuke" then
      print(string.char(j) .. i)
    end
  end
end


Measured memory_bytes: 760