akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;

int GCD(int a, int b){
	return b == 0 ? a : GCD(b, a % b);
}

int a[2010];
int gcd[2010][2010];
vector <int> from[40010];
int ans[2010];
int c[40010], in_ans[2010], minj[2010], last[2010], best[2010];
int C, n;

void dfs(int x){
	c[x] = C;
	for (int i = 0; i < from[x].size(); i++){
		int v = from[x][i];
		if (c[v] != -1 || v < n && in_ans[v]) continue;
		dfs(v);
	}
}

void color(){
	C = 0;
	memset(c, -1, sizeof(c));
	for (int i = 0; i < n; i++){
		if (c[i] != -1 || in_ans[i]) continue;
		dfs(i), C++;
	}
}

map <int, int> mp;
int m;

int id(int x){
	if (!mp.count(x)){
		m++, mp[x] = m - 1;
		return m - 1;
	}
	return mp[x];
}

int main(){
	scanf("%d", &n);
	m = n;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		int t = a[i];
		for (int j = 2; j * j <= t; j++){
			if (t % j == 0){
				from[id(j)].push_back(i);
				from[i].push_back(id(j));
				while (t % j == 0) t /= j;
			}
		}
		if (t != 1){
			from[i].push_back(id(t));
			from[id(t)].push_back(i);
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			gcd[i][j] = GCD(a[i], a[j]) != 1;
		}
	}
	for (int i = 0; i <= n; i++){
		minj[i] = INF, last[i] = -1;
	}
	int tot = 0;
	while (tot != n){
		color();
		for (int i = 0; i < C; i++){
			best[i] = -1;
		}
		for (int i = 0; i < n; i++){
			if (in_ans[i]) continue;
			if (minj[last[i] + 1] < a[i]) continue;
//			cout << i << " ";
			if (best[c[i]] == -1 || a[best[c[i]]] > a[i]) best[c[i]] = i;
		}
		int id = -1;
		for (int i = 0; i < C; i++){
			if (best[i] == -1) continue;
			if (id == -1 || a[id] < a[best[i]]) id = best[i];
		}
		if (id == -1) throw;
		in_ans[id] = 1, ans[tot++] = a[id];
		for (int i = 0; i < tot; i++){
			minj[i] = min(minj[i], a[id]);
		}
		for (int i = 0; i < n; i++){
			if (gcd[id][i]) last[i] = tot - 1;
		}
	}
	for (int i = 0; i < n; i++){
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
set < ll> primes;
 
int n,m;

bool isvalid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}
int dx[]={0,0,1,-1,-1,1,1,-1};
int dy[]={1,-1,0,0,-1,1,-1,1};
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

void solve()
{
    
    char c;
    cin>>c;
    if(c>='A' and c<='Z')cout<<"A";
    else cout<<"a";
   
    
}
 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
  //  cin>>t;
    while(t--)solve();
    
   
}

Measured memory_bytes: 3656
import math
def main():
  A,B,H,M = map(int, input().split())
  H_DO=(H*60+M)*360/(12*60)
  M_DO=M*6
  if(H_DO>M_DO):
    sabu=H_DO-M_DO
  elif(H_DO<M_DO):
    sabu=M_DO-H_DO
  else:
    sabu=0
  L=(A*A)+(B*B)-2*A*B*math.cos(math.radians(sabu))
  C=math.sqrt(L)
  print(C)
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 62484
moto = input()
num = int(input())

for i in range(num):
    order = input().split()
    if order[0] == "print":
        m,n=int(order[1]),int(order[2])
        print(moto[m:n+1])
    elif order[0] == "reverse":
        m,n=int(order[1]),int(order[2])
        moto = moto[:m]+moto[m:n+1][::-1]+moto[n+1:]
    elif order[0] == "replace":
        m,n,l=int(order[1]),int(order[2]),order[3]
        moto = moto[:m]+order[3]+moto[n+1:]

Measured memory_bytes: 7704
n = int(input())
act = []
dp = [[0]*3 for i in range(n)]
for _ in range(n):
  a,b,c = map(int,input().split())
  act.append([a,b,c])
