akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int W,H;
int used[100][100];
char fie[100][100];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int solve(int x,int y,int &c){
  if( used[x][y] ) return 0;
  used[x][y] = 1;
  c++;
  int st = 0;
  for(int i=0;i<4;i++){
    int nx = x + dx[i], ny = y + dy[i];
    if( nx < 0 || ny < 0 || nx > W-1 || ny > H-1 ) continue;
    if( fie[nx][ny] == 'W' ) st |= 2;
    if( fie[nx][ny] == 'B' ) st |= 1;
    if( fie[nx][ny] == '.' ) st |= solve(nx,ny,c);
  }
  return st;
}

int main(){
  while ( cin >> W >> H ){
    if( !W & !H ) break;
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++) cin >> fie[j][i];
    int kc = 0;
    int wc = 0;
    memset(used,0,sizeof(used));
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if( fie[j][i] == '.' ){
	  int c = 0;
	  int st = solve(j,i,c);
	  if( st == 1 ) kc+=c;
	  else if ( st == 2 ) wc+=c;
	}
      }
    }
    cout << kc << " " << wc << endl;
	
  }
}

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

int main()
{
    int a,b,c;
    int cnt=0;
    cin >>a>>b>>c;
    for(int x=a;x<=b;x++){
        if(c%x==0) {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    char c;
    while(1){
        cin>>a>>c>>b;
        if(c=='?')break;
        else if(c=='+')cout<<a+b<<endl;
        else if(c=='-')cout<<a-b<<endl;
        else if(c=='*')cout<<a*b<<endl;
        else if(c=='/')cout<<a/b<<endl;
    }
    
    return 0;
}


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

using namespace std;
//using long long = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    long long n = 0;
    cin >> n;
    vector<long long> s(n);
    for(long long i = 0;i < n;i++){
        cin >> s[i];
    }
    long long q = 0;
    cin >> q;
    long long tmp = 0;
    long long cnt = 0;
    for(long long i = 0;i < q;i++){
        cin >> tmp;
        long long l = 0;
        long long r = s.size() - 1;
        while(r >= l){
            long long m = l + (r - l) / 2;
            if(s[m] == tmp){
                cnt ++;
                break;
            }else if(s[m] > tmp){
                r = m - 1;
            }else if(s[m] < tmp){
                l = m + 1;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
    int N,M;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    cin >> M;
    vector<int> b(M);
    for(int i = 0; i < M; i++) cin >> b[i];
    
    vector<int> res;
    set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(res,res.end()));

    cout << (res.size() == b.size()) << endl;
}


Measured memory_bytes: 5492
import java.util.*;
public class Main 
{
    public static void main(String[] args) 
    {
        Scanner stdIn = new Scanner(System.in);
        while(stdIn.hasNext())
        {
            int a = stdIn.nextInt();
            int b = stdIn.nextInt();
            int c = stdIn.nextInt();
            int d = stdIn.nextInt();
            int e = stdIn.nextInt();
            int f = stdIn.nextInt();
            double x = (c * e - b * f) / (double)(a * e - b * d);
            double y = (c * d - a * f) / (double)(b * d - a * e);
            if(x == -0)
            {
                x = 0;
            }
            if(y == -0)
            {
                y = 0;
            }
            System.out.printf("%.3f %.3f\n", x, y);
        }
    }
}

Measured memory_bytes: 16388
use std::cmp;

const INF: i64 = 1e18 as i64;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let l: i64 = sc.read();
    let mut dist = vec![vec![INF; n]; n];
    for i in 0..n {
        dist[i][i] = 0;
    }
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        let c = sc.read();
        dist[a][b] = c;
        dist[b][a] = c;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = cmp::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    let mut fill = vec![vec![n; n]; n];
    for i in 0..n {
        fill[i][i] = 0;
    }
    for i in 0..n {
        for j in 0..n {
            if i == j {
                fill[i][j] = 0;
            } else if dist[i][j] <= l {
                fill[i][j] = 1;
            }
        }
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                fill[i][j] = cmp::min(fill[i][j], fill[i][k] + fill[k][j]);
            }
        }
    }

    let q: usize = sc.read();
    for _ in 0..q {
        let from = sc.read::<usize>() - 1;
        let to = sc.read::<usize>() - 1;
        let ans = fill[from][to];
        if ans == n {
            println!("-1");
        } else {
            println!("{}", ans - 1);
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4604
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
  char l, r;
  int cup[3] = {};
  cup[0] = 1;
  
  while(scanf("%c,%c", &l, &r) != EOF) {
    swap(cup[r - 'A'], cup[l - 'A']);
    getchar();
  }
  
  for(int i = 0; i < 3; i++) {
    if(cup[i]) printf("%c\n", i + 'A');
  }
  
  return 0;
}
  
  

Measured memory_bytes: 1144
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

typedef pair<int,int> P;


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

    int maxK = (N-1) * (N-2) / 2;

    if (maxK < K) {
        cout << -1 << endl;
    } else {

        vector<P> edges;
        //! create a star having node N at the center
        for (int n = 1; n < N; ++n) {
            edges.emplace_back(N, n);
        }

        vector<P> cPairs; //! pairs of children
        for (int i = 1; i < N-1; ++i) {
            for (int j = i+1; j < N; ++j) {
                cPairs.emplace_back(i,j);
            }
        }

        rep(i, maxK-K) {
            edges.push_back(cPairs[i]);
        }

        cout << edges.size() << endl;
        rep(i, edges.size()) {
            cout << edges[i].first << ' ' << edges[i].second << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		boolean flg = false;
		for (int i = 0; i <= x; i++) {
			int sum = 2*i + 4*(x-i);
			if (sum == y) {
				flg = true;
				break;
			}
		}
		if (flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K; cin >> K;
  REP(i, K){
    cout << "ACL";
  }
  cout << endl;
}


Measured memory_bytes: 3568
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if b > a:
    t_b = b + t*w
    t_a = a + t*v
    if t_a >= t_b:
        print('YES')
    else:
        print('NO')
else:
    t_b = b - t*w
    t_a = a - t*v
    if t_a <= t_b:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int num = i;
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        if (sum >= a && sum <= b) ans += i; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll w, h;
    cin >> w >> h;
    ll ans = 1e11;
    rep(_, 2)
    {
        rep(x, w)
        {
            ll s1 = x * h;
            ll remx = w - x;
            ll s2 = remx * (h / 2);
            ll s3 = remx * (h - h / 2);
            ll diff = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
            s2 = h * (remx / 2);
            s3 = h * (remx - remx / 2);
            ll diff2 = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
            diff = min(diff, diff2);
            ans = min(ans, diff);
        }

        swap(w, h);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<typeinfo>

using namespace std;

int main(){
	string N;int S;
	int n=0;
	cin>>N;
	n=stoi(N);
	for(int i=0;i<N.size();i++){
		S+=N[i]-'0';
	}
	n%S==0 ? cout<<"Yes"<<endl : cout<<"No"<<endl;
	
}

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

const int MOD_VAL = 998244353;

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

  int arr[n];
  rep(i, n) cin >> arr[i];

  int dp[n + 1][s + 1];
  rep(i, n + 1) rep(j, s + 1) dp[i][j] = 0;
  dp[0][0] = 1;

  int ans = 0;
  rep(i, n) {
    rep(j, s + 1) dp[i + 1][j] = dp[i][j];
    rep(j, s) {
      // if (arr[i] + j <= s) dp[i + 1][arr[i] + j] += dp[i][j];
      if (arr[i] + j <= s) {
        dp[i + 1][arr[i] + j] = (dp[i + 1][arr[i] + j] + dp[i][j]) % MOD_VAL;
      }
    }
    dp[i + 1][0] = dp[i][0] + 1;
    ans = (ans + dp[i + 1][s]) % MOD_VAL;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35456
# N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

ans = false
0.upto(S.size-1).each do |i|
  if S[i] == '7'
    ans = true
  end
end

if ans
  print "Yes\n"
else 
  print "No\n"
end


Measured memory_bytes: 14324
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	ans := 0
	for i := a; i <= b; i++ {
		s := strconv.Itoa(i)
		ok := true
		for i, j := 0, len(s)-1; i < j; {
			if s[i] != s[j] {
				ok = false
				break
			}
			i++
			j--
		}
		if ok {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2252
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.close();
        for(int i=0;i<=n;i++){
            if((int)((double)i*1.08)==n){
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
    }
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<bool>> existl(n-1, vector<bool>(26)), existr(n-1, vector<bool>(26));
    existl[0][s[0] - 'a'] = true;
    for (int i=1; i<n-1; i++) {
        existl[i] = existl[i-1];
        existl[i][s[i] - 'a'] = true;
    }
    existr[n-2][s[n-1] - 'a'] = true;
    for (int i=n-3; i>=0; i--) {
        existr[i] = existr[i+1];
        existr[i][s[i+1] - 'a'] = true;
    }
    int ans = 0;
    for (int i=0; i<n-1; i++) {
        int cnt = 0;
        for (int j=0; j<26; j++) {
            if (existl[i][j] && existr[i][j]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct UnionFind {
    vector<int> A;
    UnionFind(int n) : A(n, -1) {}
    int find(int x) {
        if (A[x] < 0) return x;
        return A[x] = find(A[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (A[x] > A[y]) swap(x, y);
        A[x] += A[y];
        A[y] = x;
    }
    int ngroups() {
        int ans = 0;
        for (auto a : A) if (a < 0) ans++;
        return ans;
    }
};
void yes() { cout << "Yes\n"; exit(0); }
void no() { cout << "No\n"; exit(0); }
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> B(N); for (auto &b : B) cin >> b;
    {
        vector<int> I(N); iota(begin(I), end(I), 0);
        sort(begin(I), end(I), [&](int i0, int i1) { return B[i0] < B[i1]; });
        vector<int> T(N);
        for (int i = 0; i < N; i++) T[i] = A[I[i]];
        A = T;
        for (int i = 0; i < N; i++) T[i] = B[I[i]];
        B = T;
    }
    vector<int> I(N); iota(begin(I), end(I), 0);
    sort(begin(I), end(I), [&](int i0, int i1) { return A[i0] < A[i1]; });
    for (int i = 0; i < N; i++) {
        if (A[I[i]] > B[i]) {
            no();
        }
    }
    for (int i = 0; i < N - 1; i++) {
        if (A[I[i + 1]] <= B[i]) {
            yes();
        }
    }
    UnionFind uf(N);
    for (int i = 0; i < N; i++) {
        uf.unite(i, I[i]);
    }
    if (uf.ngroups() == 1) {
        no();
    } else {
        yes();
    }
    return 0;
}


Measured memory_bytes: 1808
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int I[300];
int cnt[300];
const int M = 256;

void solve(int n) {
    for (int i = 0; i < n; i++) {
        scanf("%d", I + i);
    }
    VT<pair<double, tuple<int, int, int>>> ans;
    REP(s, 16) REP(a, 16) REP(c, 16) {
        memset(cnt, 0, sizeof(cnt));
        int R = s;
        REP(i, n) {
            R = (a * R + c) % M;
            cnt[(I[i] + R) % M]++;
        }
        long double H = 0;
        REP(i, M) {
            if (cnt[i]) H -= (long double)((1. * cnt[i]) / (1. * n)) * logl((1. * cnt[i]) / (1. * n));
        }
        //DEBUG(H)
        ans.EB(MP(H, make_tuple(s, a, c)));
    }
    SORT(ans);
    int S, A, C;
    tie(S, A, C) = ans.front().second;
    printf("%d %d %d\n", S, A, C);
}

int main(void) {
	int a, b, c, x, y, z, n, m, p;
	string s;
	while (cin >> n, n) {
		solve(n);
		//break;
	}
}

Measured memory_bytes: 3468
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		if(s=="0")
			break;
		int sum=0;
		for(int i=0;i<s.size();i++){
			sum+=s[i]-'0';
		}
		cout<<sum<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
string s;
bool flag;
int main(){
    cin>>s;
    if(s[0] == s[1] and s[1] == s[2])flag = true;
    else if(s[1] == s[2] and s[2] == s[3])flag = true;
    if(flag)printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


const int INF = 1 << 20;
struct P
{
	int r1, k1;
	vint ok;
};


int main()
{
    int n, p;
	cin >> n;
	cin.ignore();
	
	vector<P> v(n);
	rep(i, n)
	{
		cin >> v[i].r1;
		
		int k1;
		cin >> k1;
		
		rep(j, k1)
		{
			int buf;
			cin >> buf;
			v[i].ok.push_back(buf);
		}
	}
	
	cin >> p;
	
	vector<vint> G(n, vint(n, INF));
	
	rep(i, n)
	{
		rep(j, v[i].ok.size())
		{
			G[v[i].r1 - 1][v[i].ok[j] - 1] = 1;
		}
	}
	
	rep(k, n) rep(i, n) rep(j, n)
		chmin(G[i][j], G[i][k] + G[k][j]);
		
	rep(i, p)
	{
		int s1, d1, v1;
		cin >> s1 >> d1 >> v1;
		
		int cost = G[s1 - 1][d1 - 1];
		if(cost == INF || v1 <= cost)
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << cost + 1 << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int  a=0,n=0,x,f;
int main(){
	cin>>n>>a;
	 x=n%500;
	if(x>a) cout<<"No"<<endl;
	 if (x<=a)cout<<"Yes"<<endl;
	return 0;
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define llint long long
#define rg register
#define RI register int
#define RC register char
#define rg register
#define ed putchar('\n')
#define space putchar(' ')
#define Pair pair<int,int >
using namespace std;
	
template <typename tp> inline void read(tp &x)
{		
	x=0;
	RI f=1;
	RC c=getchar();
	while(c<'0' || c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	x*=f;
}	
	
template <typename tp> inline void print(tp x)
{	
	if(x<0) x=-x,putchar('-');
	if(x>9) print(x/10);
	putchar(x%10+'0'); 
}

#define int long long
const int N=1e6+10;
const int mod=998244353; 
int n,a,b,k; 
int jc[N];
int jc_inv[N];
int ans;

inline int mul(int x,int y)
{
	int res=1;
	for(;y;y>>=1)
	{
		if(y&1) res=(res*x)%mod;
		x=(x*x)%mod;
	}
	return res;
}

inline int C(int x,int y)
{
	if(y>x) return 0;
	int tmp1=jc[x];
	int tmp2=jc_inv[y];
	int tmp3=jc_inv[x-y];
	tmp1=(tmp1*tmp2)%mod;	
	tmp1=(tmp1*tmp3)%mod;
	return tmp1;
}

signed main()
{
	jc[0]=1;jc_inv[0]=1;//别忘了初始化这里 不然会疯狂WA 
	for(RI i=1;i<=300002;++i) jc[i]=(jc[i-1]*i)%mod,jc_inv[i]=mul(jc[i],mod-2);
	read(n),read(a),read(b),read(k);
	
	for(RI R=0;R<=n;++R)
	{
		if(R*a>k) break;
		int B=k-R*a;
		if(B%b) continue;
		B/=b;
		ans=(ans + (C(n,R) * C(n,B)) %mod) %mod;				
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, l, sum = 0, min = 300, num, app[200];
    cin >> n >> l;
    for(int i = 0; i < n; i++)
    {
        app[i] = l + i;
        sum += app[i];
        if(abs(app[i] < min))
        {
            min = abs(app[i]);
            num = i;
        }
    }
    cout << sum - app[num] << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()

	ans := -1
	if a <= 9 && b <= 9 {
		ans = a * b
	}
	fmt.Fprintln(stdout, ans)
}


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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

const int N = 5e5+10;
const int md = 1e9+7;
int store[N];

int sub(int n,int m){
// 	cout<<"sub "<<n<<" "<<m<<endl;
	if(n==0) return 1;
	if(n==1) return m-1;
	if(store[n]!=-1) return store[n];
	// store[n] = (m-1)*((sub(n-1,m-1)+sub(n-2,m-2))%md)%md;
	store[n] = (n-1)*((sub(n-1,m-1)+sub(n-2,m-2))%md)%md+(m-n)*sub(n-1,m-1)%md;
	store[n]%=md;
	// cout<<"store "<<n<<" "<<store[n]<<endl;
	return store[n];
}



signed main(){
	IOS
	memset(store,-1,sizeof(store));
	int n,m;cin>>n>>m;
	int c = 1;
	forn(i,n){
		c = (c*(m-i))%md;
	}
	int a = c;
	c=c*sub(n,m)%md;
	c=(c%md+md)%md;
	cout<<c;


}

Measured memory_bytes: 46456
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    vector<unsigned long> v(K + 1);
    for(unsigned long i{K}; i > 0; ){
        auto t = K / i;
        auto j = K / (t + 1);
        fill(v.begin() + j + 1, v.begin() + i + 1, modpow(t, N));
        i = j;
    }
    vector sieve(K + 1, 1UL);
    for(unsigned long p{2}; p <= K; ++p)if(sieve[p])for(unsigned long k{1}; k * p <= K; ++k){
                sieve[k * p] = 0;
                (v[k] += MOD - v[k * p]) %= MOD;
            }
    unsigned long ans{0};
    for(unsigned long i{0}; i <= K; ++i)ans += i * v[i];
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  ll n, k;
  cin >> n >> k;

  ll ans=k;
  rep(i,n-1){
    ans*=(k-1);
  }
  prt(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int n,d;
  cin>>n>>d;
  cout<<(n+(2*d))/(2*d+1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			puts("Yes");
			return 0;
		}
		a -= d;
		if (a <= 0) {
			puts("No");
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3640
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map{it.toLong()}

    val dp = Array (2) { LongArray(N + 1) { -1e18.toLong() } }
    dp[0][N] = 0L
    for (i in N - 1 downTo 0) {
        dp[0][i] = A[i] + Math.max(dp[0][i + 1], dp[1][i + 1])

        if (i + 2 <= N) {
            dp[1][i] = Math.max(
                dp[1][i + 1] - A[i] + A[i + 1] * 2,
                Math.max(dp[1][i + 2], dp[0][i + 2]) - A[i] - A[i + 1]
            )
        }
    }

    println(Math.max(dp[0][0], dp[1][0]))
}


Measured memory_bytes: 60028
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

//long long int a[100100];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	int d[k], a[k][n], count[n];
	for(int i=0; i<n; i++){
		count[i] = 0;
	}
	for(int i=0; i<k; i++){
		scanf("%d", &d[i]);
		for(int j=0; j<d[i]; j++){
			scanf("%d", &a[i][j]);
			count[a[i][j]-1]++;
		}
	}

	int ans = 0;
	for(int i=0; i<n; i++){
		if(count[i] == 0){
			ans++;
		}
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1744
import java.util.Scanner;

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

	  double x_1 = sc.nextDouble();
	  double y_1 = sc.nextDouble();
	  double x_2 = sc.nextDouble();
	  double y_2 = sc.nextDouble();
	  
	  double a = Math.pow((x_1 - x_2),2);
	  double b = Math.pow((y_1 - y_2),2);
	  double c = Math.sqrt(a+b);
	 
	  System.out.println(c);
	  
	  }
}



Measured memory_bytes: 28104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		String ans = "Yes";

		if (n % 4 != 0 && n % 7 != 0 && n % 11 != 0) {
			while (n >= 4) {
				if (n >= 7) {
					n -= 7;
				}
				if (n % 4 == 0 || n % 7 == 0 || n % 11 == 0) {
					n = 0;
				}
				if (n >= 4) {
					n -= 4;
				}
				if (n % 4 == 0 || n % 7 == 0 || n % 11 == 0) {
					n = 0;
				}
			}

			if (n != 0) {
				ans = "No";
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

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

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    n, d = map(int, input().split())
    cnt = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x**2 + y**2 <= d**2:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)) co("A");
  else co("B");
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,cnt=0,d,i;
  cin>>N;
  for(i=0;i<=2;i++)
  {
    d=N%10;
    N=N/10;
    if(d==7)
    {cnt++;}
  }
  if(cnt>0)
    cout<<"Yes";
    
   else
     cout<<"No";
  return 0;
}

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

int countDigit(ll num) {
  int count = 0;

  while (num > 0) {
    num /= 10;
    count++;
  }
  return count;
}

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

  int ans = countDigit(n);
  for (ll a = 1LL; a * a <= n; ++a) {
    if (n % a != 0) continue;

    ll b = n / a;
    int cur = max(countDigit(a), countDigit(b));
    if (ans > cur) {
      ans = cur;
    }
  }

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

Measured memory_bytes: 3572
import sys
# input = sys.stdin.readline
inf = 10 ** 18

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

x = [xi for xi, yi in xy]
y = [yi for xi, yi in xy]

ans = inf
for i in range(N - 1):
    xi, yi = xy[i]
    for j in range(i + 1, N):
        xj, yj = xy[j]
        #
        p = xj - xi
        q = yj - yi
        #
        ans_tmp = 0
        for n, (xn, yn) in enumerate(xy):
            xm = xn - p
            ym = yn - q
            # print("##", (xm, ym))
            if [xm, ym] not in xy: ans_tmp += 1
        #
        # print("#", xy, ans_tmp)
        if ans > ans_tmp: ans = ans_tmp

if N == 1:
    print(1)
else:
    print(ans)


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

int main() {
    string S, T;
    int ans = 0;
    cin >> S >> T;
    for(int i=0; i<3; i++) {
        if(S[i] == T[i]) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

sortA = sorted(A)
maxA = sortA[-1]
next_maxA = sortA[-2]

for i in range(N):
    if A[i] == maxA:
        print(next_maxA)
    else:
        print(maxA)


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

int main() {
  string s;
  cin >> s;
  string ss = s;
  reverse(s.begin(), s.end());
  if(s != ss){
    cout << "No" << endl;
    return 0;
  }

  string t = s.substr(0, (s.size()-1)/2);
  string tt = t;
  reverse(t.begin(), t.end());
  if(t != tt){
    cout << "No" << endl;
    return 0;
  }
  string p = s.substr((s.size()+3)/2);
  string pp = p;
  if(p != pp){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>g[40];
int v[40];
int deg[40];
pair<int,int>pt[40];
int n;
int dfs(int a){
	if(a==n){
		return 0;
	}
	int ret=999999999;
	v[pt[a].second]=-1;
	bool ok=true;
	for(int i=0;i<=a;i++){
		int f=pt[i].second;
		if(~v[f])continue;
		bool OK=false;
		for(int j=0;j<g[f].size();j++)if(~v[g[f][j]]){OK=true;break;}
		if(!OK){ok=false;break;}
	}
	if(ok){
		ret=min(ret,dfs(a+1));
	}
	v[pt[a].second]=1;
	ret=min(ret,dfs(a+1)+1);
	v[pt[a].second]=0;
	return ret;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		n=a;
		for(int i=0;i<a;i++)g[i].clear();
		for(int i=0;i<a;i++)v[i]=0;
		for(int i=0;i<b;i++){
			int p,q;scanf("%d%d",&p,&q);
			g[p].push_back(q);g[q].push_back(p);
			deg[p]++;deg[q]++;
		}
		int ret=0;
		for(int i=0;i<a;i++)pt[i]=make_pair(deg[i],i);
		ret=dfs(0);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1052
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

bool is_integer( double x ){
  return std::
  floor(x)==x;
}

int main(){
    string  a,b;
    cin>>a>>b;
    int x=stoi(a+b);
    double y=sqrt(x);
   if(is_integer(y))cout<<"Yes";
   else cout<<"No";
   return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n; cin >> n;
    vint a(n);
    mint sum = 0;
    rep(i,n) {
        int x; cin >> x;
        sum += x;
        a[i] = x;
    }
    mint ans = 0;
    rep(i,n-1) {
        sum -= a[i];
        ans += sum * a[i];;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}


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

int main()
{ 
  string s ;
  cin >> s ;
  if(s.size() < 4)
  {
    cout << "No" << endl ;
    return 0 ;
  }
  else if(s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I')
  {
    cout << "Yes" << endl ;
  }
  else
  {
    cout << "No" << endl ;
  }
  
}


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

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  int arr[n+1];
  for(int i = 1; i <= n; i++) arr[i] = 0;
  for(int i = 0; i < m; i++){
    int a,b;
    scanf("%d %d", &a, &b);
    arr[a]++;
    arr[b]++;
  }
  for(int i = 1; i <= n; i++){
    if(arr[i] % 2){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}

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

int main() {
    string s;
    cin>>s;
    unsigned long long int sum = 0;
    for(char c : s){
        sum+=(c-'0');
    }
    if(sum%9 == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3720
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static Scanner sc=new Scanner(in);
    public static void main(String[] args) {
        HashMap<Character,Integer> map=new HashMap<>();
        String s=sc.next();
        for (int i = 0; i < s.length(); i++) {
            map.put(s.charAt(i),map.getOrDefault(s.charAt(i),0)+1);
        }
        int c=0;
        for (Integer k:map.values())c+=k==2?1:0;
        out.println(c==2?"Yes":"No");
    }
}


Measured memory_bytes: 21844
#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>

#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
#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 bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#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() {
  int N, K; 
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  FOR(i, K, N){
    if(A[i] > A[i-K]) Yes;
    else No;
  }

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; ++i) cin >> p.at(i);
  
  int count = 0;
  for(int i = 0; i < N; ++i) if(i + 1 != p.at(i)) count++;
  
  if(count <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

using namespace std;

typedef long long ll;

int const N = 100 * 1000 + 16;

int n, m, k;
char w[N];
char a[N];

void chk(string c) {
  fill(a, a+n, 0);
  a[0] = c[0];
  a[1] = c[1];

  for(int x = 1; x <= n; ++x) {    
    int i = x % n;
    int l = (n+i-1)%n;
    int r = (i+1)%n;
    auto b = a[r];

    if(a[i] == 'S') {
      if(w[i] == 'o') a[r] = a[l];
      else a[r] = (a[l] == 'S' ? 'W' : 'S');
    } else {
      if(w[i] == 'x') a[r] = a[l];
      else a[r] = (a[l] == 'S' ? 'W' : 'S');
    }
  }

  if(a[0] == c[0] && c[1] == a[1]) {
    cout << a;
    exit(0);
  }
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n;
  cin >> w;
  chk("SS");
  chk("SW");
  chk("WS");
  chk("WW");
  cout << -1;
}

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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 1e2 + 10;

int a[N], b[N], c[N];

int main() {

   	sync;

	int n, sum = 0; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n - 1; i++) cin >> c[i];

	int last = -1;
	for(int i = 1; i <= n; i++) {
		sum += b[a[i]];
		if (last == a[i] - 1)  sum += c[last];
		last = a[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long sum = 0;

    for (long long i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum;
}

Measured memory_bytes: 3640
count = int(input());
data = input().split(" ");

def bubble_sort(data):
    # print(data);
    count = len(data);
    for i in range(count):
        for j in range(count - 1, i, -1):
            if data[j][1] < data[j - 1][1]:
                data[j], data[j - 1] = data[j - 1], data[j];
        # print(data);

def selection_sort(data):
    count = len(data);
    # print(data);
    for i in range(count - 1):
        minI = i;
        for j in range(i + 1, count):
            if data[j][1] < data[minI][1]:
                minI = j;
        if i != minI:
            data[i], data[minI] = data[minI], data[i];
        # print(data);

def show(data):
    print(" ".join(data));

A = list(data);
bubble_sort(A);
show(A);
print("Stable");

B = list(data);
selection_sort(B);
show(B);
if A == B:
    print("Stable");
else:
    print("Not stable");


Measured memory_bytes: 5608