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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (auto& e : p) cin >> e;
    sort(begin(p), end(p));

    cout << accumulate(begin(p), end(p) - 1, p.back() / 2) << endl;
}


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

ll comb[51][51];
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  ll x[n];
  rep(i,n)cin>>x[i];
  comb[0][0]=1;
  rep(i,50)rep(j,50){
    comb[i+1][j]+=comb[i][j];
    comb[i+1][j+1]+=comb[i][j];
    }
  sort(x,x+n);
  reverse(x,x+n);
    ll sum=0;
    rep(i,a)sum+=x[i];
    cout<<setprecision(8)<<1.0*sum/a<<endl;;
  if(x[0]!=x[a-1]){
    int m=0,k=0;
    rep(i,n)if(x[i]==x[a-1])m++;
    rep(i,a)if(x[i]==x[a-1])k++;
    cout<<comb[m][k]<<endl;
    return 0;
    }
  ll ans=0;
  ll p=x[a-1];
  while(a<=b&&x[a-1]==p){
    int m=0,k=0;
    rep(i,n)if(x[i]==x[a-1])m++;
    rep(i,a)if(x[i]==x[a-1])k++;
    ans+=comb[m][k];
    a++;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main() {
	char S[5];
	int s[5];
	bool flag = true;

	gets(S,5);
	for (int i = 0; i < 4; i++) s[i] = (int)S[i];
	if ((s[0] == s[1]) && (s[1] == s[2]) && (s[2] == s[3])) flag = false;
	for (int i = 0; i < 3; i++) {
		if (s[0] == s[i+1]) {
			s[0] = 0;
			s[i+1] = 0;
			break;
		}
	}
	if (s[1] != 0) {
		for (int i = 0; i < 2; i++) {
			if (s[1] == s[i+2]) {
				s[1] = 0;
				s[i+2] = 0;
				break;
			}
		}
	}
	if (s[2] != 0) {
		if (s[2] == s[3]) {
			s[2] = 0;
			s[3] = 0;
		}
	}
	for (int i = 0; i < 4; i++) {
		if (s[i] != 0) {
			flag = false;
		}
	}

	printf("%s\n", flag? "Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}

int const MAX_T = 100010;
vector<int> add[MAX_T+10];
vector<int> del[MAX_T+10];

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> s(n),t(n),c(n);
    rep(i,n) {
        cin >> s[i] >> t[i] >> c[i];
        add[s[i]].push_back(c[i]);
        del[t[i]].push_back(c[i]);
    }

    int res = 0;
    set<int> st;
    rep(j,MAX_T) {
        vector<int> dame;
        for(int x : add[j]) {
            if(st.find(x) != st.end()) dame.push_back(x);
            st.insert(x);
        }
        chmax(res,(int)size(st));
        for(int x : del[j]) {
            bool ok = true;
            for(int y : dame) {
                if(x == y) ok = false;
            }
            if(ok) st.erase(x);
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MAX_NUM = 1000000000000001;

int main(){
    int N;
    cin >> N;
    ull ans = 0;
    vector<ll> A(100001, 0);
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        ans += tmp;
        A.at(tmp)++;
    }

    int Q;
    cin >> Q;
    vector<ull> sum(Q);
    for (int i = 0; i < Q; i++) {
        ll b, c;
        cin >> b >> c;
        ll tmp = A.at(b);
        A.at(c) += tmp;
        A.at(b) = 0;
        ans -= b * tmp;
        ans += c * tmp;
        sum.at(i) = ans;
    }

    for (int i = 0; i < Q; i++) cout << sum.at(i) << endl;

    return 0;
}


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

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

    int p[m];
    char s[3];
    int ac[n], wa[n];

    for(int i = 0; i < n; i++){
        ac[i] = 0;
        wa[i] = 0;
    }
    
    for(int i = 0; i < m; i++){
        scanf("%d %s", &p[i], s);
        if(strcmp(s, "AC") == 0){
            ac[p[i] - 1] = 1;
        }else if(ac[p[i] - 1] != 1){
            wa[p[i] - 1]++;
        }
    }

    int account = 0;
    int wacount = 0;
    for(int i = 0; i < n; i++){
        if(ac[i] == 1){
            account++;
            wacount += wa[i];
        }
    }

    printf("%d %d", account, wacount);
    
}

Measured memory_bytes: 1280
#191116 B
if __name__ == "__main__":
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
    else:
        if S[0:int(N/2)] == S[int(N/2):(N+1)]:
            print("Yes")
        else:
            print("No")
    


    

Measured memory_bytes: 2940
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        int n, q;
        cin >> n >> q;
        if (n == 0) break;
        vector<int> cnt(101, 0);
        REP(i, n) {
            int m;
            cin >> m;
            REP(j, m) {
                int d;
                cin >> d;
                cnt[d]++;
            }
        }
        int ans = 0;
        int mx = 0;
        REP(i, cnt.size()) {
            if (mx < cnt[i] && q <= cnt[i]) {
                ans = i;
                mx = cnt[i];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

ll dp[20000][2][110];

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

    string s; cin >> s;
    int n = s.length();
    int D; cin >> D;
    dp[0][0][0] = 1;
    rep(i, n) rep(j, 2) rep(k, D) {
        int lim = j? 9:s[i]-'0';
        rep(d, lim+1){
            (dp[i+1][j || d<lim][(k+d)%D] += dp[i][j][k]) %= mod;
        }
    }

    ll ans = 0;
    rep(j, 2) ans += dp[n][j][0];
    --ans;
    chmod(ans);
    cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 18688
from queue import Queue

N, C, K = map(int, input().split())

# T = [[出発時刻, 到着時刻], ...]
T = [[0, 0] for _ in range(N)]
for i in range(N):
    t = int(input())
    T[i][0] = t + K
    T[i][1] = t

T.sort()
que = Queue()
for t in T:
    que.put(t)

ans = 0
dest = -1
cap = 0

while not que.empty():
    td, ta = que.get()

    # 新しいバス
    if cap == 0:
        dest = td
        cap = 1
    # 待っているバスがいる
    elif ta <= dest:
        cap += 1
    # バスがもう待てない
    else:
        ans += 1
        dest = td
        cap = 1

    # 定員に達してしまったら出発させる
    if cap == C:
        ans += 1
        cap = 0

# バスに乗客が残っていたら出発
if cap > 0:
    ans += 1

print(ans)


Measured memory_bytes: 59164
N,K=map(int,input().split())
while N>100000000000000000*K:
  N=N-100000000000000000*K
while N>100000000000000*K:
  N=N-100000000000000*K
while N>1000000000000*K:
  N=N-1000000000000*K
while N>10000000000*K:
  N=N-10000000000*K
while N>100000000*K:
  N=N-100000000*K
while N>1000000*K:
  N=N-100000*K
while N>1000*K:
  N=N-1000*K
while N>100*K:
  N=N-100*K
while N>10*K:
  N=N-10*K
while N>K:
  N=N-K

N2=N-K
if N2<0:
  N2=-N2

if N<N2:
  print(N)
else :
  print(N2)


Measured memory_bytes: 3064
#include <bitset>
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int findNumOfDigits(ll x) {
    int cnt = 0;
    while (x > 0) {
        x /= 10;
        cnt++;
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    int ans = findNumOfDigits(n);
    for (int i = 1; i <= sqrt(n); i++) {
        if (n%i == 0){
            int a_digit = findNumOfDigits(i);
            int b_digit = findNumOfDigits(n / i);
            int maxv = max(a_digit, b_digit);
            ans = min(maxv, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main () {
  string a = "keyence";
  string b;
  cin >> b;
  int bl = (int)b.size();
  bool res = true;
  for (int i = 0; i < bl; i++) {
    if (a[i] != b[i]) {
      if (b.substr(bl-7+i, 7-i) != a.substr(i, 7-i)) {
        res = false;
      }
      break;
    }
  }
  if (res) {
    printf("YES");
  } else {
    printf("NO");
  }
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int p1, p2;
  p1 = a * n;
  p2 = b;
  if (p1 <= p2) {
    cout << p1 << endl;
  }
  else {
    cout << p2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <numeric>

int main(){
    int n = 0;
    std::cin >> n;
    std::vector<long> v{std::istream_iterator<int>(std::cin), std::istream_iterator<int>()};
    
    int min = *std::min_element(v.begin(), v.end());
    int max = *std::max_element(v.begin(), v.end());
    long sum = std::accumulate(v.begin(), v.end(),0L);
    std::cout << min << " " << max << " " << sum << std::endl;
    return 0;
}



Measured memory_bytes: 3260
import java.util.*;
public class Main {
	static boolean prime[] = new boolean[1000001];
	static List<Integer> hyou = new ArrayList<Integer>();
	static int sum[] = new int[1000001];
	static int doIt(int n){
		int cnt = 0;
		boolean[] a = new boolean[sum.length];
		for(int s=0;s<a.length;s++)a[s]=true;
		for(int s=n-1;s>0;s--){
			if(prime[s]&&prime[n-s]&&a[s]){
				cnt++;
				a[n-s]=false;a[s]=false;
			}
		}
		return cnt;
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		for(int i=0;i<prime.length;i++)prime[i]=true;
		prime[0]=false;prime[1]=false;
		for(int s=0;s<prime.length;s++){
			if(prime[s]){
				for(int i=s+s;i<prime.length;i+=s)prime[i]=false;
				hyou.add(s);
			}
		}
		for(int i=0;i<sum.length;i++){
			if(prime[i])sum[i]=1;
			else sum[i]=0;
		}
		while(in.hasNext()){
			int n = in.nextInt();
			if(n==0)break;
			System.out.println(doIt(n));
		}
	}
}

Measured memory_bytes: 102248
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

vector<int> h;
int N;

int mizuyari(){
    int start = -1;
    int end = -1;
    for (int i = 0; i < N; ++i) {
        if(h[i] > 0 && start == -1){
            start = i;
        }
        if(start != -1 && i+1 == N){
            end = i;
            break;
        }
        if(start != -1 && h[i+1] == 0){
            end = i;
            break;
        }
    }
    if(start == -1 && end == -1){
        return 0;
    }

    //cout << "start: "<< start << " end: "<< end << endl;
    for (int i = start; i <= end; ++i) {
        h[i]--;
    }
    return 1;
}

int main() {

    cin >> N;
    for (int i = 0; i < N; ++i) {
        int hh;
        cin >> hh;
        h.push_back(hh);
    }
    for (int i = 0; i < 100001; ++i) {
        int re = mizuyari();
        if(re == 0){
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
//ABC106-B
#include <stdio.h>

int main(){
	int N, i, j, ans, now;
	scanf("%d", &N);
	for(i = 1, ans = 0; i <= N; i++){
		for(j = 1, now = 0; j <= i; j++){
			if(i % j == 0){
				now++;
			}
		}
		if(now == 8 && i % 2 == 1){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#define IO                       \
    std::ios_base::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define LL long long
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;

const int INF = 0x3f3f3f3f;

void solve() {
}

int main(void) {
    IO;

    int N, ans = 1;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int mini = a[0];
    for (int i = 1; i < N; ++i) {
        if (a[i] < mini) {
            ++ans;
        }
        mini = min(mini, a[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

typedef long long ll;
ll n, p, d[2];
int main()
{
	ll i, t, t0, t1;
	cin >> n >> p;
	d[0] = 1;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &t);
		t0 = d[0];
		t1 = d[1];
		d[t % 2] += t0;
		d[(t + 1) % 2] += t1;
	}
    cout << d[p] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fa(i,a,b) for(i=a;i<b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define clr(x) memset(x, 0, sizeof(x))
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;


int main()
{
	/*#ifndef OMLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);



	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll k = max((a * c), (b * d));
	ll r = max((a * d), (b * c));
	cout << max(k, r);





}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9+7,mxN = 50,INF = 1e9;
int n,q;


void solve()
{
    cin >> n;
    int curr=1,ans = 0;
    while(n--)
    {
        int a;
        cin >> a;
        if(a == curr)
            curr++;
        else ans++;
    }
    if(curr==1)
        cout << "-1\n";
    else
    cout << ans << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 998244353;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 300000

int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int valor;
    set<int> primer,segund;
    vector<int> v;
    forr(i,0,n)
    {
        cin>>valor;
        if (i%2==0)
            primer.insert(valor);
        else
            segund.insert(valor);
        v.pb(valor);
    }
    sort(all(v));
    int c=0;
    forr(i,0,n)
    {
        if (i%2==0)
        {
            if (primer.find(v[i])==primer.end())c++;
        }
    }
    cout<<c<<endl;      
    
}
// PLUS ULTRA!!

Measured memory_bytes: 5368
//---------- begin union_find ----------
pub struct DSU {
    p: Vec<i32>,
}
impl DSU {
    pub fn new(n: usize) -> DSU {
        DSU { p: vec![-1; n] }
    }
    pub fn init(&mut self) {
        for p in self.p.iter_mut() {
            *p = -1;
        }
    }
    pub fn root(&self, mut x: usize) -> usize {
        assert!(x < self.p.len());
        while self.p[x] >= 0 {
            x = self.p[x] as usize;
        }
        x
    }
    pub fn same(&self, x: usize, y: usize) -> bool {
        assert!(x < self.p.len());
        assert!(y < self.p.len());
        self.root(x) == self.root(y)
    }
    pub fn unite(&mut self, x: usize, y: usize) -> Option<(usize, usize)> {
        assert!(x < self.p.len());
        assert!(y < self.p.len());
        let mut x = self.root(x);
        let mut y = self.root(y);
        if x == y {
            return None;
        }
        if self.p[x] > self.p[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.p[x] += self.p[y];
        self.p[y] = x as i32;
        Some((x, y))
    }
    pub fn parent(&self, x: usize) -> Option<usize> {
        assert!(x < self.p.len());
        let p = self.p[x];
        if p >= 0 {
            Some(p as usize)
        } else {
            None
        }
    }
    pub fn size(&self, x: usize) -> usize {
        assert!(x < self.p.len());
        let r = self.root(x);
        (-self.p[r]) as usize
    }
}
//---------- end union_find ----------

use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(Usize1, Usize1); m],
    }
    let mut ans = n - 1;
    let mut u = DSU::new(n);
    for (a, b) in e {
        if u.unite(a, b).is_some() {
            ans -= 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 5168
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[3];
    char t[3];
    int ans=0;
    cin >> s>>t;
    rep(i,3){
        if(s[i] == t[i])
        ans++;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
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*(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;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string str[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s;
	cin >> s;
	for (int i = 0; i < sizeof(str) / sizeof(str[0]); i++)
	{
		string p = str[i];
		if (s == p)
		{
			cout << (7 - i) << endl;
			return 0;
		}
	}
}


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

C = 0
for i in range(1, N):
    C = A[i - 1] * 2 - C
C = A[-1] * 2 - C

M = [-1 for _ in range(N)]
M[0] = C // 2
for i in range(1, N):
    M[i] = A[i - 1] * 2 - M[i - 1]

print(' '.join(map(str, M)))

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

const int maxn = 300+10, maxlogn = 10, inf = 0x3f3f3f3f;

void cmin(int &x, int y) { x = min(x, y); }

int n, m, l, q;
int g[maxn][maxn], d[maxn][maxn], f[maxn][maxn];

int main() {
	int a, b, c;
	cin >> n >> m >> l;
	memset(d, 0x3f, sizeof(d));
	for (int i = 1; i <= n; ++i) g[i][i] = 0;
	for (int i = 1; i <= m; ++i) {
		cin >> a >> b >> c;
		g[a][b] = g[b][a] = d[a][b] = d[b][a] = c;
	}
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				cmin(d[i][j], d[i][k]+d[k][j]);
	memset(f, 0x3f, sizeof(f));
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if (d[i][j] <= l) {
//				cout << i << ' ' << j << endl;
				f[i][j] = 1;
			}
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				cmin(f[i][j], f[i][k]+f[k][j]);
	cin >> q;
	while (q--) {
		cin >> a >> b;
		cout << (f[a][b]==inf?-1:f[a][b]-1) << endl;
	}
}


Measured memory_bytes: 1664
while 1:
    m, f, r = map(int, input().split())
    if(m == -1 and f == -1 and r == -1):
        break
    if(m == -1 or f == -1):
        print('F')
    elif(m+f >= 80):
        print('A')
    elif(m+f >= 65 and m+f < 80):
        print('B')
    elif(m+f >= 50 and m+f < 65):
        print('C')
    elif(m+f >= 30 and m+f < 50):
        if(r >= 50):
            print('C')
        else:
             print('D')
    else:
        print('F')



Measured memory_bytes: 5592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String ans = "";
        if (str.equals("Sunny")) {
            ans = "Cloudy";
        } else if (str.equals("Cloudy")) {
            ans = "Rainy";
        } else {
            ans = "Sunny";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const double pi=acos(-1);
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int a,b,h,m;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>a>>b>>h>>m;
	double o=pi/30*m-pi/6/60*m+pi/6*(12-h);
	if(o>pi) o=2*pi-o;
	double ans=sqrt(a*a+b*b-2*a*b*cos(o));
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 4200
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m = map(int,input().split())

X = [0] + sorted(list(map(int,input().split())))
Y = [0] + sorted(list(map(int,input().split())))
sum1 = 0
sum2 = 0
MOD = 10 ** 9 + 7
for i in range(1, n + 1):
    sum1 += ((i - 1)*X[i] - (n - i)*X[i]) % MOD
for i in range(1, m + 1):
    sum2 += ((i - 1)*Y[i] - (m - i)*Y[i])%MOD
print(sum1 * sum2 % MOD)


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

using namespace std;

string s;

int main () {
    cin >> s;
    int ans = 0;
    for (int i = 0;i < s.size () / 2;i ++) {
        int l = i, r = s.size () - i - 1;
        if (s[l] != s[r])ans ++;
    }cout << ans;
}


Measured memory_bytes: 256
import collections
n = int(input())
p = [int(i) for i in input().split()]
ps = sorted(p)
x = [p[i]-ps[i] for i in range(len(p))]
c = collections.Counter(x)
if len(c) == 1:
  print('YES')
elif len(c) == 3 and x.count(0) == n-2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int K, X;
  cin >> K >> X;
  bool bl = (500 * K >= X);
  if (bl) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3572
from fractions import gcd
n,m=map(int,input().split())
a=[int(i)//2 for i in input().split()]
def lcm(x,y):
  return x*y//gcd(x,y)
l=1
for i in a:
  l=lcm(l,i)
for i in a:
  if l//i%2==0:
    print(0)
    exit()
print((m//l+1)//2)

Measured memory_bytes: 16316
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vector<pair<string,lli>> a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    a.resize(n);
    fo(i,n)
        cin>>a[i].X>>a[i].Y;
    cin>>s;
    bool fl=false;
    for(auto x:a)
    {
        if(fl)
            cnt+=x.Y;
        if(x.X==s)
            fl=true;
    }
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    rep1(i, 1009) {
        int ta = i * 8 / 100;
        int tb = i * 10 / 100;
        if (ta == a and tb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 384
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7; 
long long a[N], dp[N];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i != 1){
            dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
            if(i > 2)dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
def linearSearch(key, arr)
  result = false
  for i in arr
    if key == i
      result = true
      break;
    end
  end
  result
end


a_size = STDIN.gets.to_i
as = STDIN.gets.split(' ')

b_size = STDIN.gets.to_i
bs = STDIN.gets.split(' ')

n = 0
for i in bs
  if linearSearch(i, as) then
    n = n + 1
  end
end

puts n

Measured memory_bytes: 8952
// Aizu 1150: Cliff Climbing
// 2017.9.17 bal4u@uu

#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef struct { int r, c, t, lr; } Q;
Q q[100005]; int top, end;
char map[62][32]; int h, w;
int mk[62][32][2];
int mv[2][9][2] = {
	{{-2, 1},{-1, 2},{-1, 1},{0, 3},{0, 2},{0, 1},{1, 2},{1, 1},{2, 1}},
	{{-2,-1},{-1,-2},{-1,-1},{0,-3},{0,-2},{0,-1},{1,-2},{1,-1},{2,-1}} };

int main()
{
	int i, r, c, r2, c2, t, t2, lr, ans;
	char s[10];

	while (scanf("%d%d", &w, &h) && w) {
		memset(mk, -1, sizeof(mk));
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) scanf("%s", s), map[r][c] = *s;
		for (ans = -1, top = end = 0, r = h-1, c = 0; c < w; c++) if (map[r][c] == 'S') {
			q[end].r = r, q[end].c = c, q[end].t = 0, q[end++].lr = 0, mk[r][c][0] = 0;
			q[end].r = r, q[end].c = c, q[end].t = 0, q[end++].lr = 1; mk[r][c][1] = 0;
		}
		while (top < end) {
			r = q[top].r, c = q[top].c, t = q[top].t, lr = !(q[top++].lr);
			if (map[r][c] == 'T') { if (ans < 0 || t < ans) ans = t; continue; }
			for (i = 0; i < 9; i++) {
				r2 = r + mv[lr][i][0], c2 = c + mv[lr][i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == 'X') continue;
				if (mk[r2][c2][lr] >= 0 && t >= mk[r2][c2][lr]) continue;
				mk[r2][c2][lr] = t;
				t2 = t; if (isdigit(map[r2][c2])) t2 += map[r2][c2] - '0';
				q[end].r = r2, q[end].c = c2, q[end].t = t2, q[end++].lr = lr;
			}
		}
		printf("%d\n", ans);
    }
	return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

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

bool check2(vector<ll> &numbers, int n) {
    vector<ll> tows(n);
    rep(i, n) {
        int a = 0;
        ll k = numbers[i];
        while (k % 2 == 0) {
            a++;
            k /= 2;
        }
        tows[i] = a;
    }
    return *max_element(tows.begin(), tows.end()) == *min_element(tows.begin(), tows.end());
}

ll get2(vector<ll> &numbers, int n) {
    ll k = numbers[0];
    ll ans = 1;
    while (k % 2 == 0) {
        ans *= 2;
        k /= 2;
    }
    return ans;
}

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

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

    rep(i, n) if (numbers[i] % 2 == 1) {
            cout << 0 << endl;
            ret();
        }

    rep(i, n) numbers[i] /= 2;

    if (!check2(numbers, n)) {
        cout << 0 << endl;
        ret();
    }

    ll tow = get2(numbers, n);
    rep(i, n) numbers[i] /= tow;

    ll l = numbers[0];
    rep(i, n) l = lcm(l, numbers[i]);

    ll md = m / tow / l;

    ll ans = (md + 1) / 2;
    cout << ans << endl;


}


Measured memory_bytes: 1792
#include <stdio.h>

long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}

int main()
{
	long long a, b, n; scanf ("%lld %lld %lld", &a, &b, &n);

	long long g = gcd(a, b);
	long long r = b - 1;
	if (r > n) r = n;

	printf ("%lld\n", (a * r) / b);

	return 0;
}

Measured memory_bytes: 1728
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
rem=0
for i in range(n):
  if a[i]>=rem:
    cnt+=rem
    a[i]=a[i]-rem
  else:
    cnt+=a[i]
    rem=b[i]
    continue
  if a[i]>=b[i]:
    cnt+=b[i]
    rem=0
  else:
    cnt+=a[i]
    rem=b[i]-a[i]
if a[n]>=rem:
  cnt+=rem
else:
  cnt+=a[n]
print(cnt)

Measured memory_bytes: 18624
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int h, w;
    cin >> h >> w;
    int tile[52][52];
    int step[52][52];
    int black = 0;
    REP(i, 52) {
        REP(j, 52) {
            tile[i][j] = 0;
            step[i][j] = 99999;
        }
    }
    REP(i, h) {
        REP(j, w) {
            char x;
            cin >> x;
            if(x == '.') {
                tile[i+1][j+1] = 1;
            } else {
                tile[i+1][j+1] = 0;
                black++;
            }
        }
    }
    
    queue<int> reserve;
    //スタート地点を登録して、幅優先探索でノードを足していく
    reserve.push(1*52+1);
    step[1][1] = 0;
    while(!reserve.empty()) {
        int from = reserve.front();
        int x = from%52;
        int y = from/52;
        int cost = step[y][x];
        reserve.pop();
        //ゴールなら終了
        //cout << from << "," << cost << endl;
        if(x==w && y==h) {
            cout << h*w - 2 - black - (cost-1) << endl;
            return 0;
        }
        //次に移動する場所を登録し、costを更新する
        if(tile[y-1][x] == 1 && step[y-1][x] == 99999) { //上
            step[y-1][x] = cost+1;
            reserve.push((y-1)*52+x);
        }
        if(tile[y+1][x] == 1 && step[y+1][x] == 99999) { //下
            step[y+1][x] = cost+1;
            reserve.push((y+1)*52+x);
        }
        if(tile[y][x-1] == 1 && step[y][x-1] == 99999) { //左
            step[y][x-1] = cost+1;
            reserve.push(y*52+x-1);
        }
        if(tile[y][x+1] == 1 && step[y][x+1] == 99999) { //右
            step[y][x+1]= cost+1;
            reserve.push(y*52+x+1);
        }
        
    }
    cout << -1 << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
int seen[11][maxn], color[maxn];
vector<int> e[maxn];
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	vector<tuple<int,int,int>> qs;
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int vi, di, ci; cin >> vi >> di >> ci;
		qs.push_back(make_tuple(vi, di, ci));
	}
	reverse(qs.begin(), qs.end());
	for(int i = 0; i < q; i++){
		int vi, di, ci; tie(vi, di, ci) = qs[i];
		if(!seen[di][vi]){
			queue<pair<int,int>> q;
			q.push({di, vi});
			seen[di][vi] = 1;
			while(!q.empty()){
				int d, v; tie(d, v) = q.front(); q.pop();
				if(color[v] == 0) color[v] = ci;
				if(d){
					for(int nxt : e[v]){
						if(!seen[d - 1][nxt]){
							q.push({d - 1, nxt});
							seen[d - 1][nxt] = 1;
						}
					}
				}
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << color[i] << endl;
	return 0;
}


Measured memory_bytes: 14704
#include <iostream>
#include <map>

using namespace std;

int main(){
    int N; cin >> N; map<int, int> M;
    for (int i = 0; i < N; i++){
        int A; cin >> A; M.insert(make_pair(A, i+1));
    }

    for (map<int, int>::iterator i = M.begin(); i != M.end(); i++){
        if (i != M.begin()) cout << ' ';
        cout << (*i).second;
    }

    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main()
{
	int a,b,maxx,minn;
	bool d=0;
	cin>>a>>b;
	maxx=max(a,b);
	minn=min(a,b);
	for(int i=minn;i<=maxx;i++)
	{
		if((a*b*i)%2==1)
		d=1;
	}
		if(d==1)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
		return 0;
}

Measured memory_bytes: 256
h,w=map(int,raw_input().split())
n=int(raw_input())
a=map(int,raw_input().split())
b=[[0]*2 for i in range(n+1)]
for i in range(1,n+1):
	b[i][0]=a[i-1]
	b[i][1]=i
b=sorted(b, key=lambda x: -x[0])
c=[[0 for i in range(w)] for i in range(h)]
x=y=0
for i in range(n):
	for j in range(b[i][0]):
		c[x][y]=b[i][1]
		if x%2==0:
			y+=1
		else:
			y-=1
		if y>=w:
			x+=1
			y-=1
		if y<0:
			x+=1
			y+=1
for i in range(h):
	for j in range(w):
		print c[i][j],
	print


Measured memory_bytes: 34412
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max({2*a-1, a+b, 2*b-1}) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	string s;
	cin >> s;
	bool yymm = 1, mmyy = 1;
	
	int pe = (s[0] - '0') * 10 + s[1] - '0';
	int dr = (s[2] - '0') * 10 + s[3] - '0';
	if (pe > 12)
		mmyy = 0;
	if (dr > 12)
		yymm = 0;
	if (pe == 0)
		mmyy = 0;
	if (dr == 0)
		yymm = 0;
	if (yymm)
	{
		if (mmyy)
			cout << "AMBIGUOUS";
		else
			cout << "YYMM";
	}
	else
	{
		if (mmyy)
			cout << "MMYY";
		else
			cout << "NA";
	}
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
    int a, b;

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

    if (a > 0 && b > 0) {
        b++;
        puts("Positive");
    } else if (a < 0 && b < 0) {
        b++;
        ((b-a)%2)?puts("Negative"):puts("Positive");
    } else {
        puts("Zero");
    }

    return 0;
}



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

int main() {
	int N, M;
	string A[50], B[50];
	cin >> N >> M;
	bool check = false;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}

	for (int i = 0; i <= N - M; i++) { //上
		for (int j = 0; j <= N - M; j++) { //左
			bool check2 = true;
			for (int k = 0; k < M; k++) {
				if (A[i + k].substr(j, M) != B[k]) check2 = false;
			}
			if (check2) check = true;
		}
	}

	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500011; 
  
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i>=b;i--)
#define fill(a,i) memset(a,i,sizeof a);
struct Query 
{ 
    int l, r, idx; 
}; 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 

void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
}  
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
       
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
      
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
   
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
     
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

int main() 
{   int n,q;cin>>n>>q;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
   
    Query queries[q]; 
    for(int i=0;i<q;i++)
    {
        int l1,r1;cin>>l1>>r1;
        l1--;r1--;
        queries[i].l=l1;
        queries[i].r=r1;
        queries[i].idx=i;
    }
    
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 17420
D,G=map(int,input().split())
PC=[0]+[list(map(int,input().split()))for i in range(D)]
def f(p,c):
    if p==0:
        return 10**9
    m=min(c//(p*100),PC[p][0])
    s=100*p*m
    if m==PC[p][0]:
        s+=PC[p][1]
    if s<c:
        m+=f(p-1,c-s)
    return min(m,f(p-1,c))
print(f(D,G))

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <climits>

using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	string s1,s2;
	cin>>s1>>s2;

	int s1_length=s1.size();
	int s2_length=s2.size();

int ans=INT_MAX;
	for(int i=0;i<s1_length;i++)
	{
		int cnt=0;
		if(i+s2_length-1 <=s1_length-1)
			for(int j=0;j<s2_length;j++)
			{
				//cout<<s1[i+j]<<" "<<s2[j];
				if(s1[i+j]!=s2[j])
					cnt++;

				//cout<<cnt<<endl;
			}
		else
			break;

			//cout<<cnt<<endl;
			ans=min(ans,cnt);
			//cout<<endl;

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

Measured memory_bytes: 3604
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;
const int inf=0x3f3f3f3f;

int n,k;
vector<int> E[N];
int w[N],vis[N];
struct node { int u,w; };
bool operator <(node a,node b) { return a.w>b.w; }
priority_queue<node> Q;

int main() {
	n=read();
	for (int i=1;i<n;++i) {
		int u=read(),v=read();
		E[u].emplace_back(v),E[v].emplace_back(u);
	}
	k=read();
	for (int i=1,p;i<=k;++i)
		p=read(),vis[p]=1,w[p]=read(),Q.push((node){p,w[p]});
	while (!Q.empty()) {
		int u=Q.top().u,d=Q.top().w; Q.pop();
		for (int v:E[u]) {
			if (vis[v]&&abs(w[u]-w[v])!=1) { puts("No"); exit(0); }
			if (!vis[v]) vis[v]=1,w[v]=w[u]+1,Q.push((node){v,w[v]});
		}
	}
	puts("Yes");
	for (int i=1;i<=n;++i) printf("%d\n",w[i]);
	return 0;
}

Measured memory_bytes: 10656