akhauriyash/Code-Regression huggingface dataset:
// A - Day of Takahashi
// https://abc096.contest.atcoder.jp/tasks/abc096_a
//
#include <iostream>
using namespace std;


int solve(int m, int d) {
    if (d >= m)
        return m;
    else
        return m - 1;
}


int main(void) {
    int a, b;
    cin >> a >> b;
    int ans = solve(a, b);
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]
checked = list()
queue = deque()
for x in range(H):
    checked.append(list())
    for y in range(W):
        if map[x][y]=="#":
            checked[x].append(True)
            queue.append((x, y, 0))
        else:
            checked[x].append(False)
neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
while queue:
    x, y, res = queue.popleft()
    for dx, dy in neighbors:
        nx, ny = x+dx, y+dy
        if 0<=nx<H and 0<=ny<W:
            if not checked[nx][ny]:
                queue.append((nx, ny, res+1))
                checked[nx][ny] = True
print(res)


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

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

    string ans = "Christmas";
    if (d <= 24) ans += " Eve";
    if (d <= 23) ans += " Eve";
    if (d <= 22) ans += " Eve";

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


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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
typedef vector<int> vi;

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int main() {
    int n;
    cin >> n;
    vi nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());
    vi sign(n);
    // case1: down-up-down-up...
    sign[0] = -1;
    sign[n - 1] = (n & 1) ? -1 : 1;
    int minus = 1;
    for (int i = 1; i < n - 1; ++i) {
        sign[i] = 2 * minus;
        minus = -minus;
    }
    sort(sign.begin(), sign.end());
    ll ans1 = 0;
    for (int i = 0; i < n; ++i) {
        ans1 += sign[i] * nums[i];
    }
    // case2: up-down-up-down...
    sign[0] = 1;
    sign[n - 1] = (n & 1) ? 1 : -1;
    minus = -1;
    for (int i = 1; i < n - 1; ++i) {
        sign[i] = 2 * minus;
        minus = -minus;
    }
    sort(sign.begin(), sign.end());
    ll ans2 = 0;
    for (int i = 0; i < n; ++i) {
        ans2 += sign[i] * nums[i];
    }
    ll ans = max(ans1, ans2);
    cout << ans << endl;
    return 0;

}

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

int main()
{



    string s;
    cin >> s;

    int a = s[0]-'0',b=s[1] - '0',c = s[2] - '0',d = s[3] - '0';


    if(a-b-c-d==7) printf ("%d-%d-%d-%d=7\n",a,b,c,d);else if(a-b-c+d==7) printf ("%d-%d-%d+%d=7\n ",a,b,c,d);else if(a-b+c-d==7) printf ("%d-%d+%d-%d=7\n",a,b,c,d);else if(a-b+c+d==7) printf ("%d-%d+%d+%d=7\n",a,b,c,d);else if(a+b-c-d==7) printf ("%d+%d-%d-%d=7\n",a,b,c,d);else if(a+b-c+d==7) printf ("%d+%d-%d+%d=7\n",a,b,c,d);else if(a+b+c-d==7) printf ("%d+%d+%d-%d=7\n",a,b,c,d);else if(a+b+c+d==7) printf ("%d+%d+%d+%d=7\n",a,b,c,d);
    return 0;
}


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

