akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define INF 0x7f7f7f
#define mem(a,b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)
// const ll mod = 1e9 + 7;
// const int maxn = 1e5 + 10;
// const double eps = 1e-6;

ll town[200005];
int vis[200005];
ll rul1[200005];
ll rul2[200005];

ll n, k;

void solve()
{
    ll cnt1 = 1;
    ll cnt2 = 1;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> town[i];
    }
    ll ans = 1;
    ll m = k;
    while(m--) // 判断循环一次需要传送多少
    {
        ans = town[ans]; // 传送
        if(vis[ans] > 2)
            break;
        if(vis[ans] == 0)
            rul1[cnt1++] = ans;
        else if(vis[ans] == 1)
            rul2[cnt2++] = ans;
        vis[ans]++;
    }
    cnt1--;
    cnt2--;
    if(k <= cnt1)
        cout<<rul1[k] << endl;
    else if(cnt2 == -1 && k > cnt1)
    {
        ll a = k % cnt1;
        if(!a) a = cnt1;
    }
    else if(cnt2 != -1 && k > cnt1)
    {
        k -= cnt1;
        ll a = k % cnt2;
        if(!a)
            a = cnt2;
        cout << rul2[a] << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);
#ifdef FZT_ACM_LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while(T--)
        solve();
#endif
    return 0;
}


Measured memory_bytes: 7964
#include <iostream>

using namespace std;

int main(){
  long long N, K;
  cin >> N >> K;
  
  N %= K;
  long long t = K - N;
  if (t < N) {
    printf("%llu\n", t);
  }else{
    printf("%llu\n", N);
  }
  
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x,ans=0;
	int sum = 1,temp=0;
	cin >> n;
	vector<int> a(n);
	
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for (int i =0; i <n ; ++i) {
		if (i != n - 1){
			if (a[i] == a[i + 1]) sum++;
			else {
				ans += sum / 2;
				sum = 1;
			}
		}
		else {
			ans += sum / 2;
			sum = 1;	
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec as=a;
    int ans=INF;
    sort(all(as));
    rep(_,n){
        int mi=as[_];
        vvec b(n);
        int idx=0;
        rep(i,n){
            if(a[i]<mi) idx++;
            else b[idx].pb(a[i]);
        }
        vec c;
        rep(i,n){
            if(b[i].size()==0) continue;
            sort(all(b[i]));
            rep(j,((int)b[i].size())-k+1){
                c.pb(b[i][j]);
            }
        }
        sort(all(c));
        if(c.size()<q) continue;
        chmin(ans,c[q-1]-mi);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5120
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


n, m = map(int, input().split())
uft = UnionFind(n)
p = list(map(int, input().split()))
rev = {x: i for i, x in enumerate(p)}

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    uft.union(x, y)

ans = 0
for i, x in enumerate(p):
    if uft.find(i, x - 1):
        ans += 1

print(ans)


Measured memory_bytes: 21472
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  int ans = 0;
  int l = 0, r = s.size()-1;
  while(r-l > 0){
    if(s[l] == s[r]){
      l++; r--;
    }else if(s[l] == 'x'){
      ans++; l++;
    }else if(s[r] == 'x'){
      ans++; r--;
    }else{
      cout << -1 << "\n";
      return 0;
    }
  }

  cout << ans << "\n";

  return 0;
}

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

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

	ll n, q; cin >> n >> q;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) cin >> a[i];
	vector<tuple<ll, ll, ll>> queries(q);
	for(ll i = 0; i < q; i++) {
		cin >> get<0>(queries[i]) >> get<1>(queries[i]);
		get<0>(queries[i])--;
		get<1>(queries[i])--;
		get<2>(queries[i]) = i;
	}
	const ll m = max((ll) sqrt(n), 1LL);
	sort(queries.begin(), queries.end(), [&](const tuple<ll, ll, ll> &a, const tuple<ll, ll, ll> &b) {
		return get<0>(a) / m < get<0>(b) / m || (get<0>(a) / m == get<0>(b) / m && get<1>(a) < get<1>(b));
	});
	ll L = 0, R = -1;
	vector<ll> amount(n + 1);
	int result = 0;
	auto add = [&](const ll &a) {
		amount[a]++;
		if(amount[a] == 1) result++;
	};
	auto rem = [&](const ll &a) {
		amount[a]--;
		if(amount[a] == 0) result--;
	};
	vector<ll> output(q);
	for(ll i = 0; i < q; i++) {
		//auto [curL, curR, idx] = queries[i];
		ll curL, curR, idx;
		tie(curL, curR, idx) = queries[i];
		while(L < curL) {
			rem(a[L]);
			L++;
		}
		while(L > curL) {
			L--;
			add(a[L]);
		}
		while(R > curR) {
			rem(a[R]);
			R--;
		}
		while(R < curR) {
			R++;
			add(a[R]);
		}
		output[idx] = result;
	}
	for(int i = 0; i < q; i++) cout << output[i] << '\n';
}


Measured memory_bytes: 27164
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n;
  cin >> n;
  string s = to_string(n);
  int t = 0;
  for (auto &i : s) {
    t += i - '0';
  }
  if (n % t == 0) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3708
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(long, "cost", long, "num");

void main() {
    int N, M;
    scan(N, M);
    auto ds = new Pair[](N);
    foreach (i ; 0 .. N) {
        int ai, bi;
        scan(ai, bi);
        ds[i] = Pair(ai, bi);
    }
    ds.sort!"a.cost < b.cost"();

    long ans;

    foreach (i ; 0 .. N) {
        if (M <= 0) break;
        long tmp = min(M, ds[i].num);
        ans += 1L * tmp * ds[i].cost;
        M -= tmp;
    }

    writeln(ans);
}

int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4604
def euclid(a,b):
	if b == 0:
		return a
	else:
		return euclid(b,a % b)
		
n = int(input())
t = []
for i in range(n):
	x = int(input())
	t.append(x)

for i in range(0,n-1):
	t[i+1] = t[i] * t[i+1] // euclid(t[i],t[i+1])

print(int(t[n-1]))

Measured memory_bytes: 3060
n = str(input())
r = n[-1]
if r == "2" or r == "4" or r == "5" or r == "7" or r == "9":
    print("hon")
elif r == "0" or r == "1" or r == "6" or r == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int num[200005] = {};

int root(int x) {
	if (num[x] == x) return x;
	else {
		num[x] = root(num[x]);
		return num[x];
	}
}

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;
	else {
		num[y] = x;
		return;
	}
}


