akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

void bfs(vector<int>& dist, const int start, const vector<vector<int>>& g){
	dist[start] = 0;
	queue<int> q;
	q.push(start);
	
	while(!q.empty()){
		int now = q.front();
		q.pop();
		for(auto itr : g[now]){
			if(dist[itr] != INF) continue;
			dist[itr] = dist[now] + 1;
			q.push(itr);
		}
	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<int>> g(n, vector<int>());
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<int> dist_f(n, INF);
	bfs(dist_f, 0, g);
	
	vector<int> dist_s(n, INF);
	bfs(dist_s, n - 1, g);
	
	int f_near = 0, s_near = 0;
	for(int i = 0; i < n; ++i){
		if(dist_f[i] <= dist_s[i]){
			f_near++;
		}
		else{
			s_near++;
		}
	}
	
	if(f_near > s_near) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	
	return 0;
}



Measured memory_bytes: 6528
def main():
	S = input()
	h = [0] * (len(S) + 1)

	#  <  となっている場合だけを考える
	# a[i] < a[i+1] でない場合、a[i] に +1 したものを a[i+1] にする
	for i in range(len(S)):
		if(S[i] == "<"):
			h[i+1] = max(h[i+1], h[i] + 1)

	# > となっている場合だけを考える
	# a[i-1] > a[i] でない場合、a[i] に +1 したものを a[i-1] にする
	# この時この操作は逆順から行う
	for i in range(len(S), 0, -1):
		if(S[i-1] == ">"):
			h[i-1] = max(h[i-1], h[i] + 1)

	print(sum(h))

if __name__ == "__main__":
	main()

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


constexpr int P = 1'000'000'007;

void solve(std::istream &in, std::ostream &out) {
  int n, k;
  in >> n >> k;
  vector<int> pos, neg;
  bool zero = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    in >> x;
    zero |= x == 0;
    if (x > 0) pos.push_back(x);
    if (x < 0) neg.push_back(-x);
  }
  int ps = pos.size();
  int ns = neg.size();
  if (ps + ns < k) {
    out << 0 << '\n';
    return;
  } else if (ps + ns == k) {
    int ans = 1;
    for (int i = 0; i < ps; ++i) {
      ans = (int64_t) ans * pos[i] % P;
    }
    for (int i = 0; i < ns; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
    return;
  }
  sort(pos.rbegin(), pos.rend());
  sort(neg.rbegin(), neg.rend());
  vector<long double> lpos(1, 0), lneg(1, 0);
  for (int i = 0; i < ps; ++i) {
    lpos.push_back(lpos.back() + log((long double)pos[i]) + log2((long double)pos[i]));
  }
  for (int i = 0; i < ns; ++i) {
    lneg.push_back(lneg.back() + log((long double)neg[i]) + log2((long double)neg[i]));
  }
  vector<pair<double, int>> pp;
  if (ps > 0) {
    int ans = 1;
    int itt = (k - min(ps, k)) % 2 == 0 ? min(ps, k) : min(ps, k) - 1;   
    int  l = itt - 1, r = k - itt;
    while (l > 0 && r + 1 < ns && (int64_t) pos[l] * pos[l - 1] < (int64_t) neg[r] * neg[r + 1]) {
      l -= 2;
      r += 2;
    }
    for (int i = 0; i <= l; ++i) {
      ans = (int64_t) ans * pos[i] % P;
    }
    for (int i = 0; i < r; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
  } else {
    if (k % 2 == 1) {
      if (zero) {
        cout << 0 << '\n';
        return;
      }
      reverse(neg.begin(), neg.end());
    }
    int ans = 1;
    for (int i = 0; i < k; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
    return;
  }
}


Measured memory_bytes: 9192
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

bool cmp_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}




int main(void){

    int r;
    cin >> r;

    cout << 3*r*r << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	if S == "SUN" {
		fmt.Println(7)
	} else if S == "MON" {
		fmt.Println(6)
	} else if S == "TUE" {
		fmt.Println(5)
	} else if S == "WED" {
		fmt.Println(4)
	} else if S == "THU" {
		fmt.Println(3)
	} else if S == "FRI" {
		fmt.Println(2)
	} else if S == "SAT" {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
  int a,b;
  cin >> a >> b;
  if(a>b) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

long long solve(long long h, long long w) {
	if (w%h == 0)
		return w * 2 - h;
	else
		return (w / h) * 2 * h + solve(w%h, h);
}

int main() {
	long long n, x, ans;
	cin >> n >> x;
	if (2 * x == n)ans = 3 * x;
	else if (2 * x < n)ans = n + solve(x, n - x);
	else ans = n + solve(n - x, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int e;
  int x = 0;
  int y = 0;
  int z = 0;
  while(cin >> e && e > 0){
    int min = e;
    int zmax = ceil(pow(e, 1.0/3.0));
    int ymax = ceil(pow(e, 1.0/2.0));
    for(int i=0; i<=zmax; i++){
      for(int j=0; j<=ymax; j++){
        int y2 = j * j;
        int z3 = i * i * i;
        x = e - y2 - z3;
        if(x >= 0 && min > x + i + j){
          min = x + i + j;
        }
      }
    }
    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 3268
def calc(S):
    p = q = 0
    for c in S[1:]:
        if c == 'A':
            p += 1
        else:
            q += 1
    return p, q
def check(p, q):
    if q < 10:
        return p == 11
    return p - q == 2

while 1:
    S1 = input()
    if S1 == "0":
        break
    S2 = input()
    S3 = input()

    p1, q1 = calc(S1)
    if S2[0] == 'A':
        p1 += 1
    else:
        q1 += 1
    print(p1, q1)

    p2, q2 = calc(S2)
    if S3[0] == 'A':
        p2 += 1
    else:
        q2 += 1
    print(p2, q2)

    p3, q3 = calc(S3)
    if check(p3+1, q3):
        print(p3+1, q3)
    else:
        print(p3, q3+1)


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define ll long long
#define mod1 1000000007LL
#define mod2 1000000009LL
#define base1 19
#define base2 31
#define base3 137
#define MAX 1e12
#define MIN -10000000000
#define pi acos(-1)
#define esp 1e-6
#define memz(x) memset(x, 0, sizeof x)
#define memn(x) memset(x, -1, sizeof x)
#define pb push_back
#define nai string::npos
#define in1(a) scanf("%lld", &a)
#define in2(a,b) scanf("%lld%lld", &a, &b)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(i) printf("Case #%lld: ", ++i)
#define FILE    freopen("input.txt", "r", stdin); freopen("out.txt", "w", stdout);
using namespace std;
const ll N = 100010;
ll a[N], n, rsz, lsz, sz, res[N];
vector<ll>r, l;
string s;
ll lbs(ll pos)///left er jnno right khujbe
{
    ll high = rsz-1, low=0, mid, ans=0;
    while(high>=low)
    {
        mid=(high+low)/2;
        if(r[mid]<pos)
        {
            ans=r[mid];
            low=mid+1;
        }
        else
            high=mid-1;
    }
    return ans;
}
ll rbs(ll pos)
{
    ll high = lsz-1, low=0, mid, ans=sz-1;
    while(high>=low)
    {
//        cout<<high<<" bs "<<low<<endl;
        mid=(high+low)/2;
        if(l[mid]>pos)
        {
            ans=l[mid];
            high=mid-1;
        }
        else
            low=mid+1;
    }
    return ans;
}
int main()
{
    cin>>s;
    sz=s.length();
    for(int i=0; i<sz; i++)
    {
        if(s[i]=='R')
            r.pb(i);
        else l.pb(i);
    }
    rsz=r.size();
    lsz=l.size();
    for(int i=0;i<sz;i++)
    {
        if(s[i]=='R')
        {
            ll x = rbs(i);
            ll y = x-i;
//            cout<<i<<" "<<x<<" "<<y<<endl;
            if(y&1)
                res[x-1]++;
            else res[x]++;
        }
        else
        {
            ll x = lbs(i);
            ll y = x-i;
            if(y&1)
                res[x+1]++;
            else res[x]++;
        }
    }
    for(int i=0;i<sz;i++)
    {
        if(i>0) printf(" ");
        printf("%lld", res[i]);
    }
    return 0;
}



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

int main() {
    int r, D, x2000;
    cin >> r;
    cin >> D;
    cin >> x2000;

    vector<int> A;

    A.push_back(r * x2000 - D);
    for(int i=1; i<10; ++i) {
        A.push_back(r * A[i-1] - D);
    }

    for(auto a : A) {
        cout << a << endl;
    }
}

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

int main(){
int N,T;
  cin>>N>>T;
  vector<int>c(N), t(N);
  for(int i=0; i<N; i++){
   cin>>c[i]>>t[i]; }
  
  int count=0, ans=1000;
  for(int i=0; i<N; i++){
   if(t[i]>T){count++;}
   if(t[i]<=T){ans=min(ans, c[i]);} 
  }

  if(count==N){cout<<"TLE";}
  else{cout<<ans;}
}

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

//型定義
typedef long long ll;

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1e+9+7 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>=(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入



int main(){
    string S;
    cin >> S;
    int N = S.size();
    vector<int> dp(N);
    vector<vector<int>> mod_table(10,vector<int>(N,0));
    REP(i,10){
        mod_table[i][0]=i;
    }
    REP(i,10){
        REP(j,N-1){
            mod_table[i][j+1]=(10*mod_table[i][j])%2019;
        }
    }

    vector<ll> v(2019,0);
    dp[0]=(S[N-1]-'0');
    v[dp[0]]++;
    REP(i,N-1){
        dp[i+1]=(mod_table[S[(N-1)-(i+1)]-'0'][i+1]+dp[i])%2019;
        v[dp[i+1]]++;
    }

    ll ans=v[0];
    REP(i,2019){
        ans+=((v[i])*(v[i]-1))/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12796
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
#define vecvec(a) vector<vector<(a)>>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

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

// 二項係数計算
ll nCk(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;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    string S;
    vector<string> ue(N + 1),sita(N + 1);
    rep(i,N){
        cin >> S;
        string T = S;
        rep(j,S.size()){
            if(S[j] == '?')S[j] = 'a';
        }
        rep(j,S.size()){
            if(T[j] == '?')T[j] = 'z';
        }
        ue[i] = S;sita[i] = T;
    }
    string U;cin >> U;
    ue[N] = U;sita[N] = U;
    sort(all(ue));sort(all(sita));
    //vecout(ue);vecout(sita);
    ll from = 0,to = 0;
    rep(i,N + 1){
        if(sita[i] == U){
            from = i;
            break;
        }
        //cout << sita[i] <<" ";
    }
    //cout << "\n";
    for(ll i = N;i >= 0;i--){
        if(ue[i] == U){
            to = i;
            break;
        }
        //cout << ue[i] << " ";
    }
    //cout << "\n";
    //cout << from << " "<<to << "\n";
    for(ll i = from;i <= to;i++){
        cout << i + 1;
        cout << (i == to ? "\n":" ");
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int> x(n), y(n), h(n);
  int res;
  rep(i,n){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]!=0) res = i;
  }
  
  rep(i,101)rep(j,101){
    int H=h[res]+abs(x[res]-i)+abs(y[res]-j);
    bool ok=true;
    rep(k,n){
      if(h[k]!=max(H-abs(x[k]-i)-abs(y[k]-j),0)){
        ok=false;
        break;
      }
    }
    
    if(ok){
      cout << i << ' ' << j << ' ' << max(H,1)<< endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;


fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    while let Some(n) = sc.read1() {
        let mut xs = vec![];
        for _ in 0..n {
            let x: i64 = sc.read();
            xs.push(x);
        }
        let xs = xs;

        // calculate ascending subsequence
        let mut ascending = vec![(0, std::usize::MAX)];
        for (i, &x) in xs.iter().enumerate() {
            if x > ascending.last().unwrap().0 {
                ascending.push((x, i));
            }
        }

        let k = ascending.len();
        let mut res = vec![0; n];
        let mut partial_sum = vec![0; k];
        for x in xs {
            // binary search...
            let mut lo = 0;
            let mut hi = k;
            while hi - lo > 1 {
                let mid = (lo + hi) / 2;
                if x < ascending[mid].0 {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }
            assert!(ascending[lo].0 <= x);
            assert!(hi == k || x < ascending[hi].0);

            let idx = std::cmp::min(lo + 1, k - 1);
            res[ascending[idx].1] += x - ascending[lo].0;
            if lo > 0 {
                partial_sum[lo - 1] += 1;
            }
        }

        for j in (1..k).rev() {
            partial_sum[j - 1] += partial_sum[j];
        }

        for j in 1..k {
            let gain = partial_sum[j - 1] * (ascending[j].0 - ascending[j - 1].0);
            res[ascending[j].1] += gain;
        }

        for r in res {
            println!("{}", r);
        }
    }
}

//=============================================================================

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 11004
/*
给一个长度n 编号 1-n 的数组， m个操作， 每次操作选定 [L,R] 搞一次， q个查询，
每次查询问[L,R] 严格子区间内，搞了几回 。
例如: 操作 [1,1] [2,2] [1,2] , [1,6] 查询[1 2] 得到3
*/

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define N 666
int n,m,q;
int dp[N][N],mp[N][N]={0};
/*
dp(i,j): 区间 [i,j] 覆盖的子区间的数量
考虑到要用l+1和r-1结果，l降序，r升序
dp(l,r)+=dp(l,r-1)+dp(l+1,r)-dp(l-1,r-1) 
*/
signed main(){
	cin>>n>>m>>q;
	int l,r;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		mp[l][r]++;
	}
	for(int i=1;i<=n;i++) dp[i][i]=mp[i][i];
	for(int len=2;len<=n;len++){
		for(int l=1;l+len-1<=n;l++){
			int r=l+len-1;
			dp[l][r]=mp[l][r]+dp[l+1][r]+dp[l][r-1]-dp[l+1][r-1];
		}
	}
	while(q--){
		cin>>l>>r;
		cout<<dp[l][r]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 8636
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 200000
#define INF 2000000000
typedef long long llong;

int L[MAX/2+2],R[MAX/2+2];
llong merge(int A[],int lo,int hi,int mi)
{
    int n1=mi-lo;
    int n2=hi-mi;
    llong picks=0;
    for(int i=0;i<n1;i++) L[i]=A[lo+i];
    for(int i=0;i<n2;i++) R[i]=A[mi+i];
    L[n1]=R[n2]=INF;
    //????§???????
    int i=0,j=0;
    for(int k=lo;k<hi;k++)
    {
        if(L[i]<=R[j])
        {
            A[k]=L[i++];
        }
        else
        {
            A[k]=R[j++];
            picks+=n1-i; //??¨??????????¢??§?n1-i
        }
    }
    return picks;

}

llong mergeSort(int A[],int lo,int hi)
{
    int mi;
    llong v1,v2,v3;
    if(hi-lo>1)
    {
        mi=(hi+lo)>>1;
        v1=mergeSort(A,lo,mi);
        v2=mergeSort(A,mi,hi);
        v3=merge(A,lo,hi,mi);
        return v1+v2+v3;
    }
    return 0;
}
int main()
{
     int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    cout<<mergeSort(A,0,n)<<endl;
}

Measured memory_bytes: 4668
using System;

namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string set = "abcdefghijklmnopqrstuvwxyz";
            int[] cou = new int[26];
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null || input.Length == 0)
                    break;
                else
                {
                    input = input.ToLower();
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < set.Length; j++)
                        {
                            if ('a' <= input[i] && input[i] <= 'z')
                                if (input[i] == set[j])
                                    ++cou[j];
                        }
                    }
                }
            }
            for (int i = 0; i < set.Length; i++)
            {
                Console.WriteLine(set[i] + " : " + cou[i]);
            }
        }
    }
}

Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll h, w; cin >> h >> w;
	string s[h];
	for(ll i = 0; i < h; ++i) cin >> s[i];
	ll si = 0, na = 1;
	for(ll i = 0; i < h; ++i)for(ll j = 0; j < w; ++j) si += (s[i][j] == '#' ? 1 : 0);
	pair<ll, ll> now = pair<ll, ll>(0, 0);
	while(now.first != h - 1 || now.second != w - 1){
		ll dx[] = {1, 0};
		ll dy[] = {0, 1};
		bool po = 0;
		pair<ll, ll> tmp;
		for(ll i = 0; i < 2; ++i){
			pair<ll, ll> next = pair<ll, ll>(now.first + dx[i], now.second + dy[i]);
			if(next.first == h || next.second == w) continue;
			if(s[next.first][next.second] == '.') continue;
			if(po){
				cout << "Impossible\n";
				return 0;
			}
			po = 1;
			tmp = next;
		}
		if(!po){
			cout << "Impossible\n";
			return 0;
		}
		now = tmp;
		na++;
	}
	cout << (si == na ? "Possible\n" : "Impossible\n");
	return 0;
}

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

typedef long long ll;

const int maxn = 410;
const ll INF = 1e18;
int N, a[maxn];
ll pref[maxn], dp[maxn][maxn];

ll rec(int l, int r) {
    if (l >= r) {
        return 0;
    }
    ll& ret = dp[l][r];
    if (ret != -1) {
        return ret;
    }
    ret = INF;
    for (int i = l; i < r; i++) {
        ret = min(ret, rec(l, i) + rec(i + 1, r));
    }
    ret = ret + pref[r + 1] - pref[l];
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        pref[i + 1] = pref[i] + a[i];
    }
    memset(dp, -1, sizeof(dp));
    ll answer = rec(0, N - 1);
    cout << answer;

    return 0;
}

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

int main() {
  
  double W , H , x, y ;
  cin >> W >> H >> x >> y ;
  
  double area = W * H / 2 ;
  
  int judge ;
  if ( x == W / 2 && y == H / 2 )
    judge = 1 ;
  else
    judge = 0 ;
  
  cout << fixed ;
  cout << setprecision(6) << area ;
  cout << defaultfloat ;
  cout << " " << judge << endl;
}

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

int main(void){
  int n, m, x, y, buf;
  vector<int> xl;
  vector<int> yl;
  cin >> n >> m >> x >> y;
  xl.push_back(x);
  yl.push_back(y);
  for(int i = 0;i<n;i++){
    cin >> buf;
    xl.push_back(buf);
  }
  for(int i = 0;i<m;i++){
    cin >> buf;
    yl.push_back(buf);
  }
  sort(xl.begin(),xl.end(), greater<int>());
  sort(yl.begin(),yl.end());
  buf = yl.at(0) - xl.at(0);
  if(buf <= 0){
    cout << "War" << endl;
  }else{
    cout << "No War" << endl;
  }
  return 0;
}

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

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    string s;
    cin >> s;
    char pre = s[0];
    ll ans = 0;
    rrep(i,s.size()-1){
        if(pre!=s[i])ans++;
        pre = s[i];
    }
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int x;
  cin >> x;
  int ans;
  while (true){
    bool flag = false;
    rep(i, x-2){
      if (x % (i+2) == 0) flag = true;
    }
  if (flag == false) break;
  x++;
  }
  cout << x << endl;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h,w;
    cin >> h >> w;
    vector<string> S(h);
    fori(i,h) cin >> S[i];

    int n = h*w;
    vector<pii> direction{{-1,0},{0,-1},{1,0},{0,1}};
    function<int(pii)> solve = [=](pii start) {
        if(S[start.fi][start.se] == '#') return -1;
        queue<pair<pii,int>> qu;
        qu.push({start,0});
        set<pii> vis;
        vis.insert(start);

        int mx = 0;
        while(qu.size()) {
            auto p = qu.front();
            qu.pop();
            pii u = p.fi;
            int d = p.se;
            mmax(mx,d);
            for(auto dir: direction) {
                int x = u.fi + dir.fi;
                int y = u.se + dir.se;
                if(x < 0 || x >= h || y < 0 || y >= w) continue;
                if(vis.count({x,y})) continue;
                if(S[x][y] == '#') continue;
                vis.insert({x,y});
                qu.push({{x,y},d+1});
            }
        }

        return mx;
    };

    int ans = 0;
    fori(x,h) {
        fori(y,w) {
            mmax(ans, solve({x,y}));
        }
    }

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


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }

    priority_queue<pair<long long, int>> que;
    for (int i = 0; i < n; i++) {
        if (a.at(i) < b.at(i)) que.push(make_pair(b.at(i), i));
    }

    auto prev = [&](int i){return (i + n - 1) % n;};
    auto next = [&](int i){return (i + 1) % n;};

    long long cnt = 0;
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int i = p.second;
        long long &x = b.at(i);

        long long y = b.at(prev(i)) + b.at(next(i));

        if (y > x) break;

        if ((x - a.at(i)) / y == 0) continue;

        cnt += (x - a.at(i)) / y;
        x -=  (x - a.at(i)) / y * y;

        if (a.at(i) < x) que.push(make_pair(x, i));
    }

    for (int i = 0; i < n; i++) {
        if (a.at(i) != b.at(i)) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 9328
S=[nil]*13
H=[nil]*13
C=[nil]*13
D=[nil]*13

gets.to_i.times do
   c,n = gets.split
    n=n.to_i
     eval("%s[%d]=true"%[c,n-1])
end

S.each_with_index{|x,i| puts "S " + (i+1).to_s if not x}
H.each_with_index{|x,i| puts "H " + (i+1).to_s if not x}
C.each_with_index{|x,i| puts "C " + (i+1).to_s if not x}
D.each_with_index{|x,i| puts "D " + (i+1).to_s if not x}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[200005],n,k;
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n>>k;
	FOR(i,1,n)cin>>a[i];
	sort(a+1,a+n+1);int ans=0;
	FOR(i,1,n-k)ans+=a[i];cout<<ans;
	RE 0;
}




Measured memory_bytes: 1792
/*
ツ単ツ渉δづ可深ツつウツ優ツ静ヲツ探ツ催オツづ?嘉ーツつュツつアツづ?つェツづ?つォツづ慊つキ(ツ閉敖優ツ静ヲツ探ツ催オツづ?嘉ーツつュツつアツづ?づ?嘉つ能ツづ?つキ)
ツ陳債暗督つキツづ猟つォツ青ァツ姪アツつェツ姪「ツ妥ィツ閉カツ陳?づ可つスツつュツつウツづアツ渉堕つゥツづェツづ?つ「ツづゥツづ個づ?陳債暗督つオツづ慊つオツづ・ツつ、
ツ・ツつキツつョツ療猟づ可静篠つェツつ?づゥツ陛サツ古シツづ鳴づ債転ツつェツつケツづ按つ「
ツ・ツ転ツつェツつオツつスツ嘉アツ青板つェ10ツづーツ陳エツつヲツつスツ湘ェツ債?づ債妥?つソツ静伉づィ
ツ・ツゴツーツδ仰づ個マツスツづーツ津環づ?つスツつセツつッツづ?、ツゴツーツδ仰つオツつスツづ?づ敖づ按つキ
ツ・ツづ板づつつゥツづ?つスツ湘。ツ害ツ閉ィツづ債湘?つヲツづゥ
ツ・etc
 */
#include <iostream>
using namespace std;

#define INF 999999999

int w, h, sx, sy, gx, gy, ans;
int t[22][22];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

//ツ催?標ツつェツマツッツプツづ個氾債暗債禿?づ可つ?づゥツつゥツづ?つ、ツつゥ
bool check(int x, int y){
  return 0 <= x && x < w && 0 <= y && y < h;
}

//[y][x]ツづ個催?標ツつゥツづァツ、ツ陛サツ古シdツづ鳴古シツつッツづ?転ツつェツつオツつスツづ?つォツ、ツゴツーツδ仰づ個催?標ツづーツ津環づゥツつゥツづ?つ、ツつゥ
bool goalCheck(int x, int y, int d){
  while(check(x, y) && t[y][x] == 0){
    if(x == gx && y == gy){
      return true;
    }

    x += dx[d];
    y += dy[d];
  }

  return false;
}

//[y][x]ツづ個催?標ツつゥツづァツ陛サツ古シdツづ鳴古シツつッツづ?静篠づーツ転ツつェツつオツつスツづ?つォツ、ツ湘。ツ害ツ閉ィツづ可偲猟鳴つつウツづェツづ?止ツづ慊づゥツ暗環置ツづーツ仰?づ淞づゥ
//ツ止ツづ慊づゥツ暗環置ツづ債、ツ暗クツ青板づ警ツづ?ツづ可渉堕つォツつアツづ慊づェツづゥ(ツ参ツ湘?渡ツつオツづ?古?づ篠づェツづゥ)
//ツ静篠づーツ転ツつェツつオツづ?マツッツプツづ個氾債暗債外ツづ可出ツつスツ湘ェツ債?づ債、falseツづーツ姪淞づィツ値ツづ?つオツづ?陛板つキ
bool nextPos(int &x, int &y, int d){
  while(check(x, y) && t[y][x] == 0){
    x += dx[d];
    y += dy[d];
  }
  if(!check(x, y)) return false;

  x -= dx[d];
  y -= dy[d];

  return true;
}

//ツ深ツつウツ優ツ静ヲツ探ツ催オツづ可づヲツづィツ、ツ督堋つヲツづーツ仰?づ淞づゥ
void solve(int x, int y, int cost){
  if(cost == 10) return; //ツコツスツトツつェ10ツづーツ陳エツつヲツづゥツ湘ェツ債?妥?つソツ静伉づィ

  for(int i = 0; i < 4; i++){
    //ツ暗ェツづつ療猟づ個催?標ツづーツ仰?づ淞づゥ
    int nx = x + dx[i];
    int ny = y + dy[i];

    //ツ暗ェツづつ療猟づ個催?標ツつェツマツッツプツづ個氾債暗債禿?づ? ツつゥツづつ湘。ツ害ツ閉ィツつェツづ按つ「ツづ按づァ
    if(check(nx, ny) && t[ny][nx] == 0){
      if(goalCheck(x, y, i)){ //ツゴツーツδ仰板サツ津ィ
        ans = min(ans, cost + 1);
        return;
      }

      //ツ篠淞づ可止ツづ慊づゥツ湘ェツ渉環づーツ仰?づ淞づゥ
      if(!nextPos(nx, ny, i)) continue;

      //ツ止ツづ慊づ?つスツ湘ェツ渉環づ個つキツつョツ療猟づ個湘ェツ渉環づーツ仰?づ淞づゥ(ツづつづ慊づィツ湘。ツ害ツ閉ィツつェツつ?づゥツ催?標)
      int nx2 = nx + dx[i];
      int ny2 = ny + dy[i];
      t[ny2][nx2] = 0; //ツ湘。ツ害ツ閉ィツづーツ塗ツづィツづつづ板つオ

      solve(nx, ny, cost + 1);

      t[ny2][nx2] = 1; //ツ催?帰ツつゥツづァツ帰ツづ?づ?つォツつスツづ?つォ, ツ湘。ツ害ツ閉ィツづーツ閉慊環按つウツつケツづゥ
    }
  }
}

int main(){
  while(cin >> w >> h, w || h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cin >> t[i][j];

        if(t[i][j] == 2){
          t[i][j] = 0;
          sx = j;
          sy = i;
        }
        if(t[i][j] == 3){
          t[i][j] = 0;
          gx = j;
          gy = i;
        }
      }
    }

    ans = INF;
    solve(sx, sy, 0);

    if(ans == INF){
      cout << "-1\n";
    }
    else{
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 864
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

res, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K-a[i]:
        j -= 1
    res = max(res, i + j)
print(res)


Measured memory_bytes: 47552
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
ll const MAX = 505;
ll grid[MAX][MAX];

int main() {
	ll k; cin >> k;
	if (k == 1) {
		cout << 1 << endl << 1 << endl;
		return 0;
	}
	ll m = k / 4 + (k % 4 != 0);
	ll n = m * 2;
	cout << n << endl;
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (j % 2 == 1) {
				grid[i][j] = (i + j + n*10000000000) % n;
			}
			else {
				grid[i][j] = (i + j + n * 10000000000) % n + n;
			}
		}
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (grid[i][j] == 0) {
				grid[i][j] = n * 2;
			}
			if (grid[i][j] > k) {
				grid[i][j] -= n;
			}
		}
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			cout << grid[i][j];
			if (j <= n - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}


}

Measured memory_bytes: 3200
import itertools
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


N = int(input())
hoge = [0]*N
for i in range(N):
    x, y = list(map(int, input().split()))
    hoge[i] = (x, y)

lsts = list(itertools.permutations(range(N)))

ans = 0
b = len(lsts)

for lst in lsts:
    lst = list(lst)

    for i in range(N-1):
        (x1, y1) = hoge[lst[i]]
        (x2, y2) = hoge[lst[i+1]]
        s = math.pow(x1-x2, 2)
        t = math.pow(y1-y2, 2)

        ans += math.sqrt(s + t)

ans /= b

print(ans)
        


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout << (a%3==0||b%3==0||(a+b)%3==0 ? "Possible" : "Impossible") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll dp[205][205][505]; // dp[i][j][k]:= i番目まで見てj個選んでk個分w[0]より大きい数がある場合

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N,W;
    cin >> N >> W;
    vector<ll> w(N),v(N);
    cin >> w[0] >> v[0];
    ll sd = w[0];
    for(int i=1;i<N;i++){
        cin >> w[i] >> v[i];
        w[i] -= w[0];
    }
    w[0] = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<103;j++){
            for(int k=0;k<303;k++){
                chmax(dp[i+1][j+1][k+w[i]],dp[i][j][k] + v[i]);
                chmax(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<=N;i++){
        for(int j=0;j<303;j++){
            if(sd*i + j<=W){
                ans = max(ans,dp[N][i][j]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 80896
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[100005],b=1,c=1000000000000000000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0){
    	cout<<"0"<<endl;
    	return(0);
		  }
    }
    b=a[0];
    for(int i=1;i<n;i++){
      if(b*a[i]>c || a[i]*b<b){
        cout<<"-1"<<endl;
      	return(0);
      }
      else{
        b*=a[i];
      }
    }
    cout<<b<<endl;
    return(0);
}

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

#define MOD 100000

int poww(int n, int p){
int r = 1;
while(p){
if(p%2==1)
    r=(1LL*r*n)%MOD;
    n=(1LL*n*n)%MOD;
    p/=2;
    }
return r;
}

#define pow poww

main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
char s[5];
cin>>s;
if ((s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) || (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) || (s[0]==s[3] && s[1]==s[2]) && s[0]!=s[1]) cout<<"Yes";
   else cout<<"No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[210];
long long pw[210];
map<string,long long>dp;
int n;
long long calc(string v){
	if(dp.count(v))return dp[v];
	if(v.size()==0)return 1;
	long long ret=calc(v.substr(1,v.size()-1))*(v[0]=='1'?2:1)%mod;
	for(int i=1;i<=v.size();i++){
		string kk=v.substr(0,i);
		for(int j=i;j<v.size();j++){
			if(v[j]=='0')kk[j%i]='0';
			if((j+1)%i==0){
				ret=(ret+calc(kk)*calc(v.substr(j+1,v.size()-j-1)))%mod;
			}
		}
	}
	return dp[v]=ret;
}
int main(){
	scanf("%s",in);
	n=strlen(in);
	pw[0]=1;
	for(int i=1;i<210;i++)pw[i]=pw[i-1]*d2%mod;
	string st=in;
	printf("%lld\n",calc(st));
}

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

int main() {
  int H,W,i,j,k;
  cin >>H>>W;
  int d[10][10];
  for(i=0;i<10;i++){
	for(j=0;j<10;j++){
	cin>>d[i][j];
	}
  }
  int D[10];
  for(i=0;i<10;i++) D[i]=0;
  int p;
  for(i=0;i<H*W;i++){
	cin>>p;
	if(p>=0) D[p]+=1;
  }
  
  for(k=0;k<10;k++){
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int ans=0;
  for(i=0;i<=9;i++) {
    ans+=D[i]*d[i][1];
  }
  cout<<ans<<endl;
  return 0;
}    

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

int main(){
    //IO
    int a[9];
    int i, j;
    for (i = 0; i<9 ; i++){cin >> a[i];}
    int n;
    cin >> n;
    int b[n];
    for (i = 0; i<9 ; i++){cin >> b[i];}
    
    //calculate
    int row1, row2, row3;
    int col1, col2, col3;
    int dia1, dia2;
    int c[9]={0};
    for (i = 0; i<9; i++){
        for (j = 0; j<n; j++){
            if(a[i] == b[j]){c[i] += 1;}
        }
    }
    
    row1 = c[0]+c[1]+c[2];
    row2 = c[3]+c[4]+c[5];
    row3 = c[6]+c[7]+c[8];
    col1 = c[0]+c[3]+c[6];
    col2 = c[1]+c[4]+c[7];
    col3 = c[2]+c[5]+c[8];
    dia1 = c[0]+c[4]+c[8];
    dia2 = c[2]+c[4]+c[6];
    if (row1 >= 3 || row2 >= 3 || row3 >= 3 || col1 >= 3 || col2 >= 3 || col3 >= 3 || dia1 >=3 || dia2 >= 3){
        std::cout << "Yes" << std::endl;
    }
    else{std::cout << "No" << std::endl;}
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
typedef long long ll;
//#include <algorithm>
using namespace std;

int main() {
  string S;
  cin >> S;

  int diff0 = 0;
  int diff1 = 0;

  int str0 = 0;
  int str1 = 1;

  int slen = S.length();

  for(int i = 0; i < slen; i++){
    char c0 = '0' + str0;
    char c1 = '0' + str1;

    if(S[i] == c0){
      diff0++;
    }else{
      diff1++;
    }

    str0 = (str0 + 1) % 2;

  }

  cout << min(diff0, diff1) << endl;

}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans;
    if ((a - b) % 2 == 0) ans = abs(b - a) / 2;
    else {
        ans = min((b - (a - 1) - 1 - 1) / 2 + (a - 1) + 1, (n - (a + (n - b) + 1)) / 2 + (n - b) + 1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int main()
{
   long N, tmp, sum = 0;
   vector<long> vec;
    long m1 = LONG_MAX;
    long c=0;

   cin >> N;
   for (int i = 0; i < N; i++) {
       cin >> tmp;
       if (m1 > abs(tmp)) {
           m1 = abs(tmp);
       }
       sum += abs(tmp);
       if (tmp < 0)
            c++;
   }

    if (c%2 == 0) {
        cout << sum << endl;
    } else {
        cout << sum - m1*2 << endl;
    }
    
    return 0;   
};




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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  rep(i,n) cin >> a[i] >> b[i];
  vector<pair<int,int>> sum(n);
  rep(i,n)
  {
    sum[i] = make_pair(a[i]+b[i],i);
  }
  sort(all(sum));
  reverse(all(sum));
  ll ans = 0;
  rep(i,n)
  {
    int ind = sum[i].second;
    if(i%2==0)
    {
      ans += a[ind];
    }
    else
    {
      ans -= b[ind];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

long long int H, W;
char S[60][60] = {};


int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++)cin >> S[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (S[i][j] == '.') {
				S[i][j] = '0';
				if (S[i - 1][j - 1] == '#')S[i][j]++;
				if (S[i - 1][j] == '#')S[i][j]++;
				if (S[i - 1][j + 1] == '#')S[i][j]++;
				if (S[i][j - 1] == '#')S[i][j]++;
				if (S[i][j + 1] == '#')S[i][j]++;
				if (S[i + 1][j - 1] == '#')S[i][j]++;
				if (S[i + 1][j] == '#')S[i][j]++;
				if (S[i + 1][j + 1] == '#')S[i][j]++;
			}
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++)cout << S[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#エラストテネスの篩(最大の素因数を格納した配列)
def make_eratosthenes(n):
    A=[0]*n
    A[0],A[1]=-1,-1 #0と1は対象外
    for i in range(2,n):
        if A[i]==0:
            j=i
            while j<n:
                A[j]=i
                j+=i
    return A

n=int(input())
E=make_eratosthenes(n+5)
C=[0]*(n+5)
C[1]=1
D=[0]*(n+5) #重複判定
for i in range(2,n+5):
    e=i//E[i]
    if e==1:
        C[i]=2
        D[i]=1
    else:
        if E[e]==E[i]:
            C[i]=C[e]+D[e]
            D[i]=D[e]
        else:
            C[i]=C[e]*2
            D[i]=C[e]
ans=0
for i in range(n+1):
    ans+=i*C[i]
print(ans)

Measured memory_bytes: 302356
#include <cstdio>
#include <vector>
#include <cstring>

typedef long long ll;

int main() {
    // freopen("data.in", "r", stdin);
    // freopen("data.out", "w", stdout);
    ll a, b, k;
    scanf("%lld%lld%lld", &k, &a, &b);
    if (k < a) {
        printf("%lld\n", k + 1);
    } else {
        ll rest = k - a;
        ll count = 0;
        count = (rest / 2) * (b - a);
        if (rest % 2 == 1) {
            count += b;
        } else {
            count += a + 1;
        }
        if (count < k + 1) count = k + 1;
        printf("%lld\n", count);
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
typedef pair<long long int, P> lP;
typedef pair<P, P> PP;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 200000

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// O(ElogV)

void shortest_path(int s, int V){
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int par[MAX_V];
int rnk[MAX_V];
long long int sz[MAX_V];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		sz[y_par] = sz[x_par] + sz[y_par];
		par[x_par] = y_par;
	}else{
		sz[x_par] = sz[x_par] + sz[y_par];
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

vector<P> Es;
vector<lP> El;
vector<PP> Qs;

int main(){
	long long int N, M, K, Q;
	cin >> N >> M >> K >> Q;
	for(int i = 0; i < M; i++){
		long long int A, B, L;
		cin >> A >> B >> L;
		Es.push_back(P(A, B));
		edge e;
		e.cost = L;
		e.to = A;
		G[B].push_back(e);
		e.to = B;
		G[A].push_back(e);
	}
	for(int i = 0; i < K; i++){
		edge e;
		e.cost = 0;
		cin >> e.to;
		G[0].push_back(e);
	}
	shortest_path(0, N + 1);
	for(int i = 0; i < M; i++){
		long long int cost = min(d[Es[i].first], d[Es[i].second]);
		El.push_back(make_pair(-cost, Es[i]));
	}
	El.push_back(make_pair(-INF, P(0, 0)));
	sort(El.begin(), El.end());
	for(int i = 0; i < Q; i++){
		PP pp;
		pp.second = P(0, M);
		cin >> pp.first.first >> pp.first.second;
		Qs.push_back(pp);
	}
	for(int loop = 0; loop < 20; loop++){
		priority_queue<P, vector<P>, greater<P> > que;
		for(int i = 0; i < Q; i++){
			P p = P((Qs[i].second.first + Qs[i].second.second) / 2, i);
			que.push(p);
		}
		que.push(P(INF, 0));
		init(N + 1);
		for(int i = 0; i <= M; i++){
			unite(El[i].second.first, El[i].second.second);
			while(que.top().first == i){
				P p = que.top();
				que.pop();
				P p2 = Qs[p.second].first;
				if(same(p2.first, p2.second)){
					Qs[p.second].second.second = i;
				}else{
					Qs[p.second].second.first = i;
				}
			}
		}
	}
	for(int i = 0; i < Q; i++){
		cout << -El[Qs[i].second.second].first << endl;
	}
	return 0;
}


Measured memory_bytes: 35108
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int MOD=1e9+7ll;
int n,a,b,ans1,ans2,ans3,ans;

inline int pow(int a,int n)
{
	int res=1ll;
	while (n)
	{
		if (n&1ll) res=res*a%MOD;
		n>>=1ll;
		a=a*a%MOD;
	}
	return res;
}

inline int qpow(int a,int b)
{
    if(b==1) return a;
    int t=qpow(a,b/2);
    t=t*t%MOD;
    if(b&1ll) t=t*a%MOD;
    return t;
}

inline int C(int n,int m)
{
    if(n<m) return 0;
    if(m>n-m) m=n-m;
    int a=1,b=1;
    for(int i=0;i<m;i++)
	{
        a=(a*(n-i))%MOD;
        b=(b*(i+1))%MOD;
    }
    return a*qpow(b,MOD-2ll)%MOD;
}

inline int Lucas(int n,int m)
{
    if(m==0) return 1ll;
    return Lucas(n/MOD,m/MOD)*C(n%MOD,m%MOD)%MOD;
}

signed main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	ans1=pow(2ll,n); 
	ans2=Lucas(n,a);
	ans3=Lucas(n,b);
//	printf("%lld\n",ans1);
//	printf("%lld\n",ans2);
//	printf("%lld\n",ans3);
	ans=((ans1-ans2-ans3-1ll)%MOD+MOD)%MOD;
	printf("%lld\n",ans); 
return 0;
}

Measured memory_bytes: 256
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = arr[0];
    const A = arr[1];
    const B = arr[2];
    console.log(Math.min(A * N, B));
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29524
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

int main()
{
	string s;
	cin>>s;
	ll k;
	cin>>k;
	int c=-1;
	char t;
	for(int i=0; i<s.size(); i++){
		if(s[i]!='1'){
			c=i;
			t=s[i];
			break;
		}
	}
	if(c==-1){
		cout<<1<<endl;
	}else if(k<=c){
		cout<<1<<endl;
	}else{
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  r pic 9(08).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2.

        COMPUTE r = a1 * a2

        IF a1 < 10 AND a2 < 10 THEN
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
        ELSE
          DISPLAY "-1"
        END-IF


       STOP RUN.


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

int main()
{
   int a,b;
   char s[15];
   cin>>a>>b;
   cin>>s;int flag=1;
   int r=strlen(s);
   if (r!=(a+b+1))
    cout<<"No"<<endl;

   else
   {
       for (int i=0;i<a+b+1;i++)
       {
           if ((i==a&&s[i]!='-')||(i!=a&&(s[i]-'0'<0||s[i]-'0'>9)))
           {
                cout<<"No"<<endl;
                flag=0;
                break;
           }
       }
       if (flag)
       cout<<"Yes"<<endl;
   }
    return 0;
}


Measured memory_bytes: 256
/*input
YAKINIKUFESTIVAL
*/
#include "bits/stdc++.h"
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
using namespace std;

const int MXN = 1e6 + 10;
int t = 1; string s;
int main() {
    //cin >> t;
    while (t--) {
        double ans = 0;
        cin >> s;
        cout << s.substr(0, s.length() - 8) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
a2p={}
3.times{|i| gets.split.each_with_index{|t,j| a2p[t.to_i]=i*3+j } }
gets
f=[]
$<.each{|s|
  pos=a2p[s.to_i] or next
  f[pos]=true
}
puts [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].any?{|r| r.all?{|i| f[i] } } ? :Yes : :No


Measured memory_bytes: 1788