akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,k,S,T;
int a[55];
ll c[55][55],C[55][55];

void solve(){
  cin >> n >> k >> S >> T;
  int i=0,cnt=0;
  rep(j,18){
    if(((1 << j)&S)!=0) continue;
    if(((1 << j)&T)==0) continue;
    cnt+=1;
  }
  rep(_,n) {
    int p,q=0,id=0;cin >> p;
    rep(j,18){
      if(((1 << j)&S)!=0) continue;
      if(((1 << j)&T)==0) continue;
      q|=(((p&(1 << j))>>j)<<id);
      id++;
      //cout << p << " " << q << endl;
    }
    if((p&S)!=S) continue;
    if((p|T)!=T) continue;
    a[i]=q;
    i++;
  }
  rep(i,n){
    c[i][0]=1;
    rep(j,k){
      c[i+1][j+1]=c[i][j]+c[i][j+1];
    }
  }
  rep(i,n+1){
    C[i][0]=1;
    rep(j,k){
      C[i][j+1]=C[i][j]+c[i][j+1];
    }
  }
  // rep(i,n+1){
  //   rep(j,k+1){
  //     cout << i << " " << j << " " << c[i][j] << " " << C[i][j] << endl;
  //   }
  // }
  n=i;
  //cout << cnt << endl;
  // rep(i,n){
  //   cout << a[i] << endl;
  // }
  ll ans=0;int U=(1 << cnt);
  Rep(K,1,U){
    int popcount=0;
    rep(i,cnt){
      if(K&(1 << i))popcount+=1;
    }
    map<int,int> ma;
    rep(i,n){
      ma[a[i]&K]+=1;
    }
    ll res=0;
    for(auto t:ma){
      //cout << bitset<2>(t.first) << " " << t.second << " " << C[t.second][k]-1 << endl;
      res+=C[t.second][k]-1;
    }
    res+=1;
    //cout << bitset<2>(K) << " " << res << endl;
    if(popcount%2)ans+=res;
    else ans-=res;
  }
  cout << C[n][k]-ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3704
///                      BISMILLAHIR RAHMANIR RAHEEM
///                  ||\  ||    /\    |''\   ||  ||\  /||
///                  || \ ||   /__\   |   |  ||  || \/ ||
///                  ||  \||  /    \  |../   ||  ||    ||
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mxi 99999
using namespace std;

//*****************Data type**********************//
typedef long long ll;
typedef long long int lli;
typedef unsigned long long  ull;
typedef unsigned long long int ulli;

//****************SET**************************//
typedef set<int> SI;
typedef set<string> SS;
typedef set<char>SC;
typedef multiset<int>MSI;

//*****************Map****************************//
typedef map<int, int> mp;
typedef map<int, string> mps;
typedef map<int, char>mpc;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;

//****************Pair****************************//
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<char, char> pcc;
typedef pair<int, string> pis;
typedef pair<int, char> pic;

//*****************Vector************************//
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<lli> VLLI;
typedef vector<VI> VVI;
typedef vector<pii> VPI;

int main()
{
    int x,y,z,t,p;cin>>x>>y>>z;
    t=x;x=y;y=t;
    p=x;x=z;z=p;
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


///...........Alhamdulillah.........///








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

long long int a,b,n,m;

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

int main()
{
	while(cin>>a>>b)
	{
		n = gcd(a,b);
		m = a * b / n;
		cout<<n<<" "<<m<<endl;
	}
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, k;
    cin >> n >> k;
    long long r;
    r = n%k;
    long long tmp;
    long long ans;
    tmp = (long long)abs(r-k);
    ans = min(tmp,r);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
    ll N, X, M;
    cin >> N >> X >> M;

    // M が小さい、かつ A_{n + 1} は A_n から一意に定まる→周期を求めれば良さそう
    vector<ll> flag(M, -1);
    ll now = X;
    ll ind = 0;
    ll sum = 0;
    while(flag[now] == -1) {
        flag[now] = ind;
        sum += now;
        now = now * now % M;
        ind++;
        if (ind == N) {
            cout << sum << endl;
            return;
        }
    }
    ll d = ind - flag[now];
    ll target = flag[now];

    sum = 0;
    now = X;
    for(ll i = 0; i < target; i++) {
        sum += now;
        now = now * now % M;
    }

    ll p = 0;
    for(ll i = 0; i < d; i++) {
        p += now;
        now = now * now % M;
    }

    ll ans = sum + (N - target) / d * p;
    for(ll i = 0; i < (N + d - target) % d; i++) {
        ans += now;
        now = now * now % M;
    }

    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>

using namespace std;

long long int combination2(long long int c);

int main() {
    long long int N, sum = 0;
    cin >> N;

    vector<long long int>A(N), B(N + 1), C(N + 1);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[i] = 0;
        C[i] = 0;
    }

    for (int i = 0; i < N; i++) {
        B[A[i]] ++;
    }


    for (int i = 0; i <= N; i++) {
        sum += combination2(B[i]);
    }

    for (int i = 0; i < N; i++) {
        if (C[A[i]] == 0) {
            C[A[i]] = sum - B[A[i]] + 1;
            cout << C[A[i]] << "\n";
        }
        else {
            cout << C[A[i]] << "\n";
        }
    }

    return 0;
}


long long int combination2(long long int c) {
    long long int ans;
    ans = c * (c - 1) / 2;
    return ans;
}



Measured memory_bytes: 7992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s; cin >> s;
	string a, b;
	a = s.substr(0, s.size() / 2);
	b = s.substr(s.size() / 2);
	reverse(all(b));
	int res = a.size();
	rep(i, a.size())
	{
		if (a[i] == b[i])--res;
	}
	cout << res << endl;
}

Measured memory_bytes: 384
n = STDIN.gets.to_i
n = STDIN.gets.split.map(&:to_i)
count = 0
n.size.times do |i|
    min = i
    (i..(n.size-1)).each do |j|
        if n[j] < n[min]
            min = j
        end
    end
    if min != i
        count += 1
        n[i], n[min] = n[min], n[i]
    end
end
puts n.join(' ')
puts count

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	ll r, D, x;
	cin >> r >> D >> x;

	for(int i = 0; i < 10; i++){
		x *= r;
		x -= D;
		cout << x << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
n,m,x = map(int, input().split())
c= []
a= []
ans = float('inf')
for i in range(n):
    c_tmp, *a_tmp = map(int, input().split())
    c.append(c_tmp)
    a.append(a_tmp)


cost_l =[]

for i in range(2 ** len(c)):
    cost = 0
    skill = [0]*m
    for j in range(len(c)):  
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(m):
                skill[k] += int(a[j][k])
    
    f = 0
    for j in range(m):
        if skill[j] < x:
            f = 1
            break
    if f == 0:
        cost_l.append(cost)
            
if cost_l != []:
    print(min(cost_l))
else:
    print("-1")

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M, C,l,ans=0;
    cin >> N >> M >> C;
    int A[N][M], B[M];
    for (int i = 0; i < M;i++){
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < N; i++)
    {
        l = C;
        for (int j = 0; j < M; j++)
        {
            l += A[i][j] * B[j];
        }
        if (l > 0)
            ans++;
        }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,k,sum=0,modi=1000000007;
	cin>>n>>k;
	vector<long long int> a(n+1),b(n+1);
	for(int i=0;i<=n;i++){
		sum+=i;
		a[i]=sum;
	}
	sum=0;
	for(int i=n;i>=0;i--){
		sum+=i;
		b[i]=sum;
	}
	sum=0;
	for(int i=k;i<=(n+1);i++){
		//cout<<b[n+1-k]<<" "<<a[i-1]<<" "<<endl;
		//cout<<(sum%modi+(b[n+1-i]%modi-a[i-1]+1)%modi)%modi<<endl;	
		sum=(sum%modi+(b[n+1-i]-a[i-1]+1)%modi)%modi;
		//break;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 6372
import kotlin.math.roundToInt

fun main(args: Array<String>) {
    var a = 100L
    val n = readLine()!!.toLong()
    for (i in 1 until 10000){
        a = (a * 1.01).toLong()
        if (a >= n)
        {
            println(i)
            break
        }
    }
}


Measured memory_bytes: 34444
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"

	"sort"
	"strconv"
	"strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	m := make(map[int]struct{})
	lines, _ := ReadLongLines(4)
	a := strings.Split(lines[1], " ")
	for i := range a {
		n, _ := strconv.Atoi(a[i])
		m[n] = struct{}{}
	}

	result := make([]int, 0, 200000)

	b := strings.Split(lines[3], " ")
	for i := range b {
		n, _ := strconv.Atoi(b[i])
		if _, ok := m[n]; ok {
			result = append(result, n)
		}
	}
	sort.Slice(result, func(lhs, rhs int) bool {
		return result[lhs] < result[rhs]
	})
	for j := range result {
		con.Printf("%d\n", result[j])
	}
}



Measured memory_bytes: 19548
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    bit = list(sys.stdin.readline().rstrip())
    print(2 * min(bit.count("0"), bit.count("1")))

Measured memory_bytes: 6380
#include <cstdio>
#include <iostream>
using namespace std;
int N, M;

long long _abs(long long num)
{
    return num > 0 ? num : num * -1;
}

int main()
{
    scanf("%d %d", &N, &M);
    printf("%lld", _abs((long long)(N - 2) * (M - 2)));
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
int st[100009],isl[100009],used[100009];
vector<int> con[100009];
queue<int> check;
int calc(int x,vector<int> vec){
	int s=0;
	sort(vec.begin(),vec.end());
	int mi=vec[vec.size()-1];
	if(x<mi)return -1;
	if(vec.size()==1){
		if(vec[0]==x)return x;
		else return -1;
	}
	if(vec.size()>1){
		for(int i=0;i<vec.size();i++){
			s+=vec[i];
		}
		if(s>2*x)return -1;
		if(s<x)return -1;
		else return 2*x-s;
	}
	return -1;
}
int main(){
	int n,x,y;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>st[i];
	}
	for(int i=0;i<n-1;i++){
		cin>>x>>y;
		con[x].push_back(y);
		con[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if(con[i].size()==1){
			isl[i]=1;
			check.push(i);
		}
	}
	if(n==2){
		if(st[1]==st[2])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
		return 0;
	}
	while(!check.empty()){
		int f=check.front();check.pop();
		int p=-1,wp=-1,sum=0,num=0,cnt=0;
		if(used[f]==0){
			for(int i=0;i<con[f].size();i++){
				if(used[ con[f][i] ] == 0){
					wp=con[f][i];
					i=114514;
				}
			}
			for(int i=0;i<con[wp].size();i++){
				if(isl[ con[wp][i] ] == 0){
					cnt++;
				}
			}
			if(cnt<=1){
				vector<int> v;
				v.clear();
				p=wp;
				for(int i=0;i<con[p].size();i++){
					if(isl[ con[p][i] ] == 1){
						v.push_back(st[ con[p][i] ]);
						used[ con[p][i] ] =1;
					}
				}
				int res = calc(st[p],v);
				if(res==-1){cout<<"NO"<<endl;return 0;}
				else st[p]=res;
				if(cnt==0){
					if(st[p]==0){cout<<"YES"<<endl;}
					else cout<<"NO"<<endl;
					return 0;
				}
				isl[p]=1;
				check.push(p);
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
  	if(a==1) a=100;
  	if(a==2) a=300;
  	if(a==3) a=100;
  	if(a==4) a=200;
  	if(a==5) a=100;
  	if(a==6) a=200;
  	if(a==7) a=100;
  	if(a==8) a=100;
  	if(a==9) a=200;
  	if(a==10) a=100;
  	if(a==11) a=200;
  	if(a==12) a=100;
  	if(b==1) b=100;
  	if(b==2) b=300;
  	if(b==3) b=100;
  	if(b==4) b=200;
  	if(b==5) b=100;
  	if(b==6) b=200;
  	if(b==7) b=100;
  	if(b==8) b=100;
  	if(b==9) b=200;
  	if(b==10) b=100;
  	if(b==11) b=200;
  	if(b==12) b=100;
  
    //出力
    if(a==b) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = (ll)1e9+7;
//}}}

int a[100002];
int ab[100000];
int b[100000];
int bc[100000];
int c[100000];
int main(){
  int N;
  cin >> N;
  a[0] = 0;
  rep(i, N) cin >> a[i + 1];
  a[N + 1] = 0;
  int sum = 0;
  rep(i, N + 1){
    sum += abs(a[i] - a[i + 1]);
  }
  rep(i, N){
    int ans;
    ans = sum;
    ans -= abs(a[i + 1] - a[i]) + abs(a[i + 2] - a[i + 1]) - abs(a[i + 2] - a[i]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int Q = scanner.nextInt();
        long A[] = new long[N];
        for(int i = 0; i < N; i++){
            A[i] = scanner.nextInt();
        }
        boolean flag[] = new boolean[N + 1];
        long ans = (long)1e18;
        flag[N] = true;
        for(int loop = 0; loop < N; loop++){
            ArrayList<Long> v = new ArrayList<>(), v_tmp = new ArrayList<>();
            for(int i = 0; i <= N; i++){
                if(flag[i]){
                    Collections.sort(v_tmp);
                    for(int j = 0; j <= v_tmp.size() - K; j++){
                        v.add(v_tmp.get(j));
                    }
                    v_tmp.clear();
                }else{
                    v_tmp.add(A[i]);
                }
            }
            if(v.size() >= Q){
                Collections.sort(v);
                ans = Math.min(ans, v.get(Q - 1) - v.get(0));
            }
            int pos = 0;
            long num = (long)1e18;
            for(int i = 0; i < N; i++){
                if(!flag[i] && A[i] < num){
                    pos = i;
                    num = A[i];
                }
            }
            flag[pos] = true;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 63612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, a; std::cin >> n >> a;
    std::cout << (n % 500 <= a ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())

    d_a = (a+1)//2*b*c - a//2*b*c
    d_b = (b+1)//2*a*c - b//2*a*c
    d_c = (c+1)//2*a*b - c//2*a*b

    print(min(d_a, d_b, d_c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    ll x, y; cin >> x >> y;

    ll ans = LLINF;
    rep(rx, 2) rep(ry, 2) {
        ll cx = x, cy = y;
        if (rx) cx = -cx;
        if (ry) cy = -cy;
        if (cx > cy) continue;
        chmin(ans, cy-cx + rx + ry);
    }
    cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int mod=1000000007;
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
int fact[6666666];
int inv[6666666];

int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

signed main(){
    fact[0]=1;
    for(int i=1;i<6666666;i++)fact[i]=fact[i-1]*i%mod;
    inv[6666666-1]=mpow(fact[6666666-1],mod-2);
    for(int i=6666666-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    int a,b,c,x,y;
    while(cin>>a>>b>>c>>x>>y,a||b||c||x||y){
        int n=a+b+c;
        int t=min(x,y);
        int ans=0;
        for(int i=0;i<=t;i++){
            int w=C(i+n-1,i);
            w=w*C(n,a)%mod*C(n-a,b)%mod;
            int xx=x-i-a;
            int yy=y-i-b;
            if(xx<0||yy<0)continue;
            if(a)w=w*C(xx+a-1,xx)%mod;
            else if(xx>0)continue;
            if(b)w=w*C(yy+b-1,yy)%mod;
            else if(yy>0)continue;
            ans=(ans+w)%mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 107136
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;

int main(){
long long X;
cin >> X;
long long P = 100, step = 0;
 while(P < X){
 P += P / 100;
 step++;
 }
  cout << step << endl;
 return 0;
 }

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

ll N, M;

int main(){
	scanf("%lld %lld", &N, &M);
	ll res = 1;
	for(ll i = 1; i * i <= M; i++){
		if(M % i == 0 && i * N <= M) res = max(res, i);
		if(M % i == 0 && (M / i) * N <= M) res = max(res, M / i);
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a:u32 = read();
    let b:u32 = read();
    println!("{}",a*b);

}


Measured memory_bytes: 2108
def all_divisor(n):
    small = [1]
    large = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if not (n % i):
            small.append(i)
            large.append(n//i)
    large.reverse()
    divisor = small + large
    return divisor

n, k = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
divisor = all_divisor(sum_a)
ans = 1
for i in reversed(divisor):
  t = 0
  b = []
  d = 0
  for j in a:
    b.append(j % i)
  c = sum(b)
  b.sort()
  for x in reversed(b):
    c -= x
    d += i - x
    if c == d:
      if c <= k:
        print(i)
        exit()
print(ans)


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

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

	string s;
	vector<int> pr(n + 1, 0);
	vector<int> pg(n + 1, 0);
	vector<int> pb(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		char c;
		cin >> c;
		s += c;

		pr[i] = pr[i - 1];
		pg[i] = pg[i - 1];
		pb[i] = pb[i - 1];
		if (c == 'R') {
			++pr[i];
		} else if (c == 'G') {
			++pg[i];
		} else {
			++pb[i];
		}
	}

	long long sum = 0;
	for (int i = 0; i < n - 2; ++i) {
		for (int j = i + 1; j < n - 1; ++j) {
			if (s[i] == s[j]) {
				continue;
			}

			if (s[i] == 'R' && s[j] == 'G' || s[i] == 'G' && s[j] == 'R') {
				sum += pb[n] - pb[j];
				if (s[j + j - i] == 'B') {
					--sum;
				}
			} else if (s[i] == 'R' && s[j] == 'B' || s[i] == 'B' && s[j] == 'R') {
				sum += pg[n] - pg[j];
				if (s[j + j - i] == 'G') {
					--sum;
				}
			} else {
				sum += pr[n] - pr[j];
				if (s[j + j - i] == 'R') {
					--sum;
				}
			}
		}
	}

	cout << sum;
	
	return 0;
}
	

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    start();
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    	sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)ans+=a[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
int a[1000000];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int in;
		scanf("%d",&in);
		a[in]++;
		a[in-1]++;
		a[in+1]++;
	}
	std::sort(a,a+1000000);
	printf("%d",a[999999]);
	return 0;
}

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

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int cnt=0;
  for(int i=l;i<=r;i++){
    if(i%d == 0){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return(0);
}

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

using namespace std;

const int MAXN = 105;
int N;
int A[MAXN];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = 0;
    int cnt = 1;
    int curElem = A[0];
    for (int i = 1; i < N; i++) {
        if (A[i] != curElem) {
            curElem = A[i];
            ans += cnt / 2;
            cnt = 1;
        } else {
            cnt++;
        }
    }
    ans += cnt / 2;
    cout << ans << endl;
}

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

using namespace std;
#define ll long long
const ll MAXN=1e8;
bool f[MAXN]={0};
ll sqr(ll a){return a*a;};
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if (c-a-b>0 && 4*a*b<sqr(c-b-a))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}


int main(void){
    int A,B,Q;
    cin>>A>>B>>Q;
    
    vector<long long> s(A+2),t(B+2),x(Q);
    s[0]=t[0]=-INF;
    s[A+1]=INF;
    t[B+1]=INF;
    
    for(int i=1;i<A+1;i++)cin>>s[i];
    for(int i=1;i<B+1;i++)cin>>t[i];
    for(int i=0;i<Q;i++)cin>>x[i];
        
    
    for(int i=0;i<Q;i++){
        long long a[4];
        
        a[0]=s[former(s,x[i])];
        a[1]=s[latter(s,x[i])];
        a[2]=t[former(t,x[i])];
        a[3]=t[latter(t,x[i])];

        long long ans=INF;
        for(int j=0;j<4;j++){
            if(j<2){
                for(int k=2;k<4;k++){
                    long long L=abs(x[i]-a[j])+abs(a[j]-a[k]);
                    ans=min(L,ans);
                }
            }else{
                for(int k=0;k<2;k++){
                    long long L=abs(x[i]-a[j])+abs(a[j]-a[k]);
                    ans=min(L,ans);
                }                
            }
        }
        cout<<ans<<endl;
    }
    
}


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

int main() {
  int N;
  cin >> N;
  int64_t L1,L2,L3;
  L1=2;
  L2=1;
  if(N==1){
    cout << 1 << endl;
  }else{
    for(int i=0;i<N-1;i++){
      L3=L2+L1;
      L1=L2;
      L2=L3;
    }
    cout << L3 << endl;
  }
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
    int n, i;
    char u[10][3];
    float x[10], total = 0;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%f %s", &x[i], &u[i]);
    }

    for(i=0; i<n; i++){
        if(u[i][0] == 'B'){
            total += x[i] * 380000.0;
        }
        else{
            total += x[i];
        }
    }

    printf("%f\n", total);

    return 0;
}

Measured memory_bytes: 128
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,x,a,ans;
long long gcd(long long x,long long y){return (x%y==0 ? y : gcd(x%y,x));
}
int main()
{
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a);a-=x;
		a=(a<0 ? -a : a);
		if(!ans) ans=a;
		ans=gcd(a,ans);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

LL dp[48][1000048];
int n,X,Y,Z;
vector<Pair> can[1000048];

LL quick_pow(LL x,LL y)
{
	x%=MOD;LL res=1;
	while (y)
	{
		if (y&1)
		{
			res=(res*x)%MOD;
			y--;
		}
		x=(x*x)%MOD;
		y>>=1;
	}
	return res;
}

int num[48],num1[48];
int doit(int Mask,int cur)
{
	int res=0,i;
	for (i=1;i<=X+Y+Z;i++)
		if (Mask&(1<<(i-1))) num[i]=1; else num[i]=0;
	for (i=1;i<=X+Y+Z;i++) num1[i]=0;
	for (i=1;i<=X+Y+Z;i++)
		if (num[i] && i+cur<=X+Y+Z) num1[i+cur]=1;
	num1[cur]=1;
	for (i=1;i<=X+Y+Z;i++)
		if (num1[i]) res|=(1<<(i-1));
	return res;
}

int main ()
{
	int i,cur,Mask,toMask,nMask,totype,type;
	n=getint();X=getint();Y=getint();Z=getint();
	dp[0][0]=1;
	nMask=0;
	nMask|=(1<<(Z-1));
	nMask|=(1<<(Y+Z-1));
	nMask|=(1<<(X+Y+Z-1));
	for (Mask=0;Mask<=(1<<(X+Y+Z))-1;Mask++)
	{
		can[Mask].clear();
		for (cur=1;cur<=10;cur++)
		{
			toMask=doit(Mask,cur);
			totype=((toMask&nMask)==nMask?1:0);
			if (totype==0) can[Mask].pb(mp(cur,toMask));
		}
	}
	for (i=0;i<=n-1;i++)
		for (Mask=0;Mask<=(1<<(X+Y+Z))-1;Mask++)
				if (dp[i][Mask])
				{
					//cout<<i<<' '<<Mask<<endl;
					for (int j=0;j<int(can[Mask].size());j++)
					{
						cur=can[Mask][j].x;toMask=can[Mask][j].y;
						dp[i+1][toMask]=(dp[i+1][toMask]+dp[i][Mask])%MOD;
					}
				}
	//cout<<"*"<<endl;
	LL ans=0;
	for (Mask=0;Mask<=(1<<(X+Y+Z))-1;Mask++)
		ans=(ans+dp[n][Mask]);
	//cout<<"*"<<endl;
	LL fans=quick_pow(10,n);
	fans-=ans;
	fans%=MOD;if (fans<0) fans+=MOD;
	cout<<fans<<endl;
	return 0;
	/*for (i=1;i<=n;i++)
		for (Mask=0;Mask<=(1<<(X+Y+Z))-1;Mask++)
			if ((Mask&nMask)==nMask) ans=(ans+dp[i][Mask])%MOD;
	cout<<ans<<endl;*/
	return 0;
}

Measured memory_bytes: 160640
#include <iostream>
using namespace std;
using ull = unsigned long long;
 
int main(){
    ull a, b, x, ans = 0;
    cin >> a >> b >> x;
    if(a == 0){ ans = b / x + 1; }
    else{
        ans = b / x - (a - 1) / x;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

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


Measured memory_bytes: 3192
// atcoder/abc164/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    set<str> vis;
    for (int i = 0; i < n; ++i) {
      str s;
      cin >> s;
      vis.insert(s);
    }
    cout << vis.size() << endl;
  }

  return 0;
}


Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    bool hantei=true;
    int n,m;
    cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    cin >> m;
    vector<ll> t(m);
    rep(i,m) cin >> t[i];
    
    map<ll,int> cnt_d;
    map<ll,int> cnt_t;
    rep(i,n) cnt_d[d[i]]++;
    rep(i,m) cnt_t[t[i]]++;
    
    rep(i,m){
        if(cnt_d[t[i]] < cnt_t[t[i]]) hantei = false;
    }
    if(hantei) cout << "YES" <<endl;
    else    cout << "NO" <<endl;


}

Measured memory_bytes: 28416
#include<cstdio>
#include<cstring>
 
int main(){
bool b[4][13];
int i,n,m;
char c;
memset(b,1,sizeof(b));
scanf("%d",&n);
for(i=0;i<n;i++){
scanf(" %c %d",&c,&m);
if(c=='S')b[0][m-1]=false;
if(c=='H')b[1][m-1]=false;
if(c=='C')b[2][m-1]=false;
if(c=='D')b[3][m-1]=false;
}
 
for(i=0;i<13;i++)if(b[0][i])printf("S %d\n",i+1);
for(i=0;i<13;i++)if(b[1][i])printf("H %d\n",i+1);
for(i=0;i<13;i++)if(b[2][i])printf("C %d\n",i+1);
for(i=0;i<13;i++)if(b[3][i])printf("D %d\n",i+1);

scanf("%d",&n);

return 0;
 
}

Measured memory_bytes: 1024
#include <stdio.h>

int main () {
	int angka1, angka2, angka3, rumus;
	scanf("%d %d %d", &angka1, &angka2, &angka3);
	rumus= angka1*angka2/2;
	printf("%d", rumus);
	
	return 0;
	
}

Measured memory_bytes: 1712
import math
from collections import Counter

N, A, B = map(int, input().split())
v = list(map(int, input().split()))

v.sort(reverse = True)
cnt_v = Counter(v)
ave = []

for i in range(A, B+1):
    ave.append(sum(v[0:i]) / i)

max_ave = max(ave)
ans = 0

for j in range(B-A+1):
    temp = 1
    if ave[j] == max_ave:
        #print(j)
        l = v[:A+j]
        cnt_l = Counter(l)
        for key, values in cnt_l.items():
            temp *= (math.factorial(cnt_v[key]) // math.factorial(values) // math.factorial(cnt_v[key] - values))
        ans += temp

print(max_ave)
print(ans)

Measured memory_bytes: 3316
r1,c1,r2,c2 = map(int,input().split())

mod = 10 ** 9 + 7
MAX = (10**6)*2 + 100
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()

ans = 0
for c in range(c1, c2+1):
    ans += ((r2+1)*fac[r1]*fac[c+r2+1]-r1*fac[r2+1]*fac[c+r1])*finv[c]*finv[r1]*finv[r2+1]*inv[c+1]
    ans %= mod
    
print(ans)

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

int main(){
	string in;
	int a[3] = { 1,0,0 }, x, y;
	while (true)
	{
		cin >> in;
		if (cin.eof()) { break; }
		x = in[0];
		y = in[2];
		int tmp = a[x - 65];
		a[x - 65] = a[y - 65];
		a[y - 65] = tmp;
	}
	for(int i=0;i<3;i++){
		if(a[i] == 1){
			string out;
			out = i + 65;
			cout << out << endl;
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);

  if (k == 1L ) {
    cout << 0 << endl;
    return 0;
  }

  if (n % k == 0L) {
    cout << 0 << endl;
    return 0;
  }

  set<long long> s;

  long long m = n;
  while (true) {
    // cout << m << " " << k << endl;
    
    // if (m == 1L || m == 0L) {
    //   break;
    // }
        
    if (m > k) {
      m = m % k;
    } else {
      m = abs(m - k);
    }

    if (s.find(m) == s.end()) {
      s.insert(m);
    } else {
      break;
    }
  }

  long long r = numeric_limits<long long>::max();
  // for ( auto& it = s.begin(); it != s.end() it++) {
  for (const auto& it : s) {
    r = min(r, it);
  }

  r = min(r, n);

  cout << r << endl;
  return 0;
}


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

int main() {
  vector <vector<int>> data(3,vector<int>(3));  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> data.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  int count=0;
  int ans=0;
  for(int i=0;i<N;i++){

    if(data.at(0).at(0)==a.at(i)){
      count++;
    }
    if(data.at(0).at(1)==a.at(i)){
      count++;
    }
    if(data.at(0).at(2)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
  for(int i=0;i<N;i++){

    if(data.at(1).at(0)==a.at(i)){
      count++;
    }
    if(data.at(1).at(1)==a.at(i)){
      count++;
    }
    if(data.at(1).at(2)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
for(int i=0;i<N;i++){
    
    if(data.at(2).at(0)==a.at(i)){
      count++;
    }
    if(data.at(2).at(1)==a.at(i)){
      count++;
    }
    if(data.at(2).at(2)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
for(int i=0;i<N;i++){
    
    if(data.at(0).at(0)==a.at(i)){
      count++;
    }
    if(data.at(1).at(0)==a.at(i)){
      count++;
    }
    if(data.at(2).at(0)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
for(int i=0;i<N;i++){
    
    if(data.at(0).at(1)==a.at(i)){
      count++;
    }
    if(data.at(1).at(1)==a.at(i)){
      count++;
    }
    if(data.at(2).at(1)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
for(int i=0;i<N;i++){

    if(data.at(0).at(2)==a.at(i)){
      count++;
    }
    if(data.at(1).at(2)==a.at(i)){
      count++;
    }
    if(data.at(2).at(2)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
      count=0;
for(int i=0;i<N;i++){
    if(data.at(0).at(0)==a.at(i)){
      count++;
    }
    if(data.at(1).at(1)==a.at(i)){
      count++;
    }
    if(data.at(2).at(2)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
 
  }
      count=0;
  for(int i=0;i<N;i++){
    
    if(data.at(0).at(2)==a.at(i)){
      count++;
    }
    if(data.at(1).at(1)==a.at(i)){
      count++;
    }
    if(data.at(2).at(0)==a.at(i)){
      count++;
    }
    if(count==3){
      ans=1;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
    else{
    cout<<"No"<<  endl;
}
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys


def search(x, y):
    x_length = len(x)
    y_length = len(y)
    memo = [[0] * (y_length + 1) for i in range(x_length + 1)]
    for i, ch_x in enumerate(x, 1):
        row = memo[i]
        pre_row = memo[i-1]
        for j, ch_y in enumerate(y, 1):
            if ch_x == ch_y:
                row[j] = pre_row[j-1] + 1
            elif pre_row[j] < row[j-1]:
                row[j] = row[j-1]
            else:
                row[j] = pre_row[j]
    return memo[-1][-1]


if __name__ == "__main__":
    n = int(input())
    strs = [list(val) for val in sys.stdin.read().splitlines()]
    result = [search(strs[i*2], strs[i*2+1]) for i in range(n)]
    print(*result, sep="\n")


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

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;

int a[30];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		a[(int)(s[i] - 'a')] ++;
	ll answer = 1;
	for (int i = 0; i < 26; i++)
		answer = answer * (a[i] + 1) % mod;
	cout << (answer - 1 + mod) % mod << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll L, R, res = 2 * 1e9;
	cin >> L >> R;
	for (int i = L; i < L + 5000 - 1 && i < R; ++i) {
		for (int j = i + 1; j < L + 5000 && j <= R; ++j) {
			res = min(res, (1LL * i * j) % 2019);
		}
	}
	cout << res;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <climits>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

typedef unsigned long long ll;
typedef vector<int> vec;
typedef vector<vec> mat;

mat mul(mat A, mat B) {
  mat C(A.size(), vec(B[0].size()));
  for (int i = 0; i < A.size(); ++i) {
    for (int k = 0; k < B.size(); ++k) {
      for (int j = 0; j < B[0].size(); ++j) {
        C[i][j] = min((C[i][j] + A[i][k] * B[k][j]), 1);
      }
    }
  }
  return C;
}

mat pow(mat A, ll z) {
  if (z == 1) return A;
  mat B = pow(A, z/2);
  if (z % 2 == 0) {
    return mul(B, B);
  }
  return mul(mul(B, B), A);
}

void printmat(const mat& m) {
  for (int i = 0; i < m.size(); ++i) {
    for (int j = 0; j < m[i].size(); ++j) {
      printf(" %d", m[i][j]);
    }
    puts("");
  }
}

int N, M, prv[102], cur[102];
ll Z;

int main() {
  while (scanf("%d%d%lld", &N, &M, &Z), N | M | Z) {
    int u, v;
    rep(i,M) {
      scanf("%d%d", &u, &v);
      --u; --v;
      prv[i*2] = u, cur[i*2] = v;
      prv[i*2+1] = v, cur[i*2+1] = u;
    }
    mat t(M*2+1, vec(M*2+1, 0));
    
    rep(i,2*M) {
      rep(j,2*M) {
        if (cur[i] == prv[j] && prv[i] != cur[j])
          t[i][j] = 1;
      }
    }

    rep(i,2*M) {
      if (prv[i] == 0)
        t[2*M][i] = 1;
    }

    t = pow(t, Z);

    bool ok = false;
    rep(i,2*M) {
      if (cur[i] == N-1 && t[2*M][i] != 0) {
        ok = true; break;
      }
    }
    
    puts(ok ? "yes" : "no");
  }
  return 0;
}

Measured memory_bytes: 2784
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(1000>=n)
    cout<<1000-n;
  if(1000<n && 2000>=n)
    cout<<2000-n;
  else if(2000<n && 3000>=n)
    cout<<3000-n;
  else if(3000<n && 4000>=n)
    cout<<4000-n;
  else if(4000<n && 5000>=n)
    cout<<5000-n;
  else if(5000<n && 6000>=n)
    cout<<6000-n;
  else if(6000<n && 7000>=n)
    cout<<7000-n;
  else if(7000<n && 8000>=n)
    cout<<8000-n;
  else if(8000<n && 9000>=n)
    cout<<9000-n;
  else if(9000<n && 10000>=n)
    cout<<10000-n;
}

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

typedef long long LL;

const int maxn = 10000 + 10;
const int mod = 998244353;

char a[maxn], b[maxn];
LL fac[maxn], ifac[maxn];

LL fpm(LL a, LL b) {
    LL res = 1;
    for(; b > 0; b >>= 1) {
        if(b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

void init() {
    fac[0] = 1;
    for(int i = 1; i < maxn; ++i) fac[i] = fac[i-1] * i % mod;

    ifac[maxn-1] = fpm(fac[maxn-1], mod-2);
    for(int i = maxn-1; i >= 1; --i) ifac[i-1] = ifac[i] * i % mod;
}

LL dp[2][maxn], ans;
LL M(LL x) { return x > 0 ? x : 0; }
LL C(int n, int k) {
    return fac[n] * ifac[k] % mod * ifac[n-k] % mod;
}

int main() {
    init();
    scanf("%s%s", a, b);

    int len = strlen(a), k = 0, n = 0;
    for(int i = 0; i < len; ++i) {
        if(a[i] == '1') ++ n;
        if(a[i] == '1' && b[i] == '0') ++ k;
    }

    if(k == 0) {
        return printf("%lld\n", fac[n]*fac[n] % mod), 0;
    }

    dp[1][0] = 1;
    int cur = 0;

    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= i && j <= k; ++j) {
            dp[cur][j] = 0;
            if(j) dp[cur][j] = dp[cur^1][j-1] * (k-j+1) % mod * (k-j+1) % mod;
            dp[cur][j] = (dp[cur][j] + M(n-k-i+1+j) * dp[cur^1][j] % mod * (k-j)) % mod;
        }
        //cerr << dp[cur][k] * C(n, i) % mod * fac[n-i] % mod * fac[n-i] % mod << endl;
        ans = (ans + dp[cur][k] * C(n, i) % mod * fac[n-i] % mod * fac[n-i] % mod) % mod;
        cur ^= 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512