akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	VL arr(n);
	fr(i,0,n)
		rl(arr[i]);
	if(n==1)
	{
		cout<<"Yes\n";
		return 0;
	}
	reverse(ALL(arr));
	int flag=1;
	fr(i,1,n)
	{
		if(arr[i]>arr[i-1])
		{
			arr[i]--;
			if(arr[i]==arr[i-1])
				continue;
			flag=0;
			//arr[i]=arr[i-1];
		}
	}
	// //int flag=1;
	// fr(i,0,n-1)
	// {
	// 	if(arr[i]!=arr[i+1])
	// 		flag=0;
	// }
	// if(flag)
	// {
	// 	if(arr[1]==1)
	// 		flag=0;
	// }
	if(!flag)
		cout<<"No"<<endl;
	else
		cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

    string s, t;
    cin >> s >> t;

    REP(i, N){
        cout << s[i] << t[i];
    }
    cout << "\n";
}

Measured memory_bytes: 3632
S = list(map(str, input()))
cnt = 0

for i in range(len(S)//2+1):
    if S[i]!=S[len(S)-i-1]:
        cnt += 1

for i in range(len(S)//2):
    if S[i]!=S[(len(S)-1)//2-i-1]:
        cnt += 1

for i in range(len(S)//2):
    if S[(len(S)+3)//2+i-1]!=S[len(S)-i-1]:
        cnt += 1

if cnt==0:
    print('Yes')
else:
    print('No')

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

public class Pg
{
    static void Main()
    {
        var rd = new Reader();
        var ct = new Counter();
        Console.WriteLine(ct.GetMin(rd.ReadInts().ToList()));

    }
}
class Counter
{
    const int ROUND = 60;
    int t;
    internal int GetMin(List<int> lst, params int[] n)
    {
        try
        {
            t = n[0];
        }
        catch
        {
            t = 0;
        }
        int p = t + lst[0];
        while (lst[2] < t)
        {
            lst[2] += ROUND;
        }
        if (t <= lst[2] && lst[2] <= p)
            return lst[2];
        t = p + lst[1];
        if (t % ROUND == 0)
            return -1;
        else
            return GetMin(lst, t);
    }
}
class Reader
{
    internal IEnumerable<string> Read()
    {
        int n = int.Parse(Console.ReadLine());
        while (n-- > 0)
        {
            yield return Console.ReadLine();
        }
    }
    internal IEnumerable<int> ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse);
    }
}



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

bool comp(pair<int, int> A, pair<int, int> B){
  return A.second - A.first > B.second - B.first;
}

signed main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  vector<pair<int, int>> PR;
  vector<pair<int, int>> NE;
  
  for( int i = 0; i < N; i++ ){
    cin >> S.at(i);
    //S内の累積和を取る
    int mini = 0;
    int total = 0;
    for( int j = 0; j < S.at(i).size(); j++ ){
      if( S.at(i).at(j) == '(' ) total++;
      else total--;
      mini = min(total, mini);
    }
    if( total >= 0 ) PR.push_back(make_pair(mini, total));
    else NE.push_back(make_pair(mini, total));
  }
  
  bool fg = 1;
  int total = 0;
  if( PR.size() != 0 ) sort(PR.rbegin(), PR.rend());
  for( int i = 0; i < PR.size(); i++ ){
    if( total + PR.at(i).first < 0 ) fg = 0;
    total += PR.at(i).second;
  }
  
  if( NE.size() != 0 ) sort(NE.begin(), NE.end(), comp);
  for( int i = 0; i < NE.size(); i++ ){
    if( total + NE.at(i).first < 0 ) fg = 0;
    total += NE.at(i).second;
  }
  
  if( total != 0 ) fg = 0;
  
  if( fg ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 50372
#include <cstdio>
#include <algorithm>

#define N 5

using namespace std;

int
main ( )
{
  int n;
  int i, j;

  scanf ( "%d", &n );
  while ( n-- )
  {
    int d[ N ][ N + 1 ] = { };
    int res = 0;

    for ( i = 0; i < N; ++i )
    for ( j = 0; j < N; ++j )
    {
      scanf ( "%d", &d[ i ][ j ] );
    }

    for ( i = 1; i < N; ++i )
    for ( j = 0; j < N; ++j )
    {
      if ( d[ i ][ j ] )
      {
        d[ i ][ j ] += d[ i - 1 ][ j ];
      }
    }

    for ( i = 0; i < N; ++i )
    {
      int s[ N + 1 ], sp = 0;

      for ( j = 0; j <= N; ++j )
      {
        int co = j;

        while ( sp && d[ i ][ j ] < d[ i ][ s[ sp - 1 ] ] )
        {
          --sp;
          res = max ( res, ( j - s[ sp ] ) * d[ i ][ s[ sp ] ] );
          co = s[ sp ];
        }
        d[ i ][ co ] = d[ i ][ j ];
        s[ sp++ ] = co;
      }
    }

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

  return ( 0 );
}

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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 100007

ll f[hell];

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z = 0, k, n;
	cin >> n;
	ll a[n];
	rep(i, 0, n, 1) {
		cin >> a[i];
		z ^= a[i];
		// f[x]++;
	}


	rep(i, 0, n, 1)	cout << (a[i]^z) << " ";
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
int  main()
{
	int n,a[1005];
	int sum=0,avg;
	cin>>n;
	int k[105],p1,p2,p3;
	for(int i=1;i<=n;i++)
	   {
	   cin>>a[i];
	   sum+=a[i];
	   }
	avg=sum/n;
	for(int i=1;i<=n;i++)
	   {
	   	p1=(a[i]-avg)*(a[i]-avg);
	   	p2=(a[i]-avg+1)*(a[i]-avg+1);
	   	p3=(a[i]-avg-1)*(a[i]-avg-1);
	    k[1]+=p1;
	    k[2]+=p2;
	    k[3]+=p3;
	   }
	sort(k+1,k+4);
	cout<<k[1];
	return 0;
}

Measured memory_bytes: 256
N = int(input())
f = [0]*N
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      n=x**2+y**2+z**2+x*y+y*z+z*x
      if n<=N:
        f[n-1]+=1
print(*f,sep="\n")

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

using namespace std;
int main(void){
    // Your code here!
    string s,t,u;
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }
    else if(b==c){
        cout<<a<<endl;
    }
    else if(a==c){
        cout<<b<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (h,w,a,b ) = readLine()!!.split(" ").map { it.toInt() }
    var s1=""
    var s2=""
    for(j in 0 until w){
        if(j<a){
            s1+="0"
            s2+="1"
        }
        else{
            s1+="1"
            s2+="0"
        }
    }
    for(i in 0 until h){
        if(i<b)println(s1)
        else println(s2)
    }
}



Measured memory_bytes: 41280
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	string s;
	cin >> s;
	int m = s.length();
	cout << s[0] << m - 2 << s[m-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 3010, mod = 998244353;
int n, s, res, a[N], f[N];
#define Mod(a, b) ((a += b) >= mod && (a -= mod))
signed main() {
	read (n), read (s);
	for (int i = 1; i <= n; ++i) read (a[i]);
	for (int i = 1; i <= n; ++i) {
		if (a[i] < s) res = (res + 1ll * f[s - a[i]] * (n - i + 1)) % mod;
		if (a[i] == s) res = (res + 1ll * i * (n - i + 1)) % mod;
		for (int j = s; j >= a[i]; --j) Mod (f[j], f[j - a[i]]); Mod (f[a[i]], i);
	} return printf ("%d\n", res), 0;
}

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

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);

int main()
{
	char s[100000];
	cin >> s;

	int count0 = 0, count1 = 0;

	for (int i = 0; s[i]!='\0'; i++)
	{
		if (s[i] == '0')
			count0++;
		else if (s[i] == '1')
			count1++;
	}

	cout << 2 * min(count0, count1);

	return 0;
}

int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, x, a[200200];
vector<int> v;

int main () {
        scanf("%d %d", &N, &x);
        if (x == 1 || x == 2*N-1) return puts("No"), 0;
        puts("Yes");
        a[N-2] = 1;
        a[N-1] = x;
        a[N] = 2*N-1;
        fo(i, 2, 2*N-1) if (i != x) v.PB(i);
        fo(i, 0, 2*N-1) if (i<N-2 || i>N) a[i] = v.back(), v.pop_back();
        fo(i, 0, 2*N-1) printf("%d\n", a[i]);
        return 0;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while(scan.hasNext()) {
	    int n = scan.nextInt();
	    if(n == 0) break;
	    int mini, maxi;
	    mini = 501;
	    maxi = -1;
	    for(int i = 0; i < n; ++i) {
		int sum = 0;
		for(int j = 0; j < 5; ++j) {
		    sum += scan.nextInt();
		}
		if(sum > maxi) maxi = sum;
		if(sum < mini) mini = sum;
	    }
	    System.out.println(maxi+" "+mini);
	}
    }
}

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

// typedef long long ll;
// int main(){
// 	ll h;
// 	int n;

// 	cin>>h>>n;

// 	int arr[n];
// 	for(int i =0;i<n;i++)
// 		cin>>arr[i];

// 	for(int i =0;i<n;i++)
// 	{	h = h - arr[i];
// 		if(h <= 0)
// 			break;}

// 	if(h <= 0)
// 		cout<<"Yes";
// 	else
// 		cout<<"No";

// 	return 0;
// }

#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, K;
	cin >> N >> K;
	vector<ll>H(N);
	ll sum = 0;
	for (int i = 0; i < N; i++){
		cin >> H[i];
		sum += H[i];
	}
	sort(H.begin(), H.end(), greater<ll>());
	for (int i = 0; i < K; i++){
		if (N == i) {
			break;
		}
		sum -= H[i];
	}

	cout << sum << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    long count=0;

    for (long i=1; i<=N; i++) {
        if (i%3!=0 and i%5!=0) {
            count += i;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	double r;
	double area, cir;
	cin >> r;

	area = M_PI * r * r;
	cir = 2 * M_PI * r;

	cout << fixed << area << " " << cir;

	return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  for(int i=0; i<3; ++i){
    if(s.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
typedef long long ll;
ll N,inf = 1e9+7,dp[5010][5010] = {{0}};
string S;

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}


int main(){
	cin >> N >> S;
	ll M = S.size();
	dp[0][0] = 1;
	for(int j=1;j<=N;j++){
		for(int i=0;i<=N;i++){
			dp[i][j] += dp[i+1][j-1];
			if(i>=1) dp[i][j] += 2*dp[i-1][j-1];
			else dp[i][j] += dp[i][j-1];
			dp[i][j] %= inf;
		}
	}
	ll ans = 0;
	cout << (dp[M][N]*mult(mult(2,M),inf-2))%inf << endl;
}

Measured memory_bytes: 195968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll dfs(string S) {
  int N = S.size();
  if (S[1] != '[') {
    ll k = stoll(S.substr(1,N-2));
    return k / 2 + 1;
  }
  int count = 0;
  vector<ll> A;
  string t = "";
  for (int i = 1; i < N-1; i++) {
    if (S[i] == '[') count++;
    if (S[i] == ']') count--;
    t.push_back(S[i]);
    if (count == 0) {
      A.emplace_back(dfs(t));
      t = "";
    }
  }
  sort(all(A));
  ll y = 0;
  rep(i,A.size() / 2 + 1) y += A[i];
  return y;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  while (true) {
    int N,M; cin >> N >> M;
    if (N == 0 && M == 0) break;
    vector<int> h(N),w(M);
    rep(i,N) cin >> h[i];
    rep(i,M) cin >> w[i];

    vector<int> hh(N), ww(M);
    unordered_map <int, int> hs,ws;
    rep(i,N) {
      if (i == 0) hh[i] = h[i];
      else hh[i] = hh[i-1] + h[i];
      hs[hh[i]]++;
    }
    rep(i,M) {
      if (i == 0) ww[i] = w[i];
      else ww[i] = ww[i-1] + w[i];
      ws[ww[i]]++;
    }
    rep(i,N) {
      for (int j = i + 1; j < N; j++) {
        hs[hh[j] - hh[i]]++;
      }
    }
    rep(i,M) {
      for (int j = i + 1; j < M; j++) {
        ws[ww[j] - ww[i]]++;
      }
    }
    ll ans = 0;
    for (auto i : hs) ans += (hs[i.first] * ws[i.first]);

    cout << ans << endl;
  }
}


Measured memory_bytes: 31920
#include <cstdio>
#include <cstring>

using namespace std;
const int Max_N(100050);
const int MOD(1000000000 + 7);

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int N, F[Max_N], Last[3];
char S[Max_N]; 

int main()
{
	scanf("%s", S + 1), N = strlen(S + 1);
	bool special = true;
	for (int i = 2;i <= N;++i)
		if (S[i] == S[i - 1])
			special = false;
	if (special)
	{
		printf("1");
		return 0;
	}
	Last[0] = 0, Last[1] = Last[2] = -1, F[0] = 1;
	for (int i = 1, Sum = 0, a;i <= N;++i)
	{
		(Sum += (S[i] - 'a' + 1)) %= 3;
		if (i < N && Sum == 0)
			F[i] = 1;
		a = ((Sum - 1) % 3 + 3) % 3;
		if (Last[a] != -1)
			upd(F[i], F[Last[a]]);
		a = ((Sum - 2) % 3 + 3) % 3;
		if (Last[a] != -1)
			upd(F[i], F[Last[a]]);
		Last[Sum] = i;
	}
	printf("%d", F[N]);
	return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

vector < pii >g[maxn];
int u[maxn],v[maxn],w[maxn];
bool visited[maxn];
int c[maxn];

void dfs(int u){
    if(visited[u]) return;
    visited[u]=true;

    for(int i=0; i<g[u].size(); i++){
        int wgt=g[u][i].ss;
        if(wgt%2==0){
            c[g[u][i].ff]=c[u];
        }else {
            if(c[u]==0) c[g[u][i].ff]=1;
            else c[g[u][i].ff]=0;
        }
        dfs(g[u][i].ff);
    }
    return;
}

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;


    f1(i,n-1){
        int x,y,w;
        cin >> x >> y >> w;
        g[x].pb({y,w});
        g[y].pb({x,w});
    }
    c[1]=1;
    dfs(1);

    for(int i=1 ; i<=n ; i++){
        cout << c[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 12160
class Solution:
  def solve(self, A, B, C):
    count = 0
    while True:
      B -= A
      if B < 0: break
      count += 1
      if count == C: return C
    return count

def main():
  inputs = list(map(int, input().split()))
  A, B, C = inputs
  print(Solution().solve(A, B, C))
        
if __name__ == "__main__":
   main()

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

#define PRINT(s) cout << (s);
#define PRINTLN(s) cout << (s) << endl;

using namespace std;

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

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

    int connected[51][51];
    REP(i,0,N+1){
        REP(j,0,N+1){
            connected[i][j] = 0;
        }
    }
    REP(i,0,M){
        int town1,town2;
        cin >> town1 >> town2;
        connected[town1][town2]++;
        connected[town2][town1]++;
    }
    REP(i,1,N+1){
        int connectedTown = 0;
        REP(j,1,N+1){
            connectedTown += connected[i][j];
        }
        PRINTLN(connectedTown);
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint a(N);
    REP(i,N){
        int t; cin>>t;
        a[t-1]++;
    }
    sort(ALL(a));

    int ans=0;
    REP(i,N-K){
        ans+=a[i];
    }
    cout<<ans<<endl;

}


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

#define ll long long



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

    priority_queue<ll>a;
    ll va;
    for(int i=0;i<n;i++){
        cin>>va;
        a.push(va);
    }
    
    ll tv;
    for(int i=0;i<m;i++){
        tv = a.top();
        tv /= 2;
        a.pop();
        a.push(tv);
    }
    
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += a.top();
        a.pop();
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
vector<int> g[maxn];
int f[maxn],u[maxn],v[maxn],d[maxn];
ll p[100];
bool vis[100];
void dfs(int x,int fa){
	f[x] = fa;
	for(int y:g[x]){
		if(y==fa)continue;
		d[y] = d[x]+1;
		dfs(y,x); 
	}
}
void lca(int x,int y){
	if(d[x]<d[y])swap(x,y);
//	cout<<"!!!!!!!!"<<x<<" "<<y<<endl;
	while(d[x]>d[y]){
		vis[x] = 1;
		x = f[x];
	}
	if(x==y)return ;
	while(x!=y){
		vis[x] = 1;
		x = f[x];
		vis[y] = 1;
		y = f[y];
	}
}
int main()
{
	int n;cin>>n;
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	d[1] = 1;
	dfs(1,0);
	int m;cin>>m;
	for(int i=0;i<m;i++){
		scanf("%d%d",&u[i],&v[i]);
	}
	p[0] = 1;
	for(int i=1;i<=50;i++)p[i] = p[i-1]*2;
	ll ans = 0;
	for(int i=0;i<(1<<m);i++){
		memset(vis,0,sizeof(vis));
		int op = 1;
		for(int j=0;j<m;j++)
			if(i&(1<<j)){
				op = -op;
				lca(u[j],v[j]);
			}
		int cnt = 0;
		for(int i=2;i<=n;i++)
			if(!vis[i])cnt++;
		ans += op*p[cnt];
//		cout<<"!"<<i<<" "<<cnt<<endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6016
/*
g++ -std=c++11 -o2 -Wall ABC102B.cpp -o ./out/ABC102B.out
./out/ABC102B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a[105];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      ans = max(ans, abs(a[i]-a[j]));
    }
  }
  cout << ans << "\n";
}


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

int main() {
    int N, T, A;
    cin >> N >> T >> A;

    int min = 1e9, ans = 0, target = (T - A) * 1000;
    for (int i = 1; i <= N; ++i){
        int h, d;
        cin >> h;
        d = abs(target - 6 * h);
        if (d < min){
            min = d;
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int n,m;
vector<int>s[100];
int k[100];
int p[100];

int main(){ 

  cin>>n>>m;

  rep(i,m){
    cin>>k[i];
    rep(j,k[i]){
      int tmp;
      cin>>tmp;
      s[i].pb(tmp);
    }
  }
  rep(i,m)cin>>p[i];

  int ans=0;
  rep(i,1<<n){
    bool on[1111];
    int cnt=0;
    rep(j,n)on[j]=0;
    rep(j,n)if(i&(1<<j))on[j]=1;
    //rep(j,n)cout<<on[j]<<" ";
    //cout<<endl;
    rep(j,m){
      int hoge=0;
      rep(k,s[j].size()){
          if(on[s[j][k]-1])hoge++;
      }
      if(hoge%2==p[j])cnt++;
    }
    if(cnt==m)ans++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
vector <int> fact(1010);
void factor(int n, vector <int> &fact){
    int i=2;
    while(n!=1){
        while(n%i==0) {
            n/=i;
            fact[i]++;
        }
        i++;
    }
}
int main(void){
    int n; cin>>n;
    for(int i=2;i<=n;i++){
        factor(i, fact);
    }
    ll ans=1;
    for(int i=2;i<1010;i++){
        ans *= 1LL*(fact[i]+1);
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int S, W;
int main(){
    cin >> S >> W;
    cout << ((S > W) ? "safe" : "unsafe") << endl;
}

Measured memory_bytes: 3624
/*
  AOJ 1091
  Title:KND is So Sexy
  @kankichi573
*/
#include <stdio.h>
#include <math.h>
#include <float.h>

double a,l,x;
double h1,h2,S;
extern double sqrt(double);
main()
{
  while(EOF!=scanf("%lf %lf %lf",&a,&l,&x))
    {
      h1=sqrt(l*l-a*a/4.0);
      S=a*h1/2;
      h2=sqrt((l+x)*(l+x)/4.0-l*l/4.0);
      S += h2*l;
      printf("%.7lf\n",S);
    }
  return(0);
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int n; cin >> n;
  vi a(3 * n); rep(i, sz(a)) cin >> a[i];
  sort(rall(a));
  int ans = 0;
  rep(i, n) ans += a[2 * i + 1];
  cout << ans << endl;
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	X := readInt()
	Y := readInt()
	A := readInt()
	B := readInt()
	C := readInt()

	p := make([]int, A+1)
	q := make([]int, B+1)
	r := make([]int, C+1)

	for i := 0; i < A; i++ {
		p[i+1] = readInt()
	}
	for i := 0; i < B; i++ {
		q[i+1] = readInt()
	}
	for i := 0; i < C; i++ {
		r[i+1] = readInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p[1:])))
	sort.Sort(sort.Reverse(sort.IntSlice(q[1:])))
	sort.Sort(sort.Reverse(sort.IntSlice(r[1:])))

	p = p[:X+1]
	q = q[:Y+1]

	for i := 1; i < X; i++ {
		p[i+1] += p[i]
	}
	for i := 1; i < Y; i++ {
		q[i+1] += q[i]
	}
	for i := 1; i < C; i++ {
		r[i+1] += r[i]
	}

	result := 0
	for i := max(0, X-C); i <= X; i++ {
		ok := max(0, Y-(C-(X-i))) - 1
		ng := Y
		for ng-ok != 1 {
			m := ok + (ng-ok)/2
			t0 := q[m] + r[(X-i)+(Y-m)]
			t1 := q[m+1] + r[(X-i)+(Y-(m+1))]
			if t0 < t1 {
				ok = m
			} else {
				ng = m
			}
		}
		j := ok + 1
		result = max(result, p[i]+q[j]+r[(X-i)+(Y-j)])
	}

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str,str2[200000],strmemo="";
	long long int n, m=1, a, b, c, d, e, f, now[200][200] = {}, x[200006], y[200006], X = 0, Y = 0;
	const long long int mod = 1000000007;
	
	cin >> a>>b;
	if (a == 1 && b == 1) {
		cout << 1 << endl;
	}
	else if (a == 1 || b == 1) {
		cout<<max(a, b) - 2 << endl;
	}
	else {
		cout << (a - 2) * (b - 2) << endl;
	}
	
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b; cin >> a >> b;
	cout << max(a+b,max(a-b,a*b)) << endl;
}

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

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

    int H[N+1];
    for(int i=1; i<=N; i++) cin >> H[i];

    //道を入力する
    vector<vector<int>> road(N+1, vector<int>(0));

    for(int i=0; i<M; i++){
        int A, B;
        cin >> A >> B;

        road[A].push_back(B);
        road[B].push_back(A);
    }

    //良い展望台かどうか調べる
    int ans = 0;

    for(int i=1; i<=N; i++){
        for(int j : road[i]){
            if(H[j] >= H[i]){
                ans--;
                break;
            }
        }

        ans++;
    }

    cout << ans << endl;

} 

Measured memory_bytes: 8804
N,M = gets.split.map(&:to_i)
es=Hash[(1..N).map{|i| [i,{}] }]
(0...M).each{
  a,b = gets.split.map(&:to_i)
  es[a][b] = (es[a][b] || 0) + 1
  es[b][a] = (es[b][a] || 0) + 1
}
puts (1..N).map{|a|es[a].values.inject(0,:+)}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos(0))
#define linf (1ll << 60)

#define maxn 1000005

ll n, a[maxn], sum = 0;

int main(){

//	freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    For(i, 1, n){
    	cin >> a[i];
    	sum += a[i];
    }

    ll A = n * 1ll * (n + 1) / 2;
    if(sum % A){
    	cout << "NO" << endl;
    	return 0;
    }

    ll num = sum / A;
    ll res = 0;
    For(i, 1, n){
    	int j = (i + 1);
    	if(j > n) j = 1;
    	A = a[i] - a[j] + num;
    	if(A < 0 || (A % n)){
    		cout << "NO" << endl;
    		return 0;
    	}
    	res += A / n;
    }
    if(res != num){
    	cout << "NO" << endl;
    }
    cout << "YES" << endl;

    return 0;
}


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

string str;
char c[128];

void c2c(){
  c['['] = ']';
  c['('] = ')';
  c['{'] = '}';
  c[']'] = '[';
  c[')'] = '(';
  c['}'] = '{';
}

int solve(string left,string right){
  int cnt = 0;
  c2c();

  for(int i = 0 ; i < (1 << left.length()) ; i++){
    string nleft = "";
    for(int j = 0 ; j < left.length() ; j++){
      if(i >> j & 1){
	nleft += left[j];
      }
    }
    for(int j = 0 ; j < (1 << right.length()) ; j++){
      string nright = "";
      for(int k = 0 ; k < right.length() ; k++){
	if(j >> k & 1){
	  nright += c[right[k]];
	}
      }
      if(nright.length() != nleft.length()){
	continue;
      } 
      int t = 0;
      for(int j = 0 ; j < nleft.length() ; j++){
	if(nleft[j] != nright[nleft.length()-j-1]) break;
	++t; 
      }
      cnt = max(cnt,t);     
    }  
  }

  return 2*cnt+3;
}

int main(){
  cin >> str;

  string left = "" , right = "";
  int length = str.length();

  int i;
  for(i = 0 ; i < length ; i++){
    if(str[i] == 'i') break;
    left += str[i];
  }
  i += 2;
  for(int j = i ; j < length ; j++){
    right += str[j];
  }

  cout << solve(left,right) << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, a, b;
    cin >> n >> a >> b;
    vector<lint> x(n);
    repeat(i, n) cin >> x[i];
    
    lint ans = 0;
    repeat(i, n-1) {
        lint walkcost = (x[i+1] - x[i]) * a;
        lint telecost = b;
        ans += min(walkcost, telecost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

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

#define yes \
do\
{\
	cout << "Yes";\
	return 0;\
}\
while(0)

#define no \
do\
{\
	cout << "No";\
	return 0;\
}\
while(0)

const int N = 100003;
int a[N];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int maxn = 0, minn = 100000, cnt = 0;
	for (int i = 1; i <= n; ++i)
	{
		maxn = max(maxn, a[i]),
		minn = min(minn, a[i]);
	}
	for (int i = 1; i <= n; ++i)
		if (a[i] == minn)
			++cnt;
	if (maxn - minn > 1)
		no;
	if (maxn == minn)
		if (minn == n - 1 or (minn << 1) <= n)
			yes;
		else no;
	if (maxn == minn + 1)
		if (minn < cnt or n - cnt < (maxn - cnt << 1))
			no;
		else yes;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> Mochis (N);
for(int i = 0;i < N;i++){
cin >> Mochis.at(i);}
sort(Mochis.begin(), Mochis.end());
reverse(Mochis.begin(), Mochis.end());
int count =1;
for(int i = 1;i < N;i++){
if(Mochis.at(i - 1) == Mochis.at(i)){
count += 0;}
else count++;}
cout << count << endl;}

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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        if (N == 1) {
            WriteLine("Hello World");
        } else {
            int A = sc.nextInt();
            int B = sc.nextInt();
            WriteLine(A + B);
        }
    }

}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x=II()
    a,x=divmod(x,500)
    b=x//5
    print(a*1000+b*5)

main()

Measured memory_bytes: 3064
## まきもどし？
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
import sys
sys.setrecursionlimit(10**6)
n = ni()
A = lma()
tree = [[] for i in range(n)]
INF = 10**10
for i in range(n-1):
    u,v = ma();u-=1;v-=1
    tree[u].append(v)
    tree[v].append(u)
#print(tree)
def isok(num,val):##適宜変更
    return num<val
def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ
def LIS_1(x,ls,right):##right ::これまでわかっている右端
    idx = bisect(ls,x)+1
    if idx+1>right:
        ret= idx+1
    else:
        ret=right
    rewind_idxval.append((idx,ls[idx]))
    ls[idx]=x
    #print(x,ls)
    return ret
def DFS_LIS(prev,ls,right):
    ans[prev]= LIS_1(A[prev],ls,right)
    for node in tree[prev]:
        if not visited[node]:
            visited[node]=True
            DFS_LIS(node,ls,ans[prev])
    #rewind
    idx,pval = rewind_idxval.pop()
    ls[idx] = pval

ans = [0]*n
s = 0
right=0
rewind_idxval=collections.deque()
visited=[False]*n
visited[s]=True
ls=[INF]*n
DFS_LIS(s,ls,right)
#print(ls)
for a in ans :
    print(a)


Measured memory_bytes: 234072
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n ;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
    	ll r = n / i;
    	ans += r * (r + 1) / 2 * i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

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

    if (a > b) {
        for (int i = 0; i < a; i++){
            printf("%d", b);
        }
    }
    else {
        for (int i = 0; i < b; i++) {
            printf("%d", a);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#行き先数の入力
n = gets.chomp.to_i
#目的地の入力
t, x, y = n.times.map{gets.split.map(&:to_i)}.transpose

flag = false

(0..n - 1).each do |i|
  if x[i] + y[i] <= t[i] && (x[i] + y[i]).even? == t[i].even?
    flag = true
  else
    flag = false
    break
  end
end

if flag
  puts "Yes"
else
  puts "No"
end

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

int main() {
  int N;
  cin >> N;
  unordered_set<int> s;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (s.count(x)) s.erase(x);
    else s.insert(x);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int  main()
{
    int t;
    cin>>t;
        int r=t%10;
        if(r==2 || r==4 || r==7 ||r==9 || r==5)
        {
            cout<<"hon"<<endl;

        }
        else if(r==0 || r==1 || r==6 || r==8)
        {
            cout<<"pon"<<endl;
        }
        else
            cout<<"bon"<<endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
  float a, b, c, d, e, f, x, y;
  while( -1 != scanf("%f %f %f %f %f %f\n", &a, &b, &c, &d, &e, &f))
    {
      x = (c*e - b*f) / (a*e - b*d);
      y = (-c*d + a*f ) / (a*e - b*d);
      
      printf("%.3f %.3f\n", x + 0, y + 0);
    }
  return 0;
}



Measured memory_bytes: 2104
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] a = saori.nextHayami().split("");
		String[] b = saori.nextHayami().split("");
		String[] c = saori.nextHayami().split("");
		if(a[a.length-1].equals(b[0]) && b[b.length-1].equals(c[0])){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
#include <iostream>
#define llint long long

using namespace std;

int h, w, n;
char c[305][305];
llint sum[705][705];
llint Zero = 355;

llint calc()
{
	llint ret = 0;
	for(int u = -n; u <= n; u++){
		for(int v = 0; v <= 2*n; v++){
			sum[Zero+u][v] = 0;
		}
	}
	for(int x = 1; x <= n; x++){
		for(int y = 1; y <= n; y++){
			if(c[x][y] == '.') continue;
			int u = x-y, v = x+y;
			sum[Zero+u][v]++;
		}
	}
	for(int u = -n; u <= n; u++){
		for(int v = 0; v <= 2*n; v++){
			if(v > 0) sum[Zero+u][v] += sum[Zero+u][v-1];
		}
	}
	for(int x = 1; x <= n; x++){
		for(int y = 1; y <= n; y++){
			if(c[x][y] == '.') continue;
			for(int d = 1; d <= n; d++){
				if(x+d>n || y+d>n) break;
				if(c[x+d][y+d] == '.') continue;
				int u = x-y, v = x+y;
				if(Zero+u-2*d >= 0 && v+2*d < 705) ret += sum[Zero+u-2*d][v+2*d] - sum[Zero+u-2*d][v];
			}
		}
	}
	return ret;
}

char t[305][305];
void rot()
{
	for(int x = 1; x <= n; x++){
		for(int y = 1; y <= n; y++){
			t[x][y] = c[y][n-x+1];
		}
	}
	for(int x = 1; x <= n; x++){
		for(int y = 1; y <= n; y++){
			c[x][y] = t[x][y];
		}
	}
}

int main(void)
{
	cin >> h >> w;
	n = max(h, w);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			c[i][j] = '.';
		}
	}
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> c[j][i];
		}
	}
	
	
	llint ans = 0;
	for(int i = 0; i < 4; i++){
		ans += calc();
		rot();
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3712