akhauriyash/Code-Regression huggingface dataset:
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << '\n';
 	return 0; 
}


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

void solve(){
    double n,m,d;
    double p=0;
    cin>>n>>m>>d;
    p=(d==0)?1/n:2*(n-d)/(n*n);
    double ans=p*(m-1);
    printf("%.10lf\n",ans);
}
int main(){
    solve();
    return 0;
}


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

long long a[305][305],b[305][305];
int sa[305][305];
bool v[305][305];

int main()
{
    int n;

    scanf("%d",&n);

    memset(sa,-1,sizeof(sa));

    for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++)
    {
        scanf("%lld",&a[i][j]);
        b[i][j] = a[i][j];
    }

    for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++) v[i][j] = 1;

    for (int k = 1;k <= n;k++)
        for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++)
        if (a[i][j] >= a[i][k] + a[k][j] && i != k && j != k)
        {
            a[i][j] = a[i][k] + a[k][j];

            v[i][j] = v[j][i] = 0;
        }

    bool f = 0;

    for (int i = 1;i <= n;i++)
        for (int j = 1;j <= n;j++)
    {
        if (a[i][j] != b[i][j]) f = 1;
    }

    if (f) printf("-1\n");
    else
    {
        long long ans = 0;

        for (int i = 1;i <= n;i++)
            for (int j = i + 1;j <= n;j++) if (v[i][j]) ans += a[i][j];

        printf("%lld\n",ans);
    }
    return 0;
}


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

int n;
vector <int> a;

bool one(int x){
    vector <bool> b;
    for(int&i : a)
        b.push_back(i<=x);
    //cout << x << " = " << b[n-2] << ' ' << b[n-1] << ' ' << b[n] << endl;
    if(b[n-1]==b[n-2] || b[n-1]==b[n])
        return b[n-1];
    int left = 0 ,right = 0;
    for(int i=n-2; ~i; i--){
        if(b[i] == b[i+1])
            break;
        left++;
    }
    for(int i=n; i<2*n-1; i++){
        if(b[i] == b[i-1])
            break;
        right++;
    }
    if(left < right)
        return b[n-1-left];
    if(right < left)
        return b[n-1+right];
    return (left&1) ? !b[n-1] : b[n-1];
}

