akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){   
   int n,t,a;
   cin>>n>>t>>a;
   float kouho=10000;
   int ans=0;
   rep(i,n){
      int x;
      cin>>x;
      float kari=t-x*0.006;
      if(abs(a-kouho)>abs(a-kari)){
       ans=i;
       kouho=kari;
      }
   }
   cout<<ans+1;

   return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, a, b);

  bool ok = false;
  if (a * b % 2) ok = true;
  if (a * b * 3 % 2) ok = true;

  outl(ok ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main() {
	string str;
	cin>>str;

	string ans="CODEFESTIVAL2016";
	int num=0;
	for(int i=0;i<ans.size();++i){
		if(str[i]!=ans[i])++num;
	}

	cout<<num<<endl;
	//system("pause");
	return 0;
}

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

int main() {

  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int answer = 0;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == X) {
          answer++;
        }
      }
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
N = int(input())
S = list(input())
m =0
a =[]
for i in S:
    if i =='I':
        m=m+1
        a.append(m)
    else:
        m=m-1
        a.append(m)
if max(a)>=0:
    print(max(a))
else:
    print(0)

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

int main() {
    int zero;
    int x;

    for (int i = 0; i < 5; i++)
    {
        cin >> x;
        if(x == 0)zero = i + 1;
        /* code */
    }

    cout << zero << endl;

    


    return 0;
}

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

int main(){

  int len, w, cnt;
  string str, word;

  getline(cin, str);

  cnt = 0;
  len = str.length();
  for(int i=0; i<=len; i++){
    if(i == len || str[i] == ' ' || str[i] == '.' || str[i] == ','){
      w = word.length();
//cout << word << endl;
      if(w > 2 && w < 7){
        cnt++;
        if(cnt != 1) cout << " " << word;
        else cout << word;
      }
      word = "";
    }
    else word += str[i];
  }

  cout << endl;

  return 0;

}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





