akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

vin dx={-1,0,1,0};
vin dy={0,-1,0,1};

int w,h,nx,ny,m;

int dfs(vvin a,int x,int y,int vec,int res){
    ny=y+dy[vec];
    nx=x+dx[vec];
    if(ny<0||h-1<ny||nx<0||w-1<nx)return inf;
    while(a[ny][nx]!=1){
        y=ny;x=nx;
        if(a[y][x]==3)return res+1;
        ny=y+dy[vec];
        nx=x+dx[vec];
        if(ny<0||h-1<ny||nx<0||w-1<nx)return inf;
    }
    if(a[y][x]==2&&res==0)return inf;
    a[ny][nx]=0;
    res++;
    if(res>9)return inf;
    rep(i,4){
        ny=y+dy[i];
        nx=x+dx[i];
        if(ny<0||h-1<ny||nx<0||w-1<nx||a[ny][nx]==1)continue;
        m=min(m,dfs(a,x,y,i,res));
    }
    return m;
}

int main(){
    vin ans;
    int sx,sy,res,tmp;
    while(1){
        cin>>w>>h;
        if(w==0)break;
        vvin a(h,vin(w));
        rep(i,h)rep(j,w){
            cin>>a[i][j];
            if(a[i][j]==2){
                sy=i;
                sx=j;
            }
        }
        tmp=inf;m=inf;
        rep(i,4){
            res=0;
            tmp=min(tmp,dfs(a,sx,sy,i,res));
        }
        if(tmp>10)tmp=-1;
        ans.push_back(tmp);
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 1
#define INF (1LL<<50)
#define MOD 1000000007

map<lli,map<string,lli>> memo;
lli n;

bool ok(string last4){
	for(lli i=0;i<4;i++){
		string t = last4;
		if(i>=1)swap(t[i-1],t[i]);
		if(t.find("AGC")!=-1)return false;
	}
	return true;
}

lli func(lli now,string last3){
	if(memo[now][last3])return memo[now][last3];
	if(now == n)return 1;

	lli ret = 0;
	string s="AGCT";

	REP(i,0,4){
		string next4 = last3+s.substr(i,1);
		if(ok(next4))ret += func(now+1,next4.substr(1,3));
	}
	ret %= MOD;
	return memo[now][last3]=ret;
}

signed main(){

	cin>>n;

	cout<<func(0,"TTT")%MOD<<endl;

	return 0;
}

Measured memory_bytes: 896
var i,n,skt: integer;
a,c,d: string;
begin
readln(n);
readln(a);
for i:=1 to length(a) do     begin
if a[i]=' ' then inc(skt);
if (a[i]<>' ') and (skt=0)   then c:=c+a[i]
else if (a[i]<>' ') and (skt>0) then d:=d+a[i]
end;
for i:=1 to length(c) do
write(c[i],d[i]);
end.

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

using namespace std;

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

  if (n == 3) {
    cout << 2 << " " << 5 << " " << 63 << endl;
    return 0;
  }
  
  vector<int> cnts (7, 0);
  cnts[3] = n / 4;
  if (cnts[3] % 2 == 1) cnts[3]++;
  cnts[2] = n / 4;
  cnts[4] = n / 4;
  cnts[6] = n - cnts[3] - cnts[2] - cnts[4];

  if (cnts[6] == 5001) {
    cnts[6] -= 2;
    cnts[2]++;
    cnts[4]++;
  }

  int mx = 0;
  for (int k = 1; k <= 6; k++) {
    for (int i = 0; i < cnts[k]; i++) {
      mx = max(mx, 6 * i + k);
      cout << 6 * i + k << " ";
    }
  }
  cerr << mx << endl;
  cout << endl;
}


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

int main()
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            int z = s-i-j;
            if(z >=0 && z <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
s = 'ABC'
N = len(S)
C = 10**9+7
dp = [[0]*4 for _ in range(N+1)]
dp[N][3] = 1
for i in reversed(range(N)):
    for j in range(3):
        if i < j:
            continue
        dp[i][j] = ((1+(S[i] == '?')*2)*dp[i+1][j] +
                    (S[i] in {s[j], '?'})*dp[i+1][j+1]) % C
    if i>=3:
        dp[i][3] = ((1+(S[i] == '?')*2)*dp[i+1][3]) % C
print(dp[0][0])

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

using namespace std;
typedef long long ll;

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; }

int main()
{
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll count = B-A+1;

  ll common = __gcd(C, D); 
  
  count-=B/C-(A-1)/C;//Cで割り切れる
  //  cout << B/C-(A-1)/C << endl;
  count-=B/D-(A-1)/D;//Dで割り切れる
  // cout << B/D-(A-1)/D << endl;
  count+=B/(C*D/common)-(A-1)/(C*D/common);//C^Dで割り切れる
  //cout <<B/(C*D/common)-(A-1)/(C*D/common)<< endl;
  cout << count << endl;
  


  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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

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

	sort(str.begin(), str.end());
	for(int i=0; i<str.size()-1; i++) {
		if(str[i]==str[i+1]) {
			cout << "no" << endl;
			return 0;
		}
	}

	cout << "yes" << endl;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int n;

int main(){
    cin >> n;
    vector<int> x(n,0);
    REP(i,n)cin >> x[i];
    sort(ALL(x));
    int ans=1e+9;
    FOR(i,*(x.begin()),*(x.end()-1)+1)
    {
        int sum=0;
        REP(j,n)
        {
            sum+=(x[j]-i)*(x[j]-i);
            if(sum>=ans)break;
        }
        chmin(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


N, Q = MAP()
ab = [LIST() for _ in range(N-1)]
px = [LIST() for _ in range(Q)]

graph = defaultdict(list)

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

dic = defaultdict(int)

for p, x in px:
	dic[p-1] += x

check = [0]*N
check[0] = 1

ans = [0]*N

q = deque([0])

while q:
	n = q.popleft()
	ans[n] += dic[n]
	for node in graph[n]:
		if check[node]:
			continue
		ans[node] += ans[n]
		check[node] = 1
		q.append(node)

print(*ans)




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

using namespace std;

typedef pair<int, int> pr;
typedef vector<int> vec;
typedef long long int lli;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define TEST int T; cin >> T; while(T--)


int main() {
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int N;
long long A[101], B[101];
int op[101], bb, cc, dd;
bool vis[101];
 
long long bf(int n) {
  if(n == bb) {
    long long ans = 0;
    for(int i = bb; i < cc; i++) {
      if(op[i] == 0) {
//        vis[i] = 1, vis[i + i] = 1;
        ans += max(0LL, A[i] + (op[i + i] == 0 ? B[i + i] : 0));
      }
    }
    for(int i = cc; i < dd; i++) {
      if(op[i] == 0) {
//        vis[i] = 1;
        ans += B[i];
      }
    }
    for(int i = dd + 1; i <= N; i+=2) {
      if(op[i] == 0) {
//        vis[i] = 1;
        ans += B[i];
      }
    }
    return ans;
  }
  if(op[n]) {
    return bf(n + 1);
  }else {
    long long now = A[n] + bf(n + 1);
    for(int i = n + n; i <= N; i += n) {
      op[i]++;
    }
    now = max(now, bf(n + 1));
    for(int i = n + n; i <= N; i += n) {
      op[i]--;
    }
    return now;
  }
}
 
long long bf2(int n) {
  if(n + n > N) {
    long long ans = 0;
    for(int i = n; i <= N; i++) {
      if(op[i] == 0) ans += B[i];
    }
    return ans;
  }
  if(op[n]) {
    return bf2(n + 1);
  }else {
    long long now = A[n] + bf2(n + 1);
    for(int i = n + n; i <= N; i += n) {
      op[i]++;
    }
    now = max(now, bf2(n + 1));
    for(int i = n + n; i <= N; i += n) {
      op[i]--;
    }
    return now;
  }
}
 
 
int main() {
  scanf("%d", &N);
  bb = N / 3 + 1;
  cc = N / 2 + 1;
  dd = bb + bb;
  for(int i = 1; i <= N; i++) {
    scanf("%lld", &A[i]);
    if(A[i] > 0) B[i] = A[i];
  }
  if(N < 10) printf("%lld\n", max(0LL, A[1] + bf2(2)));
  else printf("%lld\n", max(0LL, A[1] + bf(2)));
//  for(int i = 1; i <= N; i++) if(!vis[i])cout << i << "\n";
  cin >> N;
}

Measured memory_bytes: 3820
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    cs <- U.unfoldrN n B.uncons <$> B.getLine
    q <- readLn :: IO Int
    ks <- map read.words <$> getLine
    mapM_ (print.solve cs) ks

solve :: U.Vector Char -> Int -> Int
solve cs k = fst $ U.foldl' step (U.foldl' step0 (0, emptyQ) pre) $ U.zip cs post
  where
    (pre, post) = U.splitAt k cs
    step0 (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c q

    step (!res, !q) (ck, c)
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c $ pop ck q

data Q = Q {-# UNPACK #-} !Int {-# UNPACK #-} !Int {-# UNPACK #-} !Int

emptyQ :: Q
emptyQ = Q 0 0 0

push :: Char -> Q -> Q
push 'D' (Q d m dm) = Q (d + 1) m dm
push 'M' (Q d m dm) = Q d (m + 1) (dm + d)
push c q            = q

pop :: Char -> Q -> Q
pop c (Q d m dm) = case c of
    'D' -> Q (d - 1) m (dm - m)
    'M' -> Q d (m - 1) dm
    _   -> Q d m dm

score :: Q -> Int
score (Q _ _ dm) = dm


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

int main(){
    int n;
    cin >> n;
    vector<vector<P>> t(n);
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x, y;
            cin >> x >> y;
            x--;
            t[i].emplace_back(x,y);
        }
    }

    int ans = 0;
    rep(bit,1<<n){
        vector<int> p(n);
        int num = 0;
        rep(i,n) if(bit & (1<<i)){
            p[i] = 1;
            num++;
        }

        vector<int> test(n, -1);
        bool flag = true;
        rep(i,n) if(bit & (1<<i)){
            for(auto m : t[i]){
                int x = m.first, y = m.second;
                if(test[x] == -1){
                    test[x] = y;
                    continue;
                }
                if(test[x] != y){
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            rep(i,n){
                if(test[i] == -1) continue;
                if(test[i] != p[i]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag) ans = max(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




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


}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut queue: VecDeque<char> = VecDeque::new();
    for i in 0..s.len() {
        let mut delete = false;
        match queue.front() {
            Some(x) => {
                if *x != s[i] {
                    delete = true;
                }
            },
            None => (),
        }
        if delete {
            queue.pop_front();
        } else {
            queue.push_front(s[i]);
        }
    }
    println!("{}", s.len() - queue.len());
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        return ((N-2)*180).ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)


int main() {
    int n, k;
    cin >> n >> k;
    int res = 0;
    for(int i=0; i<n; i++) {
        int t; cin >> t;
        if(t >= k) res++;
    }
    cout << res << endl;
}


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

As = [1]
As += [6 ** i for i in range(1, 7) if 6 ** i <= N]
As += [9 ** i for i in range(1, 6) if 9 ** i <= N]

As.sort(reverse=True)

Ms = [float('inf')] * (N + 1)
Ms[0] = 0
for A in As:
    for i in range(N):
        if Ms[i] != float('inf') and i + A <= N:
            Ms[i + A] = min(Ms[i + A], Ms[i] + 1)

print(Ms[N])


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


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

Int calc(vector<Int> &v){
  Int n=v.size();
  Int res=0;
  using P = pair<Int, Int>;
  stack<P> sp;
  sp.emplace(-1,-1);
  for(Int i=0;i<n;i++){
    Int j=i;
    while(sp.top().second>v[i]){
      j=sp.top().first;
      chmax(res,(i-j)*sp.top().second);
      sp.pop();
    }
    if(sp.top().second<v[i]) sp.emplace(j,v[i]);
  }
  while(!sp.empty()){
    chmax(res,(n-sp.top().first)*sp.top().second);
    sp.pop();
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  auto a=make_v<Int>(h,w);
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];
  auto dp=make_v<Int>(h,w);
  fill_v(dp,0);
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(a[i][j]) continue;
      dp[i][j]=(i?dp[i-1][j]:0)+1;
    }
  }
  Int ans=0;
  for(Int i=0;i<h;i++) chmax(ans,calc(dp[i]));
  cout<<ans<<endl;
  return 0;
}



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

const int N = 2000;
const long long INF = 1 << 21;

long long  n, k, M[N][N];
long long dist[N], ans[N];

void bfs(int s){
    rep(i,n) dist[i] = INF;

    queue<int> q;

    q.push(s);
    dist[s] = 0;

    while(!q.empty()){
        int u = q.front(); q.pop();

        for(int v = 0; v < n; v++){
            if(M[u][v] == 1 && dist[v] == INF){
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
}

int main(){
    int x, y;
    cin >> n >> x >> y;
    x--; y--;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }

    for(int i = 0; i < n-1; i++){
        M[i][i+1] = 1;
        M[i+1][i] = 1;
    }
    M[x][y] = M[y][x] = 1;

    for(int i = 0; i < n; i++){
        dist[i] = INF;
        ans[i] = 0;
    }

    bfs(0);

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(i <= x){
                ans[dist[j] - i]++;
            }else if(x < i && j < y && i < y){
                ans[min(i-x + 1 + y - j, j - i)]++;
            }else if(x < i && y <= j && i < y){
                ans[min(i-x + 1, y - i) + j - y]++;
            }else{
                ans[dist[j] - dist[i]]++;
            }
        }
    }

    for(int i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int a, b;
	cin >> a >> b;
	cout << max((ll)0, a - (ll)2 * b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int inv[26];

bool ok(const string& t) {
    if (t.find("that") != string::npos) return true;
    if (t.find("this") != string::npos) return true;
    return false;
}

string decode(const string& s) {
    rep (a, 26) if (a % 2 != 0 && a % 13 != 0) {
        rep (b, 26) {
            string t(s);
            rep (i, s.size()) if (islower(s[i])) {
                t[i] = 'a' + (s[i]-'a'+b)*inv[a] % 26;
            }
            if (ok(t)) return t;
        }
    }
    return "";
}

int main() {
    rep (i, 26) {
        int k = 1;
        rep (_, 11) k = (k*i)%26;
        inv[i] = k;
    }
    string s;
    getline(cin, s);
    int T = atoi(s.c_str());
    while (T--) {
        getline(cin, s);
        if (s.size() && s[s.size()-1] == '\r') s.resize(s.size()-1);
        cout << decode(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
	ll A,B;
    char C;
    cin>>A>>C>>B;
    cout<<(C=='+' ? (A+B):(A-B));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int INF = 1e+9;
int h, w;
string s[1000];
int dist[1000][1000];

signed main() {
	int i, j;
	
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w) dist[i][j] = INF;
	
	typedef pair<int, int> P;
	int dy[4] = {-1, 0, 1, 0};
	int dx[4] = {0, 1, 0, -1};
	queue<P> que;
	
	rep(i, h) rep(j, w) if (s[i][j] == '#') { que.push(P(i, j)); dist[i][j] = 0; }
	while (!que.empty()) {
		P now = que.front(); que.pop();
		int y = now.first;
		int x = now.second;
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (dist[ny][nx] <= dist[y][x] + 1) continue;
			dist[ny][nx] = dist[y][x] + 1;
			que.push(P(ny, nx));
		}
	}
	
	int ans = 0;
	rep(i, h) rep(j, w) ans = max(ans, dist[i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <cmath>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a;
    double b;
    cin, a, b;
    ll c = round(b * 100);
    a *= c;
    a /= 100;
    print(a);

    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,D;
    cin >>N>>D;
    vector<vector<double>>vec(N,vector<double>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>vec.at(i).at(j);
        }
    }
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double AAA=0;
            for(int k=0;k<D;k++){
                double A=(vec.at(i).at(k)-vec.at(j).at(k))*(vec.at(i).at(k)-vec.at(j).at(k));
                AAA+=A;
            }
         for(int i=1;i<1000000;++i){
             if(i*i==AAA){
                 count ++;
                 break;
             }
         }
        }
    }
    cout <<count <<endl;
}

Measured memory_bytes: 3732
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string S;
  cin >> S;
  int N = S.length() + 1;
  S = ">" + S + "<";
  vector<int> a(N, 0);
  for (int i = 0; i < N; ++i) {
    if (S[i] == '>' && S[i + 1] == '<') {
      for (int j = i + 1; j < N && S[j] == '<'; ++j)a[j] = max(a[j], a[j - 1] + 1);
      for (int j = i; j > 0 && S[j] == '>'; --j)a[j - 1] = max(a[j - 1], a[j] + 1);
    }
  }
  int64_t ans = accumulate(begin(a), end(a), (int64_t)0);
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	cout << 180 * (n - 2) << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 256
N=int(input())
result={}
s=[]
t=[]
for i in range(N):
  s.append(input())
  if s[i] in result.keys():
    result[s[i]]+=1
  else:
    result[s[i]]=1
M=int(input())
for j in range(M):
  t.append(input())
  if t[j] in result.keys():
    result[t[j]]-=1
if max(result.values()) > 0:
  print(max(result.values()))
else:
  print(0)

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

long long s;
int mod = 1e9 + 7;

int main() {
    cin >> s;
    map<long long, bool> flag;
    flag[s] = true;
    int m = 1;
    while(1) {
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s *= 3;
            s += 1;
        }
        m++;
        if (flag[s]) {
            cout << m << endl;
            return 0;
        }
        flag[s] = true;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long 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;
}

int main(void) {
    int N, D;
    cin >> N >> D;

    int d = 2 * D + 1;

    cout << ((N + d - 1) / d) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,E,F,G,H,I,J,K,L,M,N,T,W,X,Y;
  string S;
  cin >>  N >> M;
  
  vector<long long> vec(N+1,0);
  for (int i=0;i<M;i++) {
    cin >> A;
	vec.at(A)=-1;
  }
  vec.at(0)=1;
  for (int j=1;j<N+1;j++) {
    if (j==1 && vec.at(1)==0) {vec.at(1)=1;}
	else if (vec.at(j)==-1) {vec.at(j)=0;}
	else {vec.at(j)=(vec.at(j-2)+vec.at(j-1))%1000000007;}
  }
  
  cout << vec.at(N) << endl;
  
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<int> T(N+1, 0);
	int S=0;
	for (int i=1; i<=N; i++) {
		cin >>T.at(i);
		S +=T.at(i);
	}
	int M;
	cin >>M;
	for (int i=0; i<M; i++) {
		int P, X;
		cin >>P >>X;
		cout <<S-T.at(P)+X <<endl;
	}
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = [0 for _ in range(N)]
x = []
y = []
for i in range(N):
    x_ = []
    y_ = []
    A[i] = int(input())
    for _ in range(A[i]):
        in1, in2 = list(map(int,input().split()))
        x_.append(in1 - 1)
        y_.append(in2)
    x.append(x_)
    y.append(y_)

def bit_all():
    ret = 0
    for p in range(2 ** N):
        temp = 0
        flag = 1
        b = str(format(p, '020b'))
        for i in range(N):
            if b[-(i + 1)] == "1":
                for j in range(A[i]):
                    if int(b[-(x[i][j] + 1)]) != y[i][j]:
                        flag = 0
                temp += 1
        if flag:
            ret = max(ret, temp)
    return ret

ans = bit_all()
print(ans)

Measured memory_bytes: 43116
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

long long X, Y;

int mod = 1e9 + 7;

int power(int a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int b = power(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * power(a, n - 1) % mod;
    }
}

int inverse(int a) {
    if (a == 1) {
        return 1;
    }
    return power(a, mod - 2);
}

int main() {
    cin >> X >> Y;
    if ((X + Y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    long long Z = (X + Y) / 3;
    if ((X - Y + Z) % 2) {
        cout << 0 << endl;
        return 0;
    }
    long long y = (X - Y + Z) / 2;
    if (y > Z || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for (int i = 2; i < Z + 1; i++) {
        ans *= i;
        ans %= mod;
    }
    int dnm1 = 1, dnm2 = 1;
    for (int i = 2; i < y + 1; i++) {
        dnm1 = 1LL * dnm1 * i % mod;
    }
    for (int i = 2; i < Z - y + 1; i++) {
        dnm2 = 1LL * dnm2 * i % mod;
    }
    cout << ans * inverse(dnm1) % mod * inverse(dnm2) % mod << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a, b;
void inp() {
    cin >> a >> b;
}
void pc() {
    if (a<=5) cout << 0;
    if (a>5 && a<13) cout << b/2;
    if (a>12) cout << b;
}
int main()
{
    inp(); pc();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int N = 1e5+4;
vector <int> adj[N];
bool visit[N];
bool color[N];
bool ck;
int n,m;
void dfs(int s)
{
	for(auto u : adj[s])
	{
		if(visit[u] == false)
		{
			color[u] = 1-color[s];
			visit[u] = true;
			dfs(u);
		}

		else
		{
			if(color[u] != 1-color[s])
				ck = true;
		}
	}
}

signed main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%lld %lld",&a,&b);
		adj[a].pb(b);
		adj[b].pb(a);
	}

	dfs(1);
	if(ck)
	{
		cout<<n*(n-1)/2 - m;
	}
	else
	{
		int cnt = 0;
		for(int i=1;i<=n;i++)
		{
			cnt += color[i];
		}
		cout<<cnt*n - cnt*cnt - m;
	}
}

Measured memory_bytes: 7424
str_list = input().split(' ')
int_list = [int(x) for x in str_list]

a, b, x = int_list[0], int_list[1], int_list[2]

import numpy as np

if x < 0.5 * a * a * b:
    theta = 180/np.pi*np.arctan( (a*b*b)/(2*x) )
    print(theta)
else:
    theta = 180/np.pi*np.arctan( 2.0*(a*a*b-x)/(a**3) )
    print(theta)


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





int main(){

	int k;
	cin>>k;
	string s;
	cin>>s;
	if(k >= s.size())
		cout<<s<<endl;
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		for(int i=0;i<3;i++){
			cout<<'.';
		}
		cout<<endl;
	}
  
}


Measured memory_bytes: 3628
A,B,K = map(int, input().strip().split(' '))

if B-A+1 > K*2:
  ans = list(range(A, A+K))+list(range(B-K+1, B+1))
  print(*ans, sep="\n")
else:
  print(*list(range(A,B+1)), sep="\n")



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5 * 1e3 + 5;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0)
        cout << a - b;
    else
        cout << b - a;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
        for(int64_t i = 1; i * i <= n; i++) {
            if(n % i == 0) {
                ret.push_back(i);
                if(i * i != n){
                    ret.push_back(n / i);
                }
            }
        }
    sort(ret.begin(), ret.end());
    return (ret);
}


int main() {
    ll n, m;
    cin >> n >> m;
    vector<int64_t> v = divisor(m);
    ll ans = 1;
    for(int i = 1; i < v.size(); i++){
        if(v[i] * n <= m){
            ans = v[i];
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	int N;
	int sum = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a, b;
		cin >> a >> b;
		sum += b - a + 1;
	}
	cout << sum << endl;
}

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

class Program{
    public static void Main(){
        var S = string.Empty;
        var N = int.Parse(ReadLine());
        if(N == 0){
            WriteLine("0");
            return;
        }

        while(N != 0){
            var Syou = N / (-2);
            var Amari = N % (-2);
            if(N < 0){
                Amari *= -1;
                Syou += Amari;
            }
            S = $"{Amari}{S}";
            N = Syou;
        }
        WriteLine(S);
    }
}

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

typedef long long ll;
typedef long double ld;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  if (n == 1) {
    if (a == b) {
      cout << 1 << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
  else if (a > b){
    cout << 0 << endl;
  }
  else {
    cout << b*(n-2)-a*(n-2)+1<< endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    ll x=0;
    rep(i,n)cin>>a[i],x+=a[i];
    rep(i,n)cin>>b[i],x-=b[i];
    if(x<0){cout<<-1<<endl; return 0;}
    ll sum=0;
    int ans=0;
    priority_queue<int>q;
    rep(i,n){
        if(a[i]<b[i])sum+=a[i]-b[i],ans++;
        else q.emplace(a[i]-b[i]);
    }
    while(1){
        if(sum>=0)break;
        sum+=q.top();
        q.pop();
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4556
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll a,b,t;
    cin>>a>>b>>t;
    if(t<a)
    {
        cout<<"0"<<endl;
    }
    else
    {
        ll x=t/a;
        cout<<x*b<<endl;
    }
}


Measured memory_bytes: 3644
w,b = map(int, input().split())
grid = [["."  for j in range(100) ] for i in range(100)]
for v in range(w-1):
    i,j = v//25, v%25
    for t in range(4):
        grid[i*4 + 3][j*4 + t] = "#"
        grid[i*4+t][j*4+3] = "#"
for v in range(b-1 if w != 1 else b):
    i,j = v//25, v%25
    grid[i*4+1][j*4+1] = "#"
print(100, 100)
for v in grid:
    print("".join(v))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll h, w, m;
    cin >> h >> w >> m;
    set<pair<ll, ll>> hw;
    vector<ll> hcount(h, 0), wcount(w, 0);
    REP(i, m){
        ll hi, wi;
        cin >> hi >> wi;
        hi--; wi--;
        hcount.at(hi)++;
        wcount.at(wi)++;
        hw.emplace(hi, wi);
    }

    const ll maxh = *max_element(ALL(hcount));
    vector<ll> hidx;
    REP(i, h){
        if(hcount.at(i) == maxh){
            hidx.push_back(i);
        }
    }

    const ll maxw = *max_element(ALL(wcount));
    vector<ll> widx;
    REP(i, w){
        if(wcount.at(i) == maxw){
            widx.push_back(i);
        }
    }

    ll ans = maxh + maxw;
    if(hidx.size() * widx.size() <= m){
        bool is_ok = false;
        for(ll hi : hidx){
            for(ll wi : widx){
                if(hw.count(make_pair(hi, wi)) == 0){
                    is_ok = true;
                    break;
                }
            }
        }
        if(!is_ok){ ans--; }
    }
    cout << ans << endl;
    return 0;
}


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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return x>a.x;
    }
};
struct S
{
    int x,y,z;

    bool operator<(const S &a)const{
              return x<a.x;
    }
};

vector<int> v;
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
long long l[1114000];

long long o[1114211];
int j[2];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z;

P u[555320];
//stack<int> s;

//set<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;
//string r1,r;
//char r[1152][1111];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y>b.y;
}

long long f(int a)
{
    if(a<0) return 0;
    else
    return o[a];
}

long long g(int a,int b)
{
    if(b<a) return 0;
    return f(b)*(l[a]*l[b-a]%mod)%mod;
}

long long p(long long a,long long b)
{
    if(!b) return 1;
    long long x=p(a,b>>1);
    x*=x,x%=mod;
    if(b&1) x*=a,x%=mod;
    return x;
}

int main()
{
    scanf("%d",&a);
    if(a==2)
    {
        puts("1");
        return 0;
    }
    o[0]=1;
    for(int t=1;t<=a;t++)
        o[t]=o[t-1]*t%mod;
    l[0]=1;
    for(int t=1;t<=a;t++)
        l[t]=p(o[t],mod-2);
    for(int t=2;t<a;t++)
    {
        y=x;
        x=f(a-t-1)*f(t)%mod*g(a-t-1,t-1)%mod;
        z+=(x-y+mod)%mod*t%mod;
        z%=mod;
        //printf("##%lld\n",x);
        //printf("%lld %lld %lld\n",f(a-t-1),f(t),g(a-t-1,t-1));
    }
    printf("%lld",z);
}



Measured memory_bytes: 17152
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)

Measured memory_bytes: 40720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    //eturn 0;
    ll ans=2e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll g=abs(1-i)+abs(1-n/i);
            ans=min(ans,g);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
from itertools import groupby

s = input()
k = int(input())
r = len(s) * k // 2
a = [len(tuple(g)) & 1 for _, g in groupby(s)]
if len(a) > 1:
  r -= sum(a) * k // 2
  if s[0] == s[-1] and a[0] & a[-1]:
    r += k - 1
print(r)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(),
            M = sc.nextInt(),
            answer = 0;
        int[] food = new int[M];      
        for(int i = 0; i < N; i++){
            int K = sc.nextInt();
            for(int j = 0; j < K; j++){
                food[sc.nextInt()-1]++;
            }
        }
        for(int i = 0; i < M; i++){
            if(food[i] == N){
                answer++;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const int mod = 1e9 + 7;//200003;786433;998244353;
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int h, w;
char a[505][505], b[505][505], c[505][505];
bool Vis[505][505];

void BFS2(int x, int y)
{
	if(b[x][y] == '#' and a[x][y] != '#')
	{
		return;
	}
	if(c[x][y] == '#' or x == 0 or y == 0 or x == h + 1 or y == w + 1)
	{
		return;
	}
	c[x][y] = '#';
	BFS2(x + 1, y);
	BFS2(x, y + 1);
	BFS2(x - 1, y);
	BFS2(x, y - 1);
}

signed main()
{
	Fastio();
	cin >> h >> w;
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			cin >> a[i][j];
			b[i][j] = '.';
			c[i][j] = '.';
		}
	}
	for(int i = 1; i <= w; i++)
	{
		b[1][i] = '#';
		if(i & 1)
		{
			for(int j = 2; j <= h - 1; j++)
			{
				b[j][i] = '#';
				if(a[j][i + 1] == '#')
				{
					b[j][i + 1] = '#';
				}
			}
		}
	}
	BFS2(h, 1);
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			cout << b[i][j];
		}
		cout << '\n';
	}
	cout << '\n';
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			cout << c[i][j];
			if(a[i][j] == '#')
			{
				assert(c[i][j] == '#');
			}
			if(a[i][j] == '#' && b[i][j] == '#' and c[i][j] != '#')
			{
				assert(0);
			}
		}
		cout << '\n';
	}
}

Measured memory_bytes: 23760
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

int solve(int N, int K) {
    const int MAX = 510000;
    auto func = [&](int a, int b) { return max(a, b); };
    SegTree<int> seg(MAX, func, 0);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        int left = max(0, a - K);
        int right = min(MAX, a + K + 1);
        int val = seg.get(left, right);
        seg.update(a, val + 1);
    }
    return seg.get(0, MAX);
}

int main() {
    int N, K;
    cin >> N >> K;
    cout << solve(N, K) << endl;
}

Measured memory_bytes: 7492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n, x, i;
    cin >> n;
    vector < pair < ll, ll > > v;
    for(i = 0; i < n; i++){
        cin >> x;
        v.push_back(make_pair(x, i+1));
    }
    sort(v.begin(), v.end());
    for(auto it : v){
        cout << it.second << " ";
    }
    return 0;
}

Measured memory_bytes: 2672
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var S = Str;
		var max = 0;
		for (var i = 0; i <= N; i++)
		{
			var P = new HashSet<char>(S.Substring(0, i));
			var Q = new HashSet<char>(S.Substring(i, N - i));
			P.IntersectWith(Q);
			max = Max(max, P.Count);
		}
		WriteLine(max);
	}
}


Measured memory_bytes: 13280
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, k;
	long long x[100000];
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	long long ans = LLONG_MAX;

	for (int i = 0; i < n - k + 1; ++i) {
		ans = min(ans, min(abs(x[i]), abs(x[k + i - 1])) + abs ( x[k + i - 1] - x[i]));
	}

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
	char s[100];
	scanf("%s", s);
	int cont = 0;
	for(int i = 0; i < strlen(s)/2; i++){
		if(s[i] != s[strlen(s)-i-1])
			cont++;
	}
	printf("%d\n", cont);
	return 0;
}

Measured memory_bytes: 128
S = list(input())
list = []
for _ in range(len(S)-2):
    num = S[_]+S[_+1]+S[_+2]
    list.append(int(num))
list2 = []
for _ in list:
    list2.append(abs(753-_))
list2.sort()
print(list2[0])


Measured memory_bytes: 3060