int main(void){
  int a,b;
  string op;
  while(1){
    cin >> a >> op >> b;
    if(op.compare("?")==0){
      break;
    }else if(op.compare("+")==0){
      printf("%d\n", a+b);
    }else if(op.compare("-")==0){
      printf("%d\n", a-b);
    }else if(op.compare("*")==0){
      printf("%d\n", a*b);
    }else{
      printf("%d\n", a/b);
    }
  }
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
#define db double
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define pb push_back
#define er erase
#define SZ(x) (int) x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mkp make_pair
#define dmin(x, y) ((x) < (y) ? (x) : (y))
#define dmax(x, y) ((x) > (y) ? (x) : (y))
#define checkmax(x, y) ((x) < (y) ? ((x) = (y)) : (x))
#define checkmin(x, y) ((x) > (y) ? ((x) = (y)) : (x))
#define ms(data_name) memset(data_name, 0, sizeof(data_name))
#define msn(data_name, num) memset(data_name, num, sizeof(data_name))
#define For(i, j) for(reg int (i) = 1; (i) <= (j); ++(i))
#define For0(i, j) for(reg int (i) = 0; (i) < (j); ++(i))
#define Forx(i, j, k) for(reg int (i) = (j); (i) <= (k); ++(i))
#define Forstep(i , j, k, st) for(reg int (i) = (j); (i) <= (k); (i) += (st))
#define fOR(i, j) for(reg int (i) = (j); (i) >= 1; (i)--)
#define fOR0(i, j) for(reg int (i) = (j) - 1; (i) >= 0; (i)--)
#define fORx(i, j, k) for(reg int (i) = (k); (i) >= (j); (i)--)
#define tour(i, u) for(reg int (i) = head[(u)]; (i) != -1; (i) = nxt[(i)])
using namespace std;
char ch, B[1 << 20], *S = B, *T = B;
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T) ? 0 : *S++)
#define isd(c) (c >= '0' && c <= '9')
int rdint() {
  int aa, bb;
  while(ch = getc(), !isd(ch) && ch != '-');
  ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
  while(ch = getc(), isd(ch))
    aa = aa * 10 + ch - '0';
  return bb ? aa : -aa;
}
ll rdll() {
  ll aa, bb;
  while(ch = getc(), !isd(ch) && ch != '-');
  ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
  while(ch = getc(), isd(ch))
    aa = aa * 10 + ch - '0';
  return bb ? aa : -aa;
}
const int MAXN = 1e6 + 10;
char s[MAXN];
int dp[MAXN][2];
inline void work() {
  scanf("%s", s + 1);
  s[0] = '0';
  int len = strlen(s + 1);
  dp[len][0] = s[len] - '0';
  dp[len][1] = 10 - (s[len] - '0');
  fOR0(i, len) {
    dp[i][0] = dmin(dp[i + 1][0] + (s[i] - '0'), dp[i + 1][1] + (s[i] - '0' + 1));
    dp[i][1] = dmin(dp[i + 1][0] + 10 - (s[i] - '0'), dp[i + 1][1] + 10 - (s[i] - '0' + 1));
  }
  printf("%d\n", dmin(dp[0][0], dp[0][1]));
}
int main() {
  // freopen("input.txt", "r", stdin);
  work();
  return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int A[210];

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

    while(true){
        int M, Nmn, Nmx;
        std::cin >> M >> Nmn >> Nmx;
        if(!M){break;}
    
        for(int i=0;i<M;++i){
            std::cin >> A[i];
        }

        reverse(A, A+M);
        
        int res = Nmx;
        for(int i=Nmx;i>=Nmn;--i){
            if(A[M-i] - A[M-i-1] > A[M-res] - A[M-res-1]){
                res = i;
            }
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3108
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    println(if (a*b < c*d) c*d else a*b)
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 505
#define mod 1000000007


int main(){
    fastio;
    int d,l,r;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0) cnt++;
    }
    cout<<cnt<<"\n";
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int max_num = 555556;
	int prime[max_num];
	fill(prime, prime + max_num, true);
	prime[0] = prime[1] = false;
	for(int i = 0; i < max_num; i++) {
		if(prime[i]) {
			for(int j = i * 2; j < max_num; j += i) {
				prime[j] = false;
			}
		}
	}
	int n;
	cin >> n;
	vector<int> ans;
	for(int i = 0; i < max_num; i++) {
		if(prime[i] && i % 5 == 1) {
			ans.push_back(i);
		}
		if((int)ans.size() == n) break;
	}
	for(int i = 0; i < n; i++) {
		if(i > 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;	
}

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

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)
  


Measured memory_bytes: 68540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)

typedef int Capacity;
typedef int Weight;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    int n, t;
    vector<bool> vis;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    FordFulkerson(int n)
        : n(n), cap(n, vector<Capacity>(n)),
          flow(n, vector<Capacity>(n)), g(n, vector<int>()),
          inf(numeric_limits<Capacity>::max()){}
    FordFulkerson(const Graph &graph){
        *this = FordFulkerson(graph.size());
        rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    Capacity solve(int s, int t){
        this->t = t;
        Capacity res = 0, inc = 1;
        while(inc > 0){
            vis.assign(n, false);
            res += (inc = augment(s, inf));
        }
        return res;
    }
    Capacity augment(const int &v, const Capacity &lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &i : g[v]){
            if(vis[i] || flow[v][i] == cap[v][i]) continue;
            Capacity f = augment(i, min(lim, cap[v][i] - flow[v][i]));
            flow[v][i] += f;
            flow[i][v] -= f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    FordFulkerson fs(g);
    cout << fs.solve(0,N-1) << endl;
}

Measured memory_bytes: 1356
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;

int main()
{
    int n,k,ans;
    scanf("%d %d",&n,&k);
    int a[n];

    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    
ans=(n-1)/(k-1);

    if((n-1)%(k-1)!=0)
    {
        ans=ans+1;
    }

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

Measured memory_bytes: 512
#include<stdio.h>
int abs(int x){
if(x<0)x*=-1;
  return x;
}
int main(){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
  printf("Yes");
  }
  else printf("No");
  return 0;

}

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int, int>> que;

    int num_road = 0;
    rep(i, H) cin >> field.at(i);
    rep(y, H) rep(x, W)
    {
        if (field.at(y).at(x) == '.') {
            num_road++;
        }
    }

    dist.at(0).at(0) = 0;
    que.push(make_pair(0, 0));

    while (!que.empty()) {
        auto v = que.front();
        que.pop();
        int x = v.first;
        int y = v.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= W || ny < 0 || ny >= H)
                continue;
            if (field.at(ny).at(nx) == '#')
                continue;
            if (dist.at(ny).at(nx) == -1) {
                dist.at(ny).at(nx) = dist.at(y).at(x) + 1;
                que.push(make_pair(nx, ny));
            }
        }
    }

    int min_dist = dist.at(H - 1).at(W - 1);
    if (min_dist == -1) {
        cout << -1 << endl;
    } else {
        cout << num_road - (min_dist + 1) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int ll
typedef long long ll;
const int N=2e5+5;
ll ma[N*4];
int n,q;

void update(int l,int r,int id,int i,int v){
    if(l==r){
        ma[id]=v;
        return;
    }
    int mid=(l+r)>>1;
    ma[id]=0;
    if(i<=mid)update(l,mid,id*2,i,v);
    else update(mid+1,r,id*2+1,i,v);
    if(ma)
    ma[id]=max(ma[id*2],ma[id*2+1]);
}
/*
ll query_mi(int l,int r,int ql,int v,int id){
    if(r<ql)return -1;
    if(l==r){
        if(ma[id]>=v)return l;
        else return -1;
    }
    int mid=(l+r)>>1;
    int ans=-1;
    if(ql<mid)ans=query_mi(l,mid,ql,v,id*2);
    if(ans!=-1)return ans;
    ans=query_mi(mid+1,r,ql,v,id*2+1);
    return ans;
}
*/vector<int> a;
ll mi(int x,int v){
    for(int i=x;i<=n;i++){
        if(a[i]>=v)return i;
    }
    return n+1;
}
/*
ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;
    if(ql<mid)query_ma(l,mid,ql,qr,id*2);
    if(qr>mid)query_ma(mid+1,r,ql,qr,id*2+1);
    ma[id]=max(ma[id*2],ma[id*2+1]);
    return ma[id];
}
*/

ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;

    if(qr<=mid){
        return query_ma(l,mid,ql,qr,id*2);
    }
    else if(ql>=mid+1){
        return query_ma(mid+1,r,ql,qr,id*2+1);
    }
    else{
        int a=query_ma(l,mid,ql,qr,id*2),b=query_ma(mid+1,r,ql,qr,id*2+1);
        return max(a,b);
    }
}

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

    cin>>n>>q;
    a.resize(n+1);
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        a[i]=x;
        update(1,n,1,i,x);
    }
    while(q--){
        int mode,x,y;cin>>mode>>x>>y;
        if(mode==1){
            update(1,n,1,x,y);
            a[x]=y;
        }
        else if(mode==2){
            cout<<query_ma(1,n,x,y,1)<<endl;
        }
        else if(mode==3){
            /*
            ll ans=query_mi(1,n,x,y,1);
            if(ans==-1)cout<<n+1<<endl;
            else cout<<ans<<endl;
            */
            cout<<mi(x,y)<<endl;
        }
    }
}