int main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) num[i] = i;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		unite(min(a, b), max(a, b));
	}
	vector<int> c(n);
	rep(i, n) c[root(i)]++;
	int ans = 0;
	rep(i, n) ans = max(ans, c[i]);
	cout << ans << endl;
	return 0;
}


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

// ll pow(ll x, ll d){
//     ans = 1;
//     for(ll i=1;i<=x;i++){
//         ans = (i * ans) % d;
//     }
//     return ans;
// }

const int MAX = 1000010;
const int MOD = 1000000007;

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

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

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

int main() {
    COMinit();

    int X, Y;
    cin >> X >> Y;
    int n = (X + Y) / 3;
    // cout << "n " << n << endl;
    if((X+Y)%3!=0){
        cout << 0;
        return 0;
    }
    if(min(X, Y) < n){
        cout << 0;
        return 0;
    }
    int r = min(X, Y) - n;
    cout << COM(n, r);
    return 0;

}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int a, b, c, d, e, n;
    cin >> n >> a >> b >> c >> d >> e;
    Int mi = min(a, min(b, min(c, min(d, e))));
    Int res = (n % mi == 0) ? 0 : 1;
    res += n / mi;
    dump(4LL + res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
const int N = 1e5 + 55;
bool lose[N];
int a[N];
void solve() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	lose[0] = 1;
	for (int i = 1; i <= k; ++i) {
		lose[i] = true;
		for (int j = 1; j <= n; ++j) {
			if (i - a[j] >= 0 and lose[i - a[j]]) {
				lose[i] = false;
			}
		} 
	}
	if (lose[k])
		cout << "Second\n";
	else
		cout << "First\n";
}     


