akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000000000000000;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//
 
 
 
int main() {
 
	fast_cin();
 
	string s;
	cin >> s;
	
	if (s == "SUN"){
		cout << 7 << endl;	
	}else if (s == "MON"){
		cout << 6 << endl;	
	}else if (s == "TUE"){
		cout << 5 << endl;	
	}else if (s == "WED"){
		cout << 4 << endl;	
	}else  if (s == "THU"){
		cout << 3 << endl;	
	}else if (s == "FRI"){
		cout << 2 << endl;	
	}else if (s == "SAT"){
		cout << 1 << endl;	
	} 
}


Measured memory_bytes: 256
def answer():
    N = int(input())
    distances = list(map(int, input().split()))

    result = 1
    mod = 998244353

    if distances[0] != 0:
        result = 0
    elif 0 in distances[1:]:
        result = 0
    else:
        distances.sort()
        maximum = distances[-1]
        counts = [0] * (maximum + 1)
        counts[0] = 1
        for d in distances[1:]:
            counts[d] += 1
            result *= counts[d-1]
            result %= mod

    print(result)


if __name__ == '__main__':
    answer()


Measured memory_bytes: 14396
nm = list(map(int, input().split()))
h=list(map(int, input().split()))
tenbou={}
for i in range(1,nm[0]+1):
    tenbou[str(i)]=h[i-1]


for i in range(nm[1]):
    ab  = list(map(int, input().split()))
    if h[ab[0]-1]<h[ab[1]-1]:
       tenbou[str(ab[0])]=0
    
    elif h[ab[0]-1]>h[ab[1]-1]:
        tenbou[str(ab[1])]=0
    else:
        tenbou[str(ab[0])]=0
        tenbou[str(ab[1])]=0

waruitenbou=[k for k, v in tenbou.items() if v == 0]
print(nm[0]-len(waruitenbou))


Measured memory_bytes: 27292
import sys
from heapq import heappush, heappop

class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)  # The number of nodes under the target node.
        self.weight = [0] * (n+1)  # Distance from the root

    def find(self, x):
        if self.root[x] == x:
            return x
        else:
            y = self.find(self.root[x])
            self.weight[x] += self.weight[self.root[x]]
            self.root[x] = y
            return self.root[x]

    def unite(self, x, y, w=0):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.root[rx] = ry
            self.size[ry] += self.size[rx]
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.root[ry] = rx
            self.size[rx] += self.size[ry]
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def diff(self, x, y):
        return self.weight[y] - self.weight[x]


def kruskal(D, n):
    G = []
    UF = UnionFind(n)
    while len(D) > 0:
        cost, n1, n2 = heappop(D)

        if UF.is_same(n1, n2):
            continue
        else:
            G.append((cost, n1, n2))
            UF.unite(n1, n2)

    return G

def main():
    input = sys.stdin.readline
    N = int(input())
    C = []
    for i in range(N):
        x, y = map(int, input().split())
        C.append((i, x, y))

    X = sorted(C, key=lambda x: x[1])
    Y = sorted(C, key=lambda x: x[2])

    D = []
    for i in range(N-1):
        a, xa, _ = X[i]
        b, xb, _ = X[i+1]

        c, _, yc = Y[i]
        d, _, yd = Y[i+1]


        heappush(D, (xb - xa, a, b))
        heappush(D, (yd - yc, c, d))

    G = kruskal(D, N)
    ans = 0
    for g in G:
        ans += g[0]

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 52584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


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

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int n, m; cin >> n >> m;
    P ab[m];
    REP(i, m) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+m);

    int cnt = 0;
    int now = 0;
    REP(i, m) {
        int l = ab[i].second;
        int r = ab[i].first;
        if (l >= now) {
            now = r;
            cnt++;
        }
    }

    cout << cnt << "\n";

    return 0;
}


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

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

using namespace std;

typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n;

  while (true) {
    cin >> n;
    if (!n) { break; }

    vector< pair<int, int> > pos(n);
    pos[0] = make_pair(0, 0);
    rep(i, n-1) {
      int ni, di;
      cin >> ni >> di;
      int px = pos[ni].first;
      int py = pos[ni].second;
      if (di == 0) {
        pos[i+1] = make_pair( px-1, py );
      } else if (di == 1) {
        pos[i+1] = make_pair( px, py-1 );
      } else if (di == 2) {
        pos[i+1] = make_pair( px+1, py );
      } else {
        pos[i+1] = make_pair( px, py+1 );
      }
    }
    int max_x = 0, min_x = 0, max_y = 0, min_y = 0;
    rep(i, n) {
      int x = pos[i].first;
      int y = pos[i].second;
      max_x = max(max_x, x);
      max_y = max(max_y, y);
      min_x = min(min_x, x);
      min_y = min(min_y, y);
    }
    cout << max_x-min_x+1 << " " << max_y-min_y+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3068
#!/usr/bin/env ruby

n = gets.chomp.to_i
ary = gets.chomp.split(' ').map(&:to_i)

def max(a, b)
  a > b ? a : b
end

right_gcd = []
ary.each_with_index do |num, index|
  right_gcd[index] = if index.zero?
                       num
                     else
                       right_gcd[index - 1].gcd(num)
                     end
end

left_gcd = []
ary.reverse.each_with_index do |num, index|
  left_gcd[index] = if index.zero?
                      num
                    else
                      left_gcd[index - 1].gcd(num)
                    end
end
left_gcd = left_gcd.reverse

ans = 0

0.step(n - 1) do |i|
  ans = if i.zero?
          max(ans, left_gcd[i + 1])
        elsif i == n - 1
          ans = max(ans, right_gcd[i - 1])
        else
          max = max(ans, right_gcd[i - 1].gcd(left_gcd[i + 1]))
        end
end

puts ans


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {


			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
			var aArray = retreiveLongArray();

			var workDay = aArray.Sum();
			var asoberuDay = N - workDay;

			//答えの出力
			var ans = asoberuDay < 0? -1: asoberuDay;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];

  map<string, int> ans;
  for (int i = 0; i < N; i++) {
    ans[s[i]]++;
  }

  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;

  return 0;
}

Measured memory_bytes: 6432
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int m, n = 2;
  scanf("%d", &m);
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> dp(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      dp[i][j] = 0;
      if (i - 1 >= 0) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      }
      if (j - 1 >= 0) {
        dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      }
      dp[i][j] += a[i][j];
    }
  }
  printf("%d\n", dp[n - 1][m - 1]);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cerr <<"at line "<< __LINE__ <<", " << #x << " = " << x << "\n"
using namespace std;