a,b,c = act[0]
dp[0][0],dp[0][1],dp[0][2] = a,b,c
for i in range(1,n):
  dp[i][0] = max(dp[i-1][1]+act[i][0], dp[i-1][2]+act[i][0])
  dp[i][1] = max(dp[i-1][0]+act[i][1], dp[i-1][2]+act[i][1])
  dp[i][2] = max(dp[i-1][0]+act[i][2], dp[i-1][1]+act[i][2])
print(max(dp[-1][0], dp[-1][1], dp[-1][2]))

Measured memory_bytes: 48572
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(i*10000+j*5000+1000*(n-i-j) == m){
	cout<<i<<" "<<j<<" "<<n-i-j<<endl;
	return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for index, i in enumerate(a):
  ans += b[i-1]
  if(index > 0 and a[index] - a[index - 1] == 1):
    ans += c[i - 2]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<complex>
using namespace std;

long long gcd(long long a, long long b){
    return b != 0 ? gcd(b, a%b) : a;
}
int main(){
  long long n, x;
  cin >> n >> x;
  vector<long long> dx(n);
  for(long long i=0; i < n; i++){
      long long v;
      cin >> v;
      dx[i] = abs(x - v);
  }
  long long ans = dx[0];
  for(long long i=1; i < n; i++){
      ans = gcd(ans, dx[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        m: usize,
        x: u32,
        a: [u32;m]
    }
    let l = a.iter().fold(0,|acc,p| if p < &x {acc+1} else {acc});
    let r = a.iter().fold(0,|acc,p| if p > &x {acc+1} else {acc});
    println!("{}", std::cmp::min(l,r));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <bitset>

using namespace std;

const int M = 2005;
int a[M];

const int N = 4000005;
bitset < N > b;

int main(){
    int n;
    scanf("%d",&n);
    
    int s = 0;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        s += a[i];
    }
    
    b[0] = 1;
    for(int i=0;i<n;i++){
        b = b | b<<a[i];
    }
    
    int ans = 0;
    
    for(int i=s/2+s%2;i<N;i++){
        if(b[i] == 1){
            ans = i;
            break;
        }
    }
    
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


VLL fact_inv, fact;

ll pow(int a, ll b, ll m){
    if(!b) return 1;
    if(!(b % 2)){
        ll d = pow(a, b/2, m);
        return (d * d) % m;
    }
    else return (a * pow(a, b-1, m)) % m;
}

ll pow(int a, ll b) {
    return pow(a, b, MOD);
}

ll inv(int a, ll m){ // GCD(a, m) = 1
    return pow(a, m-2);
}

ll inv(int a){
    return inv(a, MOD);
}

ll comb(int a, int b, ll m){
    if(a < b) return 0;
    if(a < 0 || b < 0) return 0;
    ll ret = fact[a];
    ret = ret * fact_inv[b] % m;
    ret = ret * fact_inv[a-b] % m;
    return ret;
}

ll comb(int a, int b){
    return comb(a, b, MOD);
}

void precom(int n, ll m){
    fact.resize(n);
    fact_inv.resize(n);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for(int i = 2; i < n; ++i) fact[i] = fact[i-1] * i % m;
    for(int i = 2; i < n; ++i) fact_inv[i] = inv(fact[i]);
    return;
}

void precom(int n){
    precom(n, MOD);
    return;
}


int main(){
    int n; cin >> n;
    precom(n+10);
    int dif;

    VI idx(n, 0);
    REP(i, n+1){
        int a; cin >> a;
        if(idx[a-1] == 0) idx[a-1] = i+1;
        else dif = i+1 - idx[a-1];
    }
    REP(i, n+1){
        ll ans = comb(n+1, i+1) - comb(n-dif, i);
        cout << (ans<0 ? ans + MOD : ans) << "\n";
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        int ans=100;
        rep(i,n)
        {
                int a; cin>>a;
                int cnt=0;
                while(a%2==0)
                {
                        a/=2;
                        cnt++;
                }
                ans=min(ans,cnt);
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 256
#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 <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <memory>

using namespace std;

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

	vector<int> poses;

	for (int i = 0; i < N; i++) {
		int pos = 0;
		cin >> pos;
		poses.emplace_back(pos);
	}

	poses.emplace_back(0);

	int prev = poses[0];
	std::vector<unsigned long long> s(poses.size(), abs(0 - poses[0]));

	for (int i = 1; i < poses.size(); ++i) {
		s[i] = s[i - 1] + abs(poses[i] - prev);
		prev = poses[i];
	}

	//for (auto pos : poses) {
	//	cout << pos << endl;
	//}
	//cout << endl;

	//for (const auto& sum : s) {
	//	cout << sum << endl;
	//}
	//cout << endl;

	auto partSum = [&](int l, int r)
	{
		if (l > r) swap(l, r);
		if (l == 0) return s[r];
		return s[r] - s[l - 1];
	};

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			cout << 0 + abs(0 - poses[1]) + partSum(2, N) << endl;
		}
		else if (i == N - 1) {
			cout << partSum(0, N - 2) + abs(poses[N - 2] - 0) + 0 << endl;
		}
		else {
			cout << partSum(0, i - 1) + abs(poses[i - 1] - poses[i + 1]) + partSum(i + 2, N) << endl;
		}
	}

	return 0;
}

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

using ll = long long int;
using vi = vector<int>;
using vii = vector<vi>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  string s;
  cin >> s;
  int n = s.size(), g = 0, p = 0;
  for(char x : s){
    if(x == 'g') g++;
    else p++;
  }
  // グーを出す -> -1 or 0 point
  // パーを出す -> 0 or 1 point
  // したがって, パーをできるだけ多く出すべき
  // ただ, どこで出しても同じ得点 (because 相殺される)
  cout << n / 2 - p << "\n";
  return 0;
}

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

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
    rep(i, N) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  UnionFind tree(n);

  rep(i, m) {
    int x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }

  int c = 0;
  rep(i, n) {
    if (tree.same(i, p[i]-1)) c++;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 3964
S = int(input())
N = 0

if S < 10:
    N = S
elif S >= 10 :
    N = S % 10
elif S >= 100:
    N = S % 100 

if N == 2 or N ==4 or N ==5 or N ==7 or N ==9:
    print("hon")
elif N == 0 or N ==1 or N == 6 or N ==8:
    print("pon")
else:
    print("bon") 

Measured memory_bytes: 61792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll s1,s2,s3;
  s1=a*x+b*y;
  if(x>=y){
    s2=c*y*2+a*(x-y);
  }
  if(x<y){
    s2=c*x*2+b*(y-x);
  }
  s3=c*max(x,y)*2;
  ll ans=min(s1,min(s2,s3));
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
k, n = map(int, input().split())
a = list(map(int, input().split()))
d_max = 0

for i in range(n - 1):
    d = a[i + 1] - a[i]
    if d > d_max:
        d_max = d

d = (k - a[-1]) + a[0]
if d > d_max:
    d_max = d

print(k - d_max)


Measured memory_bytes: 26060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(b>=a*c ? c   : b/a)<<'\n';
  return(0);
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        
        if(0 < n && n <= 111){
            System.out.println(111);
        }else if(112 <= n && n <= 222){
            System.out.println(222);
        }else if(223 <= n && n <= 333){
            System.out.println(333);
        }else if(334 <= n && n <= 444){
            System.out.println(444);
        }else if(445 <= n && n <= 555){
            System.out.println(555);
        }else if(556 <= n && n <= 666){
            System.out.println(666);
        }else if(667 <= n && n <= 777){
            System.out.println(777);
        }else if(778 <= n && n <= 888){
            System.out.println(888);
        }else{
            System.out.println(999);
        }
        






    }
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int A[26] = {0};
    for (const auto & c : S) {
        A[c - 'A'] += 1;
    }
    int n = 0;
    for (const auto & i : A) {
        if (i == 2) {
            n++;
        }
    }
    if (n == 2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  string s;
  cin >> n >> m;
  vector<int> v(n);
  int sum = 0;
  rep(i,n){
    cin >> v[i];
    sum += v[i];
  }
  int can = 0;
  rep(i,n){
    if (v[i] >= (sum + 4*m-1)/(4*m) ){
      can++;
      //cout << v[i] << endl;
    }

  }
  if (can >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, vector<ll> a) {
  ll res = 0;
  for (int i = 0; i < 2000 && a.front() >= N; ++i) {
    for (ll &x: a) ++x;
    a.front() -= N + 1;
    ++res;
    sort(a.rbegin(), a.rend());
  }
  for (ll &x: a) {
    ll c = max(0LL, (x - 200) / (N + 1));
    x -= c * (N + 1);
    res += c * (N + 1);
  }
  sort(a.rbegin(), a.rend());
  while (a.front() >= N) {
    for (ll &x: a) ++x;
    a.front() -= N + 1;
    ++res;
    sort(a.rbegin(), a.rend());
  }
  cout << res << endl; 
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve(N, a);
	return 0;
}


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

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

int main(){
    ll A, B;
    cin >> A >> B;
    cout << (A*B)/gcd(A, B) << endl;
    return 0;
}

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: i32 = read();
    let y: i32 = read();
    let z: i32 = read();
    let ans = (x - z) / (y + z);
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var aa = int.Parse(line[0]);
        var bb = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        var a = getArray(line[0]);
        var aL = line[0].Length;
        var b = getArray(line[1]);
        var c = getArray((aa - bb).ToString());
        var d = getAns(a, b);
        var count = 0;
        var ret = new int[10];
        for (int i = 0; i < 10; i++) ret[i] = -1;
        for (int i = aL -1; i >= 0; i--)
        {
            if (d[i] > c[i] && count < k) { ret[i] = d[i]; count++; }
            else ret[i] = c[i];
        }
        var ans = "";
        for (int i = 0; i < aL; i++) ans += ret[aL - 1 - i].ToString();
        Console.WriteLine(int.Parse(ans));
    }
    public static int[] getAns(int[] a, int[] b)
    {
        var ret = new int[10];
        for (int i = 0; i < 10; i++)
            ret[i] = a[i] < b[i] ? a[i] + 10 - b[i] : a[i] - b[i];
        return ret;
    }
    public static int[] getArray(string s)
    {
        var sL = s.Length;
        var ret = new int[10];
        for (int i = 0; i < sL; i++)
            ret[i] = int.Parse(s[sL - 1 - i].ToString());
        return ret;
    }
}



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

int main(){
    while(1){
        int n, nums[10] = {0};
        cin >> n;
        if(!n) break;

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

        for(int i = 0;i < 10;i++){
            if(nums[i] == 0) cout << "-";
            else{
                for(int j = 0;j < nums[i];j++) cout << "*";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
n = int(input())
s_list = [input() for _ in range(n)]
count = 0
strdic = {}
for s in s_list:
    s = sorted(s)
    s = ''.join(s)
    if s in strdic:
        # 同じものがstrdic[s]回出てるってことだから
        # 答えにstrdic[s]をたす
        count += strdic[s]
        strdic[s] += 1
    else:
        strdic[s] = 1
print(count)

Measured memory_bytes: 24976
object Main extends App{
       val n = scala.io.StdIn.readInt
       val a = scala.io.StdIn.readInt
  
  	   val b = n%500

       val ans = if((a-b)>= 0){
           "Yes"
        }else{
           "No"
           }
        println(ans)
        }
        


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

int main() {
    ll n, x, mod, l, r;
    cin >> n >> x >> mod;
    vector<ll> a(100001, 0);
    a[0] = 1;
    a[1] = x;
    map<ll, ll> m;
    m[x] = 1;
    bool type = false;
    for (int i = 2; i <= 100000; ++i) {
        a[i] = a[i - 1] * a[i - 1] % mod;
        if (m[a[i]]) {
            l = m[a[i]];
            r = i;
            break;
        }
        if(!a[i]){
            l = 1;
            r = i;
            type = true;
            break;
        }
        m[a[i]] = i;
    }

    ll sum = 0, psum = 0;
    for (int i = l; i < r; ++i) psum += a[i];
    if (type) return cout << psum, 0;
    for (int i = 1; n > 0 && i < l; ++i, --n) sum += a[i];
    sum += n / (r - l) * psum;
    n %= (r - l);
    for (int i = l; i < r && n > 0; ++i, --n) sum += a[i];
    cout << sum;
}

Measured memory_bytes: 7212
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
        x: u64,
    }

    let num = ((b + x) / x) - ((a - 1 + x) / x);

    println!("{}",num)
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val V = readLine()!!.split(" ").map { it.toInt() }
    val C = readLine()!!.split(" ").map { it.toInt() }
    println((0 until N).map { V[it] - C[it] }.filter { it > 0 }.sum())
}

Measured memory_bytes: 38076
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
Pt=[K-Q]*N
for i in range(Q):
    Pt[A[i]-1]=Pt[A[i]-1]+1
for j in range(N):
    print("No" if Pt[j]<=0 else "Yes")

Measured memory_bytes: 10512
#include "iostream"
#include <algorithm>
#include <string.h>
using namespace std;

int main(int argc, char const *argv[]) {
  string S;
   cin >> S;
   int L = S.size();
   string ans = "AC";
   if(S[0] != 'A'){
     ans = "WA";
   }
   
   int cnt = 0;
   for(int i = 1; i < L; ++i){
     if(isupper(S[i])){
        if(i == 1 || i == L - 1 || S[i] != 'C'){
            ans = "WA";
          }
          ++cnt;
        }
   }

   if(cnt != 1){
     ans = "WA";
   }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+9;
const int mod=1e9+7;
using namespace std;
int main()
{
	ll a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	ll x=n/b;
	x=max(0ll,x*b-1);
	printf("%lld\n",max((x*a/b)-a*(x/b),(n*a/b)-a*(n/b)));
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}

#define max 1000000000000000000

void solve()
{
   ll n,i;cin>>n;
   vi v(n);
   rep(i,0,n) cin>>v[i];
   ll p=1;
   rep(i,0,n) 
   {
   	if(v[i]==0)
   	{
   		cout<<"0"<<"\n";
   		return;
   	}
   }
   rep(i,0,n)
   {
        if(v[i]>max/p)
        {
        	cout<<"-1"<<"\n";
        	return;
        }
        p*=v[i];
   }
   cout<<p<<"\n";
}

int main()
{
 ll t=1;
 while(t--)
   solve();
 return 0;
}

Measured memory_bytes: 4032
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = 0
    t = 0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            t += 1
        else:
            ans = max(t, ans)
            t = 0
    print(max(t, ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14628
import Control.Monad

main = do
  s <- getLine
  let [n,m] = map (read::String->Int) . words $ s
  s <- replicateM n getLine
  t <- getContents

  let mult x = show $ sum $ zipWith (*) (map (read::String->Int) . words $ x) (map (read::String->Int) . lines $ t)
  mapM_ putStrLn $ map mult s

Measured memory_bytes: 7524
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
C = list(map(int, input().split()))

vis = [False] * N
ans = [-float('inf')] * N

for root in range(N):
    if vis[root]:
        continue

    cycle = [root]
    costs = [C[root]]
    u = P[root]
    while u != root:
        cycle.append(u)
        costs.append(C[u])
        u = P[u]
    
    for u in cycle:
        vis[u] = True

    L = len(cycle)
    S = sum(costs)
    for i, v in enumerate(cycle):
        # Rewrite [1, K] as form q * L + r, :
        # 0L + 1, 0L + 2, ..., 0L + L
        # 1L + 1, 1L + 2, ..., 1L + L
        # ⋮ 
        # tL + 1, tL + 2, ... (t = floor((K - r) / L))

        # We can ignore 1L + r, 2L + r, ..., (t - 1) * L + r
        # since the total cost of loop is either positive or negative
        # When positive, 0L + r < 1L + r < 2L + r < tL + r
        # When negative, the answer should be 0L + r

        cnt = 0
        for rem in range(1, min(L, K) + 1):
            cnt += costs[(i + rem) % L]
            val1 = cnt
            val2 = cnt + (K - rem) // L * S
            ans[v] = max(ans[v], val1, val2)

print(max(ans))



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

const int N = 4000;
int wsum[N][N]={0};
int bsum[N][N]={0};
int win[N][N]={0};
int bin[N][N]={0};

int get_sum(int y1, int x1, int y2, int x2, int sum[N][N]){
  int ret = sum[y2][x2];
  if (y1 > 0){
    ret -= sum[y1-1][x2];
  }
  if (x1 > 0){
    ret -= sum[y2][x1-1];
  }
  if (y1 > 0 && x1 > 0){
    ret += sum[y1-1][x1-1];
  }
  return ret;
}

void compute_sum(int n, int in[N][N], int sum[N][N]){
  for(int i = 0;i < n;i++){
    for(int j=0;j < n;j++){
      int tmp = in[i][j];
      if (i > 0){
	tmp += sum[i-1][j];
      }
      if (j > 0){
	tmp += sum[i][j-1];
      }
      if (i > 0 && j > 0){
	tmp -= sum[i-1][j-1];
      }
      sum[i][j] = tmp;
    }
  }
}

int solve(const int k, int win[N][N], int bin[N][N]){
  compute_sum(3 * k, win, wsum);
  compute_sum(3 * k, bin, bsum);

  int ret = 0;
  for(int i = 0;i < k;i++){
    for(int j = 0;j < k;j++){
      int tmp1 =
	get_sum(    i,   j,   i+k-1,   j+k-1, wsum)
	+ get_sum(i+k, j+k, i+k+k-1, j+k+k-1, wsum)
	+ get_sum(  i, j+k,   i+k-1, j+k+k-1, bsum)
	+ get_sum(i+k,   j, i+k+k-1,   j+k-1, bsum);

      int tmp2 = get_sum(i, j, i+k-1, j+k-1 , bsum) + get_sum(i+k, j+k, i+k+k-1, j+k+k-1, bsum)
	+ get_sum(i, j+k, i+k-1, j+k+k-1, wsum) + get_sum(i+k, j, i+k+k-1, j+k-1, wsum);
      ret = max({ret, tmp1, tmp2});
    }
  }
  return ret;
}

int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 0;i < n;i++){
    int y, x;
    char color;
    cin >> x >> y >> color;
    y = y % (2 * k);
    x = x % (2 * k);
    
    if (color == 'W'){
      win[y][x]++;
      win[y+2*k][x]++;
      win[y][x+2*k]++;
      win[y+2*k][x+2*k]++;
    } else if (color == 'B'){
      bin[y][x]++;
      bin[y+2*k][x]++;
      bin[y][x+2*k]++;
      bin[y+2*k][x+2*k]++;
    }
  }
  cout << solve(k, win, bin) << endl;;
  return 0;
}


Measured memory_bytes: 221312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,ans,num;
    cin>>num;
    if(num==3)
    {
        cout<<"YES"<<endl;
        //cout<<"The growth of a three-year-old child will be celebrated."<<endl;
    }
    else if(num==5)
    {
        cout<<"YES"<<endl;
        //cout<<"The growth of a five-year-old child will be celebrated."<<endl;
    }
    else if(num==7)
    {
        cout<<"YES"<<endl;
        //cout<<"The growth of a seven-year-old child will be celebrated."<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
        //cout<<"See you next year."<<endl;
    }
}


Measured memory_bytes: 256
def f(n):
    if n % 2 == 0:
        return n//2 
    else:
        return 3 * n + 1

s = int(input())
ai = []
ai.append(s)
for i in range(1000000):
    x = f(ai[i])
    if x in ai:
        print(i+2)
        break
    ai.append(x)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
char ans[N];
string s[N];
int n,a,b,c;
void dfs(int st,int a,int b,int c)
{
	if(a<0||b<0||c<0) return;
	if(st==n+1)
	{
		cout<<"Yes"<<endl;
		for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
		exit(0);
	}
	else 
	{
		if(s[st]=="AB")
		{
			ans[st]='A';
			dfs(st+1,a+1,b-1,c);
			ans[st]='B';
			dfs(st+1,a-1,b+1,c);
		}
		else if(s[st]=="AC")
		{
			ans[st]='A';
			dfs(st+1,a+1,b,c-1);
			ans[st]='C';
			dfs(st+1,a-1,b,c+1);
		}
		else 
		{
			ans[st]='B';
			dfs(st+1,a,b+1,c-1);
			ans[st]='C';
			dfs(st+1,a,b-1,c+1);
		}
	}
}
int main(){
    cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	dfs(1,a,b,c);
	cout<<"No";
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(auto &s: S) cin >> s;
    sort(S.begin(), S.end());
    auto res = unique(S.begin(), S.end());
    cout << distance(S.begin(), res) << endl;
}

Measured memory_bytes: 9596
#include <iostream>
using namespace std;
int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int maxdiff = max(abs(a1-a2), max(abs(a2-a3), abs(a3-a1)));
    cout << abs(a1-a2) + abs(a2-a3) + abs(a3-a1) - maxdiff << endl;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long ll;
const ll inf=1000000000000000ll;
const int N=100005;
int n,m,S,T,inq[N];
int head[N],now=0;
ll dis1[N],dis2[N];
ll ans[N];
using namespace std;

struct node
{
	int t,w1,w2,next;
}adj[N<<1];
queue<int> Q;
void add(int s,int t,int a,int b)
{
	adj[++now]=(node){t,a,b,head[s]};
	head[s]=now;
}
void spfa1()
{
	int i,s,t;
	for (i=1;i<=n;i++) dis1[i]=inf;
	Q.push(S),inq[S]=1,dis1[S]=0;
	while (!Q.empty())
	{
		s=Q.front(),Q.pop();inq[s]=0;
		for (i=head[s];i;i=adj[i].next)
		{
			t=adj[i].t;
			if (dis1[t]>dis1[s]+adj[i].w1)
			{
				dis1[t]=dis1[s]+adj[i].w1;
				if (!inq[t]) inq[t]=1,Q.push(t);
			}
		}
	}
}
void spfa2()
{
	int i,s,t;
	for (i=1;i<=n;i++) dis2[i]=inf;
	Q.push(T),inq[T]=1,dis2[T]=0;
	while (!Q.empty())
	{
		s=Q.front(),Q.pop();inq[s]=0;
		for (i=head[s];i;i=adj[i].next)
		{
			t=adj[i].t;
			if (dis2[t]>dis2[s]+adj[i].w2)
			{
				dis2[t]=dis2[s]+adj[i].w2;
				if (!inq[t]) inq[t]=1,Q.push(t);
			}
		}
	}
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d %d %d",&n,&m,&S,&T);
	int i,s,t,a,b;
	for (i=1;i<=m;i++)
	{
		scanf ("%d %d %d %d",&s,&t,&a,&b);
		add(s,t,a,b),add(t,s,a,b);
	}
	spfa1(),spfa2();
	for (i=1;i<=n;i++) ans[i]=dis1[i]+dis2[i];
	for (i=n-1;i>=1;i--) ans[i]=min(ans[i],ans[i+1]);
	for (i=1;i<=n;i++) printf ("%lld\n",inf-ans[i]);
	return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros
template <long long Mod>
struct modint {
    ll n;
    modint(ll x = 0) : n((x + Mod) % Mod) {
    }

    modint operator+(const modint &r) const { return modint(*this) += r; }
    modint operator-(const modint &r) const { return modint(*this) -= r; }
    modint operator*(const modint &r) const { return modint(*this) *= r; }
    modint operator/(const modint &r) const { return modint(*this) /= r; }
    modint operator+=(const modint &r) {
        n += r.n;
        n %= Mod;
        return *this;
    }
    modint operator-=(const modint &r) {
        n -= r.n;
        n += Mod;
        n %= Mod;
        return *this;
    }
    modint operator*=(const modint &r) {
        n *= r.n;
        n %= Mod;
        return *this;
    }
    modint operator/=(const modint &r) {
        *this *= modint(r).inv();
        return *this;
    }

    modint operator=(const modint &r) { return n = r.n; }
    modint operator==(const modint &r) const { return n == r.n; }
    modint operator!=(const modint &r) const { return n != r.n; }

    modint inv() const { return pow(Mod - 2); }

    modint pow(const ll x) const {
        if (n == 0) return modint(0);
        if (x == 0) return modint(1);
        if (x == 1) return modint(n);

        modint a = modint(*this);
        a = (a * a).pow(x / 2);

        if (x % 2 == 1) {
            a *= n;
        }
        return a;
    }

    friend ostream &operator<<(ostream &os, const modint &x) { return os << x.n; }
    friend istream &operator>>(istream &is, modint &x) { return is >> x.n; }
};
typedef modint<1000000007> mint;

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

    string s1,s2;
    cin >> s1 >> s2;

    vector<int> type;
    for(int i=0;i<N;i++){
        if(s1[i] != s2[i]) {
            type.push_back(1);
            i++;
        }else{
            type.push_back(2);
        }
    }

    mint ans;
    if(type[0] == 1){
        ans = 6;
    }else{
        ans = 3;
    }

    for (int i = 1; i < type.size(); i++) {
        if (type[i - 1] == 1) {
            if (type[i] == 1) {
                ans *= 3;
            } else {
                ans *= 1;
            }
        } else {
            ans *= 2;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3576
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<ll>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, Y;
	cin >> N >> Y;
	Y /= 1000;

	int cnt = 0;
	int x, y, z;
	bool F = false;
	for(x = 0; x <= N; x++) {
		for (y = 0; y <= N; y++) {
			z = N - x - y;
			if (z < 0) continue;
			else if(10 * x + 5 * y + z == Y) {
				F = true;
				goto OUT;
			}
		}
	}

	OUT:
	if (F == false) cout << "-1 " << "-1 " << "-1" << endl;
	else cout << x << " " << y <<" " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    vector<unordered_map<char, int>> m(n);
    For(i, n){
        Cin(string, s);
        for(char c : s) m[i][c] ++;
    }
    string ans;
    for(char c = 'a'; c <= 'z'; c ++){
        int x = 1000;
        For(i, n) x = min(x, m[i][c]);
        Rep(x) ans += c;
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	vector<int> Y1(2);
	vector<int> Y2(2);
	cin >> Y1[0] >> Y1[1];
	cin >> Y2[0] >> Y2[1];
	if (Y1[0] != Y2[0]) cout << 1 << endl;
	else cout << 0 << endl;
}
	

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            WriteLine("2018" + cin.ReadLine().Substring(4));
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using System.Threading.Tasks;

namespace B_Digits
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;
            a = int.Parse(ReadLine());
            int b= 0;
            int c = 0;
            int c2 = 0;
            int d = 0;
            b = a / 100;
            c = a % 100;
            c2 = c / 10;
            d = c % 10;
            if ((b == 7) || (c2 == 7) || (d == 7)) {
                WriteLine("Yes");

            }
            else {
                WriteLine("No");
            }
            




        }

    }
}


      


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

int main(){
	int n;
	double x1, y1, x2, y2, x3, y3, xp, yp, x ,y ,z;

	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		x = (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1);
		y = (x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2);
		z = (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3);
		if ((x > 0 && y > 0 && z > 0) || (x < 0 && y < 0 && z < 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1216
#include <stdio.h>
 int main(void){
     int a,b;
     char op='\0';
     while(1){
         scanf("%d %c %d",&a,&op,&b);
         if(op=='+')
             printf("%d\n",a+b);
         else if(op=='-')
             printf("%d\n",a-b);
         else if(op=='/')
             printf("%d\n",a/b);
         else if(op=='*')
             printf("%d\n",a*b);
         else
             break;
         }
     return 0;
 }


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  pair<pair<string, int>, int> p[110];

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    int a;
    scanf("%d", &a);

    p[i] = make_pair(make_pair(s, -a), (i + 1));
  }

  sort(p, p + n);

  for (int i = 0; i < n; i++) {
    cout << p[i].second << endl;
    // cout << p[i].first.first << endl;
    // cout << p[i].first.second << endl;
  }
}


Measured memory_bytes: 256