Measured memory_bytes: 384
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,x = li()

if n == 2 and x == 2:
    print("Yes")
    for i in range(1,4):
        print(i)
        
elif (n == 2 and x == 1) or (n == 2 and x == 3):
    print("No")

elif x == 1 or x == 2*n-1:
    print("No")

elif x == 2:
    ans = [i for i in range(1,x-1)] + [i for i in range(x+3, 2*n)]
    ans = ans[:n-2] + [x+2, x, x-1, x+1] + ans[n-2:]
    
    print("Yes")
    for ai in ans:
        print(ai)
    
else:
    ans = [i for i in range(1,x-2)] + [i for i in range(x+2, 2*n)]
    ans = ans[:n-2] + [x-1, x, x+1, x-2] + ans[n-2:]
    
    print("Yes")
    for ai in ans:
        print(ai)

Measured memory_bytes: 13996
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}

int main(void){

    int n;
    long long int h;
    cin>>n>>h;

    vector<pair<long long int, long long int>> p(2*n);

    for(int i=0;i<n;i++){
        long long int a,b;
        cin>>a>>b;

        p[2*i] = make_pair(a, 1);
        p[i*2+1] = make_pair(b, 0);
    }

    sort(p.begin(), p.end());

    

    long long int sum = 0;
    long long int count = 0;
    int i = 2*n-1;

    while(sum<h){

        if(p[i].second==0){
            sum += p[i].first;
            count++;
            i--;
        }else{
            if((h-sum)%p[i].first == 0) count += (h-sum)/p[i].first;
            else count += (h-sum)/p[i].first + 1;
            break;
        }
        //cout<<sum<<" "<<endl;

    }

    cout<<count<<endl;


}

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

using namespace std;
int main()
{
	vector<int> e;
	
	for(int i=0;i<12;i++){
		e.push_back(0);
		cin>>e[i];
	}
	
	sort(e.begin(),e.end());
	
	if( e[0]==e[1] && e[1]==e[2] && e[2]==e[3] && e[4]==e[5] && e[5]==e[6] && e[6]==e[7] && e[8]==e[9] && e[9]==e[10] && e[10]==e[11] )
	cout<<"yes"<<endl;
	else
	cout<<"no"<<endl;
}



