akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdint>
using namespace std;

const int MOD = 1000000007; // 今回使う余り
int main() {
	int n, m, x, y;
	cin >> n >> m;
	
	int64_t xsum = 0, ysum = 0;
	for (int i = 0;i < n;i ++) {
		cin >> x;
		xsum = (xsum + (int64_t)(2 * i + 1 - n) * x) % MOD;
	}
	for (int i = 0;i < m;i ++) {
		cin >> y;
		ysum = (ysum + (int64_t)(2 * i + 1 - m) * y) % MOD;
	}
	cout << xsum * ysum % MOD;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

単に式変形すると解ける
xy独立なのでまずはxについて説明するよ
まず、x方向ではΣ[i=1, n] Σ[j=i + 1, n] (xj - xi)が答え
これだと2重ループだけど、あるkを用いてΣ[k = 1, n] ((k - 1)x_k - (n - k)x_k) = Σ[k = 1, n] ((2k - n - 1)x_k)に等しいと分かるとO(n)
y方向も同様にやって終わり
*/

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


int main(int argc, char** argv) {

    int n,m;
    cin>>n>>m;

    int arr[n];
    int arr2[n];
    for (int i=0;i<n;i++)
    {
        arr[i]=1;
        arr2[i]=0;
    }
    int z=0;
    arr2[0]=1;

    for (int i=0;i<m;i++)
    {int x,y;
    cin>>x>>y;
    x--;y--;

        if (arr2[x]){
        arr2[y]=1;
        }

        arr[x]--;
        arr[y]++;

        if (arr[x]==0)
        {arr2[x]=0;
        ;}
    }
    for(int i=0;i<n;i++)
    {
        if (arr2[i]==1)
        {z++;
       }
    }
cout<<z;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++)cin >> a[i];
    sort(a.begin(),a.end());
    long long sum=0;
    for(int i=0; i<n; i++){
        sum+=a[i];
    }
    sum-=a[n-1]/2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
	  
   int A,B,C;
   
    scanf("%d", &A); 
    scanf("%d", &B);
    scanf("%d", &C);
  
  
  	if(C > 20) C=20;
  	if(C<1) C=1;
  	if(A > 20) A=20;
    if(B>A) B=A;
  
    if((A-B) > C){
      C = 0;
    }
    else{
      C = C - (A-B);
    }
  
  　printf("%d",C);
  
  return 0;
   
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main() 
{
    long double ans=1;
    int n;
    cin>>n;
    
    long double a[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        //ans=ans*a;
    }
    
    sort(a,a+n);
    
    for(int i=0;i<n;i++)
    {
        //cin>>a[i];
        ans=ans*a[i];
        if(ans==0)
        {
            cout<<0;
            return 0;
        }
        if(ans>1000000000000000000)
        {
            cout<<-1;
            return 0;
        }
    }
    
    cout<<(long long int)ans;
    return 0;
}

Measured memory_bytes: 5352
H, W = map(int, input().split())

S = ["."*(W+2)]
for i in range(H):
    tmp = input()
    S.append("." + tmp + ".")
S.append("."*(W+2))

ans = []
for i in range(1, H+1):
    tmp = []
    for j in range(1, W+1):
        count = 0
        if S[i-1][j-1] == "#":
            count += 1
        if S[i][j-1] == "#":
            count += 1
        if S[i-1][j] == "#":
            count += 1
        if S[i+1][j-1] == "#":
            count += 1
        if S[i-1][j+1] == "#":
            count += 1
        if S[i][j+1] == "#":
            count += 1
        if S[i+1][j] == "#":
            count += 1
        if S[i+1][j+1] == "#":
            count += 1
        if S[i][j] == "#":
            tmp.append("#")
        else:
            str_count = str(count)
            tmp.append(str_count)
    ans.append(tmp)

for i in range(len(ans)):
    print("".join(ans[i]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);


int main() {
  string s, t;
  cin >> s >> t;
  if(s.size()-t.size()==0) {
    rep(i,s.size()){
      cout << s[i] << t[i];
    }
    return 0;
  }
  else {
    rep(i,t.size()){
      cout << s[i] << t[i];
    }
    cout << s[s.size()-1];
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;
using ll = long long;
int n;
const int maxN = 1e5 + 5;
int MOD = 1e9 + 7;
vector<int> edges[maxN];

int mult(int & a, int b) {
    return (ll) a*b % MOD;
}

int add(int a, int b) {
    ll c = a + b;
    return c > MOD ? c - MOD : c; 
}

// returns a pair(black, white)
pair<int, int> dfs(int a, int parent) {
    int is_white = 1, smth_is_black = 0;
    for (int b: edges[a]) {
        if (b != parent) {
            pair<int, int> p = dfs(b, a);
            // p.first - # of ways to color tree that child 'b' is black
            // p.second - # of ways to color tree that 'b' is white
            int memo_is_white = is_white;
            is_white = mult(is_white, p.second);
            smth_is_black = add(mult(memo_is_white, p.first), mult(smth_is_black, p.first + p.second));
        }
    }
    return {is_white, add(is_white, smth_is_black)};
}

int main(int argc, char *argv[]) {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    pair<int, int> p = dfs(1, -1);
    printf("%d\n", add(p.first, p.second));
    return 0;
}

Measured memory_bytes: 11264
def resolve():
    a, b = input().strip().split(' ')
    n, m = [int(a), int(b)]
    array = list(map(int, input().strip().split(' ')))
    homework_sum = 0
    for i in range(m):
        homework_sum = homework_sum + array[i]
    if n - homework_sum >= 0:
        ans = n - homework_sum
    else:
        ans = -1
    print(ans)
resolve()


Measured memory_bytes: 10044
#include<bits/stdc++.h>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define N 200005
#define ls(u) t[u].s[0]
#define rs(u) t[u].s[1]
#define lowbit(x) x & -x
#define ll long long
int n, m, a[N], p[N], ans;
bool vis[N];
std::map<int, int> mp;
int main ()
{
    scanf("%d", &n);
    fo (i, 1, n) {scanf("%d", &a[i]); mp[a[i]]++;}
    std::sort(a + 1, a + n + 1);
    p[0] = 1;
    fo (i, 1, 30) p[i] = p[i - 1] * 2;
    fd (i, n, 1)
    {
        if (!mp[a[i]]) continue;
        mp[a[i]]--;
        fo (j, 1, 30)
            if (p[j] > a[i])
            {
                int now = p[j] - a[i];
                if (mp[now])
                {
                    mp[now]--;
                    ++ans;
                }
                break;
            }
    }
    printf("%d", ans);
    return 0;
}

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl;
}

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

int main(){
	int n, a, k = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a);
		if(!(a&1)) k++;
	}
	if(k == n) printf("second\n");
	else printf("first\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N, D, X, count = 0;

    cin >> N >> D >> X;
    vec A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    rep(i, N)
    {
        int sum = 0;
        int j = 1;
        while (1)
        {
            sum = (A[i] * j + 1);
            if (sum > D)
            {
                break;
            }
            count++;
            j++;
        }
    }
    cout << count + N + X << endl;
}


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

int main()
{
	double a;

	while (cin >> a) {

		double s = a;

		for (int i = 0; i < 4; i++) {
			a *= 2;
			s += a;
			a /= 3;
			s += a;
		}

		a *= 2;
		s += a;

		cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(10) << s << endl;
	}

	return 0;
}


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


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n/2) ans += (s[i] != s[n-i-1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int mf(const int& a, const int& b, const int& c, const int& d) {
  return max(a, max(b, max(c, d)));
}
int main() {
  int n, m;
  cin >> n >> m;
  int mp[n][m];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      cin >> mp[i][j];
  int dp[n][m][n] = {};
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < min(i + j + 1, n); ++k) {
        dp[i][j][k] = mf(i ? dp[i-1][j][k] : 0,
                         j ? dp[i][j-1][k] : 0,
                         i && k ? dp[i-1][j][k-1] : 0,
                         j && k ? dp[i][j-1][k-1] : 0)
                        + mp[i][j] + (i == k ? 0 : mp[k][i+j-k]);
      }
    }
  }
  cout << dp[n-1][m-1][n-1] << '\n';
  return 0;
}

