akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef struct _q{
  string name;
  int time;
}que;
int n;
int head=1,tail;
que qar[100003];
void enq(que q){
  if(tail<n+2)tail++;
  else tail = 2;
  //cout<<tail-1<<endl;
  qar[tail-1]=q;
}

que deq(){
  if(head<n+2)head++;
  else head = 2;
  return qar[head-1];
}

int main(){
  int q,i=0,cnt=0;
  cin>>n>>q;
  que localqar[100003],temp;
  for(i=1;i<n+1;i++)cin>>localqar[i].name>>localqar[i].time;
  for(i=1;i<n+1;i++)
    qar[i]=localqar[i];
  tail = n+1;
  while(tail!=head){
    temp=deq();
    //cout<<temp.name<<endl;
    if(temp.time>q){
      cnt+=q;
      temp.time-=q;
      //cout<<"finished"<<endl;

      enq(temp);	  
    }
    else{
      cnt+=temp.time;
      cout<<temp.name<<" "<<cnt<<endl;
    }
  }

  return 0;
}



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

using namespace std;

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

  long long n, m;
  cin >> n >> m;

  long long res; 
  if (n == 1 && m == 1) res = 1;
  else if (n == 1 && m > 1) res = m-2;
  else if (m == 1 && n > 1) res = n-2;
  else res = (n-2)*(m-2);
  cout << res << endl;

  return 0;
}



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