int main()
{
    scanf("%d",&n);
    a.resize(2*n-1);
    for(int&i : a)
        scanf("%d",&i);

    int st = 1 ,en = 2*n-1 ,mid;
    while(st <= en){
        mid = (st+en)>>1;
        if(one(mid))
            en = mid-1;
        else
            st = mid+1;
    }

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


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

using namespace std;

int main(){
    cin.exceptions(cin.failbit);
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (n/2 + n%2) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n=0;

  cin >> n;
  int* pAry = NULL;
  pAry = new int[n];
  for(int i=0; i<n; i++){
      cin >> pAry[i];
  }

  int count = 0;
  int breaking = 0;
  while(1) {
      for(int i=0; i<n; i++){
        if( pAry[i] % 2 == 0 ){
          pAry[i] = pAry[i] / 2;
        } else {
          breaking = 1;
          break;
        }
      }
    if( breaking == 1 ){ break; }
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
 
const int maxn = 1e5+5;
int a[maxn],n;
typedef long long LL;
 
LL x;
 
void solve(){
	LL ans = x/(11LL);
	ans = ans*2LL;
	LL y = x % 11LL;
//	printf("y = %I64d\n",y);
	if(y != 0LL){
		if(y <= 6){
		ans++;
	}
	if(y >= 7 && y < 11){
		ans += 2;
	}
	}
	
	printf("%lld\n",ans);
 
}
 
int main(){
	while(scanf("%lld",&x) != EOF){
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - City Savers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N + 1], bs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i <= n; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", bs + i);

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    if (as[i] > bs[i]) sum += bs[i];
    else {
      int d = min(bs[i] - as[i], as[i + 1]);
      as[i + 1] -= d;
      sum += as[i] + d;
    }
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1024
/*		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define modo 1000000007
#define ff first
#define ss second 
#define ld long double
#define pb push_back
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x).begin(),(x).end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a; ll res = 1;
    while(b){
        if (b & 1)
        res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
	//cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		ll a[n+1];
		fe(i,1,n)
		cin>>a[i];
		
		ll dp[n+5]={0};
		dp[1]=1000;
		ll ans=1000;
		f(i,1,n)
		{
			ll stocks=0;
			if(a[i]<a[i+1])
			{stocks=ans/a[i];
			ans+=(a[i+1]-a[i])*stocks;
			}
		}
		
		cout<<ans;
		
	}
return 0;
}


Measured memory_bytes: 3660
// AOJ 1526: Password
// 2019.2.20 bal4u

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

char A[1005], B[1005];

int match(char *a, int la, char *b, int lb)
{
	int i, j, w;
	
	w = la - lb;
	for (i = 0; i <= w; i++) {
		for (j = 0; ; j++) {
			if (j == lb) return 1;
			if (b[j] != '_' && a[i + j] != b[j]) break;
		}
	}
	return 0;
}

int main()
{
	scanf("%s%s", A, B);
	puts(match(A, strlen(A), B, strlen(B)) ? "Yes" : "No");
	return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int dfs(int, bool[]);

int route[9][9];
int n, m;

int main(){
  cin.sync_with_stdio(false);
  cin >> n >> m;

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    route[a][b] = route[b][a] = 1;
  }

  bool visited[n + 1] = {false};
  visited[1] = true;
  print(dfs(1, visited));

  return 0;
}

int dfs(int v, bool visited[]) {
  bool newVisited[n + 1];

  bool all = true;
  repl(i, 1, n + 1) {
    newVisited[i] = visited[i];
    if(!visited[i]) all = false;
  }

  if(!all) {
    int cnt = 0;
    bool ok = false;
    repl(i, 1, n + 1) {
      if (route[v][i] == 1 && !newVisited[i]) {
        newVisited[i] = true;
        cnt += dfs(i, newVisited);
        newVisited[i] = false;
      }
    }
    return cnt;
  } else {
    return 1;
  }
}

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

int main(void){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    rep(i, n){
        cin >> x.at(i);
    }
    rep(i, m){
        cin >> y.at(i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    string s = "War";
    int max_x = max(x.at(n-1), X);
    int min_y = min(y.at(0), Y);
    if(max_x < min_y){
        s = "No War";
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab_s = sorted(ab, key=itemgetter(1))
ans = 'Yes'
tmp = 0
for x in ab_s:
    tmp += x[0]
    if tmp > x[1]:
        ans = 'No'
        break
print(ans)        

Measured memory_bytes: 55268
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 10;

long long n, a, b;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> a >> b;
    if ((b - a) % 2) {
        long long ans = 1e18;
        long long nowa = a, nowb = b;
        // a bere to 1
        nowb -= (a - 1);
        nowb--;
        ans = min (ans, a - 1 + 1 + (nowb - 1) / 2);
        // b bere to n
        long long x = n - b;
        nowa = a + x + 1;
        ans = min (ans, x + 1 + (n - nowa) / 2);
        cout << ans << '\n';
    }
    else {
        cout << (b - a) / 2 << '\n';
    }
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    tmp = N // 2
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2 and k != 0:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(0)
                        sys.exit()
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = N // 2    
    print((2**tmp) % 1000000007)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 61744
#include<bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define debug(x) cout << #x << " = " << x << endl
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int H,W,K;
const int mod = 1e9+7;
struct Matrix{
	int a[4][4];
	int* operator [] (int x){
		return a[x];
	}
	Matrix operator * (const Matrix &b){
		Matrix c;
		rep(i,0,4){
			rep(j,0,4){
				c[i][j] = 0;
				rep(k,0,4) c[i][j] = (c[i][j] + 1ll * a[i][k] * b.a[k][j]) % mod;
			}
		}
		return c;
	}
}M;
inline int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans = 1ll * ans * a % mod;
	return ans;
}
Matrix qpow(Matrix a,int b){
	Matrix ans;
	mem(ans.a,0);rep(i,0,4) ans[i][i]=1;
	for(;b;b>>=1,a=a*a)
		if(b&1) ans = ans * a;
	return ans;
}
char a[1005][1005];
int cntV,cntE0,cntE1,cntD0,cntD1; 
signed main(){
//	freopen("05.in","r",stdin);
	H = rd(),W = rd(),K = rd();
	Rep(i,1,H){
		Rep(j,1,W){
			a[i][j] = gc();
			while(a[i][j] != '#' && a[i][j]!='.') a[i][j] = gc();
			if(a[i][j] == '#') a[i][j] = 1; else a[i][j] = 0;
		}
	}
	cntV=0,cntE0=cntE1=cntD0=cntD1=0;
	Rep(i,1,H)Rep(j,1,W)cntV += a[i][j];
	Rep(i,1,H-1)Rep(j,1,W)cntE0 += (a[i][j]&a[i+1][j]);
	Rep(i,1,H)Rep(j,1,W-1)cntE1 += (a[i][j]&a[i][j+1]);
	Rep(j,1,W)cntD0 += (a[1][j]&a[H][j]);
	Rep(i,1,H)cntD1 += (a[i][1]&a[i][W]);
	if((cntD0&&cntD1)||K==0){puts("1");return 0;} else
	if((!cntD0&&!cntD1)){writeln(qpow(cntV,K-1));return 0;}
	M[0][0] = cntV;	M[0][1] = 0;	M[0][2] = 0;	M[0][3] = 0;
	M[1][0] = cntE0;M[1][1] = cntD0;M[1][2] = 0;	M[1][3] = 0;
	M[2][0] = 0;	M[2][1] = 0;	M[2][2] = cntV;	M[2][3] = 0;
	M[3][0] = 0;	M[3][1] = 0;	M[3][2] = cntE1;M[3][3] = cntD1;
	M = qpow(M,K-1);
	ll Vnum = qpow(cntV,K-1);
	if(cntD0)Vnum = (Vnum + mod - M[1][0]) % mod;
	if(cntD1)Vnum = (Vnum + mod - M[3][2]) % mod;
	writeln(Vnum);
//f[i] = f[i-1] * cntV + cntE0 * F[i-1]
//F[i] = F[i-1] * cntD0
//g[i] = g[i-1] * cnt
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, t;
    cin>>n;
    t = n;
    ll sum = LLONG_MAX;
    for(ll x = 1; x*x<=n; x++)
    {
        if(n%x==0)
        {
            ll s = x + (n/x);
            if(sum>s)
            {
                sum = s;
            }
        }
    }
    cout<<sum-2;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  ll h, w;
  cin >> h >> w;

  vector<string> grid;

  for (ll i = 0; i < h; i++) {
    string line;
    cin >> line;
    grid.push_back(line);
  }

  using Point = pair<ll, ll>;
  queue<pair<ll,ll>> q;
  vector<vector<ll> > distance(h, vector<ll>(w, -1));

  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      if (grid[i][j] == '#') {
        q.push(Point(i, j));
        distance[i][j] = 0;
      }
    }
  }

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

    ll x = current.first;
    ll y = current.second;

    grid[x][y] = '#';

    if (x - 1 >= 0 && grid[x - 1][y] == '.') {
      if (distance[x - 1][y] == -1) {
        q.push(Point(x - 1, y));
        distance[x - 1][y] = distance[x][y] + 1;
      }
    }

    // down
    if (x + 1 < grid.size() && grid[x + 1][y] == '.') {
      if (distance[x + 1][y] == -1) {
        q.push(Point(x + 1, y));
        distance[x + 1][y] = distance[x][y] + 1;
      }
    }

    // right
    if (y + 1 < grid[0].size() && grid[x][y + 1] == '.') {
      if (distance[x][y + 1] == -1) {
        q.push(Point(x, y + 1));
        distance[x][y + 1] = distance[x][y] + 1;
      }
    }

    // left
    if (y - 1 >= 0 && grid[x][y - 1] == '.') {
      if (distance[x][y - 1] == -1) {
        q.push(Point(x, y - 1));
        distance[x][y - 1] = distance[x][y] + 1;
      }
    }

    // for (ll i = 0; i < h; i++) {
    //   for (ll j = 0; j < w; j++) {
    //     cout << distance[i][j] << ' ';
    //   }
    //   cout << endl;
    // }
    // cout << endl;
  }

  ll ans = 0;
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      ans = max(ans, distance[i][j]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 25524
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(double base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
}
bool prime[100000 + 10];
int res[100000 + 10];
void _prime()
{
	for (int i = 0; i < 100000 + 10; i++)
	{
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i < 100000 + 10; i++)
	{
		if (prime[i])
		{
			for (int j = i * 2; j < 100000 + 10; j += i)
				prime[j] = false;
		}
	}
	for (int i = 1; i < 100000 + 10; i++)
	{
		if (i % 2 == 0)
			continue;
		if (prime[i] == false)
			continue;
		if (prime[(i + 1) / 2] == false)
			continue;
		res[i] = 1;
	}
	for (int i = 1; i < 100000 + 10; i++)
	{
		res[i] = res[i - 1] + res[i];
	}
}
int main(){
	//Qalbaz();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	_prime();
	int q;
	int l, r;
	cin >> q;
	while (q--)
	{
		cin >> l >> r;
		cout << res[r] - res[l - 1] << "\n";
	}
	return 0;
}

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


using namespace std;

int main()
{
    char str1[11],str2[11];
    while(~scanf("%s%s",str1,str2))
    {
        if((str1[0] == '-' && str2[0] != '-') || (str2[0] == '-' && str1[0] != '-'))
        {
            printf("Zero\n");
        }
        else if(str1[0] != '-' && str2[0] != '-')
        {
            printf("Positive\n");
        }
        else if(str1[0] == '-' && str2[0] == '-')
        {
            int len1 = strlen(str1);
            int len2 = strlen(str2);
            int a = str1[len1-1] - '0';
            int b = str2[len2-1] - '0';
            if((a-b) % 2 == 0)
            {
                printf("Negative\n");
            }
            else
            {
                printf("Positive\n");
            }
        }
    }
    return 0;
}

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

using namespace std ;


signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL)  ;

    int n ;
    cin >> n ;
    int temp = n%1000 ;
    if(temp == 0 )
    {
        cout << 0 << endl ;
    }
    else
    {
        cout << (1000 -temp) << endl ;
    }

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char C;
cin>>C;
C++;
cout<<C<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <climits>

using namespace std;
#define forn(x, n)         for (int x = 0; x < n; x++)
#define forr(x, n)         for (int x = n; x >= 0; x--)
#define for1(x, n)         for (int x = 1; x < n; x++)
#define fore(x, a, b, c)   for (int x = a; x <= b; x += c)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define eprint(...) 0
#endif
template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int N = 10;
string grid[N];
int row[N], col[N];
char line[N];

int main(void)
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    forn(i, n) {
        scanf("%s", line);
        grid[i] = string(line);
    }    
    int total = 0;
    forn(i, n) forn(j, m) {
        if (grid[i][j] == '#') row[i]++, col[j]++, ++total;
    }
    // eprint(total);
    int ans = 0;
    forn(mask1, (1 << n)) {
        forn(mask2, (1 << m)) {
            int tmp = 0;
            forn(i, n) if (mask1 & (1 << i)) tmp += row[i];
            forn(i, m) if (mask2 & (1 << i)) tmp += col[i];
            int tmp2 = 0;
            forn(i, n) forn(j, m) {
                if ((mask1 & (1 << i)) && (mask2 & (1 << j))) tmp2 += (grid[i][j] == '#' ? 1 : 0);
            }
            tmp -= tmp2;
            // eprint(total - tmp);
            if (total - tmp == k) ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3812
N, D = map(int,input().split()) # 複数の数字を変数に格納
List = [list(map(int,input().split())) for i in range(N)] # [[1,2],[3,4],[5,6]]

import math

count = 0

for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            tmp += (List[i][k] - List[j][k])**2
        tmp = math.sqrt(tmp)
        if tmp.is_integer() == True:
            count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678], aa[1234][1234], bb[1234][1234];
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
char maze[1234][1234];
signed main() {
	ll n, m, k, sum = 0, cnt = 1, ans = 0; cin >> n >> m;
	string s; cin >> s;
	if (m % 10 == 0) {
		for (int h = 0; h < n; h++) { if ((ll)(s[h] - '0') % 10 == 0) { ans += h + 1; } }
		cout << ans << endl; return 0;
	}
	if (m % 2 == 0) {
		for (int h = 0; h < n; h++) { if ((ll)(s[h] - '0') % 2 == 0) { ans += h + 1; } }
		cout << ans << endl; return 0;
	}
	if (m % 5 == 0) {
		for (int h = 0; h < n; h++) { if ((ll)(s[h] - '0') % 5 == 0) { ans += h + 1; } }
		cout << ans << endl; return 0;
	}
	reverse(s.begin(), s.end()); test[0] = 1;
	for (int h = 0; h < s.size(); h++) {
		sum = ((ll)(s[h] - '0') * cnt + sum) % m;
		test[sum]++; //cout << sum << endl;
		cnt *= 10; cnt %= m;
	}
	for (int h = 0; h < m; h++) {
		ans += test[h] * (test[h] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    double r; cin >> r;

    cout << fixed << setprecision(15) << r * 2 * acos(-1) << endl;
}

Measured memory_bytes: 3768
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

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

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;



		while (n >= 1)
		{
			x = n % 26;
			if (x == 0)
				x = 25;
			else
				x--;
			n = n / 26;

			if (x == 25)
				n--;


			ch = 'a' + x;

			str.pb(ch);
		}
		for (i = str.size() - 1; i >= 0; i--)
			cout << str[i];




		ln
	}
	return 0;
}


Measured memory_bytes: 3656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut c = 0;
    for i in 0..n {
        if v[i] != i + 1 {
            c += 1;
        }
    }
    if c <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250005
#define in(x)  cin>>x
#define in4(w,x,y,z) cin>>w>>x>>y>>z
#define in3(x,y,z) cin>>x>>y>>z
#define o(x)  cout<<x
#define o2(x,y) cout<<x<<' '<<y;
#define o3(x,y,z) cout<<x<<' '<<y<<' '<<z
#define o4(w,x,y,z)cout<<w<<' '<<x<<' '<<y<<' '<<z
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
S s,t,u;
int main()
{
    fast;
  in(s>>t);
  n=s.size();m=t.size();
  u=s.substr(0,m);
  fr(i,m,n-1)
  {
      c=0;
      fr(j,0,m-1)
      {
          if(u[j]==t[j])c++;
      }
      u.erase(0,1);
      u+=s[i];
      x=max(x,c);
  }
  c=0;
    fr(j,0,m-1)
      {
          if(u[j]==t[j])c++;
      }
      x=max(x,c);
  o(m-x);
}



Measured memory_bytes: 3660
N = int(input())
L = list(map(int,input().split()))
cand = []
bit =[[0 for i in range(20)] for _ in range(N)]
for j in range(len(L)):
    for i in range(20):
        bit[j][i] = (L[j] >> i) & 1
for j in range(1,len(L)):
    for i in range(20):
        bit[j][i] += bit[j-1][i]
bit = [[0 for i in range(20)]] + bit

#bisect( [x,y) )

def check(start,x):
    for i in range(20):
        if bit[x][i] - bit[start][i] >= 2:
            return False
    return True


def bisect(start,x,y):
    if y - x == 1: return x
    mid = (x + y) // 2
    if check(start,mid) == False:
        return bisect(start,x,mid)
    else:
        return bisect(start,mid,y)

cnt = 0
for n in range(N):
    cnt += bisect(n, n, N+1) - n
 #   print(bisect(n,n,N+1),n)
print(cnt)



Measured memory_bytes: 127948
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

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

def soin(a):
    fa = []
    i = 2
    d = a
    last = 1
    while d>1:
        if d % i == 0:
            if last == i:
                fa[-1][1]=fa[-1][1]+1
            else:
                fa.append([i,1])
            d=d//i
            last = i
        else:
            i += 1
        if i * i > a:
            fa.append([a,1])
            break

    return(fa)

#print(soin(n))
q = soin(m)
answer = 1

for i in q:
#    print(i,i[1])
    r = i[1]
    a = 1
    for j in range(n,n+r):
        a = a * j
    for j in range(r):
        a = a // (j+1)
    answer = answer * a % (10**9+7)

print(answer)


Measured memory_bytes: 18836
#include <iostream>
#include <vector>
#include <algorithm>
// #include <map>
// #include <cmath>
// #include <string>

using namespace std;
// typedef unsigned long long ull;


int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;

    return 0;
}


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

int main()
{    
    int n;
    string s;
    cin >> n >> s;

    if(n%2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    bool is_repeat = (s.substr(0,n/2) == s.substr(n/2));

    cout << (is_repeat ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
// file creato da gio il 2020-03-31 21:23:51.244691

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;


int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int N,M;
	cin >>M>> N;
	int a,b,f;
	cin >>a;
	f=a;
	int sum=0,maxi=0;

	for(int i=0;i<N-1;i++){
		b=a;
		cin >>a;
		if(maxi<a-b){
			sum+=maxi;
			maxi=a-b;
		}else
		sum+=a-b;

	}
	if(maxi<f+(M-a)){
		sum+=maxi;
		maxi=f+(M-a);
	}else
		sum+=f+(M-a);
	cout <<sum;
	


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int min = 0;
		for (int i=1; i < n/2+1; i++) {
			int a = i;
			int b = n - a;
			int tmp = 0;
			tmp += a/10000;
			tmp += (a%10000)/1000;
			tmp += (a%1000)/100;
			tmp += (a%100)/10;
			tmp += (a%10);
			tmp += b/10000;
			tmp += (b%10000)/1000;
			tmp += (b%1000)/100;
			tmp += (b%100)/10;
			tmp += (b%10);
			if (min==0 || min > tmp) {
				min = tmp;
			}
		}

		System.out.println(min);

	}
}

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

int main(){
	char S[100000];
	int count0=0,count1=0;
	scanf("%s",S);
	int len = strlen(S);

	for(int i=0;i<len;i++){
		if(S[i] == '0')count0++;
		else count1++;
	}

	if(count0 > count1)printf("%d\n",2*count1);
	else if(count0 < count1)printf("%d\n",2*count0);
	else printf("%d\n",2*count0);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a[4096][3], i=0, p=0, q=0;
	
	while(scanf("%d,%d,%d",&a[i][0],&a[i][1],&a[i][2])!=EOF) {
		
		if (a[i][2]*a[i][2] == a[i][1]*a[i][1] + a[i][0]*a[i][0]) p++;
		
		if (a[i][1] == a[i][0]) q++;
		
		i++;
	}
	printf("%d\n%d\n", p, q);
	return 0;
}

Measured memory_bytes: 0
def my_round(x,d=0):
    p=10**d
    return (x*p*2+1)//2/p


N = int(input())
lst_a = list(map(int, input().split()))


a_ave = sum(lst_a) / N
target_val = int(my_round(a_ave))
ans = sum([(a - target_val)**2 for a in lst_a])
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = []
for i in range(n):
    a += [list(map(int, input().split()))[2:]]
cnt = 1
pre = [0]*n
aft = [0]*n
color = [0]*n
def dfs(s):
    global cnt
    pre[s-1] = cnt
    cnt += 1
    color[s-1] = 1
    for i in a[s-1]:
        if color[i-1] == 0:dfs(i)
    aft[s-1] = cnt
    cnt += 1

for i in range(n):
    if color[i] == 0:
        dfs(i+1)

for i in range(n):
    print(i+1, pre[i], aft[i])
        
    
    


Measured memory_bytes: 5648
#include<iostream>
using namespace std;
int main(){
    int N,A,max=1,min=1000;
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> A;

        if(A<=min){
            min=A;
        }if(A>=max){
            max=A;
        }
    }
    cout << max-min << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N,M,*X=map(int,open(0).read().split())
X.sort()
a=np.array(X)
d=np.diff(a)
d.sort()
all=X[-1]-X[0]
left=d[::-1][:N-1].sum() #rverse + slice + sum
print(all-left)

Measured memory_bytes: 23028
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()


import math

def sieve_of_eratosthenes(n):
    prime_list = []  # n以下の素数のリスト
    A = [1]*(n+1)    # A[i] = iが素数なら1,その他は0
    A[0] = A[1] = 0
    for i in range(2,math.floor(math.sqrt(n))+1):
        if A[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                A[j] = 0
    for i in range(math.floor(math.sqrt(n))+1,n+1):
        if A[i] == 1:
            prime_list.append(i)
    return prime_list


prime_list = sieve_of_eratosthenes(55555)

ANS = [2]
for p in prime_list:
    if p == 2:
        continue
    else:
        if p % 10 == 1:
            ANS.append(p)
            if len(ANS) == N:
                break

print(*ANS)

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

using namespace std;

int arr[103];
int dp[100005][2];

int solve(int k, int p, int n){
    if(k==0)return 0;
    for(int  i =1; i<=n; ++i){
        if(arr[i]==k){
            return 1;
        }
    }
    if(dp[k][p]!=-1)return dp[k][p];

    int ret = 0;
    for(int i = 1; i<=n; ++i){
        if(arr[i]<=k)ret = ret | (1-solve(k-arr[i],1-p,n));
    }

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

int main(){
    memset(dp,-1,sizeof(dp));
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 1; i<=n; ++i){
        scanf("%d",&arr[i]);
    }
    int w = solve(k,0,n);
    if(w==1){
        cout<<"First\n";
    }
    else{
        cout<<"Second\n";
    }
    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int a[3],ans;
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	a[1]=a[2]-a[1];
	a[0]=a[2]-a[0];
	if((a[1]&1)==(a[0]&1))
	{
		if(a[0]&1)cout<<a[0]/2+a[1]/2+1;
		else cout<<a[0]/2+a[1]/2;
	}
	else cout<<a[0]/2+a[1]/2+2;
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    string S;
    cin >> S;

    ll cnt1 = 0;
    ll cnt2 = 0;
    ll cnt3 = 0;
    ll cnt4 = 0;
    
    rep (i, S.size()) {
        if (S[i] == 'N') {
            cnt1++;
        }
        if (S[i] == 'S') {
            cnt2++;
        }
        if (S[i] == 'W') {
            cnt3++;
        }
        if (S[i] == 'E') {
            cnt4++;
        }
    }

    bool flag1 = false;
    bool flag2 = false;

    if ((cnt1 == 0 && cnt2 == 0) || (cnt1 != 0 && cnt2 != 0)) {
        flag1 = true;
    }
    if ((cnt3 == 0 && cnt4 == 0) || (cnt3 != 0 && cnt4 != 0)) {
        flag2 = true;
    }

    if (flag1 && flag2) {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long k = sc.nextLong();
			long x = sc.nextLong();
			System.out.println(k * 500 >= x ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 20052
import java.util.*;

public class Main implements Comparable<Main>{

	int l;
	public Main(int l) {
		this.l = l;
	}
	
	public int compareTo(Main o) {
		if(l < o.l)return 1;
		else if(l > o.l)return -1;
		else return 0;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int l[] = new int[2 * n];
		for(int i = 0; i < 2 * n; ++i)l[i] = sc.nextInt();
		sc.close();
		Arrays.sort(l);
		int ans = 0;
		for(int i = 0; i < 2 * n - 1; i += 2) {
			ans += l[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==b)
  {
    cout<<a+a;
  }
  else if(a>b){
    cout<<a+(a-1);
  }
  else
  {
    cout<<b+(b-1);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long top,nex[200005],to[200005],qu[200005],fir[100005];
void lj(int u,int v,int w){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
	qu[top]=w;
}
long long n,i,j,x[100005],y[100005],z[100005],sum[100005],f[100005],ans,min1,max1,max2,max3;
void ss(int u,int v,long long w){
	sum[v]=1;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u){
			ss(v,to[top1],qu[top1]);
			sum[v]+=sum[to[top1]];
			f[v]=max(f[v],sum[to[top1]]);
		}
	f[v]=max(f[v],n-sum[v]);
	ans+=w*min(sum[v],n-sum[v])*2;
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();
   	for(i=1;i<n;i++){
		x[i]=read();y[i]=read();z[i]=read();
		lj(x[i],y[i],z[i]);
		lj(y[i],x[i],z[i]);
	}
	ss(1,1,0);
	min1=1000000000000000000LL;
	for(i=1;i<=n;i++)
		min1=min(min1,f[i]);
	for(i=1;i<=n;i++)
		if(f[i]==min1){
			if(max2==0)
				max2=i;
			else
				max3=i;
		}
	min1=1000000000000000000LL;
	if(max3==0){
		for(i=1;i<n;i++)
			if(x[i]==max2||y[i]==max2)
				min1=min(min1,z[i]);
	}
	else{
		for(i=1;i<n;i++)
			if(x[i]==max2&&y[i]==max3||x[i]==max3&&y[i]==max2)
				min1=min(min1,z[i]);
	}
	ans-=min1;
	pus(ans,2);	
    return 0;
}

Measured memory_bytes: 13568
A, B, C, D = gets.split(' ').map(&:to_i)

divisible_by_C = B / C - (A - 1) / C
divisible_by_D = B / D - (A - 1) / D
lcm_CD = C.lcm(D)
divisible_by_CD = B / lcm_CD - (A - 1) / lcm_CD

print (B - A + 1) - divisible_by_C - divisible_by_D + divisible_by_CD


Measured memory_bytes: 1788
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN {
    int n;
    struct E{
        int next,to,val;
        E() {}
        E(res next,res to,res val):next(next),to(to),val(val) {}
    }edge[N<<1];
    int head[N],cnt;
    inline void addedge(const res &u,const res &v,const res &w){
        edge[++cnt]=E(head[u],v,w),head[u]=cnt;
        edge[++cnt]=E(head[v],u,w),head[v]=cnt;
    }
    int col[N];
    void dfs(res x,res fax){
        for(res i=head[x];~i;i=edge[i].next){
            res tox=edge[i].to;
            if(tox==fax)continue;
            if(edge[i].val)col[tox]=col[x]^1;
            else col[tox]=col[x];
            dfs(tox,x);
        }
    }
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)head[i]=-1;
        for(res i=1;i<n;i++){
            res u=read(),v=read(),w=read()&1;
            addedge(u,v,w);
        }
        dfs(1,0);
        for(res i=1;i<=n;i++)printf("%d\n",col[i]);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 5632
using System;
using System.Linq;

namespace ABC072
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] res = new int[a.Max() + 2];

            foreach (var item in a)
            {
                res[item + 1] += 1;
                res[item] += 1;
                if (0 < item) res[item - 1] += 1;

            }
            Console.WriteLine(res.Max());
        }
    }
}


Measured memory_bytes: 20448
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
 
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int uf[n];
  rep(i, n) uf[i] = i;
  rep(i, m) {
    int s, t, nows, nowt;
    scanf("%d%d", &s, &t);
    nows = s, nowt = t;
    while(uf[nows] != nows) {
      nows = uf[nows];
    }
    while(uf[nowt] != nowt) {
      nowt = uf[nowt];
    }
    uf[nowt] = nows;
  }
  rep(i, n) {
    int nows = i;
    while(uf[nows] != nows) {
      nows = uf[nows];
    }
    uf[i] = nows;
  }
  /*rep(i, n) printf("%d ", uf[i]);
  printf("\n");*/
  int q;
  scanf("%d", &q);
  rep(i, q) {
    int s, t;
    scanf("%d%d", &s, &t);
    if(uf[s] != uf[t]) printf("no\n");
    else printf("yes\n");
  }
  return 0;
}



Measured memory_bytes: 2916
#include<iostream>
#include<algorithm>

int SumOfDigit(int n) {

	int sum = 0;
	while (n > 0) {
		sum += n % 10;

		n /= 10;

	}
	return sum;
}

int main() {

	int N;
	std::cin >> N;

	int ans = 1 << 30;

	for (int a = 1; a < N; a++) {

		int b = N - a;
		
		ans = std::min(SumOfDigit(a) + SumOfDigit(b), ans);

	}

	std::cout << ans << std::endl;

}

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


int main() {
  int n,m,k;
  cin >> n >> m >> k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(n*j+m*i-i*j*2==k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3624
#include <iostream>
#include <map>
using namespace std;
int a[1000000];
map<long long ,int >mp;
int main()
{
	long long n,ans=0;
	long long sum=0;
	cin>>n; 
	mp[0]++;
	for(int i=1;i<=n;i++)		
	{
		cin>>a[i];
		sum+=a[i];
		ans+=mp[sum];
		mp[sum]++;
	}
	cout<<ans;
	return 0;
}

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

const int MOD = 1e9+7;

int h,w;
char fi[1005][1005];
int dp[1005][1005];

int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		getchar();
		for(int j=1;j<=w;j++){
			scanf("%c",&fi[i][j]);
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==j && i==1){
				dp[i][j] = 1;
				continue;
			}
			if(i>1 && fi[i-1][j] == '.') dp[i][j]+=dp[i-1][j];
			if(j>1 && fi[i][j-1] == '.') dp[i][j]+=dp[i][j-1];
			dp[i][j]%=MOD;
		}
	}
	printf("%d\n",dp[h][w]);
	return 0;
}

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

bool check(vector<long long> v, int n){
	int sub = v[1] - v[0];
	for(int i = 2; i < n; ++i){
		if(v[i] - v[i - 1] != sub)
			return false;
	}
	return true;
}

int main() {
	int n;
	vector<long long> vec;
	while(cin >> n && n){
		vector<long long> hvec;
		long long h;
		for(int i = 0; i <= n; ++i){
			cin >> h;
			hvec.push_back(h);
		}
			
		for(int i = 0;  i <= n; ++i){
			vec = hvec;
			vec.erase(vec.begin() + i);
			if(check(vec, n)){
				cout << hvec[i] << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1224
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Distinct().Count() == 1 ? "Yes" : "No");
    }
}


Measured memory_bytes: 13396
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

ret = 0
for idx, b in enumerate(Bs):
    if As[idx] >= b:
        ret += b
    else:
        ret += As[idx]
        b -= As[idx]
        if As[idx + 1] >= b:
            ret += b
            As[idx + 1] -= b
        else:
            ret += As[idx + 1] 
            As[idx + 1] = 0
print(ret)

Measured memory_bytes: 19156
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string input = Console.ReadLine();
            int x = int.Parse(input);

            
            int num = x/100;

            if(num * 5 < x - num* 100)
                Console.WriteLine("0");
            else
                Console.WriteLine("1");
                

                
        }
    }

Measured memory_bytes: 13140