akhauriyash/Code-Regression huggingface dataset:
#import sys
#input = sys.stdin.readline
from collections import deque
from bisect import bisect_left

def main():
    N, Q = map( int, input().split())
    Query = [ tuple( map( int, input().split())) for _ in range(Q)]
    LX = 1
    X = deque([N])
    VX = deque([N])
    LY = 1
    Y = deque([N])
    VY = deque([N])
    mx = N
    my = N
    ans = 0
    # ANS = [0]
    for i, x in Query:
        if i == 1:
            if x < my:
                ans += mx-2
                # Y.appendleft(x)
                # VY.appendleft(mx)
                X.appendleft(x)
                VX.appendleft(mx)
                my = x
            else:
                ans += VX[bisect_left(X,x)-1]-2
                # print("x", x, bisect_left(X,x))
                # print(X, VX)
        else:
            if x < mx:
                ans += my-2
                Y.appendleft(x)
                VY.appendleft(my)

                # X.appendleft(x)
                # VX.appendleft(my)
                mx = x
            else:
                ans += VY[bisect_left(Y,x)-1]-2
                # print("y",x, bisect_left(Y,x))
                # print(Y, VY)

        # print(X, VX)
        # print( ans-ANS[-1])
        # ANS.append(ans)
    #     print(i, x, ans)
    # print(X, VX)
    # print(Y,VY)
    print((N-2)**2-ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 32696
def count(target, max_size, c_size, c_num, sum):
  if max_size == c_size:
    return 1 if sum == target else 0

  ans = 0
  for i in range(c_num, 10):
    ans += count(target, max_size, c_size+1, i+1, sum+i)
  return ans

import sys
for s in sys.stdin:
  max_size, target = map(int, s.split())
  if target == 0 and max_size == 0: break
  ans = count(target, max_size, 0, 0, 0)
  print ans

Measured memory_bytes: 4216
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		final long T = sc.nextLong();
		long[] t = new long[n];
		Arrays.setAll(t, i -> sc.nextLong());
		
		long sum = T;
		for (int i = 1; i < n; i++) {
			long dif = t[i] - t[i - 1];
			sum -= Math.max(0, T - dif);
			sum += T;
		}
		
		System.out.println(sum);
	}
}


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

const long double Pi = atan(1)*4;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long double a, b, h,m ;
  cin >> a >> b >> h >> m;
  h += m/60;
  pair<long double,long double> hr, mi;
  hr.first = a * sinl(2*Pi - h/6 * Pi);
  hr.second = a * cosl(2*Pi - h/6 * Pi);
  mi.first = b * sinl(2*Pi - m/30 * Pi);
  mi.second = b * cosl(2*Pi - m/30 * Pi);
  long double ans = sqrt((hr.first - mi.first)*(hr.first-mi.first) + (hr.second - mi.second)*(hr.second - mi.second));
  cout << fixed << setprecision(20);
  cout << ans << "\n";
return 0;
}


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

using namespace std;

using ll = long long;

