akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ull = unsigned long long;

ull solve(map<ull, ull> &memo, ull n, array<ull, 4> &costs) {
  if (n == 0) {
    return 0;
  } else if (n == 1) {
    return costs.back();
  }

  if (memo.count(n) > 0) {
    return memo[n];
  }

  array<ull, 3> d{2, 3, 5};

  ull ans = costs[3] * n;
  for (int i = 0; i <= 2; ++i) {
    ull k = 0;
    while ((n + k) % d[i] != 0) {
      k++;
    }

    ans = min(ans,
              solve(memo, (n + k) / d[i], costs) + costs[i] + k * costs.back());
    k = 0;
    while ((n - k) % d[i] != 0) {
      k++;
    }

    ans = min(ans,
              solve(memo, (n - k) / d[i], costs) + costs[i] + k * costs.back());
  }

  return memo[n] = ans;
}

int main(int argc, const char *argv[]) {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ull n, a, b, c, d;
    array<ull, 4> costs;

    cin >> n;
    for (int i = 0; i < costs.size(); ++i) {
      cin >> costs[i];
    }

    map<ull, ull> memo;
    ull ans = solve(memo, n, costs);
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  rep(i, 3){
    string s;
    cin >> s;
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int *A, int N) {
    int count=0;
    
    for (int i=0; i<N; i++) {
        int minj = i;
        int flag = 0;
        for (int j=i; j<N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
                flag = 1;
            }
        }
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        if(flag) count++;
    }
    
    return count;
}

void outputArray(int *A, int N) {
    printf("%d", A[0]);
    for (int i=1; i<N; i++) printf(" %d", A[i]);
    printf("\n");
}