Measured memory_bytes: 3168
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut x: Vec<(i64, i64)> = vec![];
    for _ in 0..n{
        let line = read_as_vec::<i64>();
        x.push((line[0], line[1]));
    }

    x.sort_by_key(|x| x.0+x.1);
    let mut ans: usize = 0;
    let mut cur = x[0];

    for i in 1..n{
        if x[i].0 - x[i].1 < cur.0+cur.1{
            ans += 1;
        }else{
            cur = x[i];
        }
    }

    println!("{}", n-ans);
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] d = new int[3];
        d[0] = scan.nextInt();
        d[1] = scan.nextInt();
        d[2] = scan.nextInt();
        Arrays.sort(d);
        if (d[0] + d[1] == d[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21588
a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, (max(x,y)*2)+1, 2):
    xr = max(x-(i//2), 0)
    yr = max(0, y-(i//2))

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)

Measured memory_bytes: 9180
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
zennbu = {A11,A12,A13,A21,A22,A23,A31,A32,A33}
yoko1 = {A11,A12,A13}
yoko2 = {A21,A22,A23}
yoko3 = {A31,A32,A33}
tate1 = {A11,A21,A31}
tate2 = {A12,A22,A32}
tate3 = {A13,A23,A33}
naname1 = {A11,A22,A33}
naname2 = {A13,A22,A31}
N = int(input())
for i in range(N):
  b = int(input())
  if b in zennbu:
    yoko1.discard(b)
    yoko2.discard(b)
    yoko3.discard(b)
    tate1.discard(b)
    tate2.discard(b)
    tate3.discard(b)
    naname1.discard(b)
    naname2.discard(b)
if len(yoko1) ==0 or len(yoko2) ==0 or len(yoko3) ==0:
  print('Yes')
elif  len(tate1) ==0 or len(tate2) ==0 or len(tate3) ==0:
  print('Yes')
elif len(naname1) == 0 or len(naname2)==0:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 3064
n, q=map(int,input().split())
str=input() #ただの文字列
q_list=[input().split() for _ in range(q)]  #問題の数が入ったリスト
pattern='AC'

#strのi番目までににACが何個あるか
count_ac=[0 for i in range(len(str))]
count=0
for i in range(len(count_ac)-1):
    if str[i]=='A' and str[i+1]=='C':
        count+=1
        count_ac[i]=count
    else:
        count_ac[i]=count
count_ac[len(str)-1]=count    
for a,b in q_list:
    A,B=int(a),int(b)
    if A>=2:
        print(count_ac[B-2]-count_ac[A-2])
    elif B>=2 and A<2:
        print(count_ac[B-2])
    else:
        print(0)
    

Measured memory_bytes: 35536
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int h, w;
	char c[102][102] = {};
	cin >> h >> w;
	REP(i, w + 2) {
		c[0][i] = c[h + 1][i] = '#';
	}
	REP(i, h + 2) {
		c[i][0] = c[i][w + 1] = '#';
	}
	FOR(i, 1, h + 1) {
		FOR(j, 1, w + 1)cin >> c[i][j];
	}

	REP(i, h + 2) {
		REP(j, w + 2)cout << c[i][j];
		cout << endl;
	}
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvpll G;
vl visited;
vl d(MAX_N);
bool ok = true;

void dfs(ll v, ll dist) {
    if(visited[v]) {
        if(d[v] != dist) {
            ok = false;
            return;
        }
        return;
    }
    visited[v] = 1;
    d[v] = dist;
    for(auto p : G[v]) {
        ll u = p.first;
        ll cost = p.second;
        dfs(u, d[v] + cost);
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    

    G.resize(n);
    rep(i, m) {
        ll L, R, D;
        cin >> L >> R >> D;
        L--;  R--;
        G[L].pb(make_pair(R, D));
        G[R].pb(make_pair(L, -D));
    }

    visited.resize(n);
    rep(v, n) {
        if(!visited[v]) {
            dfs(v, 0);
        }
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll a[25][25];
ll dp[25][1<<21];
ll n;
ll func(ll i,ll mask)
{
	//cout<<i<<" "<<mask<<endl;
	ll sum=0,j;
	if(i>n)
		return 1;
	if(dp[i][mask]!=-1)
		return dp[i][mask];
	for(j=1;j<=n;j++)
	{
		if(a[i][j]&&!(mask&(1<<(j-1))))
			sum=(sum+func(i+1,mask^(1<<(j-1))))%mod;
	}
	dp[i][mask]=sum;
	return dp[i][mask];
}
int main()
{
	ll i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=1<<n;j++)
			dp[i][j]=-1;
	}
	cout<<func(1,0)<<endl;
}


Measured memory_bytes: 346368
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 5e3 + 5;
int n, P, dp[N] = {1};

int main() {
	cin >> n >> P;
	for (int i = 1; i < n; i++)
		for (int x = min(i, n - i + 1), j = x; j < n; j++)
			(dp[j] += dp[j - x]) %= P;
	int ans = 0;
	for (int i = 0; i < n; i++)
		(ans += 1LL * (n - i) * dp[i] % P) %= P;
	cout << ans;
}


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

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

Measured memory_bytes: 3512
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

bool test(long[] a, long l, long u, long k, long q) {
  return a.split!(x => x < l)
          .filter!(x => x.length >= k)
          .map!(x => min(x.count!(y => y <= u), x.length - k + 1))
          .sum >= q;
}

void main(){
  long n, k, q;
  readlnTo(n, k, q);
  auto a = readLongs();
  long ans = long.max / 2;
  foreach(i; iota(n)) {
    long l = a[i]-1;
    long u = 3_000_000_000;
    while(l + 1 < u) {
      auto m = (l+u)/2;
      if(test(a, a[i], m, k, q)) {
        u = m;
      } else {
        l = m;
      }
    }
    ans = min(ans, u-a[i]);
  }
  writeln(ans);
}



Measured memory_bytes: 5372
#include <iostream>
#include <algorithm>

using namespace std;

long long com_sum[200009];


void solve() {
    int n;
    cin >> n;
    int ai;
    cin >> ai;
    com_sum[0] = ai;
    for (int i=1; i<n; ++i) {
        cin >> ai;
        com_sum[i] = com_sum[i-1] + ai;
    }
    long long min_dif = 2e14, dif;
    for (int i=0; i < n-1; ++i) {
        dif = abs(com_sum[n-1] - 2*com_sum[i]);
        if (dif < min_dif)
            min_dif = dif;
    }
    cout << min_dif;
}

int main() {

	solve();
    return 0;
}


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

int main(){
  int n, x;
  cin >> n;
  for(int i=1; i<=n; i++){
    x = i;
    if(x%3==0)
      cout << " " << i;
    if(i%3!=0){
      while(x>0){
	if(x%10==3){
	  cout << " " << i;
	  break;
	}
	else
	  x/=10;
      }
    }
  }
  cout << endl;  
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int N; cin >> N;
	vi los (N);
	vi his (N);
	F0R(i, N) {
		cin >> los[i];
		cin >> his[i];
	}

	sort(los.begin(), los.end());
	sort(his.begin(), his.end());

	if (N % 2 == 1) {
		print(his[N/2] - los[N/2] + 1);
	} else {
		print(his[N/2-1] + his[N/2] - los[N/2-1] - los[N/2] + 1);
	}
}

Measured memory_bytes: 4772
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str1 = lines[0];
        int n = Integer.parseInt(str1);
        Boolean card[][] = new Boolean[4][13];
        for(int i = 0; i < 4; ++i){
            for(int j = 0; j < 13; ++j){
                card[i][j] = false;
            }
        }
        for(int i = 1; i <= n; ++i){
            String[] cinfo = lines[i].split(" ");
            String pic = cinfo[0];
            int cnum = Integer.parseInt(cinfo[1]);
            cnum--;
            if(pic.equals("H")){
                card[1][cnum] = true;
            } else if(pic.equals("S")){
                card[0][cnum] = true;
            } else if(pic.equals("C")){
                card[2][cnum] = true;
            } else if(pic.equals("D")){
                card[3][cnum] = true;
            }
        }
        for(int i = 0; i < 4; ++i){
            for(int j = 0; j < 13; ++j){
                if(card[i][j] == false){
                    if(i == 0) System.out.printf("%s %d", "S", j + 1);
                    else if(i == 1) System.out.printf("%s %d", "H", j + 1);
                    else if(i == 2) System.out.printf("%s %d", "C", j + 1);
                    else if(i == 3) System.out.printf("%s %d", "D", j + 1);
                    System.out.println();
                }
            }
        }
    }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}


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

int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    if(n == 2){
        cout << max(a[0],a[1]) << endl;
        return 0;
    }
    if(n == 3){
        cout << max(a[0],max(a[1],a[2])) << endl;
        return 0;
    }
    long long dp[4][n/2];
    dp[0][0] = a[1];
    dp[1][0] = a[0];
    for(int i=1; i<n/2; i++){
        dp[0][i] = max(dp[0][i-1],dp[1][i-1]) + a[2*i+1];
        dp[1][i] = dp[1][i-1] + a[2*i];
    }
    dp[2][1] = a[3];
    dp[3][1] = max(a[0],max(a[1],a[2]));
    for(int i=2; i<n/2; i++){
        dp[2][i] = max(dp[0][i-2],max(dp[1][i-2],max(dp[2][i-1],dp[3][i-1]))) + a[i*2+1];
        dp[3][i] = max(dp[0][i-2],max(dp[1][i-2],dp[3][i-1])) + a[2*i];
    }
    long long t = max(dp[0][n/2-1],dp[1][n/2-1]);
    if(n%2==0) cout << t << endl;
    else cout << max(t,a[n-1]+dp[3][n/2-1]) << endl;
    return 0;
}


Measured memory_bytes: 8304
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
    }
    static void solve()
    {
        input();
        Dictionary<string, int> dic = new Dictionary<string, int>();
        for(int i = 0; i < N; i++)
        {
            char[] c = cin.next().ToCharArray();
            Array.Sort(c);
            string s = new string(c);
            if (dic.ContainsKey(s))
                dic[s]++;
            else
                dic.Add(s, 1);
        }
        long ans = 0;
        foreach(var c in dic)
        {
            ans += Combination(c.Value, 2);
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
      static long Combination(long n, long m)
    {
        if (m == 0) return 1L;
        return Combination(n, m - 1) * (n - m + 1) / m;
    }

}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int mp[55][55];

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

    int h, w;
    cin >> h >> w;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            char c;
            cin >> c;
            if( c == '#' ) mp[i][j] = 1;

        }
    }

    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            if( mp[i][j] == 0 ) continue;
            if( mp[i - 1][j] == 0 &&
                mp[i][j - 1] == 0 &&
                mp[i][j + 1] == 0 &&
                mp[i + 1][j] == 0 ) {
                cout << "No" << endl;
                return 0;

            }

        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