int main()
{
    int n, k;
    cin >> k >> n;
    int a[n];
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    vector<int> segments;
    for(int i=0; i<n-1; i++) segments.push_back(a[i+1]-a[i]);
    segments.push_back(k-a[n-1]+a[0]);
    sort(segments.begin(), segments.end());
    int ans = 0;
    for(int i=0; i<(int)segments.size()-1; i++) ans += segments[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

ll gcd(ll a,ll b){//最大公約数
  if(a<b){
    swap(a,b);
  }
  if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
ll lcm(ll a, ll b)
{
  ll numgcd=gcd(a, b);
  ll num1=a/numgcd;
  ll num2=b/numgcd;
    return (num1*num2*numgcd);
}
int main(void){
  ll n,k;
  cin>>n>>k;
  if(n*500>=k){
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

unsigned long long f(unsigned long long a) {
     unsigned long long res[] = {a,1,a+1,0};
     return res[a&3];
}

unsigned long long getXor(unsigned long long a,unsigned long long b) {
     return f(b)^f(a-1);
}

int main()
{
    unsigned long long A, B;
    cin >> A >> B;

    cout << getXor(A, B);

    return 0;
}


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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    r(i, n) cin >> v[i];
    int q, x, p;
    cin >> q;
    while (q--) {
        cin >> x;
        p = lower_bound(v.begin(), v.end(), x) - v.begin();
        if (p != n && v[p] == x) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


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

using namespace std;

struct Node {
  int data;
  Node *prev, *next;
} *nil;

void init () {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert (int n) {
  Node *node = (Node *)malloc(sizeof(Node));
  node->data = n;
  node->next = nil->next;
  nil->next->prev = node;
  nil->next = node;
  node->prev = nil;
}

void deleteNode (Node *node) {
  if (node == nil)
    return;

  node->prev->next = node->next;
  node->next->prev = node->prev;
  free(node);
}

void deleteFirst () {
  deleteNode(nil->next);
}

void deleteLast () {
  deleteNode(nil->prev);
}

Node* searchList (int n) {
  Node *current = nil->next;

  while (current != nil && current->data != n) {
    current = current->next;
  }

  return current;
}

int main () {
  int n, m;
  char s[100];

  init();

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s", s);

    if (strcmp(s, "insert") == 0) {
      scanf("%d", &m);
      insert(m);
    } else if (strcmp(s, "delete") == 0) {
      scanf("%d", &m);
      deleteNode(searchList(m));
    } else if (strcmp(s, "deleteFirst") == 0) {
      deleteFirst();
    } else if (strcmp(s, "deleteLast") == 0) {
      deleteLast();
    }
  }

  bool first = true;
  Node *head = nil->next;

  while (head != nil) {
    if (first)
      first = false;
    else
      printf(" ");

    printf("%d", head->data);
    head = head->next;
  }
  
  printf("\n");

  return 0;
}


Measured memory_bytes: 34404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, i;
  cin >> A >> B >> C >> D;
  i = A + B - ( C + D );
  if (i > 0){
  cout << "Left" << endl;
  }
  else if(i < 0 ){
  cout << "Right" <<endl;
  }
  else{
  cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
 

signed main(){
   
   int n,h[111111];
   cin>>n;
   int max=0,ans=0;
   rep(i,n){
   		cin>>h[i];
   		if(max<=h[i])ans++;
   		max=std::max(max,h[i]);
   }
   cout<<ans<<endl;
   
   
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int N, co;
	int sum = 0;
	int mx = 0;
	scanf("%d", &N);
	
	int L[N];

	for(co = 0; co<N; co++)
	{
		scanf("%d", &L[co]);
		sum = sum + L[co];
	}
	
	for(co = 0; co<N; co++)
	{
		if(L[co] > mx) mx = L[co];
	}
	
	if (mx*2 < sum) printf("Yes");
		else printf("No");

		return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(K);
    int w = K/2;
    int s = K/2;
    if(K%2 == 1){
        s++;
    }
    COUT(s*w);
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
count = 0
while(1):
    if N*2<=M and N!=0:
        count += N
        M -= N*2
        N = 0
        continue
    elif N*2>M and M>1:
        count += M//2
        N += M//2
        M = M%2
        continue
    elif N==0 and M>=4:
        N += M//4
        M -= N*2
        continue
    else:
        break
print(count)

Measured memory_bytes: 3060
#include<stdio.h>

#pragma warning(disable:4996)


int main() {
	//入力変数の宣言
	int N, X, T;


	//入力
	scanf("%d%d%d", &N, &X, &T);


	//関数プロトタイプ
	int minute(int, int, int);


	//出力
	printf("%d", minute(N, X, T));
}


//たこ焼きを作るのにかかる時間を出力する関数
int minute(int N, int X, int T) {
	int times = 0;
	while (N > 0) {
		N -= X;
		times += T;
	}
	return times;
}


/*実行時間制限: 2 sec / メモリ制限 : 1024 MB
配点 : 100点

問題文
高橋君はたこ焼きが好きです。
たこ焼き器を使うと、1 度に最大で X 個のたこ焼きを作ることができます。
これにかかる時間は作る個数によらず T 分です。
N 個のたこ焼きを作るためには何分必要ですか？

制約
1≤N, X, T≤1000
入力は全て整数

入力
入力は以下の形式で標準入力から与えられる。
N X T

出力
N 個のたこ焼きを作るために必要な時間の最小値を整数で出力せよ。

入力例 1
20 12 6

出力例 1
12
最初の 6 分で 12 個のたこ焼きを作れ、次の 6 分でさらに 8 個のたこ焼きを作れるので、
計 12 分で 20 個のたこ焼きを作ることができます。

6 分で 12 個作れるとは、1 分で 2 個作れるという意味ではないことに注意してください。

入力例 2
1000 1 1000

出力例 2
1000000
作るのにとても時間がかかるたこ焼きのようです。*/

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

int main(){
    int n;string s;
    cin>>n>>s;
    int l = s.size();
    for(int i=0;i<l;i++){
        int x = s[i]-'A';
        x=(x+n)%26;
        s[i]=x+'A';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1000000007;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N),B(N);
    for (int i=0;i<N;++i) cin >> A[i];
    for (int i=0;i<N;++i) cin >> B[i];

    vector<vector<int>> cnt(2,vector<int>(N+1,0));
    for (int i=0;i<N;++i) ++cnt[0][A[i]],++cnt[1][B[i]];

    for (int i=1;i<=N;++i){
        if (cnt[0][i]+cnt[1][i]>N){
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';

    for (int i=0;i<N;++i){
        cnt[0][i+1]+=cnt[0][i];
        cnt[1][i+1]+=cnt[1][i];
    }

    int shift=0;
    for (int i=1;i<=N;++i) shift=max(shift,cnt[0][i]-cnt[1][i-1]);
    for (int i=0;i<N;++i) cout << B[(i+N-shift)%N] << (i+1==N?'\n':' ');
}

Measured memory_bytes: 7132
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    s = list(t)
    j = p[i] - 1
    s[j] = x[i]
    print(sum(s))

Measured memory_bytes: 9200
a=[int(input()) for _ in range(5)]
b=[]
ans=0
for i in a:
    tmp=i
    while tmp>10:
        tmp-=10
    b.append((tmp,i))
b.sort(key=lambda x:x[0])
for i in range(5):
    if i==4:
        ans+=b[4-i][1]
    else:
        ans+=b[4-i][1]+10-b[4-i][0]
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"log"
)

func main() {
	log.SetFlags(log.Lshortfile)
	var S string
	fmt.Scan(&S)
	ans := "yes"
	for i := 0; i < len(S); i++ {
		for j := i + 1; j < len(S); j++ {
			if S[i] == S[j] {
				ans = "no"
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll  long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<ll>

#define sz(x) ((int) (x).size())
#define pll pair<long long,long long>
#define mp make_pair
#define F first
#define S second
#define T int tt; cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);
 
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define display(x) for(auto i : x) cout << i << " "; cout << '\n';
#define input(x) for(int i = 0; i < n; i++) cin >> x[i];
#define make(x,y) fill(all(x), y)
#define FO(i,startLoop,n) for (int i = startLoop; i < n; i++)

#define mod 1000000007
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define ITFO(myiterator, mymap) for(auto myiterator = mymap.begin(); myiterator!=mymap.end(); ++myiterator)
using namespace std;  
 

int main()
{
    fastio
    cin.tie(NULL); cout.tie(0);
    
  
  int n, k; cin>>n>>k; vi a(n, 0), dp(n, INT_MAX); input(a);
  dp[0] = 0;
  if(k>=n){
    ll ans = INT_MAX;
    for(int i=n-2; i>=0; --i) ans = min(ans, abs(a[i] - a[n-1]));
    cout<<ans<<endl;
    return 0;
  }  

  for(int i = 0; i<k ; ++i)  dp[i] = abs(a[i] - a[0]);
  
  for(int i=k; i<n; ++i)
  {
      ll cnt = k, mm = INT_MAX, j = i-1;
      while(cnt-- && j>=0)
      {
          mm = min(mm, abs(a[i] - a[j]) + dp[j]);
          j--;
      }
      dp[i] = mm;
  }
  cout<<dp[n-1];
  cerr << "\nTime elapsed: "<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
ll modpow(ll a,ll b){
    //b=b<<1;
    ll ret = a;
    ll resu = 1;

    while(b>0){
        if(b&1){
            resu *=ret;
            resu %=MOD;
        }
        ret = ret * ret;
        ret %= MOD;
        b=b>>1;
    }
    //cout<<resu<<endl;
    return resu;
}

ll combmod(ll n,ll r){
    ll nn = 1;
    ll rr = 1;
//    if(n-r<r){
//        r=n-r;
//    }
    rep(i,r){
        nn *= (n-i);
        nn %=MOD;
        rr *= (i+1);
        rr %=MOD;
    }
    return nn*modpow(rr,MOD-2)%MOD;





}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll sou = modpow(2,n);

    sou = (MOD + sou-1)%MOD;


    ll k1 = combmod(n,a)%MOD;
    ll k2 = combmod(n,b)%MOD;
    sou = (MOD+sou-k1)%MOD;
    sou = (MOD+sou-k2)%MOD;
    cout<<sou<<endl;












    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long 
#define N 100005
typedef std::pair<int,int> pii;
int lens,lent;
char s[N],t[N];
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>s+1>>t+1;
	lens=strlen(s+1);
	lent=strlen(t+1);
	int ret=2e9;
	rep(i,1,lens-lent+1){
		int cnt=0;
		rep(j,i,i+lent-1)
			cnt+=s[j]!=t[j-i+1];
		ret=std::min(ret,cnt);
	}
	std::cout<<ret<<'\n';
	return 0;
}

Measured memory_bytes: 3660
import sys
for line in sys.stdin:
    a,b,c,d,e,f = list(map(int, line.split()))
    y = (f-(d*c)/a)/((a*e-d*b)/a)
    x = (c-b*y)/a
    print('%03.3f' % x,'%03.3f' % y)

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

#define PB push_back
using namespace std;

int const N = 1e5 + 7;
int ds[N];
int sign[N] = {};
vector<int> adj[N];

int frep(int x)
{
	if (ds[x] == x) return x;
	return ds[x] = frep(ds[x]);
}

void join(int a, int b)
{
	a = frep(a), b = frep(b);
	if (a == b) return;
	if (a > b) swap(a, b);	
	ds[b] = a;
}

void bfs(int node)
{
	queue<int> q;
	sign[1] = 1;
	q.push(node);

	while (!q.empty())
	{
		node = q.front(); q.pop();

		for (auto x : adj[node])
			if (sign[x] == 0)
			{
				sign[x] = node;
				q.push(x);
			}
	}
}

int main()
{
	for (int i = 0; i < N; ++i)
		ds[i] = i;

	int a, b;
	int n, m; cin >> n >> m;

	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		adj[a].PB(b); adj[b].PB(a);
		join(a, b);
	}

	for (int i = 2; i <= n; ++i)
		if (frep(i) != 1)
	{
			cout << "No\n";
			return 0;
	}

	bfs(1);

	cout << "Yes\n";
	for (int i = 2; i <= n; ++i)
		cout << sign[i] << '\n';
	return 0;
}

Measured memory_bytes: 10880
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int d;
ll c[26], s[370][26], last[370][26], t[370];


ll calc(){
	ll score = 0;
        REP(i, 1, d+1){
                REP(j, 0, 26){
                        if(j==t[i]-1){
                                score += s[i][j];
                                last[i][j] = i;
                        }else last[i][j] = last[i-1][j];
                        score -= c[j] * (i - last[i][j]);
                }
        }
	return score;
};

int main(){
        scanf("%d", &d);
        REP(i, 0, 26) scanf("%ld", &c[i]);
        REP(i, 1, d+1) REP(j, 0, 26) scanf("%ld", &s[i][j]);
        REP(i, 1, d+1) t[i] = 0;
        REP(i, 0, 1+d) REP(j, 0, 26) last[i][j] = 0;
	
	ll score = calc();

	ll limit = 0;
	while(true){
		REP(i, 1, d+1) REP(j, 0, 26) {
			ll prev = t[i];
			t[i] = j;
			ll newscore = calc();
			if(newscore > score) score = newscore;
			else t[i] = prev;
			if(limit++ > 50000){
				REP(i, 1, d+1) printf("%ld\n", t[i]);
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 4012
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, L = mapint()
As = list(mapint())

procces = []
for i in range(1, N):
    double = As[i-1]+As[i]
    if double>=L:
        last = i
        print('Possible')
        break
else:
    print('Impossible')
    exit()
for i in range(1, last):
    print(i)
for i in range(N-1, last-1, -1):
    print(i)

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

int main() {
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='x'){
      count++;
    }
  }
  if(count<=7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  
      
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int indexListW[][] = { {0 , 0 , 0} , { 0 , 1 , 2} , {0 , 1 , 2} , {1 , 1 , 1} , {0 , 1 , 2} , {2 , 2 , 2} , {0 , 1 , 2} ,{0 , 1 , 2} };
		int indexListH[][] = { {0 , 1 , 2} , { 0 , 0 , 0} , {0 , 1 , 2} , {0 , 1 , 2} , {1 , 1 , 1} , {0 , 1 , 2} , {2 , 2 , 2} ,{2 , 1 , 0} };

		int a[][] = new int[3][3];

		for(int i = 0 ; i < 3 ; i++) {
			for(int j = 0 ; j < 3 ; j++) {
				a[i][j] = scan.nextInt();
			}
		}

		int n = scan.nextInt();

		for(int i = 0 ; i < n ; i++) {
			int b = scan.nextInt();
			for(int j = 0 ; j < 3 ; j++) {
				for(int k = 0 ; k < 3 ;k++) {
					if(a[j][k] == b) {
						a[j][k] = -1;
						//break;
					}
				}
			}
		}

		for(int i = 0 ; i < 8 ; i++) {
			if(a[ indexListW[i][0] ][ indexListH[i][0] ] == -1 && a[ indexListW[i][1] ][ indexListH[i][1] ] == -1 && a[ indexListW[i][2] ][ indexListH[i][2] ] == -1 ) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");

	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);

using ll = int64_t;
using ull = uint64_t;

using namespace std;

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll res = min({k, a});
    k -= a;
    if (b > 0 && k > 0) {
        k -= b;
    }
    if (c > 0 && k > 0) {
        res -= min({k, c});
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 3648
//https://beta.atcoder.jp/contests/abc094/submissions/2352613

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
  int n, m, x;
  int a[105] = {0};
  int t[105] = {0};

  cin >> n >> m >> x;
  for(int i = 0; i < m; i++){
    int work;
    cin >> work;
    a[work] = 1;
  }

  int cost = 0;
  int cos2 = 0;
  for(int i = x; i <= n; i++){
    cost += a[i];
  }
  for(int i = x; i >= 0; i--){
    cos2 += a[i];
  }
  cout << min(cost, cos2) << endl;
  return 0;
}


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

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

    ll ans = 0;
    rep(i, 0, N){
        ll l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

h=list(map(int,input().split()))
G=[[] for i in range(n)]
for _ in range(m):
 x,y=map(int,input().split())
 x=x-1
 y=y-1
 G[x].append(y)
 G[y].append(x)

ans=0

for i in range(n):
 
 for j in G[i]:
  if h[j]>=h[i]:
   break
 else:
  ans=ans+1
print(ans)



Measured memory_bytes: 29488
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  ll maxNum = max({a,b,c});
  ll ans = a + b + c - maxNum;
  ans += pow(2, k) * maxNum;
  cout << ans << endl;
}

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

using namespace std ;

int a , b ;

int xorr(int n){
        int flag = n%4;
        if(flag==0) return n;
        if(flag==1) return 1;
        if(flag==2) return n+1;
        if(flag==3) return 0;
        return 0 ;
}


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

        cin >> a >> b ;
        cout << (xorr(a-1)^xorr(b)) << endl ;
         
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , k;
    cin >> a >> b >> k;
	for( int i = a ; i <= b ; i++) {
		if( i <= a + k - 1 || i >= b - k + 1 ) cout << i << endl; 
	} 
}

Measured memory_bytes: 3628
a,b,x = gets.split.map(&:to_i)

if a ** 2 * b < 2 * x
    c = 2 * (b - (x).fdiv(a ** 2))
    puts 90 - Math.atan(a/c) * 180 / Math::PI
else
    c = (2 * x).fdiv(a * b)
    puts 90 - Math.atan(c/b) * 180 / Math::PI
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

int N;
vector<vector<ll>>G;
map<P, ll>mp;
ll d[100010];
void dfs(ll v, ll p, ll cost) {
	d[v] = cost;
	for (auto nv : G[v]) {
		if (nv == p)continue;
		int a = v, b = nv;
		if (a > b)swap(a, b);
		dfs(nv, v, cost + mp[{a, b}]);
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	G.resize(N);
	rep(i, N - 1) {
		ll a, b, c; cin >> a >> b >> c; a--; b--;
		mp[{a, b}] = c;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0, -1, 0);
	rep(i, N) {
		if (d[i] % 2 == 0)cout << 1 << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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


#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()

map<pair<int,int> , int> frq;
map<pair<int,int> , int>::iterator it;

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

   ll n,cnt=0,i,j,x,y;
   cin>>n;

   fr(i,1,n)
    {
        scanf("%d",&x);
        y=i;

        if(x>y)
            swap(x,y);

        frq[mp(x,y)]++;
    }


   for(it=frq.begin();it!=frq.end();it++)
   {
       if(it->second==2)
        cnt++;
   }

    cout<<cnt<<endl;



    return 0;
}




Measured memory_bytes: 6528
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[1010][1010];
char com[1010100];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int ijk[1010][1010][4];
int v[1010][1010][4];
int cost[1010100][4];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		scanf("%s",com);
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		int sr,sc;
		int gr,gc;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='S'){sr=i;sc=j;}
			if(str[i][j]=='G'){gr=i;gc=j;}
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<4;k++)ijk[i][j][k]=999999999;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<4;k++)v[i][j][k]=0;
		for(int i=0;i<=c;i++)for(int j=0;j<4;j++)cost[i][j]=999999999;
		for(int i=c-1;i>=0;i--){
			if(com[i]=='R')cost[i][1]=i+1;
			else cost[i][3]=i+1;
			for(int j=0;j<4;j++){
				if(com[i]=='R')cost[i][(j+1)%4]=min(cost[i][(j+1)%4],cost[i+1][j]);
				else cost[i][(j+3)%4]=min(cost[i][(j+3)%4],cost[i+1][j]);
			}
		}
		priority_queue<pair<pair<int,int>,pair<int,int> > >Q;
		ijk[sr][sc][0]=0;
		Q.push(make_pair(make_pair(0,0),make_pair(sr,sc)));
		while(Q.size()){
			int co=-Q.top().first.first;
			int dir=Q.top().first.second;
			int row=Q.top().second.first;
			int col=Q.top().second.second;
			Q.pop();
			if(v[row][col][dir])continue;
			v[row][col][dir]=1;
			if(0<=row+dx[dir]&&row+dx[dir]<a&&0<=col+dy[dir]&&col+dy[dir]<b&&str[row+dx[dir]][col+dy[dir]]!='#'&&!v[row+dx[dir]][col+dy[dir]][dir]&&ijk[row+dx[dir]][col+dy[dir]][dir]>co){
				ijk[row+dx[dir]][col+dy[dir]][dir]=co;
				Q.push(make_pair(make_pair(-co,dir),make_pair(row+dx[dir],col+dy[dir])));
			}
			if(!v[row][col][(dir+1)%4]&&ijk[row][col][(dir+1)%4]>cost[co][1]&&cost[co][1]<9999999){
				ijk[row][col][(dir+1)%4]=cost[co][1];
				Q.push(make_pair(make_pair(-cost[co][1],(dir+1)%4),make_pair(row,col)));
			}
			if(!v[row][col][(dir+3)%4]&&ijk[row][col][(dir+3)%4]>cost[co][3]&&cost[co][3]<9999999){
				ijk[row][col][(dir+3)%4]=cost[co][3];
				Q.push(make_pair(make_pair(-cost[co][3],(dir+3)%4),make_pair(row,col)));
			}
		}
		if(v[gr][gc][0]||v[gr][gc][1]||v[gr][gc][2]||v[gr][gc][3])printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 38292
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W,D;
    cin >> H >> W >> D;
    vector<vector<int>>A(H,vector<int>(W));
    map<int,P>Mp;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
            Mp[A[i][j]] = make_pair(i,j);
        }
    }
    vector<int>sum(H*W+1);
    for(int i = 1; i <= H*W; i++) {
        if(i+D <= H*W) {
            sum[i+D] = sum[i]+abs(Mp[i].first-Mp[i+D].first)+abs(Mp[i].second-Mp[i+D].second);
        }
    }
    int Q;
    cin >> Q;
    while(Q--) {
        int L,R;
        cin >> L >> R;
        cout << sum[R]-sum[L] << endl;
    }
}


Measured memory_bytes: 10364
#include<stdio.h>
int main(void){
  int i,a[101], max,t;
  
  max=0;
  for(i=0;i<=100;i++)
  a[i]=0;
  
  while(scanf("%d",&t) != EOF){
      a[t]++;
      if(a[t]>max)
      max=a[t];
  }
  for(i=0;i<=100;i++)
  if(a[i]==max)
  printf("%d\n",i);
  
    return 0;
}


Measured memory_bytes: 1972
// kopipe test 
#include <bits/stdc++.h>
#define INF 2e9
#define int ll
#define vi          vector<int>
#define de          deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()//全範囲指定を簡略化
typedef long long ll;
using namespace std;
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める
signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    
    vector<double> p(N);
    vector<double> s(N,0);
    for(int i=0;i<N;i++){
        cin >> p[i];
        s[i] = (p[i]+1)/2;
    }

    vector<double> sum(N+1,0);
    for (int i = 0; i< N; i++){
        sum[i+1] = sum[i] + s[i];
    }

    double res = 0;
    for (int i=0; i <= N-K+1; i++){
        double val = sum[K+i] - sum[i];
        res = max(res,val);
    }
    
    cout << fixed << setprecision(10) << res << '\n';
}


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

int main()
{
	int num;
	double w, h;

	while (scanf("%d,%lf,%lf", &num, &w, &h) != EOF){
		if (w / (h * h) >= 25.0){
			cout << num << endl;
		}
	}

	return (0);
}

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

void Main()
{
  ll amount = 0;
  ll n; cin >> n;
  for (ll j = 1; j <= n; j++) {
    amount += j * (n/j) * (n/j+1) / 2;
  }
  cout << amount << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n)	for(int i=0;i<n;i++)
int main(){
	int n,k;	cin>>n>>k;
	vector<ll> a(n);
	rep(i,n)	cin>>a[i];
	vector<ll> p,m;
	ll pcnt=0,mcnt=0;
	rep(i,k){
		pcnt+=max(0LL,a[i]);	mcnt+=min(0LL,a[i]);
	}
	p.push_back(pcnt);	m.push_back(mcnt);
	for(int i=k;i<n;i++){
		pcnt+=max(a[i],0LL)-max(a[i-k],0LL);
		mcnt+=min(a[i],0LL)-min(a[i-k],0LL);
		p.push_back(pcnt);	m.push_back(mcnt);
	}
	pcnt=0;
	rep(i,n)	pcnt+=max(0LL,a[i]);
	ll ret=-1e18;
	rep(i,p.size()){
		ll tmp=max(pcnt-p[i],pcnt+m[i]);
		ret=max(tmp,ret);
	}
	cout<<ret<<endl;
	return 0;
}


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

int main() {
  string S; cin>>S;
  int s = S.size();
  string T = "";
  rep(i, s) if (i%2==0) T.push_back(S[i]);
  cout<<T<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	io;
	ll n;
	cin>>n;
	vector<ll>v(n+1);
	for(ll i=0;i<n-1;i++){
		ll val;
		cin>>val;
		v[val]++;
	}
	
	for(ll i=1;i<=n;i++){
		cout<<v[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef pair<ll, P> TP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
ll n;
//-------------------関数----------------------//
int main() {
  ll a, b;
  cin >> n >> a >> b;
  if (abs(a - b) % 2 == 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n],y[n];
    for(int i=0;i<n;i++)cin >> x[i];
    for(int i=0;i<n;i++)cin >> y[i];
    double da=0,db=0,dc=0,dd=0;
    double max=0;
    for(int i=0;i<n;i++){
        da+=fabs(x[i]-y[i]);
        db+=pow(fabs(x[i]-y[i]),2);
        dc+=pow(fabs(x[i]-y[i]),3);
        if(max<fabs(x[i]-y[i]))max=fabs(x[i]-y[i]);
    }
    cout << fixed << setprecision(8)<< da << endl;
    cout << fixed << setprecision(8)<< sqrt(db) << endl;
    cout << fixed << setprecision(8)<< pow(dc,1.0/3.0) << endl;
    cout << fixed << setprecision(8)<< max << endl;
}



Measured memory_bytes: 3412