akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(g: &Vec<Vec<usize>>, cur: usize, parent: usize) -> (usize, usize) {
    let mut max_depth = 0;
    let mut max_vertex = cur;
    for &ci in g[cur].iter() {
        if ci == parent {
            continue;
        }
        let (depth, vertex) = dfs(g, ci, cur);
        if max_depth < depth {
            max_depth = depth;
            max_vertex = vertex;
        }
    }
    (1 + max_depth, max_vertex)
}

fn main() {
    let n = read::<usize>();
    let mut g = vec![vec![]; n];
    for i in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        g[a].push(b);
        g[b].push(a);
    }
    let (_, vertex1) = dfs(&g, 0, n);
    let (depth, _) = dfs(&g, vertex1, n);
    debug!(depth);
    if (depth + 1) % 3 == 0 {
        println!("Second");
    } else {
        println!("First");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 35324
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <ctime>

using namespace std;

const int len = 110;
int n,ans,sum;
char s[len];
char a[len];
char mid[len];

bool pd(char s[],int l) {
	for (int i=1;i<l;i++) {
		if (s[i] != s[i-1]) return false;
	}
	return true;
}

void work(char c) {
	int k = n;
	for (k=n;;k--) {
		if (pd(mid,k)) return;
		for (int i=0;i<k-1;i++) {
			a[i] = ((mid[i] == c) || (mid[i+1] == c)) ? c : mid[i]; 
		}
		sum++;
		strcpy(mid,a);
	}
}

int main() {
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	scanf("%s",s);
	n = strlen(s);
	ans = INT_MAX;
	for (int i=0;i<n;i++) {
		sum = 0;
		strcpy(mid,s);
		work(s[i]);
		ans = min(ans,sum);
	}
	cout << ans << endl;
	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool comp(LLP a, LLP b){
    return a.first - a.second > b.first - b.second;
}

int solve(void){
    int n;
    cin >> n;
    vector< LLP > v(n);
    lint asum = 0, bsum = 0;
    rep(i, n){
        cin >> v[i].first;
        asum += v[i].first;
    }
    rep(i, n){
        cin >> v[i].second;
        bsum += v[i].second;
    }
    if(asum < bsum){
        return -1;
    }
    int res = 0;
    lint cost = 0;
    rep(i, n){
        if(v[i].first < v[i].second){
            ++res;
            cost += v[i].second - v[i].first;
        }
    }
    sort(v.begin(), v.end(), comp);
    int j = 0;
    while(j < n && cost > 0){
        ++res;
        cost += v[j].second - v[j].first;
        ++j;
    }
    return res;
}

int main(){
    int ans = solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e3;
int k, n, a[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i];
  sort(a, a+n);
  int s = 0;
  FOR(i, 0, k) s += a[i];
  cout << s << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int ans = 0;
    rep(i, N - 1) {
        if (S[i] == S[i + 1]) {
            ans++;
        }
    }
    cout << min(ans + 2 * K, N - 1) << endl;
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b , c, d;
    cin >> a >> b >> c >> d ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( b / a < c ){
        cout << b / a << endl;
    } else {
        cout << c << endl;
    }
    //*/
    
    cout << ( a - c )  * ( b - d ) << endl;

    return 0; 
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
std::vector<int>E[100010];
int n,d[100010];
struct tree{
	int siz[100010];
	std::vector<int>G[100010];
	int dfs(int x){
		int r=0;siz[x]=1;
		for(int i:G[x]){
			int s=dfs(i);
			if(r&&s)E[r].push_back(s),E[s].push_back(r),r=0;
			else r|=s;
			++siz[x];
		}
		d[x]^=siz[x]&1;
		if(siz[x]&1)
			if(r)E[r].push_back(x),E[x].push_back(r),r=0;
			else r=x;
		return r;
	}
	void input(){
		int rt;
		for(int i=1,x;i<=n;++i){
			x=gi();
			if(~x)G[x].push_back(i);
			else rt=i;
		}
		dfs(rt);
	}
}A,B;
int ans[100010];
void DFS(int x){
	for(int i:E[x])if(!ans[i])ans[i]=-ans[x],DFS(i);
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi();
	A.input();B.input();
	for(int i=1;i<=n;++i)if(d[i])puts("IMPOSSIBLE"),exit(0);
	puts("POSSIBLE");
	for(int i=1;i<=n;++i)if(!ans[i]&&(A.siz[i]&1))ans[i]=1,DFS(i);
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 17152
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by kosuke on 2014/07/06.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n, p;
        while ((n = scan.nextInt()) != 0 && (p = scan.nextInt()) != 0) {
            int cup_stone = p;
            boolean flag = false;
            ArrayList<Integer> candidate = new ArrayList<Integer>();
            for(int i=0; i<n; i++){
                candidate.add(0);
            }

            for(int i=0; i<n; i++){
                if(cup_stone != 0) {
                    candidate.set(i, (candidate.get(i)) + 1);
                    cup_stone -= 1;
                    if(i == n-1) {
                        i = -1;
                    }
                    continue;
                }

                for(int j=0; j<n; j++){
                    if(candidate.get(j) > 0 && candidate.get(j) < p){
                        cup_stone = candidate.get(i);
                        candidate.set(i,0);
                        break;
                    }
                    else if(candidate.get(j) == p){
                        System.out.println(j);
                        flag = true;
                        break;
                    }
                }
                if(flag == true){
                    break;
                }
                if(i == n-1) {
                    i = -1;
                }
            }
        }
    }
}

Measured memory_bytes: 23244
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;

int N;

bool isPrime[(1<<16)+1];
vector<ll> primes;
void init() {
    memset(isPrime, -1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = false;
    for (ll i = 2; i <= (1<<16); i++) {
        if (isPrime[i]) {
            primes.push_back(i);
            for (ll j = i + i; j <= (1<<16); j += i) {
                isPrime[j] = false;
            }
        }
    }
}

bool valid(ll n) {
    // n = 2xy + x + y
    // 2*n+1 = (2x+1)(2y+1) -- (1)
    // 与えられたnについて(1)を満たすようなx,y(x, y > 0)が存在するかどうか
    //
    // 2*n+1が素数であるかどうかを判定すればいい. 素数ならありえないnである.
    n = 2 * n + 1;
    for (int i = 0; i < primes.size() && primes[i] * primes[i] <= n; i++) {
        if (n % primes[i] == 0) return true;
    }
    return false;
}

int main() {
    cin >> N;
    int ans = 0;
    init();
    for (int i = 0; i < N; i++) {
        ll n; cin >> n;
        if (!valid(n)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

int x[5000], a[5000];
int dp[2][5010];
const int MOD = ten(9) + 7;

int main(){
	int n, l;
	scanf("%d%d", &n, &l);
	FOR(i, n) scanf("%d", x + i);
	FOR(i, n) scanf("%d", a + i);
	FOR(i, n) x[i]++;

	FOR(i,l+1) dp[0][i] = 1;
	auto pv = dp[0], nt = dp[1];
	FOR(i, n){
		memset(nt, 0, sizeof(dp[0]));
		if (a[i]) {
			for (int dist = 0; x[i] + dist <= l; dist += a[i]) {
				int cur = x[i] + dist;
				nt[cur] = pv[cur - 1];
			}
		} else {
			nt[x[i]] = pv[x[i] - 1];
		}
		FOR(j, l){
			nt[j + 1] += nt[j];
			if (nt[j + 1] >= MOD)  nt[j + 1] -= MOD;
		}
		swap(pv, nt);
	}
	cout << pv[l] << endl;
}

Measured memory_bytes: 1284
import java.util.*;

public class Main {

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

    int count = 0;

    for(int i = 0;i < n;i++) {
      data[i] = sc.nextInt();
    }

    for(int i = 0;i < n;i++) {
      if(data[i] != i+1) {
        count++;
      }
    }

    if(count == 0 || count == 2) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

  }

}

Measured memory_bytes: 21204
# -*- coding:utf-8 -*-

def solve():
    N, K = list(map(int, input().split()))

    sunukes = [0 for _ in range(N)]
    for k in range(K):
        d = int(input())
        As = list(map(int, input().split()))
        for a in As:
            a = a-1
            sunukes[a] = 1

    ans = N - sum(sunukes)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

bool check(vector<int> a, vector<int> b) {
  for(int i = 0; i < a.size(); i++) if(a[i] != b[i]) return false;
  return true;
}

int main() {
 
  int n; cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  for(int i = 0; i < n; i++) cin >> q[i];
  int a;
  int b;
  int id = 0;
  vector<int> v(n);
  for(int i = 0; i < n; i++) v[i] = i + 1;
  
  do{
    if(check(p, v)) a = id;
    if(check(q, v)) b = id;
    id++;
  }while(next_permutation(ALL(v)));

  cout << (int)abs(a - b) << endl;
  return 0;
}


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

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll wCnt = 0;
  rep(i,n) {
    if (s[i] == 'W') {
      ++wCnt;
    }
  }

  ll ans = 0;
  // Here, we want all w in right.
  rep(i,wCnt) {
    if (s[n-1-i] != 'W') {
      ++ans;
    }
  }
  cout << ans << endl;
}


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

int main() {
	int w, h, x, y, r;

	cin >> w >> h >> x >> y >> r;

	if (x - r < 0 || w < x + r) {
		cout << "No" << endl;
	}
	else if (y - r < 0 || h < y + r) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
N = int(input())

A = list(map(int, input().split()))

flag = 0
ans = 1

if 0 in A:
    print(0)
    flag = 1

for i in range(N):
    if flag == 1:
        break
    ans = ans * A[i]
    if ans > 1000000000000000000 :
        print('-1')
        flag = 1
        break
if flag == 0:
    print(ans)

Measured memory_bytes: 87960
inputA = input()

alfabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

index = alfabet.index(inputA)

if index >= 25 :
    print("a")
else:
    print(alfabet[index+ 1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  while(true) {
    int N, M, C[16];
    cin >> N >> M;
    if(N == 0 && M == 0) break;
    REP(i, M) {
      cin >> C[i];
    }
    int sum[256], nsum[256];
    REP(i, 256) {
      sum[i] = i == 128 ? 0 : (1 << 30);
    }
    REP(i, N) { 
      int ty;
      cin >> ty;
      REP(j, 256) {
        nsum[j] = 9999999999;
      }
      REP(y, 256) {
        REP(k, M) {
          int ny = y + C[k];
          if(ny < 0) ny = 0;
          if(ny > 255) ny = 255;
          int d = ny - ty;
          int tsum = sum[y] + d * d;
          if(tsum < nsum[ny]) nsum[ny] = tsum;
        }
      }
      REP(j, 256) {
        sum[j] = nsum[j];
      }
    }
    int minsum = 999999999;
    REP(i, 256) {
      if(minsum > sum[i]) minsum = sum[i];
    }
    cout << minsum << endl;
  }
}


Measured memory_bytes: 3092
A, B = map(int, input().split())
def factorization(n):
    arr = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
a = factorization(A)
b = factorization(B)
ans = len(set(a) & set(b))
print(ans)

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

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;
int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.size(), hugs = 0;
	for(int k = 0; k < n / 2; ++k)
		if(s[k] != s[n - k - 1]) ++hugs;
	cout << hugs << '\n';
    return 0;
}


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

int main(){
	string stc;
	//stc = "Hello, World.";
	vector<long> fl(26, 0);
	char alp[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
	'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
	while (cin >> stc){
		for (long i = 0; i < stc.size(); i++){
			if (isupper(stc[i])) stc[i] = tolower(stc[i]);
			long cd;
			cd = (char)stc[i] - (long)'a';
			//cout << cd << endl;
			if (cd >= 0 && cd <= 25) fl[cd]++;
		}
	}
	for (long i = 0; i < 26; i++){
		cout << alp[i] << " : " << fl[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
 
void topological(vector<int> graph[],vector<int> &vis,stack<int> &s,int u)
{
  vis[u]=1;
  for(int i=0;i<graph[u].size();i++)
  {
    if(vis[graph[u][i]]==0)
      topological(graph,vis,s,graph[u][i]);
  }
  s.push(u);
}
 
int main()
{
  ll n,m;
  cin>>n>>m;
  vector<int> graph[n];
  for(int i=0;i<m;i++)
  {
    ll x,y;
    cin>>x>>y;
    graph[x-1].push_back(y-1);
  }
  vector<int> vis(n,0);
  stack<int> s;
  for(int i=0;i<n;i++)
  {
    if(vis[i]==0)
      topological(graph,vis,s,i);
  }
 
  vector<ll> dis(n,0);
  while(!s.empty())
  {
    ll top=s.top();
    s.pop();
    for(int i=0;i<graph[top].size();i++)
    {
      if(dis[graph[top][i]]<dis[top]+1)
        dis[graph[top][i]]=dis[top]+1;
    }
  }
 
  ll maxi=0;
  for(int i=0;i<n;i++)
    maxi=max(maxi,dis[i]);
 
  cout<<maxi<<endl;
}

Measured memory_bytes: 12924
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    ll count = 0;
    for (ll i = 1; i <= N; i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
        {
            count += 0;
        }
        else
        {
            count += i;
        }
    }

    cout << count << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    vector<int>arr(n);
    
    ll sum=0;
    
    map<ll,ll>mp;
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
        
        mp[arr[i]]++;
    }
    
    int q;
    cin>>q;
    
    int x,y;
    
    for(int i=0;i<q;i++)
    {
        cin>>x>>y;
        
        sum = sum - (mp[x]*x) + (y*mp[x]);
    
        mp[y]+=mp[x];
        mp[x]=0;
        
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 9528
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;


int main() {
  std::string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (u == s) {
    a -= 1;
  } else {
    b -= 1;
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        char [] str = sc.next().toCharArray();
        for(int x = str.length-1; x >= 0; x--) {
            System.out.print(str[x]);
        }

        System.out.print("\n");
    }
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
bool kkk(int n){
  bool ans =false;
  for(int i=1;i<=n;i++){
    if(n%i==0){
      for(int j=2;j<11;j++){
        if(pow(i,j)==n) {
          ans =true;
          break;
        }
      }
    }
  }
  if(ans) return true;
  else return false;
}
      
int main() {
  int n,j =2;
  cin >> n;
  for(int i=n;i>=1;i--){
    if(kkk(i)) {
      cout << i <<endl;
      break;
    }
  }
}
  

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


int main() {
    int N ;
    cin >> N ;
    int A[N] ;
    rep(i,N) cin >> A[i] ;
    map<ll,ll> mp ;
    rep(i,N) mp[A[i]]++ ;
    ll ans = 0 ;
    for(auto p : mp){
        ll a = p.second*(p.second-1)/2 ;
        ans += a ;
    }
    rep(i,N){
        ll b = mp[A[i]] * (mp[A[i]] - 1 ) / 2 ;
        ll c = (mp[A[i]] - 1 ) * (mp[A[i]] - 2 ) / 2   ;
        ll d = max(c,(ll)0) ;
        cout << ans - b + d <<endl;
    }
}

Measured memory_bytes: 10240
#include <stdio.h>
 int main(void)
{
 int a, b, c;
//Three integers
 scanf("%d%d%d", &a, &b, &c);
 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;
 if (ispoor) 
{//If triple is poor
 puts("Yes");
 } 
else 
{
 puts("No");
 }
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int dp[] = new int[n+10];
		dp[0] = 0;
		for (int i = 1; i <= n; i++) {
			dp[i] = dp[i - 1] + 1;
			int pow6=1;
			while(0<=i-pow6&&i-pow6<=n) {
			dp[i]=Math.min(dp[i], dp[i-pow6]+1);
			pow6*=6;
			}
			int pow9=1;
			while(0<=i-pow9&&i-pow9<=n) {
			dp[i]=Math.min(dp[i], dp[i-pow9]+1);
			pow9*=9;
			}
		}
		System.out.println(dp[n]);
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int K;
    cin>>K;
    ll A[K];
    for(int i=0;i<K;++i){
        cin>>A[i];
    }
    ll l = 1, r = 1e15; 
    ll m;
    ll ansmin, ansmax;
    while(l<r){
        m = (l+r)/2;
        for(int i=0;i<K;++i){
            m -= m % A[i];
        }
        if(m>=2){
            r = (l+r)/2;
        }
        else{
            l = (l+r)/2+1;
        }
    }
    ansmin = l;
    l = 1, r = 1e15; 
    while(l<r){
        m = (l+r)/2;
        for(int i=0;i<K;++i){
            m -= m % A[i];
        }
        if(m>2){
            r = (l+r)/2;
        }
        else {
            l = (l+r)/2+1;
        }
    }
    ansmax = l - 1;
    if(ansmax<ansmin)cout<<-1<<endl;
    else cout<<ansmin<<" "<<ansmax<<endl;
}



Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  int a = 0;
  repi(i, 1, N + 1){
    a += i;
  }
  co(a);
}

Measured memory_bytes: 256
h,n = [int(i) for i in input().split()]
 
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: x[0])
 
inf = float('inf')
memo = [inf for _ in range(10**5)]
memo[0] = 0
for i in range(h+1):
    for x,y in l:
        memo[i+x] = min(memo[i+x],memo[i] + y)
print(min(memo[h:]))

Measured memory_bytes: 48832
#define f(I)(p[I]+h[I]*(h[I]-2*h[i]))
long C,h[2<<17],p[2<<17],X,a;
P[2<<17];
s,t,x,y;
main(i){
	for(scanf("%*d%ld%ld",&C,h);~scanf("%ld",&a);P[++t]=i-1){
		for(h[i]=a;X=f(P[s]),s<t&&X>=f(P[s+1]);s++);
		for(p[i++]=X+=a*a+C;s<t&&(h[y=P[t]]-h[x=P[t-1]])*(f(y)-f(i-1))>(a-h[y])*(f(x)-f(y));t--);
	}
	printf("%ld",X);
}

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

int main(){

    int n,t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    double temp = 0;
    double comptemp = DBL_MAX;
    int ans = 0;
    for(int i=1; i<=n; i++){
        temp = t - h.at(i-1) * 0.006;
        temp = abs(a - temp);
        if(comptemp > temp){
            comptemp = temp;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n;
    cin >> n;
    vi s(n);
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        ret += s[i];
    }
    if (ret % 10 != 0) {
        cout << ret << endl;
        return 0;
    }
    sort(s.begin(), s.end());
    bool found = false;
    for (int i = 0; i < n; ++i) {
        if (s[i] % 10 != 0) {
            ret -= s[i];
            found = true;
            break;
        }
    }
    if (found)
        cout << ret << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

int main()
{
  ll N, K;cin>>N>>K;
  ll ans = K;
  for (int i = 1; i < N; i ++) ans *= (K - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>

#define N 529

int main(void)
{
	char s[N][N],a[N];
	int n,l,i,j;
	scanf("%d%d",&n,&l);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(strcmp(s[j-1],s[j])>0){
				strcpy(a,s[j-1]);
				strcpy(s[j-1],s[j]);
				strcpy(s[j],a);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
package main

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

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

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

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

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}

	q := partition(aa, 0, n-1)

	p1 := strings.Trim(fmt.Sprintf("%v", aa[0:q]), "[]")
	p2 := fmt.Sprintf("%v", aa[q:q+1])
	p3 := strings.Trim(fmt.Sprintf("%v", aa[q+1:]), "[]")

	fmt.Fprintln(writer, fmt.Sprintf("%s %s %s", p1, p2, p3))

	writer.Flush()
}

func partition(a []int, p, r int) int {
	x := a[r]
	i := p - 1
	for j := p; j < r; j++ {
		if a[j] <= x {
			i++
			a[i], a[j] = a[j], a[i]
		}
	}
	a[i+1], a[r] = a[r], a[i+1]
	return i + 1
}



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

int main(){
  string s;
  int count = 0;

  while(cin >> s){
    int start=0, end=s.size()-1;
    while(1){
      if(start == end || (s.size() / 2 < start)){
	count++;
	break;
      }
      if(s[start] != s[end]){
	break;
      }
      start++; end--;
    }    
  }
  cout << count << endl;
  return 0;
}

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

int n, k;
int imos[1000*4][1000*4];

int main() {

    // input
    cin >> n >> k;
    while(n--){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') x += k;
        x %= 2*k;
        y %= 2*k;

        for(int i=x%k+1;i<4*k;i+=k){
            for(int j=y%k+1;j<4*k;j+=k){
                if((i+j)%(2*k) != (x+1+y+1)%(2*k)) continue;
                if(i+k < 4*k && j+k < 4*k){
                    imos[i][j]++;
                    imos[i+k][j]--;
                    imos[i][j+k]--;
                    imos[i+k][j+k]++;
                }
            }
        }
        //for(int i=0;i<4*k;i++){
            //for(int j=0;j<4*k;j++){
                //printf("%2d ", imos[i][j]);
            //}
            //printf("\n");
        //}
        //printf("\n");
    }

    // debug
    //for(int i=0;i<4*k;i++){
        //for(int j=0;j<4*k;j++){
            //printf("%2d ", imos[i][j]);
        //}
        //printf("\n");
    //}

    // imos
    for(int i=0;i<4*k;i++){
        for(int j=1;j<4*k;j++){
            imos[i][j] += imos[i][j-1];
        }
    }
    for(int i=1;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            imos[i][j] += imos[i-1][j];
        }
    }

    // debug
    //printf("\n");
    //for(int i=0;i<4*k;i++){
        //for(int j=0;j<4*k;j++){
            //printf("%2d ", imos[i][j]);
        //}
        //printf("\n");
    //}

    // output
    int ans = 0;
    for(int i=0;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            ans = max(ans, imos[i][j]);
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    ll int a,c=0;
    cin>>a;
    if(a%2==1)
    cout<<c;
    else
    {
 for(ll int i=10;i<=a;i=i*5)
 {

 c+=a/i;

 }
 cout<<c;
    }

return 0;
}

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

#define ll long long int

using namespace std;

int main() {

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

	int n,l;
	cin>>n>>l;

	string a[n];

	for(int i=0;i<n;i++)cin>>a[i];

	sort(a,a+n);

	string res="";
	
	for(int i=0;i<n;i++)res = res+a[i];

	cout<<res<<endl;

	return 0;

}


Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()
b=input()
n=len(b)
l=[""]*n
for i in range(n):
    if b[i]=="A":
        l[i]="T"
    if b[i]=="T":
        l[i]="A"
    if b[i]=="G":
        l[i]="C"
    if b[i]=="C":
        l[i]="G"
print(*l)

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = list(map(int, input().split()))
    limit = pow(10, 18)
    A.sort()
    ans = 1
    if A[0] == 0:
        print(0)
    else:
        for a in A:
            ans *= a
            if ans > limit:
                print(-1)
                break
        else:
            print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21604
import java.util.Scanner;


public class Main {

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

		int N = sc.nextInt();
		for (int i = 0 ; i < N ; i++) {
			double x1 = sc.nextDouble(),
					y1 = sc.nextDouble(),
					x2 = sc.nextDouble(),
					y2 = sc.nextDouble(),
					x3 = sc.nextDouble(),
					y3 = sc.nextDouble();

			double a1 = 2*(x2-x1), b1 = 2*(y2-y1),
					c1 = x1*x1-x2*x2+y1*y1-y2*y2,
					a2 = 2*(x3-x1), b2 = 2*(y3-y1),
					c2 = x1*x1-x3*x3+y1*y1-y3*y3;

			double px = (b1*c2-b2*c1)/(a1*b2-a2*b1),
					py = (c1*a2-c2*a1)/(a1*b2-a2*b1),
					r = Math.sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));

			System.out.println(String.format("%.3f %.3f %.3f", px, py, r));
		}

	}
}

Measured memory_bytes: 20792
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
 
using namespace std;
using ll =long long;
using P = pair<int,int>;
 
int K;
 
int main(int argc, const char * argv[]) {
    
    cin >> K;
    
    ll c=0;
    ll num=7;
    while(c<=K){
        c++;
        if(num%K==0){
            break;
        }
        num = num%K;
        num = (num * 10 + 7);
    }
    
    if(num%K==0) cout << c << endl;
    else cout << "-1" << endl;
    
    return 0;
}

Measured memory_bytes: 3176
#include "bits/stdc++.h"

using namespace std;

/**
 * 全探索
 * ﾁｮｯﾄｶｲｾﾂﾐﾀ
 */

using ll = long long int;

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

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

	vector<ll> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	vector<ll> xx = x, yy = y;
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());

	ll res = (xx[n - 1] - xx[0]) * (yy[n - 1] - yy[0]);

	// 非競プロerが見たら発狂しそうなfor
	for (int xi = 0; xi < n; xi++) {
		for (int xj = xi + 1; xj < n; xj++) {
			for (int yi = 0; yi < n; yi++) {
				for (int yj = yi + 1; yj < n; yj++) {
					int num = 0;
					ll left = xx[xi], right = xx[xj];
					ll bottom = yy[yi], top = yy[yj];

					for (int i = 0; i < n; i++) {
						if (left <= x[i] && x[i] <= right && bottom <= y[i] && y[i] <= top) {
							num++;
						}
					}

					if (num >= k) {
						res = min(res, (right - left) * (top - bottom));
					}
				}
			}
		}
	}

	cout << res << endl;
	return 0;
}


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

long multiple(int i, int j, int m, long** A, long** B){
    long ret=0;

    for(int r=0;r<m;r++){
        ret += A[i][r] * B[r][j];
    }
    return ret;
}

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    //int A[n][m];
    long** A = new long*[n];
    for(int i=0;i<n;i++)A[i] = new long[m];
    //int B[m][l];
    long** B = new long*[m];
    for(int i=0;i<m;i++)B[i] = new long[l];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
            //cout << A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> B[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j)cout << " ";
            cout << multiple(i, j, m, A, B);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
using namespace std;
#define ll long long
typedef pair<int, int> P;
char maze[30][30];
int  w, h;
int sx, sy;
int ans = 0;

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

void bfs() {
	queue<P> que;
	que.push(P(sy, sx));

	while (que.size()) {
		P p = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.second + dx[i], ny = p.first + dy[i];


			if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != '#') {
				que.push(P(ny, nx));
				maze[ny][nx] = '#';
				ans++;
			}
		}
	}
	return;
}

int main() {
	while (1) {
		ans = 0;
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> maze[i][j];
				if (maze[i][j] == '@') {
					maze[i][j] = '#';
					sx = j;
					sy = i;
					ans++;
				}
			}
		}
		bfs();
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

int c[26];
int main() {
    int i;
    int N;
    string S;
    cin >> N >> S;

    for (i = 0; i < N; i++) c[S[i]-'a']++;
    LLI ans = 1;
    for (i = 0; i < 26; i++) ans *= c[i]+1,ans %= MOD;
    cout << (ans+MOD-1) % MOD << endl;

    return 0;
}



Measured memory_bytes: 3728
#ifndef LOCAL
#pragma GCC optimize("O2")
#endif
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main(){
   int  N;cin >> N;
   vector<int> A(N), B(N);

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

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

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  int MIN=0;
  for(int i=0;i<N;i++){
    if(MIN<H[i]){H[i]--;MIN=H[i];}
    else if(MIN>H[i]){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main() {
    int k;
    cin >> k;
    int cnt = 0;
    int rem = 0;
    set<int> st;
    while(1){
        cnt++;
        rem = (rem*10 + 7)%k;
        if (rem == 0){
            cout << cnt << endl;
            return 0;
        }
        if (st.find(rem)!=st.end()){
            cout << -1 << endl;
            return 0;
        }
        st.insert(rem);
    }
}

Measured memory_bytes: 50468
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<bool> IsPrime(1000010,true);
void sieve(ll n){
    REP(i,2,n+1){
        if(IsPrime[i]){
            ll k=2;
            while(k*i<=n){
                IsPrime[k*i]=0;
                k++;
            }
        }
    }
}
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[200010],finv[200010],inv[200010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,200010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll 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(){
    ll n,m;
    cin>>n>>m;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    sieve(1000010);
    combinit();
    ll k=m;
    vector<ll>fact(1000010);
    REP(i,2,sqrt(m)+1){
        while((k%i==0)&&IsPrime[i]){
            fact[i]++;
            k/=i;
        }
    }
    ll ans=1;
    if(k!=1)ans*=n;
    REP(i,2,sqrt(m)+1){
        if(fact[i]){
            ans*=comb(fact[i]+n-1,n-1);
            ans%=inf;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12928
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: i64, b: i64, c: i64, k: i64
    }
    if a >= k {
        println!("{}", k);
        return;
    }
    let kb = k - a;
    if b >= kb {
        println!("{}", a);
        return;
    }
    let kc = kb - b;
    println!("{}", a - kc);

}


Measured memory_bytes: 2196
#include <stdio.h>
#include <string.h>

 
int main(){
  char a[10];
  char b[10];
  int d;
  int e;
  char f[10];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%s",f);
  
  if(strcmp(f,a)==0){
    d = d-1;
  }else{
    e = e-1;
  }
  printf("%d %d",d,e);
  
  return 0;
}

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

int check(int n){
    int a, b, c, d, e;
    int ans = 0;
    e = n % 10;
    n /= 10;
    d = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    a = n % 10;
    n /= 10;
    if (a == e && b == d) ans = 1;
    return ans;
}

int main(){
    int A, B;
    cin >> A >> B;
    int sum=0;
    for (int i=A; i<=B; i++){
        sum += check(i);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s, ans;
  in(s);
  ans = "AC";
  if(s[0] != 'A')
    ans = "WA";
  ll k;
  k = 0;
  bool h;
  char a;
  rep2(i, 1, s.size()){
    a = 'A';
    h = false;
    rep(j, 26){
      if(s[i] == a)
        h = true;
      a++;
    }
    if(h){
      if(i == 1 || i == s.size() - 1 || s[i] != 'C')
        ans = "WA";
    }
    if(s[i] == 'C')
      k++;
  }
  if(k != 1)
    ans = "WA";
  out(ans);
  memi;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for w in range(1, W):
  if a[0][w] != '#':
    dp[0][w] = dp[0][w - 1]

for h in range(1, H):
  ah = a[h]
  dph = dp[h]
  dph1 = dp[h - 1]
  if ah[0] != '#':
    dph[0] = dph1[0]
  for w in range(1, W):
    if ah[w] != '#':
      dph[w] = (dph[w - 1] + dph1[w]) % 1000000007

print(dp[H - 1][W - 1])


Measured memory_bytes: 43636