/**
*    created: 16.07.2020 01:40:58
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    cout << n *(n+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

int f[105][12];
int p[105][12];
int N;
int main(){
  std::cin>>N;
  for(int i=0;i<N;++i)
    for(int j=0;j<10;++j)
      std::cin>>f[i][j];
  
    for(int i=0;i<N;++i)
      for(int j=0;j<11;++j)
        std::cin>>p[i][j];
  
  long long ans=-(1LL<<30);
  for(int s=1,end=1<<10;s<end;++s){
    int res=0;
    for(int i=0;i<N;++i){
      int cnt=0;
      for(int j=0;j<10;++j)
        if(((s>>j)&1)&&f[i][j])
          ++cnt;
      res+=p[i][cnt];
    }
    ans=std::max<long long>(ans,res);
  }
  
  std::cout<<ans<<std::endl;
    
  return 0;
}

Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = head . words
printer = unlines . (:[])

solver x = if elem '7' x then "Yes" else "No" 

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
typedef pair<int,int> P;
string alph="abcdefghijklmnopqrstuvwxyz";
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    int sum=n*(n-1)/2;
    int num[26]={};
    for(int i=0; i<n;i++){
        for(int j=0; j<26;j++){
            if(s[i]==alph[j]){
                ans+=num[j];
                num[j]++;
            }
        }
    }
    cout<<sum-ans+1<<endl;
}


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

int main()
{
    
    string S;
    cin >> S;
    
    bool flag = false;
    if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) {
        flag = true;
    }
    if (S[0] == S[2] && S[1] == S[3] && S[2] != S[3]) {
        flag = true;
    }
    if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) {
        flag = true;
    }
    
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] ans = new int[N+1];
		for (int i = 0; i < M * 2; i++) {
			ans[sc.nextInt()]++;
		}
		for (int i = 1; i < ans.length; i++) {
			System.out.println(ans[i]);
		}
	}
}



Measured memory_bytes: 21844
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int x = Integer.parseInt(s);
        int y = x * x * x;
        System.out.println(y);
    }
}

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

void maxHeapify(int i) {
  int left = 2*i;
  int right = 2*i + 1;
  int largest = 0;

  if (left <= A.size()-1 && A.at(left) > A.at(i)) {
    largest = left;
  } else {
    largest = i;
  }
  if (right <= A.size()-1 && A.at(right) > A.at(largest)) {
    largest = right;
  }

  if (largest != i) {
    int tmp = A.at(largest);
    A.at(largest) = A.at(i);
    A.at(i) = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(int n){
  int p = n/2;
  while (p > 0) maxHeapify(p--);
}


int main() {
  int n; cin >> n;
  A.push_back(0);
  rep(i, n) {
    int tp; cin >> tp;
    A.push_back(tp);
  }
  buildMaxHeap(n);
  rep(i, n) cout << " " << A.at(i+1);
  cout << endl;
}



Measured memory_bytes: 4752
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
	
	string s;
	cin >>s;
	
	int i,n=s.length(),ch[26]={0},w;
	for (i=0 ; i<n ; i++) {
		w=s[i]-97;
		ch[w]++;
	}
	
	string ans;
	for (i=0 ; i<26 ; i++) {
		ans=i+97;
		if (ch[i]==0) {
			cout <<ans <<endl;
			break;
		}
		if (i==25) {
			cout <<"None" <<endl;
		}
	}
	
	return 0;
}

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

struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};

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

  UnionFind uf(n);
  vector<P> query(m);

  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    query[i] = make_pair(a, b);
  }

  reverse(query.begin(), query.end());
  vector<ll> res;
  ll cnt = (ll)n * (n - 1) / 2;
  res.emplace_back(cnt);
  for (int i = 0; i < m; i++) {
    int u = query[i].first, v = query[i].second;
    if (uf.same(u, v)) res.emplace_back(res.back());
    else {
      ll a = uf.size(u), b = uf.size(v);
      ll d = res.back() - (a * b);
      res.emplace_back(d);
      uf.unite(u, v);
    }    
  }
  reverse(res.begin(), res.end());
  for (int i = 0; i < res.size() -1 ; i++) {
    cout << res[i+1] << endl;
  }
  return 0;
} 

Measured memory_bytes: 3444
#include <stdio.h>
#define N 101
#define INF -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int Q[N],color[N],d[N],head,tail;

void enqueue(int x){
  Q[tail]=x;
  tail=(tail+1)%101;
}

int dequeue(void){
  int a;
  a=head;
  head=(head+1)%101;
  return Q[a];
}

void bfs(int s){
  int u,v,i;
  d[s]=0;
  color[s]=GRAY;
  enqueue(s);
  
  while(head!=tail){
    u=dequeue();
    for(v=1;v<=n;v++){
      if(M[u][v]==1 && color[v]==WHITE){
	color[v]=GRAY;
	d[v]=d[u]+1;
	enqueue(v);
      }
    }
    color[u]=BLACK;
  }
}

int main(){
  int u,v,k,i,j;
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    d[i]=INF;
    color[i]=WHITE;
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }
  
  bfs(1);
  
  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int w[n];
    int v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    vector<long long int> dp(m+1,0);
    for(int i=0;i<n;i++){
        for(int j=m;j>=w[i];j--){
            dp[j] = max(dp[j],v[i] + dp[j-w[i]]);   
        }
    }
    long long int ans = 0;
    for(int i=0;i<=m;i++){
        ans = max(dp[i],ans);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        double c=toRadians(sc.nextDouble());
        out.println(a*b*sin(c)/2);
        out.println(a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
        out.println(b*sin(c));
    }
}


Measured memory_bytes: 28044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,l,n) for(ll i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
	fast;
	ll n,k;
	cin>>n>>k;
	if(n%(2*k+1)==0) cout<<n/(2*k+1);
	else cout<<ceil(n/float(2*k+1));
	return 0;
}


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

bool Left(string S) {
  int tmp = stoi(S.substr(0, 1)) * 10 + stoi(S.substr(1, 1));
  if (0 < tmp && tmp < 13) return true;
  else return false;
}

bool Right(string S) {
  int tmp = stoi(S.substr(2, 1)) * 10 + stoi(S.substr(3, 1));
  if (0 < tmp && tmp < 13) return true;
  else return false;
}

int main() {
  
  string S; cin >> S;
  
  if (Left(S)) {
    if (Right(S)) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else {
    if (Right(S)) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  
}

Measured memory_bytes: 256