Measured memory_bytes: 31616
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val o = scala.collection.mutable.Queue(sc.nextLine.split(""): _*)
    val e = scala.collection.mutable.Queue(sc.nextLine.split(""): _*)

    var s: String = ""
    while (o.nonEmpty) {
      s += o.dequeue
      if (e.nonEmpty) s += e.dequeue
    }
    println(s)
  }
}


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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll count = 0;
    int n;
    cin >> n;
    vector<ll> a(n+1), b(n);
    for(int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for(int i = 0; i < n; i++) {
        count += min(a[i]+a[i+1], b[i]);
        b[i] -= a[i];
        b[i] = max(0LL, b[i]);
        a[i+1] -= (b[i]);
        a[i+1] = max(0LL, a[i+1]);
    }
    cout << count << "\n";
    return 0; 
}

Measured memory_bytes: 1792
def a
  a, b = gets.chomp.split.map(&:to_i)
  a = 100 if a == 1
  b = 100 if b == 1

  if a > b
    puts :Alice
  elsif a == b
    puts :Draw
  else
  puts :Bob
  end
end

def b
  n, m = gets.chomp.split.map(&:to_i)
  fs = (1..n).map { gets.chomp.split '' }
  gs = (1..m).map { gets.chomp.split '' }

  (0..(n - m)).each {|x|
    (0..(n - m)).each {|y|
      flg = true
      (0...m).each {|i|
        (0...m).each {|j|
          if fs[i + x][j + y] != gs[i][j]
            flg = false
            break
          end
        }
        break if not flg
      }
      if flg
        puts :Yes
        exit
      end
    }
  }
  puts :No
