akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static final int[] di = {-1,-1,-1,0,0,1,1,1};
	public static final int[] dj = {-1,0,1,-1,1,-1,0,1};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0) {
				break;
			}
			char[][] s = new char[h][];
			for(int i=0;i<h;i++) {
				s[i] = sc.next().toCharArray();
			}
			ArrayList<String> found = new ArrayList<String>();
			for(int i=0;i<h;i++) {
				for(int j=0;j<w;j++) {
					for(int k=0;k<8;k++) {
						StringBuilder sb = new StringBuilder();
						int ni = i;
						int nj = j;
						while(true) {
							sb.append(s[ni][nj]);
							ni = (ni + di[k] + h) % h;
							nj = (nj + dj[k] + w) % w;
							if (ni == i && nj == j) {
								break;
							}
						}
						found.add(sb.toString());
					}
				}
			}
			int maxl = 0;
			String maxs = "";
			Collections.sort(found);
			for(int i=0;i<found.size()-1;i++) {
				int l1 = found.get(i).length();
				int l2 = found.get(i+1).length();
				int l = Math.min(l1, l2);
				int matchl = 0;
				for(int j=0;j<=l;j++) {
					char c1 = j == l ? 'a' : found.get(i).charAt(j);
					char c2 = j == l ? 'b' : found.get(i+1).charAt(j);
					if (c1 != c2) {
						matchl = j;
						break;
					}
				}
				if (matchl >= maxl) {
					String matchs = found.get(i).substring(0, matchl);
					if (matchl > maxl || maxs.compareTo(matchs) > 0) {
						maxs = matchs;
					}
					maxl = matchl;
				}
			}
			if (maxl < 2) {
				System.out.println(0);
			}else{
				System.out.println(maxs);
			}
		}
	}

}

Measured memory_bytes: 48652
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
// ll mod = 998244353;
 ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 

ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}


ll n,m,num,sum,a,b,d,e,h,r,l,q;
ll w, ans;
ll k;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];

int main(){
    cin >> n >> k;
    c3_init();
    ans = 0;
    if(k > 2 * n){
        ans = c3(2*n-1, n-1);
    }else{
        k = min(k, n - 1);
        for(ll i=0;i<=k;i++){
            ll tmp1 = c3(n, i);
            ll tmp2 = c3(n - 1, n - i - 1);

            ans += (tmp1 * tmp2) % mod;
            ans %= mod;
        }
    }
    p(ans);
    return 0;

}


















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

int main(){
  int n,l;
  vector<string> v;
  string s;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(),v.end());
  for(int j=0;j<n;j++)
  {
    cout << v[j];
  }
  cout << endl;
  return 0;
}

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

int main(){
int n;cin>>n;
for (int i=1;i<=n;i++){
	if (i%3==0){
    	cout << " " << i;//test if 3 is factor of i
		}
	else if (i%10==3){
		cout <<" "<<i;//test if integer contains 3
		}
	else if (i>10 && i<100){
		int j=i/10;
		if (j%10==3){
			cout <<" "<<i;
		   }
   	}
	   	   	else if (i>100 && i<1000){
		int k=i/100;
   int j=i/10;
		if (k%10==3){
			cout <<" "<<i;
		   }
		else if (j%10==3){
			cout <<" "<<i;
		   }
   		  }
   		  	   	   	else if (i>1000){
		int l=i/1000;
				int k=i/100;
   int j=i/10;
		if (k%10==3){
			cout <<" "<<i;
		   }
		else if (j%10==3){
			cout <<" "<<i;
		   }
		else if (l%10==3){
			cout <<" "<<i;
		   }
   		  }
	}
	cout<<endl;
}


Measured memory_bytes: 3080
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

a= int(arr_data[0][0])
b= int(arr_data[0][1])

if a*b==15:
    
    print("*")
elif a+b==15:
    print("+")
else:
    print("x")


