akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let modulo: i64 = 998244353;
    let n: i64 = sc.read();
    let m: i64 = sc.read();
    let k: i64 = sc.read();
    let comb = CombinationMod::new(n as usize, modulo);
    let mut ans: i64 = 0;
    for i in 0..=k {
        let mut add: i64 = 1;
        add = add * comb.query(n - 1, i as i64) % modulo;
        add = add * m % modulo;
        add = add * modpow(m - 1, n - i - 1, modulo) % modulo;
        ans = (ans + add) % modulo;
    }
    if ans < 0 {
        ans = (ans + modulo) % modulo;
    }
    println!("{}", ans);
}

fn modpow(a: i64, x: i64, m: i64) -> i64 {
    if x == 0 {
        1
    } else if x % 2 != 0 {
        a * modpow(a, x - 1, m) % m
    } else {
        let half = modpow(a, x / 2, m);
        half * half % m
    }
}

struct CombinationMod {
    fac: Vec<i64>,
    inv_fac: Vec<i64>,
    modulo: i64,
}
impl CombinationMod {
    pub fn new(size: usize, modulo: i64) -> CombinationMod {
        let mut fac: Vec<i64> = vec![1; size + 1];
        let mut inv_fac: Vec<i64> = vec![1; size + 1];
        let mut inv: Vec<i64> = vec![1; size + 1];
        for i in 2..=size {
            fac[i] = fac[i - 1] * i as i64 % modulo;
            inv[i] = modulo - inv[modulo as usize % i] * (modulo / i as i64) % modulo;
            inv_fac[i] = inv_fac[i - 1] * inv[i] % modulo;
        }
        CombinationMod {
            fac: fac,
            inv_fac: inv_fac,
            modulo: modulo,
        }
    }
    fn query(&self, n: i64, r: i64) -> i64 {
        self.fac[n as usize] * self.inv_fac[r as usize] % self.modulo
            * self.inv_fac[(n - r) as usize]
            % self.modulo
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 6740
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  typedef long long int ll;
int A, B, C;
cin >> A >> B;
bool ans = false;
if(B + A >= 24)ans = true;
if(ans)cout << B + A - 24 << endl;
else cout << B + A << endl;
        return 0;
}

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

using namespace std;

main(){
  string in;
  string key;
  int size;
  vector<int> pos;
  int find[50];
  int npos;
  while(1){
    in="";
    string tmp;
    while(1){
      getline(cin, tmp);
      if(tmp.size()==0) break;
      in+=tmp;
    }
    key="";
    while(1){
      getline(cin, tmp);
      if(tmp.size()==0) break;
      key+=tmp;
    }
    if(key.size()==0) break;
    int l=0, u=0;
    size=10000000;
    npos=0;
    for(int i=0;i<key.size();i++) find[i]=0;
    pos.clear();
    int nf=0;
    while(u<in.size()){
      for(int i=0;i<key.size();i++){
	if(in[u]==key[i]){
	  if(find[i]==0){
	    nf++;
	  }
	  find[i]++;
	  break;
	}
      }
      if(nf==key.size()){
	bool end=false;
	while(l<u && !end){
	  for(int i=0;i<key.size();i++){
	    if(in[l]==key[i]){
	      if(find[i]==1){
		end=true;
		if(size>u-l+1){
		  pos.clear();
		  size=u-l+1;
		  pos.push_back(l);
		  npos=1;
		}else if(size==u-l+1){
		  npos++;
		}
		find[i]--;
		nf--;
		break;
	      }else{
		find[i]--;
	      }
	      break;
	    }
	  }
	  l++;
	}
      }
      u++;
    }
    cout << npos << endl << endl;;
    if(npos!=0){
      string r;
      for(int i=0;i<size;i++){
	r+=in[i+pos[0]];
      }
      for(int i=0;i<r.size();i++){
	cout << r[i];
	if(i+1==r.size()) continue;
	if(i&&(i+1)%72==0) cout << endl;
      }
      cout << endl << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 100;
int a[N];
int main(){
	int n;
	scanf("%d", &n);
	ll mon = 1000LL, sto = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	a[0] = 250, a[n + 1] = -1;
	for(int i = 1; i <= n; i++){
		if(a[i] <= a[i - 1] && a[i] < a[i + 1]){
			ll val = mon / (1LL * a[i]);
			sto += val;
			mon %= a[i];
		}
		else if(a[i] >= a[i - 1] && a[i] > a[i + 1]){
			mon += sto * a[i];
			sto = 0;
		}

	}
	printf("%lld", mon);

}

Measured memory_bytes: 3820
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    vector<ll> sum(N + 1, 0);
    for (ll i = 1; i <= N; i++) {
        sum[i] = sum[i - 1] + a[i - 1];
    }

    multiset<ll> candidates;
    for (ll l = 0; l < N; l++) {
        for (ll r = l; r < N; r++) {
            ll b = sum[r + 1] - sum[l];
            candidates.insert(b);
        }
    }

    ll ans = 0;
    for (ll i = 63; i >= 0; i--) {
        ll num = 0;
        for (ll c : candidates) {
            if (c & (1LL << i)) {
                num++;
            }
        }

        if (num >= K) {
            //ここを立てる
            multiset<ll> next;
            for (ll c : candidates) {
                if (c & (1LL << i)) {
                    next.insert(c);
                }
            }
            candidates = next;
            ans += (1LL << i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 29056
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    int N, T, X;
    cin >> N >> T;

    int last = 0;
    int shower = 0;

    for (int i = 0; i < N; i++) {
        cin >> X;

        //debug() << X + T;
        if (X >= last) {
            shower += T;
            last = X + T;
        } else if (X + T > last) {
            shower += (X + T) - last;
            last = X + T;
        }
    }

    cout << shower << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<sstream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int ans = 0, n, a, b;
  cin >> n >> a >> b;
  int t[n];
  for(int i = 0; i < n; i++){
    cin >> t[i];
    if(t[i] < a || t[i] >= b) ans++; 
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var gap int
	var strs string
	fmt.Scan(&gap, &strs)

	result := make([]rune, len(strs))

	for i, str := range strs {
		s := int(str)
		if s+gap <= 'Z' {
			result[i] = rune(s + gap)
		} else {
			result[i] = 'A' + rune(s+gap-'Z'-1)
		}
	}

	fmt.Printf("%s", string(result))

}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
char map[30][30];
int vis[30][30],n,m,cnt=0;
int dir[4][2]={0,1,0,-1,-1,0,1,0};
struct node{int x,y,step;
}k[30];
void bfs(int x,int y)
{
	memset(vis,0,sizeof(vis));
	int i;
	queue<node>q;
	node pre,next;
	pre.x=x,pre.y=y,pre.step=0;
	q.push(pre);
	vis[pre.x][pre.y]=1;
	while(!q.empty())
	{
		pre=q.front();
		q.pop();
		cnt=cnt>pre.step?cnt:pre.step;
		for(i=0;i<4;i++)
		{
			next.x=pre.x+dir[i][0],next.y=pre.y+dir[i][1];
			if(next.x<1||next.x>n||next.y<1||next.y>m)continue;
			if(!vis[next.x][next.y]&&map[next.x][next.y]=='.')
			{
				next.step=pre.step+1;
				q.push(next);
				vis[next.x][next.y]=1;
			}
		}
	}
}
int main()
{
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	    scanf("%s",map[i]+1);
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
	{
		if(map[i][j]=='.')bfs(i,j);
	}
	printf("%d\n",cnt);	    
}

Measured memory_bytes: 256
import copy
h,w,k=map(int,input().split())
s=[]
for i in range(h):
  s+=[[int(i) for i in input()]]
ans=h+w-2
for i in range(2**(h-1)):
  t=format(i,''.join(['0',str(h-1),'b']))
  a=sum([int(tt) for tt in t])
  h1=[0]+[ii+1 for ii in range(h-1) if t[ii]=='1']+[h]
  h2=[[h1[ii],h1[ii+1]] for ii in range(len(h1)-1)]
  j0=0
  slsum=[0]*len(h2)
  sl=[0]*len(h2)
  for j in range(w):
    for l in range(len(h2)):
      sl[l] = sum([s[ii][j] for ii in range(h2[l][0],h2[l][1])])
      slsum[l]+=sl[l]
      if sl[l]>k:
        a=-1
        break
    if a==-1:
      break
    if any([x>k for x in slsum]):
      slsum=copy.deepcopy(sl)
      a+=1
  if a==-1:
    continue
  ans=min(ans,a)
print(ans)

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
#define V std::vector
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

int n, m; bool vis[kN];
std::list <int> path;
V <int> E[kN];
void Add(int u, int v) {
	E[u].push_back(v); E[v].push_back(u);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		rd(n, m);
		for(int i = 1; i <= m; ++i) {
			int u, v; rd(u, v);
			Add(u, v);
			if(i == 1) {
				vis[u] = vis[v] = true;
				path.push_back(u); path.push_back(v);
			}
		}
		while(true) {
			int cur = path.front(); bool flag = false;
			for(auto i : E[cur]) if(!vis[i]) {
				vis[i] = true; flag = true;
				path.push_front(i);
				break;
			}
			if(!flag) break;
		}
		while(true) {
			int cur = path.back(); bool flag = false;
			for(auto i : E[cur]) if(!vis[i]) {
				vis[i] = true; flag = true;
				path.push_back(i);
				break;
			}
			if(!flag) break;
		}
		int len = 0;
		for(auto i : path) ++len;
		printf("%d\n", len);
		for(auto i : path) printf("%d ", i);
		printf("\n");
	} return 0;
}

Measured memory_bytes: 19332
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str="";
		while(true){
			try {
				str = br.readLine();
			}catch (Exception e) {

			}
			if(str == null){
				break;
			}

			String moji[] = str.split(" ");
			int sum = Integer.parseInt(moji[0]) + Integer.parseInt(moji[1]);

			System.out.println(Integer.toString(sum).length());
		}
	}
}

Measured memory_bytes: 10000
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,i,ans=1;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<n-1;i++){
    if(a[i]<a[i+1]) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
N=int(input())
W=str(input())
w_list = [W]
OUT = False
for i in range(N-1):
  W=str(input())
  w_list.append(W)
  if W[0] != w_list[i][len(w_list[i])-1]:
    OUT = True
  n = len([1 for w in w_list if w==W])
  if n > 1:
    n = 0
    OUT = True
if OUT:
  print('No')
else:
  print('Yes')

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

int main() {
  char a,b;
  cin >> a;
  if(a=='A')
    b = 'T';
  else if(a=='T')
    b = 'A';
  else if(a=='G')
    b = 'C';
  else
    b ='G';
  cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
ll N,Q,K;
vector<vector<pair<ll,ll>>> G(100010);
vector<ll> d(100010,INF);
void dijkstra(){
    
    d[K] = 0;
    priority_queue<Pi,vector<Pi>,greater<Pi>> pque;
    pque.push(mp(0,K));
    while(!pque.empty()){
        Pi p = pque.top();
        pque.pop();
        ll pos=p.second,cost=p.first;
        if( cost > d[pos] )continue;
        rep(i,G[pos].size()){
            ll  to = G[pos][i].first;
            ll newcost = cost + G[pos][i].second;
            if(newcost < d[to]){
                d[to] = newcost;
                pque.push(mp(d[to],to));
            }
        }

    }

}

int main() {
    
    cin >>N;
    //vector<vector<Pi>>G(N);
    rep(i,N-1){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].pb(mp(b,c));
        G[b].pb(mp(a,c));
    }
    cin>>Q>>K;
    K--;
    dijkstra();
    rep(i,Q){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        cout<<d[x]+d[y]<<endl;
    }
    
   


    return 0;
    

}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  vector<int> t(N);
  int total = 0;
  for (int i = 0; i < N; i++){
    cin >> s[i] >> t[i];
    total += t[i];
  }
  string X;
  cin >> X;
  int played = 0;
  int i = 0;
  while (s[i] != X){
    played += t[i];
    i++;
  }
  played += t[i];
  cout << total - played;
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut a=read::<String>().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>();
    a.sort();
    println!("{}",if a.iter().map(|c|*c).collect::<String>()=="abc"{"Yes"}else{"No"})
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"math/big"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() uint64 {
	sc.Scan()
	i, e := strconv.ParseUint(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func int64Array(n []string) []int64 {
	var m []int64
	for i, _ := range n {
		v, _ := strconv.ParseInt(n[i], 10, 64)
		m = append(m, v)
	}
	return m
}

func uint64Array(arr []string) (newArr []uint64) {
	for i, _ := range arr {
		n, _ := strconv.ParseUint(arr[i], 10, 64)
		newArr = append(newArr, n)
	}
	return
}

func intExistIn(v int, arr []int) bool {
	for _, a := range arr {
		if a == v {
			return true
		}
	}

	return false
}

func stringExistIn(v string, arr []string) bool {
	for _, a := range arr {
		if a == v {
			return true
		}
	}

	return false
}

func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func uintArrayToStr(a []uint64) string {
	var S string

	for _, v := range a {
		S += strconv.Itoa(int(v))
	}
	return S
}

func remove(x []uint64, y int) []uint64 {
	var newArray []uint64
	for i, _ := range x {
		if i != y {
			newArray = append(newArray, x[i])
		}
	}
	return newArray
}

func ascendSort(a []uint64) []uint64 {
	for i := 0; i < len(a); i++ {
		for i := 0; i < len(a)-1; i++ {
			if a[i] > a[i+1] {
				tmp := a[i+1]
				a[i+1] = a[i]
				a[i] = tmp
			}
		}
	}
	return a
}

func descendSort(a []uint64) []uint64 {
	for i := 0; i < len(a); i++ {
		for i := 0; i < len(a)-1; i++ {
			if a[i] < a[i+1] {
				tmp := a[i+1]
				a[i+1] = a[i]
				a[i] = tmp
			}
		}
	}
	return a
}

func maxAndIndex(a []uint64) (uint64, int) {
	max := uint64(0)
	index := 0
	for i, v := range a {
		if v > max {
			max = v
			index = i
		}
	}
	return max, index
}

func sum(a []uint64) uint64 {
	sum := uint64(0)
	for _, v := range a {
		sum += v
	}
	return sum
}

func defeat(count *int64, hero *int64, monster *int64) {
	if *hero >= *monster {
		*count, *hero, *monster = *count+*monster, *hero-*monster, int64(0)
		return
	}
	*count, *hero, *monster = *count+*hero, int64(0), *monster-*hero
}

func main() {
	// sc.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(readLine())
	monsters := int64Array(strings.Split(readLine(), " "))
	heroes := int64Array(strings.Split(readLine(), " "))

	var count int64

	for i := 0; i < N; i++ {
		defeat(&count, &heroes[i], &monsters[i])
		defeat(&count, &heroes[i], &monsters[i+1])
	}

	fmt.Println(count)
}

Measured memory_bytes: 12800
#069-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

h,w=IL()
n=I()
a=IL()
c=0
reverse=False
cl=[[-1 for i in range(w)] for j in range(h)]
for i in range(h):
    if reverse:
        for j in range(w):
            cl[i][w-1-j]=c+1
            a[c]-=1
            if a[c]==0:
                c+=1
        reverse=False
    else:
        for j in range(w):
            cl[i][j]=c+1
            a[c]-=1
            if a[c]==0:
                c+=1
        reverse=True

for i in range(h):
    for j in range(w):
        print(cl[i][j],end=" ")
    print()

Measured memory_bytes: 3920
#059_C
n=int(input())
a=list(map(int,input().split()))

def search(x):#x=0,1
    tmp=0
    cnt=0
    for i in range(n):
        tmp+=a[i]
        if i%2==x:
            if tmp<=0:
                cnt+=1-tmp
                tmp=1              
        else:
            if tmp>=0:
                cnt+=tmp+1
                tmp=-1
    return cnt

print(min(search(0),search(1)))

Measured memory_bytes: 14332
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 1000005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int mark[1000005], primes[80000], counter = 0;
vector<ii> vp;

void genSieve()
{
    int limit = sqrt(1000100);
    mark[1] = 1;
    for(int i = 4; i < MAX; i += 2)
        mark[i] = 1;

    primes[counter++] = 2;
    for(int i = 3; i < MAX; i += 2) {
        if(!mark[i]) {
            primes[counter++] = i;
            if(i <= limit) {
                for(int j = i * i; j < MAX; j += i * 2)
                    mark[j] = 1;
            }
        }
    }
}

void factorize(ll n)
{
    int idx = 0;
    ll pf = primes[idx];

    while(pf * pf <= n) {
        if(n % pf == 0) {
            int cnt = 0;
            while(n % pf == 0){
                cnt++;
                n /= pf;
            }
            vp.pb(mk(pf, cnt));
        }
        pf = primes[++idx];
    }

    if(n != 1) {
        vp.pb(mk(n, 1));
    }
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    genSieve();

    ll n;

    cin>>n;

    factorize(n);

    int res = 0;
    for(int i = 0; i < vp.size(); i++) {
        int low = 1, high = vp[i].ss, mid, ans = -1;
        while(low <= high) {
            mid = (low + high + 1) >> 1;
            if((mid * (mid + 1)) / 2 <= vp[i].ss) {
                ans = mid;
                low = mid + 1;
            }
            else {
                high = mid - 1;
            }
        }
        res += ans;
    }

    cout<<res<<endl;

    return 0;
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> count(60, 0);
  rep(i, 60) {
    rep(j, n) if(a[j] & 1ll<<i) ++count[i];
  }
  mint ans = 0;
  rep(i, 60) {
    mint add = 1ll<<i;
    add *= count[i];
    add *= n-count[i];
    ans += add;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 5612
#include <iostream>
#include <array>

using namespace std;

int N;
array<int, 100> As;


int64_t calc(int64_t n) {

  int64_t ret = 0;
  for (int i=0; i<N; ++i) {
    int64_t diff = n - As[i];
    ret += diff * diff;
  }

  return ret;
}


int main() {

  cin >> N;
  for (int i=0; i<N; ++i) {
    cin >> As[i];
  }


  int s=-100, l=100;
  while (1 < l-s) {
    if (calc(s) < calc(l))
      l = (s + l) / 2;
    else
      s = (s + l) / 2;
  }

  if (calc(s) < calc(l))
    cout << calc(s) << endl;
  else
    cout << calc(l) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[9]={1,1,1,1,1,2,2,2,3} , dy[9]={-2,-1,0,1,2,-1,0,1,0} ;
typedef pair<pli,pint> P;

int main(){
    int w,h;
    while(cin>>w>>h,w!=0){
        char s[h][w];
        vector<pint> st,gl;
        rep(i,h)rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=='S')st.push_back({i,j});
            if(s[i][j]=='T')gl.push_back({i,j});
        }
        priority_queue<P,vector<P>,greater<P>> q;
        ll dist[h][w][2];
        rep(i,h)rep(j,w)rep(k,2)dist[i][j][k]=inf;
        for(auto y:st){
            rep(i,2)q.push({{0,i},y});
            rep(i,2)dist[y.first][y.second][i]=0;
        }
        while(!q.empty()){
            P p=q.top();
            q.pop();
            ll d=p.first.first;
            int flag=p.first.second;
            int y=p.second.first;
            int x=p.second.second;
            if(d>dist[y][x][flag])continue;
            rep(i,9){
                int nx=x+(flag?1:-1)*dx[i],ny=y+dy[i];
                if(0<=nx&&nx<w&&0<=ny&&ny<h&&s[ny][nx]!='X'&&s[ny][nx]!='S'){
                    int dd=(s[ny][nx]=='T'?0:s[ny][nx]-'0');
                    if(dist[ny][nx][!flag]>d+dd){
                        dist[ny][nx][1-flag]=d+dd;
                        q.push({{d+dd,1-flag},{ny,nx}});
                    }
                }
            }
        }
        ll ans=inf;
        for(auto y:gl)rep(i,2)ans=min(ans,dist[y.first][y.second][i]);
        cout<<(ans==inf?-1:ans)<<endl;
    }
}


Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
int main(void){
    long long int n,a=2,b=1,c=3;
    cin>>n;
    if(n==0) cout<<a<<endl;
    else if(n==1) cout<<b<<endl;
    else if(n==2) cout<<c<<endl;
    else{
         rep(i,n-2){
             a=b;
             b=c;
             c=a+b;
         }
         cout<<c<<endl;     
    }
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    lint n;
    cin >> n;
    lint ans;

    ans = n*n*n;

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int x;
    cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N;
    int[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        long sum = 0;
        foreach (var i in A)
        {
            sum += i;
        }

        long ans = 0;

        // 高さiのノード最大
        long node = 1;
        for (int i = 0; i <= N; i++)
        {
            // iに割り当てるnode A[i]個
            ans += node;
            if (node < A[i])
            {
                Console.WriteLine("-1");
                return;
            }
            node -= A[i];
            sum -= A[i];
            node = Math.Min(sum, node * 2);
            // Console.WriteLine($"{i} {node} {sum}");
            // min(sum,残り*2)にnodeを増やす
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    // 常に最大値を割引するのが良い
    // priority_queueで現段階でのmaxを拘束に取得する
    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        q.push(a);
    }

    // 先頭を取り出して割ってまた戻す
    for(int i = 0; i < m; i++){
        int a = q.top();
        q.pop();
        q.push(a / 2);
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3924
/*
円の面積と円周
*/

#include<stdio.h>
#include<math.h>
int main(void){
  double r;
  double area,circumference;/*円の面積と円周*/
  
  scanf("%lf",&r);
  circumference = r*r*3.14159265359;
  area = 2*r*3.14159265359;

  printf("%f %f\n",circumference,area);
  return 0;
}
  


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

int main()
{
  string s;
  cin >> s;
  string ans = "";
  for(int i = 0; i < (int)s.size(); i++)
    if(s[i] == 'B'){
      if(ans != "")
        ans = ans.substr(0,ans.size()-1);
    }else{
      ans += s[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
const int inf=1e6;
int k,dist[100000];
deque<int> todo;
int main(){
	cin>>k;
	for (int i=0;i<k;i++) dist[i]=inf;
	dist[1]=1;todo.push_back(1);
	while(!todo.empty()){
		int x=todo.front();todo.pop_front();
		if (dist[(10*x)%k]>dist[x]){
			dist[(10*x)%k]=dist[x];
			todo.push_front((10*x)%k); 
		}
		if (dist[(x+1)%k]>dist[x]+1){
			dist[(x+1)%k]=dist[x]+1;
			todo.push_back((x+1)%k); 
		}
	}
	cout<<dist[0];
}

Measured memory_bytes: 896
n = int(input())
p = input().split()
p = [int(i) for i in p]

ans = 0
for i in range(1,n-1):
    if (p[i] > p[i-1] and p[i] < p[i+1]) or (p[i] < p[i-1] and p[i] > p[i+1]):
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ 
	cin.sync_with_stdio(0);
	
	double output = 0;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		double next;
		cin >> next;

		output += 1 / next;
	}

	cout << setprecision(15) << 1 / output << endl;


} //cin.tie(0) bei schnellem Wechseln

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

int main(){

  for (int x = 0;true;x++){
    int h,w;
    cin >> h >> w;

    if (h==0 && w==0) break;

    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        if( (i+j) % 2 == 0 ){
          cout << "#";
        }
        else {
          cout << ".";
        }

        if(j == w){
          cout << endl;
        }
      }
      if (i == h){
        cout << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long

#define m_p make_pair
#define mod 1000000007
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	char c;
	cin >> c;
	c++;
	cout << c << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool a[8];
ll b;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x<400){
			a[0]=true;
		}
		else if(x<800){
			a[1]=1;
		}
		else if(x<1200){
			a[2]=1;
		}
		else if(x<1600){
			a[3]=1;
		}
		else if(x<2000){
			a[4]=1;
		}
		else if(x<2400){
			a[5]=1;
		}
		else if(x<2800){
			a[6]=1;
		}
		else if(x<3200){
			a[7]=1;
		}
		else{
			b++;
		}
	}
	ll ans=0;
	for(int i=0;i<8;i++){
		ans+=a[i];
	}
	if(ans==0){
		cout << 1 << " "<<b;
	}
	else{
		cout << ans << " "<< ans+b;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, q, i, j, cnt = 0;
  int s[10000], t[500];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }

  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (s[j] == t[i]) {
        cnt++;
        break;
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}

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

//#include <atcoder/all>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}

ll floor_sum(ll n, ll m, ll a, ll b) {
    ll ret = 0;
    if (b >= m) {
        ret += n * (b / m);
        b %= m;
    }
    if (a >= m) {
        ret += n * (n - 1) * (a / m) / 2;
        a %= m;
    }
    ll y = (a * n + b) / m;
    if (y == 0) { return ret; }
    b = a * n - m * y + b;
    ret += floor_sum(y, a, m, b);
    return ret;
}

int main() {
    PRE_COMMAND
    int q;
    cin >> q;
    ll n, m, a, b;
    for (int i = 0; i < q; i++) {
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  string S; cin >> S;
  map<char, int> c; rep(i,4) c[S[i]]++;
  string result = "Yes";
  for (auto x: c) if (x.second!=2) result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;

void Coins() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	for (size_t i = 0; i <= A; i++)
	{
		for (size_t j = 0; j <= B; j++)
		{
			for (size_t k = 0; k <= C; k++)
			{
				if (500 * i + 100 * j + 50 * k == X) res++;
			}
		}
	}
	cout << res << endl;
}
int main() {
	Coins();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {

	double r;
	double pi = 3.14159265359, circ_area, length;

	scanf("%lf\n", &r);

	if (0 < r && r < 10000) {
		circ_area = r * r * pi;
		length = (2 * r) * pi;

		printf("%0.6f %0.6f\n", circ_area, length);
	}

	return 0;
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#define F first
#define S second
#define PB push_back
#define MP make_pair


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define INF 2000000000

const int max_n=1e9+1;
const ll mod=998244353;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int k;
    double p,sum=0;
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        cin>>k;
        p=k;
        sum+=(1/p);
    }
    sum=(1/sum);
    cout<<setprecision(9)<<sum;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <fstream>
#include <iterator>
#include <stdlib.h>
#include <map>
#include <queue>
#include <vector>
#include <functional>
#include <set>
#include <list>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

// vector cout
template<typename _Ty>
ostream& operator << (ostream& os, const vector<_Ty>& v) {
	os << "{";
	for (size_t i = 0; i < v.size(); i++)
	{
		if (i != 0) os << ", ";
		os << v[i];
	}
	os << "}";

	return os;
}

typedef pair<int, int> P;

int main() {

	int a, b;

	while (cin >> a >> b) {
		map<int, int> m;
		while (1) {
			if (a == 0 && b == 0) break;
			m[a]++; m[b]++;
			cin >> a >> b;
		}

		map<int, int>::iterator it;
		bool flag = true;

		for (it = m.begin(); it != m.end(); it++) {
			if ((*it).first == 1 || (*it).first == 2) {
				//1 or 2 : odd
				if ((*it).second % 2 != 1) {
					flag = false;
					break;
				}
			}
			else {		
				//otherwise : even
				if ((*it).second % 2 != 0) {
					flag = false;
					break;
				}
			}
		}
		if (flag) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3016
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    S = input()
    check = [
        "AKIHABARA",
        "KIHABARA",
        "AKIHBARA",
        "AKIHABRA",
        "AKIHABAR",
        "KIHBARA",
        "KIHABRA",
        "KIHABAR",
        "AKIHBRA",
        "AKIHBAR",
        "AKIHABR",
        "KIHBRA",
        "KIHABR",
        "KIHBAR",
        "AKIHBR",
        "KIHBR",
    ]
    if S in check:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n;
  cin>>n;
  string s;
  set<string> st;
  map<string,ll> mp;
  for(int i=0;i<n;i++){
    cin>>s;
    sort(s.begin(),s.end());
    st.insert(s);
    mp[s]++;
  }
  ll c=0;
  for(auto au: st){
    c+=mp[au]*(mp[au]-1)/2;
  }
  cout<<c;
}

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

const int MaxN = 200050;
#define rep(i,s,t) for(int i = s; i <= t; ++ i)

int x, n, ans[MaxN];
vector<int> g;
bool vis[MaxN];

int main()
{
    cin.sync_with_stdio(false);
    cin >> n >> x;
    if(x == 1 || x == n*2-1) return puts("No"), 0;
    cout << "Yes" << endl;
    ans[n] = x;
    if(x == 2) {ans[n-1] = x+1; ans[n+1] = x-1; ans[n+2] = x+2;}
    else {ans[n-1] = x-1; ans[n+1] = x+1; ans[n+2] = x-2;}
    rep(i,1,2*n-1) vis[ans[i]] = true; 
    rep(i,1,2*n-1) if(!vis[i]) g.push_back(i);
    reverse(g.begin(),g.end());
    rep(i,1,2*n-1) if(!ans[i]) ans[i] = g.back(), g.pop_back();
    rep(i,1,2*n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N,D,A; cin>>N>>D>>A;
    vector<P> d;
    vec Z(N);
    rep(i,N){
        ll a,b; cin>>a>>b;
        d.pb(mp(a,b));
        //Z.pb(a);
    }
    sort(ALL(d));
    rep(i,N) Z.at(i)=d.at(i).first;
    vec Y(N+1,0);

    ll ans=0;
    ll count=0;
    rep(i,N){
        count-=Y.at(i);
        if(d.at(i).second>count*A){
            ll K=(d.at(i).second-1-count*A)/A;
            K++;
            ans+=K;
            count+=K;
            ll x=upper_bound(ALL(Z),d.at(i).first+2*D)-Z.begin();
            Y.at(x)+=K;
        }
    }
    cout<<ans<<endl;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll sum[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[114514];
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	sort(a, a+n);
	REP(i, n){
		sum[i+1]=sum[i]+a[i];
	}
	ll ans;
	if(n==2){
		ans=a[1]-a[0];
	}
	if(n==3){
		ans=max(2*a[2]-a[0]-a[1], a[1]+a[2]-2*a[0]);
	}
	else if(n&1){
		ans=max(2*(sum[n]-sum[n/2+1])-2*sum[n/2+1]+a[n/2]+a[n/2-1], 2*(sum[n]-sum[n/2])-a[n/2]-a[n/2+1]-2*sum[n/2]);
	}
	else{
		ans=2*(sum[n]-sum[n/2])-a[n/2]-2*sum[n/2]+a[n/2-1];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int gcd(int a, int b)
{
    if(a==b)
        return a;
    if(a>b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

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

int main()
{
    int i, j, res;
    int n;
    while(scanf("%d",&n)!=EOF){
        int arr[n];
        for(i=0; i<n; i++){
            scanf("%d",&arr[i]);
        }
        res = arr[0];
        for(j=1; j<n; j++){
            res = lcm(res, arr[j]);
        }
        printf("%d\n",res);
    }
}


Measured memory_bytes: 2100