constexpr ll inf = 1<<30;
vector<ll> a(55);
vector<ll> p(55);
ll f(ll n,ll x){
    if(n<=0) return (x<=0)?0:1;
    
    if(x <= a[n-1] + 1){
        return f(n-1,x-1);
    }else{
        return p[n-1] + 1 + f(n-1,x-2-a[n-1]);
    }
    
}
int main(){
    int n;
    ll x;
    cin>>n>>x;
    a[0] = 1;
    p[0] = 1;
    for(int i=0;i<n;++i){
       a[i+1] = 2*a[i]+3;
       p[i+1] = 2*p[i]+1;
    }
    cout << f(n,x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
char w[10001];
int main()
{
    int n;
    int i;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%s",w);
        for(i=0;w[i]!='\0';i++)
        {
            if(w[i]+n<=90)
            {
                printf("%c",w[i]+n);
            }
            else
            {
                printf("%c",w[i]+n-26);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n,x, t;
    cin >> n >> x >> t;
    ll a = n/x;
    ll b = n%x;
    if(b == 0){
    cout << t * a << endl;
    }else{
        cout << t * (a + 1) << endl;
    }
}


Measured memory_bytes: 3628
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
#define MAX 100005
struct node {
    lli v, d;
    node(lli v, lli d) : v(v), d(d) {}
    bool operator<(const node& n) const { return d > n.d; }
};
struct edge {
    lli to, d;
    edge(lli to,lli d) : to(to), d(d) {}
};
lli V;
struct Graph {
    vector<edge> G[MAX];
    lli dist[MAX];  // shortest distance
    Graph()
    {
        rep(i, MAX)
        {
            G[i].clear();
            dist[i] = -1;
        }
    }
    void dijkstra(lli s)
    {
        priority_queue<node> que;
        que.push(node(s, 0));
        while (!que.empty()) {
            lli v = que.top().v, d = que.top().d;
            que.pop();
            if (dist[v] >= 0 and dist[v] <= d)
                continue;
            dist[v] = d;
            for (lli i = 0; i < G[v].size(); i++)
                que.push(node(G[v][i].to, d + G[v][i].d));
        }
    }
};

Graph g1{};
int main()
{
    lli a,b,n,v,p,k;
    cin >> n;
    rep(i, n - 1)
    {
        cin >> a >> b;
        a--, b--;
        g1.G[a].push_back(edge(b,1));
        g1.G[b].push_back(edge(a,1));
    }
    cin >> k;
    lli vl[100095],pl[100095];
    rep(i, k)
    {
        cin >> v >> p;
        p+=1;
        v--;
        vl[i] = v;
        pl[i] = p;
        g1.G[n].push_back(edge(v,p));
        g1.G[v].push_back(edge(n,p));
    }
    g1.dijkstra(n);
    queue<lli> que;
    rep(i,n)cerr << i << ' ' << g1.dist[i]<<endl;
    que.push(0);
    bool used[100005]={};
    used[0] = true;

    while (!que.empty()) {
        lli now = que.front();
        que.pop();
        for(lli i = 0;i<g1.G[now].size();i++){
            edge s = g1.G[now][i];
            if (s.to == n || now == n)
                continue;
            if (abs(g1.dist[now] - g1.dist[s.to]) == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(!used[s.to]){
                used[s.to] = true;
                que.push(s.to);
            }

        }
    }
    rep(i,k)if(g1.dist[vl[i]]!= pl[i]) {
            cout << "No"<<endl;
            return 0;
        }
    cout << "Yes" << endl;
    rep(i, n)
    {
        cout << g1.dist[i]-1 << endl;
    }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<list<int>> e(n);
  vector<int> c(n,0);
  vector<int> dp(n,0);
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    e[x-1].push_back(y-1);
    c[y-1]++;
  }
  queue<int> q;
  for(int i=0;i<n;i++){
    if(c[i]==0) q.push(i);
  }
  int now;
  while(!q.empty()){
    now=q.front();
    q.pop();
    for(auto v:e[now]){
      c[v]--;
      dp[v]=max(dp[v],dp[now]+1);
      if(c[v]==0){
        q.push(v);
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5888
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define mp make_pair
#define f first
//#define sex second

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <set>
#include <ostream>
#include <queue>
#include <functional>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
#pragma comment(linker, "/STACK:228228000")
const ll mod = 998244353;

ll n;
ll ds[100000];
ll qa[10], qan[8];

int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	
	cin >> n;
	qa[0] = 1;
	qan[0] = 1;
	forn(i, 1, 10)
		qa[i] = qa[i - 1] * 6;

	forn(i, 1, 8)
		qan[i] = qan[i - 1] * 9;


	forn(i, 0, n)
	{
		if ((ds[i] == 0) && (i > 0))
			break;
		forn(j, 0, 10)
		{
			if (i + qa[j] <= n)
			{
				ds[i + qa[j]] = min(ds[i + qa[j]], ds[i] + 1);
				if (ds[i + qa[j]] == 0)
					ds[i + qa[j]] = ds[i] + 1;
			}
			if (i + qan[j] <= n)
			{
				ds[i + qan[j]] = min(ds[i + qan[j]], ds[i] + 1);
				if (ds[i + qan[j]] == 0)
					ds[i + qan[j]] = ds[i] + 1;
			}
		}
	}
	
	cout << ds[n];

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

A.append(0)

tani=[]
yama=[]

next_buy=True
cur_val=float("inf")
cur_money=1000
cur_stock=0

for a in A:
    if next_buy:
        if a>cur_val:#前の値段で買う
            #print("buy {}".format(cur_val))
            cur_stock=cur_money//cur_val
            cur_money-=cur_stock*cur_val
            cur_val=a
            next_buy=False
        else:
            cur_val=a
    else:#うる
        if a<cur_val:
            #print("sell {}".format(cur_val))
            cur_money+=cur_stock*cur_val
            cur_stock=0
            cur_val=a
            next_buy=True
        else:
            cur_val=a

print(cur_money)


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  vi p(n);
  rep (i, n) {
    cin >> p[i];
  }
  sort(all(p));
  ll sum = 0;
  rep (i, n) {
    sum += p[i];
  }
  sum -= p.back() / 2;
  cout << sum << endl;
}


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

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

 int main() {
   int A, B, C, mx, ans;
   cin >> A >> B >> C;
   mx = max(A, max(B, C));

   A = mx - A;
   B = mx - B;
   C = mx - C;

   vector<int> vec {A, B, C};
   sort(vec.begin(), vec.end());

   if ((vec.at(1) + vec.at(2)) % 2 == 0) ans = (vec.at(1) + vec.at(2)) / 2;
   else ans = (vec.at(1) + vec.at(2)) / 2 + 2;

   cout << ans << endl;

 }


Measured memory_bytes: 256
s = str(input())
nl = [s[0],s[1],s[2],s[3]]
nl = list(map(int,nl))

dic = {'+':1, '-':-1}
end = False
for op1 in ['+','-']:
    for op2 in ['+','-']:
        for op3 in ['+','-']:
            num = nl[0] + nl[1]*dic[op1] + nl[2]*dic[op2] + nl[3]*dic[op3]
            if num == 7 and not end:
                print('{}{}{}{}{}{}{}=7'.format(s[0],op1,s[1],op2,s[2],op3,s[3]))
                end = True

Measured memory_bytes: 3064
function main(input) {
    var args = input.trim().split(" ");
    var N = args[0];

    var total = 0;
    if (N.length % 2 === 1) {
        var diff = Math.pow(10, N.length - 1);
        total = N - diff + 1;
    }

    var validDigit = Math.ceil((N.length - 1) / 2);
    for(var i = 1; validDigit + 1 > i; i++) {
        total += Math.pow(10,i * 2 - 2) * 9;
    }

    console.log(total);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));



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


void solve(string S){
    int one = 0;
    int zero = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            zero++;
        }else{
            one++;
        }
    }
    cout << 2 * min(one, zero) << endl;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  int64_t a, b, c, k;
  cin >> a >> b >> c >> k;
  int64_t total = 0;
  if (a >= k) {
    total += k;
  } else {
    k -= a;
    total += a;
    if (b < k) {
      k -= b;
      total -= k;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3672
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007//10^9+7
#define PI acos(-1)

using namespace std;

static int bit[200010];
int bitlen=200000;//使う長さをここに入れる

void bit_init(void){
	int i;
	for(i=0;i<=bitlen;i++){
		bit[i]=0;
	}
}

//sum BITの1番目からi番目までの和を取る
int bitsum(int i){
	int s=0;
	while(i>0){
		s=s+bit[i];
		i=i-(i&-i);
	}
	return s;
}

//add BITのi番目の値をx増やす
void bitadd(int i,int x){
	while(i<=bitlen){
		bit[i]=bit[i]+x;
		i=i+(i&-i);
	}
}

struct num_t {
	int idnum;
	ll int num;
} ;

int compare_num(const void *a, const void *b) {
	struct num_t *A = (struct num_t *)a;
	struct num_t *B = (struct num_t *)b;
	if(A->num - B->num >0){
		return 1;
	}else if(A->num - B->num >0){
		return -1;
	}else{
		return 0;
	}
}

int compare_idnum(const void *a, const void *b) {
	struct num_t *A = (struct num_t *)a;
	struct num_t *B = (struct num_t *)b;
	return A->idnum - B->idnum;
}

int main(void)
{
	//変数の宣言
	int n,k;
	static int a[200010];
	static struct num_t ruiseki[200010];

	//よく使う変数
	int i,j,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d %d",&n,&k);
//	scanf_s("%d %d",&n,&k);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	fri(n){
		a[i]=a[i]-k;
		if(i==0){
			ruiseki[i].num=a[i];
			ruiseki[i].idnum=i;
		}else{
			ruiseki[i].num=ruiseki[i-1].num+a[i];
			ruiseki[i].idnum=i;
		}
		if(ruiseki[i].num>=0) ans++;
	}


	qsort(ruiseki, n, sizeof(struct num_t), compare_num);

	count=1;
	for(i=0;i<n;i++){
		if(0==i){
			temp=ruiseki[0].num;
			ruiseki[0].num=1;
		}else{
			if(ruiseki[i].num==temp){
				ruiseki[i].num=count;
			}else{
				temp=ruiseki[i].num;
				count++;
				ruiseki[i].num=count;
			}
		}
	}

	qsort(ruiseki, n, sizeof(struct num_t), compare_idnum);


	bitlen=n;
	bit_init();

	for(i=0;i<n;i++){
		ans=ans+bitsum(ruiseki[i].num);
		bitadd(ruiseki[i].num,1);
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int op = 0, mi = 1e9;
    /*
    ループ終了後にopが0より大きい…')'が足りない
    ループ終了後にopが0より小さい…'('が足りない
    
    ループ終了後にopが0のとき注意（例３）
    "))))(((("は最後にopはゼロになるが、'('が足りない部分（途中で')'が'('より多いとき）
    を記録するためにopの最小値を更新し続ける

    最後に
    sの先頭に-mi個'('をつける（このときopを同じ分だけ足す（個数が合わないので（例３）））
    sの後ろにop個')'をつける

    */

    for(int i = 0; i < n; i++){
        if(s[i] == '(') op++;
        else op--;
        mi = min(mi, op);
    }

    for(int i = 0; i < -mi; i++){
        s = '(' + s;
        op++;
    }
    for(int i = 0; i < op; i++){
        s += ')';
    }

    cout << s << endl;

    return 0;
}

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

int main(){
	int k, s;
	cin >> k >> s;
	int ans = 0;
	rep(i, k){
		rep(j, k){
			if(s - (i+j) >= 0 && s -(i+j) <= k)
				ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
class Dijkstra{
    private:
        struct edge{
            ll to,cost;
        };
        vector<vector<edge>> G;
        vector<ll> d;
        ll siz;
    public:
        Dijkstra(int n){
            G.resize(n);
            siz = n;
        }
        void add_edge(int from,int to,int cost){
            G[from].push_back(edge{to,cost});
        }
        vector<ll> dijkstra(ll s){
            priority_queue<P,vector<P>,greater<P>> q;
            d.assign(siz,INF);
            d[s] = 0;
            q.push(P(0,s));
            while(!q.empty()){
                P p = q.top();q.pop();
                int v = p.second;
                if (d[v] < p.first) continue;
                for(edge &e:G[v]){
                    if (chmin(d[e.to],d[v]+e.cost)){
                        q.push(P(d[e.to],e.to));
                    }
                }
            }
            return d;
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,n;
    cin >> n;
    Dijkstra g(n);
    rep(i,n-1){
        cin >> a >> b >> c;
        a--;
        b--;
        g.add_edge(a,b,c);
        g.add_edge(b,a,c);
    }
    ll q,k,x,y;
    cin >> q >> k;
    vector<ll> d = g.dijkstra(k-1);
    rep(i,q){
        cin >> x >> y;
        x--;
        y--;
        PRINT(d[x]+d[y]);
    }
}



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

using namespace std;

int main() {
   ios_base :: sync_with_stdio(0);
   cin.tie(0) , cout.tie(0);
   int n;
   cin >> n;
   vector<int> v(n , 0);
   for (int i = 0; i < n; i++) {
      cin >> v[i];
   }
   vector<int> difs;
   for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      difs.push_back(v[i] - x);
   }
   sort(difs.begin() , difs.end());
   reverse(difs.begin() , difs.end());
   int ans = 0;
   for (int d : difs) {
      if (d < 0) {
         break;
      }
      ans += d;
   }
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
import numpy as np
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          continue
        c = b+1
        if c>=A[h][w]:
          continue
        A[h][w]=c
        q.append([h,w])
      
    A = np.array(A)
    ans = max(ans,max(A[A<10**5]))
    
print(ans)

Measured memory_bytes: 12452
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    if (n%k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <string> s(n);
    rep (i,0,n)
    {
        cin>>s[i];
        sort (all(s[i]));
    }
    map <string,ll> fre;
    rep (i,0,n)
    {
        fre[s[i]]++;
    }
    set <string> s1;
    rep (i,0,n)
    {
        s1.insert(s[i]);
    }
    ll ans=0;
    for (auto x: s1)
    {
        ans+=(fre[x]*(fre[x]-1))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 26112
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 5)
		cout << 0 << endl;
	else if(a < 13)
		cout << b/2 << endl;
	else
		cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long  int MOD = 1000000007;
const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N >> K >> M;
	vector<vector<long long int>>comb(N + 1, vector<long long int>(N + 1));
	for (int i = 0; i <= N; i++) {
		comb[i][0] = 1;
		comb[i][i] = 1;
	}
	for (int i = 2; i <= N; i++) {
		for (int j = 1; j < i; j++) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			comb[i][j] %= M;
		}
	}
	vector<vector<long long int>>dp(N + 2, vector<long long int>(K + 1));
	for (int i = 0; i <= K; i++) {
		dp[0][i] = 1;
		dp[1][i] = 1;
	}
	//for (int i = 2; i <= N + 1; i++) {
	//	for (int j = K - 1; j >= 0; j--) {
	//		for (int k = 1; k < i; k++) {
	//			for (int l = j + 1; l <= K; l++) {
	//				long long int add = dp[i - k][l] * dp[k][j];
	//				add %= M;
	//				add *= comb[i - 2][k - 1];
	//				add %= M;
	//				dp[i][j] += add;
	//				dp[i][j] %= M;
	//			}
	//		}
	//	}
	//}
	for (int i = 2; i <= N + 1; i++) {
		for (int k = 1; k < i; k++) {
			long long int box = dp[i - k][K];
			for (int j = K - 1; j >= 0; j--) {
				long long int add = box * dp[k][j];
				add %= M;
				add *= comb[i - 2][k - 1];
				add %= M;
				dp[i][j] += add;
				dp[i][j] %= M;
				box += dp[i - k][j];
				box %= M;
			}
		}
	}
	cout << dp[N + 1][0] << endl;
	return 0;
}

Measured memory_bytes: 1792
open Scanf
open Printf

let iota n : int list =
  let rec f n ans = if n = 0 then ans else f (n - 1) ((n - 1) :: ans) in
  f n []

let () =
  let n, m, p = scanf " %d %d %d" (fun a b c -> a, b, c) in
  let es = Array.init m @@ fun _ -> scanf " %d %d %d" @@ fun a b c -> (a - 1), (b - 1), c - p in
  let inf = max_int / 4 in
  let dist = Array.make n (-inf) in
  let from_s = Array.make n false in
  let from_t = Array.make n false in
  dist.(0) <- 0;
  from_s.(0) <- true;
  from_t.(n - 1) <- true;
  for _ = 0 to n do
    es |> Array.iter @@ fun (a, b, c) ->
      dist.(b) <- max dist.(b) (dist.(a) + c);
      from_s.(b) <- from_s.(b) || from_s.(a);
      from_t.(a) <- from_t.(a) || from_t.(b)
  done;
  let tmp = Array.copy dist in
  for _ = 0 to n do
    es |> Array.iter @@ fun (a, b, c) ->
      dist.(b) <- max dist.(b) (dist.(a) + c);
  done;
  if (iota n |> List.exists (fun i -> from_s.(i) && from_t.(i) && dist.(i) <> tmp.(i))) then
    printf "-1\n"
  else
    printf "%d\n" @@ max 0 dist.(n - 1);

Measured memory_bytes: 4864
#!/usr/bin/env python3

import itertools
import copy

h, w, k = map(int, input().split())
c = [[] for _ in range(h)]
for i in range(h):
    c[i] = list(input())

ccs = []

hnum = list(range(h))
wnum = list(range(w))

def countBlack(cc):
    ans = 0
    for i in range(h):
        ans += cc[i].count('#')
    return ans

ans = 0
# column
for i in range(w+1):
    for comb_column in list(itertools.combinations(wnum, i)):
        for p in range(h+1):
            for comb_row in list(itertools.combinations(hnum, p)):

                if len(comb_column)==w or len(comb_row)==h:
                    break

                cc = copy.deepcopy(c) 
                # print('comb_column =', comb_column)
                # print('len(comb_column) =', len(comb_column))
                # print('comb_row =', comb_row)
                # print('len(comb_row) =', len(comb_row))
                # column を塗る
                for j in range(len(comb_column)):
                    for j2 in range(h):
                        cc[j2][comb_column[j]] = 'R'

                # row を塗る
                for q in range(len(comb_row)):
                    for r in range(w):
                        cc[comb_row[q]][r] = 'R'

                # matrix
                # for s in range(h):
                #     print(cc[s])
                # print()

                ccs.append(cc)

for i in ccs:
    if k == countBlack(i):
        ans += 1

print(ans)

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

//#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    string s;
    cin>>s;
    vector<int>v(26,0);
    for(auto c:s)
    {
        v[c-'a']++;
    }
    bool flag=false;
    char d;
    for(int i=0;i<26;i++)
    {
        d='a'+i;
        if(v[i]==0)
        {
            cout<<s+d<<endl;
            exit(0);
        }
    }
    for(int j=s.length()-1;j>=1;j--)
    {
        if(s[j]>s[j-1])
        {
            vector<char>v;
            for(int k=j;k<s.length();k++)
                if(s[k]>s[j-1])
                v.push_back(s[k]);
              sort(v.begin(),v.end());
              swap(s[j-1],v[0]);
              for(int i=0;i<j;i++)
                  cout<<s[i];
              exit(0);
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair

// random generator
// mt19937 rndm(time(0));

// ll gcd(ll a, ll b)
// {
//     while (b>0)
//     {
//         int tmp = a;
//         a = b;
//         b = tmp%b;
//     }
//     return a;
// }


// long long gcd(long long a, long long b) {
// 	return a? gcd(b % a, a) : b;
// }

 
const int M=1e9+7;
ll powmod(ll a,ll b, ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}/* a^b%mod */
const int N=1e5+10;



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

	string s,t;
	cin>>s>>t;
	set<int>a[26], b[26];
	for(int i=0;i<s.size();++i) {
		a[s[i]-'a'].insert(t[i]-'a');
		b[t[i]-'a'].insert(s[i]-'a');
	}
	for(int i=0;i<26;++i) {
		if(a[i].size()>1 || b[i].size()>1) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}




Measured memory_bytes: 916
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		unordered_map<string,int>mp;
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			mp[s]++;
		}
		cout<<"AC x "<<mp["AC"]<<endl;
		cout<<"WA x "<<mp["WA"]<<endl;
		cout<<"TLE x "<<mp["TLE"]<<endl;
		cout<<"RE x "<<mp["RE"]<<endl;
		return 0;
	}


Measured memory_bytes: 3652
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    print('2018' + S[4:])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8888
//繝・Φ繝励Ξ
#include <bits/stdc++.h>
#define int long long
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PAIR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 

  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  cin >> N;
  int d[N];
  REP(i,N) cin >> d[i];
  sort(d,d+N);
  int ans = 1 ;
  REP(i,N-1)
  {
    if (d[i+1] != d[i])
    {
      ans ++;
    }
  }
  cout << ans <<endl;
}

//N縺薙・荳ｭ縺九ｉ騾｣邯壹☆繧橘蛟九ｒ驕ｸ縺ｶ縺ｨ縺阪・驕ｸ縺ｳ譁ｹ縺ｯ髯舌ｌ繧峨ｌ繧九・ S T L

//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ REP(i,N) ruiseki[i+1] += ruiseki[i];
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  set<char> s;
  for(Int i=0;i<n;i++){
    char c;
    cin>>c;
    s.emplace(c);
  }
  cout<<(s.size()==3u?"Three":"Four")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int H, W;

char maze[20][20];

int d[20][20];

int bfs(P s, P g)
{
    queue<P> q;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int i, j;
    P p;

    rep(i, 0, H - 1)
    {
        rep(j, 0, W - 1)
        {
            d[i][j] = MOD;
        }
    }

    d[s.first][s.second] = 0;

    if (s == g)
    {
        return 0;
    }

    q.push(s);

    while (q.size())
    {
        p = q.front();
        q.pop();

        rep(i, 0, 3)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if (nx >= 0 && ny >= 0 && nx < H && ny < W && d[nx][ny] == MOD && maze[nx][ny] == '.')
            {
                q.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[g.first][g.second];
}

int main(void)
{
    int i, j, k, l;
    int ans = 0;

    cin >> H >> W;

    rep(i, 0, H - 1)
    {
        rep(j, 0, W - 1)
        {
            cin >> maze[i][j];
        }
    }

    rep(i, 0, H - 1)
    {
        rep(j, 0, W - 1)
        {
            rep(k, 0, H - 1)
            {
                rep(l, 0, W - 1)
                {
                    if (maze[i][j] == '.' && maze[k][l] == '.')
                    {
                        ans = max(bfs(P(i, j), P(k, l)), ans);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

int main()
{
	int N;
	cin>>N;
	vector<int> H(N);
	for(int i=0; i<N; i++)
	{
		cin>>H[i];
	}
	int sum = 1;
	int max = H[0];
	for(int i=1; i<N; i++)
	{
		if(max<=H[i])
		{
			sum++;
			max = H[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	n;
	std::cin >> n;

	pnl((int)((int)sqrt(n) * (int)sqrt(n)));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int H1, M1, H2, M2, K;
  int up, sleep, result;
  cin>>H1>> M1>> H2>> M2>> K;
  
  up = H1*60+M1;
  sleep = H2*60+M2;
  result = sleep - K-up;
  cout<<result<<endl;
}

Measured memory_bytes: 3636
s = list(input())
if len(s)%2 == 0:
    l = s[:len(s)//2]
    r = s[len(s)//2:]
else:
    l = s[:len(s)//2]
    r = s[len(s)//2+1:]

r.reverse()

ans = 0
for _l, _r in zip(l, r):
    if _l != _r:
        ans += 1

print(ans)


Measured memory_bytes: 3060
N,T = map(int,input().split())
list = [list(map(int,input().split())) for _ in range(N)]
min_cost = list[0][0]
cnt = 0

for c,t in list:
    if t <= T:
        cnt += 1
        comp_cost = c
        if comp_cost < min_cost:
            min_cost = comp_cost

if cnt >= 1:
    print(min_cost)
elif cnt == 0:
    print('TLE')

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

int main(){
  int a=0,b=0,c=0,d=0;
  for(int i=0; i<6; i++){
    int x;
    cin>>x;
    if(x==1)a++;
    if(x==2)b++;
    if(x==3)c++;
    if(x==4)d++;
  }
  if(a<3 && b<3 && c<3 && d<3)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > H(N);
  REP(i, N) cin >> H[i];
  int count = 0, ans = 0;
  REP(i, N - 1) {
    if (H[i] < H[i + 1]) {
      chmax(ans, count);
      count = 0;
    } else {
      count++;
    }
  }
  chmax(ans, count);
  print(ans);
}

Measured memory_bytes: 1024
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll A, B, T;
	cin >> A >> B >> T;
	cout << T / A * B << endl;
	
}








Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

double helon(double a, double b, double c){
	double s = (a + b + c) / 2;
	return sqrt(s * (s - a) * (s - b) * (s - c));
}

double a, l, x;

int main(){
	while(~scanf("%lf%lf%lf", &a, &l, &x)){
		printf("%.10lf\n", helon(a, l, l) + helon(l, (l+x)/2, (l+x)/2) * 2);
	}
	return 0;
}

Measured memory_bytes: 1240
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

a = input()
s = raw_input()
print s if a >= 3200 else "red"

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
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;
}
int n;
int main()
{
	n=read();
	if (n%2==0) cout << n << ' ' << n << ' ' <<n/2 << endl;
	else
	{
		for (int i=1;i<=3500;i++)
			for (int j=1;j<=3500;j++)
			if (4*i*j-n*i-n*j>0)
			{
				long long x=(1LL*n*i*j)/(4*i*j-n*i-n*j);
				if (1LL*x*(4*i*j-n*i-n*j)==1LL*n*i*j)
				{
					cout << i << ' ' << j << ' ' << x << endl;
					return 0;
				}
			}
	}
	return 0;
}


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



int main(){long n;
cin >> n;
vector<long> a(n + 1);
erep(i, n) cin >> a.at(i);
vector<long> b(n + 1);

if(!(n & 1)){
    erep(i, n / 2){
        b.at(i) = a.at(n - (i - 1) * 2);
    }
    long k = n / 2 + 1;
    for(long i = k; i <= n; i++){
        b.at(i) = a.at((i - n / 2) * 2 - 1);
    }
}
else{
    erep(i, (n + 1) / 2){
        b.at(i) = a.at(n - (i - 1) * 2);
    }
    for(long i = (n + 1) / 2 + 1; i <= n; i++){
        b.at(i) = a.at((i - (n + 1) / 2) * 2);
    }
}
erep(i, n){
    cout << b.at(i);
    if(i != n) cout << ' ';
    else cout << endl;
}
// cout << n / 2 + 1 << endl;
// cout << (4 - n / 2) * 2 - 1 << endl;

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



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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if(b-a == c-b) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}   
/** atcoder **/


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

public class AtCoderC
{
    static void Main()
    {
        var sc = new Scanner();

        long num = sc.NextLong();

        long answer = 0;

        for (long i = 1; i <= num; i++)
        {
            for (long j = 1; j <= num; j++)
            {
                for (long k = 1; k <= num; k++)
                {
                    answer += Gcd(Gcd(i, j), k);
                }
            }
        }

        Console.WriteLine(answer);
    }

    // 最大公約数（long）
    private static long Gcd(long a, long b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
  int n;
  vector<int> a;
  
  cin >> n;
  for(int i =0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  
  sort(a.begin(),a.end(),greater<int>());
  int sum_a = 0, sum_b = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0)sum_a += a[i];
    else sum_b += a[i];
  }
  
  cout << sum_a - sum_b << endl;
}

Measured memory_bytes: 256
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
n=list(map(int,input().split()))
if X<min(n) or X>max(n):
  print(X)
  exit()

key=min(n)-1
Key=max(n)+1
l=list(range(key,Key+1))
ll=[x for x in l if x not in n]
ll.append(X)
ll.sort()
i=ll.index(X)
if abs(X-ll[i-1])>abs(X-ll[i+1]):
  print(ll[i+1])
else:
  print(ll[i-1])

  

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    int ex,ey,eh;
    for(int i= 0;i < n;i++){
        cin >> x.at(i) >> y.at(i) >> h.at(i);
        if(h.at(i) > 0){
            ex= x.at(i);
            ey= y.at(i);
            eh= h.at(i);
        }
    }
    
    bool is_answer = true;
    
  //h.at(i) = 0の場合の情報を無視するとWAする
    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            int ch = eh + abs(ex - cx) + abs(ey - cy);
            ch = max(ch,0);
            is_answer = true;
            
            
            for(int i =0; i < n; i++){
                int v = ch - abs(x.at(i) - cx) - abs(y.at(i) - cy);
                v = max(v,0);
                if(v != h.at(i))is_answer = false;
            }
            
            
            if(is_answer){
                if(ch == -1)ch = 1;
                cout << cx << " " << cy << " " << ch;
            }
            
        }
        
        
    }
}


Measured memory_bytes: 256