akhauriyash/Code-Regression huggingface dataset:
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int a,b;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b;
	cout<<int(double(a+b)/2+0.5);
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
vll v;
ll sum[100100];

void solve(){
    cin >> n;
    v.pb(0);
    for(int i = 0; i < n; ++i){
        ll x;
        cin >> x;
        sum[i + 1] = sum[i] + abs(x - v.back());
        v.pb(x);
    }
    //for(int i = 0; i < n + 1; ++i) cout << sum[i] << " ";

    for(int i = 1; i < n; ++i){
        int cur = sum[i - 1] + abs(v[i + 1] - v[i - 1]) + sum[n] - sum[i + 1] + abs(v[n]);
        cout << cur << "\n";
    }
    cout << sum[n - 1] + abs(v[n - 1]) << "\n";
}

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

    solve();
    
    return 0;
}

Measured memory_bytes: 2932
l, r = map(int,input().split())

min=10**9
if((r-l)>=2019):
    min = 0
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            if(i<j and l<j):
                mod = (i*j)%2019
                if(mod<min):
                    min=mod

print(min)

Measured memory_bytes: 3060
target = 'ACGT'
S = input()

answer = 0
for start in range(len(S)):
    if S[start] not in target:
        continue
    count = 0
    for end in range(start, len(S)):
        if S[end] in target:
            count += 1
        else:
            break
    
    answer = max(answer, count)

print(answer)

Measured memory_bytes: 9048
N, M = (int(x) for x in input().split())
F = [0,1]
for i in range(N):
    F.append(F[i]+F[i+1])

a = [-1]
for i in range(M):
    a.append(int(input()))

a.append(N+1)
ans = 1
for i in range(M+1):
    length = a[i+1] - a[i] - 1
    if length == 0:
        print(0)
        exit()
    else:
        ans *= F[length]

print(ans%(10**9+7))


Measured memory_bytes: 464100
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 2010, M = 4e6+10;
int n, k, dp[N][N];
int fac[M], ifac[M];
int C(int n, int m) {
	if (n<m) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}
int main() {
	fac[0]=1;
	REP(i,1,M-1) fac[i]=(ll)fac[i-1]*i%P;
	ifac[M-1]=inv(fac[M-1]);
	PER(i,0,M-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	if (k==1) return puts("1"),0;
	dp[0][0] = 1;
	REP(i,0,n) REP(j,0,i) {
		dp[i+1][j] = (dp[i+1][j]+dp[i][j])%P;
		dp[i][j+1] = (dp[i][j+1]+(ll)C(n*k-j*(k-1)-i-1,k-2)*dp[i][j])%P;
	}
	int ans = (ll)dp[n][n]*fac[n]%P;
	printf("%d\n", ans);
}








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

int main() {
    int N, K;

    cin >> N >> K;

    int x[N];

    int sum = 0;

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

    for (int i = 0; i < N; i++) {
        int a_sa = x[i];
        int b_sa = K - x[i];

        int taishou_sa = min(a_sa, b_sa);

        sum = sum + (2 * taishou_sa);

    }

    cout << sum << endl;


    return 0;

}





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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-5
#define inf 1e14

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

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 25;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a == b && b == c ? "Yes" : "No");
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize(2)
#pragma G++ optimize(2)

#include <bits/stdc++.h>

#define LL long long
#define int long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<LL, LL>
#define pdd pair<double, double>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define length(p1, p2) ((p1.fi-p2.fi)*(p1.fi-p2.fi)+(p1.se-p2.se)*(p1.se-p2.se))
#define ith(state, i) (state & (1 << i))
#define PI acos(-1.0)
#define SZ(x) ((int)(x.size()))

using namespace std;

constexpr int N = 1e6+9;
constexpr int M = 1e9+9;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

string pay;
int dp[N][2];

int solve(int i, int f) {
    if (i < 0) return f ? INF : 0;
    int& ans = dp[i][f];
    if (ans != INF) return ans;
    int n = pay[i] - '0';
    if (f) {
        ans = min(ans, 10 - n + solve(i-1, 0));
        ans = min(ans, 10 - n - 1 + solve(i-1, 1));
    } else {
        ans = min(ans, n + solve(i-1, 0));
        ans = min(ans, n + 1 + solve(i-1, 1));
    }
    return ans;
}