end

b


Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B,K;

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

    int ans;
    for(int i=min(A,B);i>=1;i--){
        if(A%i==0 && B%i==0){
            K--;
            if(K==0){
                ans=i;
                break;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n);
  REP(i, n) cin >> a.at(i);
  ll ansp=0, ansm=0;
  ll sump=0, summ=0;
  if (a.at(0) < 0) {
    ansp = -a.at(0)+1;sump=1;
    summ = a.at(0);
  } else if (a.at(0) > 0) {
    ansm = a.at(0)+1;summ=-1;
    sump = a.at(0);
  } else {
    ansm=1;summ=-1;
    ansp=1;sump=1;
  }
  rep(i, 1, n) {
    if (sump > 0) {
      if (sump + a.at(i) >= 0) {
        ansp += a.at(i) + sump + 1;
        sump = -1;
      } else {
        sump += a.at(i);
      }
    } else {
      if (sump + a.at(i) <= 0) {
        ansp += -(a.at(i) + sump) + 1;
        sump = 1;
      } else {
        sump += a.at(i);
      }
    }
    if (summ < 0) {
      if (summ + a.at(i) <= 0) {
        ansm += -(a.at(i) + summ) + 1;
        summ = 1;
      } else {
        summ += a.at(i);
      }
    } else {
      if (summ + a.at(i) >= 0) {
        ansm += a.at(i) + summ + 1;
        summ = -1;
      } else {
        summ += a.at(i);
      }
    }
  }
  cout << min(ansp, ansm) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u)
    {
        cout << a - 1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int min = Math.min(a, b);
		int max = Math.max(a, b);
		if(min+w>=max) {
			System.out.println(0);
			return;
		} else {
			System.out.println(max - (min + w));
		}
	}
}

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

int main() {
  int s1s2s3;
  
  cin >> s1s2s3;
  s1s2s3 = (s1s2s3) / 100 + (s1s2s3) % 100 / 10 + (s1s2s3) % 10;
  
  cout << s1s2s3 << endl;
  
}


Measured memory_bytes: 3552
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque

class Node:
    def __init__(self,depth):
        self.depth=depth
        self.left=None
        self.right=None

def insert(node,s):
    n=node
    for i in range(len(s)):
        t=s[i]
        if t=='0':
            if n.left is None:
                n.left=Node(i+1)
            n=n.left
        else:
            if n.right is None:
                n.right=Node(i+1)
            n=n.right

class Trie:
    def __init__(self):
        self.root=Node(0)
    def insert(self,s:str):
        insert(self.root,s)

n,l=map(int,input().split())
S=[input().strip() for _ in range(n)]
trie=Trie()
for s in S:
    trie.insert(s)
Data=[]
q=deque([trie.root])

def dfs(node):
    if node.right is None and node.left is None:
        return
    if node.right is None or node.left is None:
        Data.append(l-node.depth)
    if node.right:
        q.append(node.right)
    if node.left:
        q.append(node.left)

while q:
    dfs(q.popleft())
xor=0

def Grundy(n):
    ret=1
    while n%2==0:
        n//=2
        ret*=2
    return ret

for i in Data:
    xor^=Grundy(i)
print('Alice' if xor else 'Bob')

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

int n;
priority_queue<int> pq;
int a[100005];
int sma,big;
vector<pair<int,int> > v;