int main() {
    int n;
    scanf("%d", &n);
    
    int a[n];
    for (int i=0; i<n; i++) scanf("%d", &a[i]);
    
    int count = selectionSort(a, n);
    outputArray(a, n);
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define print(a, b) printf("Case %d: %.0f\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;

   ll a, b;
   cin >> a >> b;

   if (a > b)
      cout << "safe" << endl;

   else
      cout << "unsafe" << endl;
   return 0;
}

Measured memory_bytes: 3668
n = int(input())
p = reversed(list(map(int, input().split())))
a = [i*20000 for i in range(1,n+1)]
b = [i*20000 for i in range(n,0,-1)]
for k,v in enumerate(p):
  b[v-1] -= k
print(*a)
print(*b)


Measured memory_bytes: 5772
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

int main() {
    double x[3], y[3];
    REP(i, 3) cin >> x[i] >> y[i];
    double a, b, c;
    a = sqrt((x[1] - x[2])*(x[1] - x[2]) + (y[1] - y[2])*(y[1] - y[2]));
    b = sqrt((x[0] - x[2])*(x[0] - x[2]) + (y[0] - y[2])*(y[0] - y[2]));
    c = sqrt((x[0] - x[1])*(x[0] - x[1]) + (y[0] - y[1])*(y[0] - y[1]));
    if (max({a,b,c}) == b) swap(a, b);
    else if (max({a,b,c}) == c) swap(a, c);
    double cos2 = (a * a + c * c - b * b) / (2 * a * c);
    double cos3 = (a * a + b * b - c * c) / (2 * a * b);
    double ans = a / (2 + (1 / sqrt(2 / (cos2 + 1) - 1)) + (1 / sqrt(2 / (cos3 + 1) - 1)));
    printf("%.12f", ans);
    getchar(); getchar();
}

Measured memory_bytes: 256
n,m=map(int,input().split())
w=[1]*n
p=[0]*n
p[0]=1
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if p[x]:
        p[y]=1
    w[x]-=1
    w[y]+=1
    if w[x]==0:
        p[x]=0
print(sum(p))

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	// k 回出来る
	while(b <= a){
		k--;
		b *= 2;
	}
	while(c <= b){
		k--;
		c *= 2;
	}
	if(k >= 0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  string S;
  int N;
  cin >> N;
  cin >> S;
  for(int i=0;i<S.length();i++){
    if('Z'-S[i]<N) cout << char(S[i]+N-26);
    else cout << char(S[i]+N);
  }
  cout << endl;
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;
int fib(int n){
    int dp[50];
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i < 45; ++i){
        dp[i] = dp[i-1] + dp[i-2];
    }
    return dp[n];
}

int main(){
    int n;
    cin >> n;
    cout << fib(n) << endl;
}

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

using namespace std;
const int MAXN=100001;
int n,m,st[MAXN],et[MAXN],c[MAXN],pre[MAXN],res[MAXN];

int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >>st[i] >>et[i] >>c[i];
	for(int i=1;i<=m;i++)
	{
		memset(pre,0,sizeof(pre));
		for(int j=1;j<=n;j++) if(c[j]==i) pre[st[j]]++,pre[et[j]+1]--;
		for(int j=1;j<MAXN;j++) pre[j]+=pre[j-1];
		for(int j=1;j<MAXN;j++) if(pre[j]>0) res[j]++; //因为i,j属于一个频道，所以只能算一次 
	}
	
	int ans=0;
	for(int i=1;i<MAXN;i++) ans=max(ans,res[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
vector<vector<int>> v;
vector<vector<int>> dp;

int f(int x,int y){
  if(dp[x][y]!=-1) return dp[x][y];
  else if(x==0){
    if(y>=v[0][0]) dp[x][y]=v[0][1];
    else dp[x][y]=0;
  }
  else if(y<v[x][0]) dp[x][y]=f((x-1)/2,y);
  else {
    dp[x][y]=max(f((x-1)/2,y),f((x-1)/2,y-v[x][0])+v[x][1]);
  }
  return dp[x][y];
}

int main() {
  int N;
  cin>>N;
  v.resize(N);
  for(int i = 0; i < N; i++) v[i].resize(2);
  for(int i = 0; i < N; i++) cin>>v[i][1]>>v[i][0];
  int M = 0,Q;
  cin>>Q;
  vector<vector<int>> q(Q,vector<int>(2));
  for(int i = 0; i < Q; i++){
    cin>>q[i][0]>>q[i][1];
    q[i][0]--;
    chmax(M,q[i][1]);
  }
  dp.resize(min(N,(1<<10)));
  for(auto &x:dp) x.assign(M+1,-1);
  for(int i = 0; i < (int)dp.size();i++){
    for(int j =0; j < M+1; j++) f(i,j);
  }
  for(int i = 0; i < Q; i++) {
    int p = q[i][0];
    int L = q[i][1];
    if(p<(int)dp.size()) {
      printf("%d\n",dp[p][L]);
    }
    else{
      int ans = 0;
      int w = p;
      vector<int> t;
      while(w>=(int)dp.size()){
        t.push_back(w);
        w=(w-1)/2;
      }
      int cnt = t.size();
      for(int i = 0; i < (1<<cnt);i++){
        int a = 0,b = L;
        for(int j = 0; j < cnt; j++){
          if(i&(1<<j)){
            a+=v[t[j]][1];
            b-=v[t[j]][0];
            if(b<0) break;
          }
        }
        if(b<0) continue;
        chmax(ans,a+dp[w][b]);
      }
      printf("%d\n",ans);
    }
  }
}

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

void hikaku(){
	int a[10],yoke;
	for(int i=0;i<10;i++){
		cin>>a[i];
		}
	for(int i=0;i<9;i++){
		for(int n=i+1;n<10;n++){
			if(a[i]<a[n]){
				yoke=a[i];
				a[i]=a[n];
				a[n]=yoke;
				}
			}
		}
	for(int i=0;i<3;i++){
		cout<<a[i]<<endl;
		}
}
int main(){
	hikaku();
	return 0;
	}

Measured memory_bytes: 1160
object Main extends App {
  val n = readInt
  val s = (1 to n).map{_ => readLine}
  val m = readInt
  val t = (1 to m).map{_ => readLine}
  
  var map = Map.empty[String,Int]
  
  (0 until n).foreach{i =>
    map = map.updated(s(i),map.getOrElse(s(i),0)+1)
  }
  
  (0 until m).foreach{i =>
    map = map.updated(t(i),map.getOrElse(t(i),0)-1)
  }
  
  println(Array(map.values.max,0).max)
}

Measured memory_bytes: 25540
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)

Measured memory_bytes: 9208
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

    // 直線(x1,y1)(x3,y3)と線分(x2,y2)(x4,y4)の交差判定。
    // (結果 < 0) <=> 交差, (結果 > 0) <=> 交差しない, (結果 = 0) <=> 線分の端点が直線上に存在(今回与えられる入力ではあり得ない)
    static boolean intersec(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
        return (((y2 - y1) * (x3 - x1) - (y3 - y1) * (x2 - x1)) * ((y4 - y1) * (x3 - x1) - (y3 - y1) * (x4 - x1)) < 0);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input;

        while ((input = br.readLine()) != null) {
            String[] line = input.split(",");
            double[] p = new double[8];

            for (int i = 0; i < 8; i++) {
                p[i] = Double.parseDouble(line[i]);
            }

            if (intersec(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7])
                    && intersec(p[6], p[7], p[0], p[1], p[2], p[3], p[4], p[5])) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

        }
    }
}