signed main() {
    fastio;
    cin >> pay;
    memset(dp, 0x3f, sizeof(dp));
    reverse(pay.begin(), pay.end());
    cout << min(1 + solve(SZ(pay)-1, 1), 0 + solve(SZ(pay)-1, 0)) << endl;
    return 0;
}

Measured memory_bytes: 63900
#include<cstdio>
#include<algorithm>
const int N=5e5+3;
char buf[4000000],*c,t[8];
int i,j,k,n,x,a[N],RT,ls[N],rs[N],fa[N],d[N],mi[N],siz[N];
inline int Read()
{
	while(*c<48)++c;
	for(x=0;*c>47;++c)x=x*10+*c-48;
	return x;
}
inline void W(int i)
{
	for(x=1;i;i/=10)t[x++]=i%10+48;
	for(;x--;*c++=t[x]);
}
inline void pup(int p)
{
	siz[p]=siz[ls[p]]+siz[rs[p]]+1;
	mi[p]=std::min(d[p],std::min(mi[ls[p]],mi[rs[p]]));
}
void L_rotate(int p)
{
	int i=fa[p],j=fa[i],t=siz[p];
	if(fa[p]=j)(ls[j]==i?ls[j]:rs[j])=p;else RT=p;
	if(ls[p])fa[ls[p]]=i;
	rs[i]=ls[p],ls[p]=i,fa[i]=p;
	pup(i),pup(p);
}
void R_rotate(int p)
{
	int i=fa[p],j=fa[i],t=siz[p];
	if(fa[p]=j)(ls[j]==i?ls[j]:rs[j])=p;else RT=p;
	if(rs[p])fa[rs[p]]=i;
	ls[i]=rs[p],rs[p]=i,fa[i]=p;
	pup(i),pup(p);
}
void splay(int p,int top=0)
{
	for(int i,j,q;fa[p]!=top;)
	{
		q=fa[p],i=ls[fa[p]]==p,j=ls[fa[q]]==q;
		if(i^j||fa[q]==top)i?R_rotate(p):L_rotate(p);else
		i?(R_rotate(q),R_rotate(p)):(L_rotate(q),L_rotate(p));
	}
}
int getnum(int x)
{
	for(int p=RT,t;p;)
	{
		if(t=siz[ls[p]]+1,x==t)return p;
		if(t<x)x-=t,p=rs[p];else p=ls[p];
	}
}
int Q(int p,int x)
{
	int res=0;
	for(;p;)
		if(mi[rs[p]]<x)res+=siz[ls[p]]+1,p=rs[p];else
		if(d[p]<x)return res+=siz[ls[p]]+2;else p=ls[p];
	return res+1;
}
void sft(int l,int r)
{
	splay(getnum(r-1)),splay(getnum(r+1),RT);
	i=ls[rs[RT]],ls[rs[RT]]=0;
	pup(rs[RT]),pup(RT);
	splay(getnum(l-1)),splay(getnum(l),RT);
	ls[rs[RT]]=i,fa[i]=rs[RT];
	pup(rs[RT]),pup(RT);
}
void dfs(int p)
{
	if(!p)return;
	dfs(ls[p]),a[d[p]]=++i,dfs(rs[p]);
}
int main()
{
	fread(buf,1,4e6,stdin),c=buf;
	n=Read(),k=Read();
	for(i=1;i<=n;d[Read()]=i++);
	rs[RT=n+2]=1,fa[1]=RT,*mi=n;
	for(siz[RT]=n+2,siz[n+1]=1,i=n;i;--i)
		rs[i]=i+1,fa[i+1]=i,siz[i]=n+2-i;
	for(i=2;i<=n;++i)
	{
		splay(getnum(1)),splay(getnum(i+1),RT);
		if((j=Q(ls[rs[RT]],k+d[i]))<i)sft(j+1,i+1);
	}
	splay(getnum(1)),splay(getnum(n+2),RT);
	i=0,dfs(ls[rs[RT]]);
	for(*t=10,c=buf,i=1;i<=n;W(a[i++]));
	fwrite(buf,1,c-buf,stdout);
}