int main(){

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

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    sma=a[1];
    big=a[n];
    int i;
    for(i=n-1;i>=2&&a[i]>=0;i--){
        v.push_back(make_pair(sma,a[i]));
        sma-=a[i];
    }
    for(;i>=2;i--){
        v.push_back(make_pair(big,a[i]));
        big-=a[i];
    }
    cout<<big-sma<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i].first<<' '<<v[i].second<<endl;
    }
    cout<<big<<' '<<sma<<endl;

    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n,k,ans=0;
    cin>>n>>k;
    vector<int> x(n);
    rep(i,0,n)cin>>x[i];
    rep(i,0,n){
        int num=min(2*x[i],2*abs(k-x[i]));
        ans+=num;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%s",$s);

for ($i=0; $i < strLen($s)-1; $i++)
{
    if($s[$i]==='A')
    {
        $aPos = $i;
        break;
    }
}
for ($i = strLen($s)-1; 0<$i; $i--)
{
    if($s[$i]==='Z')
    {
        $bPos = $i;
        break;
    }
}



echo ($bPos - $aPos +1).PHP_EOL;



Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int now = 0;
    int MIN = 0;
    rep(i,n){
        if (s[i]=='(')
            now++;
        else now--;
        MIN = min(now, MIN);
    }
    if (MIN<0)
        repf(i, MIN, 0) cout << '(';
    cout << s;
    now -= MIN;
    rep(i, now) cout << ')';
    cout << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll d, n;
  cin >> d >> n;
  ll result = 1;
  for(i = 0; i < d; i++)
    result *= 100;
  if(n != 100)
    cout << result * n << endl;
  else
    cout << result * 101 << endl;
  

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Set - Set: Range Search
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_7_C&lang=jp

"""
from bisect import insort, bisect_right, bisect_left

class Multi_set:
    def __init__(self):
        self.total = 0
        self.ms = dict()
        self.lr = []

    def insert(self, x):
        if x in self.ms:
            if self.ms[x] == 0:
                self.ms[x] = 1
                self.total += 1
        else:
            self.total += 1
            self.ms[x] = 1
            insort(self.lr, x)
        print(self.total)

    def find(self, x):
        print(self.ms.get(x, 0))

    def delete(self, x):
        if x in self.ms:
            self.total -= self.ms[x]
            self.ms[x] = 0

    def dump(self, l, r):
        lb = bisect_left(self.lr, l)
        ub = bisect_right(self.lr, r)
        for i in range(lb, ub):
            k = self.lr[i]
            v = self.ms[k]
            print(f'{k}\n' * v, end='')


ms = Multi_set()
for _ in range(int(input())):
    op, x, y = (input() + ' 1').split()[:3]
    if op == '0':
        ms.insert(int(x))
    elif op == '1':
        ms.find(int(x))
    elif op == '2':
        ms.delete(int(x))
    else:
        ms.dump(int(x), int(y))



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

int main(){
	string s; cin>>s;
	set<char> st;
	for(int i=0; i<26; i++){
		char t='a'+i;
		st.insert(t);
	}
	int k=s.size();
	rep(i,k){
		st.erase(s[i]);
	}
	if(st.size()==0) cout<<"None"<<endl;
	else cout<<*st.begin()<<endl;
	
}


Measured memory_bytes: 3708
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = gets.to_i

puts L[K - 1]


Measured memory_bytes: 3836
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

// MODが素数以外でも使えるバージョン。階乗の逆元を求める。
ll extgcd(ll a, ll b, ll& x, ll& y)
{
	ll d = a;
	if (b != 0)
	{
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else
	{
		x = 1;
		y = 0;
	}
	return d;
}

// 逆元を求める
ll mod_inverse(ll a, ll m)
{
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

enum { NUM_FACTORIAL = 1012345 };
ll f[NUM_FACTORIAL];
ll f_inv[NUM_FACTORIAL];
ll MOD = (ll)1e9 + 7LL;

void mod_factorial_init()
{
	f[0] = 1;
	for (int i = 1; i < NUM_FACTORIAL; ++i)
	{
		f[i] = f[i - 1] * i;
		f[i] %= MOD;
	}

	for (int i = 0; i < NUM_FACTORIAL; ++i)
	{
		f_inv[i] = mod_inverse(f[i], MOD);
	}
}

// 組み合わせを求める。事前計算O(n)で、0～nまでと範囲も広いので、MODつきならパスカルの三角形よりも良い。最有力。
ll mod_comb(ll n, ll k) {
	if (k > n || n<0 || k <0)
	{
		return 0;
	}

	return ((f[n] * f_inv[k]) % MOD * f_inv[n - k]) % MOD;
}


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

	mod_factorial_init();



	for (int i=1;i<=K;++i)
	{
		// 赤いボールの隙間にいれる、いれる場所のパターン数
		ll places = mod_comb(N - K + 1, i);

		// 青いボールを入れるパターン数

		// K-i個のボールを入れる
		// 区切りi-1


		ll blue = mod_comb(K - i+(i-1), i-1);

		ll ptn = places * blue % MOD;

		cout << ptn << endl;
	}


	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    LL ans=0;
    cin >> n;
    VI a(n);
    map<int,int> mp;
    REP(i,n) {
        cin >> a[i];
        mp[a[i]]++;
        ans+=a[i];
    }
    int qq;
    cin >> qq;
    REP(q,qq) {
        int b,c;
        cin >> b >> c;
        int cnt=( mp.count(b) ? mp[b] : 0 );
        int diff=c-b;
        ans+=(LL)diff*cnt;        
        cout << ans << '\n';
        if ( mp.count(b) ) mp.erase(b);
        mp[c]+=cnt;
    }

    return 0;
}




Measured memory_bytes: 6620
import numpy as np
from numba import njit
def main():
    N = int(input())
    nlist = np.array(list(map(int, input().split())))

    def gdc(x, y):
        b = max(x, y)
        s = min(x, y)
        r = b % s
        if r == 0:
            return s
        else:
            return gdc(s, r)

    scp = False
    pcp = False

    sgdc = nlist[0]
    for n in nlist:
        sgdc = gdc(sgdc, n)
        if sgdc == 1:
            scp = True

    if not scp:
        print('not coprime')
        exit()

    pcheckl = [0] * (10**6+1)
    for n in nlist:
        pcheckl[n] = 1

    pcp = all([sum(pcheckl[i::i]) <= 1 for i in range(2, 10**6+1)])

    if pcp:
        print('pairwise coprime')
    elif scp:
        print('setwise coprime')

if __name__ == '__main__':
    main()

Measured memory_bytes: 209516
#include<stdio.h>
int main (){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a + b == c || 
		a + c == b ||
		b + c == a){
		printf("Yes");
		}
		else
		{
			printf("No");
			}
	return 0;
	}

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

int main()
{
    /*
    int a,b;
    cin>>a>>b;
    int count=a;
    int sockets = 1;
    if(b==1)
    {
        cout<<0<<endl;
        return 0;
    }
    if(a<b)
    {
        while(count<b)
        {
            count+=(a-1);
            sockets++;
        }
    }
    else
    {
        cout<<1<<endl;
        return 0;
    }  
    
    cout<<sockets<<endl;
    */
    int n;
    cin>>n;
    vector <int> x(n);
    rep(i,n)
    {
        cin>>x[i];
    }

    int ans = 1001001001;
    for (int p = 1; p <= 100; ++p) {
        int now = 0;
        rep(i,n) now += (x[i]-p)*(x[i]-p);
        ans = min(ans, now);
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate

N,K = map(int,input().split())
A = [int(input()) - K for _ in range(N)]
Acum = [0] + list(accumulate(A))

a_to_i = {a:i for i,a in enumerate(sorted(set(Acum)), 1)}

B = [a_to_i[a] for a in Acum]

L = len(a_to_i) + 1
tree = [0] * (L+1)

# 過去に自分以下の値が何回出てきているのか
def BIT_update(tree, x):
    while x <= L:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree, x):
    s = 0
    while x:
        s += tree[x]
        x -= x & (-x)
    return s

answer = 0
for b in B:
    answer += BIT_sum(tree,b)
    BIT_update(tree,b)

print(answer)



Measured memory_bytes: 54288
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SC second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll cnt = 0;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  ll n, m ;
  cin >> n >> m ;
  if(n==1){
    if(m==1){
      cout << 1 <<endl ;
    }
    else{
      cout << m-2 <<endl ;
    }
  }
  else if(m==1){
    cout << n-2 <<endl ;
  }
  else{
    cout <<(n-2)*(m-2) <<endl ;
  }
  


  return 0 ;
}

Measured memory_bytes: 256
LENGTH = 30


def calculate_step(length):
    step_list = [0] * (length + 1)
    step_list[1] = 1
    step_list[2] = 2
    step_list[3] = 4

    for lp in range(4, length + 1):
        total = sum(step_list[lp - 3:lp])
        step_list[lp] = total

    return step_list


step_list = calculate_step(LENGTH)
step_list = [int(item / 10 / 365 + 1) for item in step_list]

while True:

    step = int(input())

    if step == 0:
        break

    print(step_list[step])



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
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; }

int64_t gcd(int64_t a, int64_t b) {
    if (b > a) {
        int64_t c = a;
        a = b;
        b = c;
    }

    if (a % b == 0) {
        return b;
    }

    int64_t c = a % b;
    return gcd(b, c);
}

int main()
{
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    int64_t c_ = (B / C) - (A / C);
    if (A % C == 0) c_ += 1;
    int64_t d_ = (B / D) - (A / D);
    if (A % D == 0) d_ += 1;
    int64_t E = C * D / gcd(C, D);
    int64_t e_ = (B / E) - (A / E);
    if (A % E == 0) e_ += 1;
    cout << (B - A + 1) - (c_ + d_) + e_ << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,a[2005],in[2005];
bool vis[2005];
priority_queue<int> pq;
vector<int> g[2005],g1[2005];
void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<g1[x].size();i++)
		if(!vis[g1[x][i]])
		{
			in[g1[x][i]]++;
			g[x].push_back(g1[x][i]);
			dfs(g1[x][i]);
		}
}
void topo()
{
	for(int i=1;i<=n;i++)
		if(!in[i])
			pq.push(i);
	while(!pq.empty())
	{
		int now=pq.top();
		pq.pop();
		cout<<a[now]<<' ';
		for(int i=0;i<g[now].size();i++) pq.push(g[now][i]);
	}
	cout<<endl;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])!=1)
			{
				g1[i].push_back(j);
				g1[j].push_back(i);
			}
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	topo();
	return 0;
}


Measured memory_bytes: 17792
n = int(input())
rest_list = []
for i in range(n):
    each_input = input().split()
    rest_list.append((i, each_input[0], int(each_input[1])))
   
rest_list.sort(key=(lambda x: x[2]), reverse=True)
rest_list.sort(key=(lambda x: x[1]))
print(*[i[0]+1 for i in rest_list], sep='\n')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());

		int[][] map = new int[n][n];
		int[][] tmpj = new int[n][n + 1];
		
		for (int i = 0; i < n; i++) {
			String[] nico = sc.nextLine().split(" ");
			
			tmpj[i][0] = 0;
			for (int j = 0; j < n; j++) {
				map[i][j] = Integer.parseInt(nico[j]);

				tmpj[i][j + 1] = tmpj[i][j] + map[i][j];
			}
		}
		
		int max = Integer.MIN_VALUE;
		for (int si = 0; si < n; si++) {
			for (int ei = (si + 1); ei <= n; ei++) {

				for (int sj = 0; sj < n; sj++) {
					for (int ej = (sj + 1); ej <= n; ej++) {
						
						int sum = 0;
						for (int i = si; i < ei; i++) {
							sum = sum + tmpj[i][ej] - tmpj[i][sj];
						}
						if (max < sum) max = sum;
					}
				}
			}
		}
		
		System.out.println(max);
	}
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		cnt += __builtin_ctz(a[i]);
	}
	cout << cnt << endl;
	return 0;
}


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

int n, k, a[5010];
typedef unsigned long long ull;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=1; i<=n; ++i) cin >> a[i];
	sort(a+1, a+n+1);
	int l = 0, r = n+1;
	while(l+1 != r){
		int m = (l + r) / 2;
		int v[5010] = {};
		for(int i=1; i<=n; ++i){
			if(i < m) v[i] = a[i];
			if(i > m) v[i-1] = a[i];
		}
//		cout << m << " " << a[m] << "\n";
//		for(int i=1; i<=n-1; ++i) cout << i << " " << v[i] << "\n";
		ull dp[5010][80] = {{}};
		dp[0][0] = (ull)1;
		for(int i=1; i<=n-1; ++i){
			dp[i][0] |= 1;
			for(int j=0; j<80; ++j)
				dp[i][j] = dp[i-1][j];
			int x = v[i] / 64, y = v[i] % 64;
			if(x < 80) dp[i][x] |= (ull)1 << y;
			for(int j=0; j+x<79; ++j){
				dp[i][j+x] |= dp[i-1][j+x] | (dp[i-1][j] << y);
				if(y > 0) dp[i][j+x+1] |= dp[i-1][j+x+1] | (dp[i-1][j] >> (64 - y));
			}
		}
		bool f = false;
//		for(int i=0; i<n; ++i) cout << i << "\n" << bitset<64>(dp[i][3]) << "\n" << bitset<64>(dp[i][2]) << "\n" << bitset<64>(dp[i][1]) << "\n" << bitset<64>(dp[i][0]) << "\n";
		for(int i=max(0, k-a[m]); i<=k-1; ++i){
//			if(a[m] == 120 && i == 51)
//				cout << bitset<64>(dp[n-1][0]) << "\n";
			if((dp[n-1][i/64] >> (i%64)) % 2 == 1){
				f = true;
//				cout << a[m] << " " << i << "\n";
			}
		}
		if(f) r = m;
		else l = m;
	}
	cout << l << "\n";
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	ll k; cin >> k;
	ll sum_lcm = 1;
	ll ng = 1;
	ll cnt = -1;
	rep(i,0,n){
		ll a; cin >> a;
		ng = (ng * a) / __gcd(ng,a);
		a /= 2;
		ll b = a;
		ll j = 0;
		while(b % 2 == 0){
			b /= 2;
			j++;
		}
		if(i == 0)cnt = j;
		else{
			if(cnt != j){
				cout << 0 << endl;
				return 0;
			}
		}
		sum_lcm = (sum_lcm*a) / __gcd(sum_lcm,a);
	}
	ll ans = k / sum_lcm - k / ng;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	long long n,k,s;
	cin>>n>>k>>s;
	if(s!=1000000000){
		for(int i=0;i<k;i++){
			cout<<s<<" ";
		}
		for(int i=0;i<n-k;i++){
			cout<<1000000000;
			if(i!=n-k-1){
				cout<<" ";
			}else{
				cout<<endl;
			}
		}
	}else{
		for(int i=0;i<k;i++){
			cout<<s<<" ";
		}
		for(int i=0;i<n-k;i++){
			cout<<1;
			if(i!=n-k-1){
				cout<<" ";
			}else{
				cout<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
inline int read() {
	int x=0,s=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') s=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return s*x;
}

const int MAXN=400005,Mo=1000000007;
int n,m,q;
ll A,B,a[MAXN],b[MAXN];
bool check(ll x){
	ll num=0;
	FOR(i,1,n)
	if (a[i]>x*B) {
		ll y=a[i]-x*B;
		num+=(y+A-1)/A;
		if (num>x) return false;
	}
	return true;
}
int main(){
	n=read();
	A=read(),B=read();
	A-=B;
	FOR(i,1,n) a[i]=read();
	int l=0,r=1e9+1,mid;
	while (l+1<r) {
		mid=(l+r)/2;
		if (check(mid)) r=mid; else l=mid;
	}
	printf("%d\n",r);
	
	return 0;
}

/*
*/


Measured memory_bytes: 2304
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;



int main() {
    map<string,int> m;
    m["SUN"] = 7;m["MON"] = 6;m["TUE"] = 5;m["WED"] = 4;
    m["THU"] = 3;m["FRI"] = 2;m["SAT"] = 1;
    string S; cin >> S;
    cout << m[S] << endl;
}



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

poll = {}

for _ in range(n):
  i = input()
  if poll.get(i) is None:
    poll[i] = 1
  else:
    poll[i] += 1

maxVotes = max(poll.values())
ans = []
for key in poll.keys():
  if poll[key] == maxVotes:
    ans.append(key)

ans.sort()
for i in ans:
  print(i)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << ((a > b) ? a - 1 : a) << '\n';
    return (0);
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] u = new int[n];
		int[] d = new int[n];
		long dall = 0;
		for(int i = 0; i < n; i++) {
			u[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
			dall += d[i];
		}
		long b = u[0];
		long ans = b + dall;
		for(int i = 0; i < n-1; i++) {
			b += u[i+1];
			dall -= d[i];
			long now = b + dall;
			if(now > ans) {
				ans = now;
			}
		}
		if(n == 1) {
			ans = u[0] + d[0];
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

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

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

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

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

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

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


Measured memory_bytes: 32828
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool ca2(int x,int y,int d){
	if(d%4==0){
		return ca2(x/2,y/2,d/4);
	}
	if(d%2==0){
		if(x%2==0) return true;return false;
	}
	if((x+y)%2==0) return true;return false;
}
bool cal(int x,int y,int d1,int d2){
	if(d1%4!=0 && d2%4!=0){
		if(x%2==0 && y%2==0) return true;return false;
	}
	if(d1%4==0 && d2%4==0){
		return cal(x/2,y/2,d1/4,d2/4);
	}
	if(d1%4==0) swap(d1,d2);
	if(d1%2==0){
		if(x%2==0) return ca2(x/2,y/2,d2/4);return false;
	}
	if((x+y)%2==0) return ca2(x/2,y/2,d2/4);return false;
}
int main()
{
	int n,d1,d2;
	vector<pint> out;
	cin>>n>>d1>>d2;
	rep(i,n*2) rep(j,n*2){
		if(cal(i,j,d1,d2)) out.pb(mp(i,j));
	}
	assert(out.size()>=n*n);
	rep(i,n*n){
		cout<<out[i].fi<<' '<<out[i].se<<endl;
	}
}


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

int main(){
  string A, B, U; cin >> A >> B;
  int a, b; cin >> a >> b;
  cin >> U;
  if(U==A){
    cout << a-1 << " " << b << endl;
    return 0;
  }
  cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
using namespace std;
int main() {
	string s;
	cin>>s;
	int sum=0;
	int a=s.size();
	for(int i=0;i<a;i++){
		if((s[i]=='W'&&s[i+1]=='B')||(s[i]=='B'&&s[i+1]=='W')){sum++;}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
void solve(int i) {
	int k; cin >> k;
	cout << "Case " << i << ":\n";
	for (int i = 0; i < 10; i++) {
		k = (k*k / 100) % 10000;
		cout << k << endl;
	}
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		solve(i + 1);
	}
}

Measured memory_bytes: 2980
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n; cin>>n;
	int l[2*n]; forn(i,2*n) cin>>l[i];

	sort(l, l+2*n);
	int ans = 0;
	forn(i, 2*n){
		if(i%2 == 0) ans += l[i];
	}
	cout<<ans<<ln;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
let N = stdin.ReadLine() |> int

let L =
    stdin.ReadLine().Split()
    |> Array.map int
    |> Array.sort

let isDifferent3 x y z =
    if x <> y && y <> z && z <> x then true
    else false

let rec solver r i j k =
    if i = N then r
    elif j = N then solver r (i + 1) (i + 2) (i + 3)
    elif k = N then solver r i (j + 1) (j + 2)
    elif isDifferent3 L.[i] L.[j] L.[k] && L.[i] + L.[j] > L.[k] then solver (r + 1) i j (k + 1)
    else solver r i j (k + 1)

solver 0 0 1 2 |> stdout.WriteLine


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

int main()
{
    string S;
    cin >> S;
    if (S == "RRR")
    {
        cout << 3 << endl;
    }
    else if (S == "SRR" || S == "RRS")
    {
        cout << 2 << endl;
    }
    else if (S == "SSS")
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const long long Maxn=100000;
long long n,sum=0;
long long a[Maxn],b[Maxn],c[Maxn];
int main()
{
	long long ans,ant;
	cin>>n;
	for(int j=0;j<n;j++)
	cin>>a[j];
	for(int j=0;j<n;j++)
		cin>>b[j];
	for(int j=0;j<n;j++)
		cin>>c[j];
    sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	for(int i=0;i<n;i++)
	{
		ans=lower_bound(a,a+n,b[i])-a;
		ant=upper_bound(c,c+n,b[i])-c;
		sum+=ans*(n-ant);
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
int A[21], B[21], C[21];

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

  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N-1) cin >> C[i+1];
  int ans = 0;
  int tmp = -10;
  rep(i, N){
    int a = A[i];
    a--;
    ans+=B[a];
    if (a==tmp+1) ans+=C[a];
    tmp = a;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,t;
    cin >> n >> t;
    vector<ll> arr(n),vals(n);
    vector<vector<ll>> dp(n,vector<ll>(t+1,0));
    F0R(i,n)
        cin >> arr[i] >> vals[i];
    F0R(i,n)
        dp[i][0]=0;
    F0R(j,t+1)
    {
        if(arr[0]<=j)
            dp[0][j]=vals[0];
    }
    // cout << "REACHED HERE" << endl;
    FOR(j,1,t+1)
    {
        FOR(i,1,n)
        {
            dp[i][j]=dp[i-1][j];
            if(j-arr[i]>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i]]+vals[i]);
        }
    }
    // cout << "FINISHED" << endl;
    ll best=-1;
    F0R(i,n)
        best=max(best,dp[i][t]);
    cout << best << endl;

    return 0;
}


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

int ecd(int a, int b){
    if (b == 0){
        return a;
    }
    return ecd(b, a%b);
}

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

    int sign = 0;
    for (int i = 0; i<n; i++){
        int a;
        cin >> a;
        a = abs(x-a);

        if (sign == 0){
            sign = a;
            continue;
        }

        if (sign > a){
            sign = ecd(sign, a);
        }else if (a > sign){
            sign = ecd(a, sign);
        }else if (a == sign){
            sign = a;
        }
    }

    cout << sign << endl;
}

Measured memory_bytes: 256