int main() {
	int n;
	cin >> n;
	VLL a(n), c(n);
	REP(i, n)cin >> a[i];
	ll sum = 0, ans = 0, nsum = 0;
	REP(i, n) {
		int b;
		cin >> b;
		c[i] = a[i] - b;
		sum += c[i];
		if (c[i] < 0)ans++, nsum -= c[i];
	}
	if (sum < 0) {
		cout << -1 << endl;
		return 0;
	}
	sort(ALL(c));
	int tmp = n - 1;
	while (nsum > 0) {
		nsum -= c[tmp];
		tmp--;
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int k;
int a,b,c;
void dfs(int q,int w,int e)
{
	if(q+w+e==k)
	{
		ll A = a<<q,B=b<<w,C=c<<e;
		if(A<B&&B<C)
		{
			cout << "Yes"<<endl;
			exit(0);
		}
		return;
	}
	dfs(q+1,w,e);
	dfs(q,w+1,e);
	dfs(q,w,e+1);
}

int main()
{
	cin >> a >> b >> c;
	cin >> k;

	dfs(0,0,0);
	cout<<"No"<<endl;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

string a,b,c;cin>>a>>b>>c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
printf("YES\n");
else
printf("NO\n");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,a[100],i,ans;
int main(){
  cin>>N;
  for(i=0;i<N;i++)
  cin>>a[i];
  for(i=0;i+1<N;i++){
    if(a[i]==a[i+1]){
      ans++;
      i++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    line = list(map(int, input().split()))
    a += line
a_set = set(a)
cnt = 0
for i in range(1,n+1):
    if not i in a_set:
        cnt += 1
print(cnt)


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

using namespace std;
typedef long long ll;

int main()
{
  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  if (p == 2 || p == 5)
  {
    ll ans = 0;
    for (ll i = s.size() - 1; i >= 0; i--)
    {
      ll digit = s.at(i) - '0';
      if (digit % p == 0)
      {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  reverse(s.begin(), s.end());
  vector<ll> acc = {};
  map<ll, ll> cnts = {};
  cnts[0] = 1; // 範囲外を選択する場合を考慮

  ll d = 1;
  for (ll i = 0; i < s.size(); i++)
  {
    ll digit = s.at(i) - '0';
    if (i == 0)
    {
      ll val = digit % p;
      acc.push_back(val);
      if (cnts.count(val) > 0)
        cnts[val]++;
      else
        cnts[val] = 1;

      d *= 10;
      d %= p;

      continue;
    }
    else
    {
      ll val = d * digit + acc[i - 1];
      val %= p;
      acc.push_back(val);
      if (cnts.count(val) > 0)
        cnts[val]++;
      else
        cnts[val] = 1;

      d *= 10;
      d %= p;
    }
  }

  ll ans = 0;
  for (auto x : cnts)
  {
    if (x.second > 0)
    {
      ans += x.second * (x.second - 1) / 2;
    }
  }

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


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int> edges[100000];
int64_t dp[100000][2];

void dfs(int i, int p){
    dp[i][0] = dp[i][1] = 1;
    for(int j : edges[i]){
        if(j == p) continue;
        dfs(j, i);
        mul(dp[i][0], dp[j][0] + dp[j][1]);
        mul(dp[i][1], dp[j][0]);
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    dfs(0, -1);
    cout << ((dp[0][0] + dp[0][1]) % MOD) << endl;
    return 0;
}

Measured memory_bytes: 14208
n = int(input())

result = ""
for i in (range(1,n+1)):
    if i % 3 == 0:
        result += " " + str(i)
        continue
    j = i
    while j > 0:
        if j % 10 == 3:
            result += " " + str(i)
            break
        else:
            j //= 10
        
       
print (result)


Measured memory_bytes: 5624
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = h[0]
cnt = 0
for i in h[1:]:
    if i <= tmp:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
    tmp = i
if cnt > ans:
    ans = cnt
print(ans)


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

#define int long long

int N, K, S;
int dp[21][11][156];

int dfs(int p, int k, int s) {
  if ( k == K ) {
    if ( s == S ) return 1;
    else return 0;
  }
  if ( dp[p][k][s] >= 0 ) return dp[p][k][s];

  int ret = 0;
  for ( int i = p+1; i <= N; i++ ) {
    ret += dfs(i, k+1, s+i);    
  }

  return dp[p][k][s] = ret;
}

signed main() {
  while ( cin >> N >> K >> S, N ) {
    fill_n(**dp, 21*11*156, -1);
    cout << dfs(0, 0, 0) << endl;    
  }
  return 0;
}



Measured memory_bytes: 3288
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-19 18:52:05
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
const int N=100010;
int n;
#define arr std::vector<int>
arr inv(arr a)
{
	arr b(n+1);
	fr(i,1,n) b[a[i]]=i;
	return b;
}
arr operator*(arr a,arr b)
{
	arr c(n+1);
	fr(i,1,n) c[i]=a[b[i]];
	return c;
}
arr &operator*=(arr &a,arr b){ return a=a*b; }
int k;
arr a,b,c;
arr power(arr a,int b)
{
	arr r(n+1);
	fr(i,1,n) r[i]=i;
	for(;b;b>>=1,a*=a) if(b&1) r*=a;
	return r;
}
int main()
{
	n=read(); k=read(); a=arr(n+1); b=arr(n+1);
	fr(i,1,n) a[i]=read();
	fr(i,1,n) b[i]=read();
	c=b*inv(a)*inv(b)*a; k--;
	while(k%6){ arr d=a; a=b; b*=inv(d); k--; }
	a=power(c,k/6)*a*power(inv(c),k/6);
	fr(i,1,n) printf("%d%c",a[i],i==n?'\n':' ');
	return 0;
}
/*
a
b
bA
bAB
bABaB
bABaaB
bABabaB
bABabAbaB
*/

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    int n,m; cin>>n>>m;
    ll ans = 0;
    if(n!=0) ans += n*(n-1)/2;
    if(m!=0) ans += m*(m-1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int hen1 = 0, hen2 = 0, x = 0;
        int ccount = 0 , hcount = 0;

        while(scanf("%d,%d,%d",&hen1, &hen2, &x) != EOF)
        {


                        if(hen1 == hen2)
                        {
                                hcount++;
                        }
                        else if(x > hen1 && x> hen2)
                        {
                                ccount++;
                        }
        }
        printf("%d\n",ccount);
        printf("%d\n",hcount);
        return 0;
}

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

int main(){
  unsigned long long int N,A,B,C,D,E,mn;
  cin>>N>>A>>B>>C>>D>>E;
  mn=A;
  if(B<=mn) mn=B;
  if(C<=mn) mn=C;
  if(D<=mn) mn=D;
  if(E<=mn) mn=E;
  if(N%mn==0) cout<<(N/mn)+4<<endl;
  else cout<<(N/mn)+5<<endl;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = min(a) + min(b)
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Measured memory_bytes: 70764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int n, m; cin>> n >> m;
    ll ac=0, wa=0;
    vector<ll> isac(n, 0), iswa(n, 0);
    rep(i, m){
        int p;
        string s;
        cin>> p >> s;
        p--;
        if(s=="AC"){
            if(isac[p] == 0){
                ac++;
                wa += iswa[p];
                isac[p] = true;
            }
        }
        else iswa[p]++;
    }
    cout<<ac<<" " << wa << endl;
}

Measured memory_bytes: 4864
def main():
    D = int(input())
    fuman = list(map(int, input().split()))
    manzoku = [[0]*26 for _ in range(D)]
    for i in range(D): manzoku[i] = list(map(int, input().split()))
    # できるだけ点数が下がらないように、満足度の高いものを選んでいく
    # d日目にテストiを受けた時、score += manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)
    # >テストiをd日目に受ける
    # manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)が一番大きいもの(i)を受けるそれだけ
    timepass = [0]*26
    # 初日のみ指定
    x,t = 0,0
    for j in range(26):
        tmp = manzoku[i][j]
        if tmp>x:
            x = tmp
            t = j
    print(t+1)
    for i in range(1,D):
        x1 = 0
        t1 = 0
        for j in range(26):
            tmp = manzoku[i][j]
            for k in range(26):
                if not j==k: tmp -= fuman[k]*timepass[k]
            if tmp>x1:
                x1 = tmp
                t1 = j

        #sel
        for j in range(26):
            if not j==t1: timepass[j] += 1
            else: timepass[j] = 0
        print(t1+1)



main()


Measured memory_bytes: 9336
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  int m=n;
  int i;
  vector<int> ans(0);
  for(i=2;i*i<=m;i++)
  {
    while(n%i==0)
    {
      ans.emplace_back(i);
      n/=i;
    }
  }
  if(n>1)ans.emplace_back(n);
  cout<<m<<':';
  rep(i,ans.size())
  {
    cout<<' '<<ans[i];
  }
  cout<<endl;
}



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

int main() {
    int N, W;
    cin >> N >> W;
    long long int dp[110][100100] = {0};

    for (int i=1; i<=N; ++i) {
        long long int w, v;
        cin >> w >> v;
        for (int j=0; j<=W; ++j) {
            if (j < w) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j]);
        }
    }
    long long int ans = 0;
    for (int i=0; i<=W; ++i) ans = max(ans, dp[N][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 86272
using System;
using System.Collections.Generic;

class A{
	public static void Main(){


		while (true) {

			string[] s = Console.ReadLine ().Split (' ');
			int n = int.Parse(s [0]);
			int x = int.Parse(s [1]);

			int count = 0;

			if (n == x && n == 0) {
				break;
			}

			for (int i = 1; i <= n ; i++) {
				for (int l=i+1; l <= n;l++) {
					for(int y=l+1; y<=n;y++){
						if (i + l + y == x) {
							count++;
						}
					}
				}
			}
			Console.WriteLine (count);
		}



	}
}

Measured memory_bytes: 9224
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
		
#階乗#
lim = 10**6   #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod

X, Y = MAP()

a = (Decimal("2")*Decimal(str(X))-Decimal(str(Y)))/Decimal("3") 
b = (Decimal("2")*Decimal(str(Y))-Decimal(str(X)))/Decimal("3") 

if a%1 == b%1 == 0 and 0 <= a and 0 <= b:
	print(C(int(a+b), int(a)))
else:
	print(0)


Measured memory_bytes: 89592
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define f(i,x) for(int i=0;i<x;i++)

using namespace std;

int main()
{
	int a, b=0, x;

	cin >> a;

	x = a;
	while (a != 0) {
		b += a % 10;
		a /= 10;
	}
	if (x%b == 0)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 5010;

int p[N];
ll c[N];

void solve() {
    int n, k; cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    ll ans = -1e18;
    for (int i = 1; i <= n; i++) {
        if (p[i] == -1)
            continue;
        vector<ll> cycle;
        int v = i;
        while (p[v] != -1) {
            cycle.push_back(c[p[v]]);
            int u = p[v];
            p[v] = -1;
            v = u;
        }
        int sz = cycle.size();
        ll sum = 0;
        for (auto x : cycle) sum += x;
        for (int i = 0; i < sz; i++) {
            ll res = 0;
            for (int j = i, iter = 1; iter <= k && iter <= sz; iter++, j = (j + 1) % sz) {
                res += cycle[j];
                ll last = k - iter;
                ll cyc = max(0ll, (last / sz) * sum);
                ans = max(ans, res + cyc);
            }
        }
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 3716
// 国内予選 2014 A 税率変更
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int s = sc.nextInt();
            if (x == 0) {
                break;
            }
            
            /*
             * s1: 商品1の税抜き価格
             * s2: 商品2の税抜き価格
             * x1: 商品1の変更前の税込価格
             * x2: 商品2の変更前の税込価格
             * y1: 商品1の変更後の税込価格
             * y2: 商品2の変更後の税込価格
             */
            int ans = 0;
            for (int s1 = 1; s1 < s; s1++) {
                for (int s2 = 1; s2 < s; s2++) {
                    int x1 = s1 * (100 + x) / 100;
                    int x2 = s2 * (100 + x) / 100;
                    
                    if (x1 + x2 == s) {
                        int y1 = s1 * (100 + y) / 100;
                        int y2 = s2 * (100 + y) / 100;
                        ans = Math.max(ans, y1 + y2);
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 20868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c;
  //string c;
  cin >> a;

  int ans = 0;
  //string ans = "Yes";
  repm(i, 1, a + 1){
    string s = to_string(i);
    if (s.size() % 2 != 0) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.5
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

Vi vec(0),a(0),b(0);
int k;

bool check(int now){
  int l = a.size(),ct = 0;
  
  rep(i,0,l){
    if(a[i]*b[i] <= now) continue;
    else {
      ct += dem((a[i]*b[i]-now),(b[i]));
    }
  }
  
  if(ct <= k) return true;
  else return false;
}

int binary(){
  int l = a.size();
  int L = 0,R = 1000000000000000,mid = (L+R)/2;
  int ans = 0;
  
  while(L<R){
    if(check(mid)) {
      R = mid;
      ans = R;
    }
    else L = mid+1;
    
    mid = (L+R)/2;
  }
  return ans;
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,qw,er,ty;
  cin >> n >> k;
  
  if(k>=10000000000000) cout << 0 << endl;
  
  rep(i,0,n){
    cin >> qw;
    a.pb(qw);
  }
  rep(i,0,n){
    cin >> qw;
    b.pb(qw);
  }
  
  sort(ALL(a));
  sortr(ALL(b));
  
  Verr(a);
  Verr(b);
  
  int ans = binary();
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4848
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    println!("{}", n*n*n);
}


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

int main()
{
    unsigned long long ullTimes = 0;
    unsigned long long ullHours = 0;
    unsigned long long ullMinutes = 0;
    unsigned long long ullSeconds = 0;
    
    cin >> ullTimes;
    
    ullHours = ullTimes / 60 / 60;
    ullMinutes = (ullTimes - (ullHours * 60 * 60)) / 60;
    ullSeconds = ullTimes % 60;
    
    cout << ullHours << ":" << ullMinutes << ":" << ullSeconds << endl;
    
    return 0;
}



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

vector<int> v[55];
bool vis[55]; 
int n,m;
int x[55],y[55],cnt=0;

void dfs(int a)
{
	cnt++;
	vis[a]=true;
	for(int k=0;k<v[a].size();k++)
		if(!vis[v[a][k]]) 
			dfs(v[a][k]);
		
} 

int main()
{
	int sum=0;
	cin >> n >> m;
	for(int i=0;i<m;i++)
		cin >> x[i] >> y[i];
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
			if(j != i)
			{
				v[x[j]].push_back(y[j]);
				v[y[j]].push_back(x[j]);
			}
		for(int j=1;j <= n;j++)
			vis[j]=false;
		dfs(1);
		if(cnt != n)
			sum++;
		for(int j=1;j <= n;j++)
			v[j].clear();
		cnt=0;
		cout << endl;
	}
	cout << sum << endl;
	return 0;
} 

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

int main()
{
    long int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    long long int c=a[n-1],k=n-2,flag=1;
    for(int i=0;i<n-2;i++)
    {
        c+=a[k];
       if(flag==0)
       {
           k--;
           flag=1;
       }
        else flag=0;        
    }
cout<<c;
	return 0;
}

Measured memory_bytes: 5196
package main

import "fmt"

type block struct {
	center int
	len int
}

func (b block) llen() int {
	return b.center + 1
}

func (b block) rlen() int {
	return b.len - b.llen()
}

// llenが奇数の場合に+1
func (b block) lcenter() int {
	if b.len % 2 == 0 {
		return b.len / 2
	}

	if b.llen() % 2 == 1 {
		return b.len/2 + 1
	}

	return b.len/2
}

// rlenが奇数の場合に+1
func (b block) rcenter() int {
	if b.len % 2 == 0 {
		return b.len / 2
	}

	if b.rlen() % 2 == 1 {
		return b.len/2 + 1
	}

	return b.len/2
}

func main() {
	var S string
	fmt.Scanf("%s", &S)

	var blocks []block
	var currentBlock block = block{}
	mode := "right"
	for _, s := range S {
		if mode == "right" {
			if s == 'L' {
				currentBlock.center = currentBlock.len - 1
				mode = "left"
			}
		} else {
			if s == 'R' {
				blocks = append(blocks, currentBlock)
				currentBlock = block{}
				mode = "right"
			}
		}
		currentBlock.len++
	}
	blocks = append(blocks, currentBlock)

	for _, b := range blocks {
		for i := 0; i < b.len; i++ {
			if i == b.center {
				fmt.Println(b.lcenter())
			} else if i == (b.center + 1) {
				fmt.Println(b.rcenter())
			} else {
				fmt.Println(0)
			}
		}
	}
}


Measured memory_bytes: 5632
#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, K;
ll a[100100], l[100100], r[100100], cum[100100], mx;

int main () {
        scanf("%d %d", &N, &K);
        fo(i, 0, N) {
                scanf("%lld", &a[i]);
                l[i+1] = l[i] + max(a[i], 0ll);
                cum[i+1] = cum[i] + a[i];
        }
        for (int i = N; i-->1; ) {
                r[i-1] = r[i] + max(a[i], 0ll);
        }
        fo(i, 0, N-K+1) {
                mx = max(mx, l[i] + r[i+K-1] + max(cum[i+K] - cum[i], 0ll));
        }
        printf("%lld\n", mx);
        return 0;
}



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

int main(int argc, char const *argv[])
{
    int H, W;
    string s[60];
    int ans[60][60];
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> s[i];
    
    int mcnt = 0;
    for(int h = 0; h < H; h++) for(int w = 0; w < W; w++)
        {
            if (s[h][w] == '#') {
                ans[h][w] = -1;
                continue;
            }
            
            for(int sh = -1; sh < 2; sh++) for(int sw = -1; sw < 2; sw++)
                {
                    if (h + sh < 0 || w + sw < 0) continue;
                    if (s[h + sh][w + sw] == '#') mcnt++;
                }
            ans[h][w] = mcnt;
            mcnt = 0;
        }
    
    for(int ah = 0; ah < H; ah++)
    {
        
        for(int aw = 0; aw < W; aw++)
        {
            if (ans[ah][aw] == -1) {
                cout << '#';
            }
            else {
                cout << ans[ah][aw];
            }
        }
        cout << endl;
    }
    

    return 0;
}



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int n;

void dfs(ll cur, ll &count) {
  if (cur > n) {
    return;
  }
  string s = to_string(cur);
  if (s.find('7') != string::npos
      && s.find('5') != string::npos
      && s.find('3') != string::npos) {
    count++;
  }
  vector<int> d = {7, 5, 3};
  for (int dd : d) {
    dfs(cur * 10 + dd, count);
  }
}

int main() {
  cin >> n;
  ll res = 0;
  dfs(0, res);
  cout << res << endl;
  return 0;
}


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

using namespace std;

int main() {
    long long a , b ;
    char c ; 
    scanf("%lld %c %lld", &a , &c , &b);
    if(c == '+'){
        cout << a + b << endl;
        return 0;
    }
    cout << (a - b) << endl;
}

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

int main(){
  int n;
  int ans = -2e9, mn = 2e9;
  cin >> n;
  for(int i = 0; i < n; i++){
    int t; cin >> t;
    ans = max(ans, t - mn);
    mn = min(mn, t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
 
int main(){
    vector<char> s(4);
    rep(i,4) cin >> s.at(i);
    sort(s.begin(), s.end());
    string ans;
    if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
}

Measured memory_bytes: 24388
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;


int main(){
    int N,M;
    cin >> N >> M;
    vector<bool> ok(N+1,true);

    int a;
    for(int i=0;i<M;i++){
        cin >> a;
        ok[a] = false;
    }

    vector<long long>dp(N+1);
    dp[0] = 1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(N,now+2);next++){
            if(ok[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
}


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

ll const MOD = 2019;

 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

ll inv_mul(ll x, ll y){
     return (x % MOD* modpow(y,MOD-2))%MOD;
 }

int main() {
    cin.tie(0);
     ios::sync_with_stdio(false);
     
    vector<ll> rev(2020);
    
    for (int i = 1; i < 2020; i++) {
        if(2019%i==0){
            rev[i]=0;
        }else{
            for (int j = 1; j < 2020; j++) {
                if(i*j%2019==1){
                    rev[i]=j;
                    break;
                }
            }
        }

    }
    
    string s;
    std::cin >> s;
    
    ll n = s.size();
    // std::cout << inv_mul(1009,5) << std::endl;
    ll ans = 0;
    map<ll,ll> cnt;
    cnt[0]++;
    ll last = 0;
    for (int i = 0; i < n; i++) {
        // std::cout << rev[10] << std::endl;
        ll rog = (last+(s[i]-'0')*modpow(rev[10],i+1))%2019;
        ans += cnt[rog];
        last = (last+(s[i]-'0')*modpow(rev[10],i+1))%2019;
        cnt[last]++;
        
        // std::cout <<rog<<" "<<last << std::endl;

        // std::cout << ans<<" a "<<i << std::endl;
    }
    
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3840
n = int(input())
from collections import defaultdict
link = defaultdict(list)
inc = defaultdict(int)
chg=10**6
for i in range(n):
    tmp=list(map(int,input().split()))
    for j in range(len(tmp)-1):
        me1 = min(i,tmp[j]-1)
        opp1 = max(i,tmp[j]-1)
        me2 = min(i,tmp[j+1]-1)
        opp2 = max(i,tmp[j+1]-1)
        now = me1*chg+opp1
        nxt = me2*chg+opp2
        link[now].append(nxt)
        inc[nxt]+=1

s=[]
for i in range(n):
    for j in range(i+1,n):
        if inc[i*chg+j]==0:
            s.append(i*chg+j)
res=[]
while s:
    nxt=s.pop()
    res.append(nxt)
    for m in link[nxt]:
        inc[m]-=1
        if inc[m]==0:
            s.append(m)
if len(res)!=((n-1)*n)//2:
    print(-1)
    exit()

path=defaultdict(lambda: -1)
for now in res:
    if path[now]==-1:
        path[now]=0
    for nxt in link[now]:
        path[nxt] = max(path[nxt],path[now]+1)
print(max(path.values())+1)

Measured memory_bytes: 217060
#include<bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define loop(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define br                break
#define con               continue

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
 
const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

priority_queue<pii, vector<pii>, greater<pii> >q;
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string s,s1,str;
    cin>>s>>s1;
    int mn = sz(s1);
    int n= sz(s);
    int n1= sz(s1);

    for(int i=0;i<n-n1+1;i++){
    	str = s.substr(i,n1);
    	int coun=0;
    	if(str.size()<n1)break;
    	for(int j=0;j<n1;j++){
    		if(str[j]!=s1[j])coun++;
    	}
    	mn = min(mn,coun);
    	if(mn==0){
    		cout<<0<<endl;
    		return 0;
    	}
    	str.clear();
    }
    cout<<mn<<endl;
 
}

Measured memory_bytes: 3616
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long ans = 0;
        long i = 1;
        Set<Long> set = new HashSet<Long>();
        while (i * i <= N) {
            if (N % i == 0) {
                long g = N / i;
                set.add(i);
                set.add(g);
            }
            i++;
        }
        for (Long l : set) {
            l--;
            if (l == 0) {
                continue;
            }
            if (N % l == N / l) {
                ans += l;
            }

        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 22784
#include <stdio.h>
int main(){

  int S=0,h,m,s;

  scanf("%d",&S);
  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#define debug(x) cout<<x<<"\n";
#define Max(a,b) ((a)>(b)?(a):(b))
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f;
using namespace std;
int main()
{	
	string s;
	cin>>s;
	char flag=s[0];
	int cnt=0;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]!=flag)
		{
			cnt++;
			flag=s[i];
		}
	}
	cout<<cnt<<"\n";
	return 0;
} 

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

map <string,int> mp;
signed main(){
  int n , ans=0;
  vector<string> vec;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
	cin>>s;
    mp[s]++;
    ans=max(ans,mp[s]);
    vec.push_back(s);
  }
  
  sort(vec.begin(),vec.end());
  for(int i=0;i<vec.size()-ans+1;i++){
    if(vec[i] == vec[i+ans-1]){
      cout<<vec[i]<<endl;
    }
  }
  return(0);
}

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

int sumDigit(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int n, a, b;
  cin >> n;
  
  int ans = 0;
  
  for(a = 1; a < n; a++) {
    b = n - a;
    int tempAns = sumDigit(a) + sumDigit(b);
    if(ans == 0 || ans > tempAns) ans = tempAns;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T, class S> int arrCountVal(int N, T A[], S val){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i]==val){
      res++;
    }
  }
  return res;
}
template<class T> inline int Cmod2(T n, T k){
  if((n&k)==k){
    return 1;
  }
  return 0;
}
int N;
char S[1000000+2];
int main(){
  int i;
  int m = 0;
  int mul = 1;
  rd(N);
  rd(S);
  for(i=(0);i<(N);i++){
    S[i] -= '1';
  }
  if(arrCountVal(N,S,1)==0){
    mul = 2;
    for(i=(0);i<(N);i++){
      S[i] /= 2;
    }
  }
  for(i=(0);i<(N);i++){
    m = (m + S[i] * Cmod2(N-1,i)) % 2;
  }
  wt_L(mul * m);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200322-1 [beta]

// --- original code ---
// int N;
// char S[1d6+2];
// 
// {
//   int m = 0, mul = 1;
//   rd(N,S);
//   rep(i,N) S[i] -= '1';
// 
//   if(arrCountVal(N,S,1)==0){
//     mul = 2;
//     rep(i,N) S[i] /= 2;
//   }
// 
//   rep(i,N) m = (m + S[i] * Cmod2(N-1,i)) % 2;
//   wt(mul * m);
// }


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=200005;

int n,cnt,last[N],fa[N],dep[N],dis[N],q[N],dfn[N],mx[N],tim,a[N][2],sx,sy;
bool vis[N],win[N];
struct edge{int to,next,col;}e[N*4];

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

void addedge(int u,int v,int col)
{
	e[++cnt].to=v;e[cnt].col=col;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].col=col;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x)
{
	dep[x]=dep[fa[x]]+1;dfn[x]=++tim;
	for (int i=last[x];i;i=e[i].next)
		if (e[i].to!=fa[x]) fa[e[i].to]=x,dfs(e[i].to);
	mx[x]=++tim;
}

bool check(int x,int y)
{
	if (dfn[x]>dfn[y]) swap(x,y);
	if (dfn[x]<dfn[y]&&mx[x]>dfn[y]) return dep[y]-dep[x]>2;
	if (fa[x]==fa[y]) return 0;
	return 1;
}

void bfs()
{
	int h=1,t=1;q[1]=sx;vis[sx]=1;
	while (h<=t)
	{
		int x=q[h++];
		for (int i=last[x];i;i=e[i].next)
			if (!e[i].col&&!vis[e[i].to])
			{
				dis[e[i].to]=dis[x]+1;
				if (dis[e[i].to]<dep[e[i].to]) vis[e[i].to]=1,q[++t]=e[i].to;
			}
	}
}

int main()
{
	n=read();sx=read();sy=read();
	for (int i=1;i<n;i++) a[i][0]=read(),a[i][1]=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y,1);
	}
	dep[0]=-1;dfs(sy);
	for (int i=1;i<n;i++)
	{
		if (check(a[i][0],a[i][1])) win[a[i][0]]=win[a[i][1]]=1;
		else addedge(a[i][0],a[i][1],0);
	}
	bfs();
	for (int i=1;i<=n;i++) if (win[i]&&vis[i]) {puts("-1");return 0;}
	int ans=0;
	for (int i=1;i<=n;i++) if (vis[i]) ans=max(ans,dep[i]*2);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 22656
#include<bits/stdc++.h>
#define ll long long
#define pub push_back 
#define pob pop_back 
#define puf push_front
#define pof pop_front
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
using namespace std ;
int main()
{
	ll a , b , k ;
	cin >> a >> b ;
	if((a+b)%2 == 0)
		cout<< (a+b)/2 << endl ;
	else
		cout << "IMPOSSIBLE" << endl ;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string Map[101]={};
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++)
      if(i<50)
	Map[i]+='.';
      else
	Map[i]+='#';
  int wcnt=0;
  int bcnt=0;
  if(b!=1){
  for(int i=0;i<49;i+=2){
    for(int j=0;j<100;j+=2){
      Map[i][j]='#';
      bcnt++;
      if(bcnt==b-1)
	break;
    }
    if(bcnt==b-1)
      break;
  }
  }
  if(a!=1){
  for(int i=51;i<100;i+=2){
    for(int j=0;j<100;j+=2){
      Map[i][j]='.';
      wcnt++;
      if(wcnt==a-1)
	break;
    }
    if(wcnt==a-1)
      break;
  }
  }
  cout<<100<<" "<<100<<endl;
  for(int i=0;i<100;i++)
    cout<<Map[i]<<endl;
  return 0;
}


Measured memory_bytes: 256