Measured memory_bytes: 28288
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int main(){
	int m;
	cin >> m;
	
	cout << 24 + (24 - m) << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())

Sq = deque(S)


flg = True
for i in range(Q):
    que = input()
    if que == "1":
        if flg:
            flg = False
        else:
            flg = True
    else:
        j, F, C = que.split()
        if int(F) == 1:
            if flg:
                Sq.appendleft(C)
            else:
                Sq.append(C)
        else:
            if flg:
                Sq.append(C)
            else:
                Sq.appendleft(C)

if flg:
    for i in Sq:
        print(i, end="")
else:
    Sq.reverse()
    for i in Sq:
        print(i, end="")

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

int k;
int a, b;

int main()
{
	cin >> k;
	cin >> a >> b;
	for(int i = a; i <= b; i++) if(i % k == 0) {cout << "OK"; return 0;}
	cout << "NG";
	
//	system("pause");
	return 0;
}

Measured memory_bytes: 3596
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();

    let inf: i64 = n as i64 * n as i64 * n as i64;
    let mut memo: Vec<Vec<i64>> = vec![vec![inf, inf, inf]; n];

    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..m {
        let u = sc.cin::<usize>() - 1;
        let v = sc.cin::<usize>() - 1;
        g[u].push(v);
    }
    let s: usize = sc.cin::<usize>() - 1;
    let t: usize = sc.cin::<usize>() - 1;

    memo[s][0] = 0;

    use std::collections::BinaryHeap;
    let mut q = BinaryHeap::new();
    q.push((0 as i64, s));
    while let Some((_dist, u)) = q.pop() {
        let dist = -_dist;
        for &v in g[u].iter() {
            let res = (dist + 1) % 3;
            if memo[v][res as usize] > dist + 1 {
                memo[v][res as usize] = dist + 1;
                q.push((-dist-1, v));
            }
        }
    }

    put!(if memo[t][0] == inf { -1 } else { memo[t][0] / 3 });

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 18684
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(int i = x, _b = y; i <  _b; i ++)
#define fd(i, x, y) for(int i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
#define dub(...) fprintf(stderr, _VA_ARGS)
using namespace std;

const int mo = 998244353;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x * x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

const int N = 5e5 + 5;

int n, m;
ll fac[N], nf[N];

void build(int n) {
	fac[0] = 1; fo(i, 1, n) fac[i] = fac[i - 1] * i % mo;
	nf[n] = ksm(fac[n], mo - 2); fd(i, n, 1) nf[i - 1] = nf[i] * i % mo;
}

ll C(int n, int m) {
	if(n < m) return 0;
	return fac[n] * nf[m] % mo * nf[n - m] % mo;
}

int main() {
	build(5e5);
	scanf("%d %d", &n, &m);
	ll ans = 0;
	fo(k, 0, min(n, m))
		ans += (k & 1 ? -1 : 1) * C(n, k) * C(m, k) % mo * fac[k] % mo * ksm(m + 1, n - k) % mo * ksm(n + 1, m - k) % mo;
	ans = (ans % mo + mo) % mo;
	pp("%lld\n", ans);
} 

Measured memory_bytes: 8064
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

// sorting pairs

struct Tupple{

  int v;
  int w;
  string t;
  long long int d;
  string s;

  bool operator<(const Tupple& a) const{

    if(v < a.v){
      return true;
    }
    if(v == a.v ){
      if(w < a.w){
        return true;
      }
    }
    if(v == a.v && w == a.w  ){
      if(t < a.t){
        return true;
      }
    }
    
    if(v == a.v && w == a.w && t == a.t ){
      if(d < a.d){
        return true;
      }
    }
    
    if(v == a.v && w == a.w && t == a.t && d == a.d ){
      if(s < a.s){
        return true;
      }
    }

    return false;

    //if(x < another.x){
    //  return true;
    //}
    //if(x == another.x){
    //  if(y < another.y){
    //    return true;
    //  }
    //}
    //
    //return false;
    
  }
  
};


int main(){
  long ii,jj,kk;
  vector<int> ret;
  int n;
  vector<Tupple> t;

  cin >> n;

  t.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> t[ii].v >> t[ii].w >> t[ii].t >> t[ii].d >> t[ii].s ;
  }
  
  sort(t.begin(),t.end());
  
  for(ii=0;ii<n;ii++){
    //cout << p[ii].x << " " << p[ii].y << endl;
    cout << t[ii].v << " " << t[ii].w << " " << t[ii].t << " " << t[ii].d << " " << t[ii].s << endl;
  }

  
  return 0;

}