int main()
{
	while(1){
		int H,W;
		cin >>  H >> W;
		
		if(H==0&&W==0)break;
		
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}



void solve()
{
	int k,a,b;
	cin>>k>>a>>b;
	int val=a/k;
	int x=(val+1)*k;
	if(a%k==0 || x<=b || k==1)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    char c;
    cin >> c;
    int n = c - 'A';
    if(n <= 25) cout << 'A'<< endl;
    else cout << 'a' << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007


int n;
int x[10],y[10];

double dist(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

    int main(void){
    
    cin >> n;

    //順列計算時の調整のため、１からスタート
    for (int i = 1; i <= n; i++)
        cin >> x[i] >> y[i];

    double all_sum = 0.0;

    //順列の数字を入力
    vector<int> P_num(n);
    rep(i, n) P_num.at(i) = i + 1;

      do{
          //rep(i, n - 1)
           for (int i = 0; i < n - 1;i++) all_sum += dist(P_num[i], P_num[i + 1]);
    } while (next_permutation(P_num.begin(), P_num.end()));

    int factorial = 1;
    for (int i = 2; i <= n;i++)
        factorial *= i;

    double ans = all_sum /(double)factorial;
   
    printf("%.12lf\n",ans);
    return 0;
}


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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int in[3] = {};
	int out = 0;
	cin >> in[0] >> in[1] >> in[2];
	
	out = in[0];
	if (in[0] == in[1]) {
		out = in[2];
	} else if (in[0] == in[2]) {
		out = in[1];
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 888
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
K = int(input())

if int('1' * K) > N:
	print(0)
	sys.exit()

N = str(N)
L = len(N)

def C(a,b):
	out = 1
	for _ in range(b):
		out *= a
		a -= 1
	for bb in range(1,b+1):
		out //= bb
	return out 

def solve(N,n,K):
	if K == 0:
		return 1
	if int('1' * K) > int(N):
		return 0

	ans = 0
	#桁が小さい時
	for i in range(1,n):
		if K - 1 > i - 1:
			continue
		else:
			ans += 9 * C(i-1, K-1) * (9 ** (K-1))
	
	#桁が同じで、先頭が小さい時
	head = int(N[0])
	ans += (head - 1) * C(n-1, K-1) * (9 ** (K-1))

	#桁が同じで先頭も一緒
	sh_N = ''
	for i in range(1,n):
		if N[i] != '0':
			sh_N = N[i:]
			break
	
	if sh_N != '':
		sh_n = len(sh_N)
		ans += solve(sh_N, sh_n, K-1)
	else:
		if K == 1:
			ans += 1

	return ans

answer = solve(N,L,K)

print(answer)
		

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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($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();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($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 xs: Vec<u64> = sc.vec(n);
    let s: u64 = xs.iter().sum();
    let mut ans = if s % 10 == 0 { 0 } else { s };
    for x in xs {
        if (s - x) % 10 != 0 && ans < s - x {
            ans = s - x;
        }
    }
    put!(ans);
}

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()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> V(N+1,0);
  
  for(int i=2;i<=N;i++){
    int a;
    cin >> a;
    V[a]++;
  }
  
  for(int i=1;i<=N;i++) cout << V[i] << endl;
  return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> q;
  q.push_back(0);
  for (int i = 0; i < 2; i++) {
    vector<int> nq;
    for (int v: q) {
      for (int u: G[v]) {
        nq.push_back(u);
      }
    }
    q.swap(nq);
  }
  bool res = false;
  for (int v: q) {
    if (v == N - 1) {
      res = true;
      break;
    }
  }
  cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 13168
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i=0;i<n;i++)
#define llint long long int

using namespace std;

int main() {
	int a;
	cin >> a;
	if (a % 2 == 0) {
		cout << a / 2 - 1 << endl;
	}
	else {
		cout << a / 2 << endl;
	}
	return 0;
}

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

int main()
{
    long long int n;cin>>n;
    long long int arr[n],sum=0,
    flag[100001]={0};
    for(int i=0;i<n;i++){
    cin>>arr[i];
    sum=sum+arr[i];
    flag[arr[i]]++;
    }
    long long int q;cin>>q;
    while(q--){
    int l,r;
    cin>>l>>r;
    sum=sum-l*flag[l]+r*flag[l];
    flag[r]=flag[r]+flag[l];
    flag[l]=0;
    
    cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;
#define lol long long

int main()
{
	int N, M;
	cin >> N >> M;
	int S = 1900 * M + 100 * (N - M);
	int ans = pow(2, M) * S;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> a,p;

ll solve(ll n, ll x){
    if(n == 0) return 1;
    else if(x == 1) return 0;
    else if(x > 1 && x <= a[n-1]+1) return solve(n-1,x-1);
    else if(x == a[n-1] + 2) return p[n-1] + 1;
    else if(x > a[n-1] + 2 && x < 2*a[n-1] + 3) return 1 + p[n-1] + solve(n-1,x-2-a[n-1]);
    else return 2*p[n-1]+1;
}

int main() {

    ll n,x; cin >> n >> x;
    a.push_back(1);
    p.push_back(1);

    rep(i,55){
        a.push_back(2*a[i]+3);
        p.push_back(2*p[i]+1);
    }


    cout << solve(n,x);

}

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

int main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	int cop=n;
	rep(i,cop){
		if(n<k){
			ans++;
			break;
		}else {
			n=n/k;
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

int k;
int cost(int a[], int dp[], int n, int i)
{
	if(i > n-1)
		return 100000;
	// if(i == n-1)
	// 	return 0;
	if(dp[i] >= 0 )
		return dp[i];
	else
	{
		int k1 = abs(a[i+1] - a[i]) + cost(a, dp, n, i+1);
		for (int j = 1; j < k; ++j)
		 {
		 	k1 = min(k1, abs(a[i+j+1] - a[i]) + cost(a, dp, n, i+j+1));
		 } 
		// int k2 = abs(a[i+2] - a[i]) + cost(a, dp, n, i+2);
		dp[i] = k1;
		return dp[i]; 
	}
}

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

	cin >> n >> k;

	int a[n+2] = {};
	int dp[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		dp[i] = -1;	
	}

	dp[n-1] = 0;	
	// int l = cost(a, dp, n, 0);
	dp[1] = abs(a[1] - a[0]);
	dp[0] = 0;

	int k1, k2;
	for (int i = 2; i < n; ++i)
	{
		k1 = dp[i-1] + abs(a[i] - a[i-1]);
		for (int j = 1; j < k; ++j)
		{	
			if(i-j >= 1)
				k1 = min(k1, dp[i-j-1] + abs(a[i] - a[i-j-1]));
			else
				break;
		}
		dp[i] = k1; 
	}

	cout << dp[n-1]; 

	// cout << l;
	return 0;
}


Measured memory_bytes: 1024
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents =[-1 for i in range(n)]
    # どのグループに属しているかを返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]


N, M = map(int, input().split())
uf = UnionFind(N)
X = [[] for _ in range(M)]
for i in range(M):
    X[i] = list(map(int, input().split()))
    uf.unite(X[i][0]-1, X[i][1]-1)
print(-min(uf.parents))

Measured memory_bytes: 49876
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

typedef long long ll;

ll dp[100001][13];
string S;

const ll MOD = 1000000007;

int main() {
	cin >> S;
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 13; j++) {
			dp[i][j] %= MOD;
			if (S[i] != '?') {
				dp[i + 1][(j * 10 + (S[i] - '0')) % 13] += dp[i][j];
			}
			else {
				for (int k = 0; k <= 9; k++) {
					dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
				}
			}

		}
	}
	cout << dp[S.size()][5] % MOD << endl;
	return 0;
}

Measured memory_bytes: 10624
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

// #[cfg_attr(cargo_equip, cargo_equip::equip)]
// use ::__kyopro_lib::{};

fn main() {
    input! {
        n: u64,
        x: usize,
        m: usize,
    }

    let mx_k = 50;
    // (next, sum)
    let mut t = vec![vec![(0, 0); mx_k]; m];

    for i in 0..m {
        t[i][0] = (i * i % m, i);
    }
    for k in 0..mx_k - 1 {
        for i in 0..m {
            let x = t[i][k];
            let y = t[x.0][k];
            t[i][k + 1] = (y.0, y.1 + x.1);
        }
    }

    // println!("{:?}", t);

    let mut res = 0;
    let mut x = x;
    for k in 0..mx_k {
        if n >> k & 1 == 1 {
            res += t[x][k].1 as u64;
            x = t[x][k].0;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 84144
l = [int(input()) for i in range(5)]
m = []
flag = l[0]%10
cnt = 0
for i in range(1,5):
    if l[i]%10 < flag and l[i]%10 != 0:
        cnt = i
for i in range(5):
    if i == cnt or l[i]%10 == 0:
        m.append(l[i])
    else:
        m.append(l[i]+(10-(l[i]%10)))
print(sum(m))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#include <map>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
int main(){
  int A[100005],B[100005],C[100005];
  map<int,int> d;
  int N;
  cin >> N;
  rep(i,N)cin >> A[i];
  rep(i,N){
    B[i] = A[i];
    d[A[i]]=i%2;   
  }
  sort(B,B+N);
  int cnt = 0;
  rep(i,N){
    if(i%2!=d[B[i]])cnt++;
  }
  cout << cnt/2 << endl;
  
}

Measured memory_bytes: 5760
n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[]
c=[]
d=[0]*(10**5+1)
for i in range(n):
    d[a[i]]+=1
ans=sum(a)
cnt=0
for i in range(q):
    b,c=map(int,input().split())
    ans+=(d[b]*(c-b))
    d[c]+=d[b]
    d[b]=0
    print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  string s; cin >> s;
  int n = s.size();
  map<int, int> mp;
  mp[0] = mp[1] = 0;
  rep(i, n) {
    ++mp[s[i]-'0'];
  }
  cout << 2*min(mp[0], mp[1]) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int n,k;
  cin>>n>>k;
  int a[n],id;
  r(i,n){
    cin>>a[i];
    if(a[i]==1)id=i;
  }
  int ans=1e9;
  for(int i=id-(k-1);i<id+k;i++){
    int l=i,r=i+(k-1),c=1;
    if(0<l){
      c+=(l-1)/(k-1);c++;
    }
    if(r<n-1){
      c+=(n-1-r-1)/(k-1);c++;
    }
    //cout<<l<<' '<<r<<' '<<i<<' '<<c<<endl;
    ans=min(ans,c);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    string s;
    cin>>s;
    int sum=0;
    rep(i,s.size()) sum+=s[i]-'0';
    if(sum%9==0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    if(N % 1000==0) cout << 0 << endl;
    else 
        cout << ((N / 1000) + 1)*1000 - N  << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>

int main()
{
    std::string figure[] = {
        "1100000011",
        "1000000010000000100000001",
        "1111",
        "1000000110000001",
        "11000000011",
        "100000001100000001",
        "110000011"
    };

    while (!std::cin.eof()) {
        std::string s = "", tmp;
        for (int i = 0; i < 9; ++i) {
            getline(std::cin, tmp);
            s += tmp;
        }

        for (int i = 0; i < 7; ++i) {
            if (s.find(figure[i]) != std::string::npos) {
                std::cout << static_cast<char>(i + 'A') << std::endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int flag1(int dp[],int n,int arr[],int i){
    if(i==n-1){
        dp[i]=0;
        // return 0;
    }
    else if(i==n-2){

        dp[i]=abs(arr[n-1]-arr[n-2]);

    }
    else
    {
        dp[i]=min(abs(arr[i+1]-arr[i])+flag1(dp,n,arr,i+1),abs(arr[i+2]-arr[i])+flag1(dp,n,arr,i+2));
    }
    return dp[i];
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int dp[n];
    for (int i = n - 1; i >= 0; i--)
    {
        if (i == n - 1)
        {
            dp[i] = 0;
        }
        else if (i == n - 2)
        {
            dp[i] = abs(a[n -1] - a[n - 2]);
        }
        else
        {
            dp[i] = min(dp[i+1]+abs(a[i+1]-a[i]),dp[i+2]+abs(a[i+2]-a[i]));

        }
    
    }
    //cout<<flag1(dp,n,a,0);
    cout<<dp[0];
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[0]=='A'){
                if(s[i] =='C'){
                    cnt++;
                }
            }
    }
    if(cnt != 1){
        cout<<"WA"<<endl; 
        return 0;
    }
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] >= 'A' && s[i] <= 'Z')ans++;
    }
    if(ans != 2)cout<<"WA"<<endl;
    else cout<<"AC"<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c||a==c&&a!=b||b==c&&b!=a){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll n,m,k,ans=0,tmp=1;
ll power(ll a,ll b) {return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main()
{
    cin>>n>>m>>k;
    for(ll i=0;i<=k;i++){
        ans=(ans+(tmp*m%mod)*power(m-1,n-i-1))%mod;
        tmp=tmp*(n-i-1)%mod*power(i+1,mod-2)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3612
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    res = 1
    res += ((len(a)-k) + (k-1) - 1)// (k-1)
    print(res)

if __name__ == '__main__':
    main()


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

int main(){
	int N,W;
	int v[101],w[101];
	cin>>N>>W;
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	int DP[N+1][W+1];
	for(int j=0;j<=W;j++)
		DP[0][j]=0;

	for(int i=1;i<=N;i++)
		for(int j=0;j<=W;j++)
			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
			}
		cout<<DP[N][W]<<endl;

		return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int h,w,k;
    cin >> h >> w >> k;
    Mint<> dp[h + 1][w];
    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int k = 0; k < 1 << (w - 1); k++){
                bool valid = true;
                for(int l = 0; l < w - 2; l++){
                    if((k >> l) & 1 && (k >> (l + 1)) & 1) valid = false;
                }
                if(!valid) continue;
                if(j < w - 1 && (k >> j) & 1) dp[i + 1][j] += dp[i][j + 1];
                else if(j > 0 && (k >> (j - 1)) & 1) dp[i + 1][j] += dp[i][j - 1];
                else dp[i + 1][j] += dp[i][j];
            }
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}

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

using namespace std;
int k, n;
int res[1080000];
int main(){
	cin >> k >> n;
	int N = n;
	if(k % 2 == 0){
		cout << k / 2;
		for(int i = 0;i < n - 1;i++)cout << " " << k;
		cout << endl;
		return 0;
	}
	if(k == 1){
	for(int i = 0;i < (n+1)/2;i++)cout << 1 << " " ;
cout << endl;
return 0;
}
	

	for(int i = 0;i < n;i++)res[i] = k/2+1;
	n/=2;
	while(n--){
		int j = 0;
		while(res[j] == 0)j++;
		res[j]--;
		if(res[j] != 0)
			for(int i = 0;i < j;i++)res[i] = k;
		
	}
	for(int i = N-1;i >= 0;i--){
		if(res[i] == 0)break;
		cout << res[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll mod(ll x, ll m) {
  if (x < 0) {
    return (m - ((-x) % m)) % m;
  } else {
    return x % m;
  }
}

int main()
{
  ll n,x,d;
  cin>>n>>x>>d;
  if (d == 0) {
    if (x == 0) {
      cout<<1<<endl;
      return 0;
    } else {
      cout<<n+1<<endl;
      return 0;
    }
  }
  if (x == 0) {
    cout<<n*(n-1)/2+1<<endl;
    return 0;
  }
  if (d < 0) {
    d = -d;
    x = -x;
  }
  map<ll,vector<tuple<ll,ll>>> vvt;
  for(auto&& i:irange(0l,n+1)) {
    ll offset = i*x;
    ll ro = mod(offset, d);
    ll qo = (offset - ro) / d;
    ll mn = i*(i-1)/2 + qo;
    ll mx = n*(n-1)/2 - (n-i)*(n-i-1)/2 + qo;
    vvt[ro].emplace_back(mn, 1);
    vvt[ro].emplace_back(mx+1, -1);
  }
  ll cnt = 0;
  for(auto&& vt:vvt) {
    boost::sort(vt.second);
    ll old = -1e15;
    ll c = 0;
    for(auto&& t:vt.second) {
      ll y, p;
      tie(y,p) = t;
      if (p > 0 && c == 0) {
        old = y;
      } else if (p < 0 && c == 1) {
        cnt += y - old;
      }
      c += p;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 25216
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string A[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while(cin >> S) {
        int N = sz(S);
        vector<int> can(N + 1);
        can[0] = 1;
        rep(i, N)if(can[i]) {
            for(string &t : A) {
                if(i + sz(t) <= N && t == S.substr(i, sz(t))) {
                    can[i + sz(t)] = 1;
                }
            }
        }
        cout << (can[N] ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 848
import numpy as np
import sys
n,m=map(int,input().split())
a= [list(input()) for i in range(n)] 
b= [list(input()) for i in range(m)] 
na=np.array(a)

sa=n-m+1

for x in range(sa):
    for y in range(sa):

        if na[x:x+m,y:y+m].tolist()==b:
            print("Yes")
            sys.exit()
print("No")

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

char s3[8];
char sub4(int d)//数値を文字に変換
{
	if(d==2)return '2';
	if(d==3)return '3';
	if(d==4)return '4';
	if(d==5)return '5';
	if(d==6)return '6';
	if(d==7)return '7';
	if(d==8)return '8';
	if(d==9)return '9';
}
void sub3(int c)
{
	int cnt=0;
	
	memset(s3,'\0',sizeof(s3));//文字列の中身を空にする
	if(c>=1000){
		if(c>=2000)s3[cnt++]=sub4(c/1000);
		s3[cnt++]='m';
		c=c%1000;
	}
	if(c>=100){
		if(c>=200)s3[cnt++]=sub4(c/100);
		s3[cnt++]='c';
		c=c%100;
	}
	if(c>=10){
		if(c>=20)s3[cnt++]=sub4(c/10);
		s3[cnt++]='x';
		c=c%10;
	}
	if(c>=1){
		if(c>=2)s3[cnt++]=sub4(c/1);
		s3[cnt++]='i';
	}
}
int sub2(char s)//文字を数値に変換
{
	if(s=='2')return 2;
	if(s=='3')return 3;
	if(s=='4')return 4;
	if(s=='5')return 5;
	if(s=='6')return 6;
	if(s=='7')return 7;
	if(s=='8')return 8;
	if(s=='9')return 9;
}
int sub1(char str[])//MCXI文字列をMCXI値に変換
{
	int i;
	int n=0;
	int len=strlen(str);
	
	for(i=0;i<len;i++){
		if(str[i]=='m'){
			if(i!=0)n+=sub2(str[i-1])*1000;
			else n+=1000;
		}
		if(str[i]=='c'){
			if(i!=0&&str[i-1]!='m')
				n+=sub2(str[i-1])*100;
			else n+=100;
		}
		if(str[i]=='x'){
			if(i!=0&&str[i-1]!='m'&&str[i-1]!='c')
				n+=sub2(str[i-1])*10;
			else n+=10;
		}
		if(str[i]=='i'){
			if(i!=0&&str[i-1]!='m'&&str[i-1]!='c'&&str[i-1]!='x')
				n+=sub2(str[i-1])*1;
			else n+=1;
		}
	}
	return n;
}
int main(void)
{
	int num;
	int a,b;
	char s1[500],s2[500];
	
	scanf("%d",&num);
	while(num--){
		scanf("%s%s",s1,s2);
		a=sub1(s1);//1つ目のMCXI文字列をMCXI値に変換
		b=sub1(s2);//2つ目のMCXI文字列をMCXI値に変換
		sub3(a+b);
		printf("%s\n",s3);
	}
		return 0;
}


Measured memory_bytes: 2572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    multiset<ll> L,R;
    ll count=0;
    ll sumL=0,sumR=0;
    ll c=0;
    for(ll i=0;i<Q;++i){
        ll t;
        cin >> t;
        if(t==1){
            ll a;
            cin >> a;
            ll b;
            cin >> b;
            c+=b;
            L.insert(a);
            sumL+=a;
            auto y=prev(L.end());
            R.insert(*y);sumR+=*y;
            sumL-=*y;L.erase(y);
            count++;
            if(count%2){
                auto x=R.begin();
                L.insert(*x);sumL+=*x;
                sumR-=*x;R.erase(x);
            }

        }
        else {
            ll t=(count+1)/2;
            ll s=count-t;
            ll mark=*(prev(L.end()));
            cout<<mark<<" "<<llabs(sumL-t*mark)+llabs(sumR-s*mark)+c<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& os, const ModInt<MOD>& mi) { return os << mi.get(); }
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb() {fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1);
        for (int i = 1; i < FAC_MAX; i++) fac[i] = fac[i - 1] * i;
        for (int i = 1; i < FAC_MAX; i++) ifac[i] = T(1) / fac[i];}
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }
    T fact(int n) { if (n < 0) return T(0); return fac[n]; }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------


int main() {
    Comb<mint, 100001> com;
    int N, M;
    cin >> N >> M;

    mint ans = 0;

    if (M == N) ans = com.fact(N) * com.fact(M) * 2;
    else if (abs(N - M) == 1) ans = com.aPb(N, N) * com.aPb(M, M);
    else ans = 0;

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>



ll n, ans = INF;
int main() {
	cin >> n;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
	}
	REP(i, n + 1) {
		ll a1 = 0, a2 = 0;
		REP(j, n) {
			if(j < i)a1 += s[j];
			else a2 += s[j];
		}
		//cout << a1 << " " << a2 << " " << i << endl;
		ans = min(ans, abs(a1 - a2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from operator import itemgetter
N=int(input())
a=[]
for i in range(N):
  p,q=input().split()
  s=int(q)
  P=[p,-s,i+1]
  a.append(P)
A=sorted(a)
      
for n in range(N):
  print(A[n][2])
  

Measured memory_bytes: 3060
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

// clang-format on

main {
  str a, b, c;
  cin >> a >> b >> c;
  cout << ((a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) ? "YES" : "NO")
       << endl;
  bye;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
#define MAX 300001
bool prime[MAX];

void hurui(){
  REP(i,MAX) prime[i] = (i%7==1 || i%7==6) ? true : false;
  for(int i=6; i*i<MAX; ++i){
    if(prime[i]){
      for(int j=i*i; j<MAX; j+=i) prime[j] = false;
    }
  }
}
int main(){
  hurui();
  int n;
  while(cin>>n, n!=1){
    cout<<n<<":";
    for(int i=2; i<=n; ++i){
      if(prime[i] && n%i==0) cout<<" "<<i;
    }
    cout<<endl;
  }
  return 0;
}

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

#define _debug(fmt, ...) fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__)
#define rep(i, n) for (int i=0; i<(n); i++)
#define Rep(i, n) for (int i=1; i<=(n); i++)
#define range(x) (x).begin(), (x).end()
typedef long long LL;
typedef unsigned long long ULL;

vector<int> val;
int n;
int main() {
  cin >> n;
  val.push_back(0);
  rep (i, n) {
    int x;  cin >> x;
    val.push_back(x);
  }
  val.push_back(0);
  int tot = 0;
  for (int i=0; i<=n; i++) 
    tot += abs(val[i] - val[i+1]);
  for (int i=1; i<=n; i++) {
    int ans = tot;
    ans -= abs(val[i-1] - val[i]) + abs(val[i] - val[i+1]);
    ans += abs(val[i+1] - val[i-1]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);


int main(void){
  int a,b,gcd=1;
  cin>>a>>b;
  if(b>a)swap(b,a);
  while(1){
    gcd = b;
    b = a%b;
    a = gcd;
    if(b==0)break;
  }
  cout<<a<<endl;

  return 0;
}



Measured memory_bytes: 3116
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n,k;
     cin>>n>>k;
     vector<lld> dp(k+1,0),v(n);
     rep(i,0,n-1)
     {
         cin>>v[i];
     }
     sort(all(v));
     rep(i,v[0],k)
     {
         int fou=0;
         rep(j,0,n-1)
         {
             if((i>=v[j])&&(dp[i-v[j]]==0))
             {
                 fou=1;
             }
         }
         if(fou)
            dp[i]=1;
     }
     if(dp[k])
        cout<<"First"<<endl;
     else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
multiset<long long>L;
multiset<long long>R;
int p[110000];
int q[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
	}
	long long lx=0;
	long long rx=0;
	long long ret=0;
	L.insert(p[0]);
	R.insert(p[0]);
	for(int i=1;i<a;i++){
		lx-=q[i]-p[i];
		rx+=q[i-1]-p[i-1];
		long long ll=*(L.rbegin());
		long long rr=*(R.begin());
		ll+=lx;
		rr+=rx;
		if(ll<=p[i]&&p[i]<=rr){
			L.insert(p[i]-lx);
			R.insert(p[i]-rx);
		}else if(rr<p[i]){
			R.insert(p[i]-rx);
			R.insert(p[i]-rx);
			long long val=*(R.begin())+rx;
			ret+=p[i]-val;
			R.erase(R.begin());
			L.insert(val-lx);
		}else{
			L.insert(p[i]-lx);
			L.insert(p[i]-lx);
			long long val=*(L.rbegin())+lx;
			ret+=val-p[i];
			L.erase(--(L.end()));
			R.insert(val-rx);
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 10368
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[]) {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;

  long double angle_a = (H * 60.0 + M) / (12.0 * 60.0);
  long double angle_b = M / 60.0;

  long double ret = 0;
  if (angle_a != angle_b) {
    long double diff = abs(angle_a - angle_b);
    if (diff > 0.5)
      diff = 1.0 - diff;
    else if (diff == 0.5) {
      cout << A + B << endl;
      return 0;
    }
    if (A > B) {
      long double a = B * sin(2 * diff * 3.14159265358979);
      long double b = B * cos(2 * diff * 3.14159265358979);
      ret = sqrt(pow((A - b), 2) + pow(a, 2));
    } else {
      long double a = A * sin(2 * diff * 3.14159265358979);
      long double b = A * cos(2 * diff * 3.14159265358979);
      ret = sqrt(pow((B - b), 2) + pow(a, 2));
    }
  } else {
    ret = abs(A - B);
  }

  cout << fixed << setprecision(15) << ret << endl;

  return 0;
}

Measured memory_bytes: 4168
#include <iostream>
using namespace std;
 
const int INF = 1000000000;
 
int main()
{
    while(true){
        int n, m;
        cin >> n >> m;
 
        if(n==0 && m==0)
            break;
 
        int C[100][100];
        int T[100][100];
        for(int i=0; i<m; i++){
            for(int j=0; j<m; j++){
                if(i==j){
                    C[i][j] = T[i][j] = 0;
                }
                else{
                    C[i][j] = T[i][j] = INF;
                }
            }
        }
 
        for(int i=0; i<n; i++){
            int a, b, c, t;
            cin >> a >> b >> c >> t;
 
            C[a-1][b-1] = C[b-1][a-1] = c;
            T[a-1][b-1] = T[b-1][a-1] = t;
        }
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(C[i][j] > C[i][k]+C[k][j])
            C[i][j] = C[i][k] + C[k][j];
          if(T[i][j] > T[i][k]+T[k][j])
            T[i][j] = T[i][k] + T[k][j];
        }
      }
    }
    unsigned int k;
    cin >> k;
    for(int i=0;i<k;i++){
      int p,q,r;
      cin >> p >> q;
 
      cin >> r;
 
      if(r==0){
        cout << C[p-1][q-1] << endl;
      } else {
        cout << T[p-1][q-1] << endl;
      }
    }
  }
 
    return 0;
}


Measured memory_bytes: 3144
N=int(input())
A=list(map(int,input().split()))

chk = A[0]

i = 1




while i < N:
    chk = chk * A[i]
    if chk > 1000000000000000000:
        chk = -1
        break
    i+=1

i = 0
while i < N:
    if A[i] == 0:
        chk = 0
    i+=1

print(chk)


Measured memory_bytes: 21656
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//141
//141222 ×
//1414222
//22222

int main() {

	int n; cin >> n;
	vector<int> a(n);

	map<int, int> m;

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

		if (a[i] % 4 == 0) {
			m[4]++;
		}
		else if (a[i] % 2 == 0) {
			m[2]++;
		}
		else {
			m[1]++;
		}
	}

	if (m[1] == 0) {
		cout << "Yes" << endl;
		return 0;
	}


	if (m[4] >= m[1]) {
		cout << "Yes" << endl;
	}
	else if (m[1]== m[4]+1) {
		if (m[2] == 0) {
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

	
	
	

	return 0;
}

Measured memory_bytes: 640