Measured memory_bytes: 3064
a1=[]
a2=[]
a3=[]
d=0
N,M=map(int, input().split())
for i in range(M):
 s,c=map(int, input().split())
 if N-s+1==3:
  if a1==[]:
   if c==0:
    if s==1:
     d+=1
    else:
     a1.append(c)
   else:
    a1.append(c)
  else:
   if c in a1:
    continue
   else:
    d+=1
 elif N-s+1==2:
  if a2==[]:
   if c==0:
    if s==2:
     d+=1
    else:
     a2.append(c)
   else:
    a2.append(c)
  else:
   if c in a2:
    continue
   else:
    d+=1
 else:
  if a3==[]:
   a3.append(c)
  else:
   if c in a3:
    continue
   else:
    d+=1
if a1==[]:
 a1.append(0)
if a2==[]:
 a2.append(0)
if a3==[]:
 a3.append(0)
if d>=1:
 print(-1)
else:
 if N==1:
  print(a3[0])
 elif N==2:
  print(max(a2[0],1)*10+a3[0])
 else:
  print(max(a1[0],1)*100+a2[0]*10+a3[0])


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

int main()
{
    ll A, B;
    cin >> A >> B;

    set<ll> primes;
    primes.insert(1);
    for (ll i = 2; i * i <= A; i++) {
        while (A % i == 0) {
            primes.insert(i);
            A /= i;
        }
    }
    if (A != 1) {
        primes.insert(A);
    }

    int ans = 0;
    for (ll prime: primes) {
        if (B % prime == 0) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

const int MxN=1e5+1;
bool dp[MxN];

int main() {
    string s; cin>>s;
    dp[0]=1;
    int n=s.size();
    for(int i=0;i<n;i++) {
        if(!dp[i]) continue;
        if(i<=n && s.substr(i, 7)=="dreamer") dp[i+7]=1;
        if(i<=n && s.substr(i, 6)=="eraser") dp[i+6]=1;
        if(i<=n && s.substr(i, 5)=="dream") dp[i+5]=1;
        if(i<=n && s.substr(i, 5)=="erase") dp[i+5]=1;
    }
    if(dp[n]) cout<<"YES \n";
    else cout<<"NO \n";
    return 0;
}

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

using namespace std;

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

    int n, x;
    cin >> n >> x;

    int k = 2 * n - 1;
    if (x == 1 || x == k) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";

    vector<char> used(k + 1);
    vector<int> ans(k + 1);
    for (int i = -1; i <= 1; ++i) {
        used[x + i] = true;
        ans[n + i] = x + i;
    }
    int p = 1;
    for (int i = 1; i <= k; ++i) {
        if (abs(n - i) <= 1) continue;
        while (used[p]) ++p;
        ans[i] = p;
        used[p] = true;
    }

    for (int i = 1; i <= k; i++) {
        cout << ans[i] << '\n';
    }
}


Measured memory_bytes: 2560
iA,iB,iC,iX,iY = map(int,input().split())


if iY > iX:
    iX,iY = iY,iX
    iA,iB = iB,iA
print(min(2*iC*iX ,iX*iA+iY*iB, (iA+iB)*iY+2*iC*(iX-iY),2*iC*iY+iA*(iX-iY)))


Measured memory_bytes: 3060
s = input()
yes = True
for i, c in enumerate(s):
    if i % 2 == 1 and c == 'R':
        #print(i)
        yes = False
    elif i % 2 == 0 and c == 'L':
        yes = False
        #print(i)
if yes:
    print('Yes')
else:
    print('No')
    


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll V, E;
struct Edge {
    ll from, to, cost;
};
vector<Edge> Edges;

//通常
struct UnionFind {
    VL par, rank;
    UnionFind(int size) { init(size); }
    void init(int size) {
        REP(i, size) {
            par.push_back(i);
            rank.push_back(0);
        }
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            swap(x, y);
        } else {
            if(rank[x] == rank[y]) rank[x]++;
        }
        par[y] = x;
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

signed main() {
    cin >> V >> E;
    REP(i, E) {
        LCIN(s, t, w);
        Edges.push_back({s, t, w});
    }
    sort(All(Edges),
         [](const Edge &x, const Edge &y) { return x.cost < y.cost; });
    auto uf = UnionFind(V);
    ll ans = 0;
    REP(i, E) {
        Edge e = Edges[i];
        if(!uf.same(e.from, e.to)) {
            uf.unite(e.from, e.to);
            ans += e.cost;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5928
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod = 1e9 +7;
void solve(){
    int n;
    
    ll sum=0;
    int a[1000000];
    cin>>n;
    for(int i=0; i< n; i++){
         cin>>a[i];
         sum +=a[i];
		sum %= mod;
            
    }
    ll ans= 0;
    for(int i = 0; i < n; i++){
			sum -= a[i];
			if (sum < 0) sum += mod;
			ans += a[i] * sum;
			ans %= mod;
		
		
		}
    

    cout<<ans<<"\n";

}
int main(){
    ios_base::sync_with_stdio(false); //macht programm I/O schneller
    cin.tie(NULL); //flush the io stream befor accepting your input
    solve();
}


Measured memory_bytes: 4368
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    count = 0
    for i in range(1,N):
        if A[i] == A[i-1]:
            count += 1
            A[i] = -1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();

    let mut B = A.clone();
    B.sort();

    let mut Ae = HashMap::new();
    let mut Be = HashMap::new();

    for i in 0..N{
        let a = A[i];
        let b = B[i];
        if i%2==0{
            let n:isize = *Ae.get(&a).unwrap_or(&0);
            let m:isize = *Be.get(&b).unwrap_or(&0);
            Ae.insert(a,n+1);
            Be.insert(b,m+1);
        }
    }

    let mut ans = 0;
    for (k,v) in Ae.into_iter(){
        let n = *Be.get(&k).unwrap_or(&0);
        ans += (v-n).abs();
    }
    println!("{}",ans);
}


Measured memory_bytes: 14536
#include <iostream>
using namespace std;
int main(){
int n;
  cin >> n;
  int a,b,c;
  a=n/100;
  b=(n%100)/10;
  c=n%10;
  cout << (a==1?9:1);
  cout<<(b==1?9:1);
  cout << (c==1?9:1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int year=atoi(S.substr(0,4).c_str()) ;
    int month=atoi(S.substr(5,2).c_str()) ;
    if(year<=2019 && month<=4)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    //cout<<year<<" "<<month<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string reverse(string s)
{
	char *rev_c = new char[s.size()];
	for (int i = s.size() - 1; i >= 0; i--)
	{
		rev_c[s.size() - 1 - i] = s[i];
 	}
	string rev_s(rev_c, s.size());
	delete rev_c;
	return rev_s;
}

int main()
{
	string s;
	cin >> s;
	cout << reverse(s) << endl;
	return 0;
}


Measured memory_bytes: 3044
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  char a[5];
  for(int i=0 ;i<6;i++)
  cin >> a[i];

  if(a[0]==a[5]&&a[1]==a[4]&&a[2]==a[3]) cout <<"YES"<<endl;
  else cout << "NO"<<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 rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;

    int x = 0;
    rep(i, n - 1) {
        x += x / (k - 1) + 1;
    }

    cout << x << endl;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
bool isPrime(long long n);
signed main(){
    long long N;
    cin>>N;
    long long a[N+5];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    long long sum=0;
    for(long long i=0;i<N;i++){
        
        if(isPrime(a[i])){
            sum++;
        }
    }
    cout<<sum<<'\n';
    return(0);
}

bool isPrime(long long n){
    if(n == 2)return true;
    if(n <=1 || n%2 == 0)return false;
    for(long long i=3;  i*i<=n; i+=2){
    if(n%i ==0)return false;
    }
    return true;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
//#include "mylib-cpp.h"

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> s(n);
    int tmp1, tmp2, ans=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<n;i++){
        tmp1 = 0;
        tmp2 = 0;
        for(int j=0;j<n;j++){
            if(i <= j)tmp1 += s[j];
            else tmp2 += s[j];
        }
        int res = tmp1 - tmp2;
        if(ans == 0 || abs(res) < ans) ans = abs(res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
 ll n;
 cin>>n;
 vector<ll> a(n);
 for(int i=0;i<n;i++)cin>>a.at(i);
 ll res=a.at(0);
 for(int i=1;i<n;i++){
 res^=a.at(i);
 }
 if(res==0)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
n = int(input())
abc = []
for _ in range(n):
    abc.append(list(map(int, input().split()))) 

dp = [[0]*3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,n):
    for j in range(3):
        if j == 0:
            dp[i][j] = max(dp[i-1][1], dp[i-1][2]) + abc[i][j]
        if j == 1:
            dp[i][j] = max(dp[i-1][0], dp[i-1][2]) + abc[i][j]
        if j == 2:
            dp[i][j] = max(dp[i-1][0], dp[i-1][1]) + abc[i][j]
print(max(dp[n-1]))

Measured memory_bytes: 74200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	string s,t; cin >> s >> t;
	V<int> a(si(s)+1), b(si(t)+1);
	rep(i,si(s)){
		a[i+1] = (a[i] + (s[i]=='A'?1:2))%3;
	}
	rep(i,si(t)){
		b[i+1] = (b[i] + (t[i]=='A'?1:2))%3;
	}
	int Q; cin >> Q;
	while(Q--){
		int c,d,e,f; cin >> c >> d >> e >> f; c--,e--;
		if((a[d]-a[c]+3)%3 == (b[f]-b[e]+3)%3) cout << "YES\n";
		else cout << "NO\n";
	}
}


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

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){___
  int n, k; cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  sort(a, a+n);
  cout << accumulate(a, a+k, 0) << "\n";
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 1000010;

struct edge{
        int to;
        double cost;
};

vector<vector<edge>> graph(bound);
// スタート地点から頂点 i への最短距離
vector<double> dist(bound);
bool flag[bound];

struct circle{
	double x;
	double y;
	double r;
};

int main(){
	int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
	int n; cin >> n;
	vector<circle> v(n+2);
	v[0].x = xs, v[0].y = ys, v[0].r = 0.0;
	v[1].x = xt, v[1].y = yt, v[1].r = 0.0;
	for( int i = 2; i < n+2; ++i ){
		cin >> v[i].x >> v[i].y >> v[i].r;
	}
	fill( dist.begin(), dist.end(), 4e9 );
	for( int i = 0; i < n+2; ++i ){
		for( int j = i+1; j < n+2; ++j ){
			double d = max(0.0, sqrt( (v[i].x-v[j].x)*(v[i].x-v[j].x) + (v[i].y-v[j].y)*(v[i].y-v[j].y) ) - v[i].r - v[j].r);
			// cout << i << ' ' << j << ": " << d << endl;
			graph[i].push_back((edge){j, d});
			graph[j].push_back((edge){i, d});
		}
	}
	// first: そこまでの距離(dist)
	// second: ノード(point) = 半径の番号
	priority_queue< pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>> > q;
	q.emplace(0.0, 0);
	dist[0] = 0;
	int cnt = 0;
	while( !q.empty() ){
		// s: スタート地点から punkt までの長さ
		double s = q.top().first;
		int punkt = q.top().second;
		q.pop();
		if( flag[punkt] ) continue;
		flag[punkt] = true;
		// cout << "point: " << punkt << ", dist: " << dist[punkt] << endl;
		for( auto nextp : graph[punkt] ){
				if( dist[nextp.to] <= s+nextp.cost ) continue;
				// cout << nextp.to << ' ' << nextp.cost << endl;				
				q.emplace( s+nextp.cost, nextp.to );
				dist[nextp.to] = s+nextp.cost;
		}
	}
	// cout << dist[0] << ' ' << dist[1] << ' ' << dist[2] << endl;
	cout << fixed << setprecision(10) << dist[1] << endl;
	return 0;
}

Measured memory_bytes: 53104
# include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	string sr = s;
	long long res = 0;
	sort(sr.begin() , sr.end());
	reverse(sr.begin() , sr.end());
	vector < int > vB , vW;
	for(int i = 0; i < s.size(); i ++){
		if(s[i] == 'B') vB.push_back(i);
		else vW.push_back(i);
	}
	reverse(vW.begin() , vW.end());
	reverse(vB.begin() , vB.end()); 
	for(int i = 0; i < sr.size(); i ++){
		if(sr[i] == 'W'){
			res += abs(vW.back() - i);
			vW.pop_back();
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>

#define ll long long
using namespace std;


int main() {
    int N,M;
    cin>>N>>M;
  
    cout << (N+M)%24 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a,b="CF";
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){
            bl++;
            if(bl==2)
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<bool> len1(10, false);
    vector<vector<bool>> len2(10, vector<bool>(10, false));
    vector<vector<vector<bool>>> ans(10, vector<vector<bool>>(10, vector<bool>(10, false)));

    len1[S[0]-'0'] = true;
    for (int x = 1; x < N; x++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                ans[i][j][S[x]-'0'] = len2[i][j];
            }
        }
        for (int i = 0; i < 10; i++) len2[i][S[x]-'0'] = len1[i];
        len1[S[x]-'0'] = true;
    }
    int a = 0;
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) for (int k = 0; k < 10; k++) if (ans[i][j][k]) a++;
    cout << a << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string s;

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

  cin>>s;
  int n=s.size();
  int cnt0=0,cnt1=0;
  rep(i,n){
    if(s[i]=='0')cnt0++;
    else cnt1++;
  }
  cout<<min(cnt0,cnt1)*2<<endl;

  return 0;
}


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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  int mx = -1, sum = 0;
  REP(i,n){
    int v;
    cin >> v;
    mx = max(mx, v);
    sum += v;
  }
  if(mx < sum - mx){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l = vector<int>(n);
    int s = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        s += l[i];
    }
    sort(l.begin(), l.end());
    if ((s - l.back()) > l.back()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

long long max(long long a, long long b){
  return (a > b)? a : b;
}

using namespace std;

int main(){
  long long a, b, c, k;
  std::cin >> a >> b >> c >> k;
  long long ans = 0;
  ans += min(a, k);
  ans += -1 * min(c, max(k - a - b, 0));
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define inf = 1e9 + 5;
#define dbg(vari) cerr << #vari << " = " << (vari) << endl;

void dfs(unordered_map<int, vector<int>> &m,
         unordered_map<int, long long> &weight,
	 vector<bool> &v,
	 int curr) {
  for (auto child : m[curr]) {
      if (v[child]) continue;
      v[curr] = true;
      weight[child] += weight[curr];
      dfs(m, weight, v, child);
  }
}

void solve(long long N, long long Q, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> p,
           std::vector<long long> x) {
  unordered_map<int, vector<int>> m;
  for (int i = 1; i <= N; i++) {
    m[i] = vector<int>();
  }
  for (int i = 0; i < N - 1; i++) {
    m[a[i]].push_back(b[i]);
    m[b[i]].push_back(a[i]);
  }
  unordered_map<int, long long> weights;
  for (int i = 0; i <= N; i++) {
      weights[i] = 0;
  }
  for (int i = 0; i < Q; i++) {
    weights[p[i]] += x[i];
  }
  vector<bool> v(N+1, false);
  dfs(m, weights, v, 1);
  for (int i = 1; i < N; i++) {
      cout << weights[i] << " ";
  }
  cout << weights[N] << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> a(N - 1);
  std::vector<long long> b(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  std::vector<long long> p(Q);
  std::vector<long long> x(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &p[i]);
    scanf("%lld", &x[i]);
  }
  solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
  return 0;
}


Measured memory_bytes: 53320
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) {
		--a;
	} else if (t == u) {
		--b;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
#define size(x) ((int)(x).size()) 
#define FIRST first 
#define SECOND second
#define FRONT front
#define PUSH_BACK push_back
#define MAKE_PAIR make_pair 
#define EMPTY empty
#define PRIORITY_QUEUE priority_queue
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL;  
//head

const int inf = 1e8;
const int maxn = 2e4;
struct edge
{
	int v, r, w, c;
};
std::vector<edge> G[maxn];
int h[maxn], dist[maxn];
int pv[maxn], pe[maxn];
int V;
int n, m, k;

void init(){
	for(int i = 0; i < V; i++){
		G[i].clear();
	}
}

void add(int u, int v, int w, int cost){
	G[u].push_back((edge){v, size(G[v]), w, cost});
	G[v].push_back((edge){u, size(G[u])-1, 0, -cost});
} 

void bellman(int s){
	int update = 1;
	fill(dist, dist+V, inf);
	dist[s] = 0;
	while(update){
		update = 0;
		for(int u = 0; u < V; u++){
			for(int j = 0; j < size(G[u]); j++){
				edge &e = G[u][j];
				if(e.w > 0 && dist[e.v] > dist[u] + e.c){
					dist[e.v] = dist[u] + e.c;
					update = 1;
				}
			}
		}
	}
}

int min_cost_flow(int s, int t, int flow){
	int res = 0;
	fill(h, h+V, 0);
	bellman(s);
	for(int i = 0; i < V; i++){
		h[i] += dist[i];
	}
	while(flow > 0){
		fill(dist, dist+V, inf);
		dist[s] = 0;
		priority_queue<pii, std::vector<pii>, greater<pii> > q;
		q.push(pii(0, s));
		while(!q.empty()){
			pii x = q.top(); q.pop();
			int u = x.second;
			if(dist[u] < x.first) continue;
			for(int i = 0; i < size(G[u]); i++){
				edge &e = G[u][i];
				int k = h[u] + dist[u] + e.c - h[e.v];
				if(k < dist[e.v] && e.w > 0){
					dist[e.v] = k;
					q.push(pii(k, e.v));
					pv[e.v] = u;
					pe[e.v] = i;
				}
			}
		}
		if(dist[t] == inf) {
			return -1;	//不能再增广
		}
		for(int i = 0; i < V; i++){
			h[i] += dist[i];
		}   
		int tf = flow;
		for(int v = t; v != s; v = pv[v]){
			tf = min(tf, G[pv[v]][pe[v]].w);
		}	
		if(tf){
			for(int v = t; v != s; v = pv[v]){
				edge &e = G[pv[v]][pe[v]];
				e.w -= tf;
				G[v][e.r].w += tf;
			}
			res += tf * h[t];
			flow -= tf;
		}
	}
	return res;	
}

int a[maxn], w[maxn], vis[maxn];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> m >> n >> k;
	int res = 0;
	for(int i = 1; i <= n; i++){
		cin >> w[i];
	} 
	for(int i = 0; i < k; i++){
		cin >> a[i];
	}
	k = unique(a, a+k) - a;
	int s = 0, t = k - 1;
	for(int i = 0; i < k-1; i++){
		add(i, i+1, inf, 0);
	}
	V = k;
	// cout << k << endl;
	for(int i = 0; i < k; i++){
		res += w[a[i]];
		if(vis[a[i]]){
			add(vis[a[i]], i, 1, -w[a[i]]);
			// cout << vis[a[i]] << ' ' << -w[a[i]] << endl;
		}
		vis[a[i]] = i+1;
	}
	cout << res + min_cost_flow(s, t, m-1) << endl;
	return 0;
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;

struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

int dr[] = {0, 0, -1, +1, -1, -1, +1, +1};
int dc[] = {-1, +1, 0, 0, -1, +1, -1, +1};

int main(){
    int h, w, n; scanf("%d%d%d", &h, &w, &n);
    umap<int,int> row, col;
    umap<pair<int,int>, int, HASH> grid;
    int mx_r = 0, mx_c = 0;
    for(int i = 0; i < n; i++){
        int x, y; scanf("%d%d", &x, &y);
        row[x]++; col[y]++;
        grid[{x,y}] = 1;
        mx_r = max(mx_r, row[x]);
        mx_c = max(mx_c, col[y]);
    }
    vector<int> a, b;
    for(auto i: row){
        if(i.second == mx_r)
            a.push_back(i.first);
    }
    for(auto i: col){
        if(i.second == mx_c)
            b.push_back(i.first);
    }
    int ans = 0;
    int highest = mx_r+mx_c;
    for(int i: a){
        for(int j: b){
            ans = max(ans, mx_r+mx_c-grid[{i,j}]);
            if(ans == highest)
                goto end;
        }
    }
    end:;
    printf("%d", ans);
}



Measured memory_bytes: 52616
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  int n;
  cin >> n;
  vl vec(n*3);
  rep(i, n*3) cin >> vec[i];
  sort(all(vec), greater<ll>());
  ll sum = 0;
  rep(i, n) sum += vec[i*2+1];
  cout << sum << endl;
  return 0;
}
    


Measured memory_bytes: 5628
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int a[100][100] = { {} };
	int b[100] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		int x = 0;
		for (int j = 0; j < m; j++) x += a[i][j] * b[j];
		cout << x << endl;
	}
}


Measured memory_bytes: 3152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKnapsack1 solver = new DKnapsack1();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnapsack1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int W = in.nextInt();
            int[] w = new int[n];
            int[] v = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                v[i] = in.nextInt();
            }
            long[][] dp = new long[W + 1][n + 1];
            for (int i = 1; i < n + 1; i++) {
                for (int u = 0; u < W + 1; u++) {
                    dp[u][i] = dp[u][i - 1];
                    if (u >= w[i - 1]) {
                        dp[u][i] = Math.max(dp[u][i], dp[u - w[i - 1]][i - 1] + v[i - 1]);
                    }
                }
            }
            out.println(dp[W][n]);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public void close() {
        }

    }
}



Measured memory_bytes: 130004
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	string tmp;
  cin >> tmp;
  REP(i, SZ(tmp)){
    if (tmp[i] == '1') tmp[i] = '9';
    else tmp[i] = '1';
  }
  cout << tmp << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char str[5],r;
    while(gets(str)!=NULL)
    {
      if(str[0]=='H')
        {
            if(str[2]=='H')
                r='H';
            else
                r='D';
        }
        else
        {
            if(str[2]=='H')
                r='D';
            else
                r='H';
        }
        printf("%c\n",r);
    }
    return 0;
}


Measured memory_bytes: 128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	counts := make([]int, 3)
	n := len(s)
	for i := 0; i < n; i++ {
		counts[s[i]-'a']++
	}

	sort.Ints(counts)

	ans := "NO"
	if n == 1 || (counts[2]-1 <= counts[0] && counts[2]-1 <= counts[1]) {
		ans = "YES"
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 896
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long int   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005                                                                                //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	fast
	ll r;
	cin>>r;
	ll ans=pow(r,2);
	cout<<ans;
	return 0;
}

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

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

  // ここにプログラムを追記
  int sum = 0, X = N;
  while(X >= 1) {
    sum += X%10;
    X /= 10;
  }
  if(N%sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int digit_sum(int num) {
    int res = 0;
    while (num > 0) {
        res += num % 10;
        num /= 10;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    if (N % digit_sum(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

constexpr long long MOD = 1'000'000'007;

class binomial_coefficients {
	long long MAX_VAL;
	vector<long long> fac, mmi;

public:

	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = (x % MOD + MOD) % MOD;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};


int main(){
	
	long long n, k;
	long long ans = 0;
	binomial_coefficients bc;
	
	cin>>n>>k;
	
	bc.init(n+k);
	
	
	for(int i = 0; i <= k; i++){
		if(i%2) {
			ans += (MOD - bc.combination(k, i) * bc.power(k - i, n)%MOD);
		} else {
			ans += bc.combination(k, i) * bc.power(k - i, n);
		}
		
		ans %= MOD;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a1 = IO.RSInt;
            var a2 = IO.RSInt;

            var candy = 0;
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                candy = 0;
                for (int j = 0; j < n; j++)
                {
                    if (j == i)
                    {
                        candy += a1[j] + a2[j];
                    }
                    else if (j < i) candy += a1[j];
                    else candy += a2[j];
                }
                ans = Max(ans, candy);
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396