Measured memory_bytes: 16936
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll r;
    cin >> r;
    cout << 3 * r * r;
    return 0;
}

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

using namespace std;

typedef long long ll;

ll read (){
	ll ret=0,w=0;char c=getchar ();
	while (c>'9'||c<'0')w=(c=='-'?1:0),c=getchar();
	while (c<='9'&&c>='0')ret=ret*10+c-'0',c=getchar();
	return w==1?-ret:ret;
}

ll n,x,d;

ll gcd (ll a,ll b){
	if (a%b==0)return b;
	return gcd(b,a%b);
}

int main (){
	n=read();
	x=read();
	d=gcd(n,x);
//	cout<<d<<endl;
	cout<<(n/d-1)*3*d;
	return 0;
}


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

int main (void)
{
int t[4],n[4];
for(int i=0;i<4;i++)
{
cin>>t[i]>>n[i];
}
for(int i=0;i<4;i++)
{
switch(t[i]){
 case 1:cout<<n[i]*6000<<endl; break;
 case 2:cout<<n[i]*4000<<endl; break;
 case 3:cout<<n[i]*3000<<endl; break;
 case 4:cout<<n[i]*2000<<endl; break;
}
}
return 0;
}

Measured memory_bytes: 3120
use proconio::input;
use std::cmp::max;

fn main()
{
    input! {
    a:i32,
    b:i32
    }
    ;
    let ans = if a == b {
        2 * a
    } else {
        let m = max(a, b);
        m + m - 1
    };
    println!("{}", ans);
}

Measured memory_bytes: 2172
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int ans=0;
  int X = 0;
  int N = 0;
  string s;

  cin >> s;
  
  if(s == "A"){
    cout << "T" << endl;
  }else if(s == "C"){
    cout << "G" << endl;
  }else if(s == "T"){
    cout << "A" << endl;
  }else if(s == "G"){
    cout << "C" << endl;
  }
}


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

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	long long  n, k; cin >> n >> k;
	vector<long long > a(n + 1, 0); for (int  i = 1; i <= n; i++) cin >> a[i];
	vector<long long > pref(n + 1, 0); for (int  i = 1; i <= n; i++) pref[i] = (pref[i - 1] + (a[i] % k)) % k;

	map<long long , long long > freq;
	freq[0] = 1;
	long long  ans = 0;
	for (int  i = 1; i <= n; i++) {

		if (i >= k and freq.find(pref[i - k] - (i - k)) != freq.end()) {
			freq[pref[i - k] - (i - k)]--;
			if (freq[pref[i - k] - (i - k)] == 0) freq.erase(pref[i - k] - (i - k));

		}
		if (freq.find(pref[i] - i) != freq.end()) ans += (freq[pref[i] - i]);
		if (freq.find(pref[i] - i + k) != freq.end())ans += (freq[pref[i] - i + k]);

		freq[pref[i] - i]++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 18792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1000000007;
char st[1005];
int p[1005][1005];
struct Node
{
    int a[3];
    Node operator *(const Node &b)const
    {
        return (Node){{1ll*a[0]*b.a[0]%mod,(1ll*a[0]*b.a[1]+1ll*a[1]*b.a[2])%mod,1ll*a[2]*b.a[2]%mod}};
    }
}f;
Node qpower(Node a,long long b)
{
    Node ans={{1,0,1}};
    for(;b;b>>=1,a=a*a)if(b&1)ans=ans*a;
    return ans;
}
int qpower(int a,long long b)
{
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=1ll*ans*a%mod;
    return ans;
}
int main()
{
//    freopen("data.txt","r",stdin);
    int H,W;long long K;
    scanf("%d%d%lld",&H,&W,&K);
    if(K==0){puts("1");return 0;}
    int n=0;
    for(int i=1;i<=H;i++)
    {
        scanf("%s",st+1);
        for(int j=1;j<=W;j++)
            p[i][j]=st[j]=='#',n+=p[i][j];
    }
    int n1=0,n2=0;
    for(int i=1;i<=H;i++)
        for(int j=1;j<W;j++)
            n1+=p[i][j]&&p[i][j+1];
    for(int i=1;i<H;i++)
        for(int j=1;j<=W;j++)
            n2+=p[i][j]&&p[i+1][j];
    int cnt1=0,cnt2=0;
    for(int i=1;i<=H;i++)cnt1+=p[i][1]&&p[i][W];
    for(int i=1;i<=W;i++)cnt2+=p[1][i]&&p[H][i];
    if(cnt1&&cnt2){cout<<1<<endl;return 0;}
    if(!cnt1&&!cnt2){cout<<qpower(n,K-1)<<endl;return 0;}
    if(cnt1)f.a[0]=n,f.a[1]=n1,f.a[2]=cnt1;
    else f.a[0]=n,f.a[1]=n2,f.a[2]=cnt2;
    cout<<((qpower(n,K-1)-qpower(f,K-1).a[1])%mod+mod)%mod<<endl;
}

Measured memory_bytes: 7672
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
void chmin(int &a, int b) { if (a > b) a = b; }
using namespace std;
using LL = long long int;
using ULL = unsigned long long;
const int INF = 1e9;
int N, A, B, C;
vector<int> L;
int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (not a or not b or not c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int res = rec(i + 1, a, b, c);

    chmin(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));
    return res;
}
int main() {
    cin >> N  >> A >> B >> C;
    L.resize(N);
    rep(i, N) {
        cin >> L[i];
    }

    cout << rec(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
A, B, H, M = gets.split.map(&:to_i)
 
h = H * 30 + M / 60.0 * 30
m = M * 6
degree = (h - m).abs
real_degree = [degree, 360 - degree].min
 
puts Math.sqrt(A**2 + B**2 - 2*A*B*Math.cos(real_degree.to_f * Math::PI / 180.0))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    ans += a-1;
  } 
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
double V = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	
	return;
}