Measured memory_bytes: 24224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

int N, K;
string S;

int main() {
    cin >> N >> K >> S;
    int a = 0;
    rep(i,N-1) if (S[i] != S[i+1]) ++a;
    cout << N-1 - max(a-K*2,0) << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

bool dfs(int node, vector<ll> &A, vector<int> &used, vector<vector<int> > &edges, priority_queue<ll, vector<ll>, greater<ll> > &que){
    if(used[node]==1)return false;
    used[node]=1;
    que.push(A[node]);

    for(auto v: edges[node]){
        dfs(v, A, used, edges, que);
    }
    return true;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> A(N,0);
    for(auto &a:A){
        cin >> a;
    }

    vector<vector<int> > edges(N,vector<int>(0));
    for(int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    priority_queue<ll, vector<ll>, greater<ll> > que;
    vector<int> used(N,0);
    ll ans=0;
    int cnt=0;
    for(int i=0; i<N; i++){
        priority_queue<ll, vector<ll>, greater<ll> > tmp;
        if(dfs(i, A, used, edges, tmp)){
            ans+=tmp.top();
            tmp.pop();
            cnt++;
        }
        while((int)tmp.size()>0){
            que.push(tmp.top());
            tmp.pop();
        }
    }
    if(cnt==1){
        cout << 0 << endl;
        return 0;
    }

    cnt-=2;
    while(cnt>0){
        if((int)que.size()==0){
            cout << "Impossible" << endl;
            return 0;
        }
        ans+=que.top();
        que.pop();
        cnt--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9336
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p ** .5) + 1):
        if p % i == 0:
            return False
    return True


a, b = map(int, input().split())
g = gcd(a, b)
kouyakusu = make_divisors(g)
ans = 1
for i in kouyakusu:
    if is_prime(i):
        ans += 1
print(ans)

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

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n-1);
    rep(i,n){
        cin>>A[i];
        A[i]--;
    }
    rep(i,n)cin>>B[i];
    rep(i,n-1)cin>>C[i];
    
    int ans=0;
    int prev=-2;
    rep(i,n){
        ans += B[A[i]];
        if(A[i] == prev+1){
            ans += C[prev];
        }
        prev = A[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double C(int x,int y){
  double res=1;
  for(int i=0;i<y;i++) res*=x-i;
  for(int i=1;i<=y;i++) res/=i;
  return res;
}
int main(){
  int n,m;
  double l;
  cin >> n >> m >> l;
  int i,j,k,a;
  double p[n],t[n],v[n];
  double b[n][m+1];
  for(i=0;i<n;i++) {
    cin >> p[i] >> t[i] >> v[i];
    for(j=0;j<=m;j++){
      b[i][j]=C(m,j)*pow(p[i]/100,j)*pow(1.0-p[i]/100,m-j);
    }
  }
  double ans,x,y;
  for(i=0;i<n;i++){
    ans=0;
    for(j=0;j<=m;j++){
      x=b[i][j];
      for(k=0;k<n;k++){
    if(i==k) continue;
    y=0;
    for(a=m;a>=0;a--){
      if(l/v[k]+t[k]*a>l/v[i]+t[i]*j) y+=b[k][a];
      else break;
    }
    x*=y;
      }
      ans+=x;
    }
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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


int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    ll tmp;

    rep(i,n){ 
        cin >> b[i];
        b[i]--;
        a[b[i]]++;
    }

    ll total = 0;
    rep(i,n){
        total += (a[i] * (a[i]-1))/2;
    }

    rep(i,n){
        tmp = total;
        tmp -= (a[b[i]] * (a[b[i]]-1))/2;
        tmp += ((a[b[i]]-1)*(a[b[i]]-2))/2;
        cout << tmp << endl;
    }


    return 0;
}


Measured memory_bytes: 5760
import sys
from itertools import accumulate

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


def main():
    N, C, *STC = map(int, read().split())

    P = [[] for _ in range(C)]
    for s, t, c in zip(*[iter(STC)] * 3):
        P[c - 1].append((s, t))

    M = 10 ** 5
    vec = [0] * (M + 2)
    for i in range(C):
        P[i].sort()
        for j, (s, t) in enumerate(P[i]):
            if j > 0 and s == P[i][j - 1][1]:
                vec[s] += 1
                vec[t] += -1
            else:
                vec[s - 1] += 1
                vec[t] += -1

    vec = list(accumulate(vec))

    print(max(vec))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 39784
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
int compar(const int *val1,const int *val2){
    return *val2-*val1;
}
int main(void){
    int num,i,o,a,b,p1,p2,line[101],line1[100],line2[101],n,sum,sign;
    memset(line,0,sizeof(line));memset(line1,0,sizeof(line1));
    scanf("%d",&num);i=num;n=num;
        for(i=i*(i-1)/2;i>0;i--){
            scanf("%d %d %d %d",&a,&b,&p1,&p2);
            if(p1==p2){
                line[a]+=1;line1[a-1]+=1;
                line[b]+=1;line1[b-1]+=1;
            }
            if(p1>p2){
                line[a]+=3;line1[a-1]+=3;
            }
            if(p1<p2){
                line[b]+=3;line1[b-1]+=3;
            }
        }
        qsort(line1,n,sizeof(int),(int (*)(const void *,const void *))compar);
        for(i=0,sum=1,sign=0;sum+=sign,i<n;sign=1,i++){
            for(o=1;o<=n;o++){
                if(line1[i]==line[o] && line[o]!=-1){
                    sign++;
                    line2[o]=sum;
                    line[o]=-1;
                }
            }
        }
        for(i=1;i<=n;i++)
            printf("%d\n",line2[i]);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define nax (int)1e5+2
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n" 
#define INF (int)1e9
#define eps (long double)1e-9
//#define int long long
using namespace std;
// sequences with only one 2 should not be included	
int main(){
	
	int n,m;
	cin>>n>>m;
	vector<int> v(n);
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>v[i];
		sum += v[i];
	}
	sort(v.rbegin(),v.rend());
	int min = sum/(4*m);
	if(sum % 4 == 0){
		min = min -1;
	}
	//deb(min);
	if(v[m-1] > min){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}
	


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var s1 = int.Parse(s[0].ToString());
            var s2 = int.Parse(s[1].ToString());
            var s3 = int.Parse(s[2].ToString());

            Console.WriteLine(s1 + s2 + s3);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b;
int32_t main(){_

   cin >> a >> b ;

   vector<int> v;
   v.pb(a+b);
   v.pb(a-b);
   v.pb(a*b);

   sort(v.rbegin(), v.rend());

   cout<<v[0];


   return 0;
}

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


int main(){
    int n, k;
    cin >> n >> k;

    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int sum = 0;
    for(int i=0; i<k; i++){
        sum += p[i]+1;
    }

    int max = sum;
    for(int i=k; i<n; i++){
        sum -= p[i-k]; // +1     
        sum += p[i]; // +1

        if( sum > max ){
            max = sum;
        }
    }

    cout << max / 2;
    if(max%2 == 1){
        cout << ".5";
    }
    cout << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	int n, h, w, a, b;
	int cnt = 0;
	int ac, bc;
	cin >> n >> h >> w;
	rep(i, n) {
		cin >> a >> b;
		ac = a / h;
		bc = b / w;
		cnt += min(ac, bc);
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long

/* 
 * ループ系のマクロ
 * `REP(i, 10) { // cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
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; }

const int MOD = 1e9 + 7;
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
ll skip = 1;
bool lunlun(ll d){
  ll digit = GetDigit(d);
  ll lun = d / pow(10, digit - 1);
            // cout << endl << lun<< 'f' << endl;
  for(ll i = digit; i > 0; i--) {
    // cout << d << 'd' << endl << pow(10, i - 1) << "pow" << endl;
    int po = pow(10, i - 1);
    ll tmp = d / po;
    // cout << tmp << "tmp" << endl << lun << "lun" << endl;
    ll diff = tmp < lun ? lun - tmp : tmp - lun;
    if(diff < -1 || diff > 1) {
        // cout << diff << "diff" << endl;
        skip = po;
        return false;
    }
    lun = tmp;
    d -= po * tmp;
  }
  return true;
}
int main() {
    INIT();

    ll k,cnt = 0;
    cin >> k;
    ll i = 1;
    while(true) {
        ll lun = lunlun(i);
        if(lun) {
            cnt++;
            if(cnt == k) {
                cout << i;
                return 0;
            }
            i++;
        } else {
            i += skip;
        }
            // cout << i << 'i' << endl;
            // cout << cnt << 'c' << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int mod = 998244353;

int powmod(int b, int p){
	int ans=1;
	while(p){
		if(p&1){
			ans=(1ll*ans*b)%mod;
		}
		p>>=1;
		b=(1ll*b*b)%mod;
	}
	return ans;
}

int fact[4005], ifact[4005];

void pre(){
	fact[0]=1, ifact[0]=1;
	for(int i=1;i<4005;i++){
		fact[i]=(1ll*fact[i-1]*i)%mod;
		ifact[i]=powmod(fact[i],mod-2);
	}
}

int ncr(int n, int r){
	if(r==0 || n==r){
		return 1;
	}
	if(n<r){
		return 0;
	}
	
	int ans = (1ll*ifact[r]*ifact[n-r])%mod;
	return (1ll*ans*fact[n])%mod;
}

int dp[2005][2005]={}, pdp[2005][2005]={};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	pre();
	int k,n; cin >> k >> n;
	
	dp[0][0]=1;
	fill(pdp[0],pdp[0]+n+1,1);
	for(int i=1;i<=k;i++){
		for(int j=0;j<=n;j++){
			dp[i][j] = dp[i-1][j];
			if(j)
				dp[i][j] = (dp[i][j]+2ll*pdp[i-1][j-1])%mod;
		}
		pdp[i][0]=dp[i][0];
		for(int j=1;j<=n;j++){
			pdp[i][j]=(pdp[i][j-1]+dp[i][j])%mod;
		}
	}
	
	for(int i=2;i<=k;i++){
		int ans=0;
		for(int p=0;p<=n;p++){
			int cur = ncr(n-p+k-i,k-i);
			
			int left = i-1;
			if(left&1){
				cur=(1ll*cur*(dp[left/2][p]+(p>0?dp[left/2][p-1]:0)))%mod;
			}
			else{
				cur=(1ll*cur*dp[left/2][p])%mod;
			}
			
			ans=(ans+cur)%mod;
		}
		cout << ans << endl;
	}
	
	for(int i=k+1;i<=2*k;i++){
		int ans=0;
		for(int p=0;p<=n;p++){
			int cur = ncr(n-p+i-k-2,i-k-2);
			
			int left = 2*k+1-i;
			if(left&1){
				cur=(1ll*cur*(dp[left/2][p]+(p>0?dp[left/2][p-1]:0)))%mod;
			}
			else{
				cur=(1ll*cur*dp[left/2][p])%mod;
			}
			ans=(ans+cur)%mod;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    vector<int> h;
    int h_tmp;
    int ans = 1;
    int max;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h_tmp;
        h.push_back(h_tmp);
    }
    max = h[0];
    for(int i=1; i<n; i++){
        if(h[i]>=max){
            ans++;
            max=h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int T[N], A[N];
	rep(i, 0, N) cin >> T[i] >> A[i];

	ll a = 1, b = 1;

	rep(i, 0, N) {
		ll p = a / T[i], q = b / A[i];
		if(a % T[i] != 0) p++;
		if(b % A[i] != 0) q++;
		ll n = max(p, q);
		a = n * T[i];
		b = n * A[i];
	}
	cout << a + b << 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)
#define all(a) (a).begin(), (a).end()
template <int MOD>
class ModInt {
  long long x;

 public:
  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt<MOD> pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }
};

using mint = ModInt<1000000007>;

int H, W;

int main() {
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> a[i][j];

  vector<mint> dp(W, 0);
  dp[0] = 1;

  rep(i, H) rep(j, W) {
    if (a[i][j] == '#') {
      dp[j] = 0;
    } else if (j > 0) {
      dp[j] += dp[j - 1];
    };
  }

  cout << dp[W - 1] << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    int x,y,a;// Your code here!
    cin >> x >> y;
    if(x<y){
        a=y;y=x;x=a;
    }
    
    for(int d;x%y!=0;){
       // if(x%y!=0){
            d=x%y,x=y,y=d;
    //    }
        
        
        
    }
    cout << y<<endl;
    
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<Pi> Vp;
typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int k,n; cin>>k>>n; int s=0,ma=0;
    for (int i = 0; i < n; i++){
        int a; cin>>a; cmax(ma,a); s+=a;
    }
    cout<<max(0,2*ma-s-1)<<'\n';
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int a, b, c, d, e, f;

bool calc(int i, int j) {
	bool isok = false;
	for (int l = 0; l * a <= j; l++) {
		if ((j - l * a) % b == 0) {
			isok = true;
			break;
		}
	}
	if (!isok) {
		return false;
	}
	isok = false;
	for (int l = 0; l * c <= i; l++) {
		if ((i - l * c) % d == 0) {
			isok = true;
			break;
		}
	}
	return isok;
}

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	double cc = -1;
	int cci = -1, ccj = -1;
	for (int j = a; j <= f / 100; j++) {
		for (int i = 0; i <= e * j; i++)
			if (calc(i, j) && i + j * 100 <= f) {
				if (cc < 1.0 * i / j)
					cc = 1.0 * i / j, cci = i, ccj = j;
			}
	}
	cout << (cci + ccj * 100) << " " << cci << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a<=b){
		if(c<=d){
			cout<<a+c;	
		}
		else{
			cout<<a+d;
		}
	}
	else{
		if(c<=d){
		cout<<b+c;	
		}
		else{
			cout<<b+d;
		}
	}
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.read();
    let p: String = sc.read();
    let s = s.clone() + &s;
    let ans = if s.find(&p).is_some() {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}



Measured memory_bytes: 5044
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

vector<int> G[200200];
int per,mx;
void dfs(int s,int f,int now=0){
    if(mx<now){
        mx=now;
        per=s;
    }
    for(int t:G[s]){
        if(t==f)continue;
        dfs(t,s,now+1);
    }
}

int main(){
    int n; cin >> n;
    for(int i=0;i<n-1;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    mx=-1;
    dfs(0,-1);
    dfs(per,-1);
    if(mx%3==1){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int c1 = a / d;
	int c2 = c / b;
	if (d * c1 < a) c1++;
	if (b * c2 < c) c2++;
	if (c1 >= c2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
// bool sortBy(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
// 	if(a.S.F==b.S.F)
// 		return a.F<b.F;
// 	return a.S.F<b.S.F;
// }

// #define MAXN 1001
// int pf[MAXN]; 
// void sieve(){
// 	long long int i,j; 
//     pf[1] = 1; 
//     for (i=2; i<MAXN; i++) 
//     pf[i] = i;   
//     for (i=2; i*i<MAXN; i++){ 
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i) 
//                 if (pf[j]==j) 
//                     pf[j] = i; 
//         } 
//     } 
// }
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  

int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	// sieve();
	while(qwe--){
        int n,x,t;
        cin>>n>>x>>t;

        if(n%x==0){
            cout<<t*(n/x);
        }else{
            cout<<t*((n/x)+1);
        }
		

	}

	return 0;
}


Measured memory_bytes: 3612
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

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

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        v: [i32; n],
    }

    let mut v = v;
    v.sort();

    let mut ans = 0.0;

    for i in 0..n {
        if ans == 0.0 {
            ans = v[i] as f32;
        } else {
            ans = (ans + v[i] as f32) / 2.0;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
/*
				C++
				encoding: UTF-8
				Last Modified: 19/Oct/2019 07:45:59 PM

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		 int                    long long
#define		 ve                     vector
#define		 pb                     push_back
#define		 endl                   "\n"
#define		 ff                     first
#define		 ss                     second
#define		 pii                    pair<int, int>
#define		 len(v)                 (int)v.size()
#define		 all(v)                 v.begin(), v.end()
#define		 reset(a, b)            memset(a, b, sizeof(a));
#define		 fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		 dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

const int N = 305;
int n, m, l;
int dist[N][N], c[N][N];
int s, t;

void init () {
	fr (i, 0, N) {
		fr (j, 0, N) {
			dist[i][j] = 1e18;
			if (i == j) {
				dist[i][j] = 0;
			}
		}
	}
}

void floyd () {
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dist[i][j] = min (dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	fr (i, 1, n + 1) {
		fr (j, 1, n + 1) {
			c[i][j] = (dist[i][j] <= l ? 1 : 1e18);
		}
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				c[i][j] = min (c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	cin >> n >> m >> l;
	init ();
	fr (i, 0, m) {
		int u, v, c;
		cin >> u >> v >> c;
		dist[u][v] = c;
		dist[v][u] = c;
	}

	floyd ();

	int tc;
	cin >> tc;
	while (tc--) {
		cin >> s >> t;
		pr (c[s][t] < 1e18 ? c[s][t] - 1 : -1);
	}
	return 0;
}


Measured memory_bytes: 2048
n, k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
    p[i] = (p[i] + 1) / 2
s = 0
for i in range(k):
    s = s + p[i]
mx = s
for i in range(k, n):
    s += p[i] - p[i - k]
    mx = max(mx, s)
print(mx)


Measured memory_bytes: 24548
from collections import Counter
# バージョン0.14.0まで scipy.misc.comb()
# バージョン0.14.0から scipy.special.comb()
from scipy.misc import comb
# from scipy.special import comb


def main():
    s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]])
    ans = 0
    for v in s.values():
        ans += comb(v, 2, exact=True)
    print(int(ans))
    return


main()


Measured memory_bytes: 32000
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    vec =list(map(int, input().split())) 
    prev = -1
    cnt = 1
    ANS = 0
    for x in vec:
        if(prev == x):
            cnt += 1
        else:
            prev = x
            ANS += cnt//2
            cnt = 1
    
    ANS += cnt//2
    print(ANS)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3952
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	vector<string> week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string str;
	cin >> str;
	for (int i = 0; i < week.size(); ++i) {
		if (str == week[i]) {
			cout << week.size()-i << endl;
			break;
		}
	}
	return 0;
}


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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define POS first
#define VAL second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


PII dfs(string &s, int pos0) {
    char c = s[pos0 + 1];
    
    if (c == '[') {
        VI nums;
        int pos = pos0 + 1;
        while (s[pos] != ']') {
            PII ans_one = dfs(s, pos);
            pos = ans_one.POS;
            nums.PB(ans_one.VAL);
        }

        sort(ALL(nums));

        int ans_val = 0;
        for (int i = 0; i < (int)(nums.size() / 2 + 1); i++) {
            ans_val += nums[i];
        }

        return MP(pos + 1, ans_val);

    } else { // numeric
        auto pos = s.find(']', pos0);
        string int_s = s.substr(pos0 + 1, pos - pos0 - 1);
        int num = fromString<int>(int_s);

        return MP(pos + 1, num / 2 + 1);
    }
}

int solve(string &s) {
    PII ans = dfs(s, 0);
    return ans.VAL;
}

int main(void) {
    int T;
    cin >> T;

    string s;
    while (T--) {
        cin >> s;
        cout << solve(s) << endl;
    }

	return 0;
}

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

# 1の位置を見つける
A_1 = A.index(1)

# １回目の1の位置に応じて、計算変わるはず。
result = N
for i in range(K):
    # 1回目の操作
    tmp = 1
    left_d = A_1 - i
    right_d = N - A_1 - 1 - ( K - i - 1)
    
    # 左側
    while left_d > 0:
        tmp += 1
        left_d -= K - 1

    # 右側
    while right_d > 0:
        tmp += 1
        right_d -= K - 1
    
    if tmp < result:
        result = tmp

print(result)

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

int main(void){
	string str;
	while(1){
		getline(cin, str);
		bool flg = true;
		if(str == ".") break;

		stack<char> q;
		for(int p=0; p < str.length(); p++){
			if(str[p] == '('){
				q.push('(');
			}
			if(str[p] == '['){
				q.push('[');
			}
			if(str[p] == ')'){
				if(q.empty() || q.top() != '('){
					flg = false;
					break;
				}else{
					q.pop();
				}
			}
			if(str[p] == ']'){
				if(q.empty() || q.top() != '['){
					flg = false;
					break;
				}else{
					q.pop();
				}
			}
		}
		if(q.empty() && flg) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
    }

    // x^2 + y^2 + z^2 + xy + yz + zx = (x+y+z)^2 - (xy + yz + zx)

    let mut t = vec![0; n + 1];

    for x in 1.. {
        if x * x > n {
            break;
        }
        for y in 1..=x {
            for z in 1..=y {
                let i = x * x + y * y + z * z + x * y + y * z + z * x;
                if i > n {
                    break;
                }
                if x != y && y != z {
                    t[i] += 6;
                } else if x == y && y == z {
                    t[i] += 1;
                } else {
                    t[i] += 3;
                }
            }
        }
    }

    for i in 1..=n {
        println!("{}", t[i]);
    }
}


Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main() {
	int L, R, d;
	int answer = 0;

	cin >> L >> R >> d;

	for (int i = L; i <= R; i++) {
		if(i % d == 0){
			answer += 1;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 3124
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=1e6+5,mod=1000000007;
int n,m,a[N];
int main()
{
	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for( int i=1;i<=m&&cin>>a[i];i++);
	for(int i=1;i<=m;i++) n-=a[i];
	if (n>=0) cout<<n;
	else cout<<-1;
	return 0;
}


Measured memory_bytes: 3656