Measured memory_bytes: 9012
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    ll h, n; cin >> h >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    ll sum = 0;
    rep(i, n) sum += a.at(i);
    if(sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

ll ap[26];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      
    ll n;
    cin>>n;
    string s;
    cin>>s;
    // ll ap[26];
    ll k=0;
    // ll cnt = 1;
    for(ll i=0;i<n;i++){
      ap[s[i]-'a']++;
    }
    ll ans = 1;

    for(ll i=0;i<26;i++){
      ans=  (ans*(ap[i]+1))%mod;
    }

    ans = (ans-1+mod)%mod;

    cout<<ans;


    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  if(N==1){
    cout << "Yes";
    return 0;
  }
  ll i;
  vector<ll> H(N);
  for(i=0;i<N;i++){
    cin >> H[i];
  }
  for(i=N-1;i>0;i--){
    if(H[i-1] > H[i]+1){
      cout << "No";
      return 0;
    }else if(H[i-1] == H[i]+1){
      H[i-1]--;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
using pl = pair<ll,ll>;
signed main(){
	ll n,m,a,b; cin>>n>>m>>a>>b;
	rep(i,0,n){
		rep(j,0,m){
			if(i<b && j<a)cout<<0;
			else if(i<b || j<a)cout<<1;
			else cout<<0;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int N;
vector<int> U,V;
vector<ll> W;
vector<int> Color;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
  U.assign(N,0);
  V.assign(N,0);
  W.assign(N,0);
  REP(i,N) {
    cin >> U[i] >> V[i] >> W[i];
    U[i]--;
    V[i]--;
    W[i]%=2;
    }
  Color.assign(N,0);
}

map<int, map<int,int> > toList;
int bfs(int x, int p){
  Color[x] = (p==-1) ? 0 : ((toList[p][x]==0) ? Color[p] : Color[p]^1) ;
  for(auto next:toList[x]) {
    if(next.first==p) continue;
    bfs(next.first, x);
    }
  return 0;
}

int solve(){
  REP(i,N) {
    toList[U[i]][V[i]] = W[i];
    toList[V[i]][U[i]] = W[i];
  }
  bfs(0,-1);
  REP(i,N) cout << Color[i] << endl;
  return 0;
}

int main()
{
  input();
  solve();
  return 0;
}


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

namespace ABC044_D
{
    class Program
    {
        static void Main()
        {
            var n = Utility.ReadLong();
            var s = Utility.ReadLong();
            long ans = 0;
            if (n <= s)
            {
                ans = F(n + 1, n) == s ? n + 1 : -1;
            }
            else
            {
                ans = EnumerateDivisor(n - s).Where(v => F(v + 1, n) == s).DefaultIfEmpty(-2).Min() + 1;
            }

            Console.WriteLine($"{ans}");
        }

        static long F(long b, long n)
        {
            return n < b ? n : F(b, n / b) + n % b;
        }

        static IEnumerable<long> EnumerateDivisor(long source)
        {
            var sqrt = Math.Sqrt(source);
            for (int i = 1; i <= sqrt; i++)
            {
                if (source % i == 0)
                {
                    yield return i;
                    yield return source / i;
                }
            }
        }
    }

    public static class Utility
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();

        public static IEnumerable<int> EnumerateDigits(int value)
        {
            while (value > 0)
            {
                yield return value % 10;
                value /= 10;
            }
        }

        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(v => int.Parse(v));
    }
}


Measured memory_bytes: 13396
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007

ll add(ll a, ll b)  { return ((a % mod + b % mod) % mod); }
ll sub(ll a, ll b)  { return ((a % mod - b % mod) % mod); }
ll mult(ll a, ll b) { return (((a % mod) * (b % mod)) % mod); }

void solve()
{
    ll n;
    cin >> n;
    ll a[n];

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

    for (ll i = n - 2 ; i >= 0 ; --i) {
        b[i] = add(b[i] , b[i + 1]);
    }

    ll f= 0 ;

    for(ll i=0 ; i < n - 1 ; ++i) {

        ll z = mult(a[i] , b[i+1]);
        f = add(f , z);
    }

    cout << f % mod;

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    //TEST
    solve();
}



Measured memory_bytes: 6736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
signed main(){
  ll t;
  ll a,b,c,d,g,v;
  cin >> t;
  for(int i=0;i<t;i++){
    string ans;
    cin >> a >> b >> c >> d;
    if(b>a||(b<=a&&b>d)){
      ans = "No";
    }else if((b<=a&&b<=d)&&c>=b){
      ans ="Yes";
    }else{
      g = gcd(b,d);
      v = b-g+(a%g);
      if(v<=c){
        ans = "Yes";
      }else{
        ans = "No";
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main()
{
    int a, b;
    char cp;

    cin >> a >> cp >> b;
    if (cp == '+')
        cout << (a + b) << endl;
    else if (cp == '-')
        cout << (a - b) << endl;

    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    vector<int64_t> v(n);
    for (auto&& vv : v) {
        cin >> vv;
    }

    vector<pair<int64_t, int64_t>> dp(n + 1);
    dp[0] = {0L, 1L};
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, n) | reversed) {
            if (dp[j].second == 0L) {
                continue;
            }
            if (dp[j + 1].first < dp[j].first + v[i]) {
                dp[j + 1].first = dp[j].first + v[i];
                dp[j + 1].second = dp[j].second;
            } else if (dp[j + 1].first == dp[j].first + v[i]) {
                dp[j + 1].second += dp[j].second;
            }
        }
    }

    constexpr long double EPS = 1.e-3;
    long double avg = 0;
    int64_t w = 0;
    for (auto i : irange(a, b + 1)) {
        if (avg + EPS < dp[i].first / (long double)i) {
            avg = dp[i].first / (long double)i;
            w = dp[i].second;
        } else if (avg - EPS < dp[i].first / (long double)i) {
            w += dp[i].second;
        }
    }

    cout << setprecision(20) << avg << endl;
    cout << w << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import itertools as it

def li():
    return [int(x) for x in input().split()]

N = int(input())
L = li()

# 組み合わせ列挙
com = it.combinations(L, 3)
com_list = list(com)

cnt = 0
for l in com_list:
    unique_l = len(set(l))
    if unique_l != 3:
        continue
    a, b, c = l[0], l[1], l[2]
    if a < b + c and b < c + a and c < a + b:
        cnt += 1

print(cnt)

Measured memory_bytes: 90732
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define LL long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)
#define YES "Yes"
#define NO "No"

using namespace std;

typedef pair<int, int> P;

class CGuessTheNumber {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        LL N, M;
        cin >> N >> M;
        LL *n = new LL[N];
        for (LL i = 0; i < N; ++i) {
            n[i] = -1;
        }

        for (LL i = 0; i < M; ++i) {
            LL s, c;
            cin >> s >> c;
            if (n[s - 1] != -1 && n[s - 1] != c) {
                cout << -1;
                return;
            }
            n[s - 1] = c;
        }
        if (N > 1 && n[0] == 0) {
            cout << -1;
            return;
        }

        if (N == 1) {
            cout << (n[0] == -1 ? 0 : n[0]);
            return;
        }

        cout << (n[0] == -1 ? 1 : n[0]);

        for (LL i = 1; i < N; ++i) {
            cout << (n[i] == -1 ? 0 : n[i]);
        }
    }
};

int main() {
	CGuessTheNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


void solve(std::string S_A, std::string S_B, std::string S_C){
    ll a=0, b=0, c=0;
    char who='a';
    while(1){
        if(who == 'a'){
            if (a==S_A.length()){
                cout << 'A' << endl;
                break;
            }
            who = S_A[a];
            a++;
            
            continue;
        }
        if(who == 'b'){
            if (b==S_B.length()){
                cout << 'B' << endl;
                break;
            }
            who = S_B[b];
            b++;
            
            continue;
        }
        if(who == 'c'){
            if (c==S_C.length()){
                cout << 'C' << endl;
                break;
            }
            who = S_C[c];
            c++;
            
            continue;
        }
    }
}

int main(){
    std::string S_A;
    std::cin >> S_A;
    std::string S_B;
    std::cin >> S_B;
    std::string S_C;
    std::cin >> S_C;
    solve(S_A, S_B, S_C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int push_comp(int v, vector<int> & comp_up) {
	int C = v;
	while(comp_up[C] != C) C = comp_up[C];
	while(comp_up[v] != C) {
		int up = comp_up[v];
		comp_up[v] = C;
		v = up;
	}
	return C;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, H, W;
	cin >> N >> H >> W;
	vector< pair<int, pair<int, int> > > V(N);
	for(int i = 0; i < N; i++) cin >> V[i].ss.ff >> V[i].ss.ss >> V[i].ff;
	sort(begin(V), end(V));
	vector<int> comp_up(H+W), comp_sz(H+W, 1);
	for(int i = 0; i < H+W; i++) comp_up[i] = i;
	vector<char> comp_done(H+W, 0);
	cat ans = 0;
	for(int i = N-1; i >= 0; i--) {
		int u = V[i].ss.ff, v = V[i].ss.ss + H;
		u = push_comp(u, comp_up);
		v = push_comp(v, comp_up);
		if(comp_done[u] && comp_done[v]) continue;
		ans += V[i].ff;
		if(u == v) comp_done[u] = 1;
		else {
			if(comp_sz[u] > comp_sz[v]) swap(u, v);
			comp_up[u] = v;
			comp_sz[v] += comp_sz[u];
			comp_done[v] |= comp_done[u];
		}
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3200
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	double a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
ans=[]
if k>=(b-a+1)/2:
  ans=list(range(a,b+1))
else:
  ans=list(range(a,a+k))
  ans_back=list(range(b+1-k,b+1))
  ans.extend(list(range(b+1-k,b+1)))
for i in ans:
  print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n, h, w; cin >> n >> h >> w;
  ll ans = 0;
  REP(i,n){
    ll a,b; cin >> a >> b;
    if(a>=h && b>=w) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll n,k,a[100000];
ll dpt[100000];
ll dp(ll i){
	if(dpt[i]!=-1){
		return dpt[i];
	}
	if(i==n-1){
		return 0;
	}
	dpt[i]=(abs(a[i]-a[i+1])+dp(i+1));
	for(int j=i+1;j<=min(i+k,n-1);++j){
		dpt[i]=min(dpt[i],abs(a[i]-a[j])+dp(j));
	}
	return dpt[i];
}
int main(){
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for(int i=0;i<n;++i){
    	cin>>a[i];
    }
   memset(dpt,-1,sizeof(dpt));
    cout<<dp(0);
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> vec(n);

	for (int i = 0; i < n; i++)
	{
		cin >> vec.at(i).first.first >> vec.at(i).first.second;
		vec.at(i).first.second *= -1;
		vec.at(i).second = i + 1;
	}

	sort(vec.begin(), vec.end());

	for (int i = 0; i < n; i++)
	{
		cout << vec.at(i).second << endl;
	}
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    ll sum = 0, lim = 0, rmv = 0;
    REP(i, 1, n+1) {
        sum += i;
        if(sum >= n) {
            lim = i;
            rmv = sum-n;
            break;
        }
    }
    for(int i = 1; i <= lim; i++) {
        if(i == rmv) continue;
        cout << i << '\n';
    }
    return 0;
}

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

int main(){

 int64_t A,b;
 cin>>A;
 double B;
 cin>>B;

 b=100*B+0.5;
 int64_t ans=A*b/100;
 cout<<ans<<endl;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArray = br.readLine().split(" ");


        int a = Integer.parseInt(strArray[0]);
        int b = Integer.parseInt(strArray[1]);
        if (a >= b) {
            System.out.println(getGCD(a, b));
        } else {
            System.out.println(getGCD(b, a));
        }
    }

    public static int getGCD(int a, int b) {
        if (a % b == 0) return b;
        else if (a < b) {
            return getGCD(a, b % a);
        }
        else return getGCD(b, a % b);
    }
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    string S;
    cin >> S;
    string R = S;
    reverse(R.begin(), R.end());
    bool kaibun = true;

    if (S != R)
    {
        kaibun = false;
    }

    string S_sub = S.substr(0, (S.size() - 1) / 2);
    string R_sub = S_sub;
    reverse(R_sub.begin(), R_sub.end());
    if (S_sub != R_sub)
    {
        kaibun = false;
    }
    S_sub = S.substr(0, (S.size() + 3) / 2);
    R_sub = S_sub;
    reverse(R_sub.begin(), R_sub.end());
    if (kaibun)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long double ld;

int n, a[305], br[4];
ld dp[305][305][305];

ld rek(int x, int y, int z){
	//cout << x << ' ' << y << ' ' << z << endl;
	if(!x && !y && !z)
		return 0;
	ld &ret = dp[x][y][z];
	if(ret != -1)
		return ret;
	ret = 0;
	if(x){
		ret += rek(x - 1, y, z) * (ld)x;
	}
	if(y){
		ret += rek(x + 1, y - 1, z) * (ld)y;
	}
	if(z){
		ret += rek(x, y + 1, z - 1) * (ld)z;
	}
	ret += n;
	ret /= (ld)(x + y + z);
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i];
	br[a[i]]++;
}
for(int i = 0 ; i <= 300 ; ++i){
	for(int j = 0 ; j <= 300 ; ++j){
		for(int v = 0 ; v <= 300 ; ++v){
			dp[i][j][v] = -1;
		}
	}
}
cout << fixed << setprecision(10) << rek(br[1], br[2], br[3]) << endl;

return 0;
}



Measured memory_bytes: 438528
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long march[5]={0};
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M')march[0]++;
        if(s[0]=='A')march[1]++;
        if(s[0]=='R')march[2]++;
        if(s[0]=='C')march[3]++;
        if(s[0]=='H')march[4]++;
    }
    long ans=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans+=march[i]*march[j]*march[k];
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x = a+b;
    int y = a+c;
    int z = b+c;
    if(x<y && x<z){cout << x << endl;}
    else if(y<x && y<z){cout << y << endl;}
    else if(z<x && z<y){cout << z << endl;}
    else if(z==x && z==y && x==y){cout << x << endl;}

    return 0;
}

Measured memory_bytes: 256
n=int(input())
ans=0
S=[]
for i in range(n):
    s=int(input())
    ans+=s
    S.append(s)
if ans%10!=0:
    print(ans)
else:
    S.sort()
    for j in range(n):
        if S[j]%10!=0:
            ans-=S[j]
            print(ans)
            break
    if ans==sum(S):
        print(0)
    


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

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

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<string> w(n);
	cin >> w;
	map<string, int> mp;
	for (int i = 0; i < n-1; i++) {
		if (w[i].back() != w[i+1].front() or mp[w[i]] > 0) {
			cout << "No" << endl;
			return 0;
		}
		mp[w[i]]++;
	}
	if (mp[w.back()] > 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
h = [0 for i in range(N)]

for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

ans = 0
ans_cx = 0
ans_cy = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] != 0:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                break
        
        can_be_ans = True
        for i in range(N):
            if h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0):
                can_be_ans = False
                break

        if can_be_ans:
            if ans < H:
                ans = H
                ans_cx = cx
                ans_cy = cy

print(ans_cx, ans_cy, ans)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD =  1000000007;
const ll INF = 1LL << 60;


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

    ll y = 1000;
    for(int i = 0; i < n - 1; i++){
        ll s = 0;
        if(a[i] < a[i + 1]) s = y / a[i];
        y += (a[i + 1] - a[i]) * s;
    }
    cout << y << endl;

    return 0;
}


Measured memory_bytes: 3540
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];
		
		int val = int.Parse(Console.ReadLine());
		int n=1;
		int re=1;
		for(int i=0;i<8;i++){
			if(val<n){re=n/2;break;}
		n=n*2;
		}

		Console.WriteLine(re);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

int main(){
  string s;
  long long n;
  cin >> s;
  n=s.size();
  long long i,c,p;
  p=0;
  c=0;
  i=n-1;
  while(i>=0){
    if(s.at(i)=='A'){
      c=c+p;
      i--;
    }else{
      if(i<=1){
        p=0;
        i--;
      }else{
        if(s.at(i)=='C'&&s.at(i-1)=='B'){
          p++;
          i=i-2;
        }else{
          p=0;
          i--;
        }
      }
    }
  }
  
  cout << c << endl;
}

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

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

  ll n,m,s; cin>>n>>m>>s;
  struct Train {
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }
  for (int i = 0; i < n; i++) {
    int c,d; cin>>c>>d;
    graph[i].emplace_back(i,-c,d);
  }
  constexpr ll MAX = 200;
  constexpr ll INF = 1e18;
  vector<array<ll, MAX+1>> dp(n);
  for (auto& arr:dp) arr.fill(INF);
  dp[0][min(s,MAX)] = 0;
  priority_queue<Train, vector<Train>, greater<>> qs;
  qs.emplace(0,s,0);
  while (not qs.empty()) {
    auto [s,c,d] = qs.top(); qs.pop();
    if (d > dp[s][min(c,MAX)]) continue;
    for (auto t:graph[s]) {
      if (c-t.c<0) continue;
      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;
      dp[t.s][min(c-t.c,MAX)] = d+t.d;
      qs.emplace(t.s, c-t.c, d+t.d);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3852