int main(void) {
	int gakuseki = 0;
	double weight = 0;
	double height = 0;

	while (scanf("%d,%lf,%lf", &gakuseki, &weight, &height) != EOF) {
		if (weight / (height * height) >= 25.0) {
			CO gakuseki E
		}
	}

	
	



	return 0;
}

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

const int MAXK = 1e5 + 10;
const int MOD = 1e9 + 7;

int pref[MAXK],dp[MAXK],N,K;

int calc(int a,int b){
	if(a < 0) a = 0;
	int ans = pref[b];
	if(a != 0) ans -= pref[a-1];
	return ans % MOD;
}

int main(){

	cin >> N >> K;

	dp[0] = 1;

	for(int kid = 1;kid<=N;kid++){

		int c;
		cin >> c;

		pref[0] = dp[0];
		dp[0] = 0;
		for(int i = 1;i<=K;i++){
			pref[i] = (pref[i-1] + dp[i]) % MOD;
		}

		for(int i = 0;i<=K;i++){
			dp[i] = calc(i-c,i);
		}

	}

	int ans = dp[K];
	if(ans < 0) ans += MOD; 
	printf("%d\n",ans);

	return 0;

}


Measured memory_bytes: 4532
using System;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            if ((a + b) % 2 == 1) Console.WriteLine("IMPOSSIBLE");
            else Console.WriteLine((a + b) / 2);

        }
    }
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
void show(auto v) {
  for (auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector <int> C(N), D(N+1), M(N+1);
  for (int i = 0; i < N; i++) {
    int a; cin >> a; a--;
    C.at(a)++;
  }
  sort(C.begin(), C.end(), greater<int>());
  int prevVal = 0;
  for (int i = N-1; i >= 0; i--) {
    if (C.at(i) == prevVal) continue;
    for (int j = prevVal + 1; j <= C.at(i); j++) D.at(j) = i + 1;
    prevVal = C.at(i);
  }

  int s = 0;
  M.at(0) = N;
  for (int i = 1; i <= N; i++) {
    s += D.at(i);
    M.at(i) = s / i;
  }
  
  int i = N;
  int j = 1;
  while (i >= 0 && j <= N) {
    if (M.at(i) >= j) {
      cout << i << "\n";
      j++;
    }else {
      i--;
    }
  }

  return 0;
}



Measured memory_bytes: 4352
// MattG 1-21-2020 (2:47 AM)

#include <stdio.h>

#define MAX 200005

typedef unsigned long long ull;

ull max(ull a, ull b) {
    return a > b ? a : b;
}

ull min(ull a, ull b) {
    return a < b ? a : b;
}

int abs(int a) {
    return a >= 0 ? a : -a;
}

ull sqr(ull a) {
    return a * a;
}

typedef struct {
    int index;
    ull height;
} Entry;

ull get_overtake(ull *h, ull *dp, Entry old, int x) {  //maybe simplify to remove possible overflow???
    ull top = ( sqr(h[x]) - sqr(h[old.index]) + dp[x] - dp[old.index] );
    ull bottom = ( 2 * ( h[x] - h[old.index] ) );  
    return (top / bottom) + (top % bottom == 0 ? 0 : 1);
    // account for not divisible case
}

// return new min_end value
//    0 1 2 3 4 5 6 _   <- min_list
//      s         e     // check endpoint cases separately (or at least end)
// if we're on an index, we're considering whether to replace it or not

int binsert(int s, int e, ull *h, ull *dp, Entry *min_list, int new_index) {

    // how many left? implement todo? maybe unnecessary
    
    int m = (s + e) / 2;
    ull ot = get_overtake(h, dp, min_list[m-1], new_index);
    if (ot > min_list[m].height) {   // go right
        return binsert(m+1, e, h, dp, min_list, new_index);
    }
    else if (ot < min_list[m-1].height) { // "=" ?           // h[new_index]) {  // go left
        return binsert(s, m-1, h, dp, min_list, new_index);
    }
    else {
        min_list[m].index = new_index;
        min_list[m].height = ot;
        return m;
    }
}

int main() {
    int N;
    ull C;
    ull h[MAX];
    ull dp[MAX];
    Entry min_list[MAX];
    int min_start = 0;
    int min_end = 0;
    int src_index;
    ull start_check, end_check;

    dp[0] = 0;
    min_list[0].index = 0;
    min_list[0].height = -1;

    scanf("%d %llu", &N, &C);
    scanf("%llu", &h[0]);
    min_list[0].height = h[0];

    for (int i=1; i < N; i++) {
        scanf("%llu", &h[i]);
        // update min_start index (here or end?) // might be wrong be careful
        while (min_start < min_end && h[i] >= min_list[min_start+1].height) {
            min_start++;
        }

        src_index = min_list[min_start].index;
        dp[i] = dp[src_index] + sqr(h[i] - h[src_index]) + C;

        start_check = get_overtake(h, dp, min_list[min_start], i);
        if (start_check <= h[i]) {   // not min_list[min_start].height
            min_list[min_start].index = i;
            min_list[min_start].height = h[i];
            min_end = min_start;
            //printf("DID IMMEDIATE\n");
        }
        else {
            end_check = get_overtake(h, dp, min_list[min_end], i);
            if (end_check >= min_list[min_end].height) { //h[i]) {
                min_end++;
                min_list[min_end].index = i;
                min_list[min_end].height = end_check;
                //printf("DID END\n");
            }
            else {
                min_end = binsert(min_start+1, min_end, h, dp, min_list, i);
                //printf("DID RAND\n");
            }
        }
    }

    printf("%llu\n", dp[N-1]);
    return 0;
}


Measured memory_bytes: 6400
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return map(int, input().split())
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    mxy = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    h, w, K = LI()
    y1, x1, y2, x2 = LI()
    q = deque()
    field = [[False] * (w + 2)] + [None] * h + [[False] * (w + 2)]
    for i in range(1, h + 1):
        field[i] = [False] + [True] * w + [False]
    for i in range(1, h + 1):
        s = input().rstrip()
        for j in range(1, w + 1):
            if s[j-1] == "@":
                field[i][j] = False
    q.append((x1, y1))
    ans = 0
    c = [[0] * (w + 2) for i in range(h + 2)]
    while q:
        next_q = deque()
        while q:
            x, y = q.pop()
            if (x, y) == (x2, y2):
                print(ans)
                return
            if field[y][x]:
                for i in range(1, K + 1):
                    if field[y + i][x]:
                        if not c[y + i][x]:
                            next_q.append((x, y + i))
                            c[y + i][x] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y][x + i]:
                        if not c[y][x + i]:
                            next_q.append((x + i, y))
                            c[y][x + i] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y - i][x]:
                        if not c[y - i][x]:
                            next_q.append((x, y - i))
                            c[y - i][x] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y][x - i]:
                        if not c[y][x - i]:
                            next_q.append((x - i, y))
                            c[y][x - i] = 1
                    else:
                        break
                field[y][x] = False
        ans += 1
        q = next_q
    print(-1)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 129308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0033
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int result = int.MaxValue;

            for (int i = 0; i < s.Length - 2; i++)
            {
                var t = s.Substring(i, 3);

                var sa = Math.Abs(753 - int.Parse(t));

                if (sa <= result)
                {
                    result = sa;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27508
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
    int n;
    cin >> n;
    int x = (n*100)/108;
    for(int i = x-10;i <= x+10;++i)if((i*108)/100 == n){
        cout << i;
        return 0;
    }
    cout << ":(";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x;
    int n;
    int i;
    scanf("%d", &n);
    for(i = 1;i <= n;i++){
        if(i % 3 == 0){
            printf(" %d", i);
            continue;
        }
        x = i;
        do{
            if(x % 10 == 3){
                printf(" %d", i);
                break;
            }
        x /= 10;
        }while(x);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#define abs(X) ((X) < 0 ? -1 * (X) : (X))

int main()
{
    char s[16];
    int tmp;
    int ans = 100000;

    scanf("%s", s);

    for (int i = 0; i < strlen(s) - 2; i++) {
        tmp = (s[i] - '0') * 100 +
            (s[i + 1] - '0') * 10 +
            (s[i + 2] - '0');

        if (abs(753 - tmp) < ans) {
            ans = abs(753 - tmp);
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
N,A,B,C = map(int,input().split())
L = list(int(input()) for i in range(N))

def f(cur,a,b,c) :
    if cur == N :
        if min(a,b,c) > 0 :
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else :
            return float("inf")
    ret0 = f(cur+1,a,b,c)
    ret1 = f(cur+1,a+L[cur],b,c) + 10
    ret2 = f(cur+1,a,b+L[cur],c) + 10
    ret3 = f(cur+1,a,b,c+L[cur]) + 10
    return min(ret0,ret1,ret2,ret3)
    
print(f(0,0,0,0))


Measured memory_bytes: 3064
from bisect import bisect_left
from collections import Counter
import sys

def main():
    input = sys.stdin.readline
    N = int(input().rstrip())
    # Union-Find
    parent = list(range(N))
    rank = [1] * N
    def get_root(node):
      if parent[node] == node:
        return node
      root = get_root(parent[node])
      parent[node] = root
      return root
    
    def union(a, b):
      root_a = get_root(a)
      root_b = get_root(b)
      if root_a == root_b:
        return
      rank_a = rank[root_a]
      rank_b = rank[root_b]
      if rank_a < rank_b:
        parent[root_a] = root_b
      else:
        parent[root_b] = root_a
        if rank_a == rank_b:
          rank[root_a] += 1

    XYs = []
    XYs1 = []
    XYs2 = []
    for i in range(N):
        x, y = map(int, input().rstrip().split())
        XYs.append([x, y, i])
        XYs2.append([N-x, N-y, i])
    XYs1 = sorted(XYs)
    XYs2.sort()
    
    buf = []
    L = 0
    for x, y, k in XYs1:
        idx = bisect_left(buf, [-y, k])
        if idx == L:
            buf.append([-y, k])
        else:
            ny, nk = buf[-1]
            while L > idx:
                ty, tk = buf.pop()
                union(k, tk)
                L -= 1
            buf.append([ny, nk])
        L += 1
    
    buf = []
    L = 0
    for x, y, k in XYs2:
        idx = bisect_left(buf, [-y, k])
        if idx == L:
            buf.append([-y, k])
        else:
            ny, nk = buf[-1]
            while L > idx:
                ty, tk = buf.pop()
                union(k, tk)
                L -= 1
            buf.append([ny, nk])
        L += 1

    ct = Counter()
    for i in range(N):
        ct[get_root(i)] += 1
    
    for p in parent:
        print(ct[p])

main()


Measured memory_bytes: 141100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,f=0;
    string s;
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]=='7')f=1;
    }
    if(f)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			String buffer = sc.next();
			if (buffer.equals("0")) {
				break;
			}
			int p[] = new int[2];
			int v = 0;
			for (char ch : buffer.substring(1).toCharArray()) {
				v = ch - 'A';
				p[v]++;
			}
			if (p[0] > p[1]) {
				p[0]++;
			} else {
				p[1]++;
			}
			System.out.println(p[0] + " " + p[1]);
			buffer = sc.next();
			p = new int[2];
			for (char ch : buffer.substring(1).toCharArray()) {
				v = ch - 'A';
				p[v]++;
			}
			if (p[0] > p[1]) {
				p[0]++;
			} else {
				p[1]++;
			}

			System.out.println(p[0] + " " + p[1]);
			buffer = sc.next();
			p = new int[2];
			for (char ch : buffer.substring(1).toCharArray()) {
				v = ch - 'A';
				p[v]++;
			}
			if (p[0] > p[1]) {
				p[0]++;
			} else {
				p[1]++;
			}
			System.out.println(p[0] + " " + p[1]);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 11000
// Aizu 1154: Monday-Saturday Prime Factors
// 2017.9.13 bal4u@uu
// 2017.12.22

#include <stdio.h>

#define MAX 300000

char mk[MAX+2];
int tbl[35815], sz;

int main()
{
	int n, i, j;
	int *tp;
	
	for (i = 7; i <= MAX; i += 7) mk[i-1] = mk[i+1] = 1;
	for (i = 0; i <= MAX; i++) if (mk[i] && i <= 547) {		// 547 = sqrt(300000)
		for (j = i*i; j <= MAX; j+=i) mk[j] = 0;
	}

	sz = 0;
	for (i = 1; i <= MAX; i++) if (mk[i]) tbl[sz++] = i;
	tbl[sz] = 0x7ffffff;
	
	while (scanf("%d", &n) && n > 1) {
		printf("%d:", n);
		for (tp = tbl; *tp <= n; tp++) if (n % *tp == 0) printf(" %d", *tp);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2168
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, K;

    scanf("%zu %zu", &N, &K);

    if (K == 1) {
        puts("0");
    }
    else {
        printf("%zu\n", N - K);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//


int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    ll ans = 0LL;
    for(ll i=0; i<64; i++){
        ll one = 0LL;
        ll zero = 0LL;
        rep(j, n){
            if(v[j] >> i & 1){
                one++;
            }
            else{
                zero++;
            }
        }
        ll tmp = (one * zero);
        rep(j, i){
            tmp = tmp * 2 % MOD;
        }
        //cout << (one * zero) * tmp << endl;
        ans += tmp;
        ans %= MOD;
    }

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


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  ll n;
  cin>>n;
  vector<ll> v,v1,v2;
  for(i=0;i<n;i++){
    ll x;
    cin>>x;
    v.pb(x);
  }
  sort(v.begin(),v.end());
  
  if(v[0]>=0){
    v2.pb(v[0]);
    for(i=1;i<v.size();i++) v1.pb(v[i]);
  }
  else if(v[v.size()-1]<=0){
    v1.pb(v[v.size()-1]);
    for(i=0;i<v.size()-1;i++) v2.pb(v[i]);
  }

  else {
    for(i=0;i<n;i++){
      if(v[i]<0) v2.pb(v[i]);
      else v1.pb(v[i]);
    }
  }

  ll ans=0;
  for(i=0;i<v2.size();i++) ans-=v2[i];
  for(i=0;i<v1.size();i++) ans+=v1[i];
  cout<<ans<<endl;

    ll s=v2[0];
    for(i=0;i<v1.size()-1;i++){
      cout<<s<<" "<<v1[i]<<endl;
      s-=v1[i];
    }
    cout<<v1[v1.size()-1]<<" "<<s<<endl;
    s=v1[v1.size()-1]-s;

    for(i=1;i<v2.size();i++){
      cout<<s<<" "<<v2[i]<<endl;
      s-=v2[i];
  }


  return 0;
}

Measured memory_bytes: 4340