akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
	int data[11][11];
	int n;
	cin >> n;
	while (n){

		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				cin >> data[i][j];
			}
		}
		int sum_col[10] = { 0 };
		int sum_low[10] = { 0 };

		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				sum_col[i] += data[i][j];
				sum_low[i] += data[j][i];
			}
			data[i][n] = sum_col[i];
			data[n][i] = sum_low[i];
		}
		int sum = 0;
		for (int i = 0; i < n; i++){
			sum += data[i][n];
		}
		data[n][n] = sum;
		for (int i = 0; i < n + 1; i++){
			for (int j = 0; j < n + 1; j++){
				cout << setw(5) << right << data[i][j];
			}
			cout<<"\n";
		}
		cin >> n;
	}
	
	return 0;	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,k;
ll x[100100];

int main(){
  cin >> n >> k;
  ll ans = INF;
  rep(i,n)cin >> x[i];
  rep(i,n){
    if(i + k - 1 >= n)continue;
    ll num;
    if(x[i] * x[i + k - 1] < 0)num = 2 * min(abs(x[i]),x[i + k - 1]) + max(abs(x[i]),x[i + k - 1]);
    else num = max(abs(x[i]),abs(x[i + k - 1]));
    ans = min(ans,num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;

	int sum = A + B + C;
	int ret = sum + 9 * max(A, max(B, C));
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
void solveH()
{
  int a,b,c,tem,i;
  cin>>a>>b>>c;
  tem=min(a,b);
  vector<int>vec;
  for(i=1;i<=tem;i++)
  {
    if(a%i==0&&b%i==0)
    {
      vec.push_back(i);
    }
  }
  cout<<vec[vec.size()-c]<<endl;
}
void solveI()
{
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
// solveG();
//solveH();
solveI();
  return 0;
}

Measured memory_bytes: 3804
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Cryptography;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			int ans = 0;
			for (int i = 1; i < n; i++) {
				for (int j = 1; j < n; j++) {
					if (i * j < n) {
						ans++;
					} else {
						break;
					}
				}
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 27532
s = input()
i = 0

l_count = 0
r_count = 0

check = 0

sum_value = 0

while i < len(s):
    if s[i] == '<':
        if r_count > 0:
            if check > r_count:
                sum_value += check
                n = r_count-1
                sum_value += n * (n + 1) // 2 
            else:
                n = r_count
                sum_value += n * (n + 1) // 2     
        l_count += 1
        r_count = 0
        
        
    elif s[i] == '>':
        if l_count > 0:
            check = l_count
            n = l_count-1
            sum_value += n * (n + 1) // 2
        l_count = 0
        r_count += 1
    i += 1
    
if l_count > 0:
    n = l_count
    sum_value += n * (n + 1) // 2  
if r_count > 0:
    n = r_count
    sum_value += n * (n + 1) // 2

print(sum_value)

Measured memory_bytes: 4116
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    s = input()

    cnt = 0
    for c in s:
        if c == 'R':
            cnt += 1

    if 2 * cnt > N:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin >> s;
    rep(i,s.size()/2){
        cout << s.at(2*i);
    }
    if(s.size()%2 == 1){
        cout << s.at(s.size()-1);
    }
    cout << endl;
    
}

Measured memory_bytes: 512
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>

int main(){
    long long l;
    std::cin >> l;
    
    std::cout << std::setprecision(7) << std::fixed << std::pow(l, 3) / 27 << std::endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import *
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for x in a:
  heappush(q,-x)
for i in range(m):
  temp=-heappop(q)
  temp//=2
  heappush(q,-temp)

print(-sum(q))

Measured memory_bytes: 14180
W,H,x1,y1= map(int,input().split())   


ans = float(W*H/2)

if x1 == 1/2*W and y1 == 1/2*H :
    hantei = 1
else:
    hantei = 0

seikai = [ans,hantei]
print(' '.join(map(str, seikai)))



Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct{
    int m[3];
}triangle;

int main(){

    triangle *tri;
    int e;
    scanf( "%d",&e );
    if(( tri = ( triangle * ) malloc( sizeof( triangle ) * e )) == NULL ) return -1;
    for( int i = 0;i < e;i++ )scanf( "%d %d %d",
                                        &tri[i].m[0],&tri[i].m[1],&tri[i].m[2] );

    for( int i = 0;i < e;i++ ){
        for( int k = 0;k < 2;k++ ){
            for( int j = 0;j < 2;j++ ){
                if( tri[i].m[j] >= tri[i].m[j+1] ){
                    int buf = tri[i].m[j];
                    tri[i].m[j] = tri[i].m[j+1];
                    tri[i].m[j+1] = buf;
                }
            }
        }
        if( tri[i].m[0] * tri[i].m[0] + tri[i].m[1] * tri[i].m[1] == tri[i].m[2] * tri[i].m[2] ) printf( "YES\n" );   
        else printf( "NO\n" );
    }
    return 0;
}

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

graph = {}
for i in range(1, n+1):
    s, p = input().split(' ')
    newMap = {'number': i, 'score': int(p)}
    if s not in graph:
        graph[s] = [newMap]
    else:
        graph[s].append(newMap)

keys = list(graph.keys())
keys.sort()
for key in keys:
    maps = sorted(graph[key], reverse=True, key=lambda x: x['score'])
    for map in maps:
        print(map['number'])


Measured memory_bytes: 38256
import sys
f = sys.stdin

def set1(sq):
    x = len(sq) // 2
    y = len(sq) // 2 + 1
    square[y][x] = 1
    return x, y, 1
def mv_r(sq, x, y):
    x = (x + 1) % len(sq)
    y = (y + 1) % len(sq)
    return x, y
def mv_l(sq, x, y):
    x -= 1
    if x < 0:
        x += len(sq)
    y = (y + 1) % len(sq)
    return x, y

def setnext(sq, x, y, i):
    x, y = mv_r(sq, x,y)
    i += 1
    while sq[y][x]:
        x, y = mv_l(sq, x, y)
    sq[y][x] = i
    return x, y, i

while True:
    n = int(f.readline())
    if n == 0:
        break
    square = [[None for j in range(n)] for i in range(n)]
    arg = set1(square)
    for i in range(n * n - 1):
        arg = setnext(square,*arg)

    for line in square:
        for num in line:
            print("{:4d}".format(num),end='')
        print()

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


int main()
{
	int x,y;

	while(1){
		cin >> x;
		cin >> y;
		if(x==0 &&y == 0)
			break;
		
		if(x<y)
			cout<<x<<" "<<y<<endl;
		else
			cout<<y<<" "<<x<<endl;
	}


	return 0;
}

Measured memory_bytes: 1164
H,W,M=map(int,input().split())
bombh=[]
bombw=[]
bomb=[]
w=[0]*W
h=[0]*H
for i in range(M):
    hs,ws=map(int,input().split())
    w[ws-1]+=1
    h[hs-1]+=1
    bomb.append([hs-1,ws-1])
maxh=max(h)
maxw=max(w)
ans=maxh+maxw
count=0
for i in range(M):
    if ans==h[bomb[i][0]]+w[bomb[i][1]]:
        count+=1
a=h.count(maxh)*w.count(maxw)
if a==count:
    ans-=1
print(ans)

Measured memory_bytes: 58796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n = s.size();
	stack<char> st;
	st.push(s.at(0));
	st.push(s.at(1));
	int cnt = 0;
	for(int i = 2; i < n; i++){
		bool ch = true;
		while(1){
			if(st.size() == 1) break;
			char c = st.top();
			st.pop();
			if(st.top() != s.at(i)){
				cnt++;
				ch = false;
			}
			else{
				if(ch) st.push(c);
				break;
			}
		}
		st.push(s.at(i));
	}
	if(cnt % 2 == 0) cout << "Second" << endl;
	else cout << "First" << endl;
}


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

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

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

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")
    };
}

fn main() {
    input!{
        n: u64,
        a: u64,
    }
    println!("{}", if n % 500 <= a { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
using System;

namespace ConsoleApplication17
{
    class Program
    {
        public static void Main()
        {
            int a, b;

           

            while (true)
            {
                  string[] s = Console.ReadLine().Split(' ');
 
                 a = int.Parse(s[0]);
                 string op = s[1];
                 b = int.Parse(s[2]);
 
                if (op == "+")
                {
                    Console.WriteLine(a + b);
                }
                else if (op == "-")
                {
                    Console.WriteLine(a - b);
                }
                else if (op == "*")
                {
                    Console.WriteLine(a * b);
                }
                else if (op == "/")
                {
                    Console.WriteLine(a / b);
                }
                else if (op == "?")
                {
                    break;
                }
            }

                }

            }
        }
    

 

Measured memory_bytes: 9264
#!/usr/bin/env python3
import sys


def solve(K: int, S: str):
    if len(S) <= K:
        print(S)
    else:
        print(S[:K]+'...')
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define        ll          long long int
#define        sz          201000
#define        fast        ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        sc1(a)      scanf("%lld",&a)
#define        sc2(a,b)    scanf("%lld %lld",&a,&b)
#define        pb          push_back
#define        pn          printf("No\n")
#define        pyy         printf("Yes\n")
#define        op(a)       printf("%lld\n",a)

using namespace std;


vector<ll>vt[sz];
ll vis[sz];

void dfs(ll u)
{
    vis[u]=1;
    ll i;

    for(i=0;i<vt[u].size();i++)
    {
       ll v=vt[u][i];
        if(vis[v]==0)dfs(v);
    }
}
int main()
{


     ll n,m,u,v,i,j,k,d,p;

     cin>>n>>m;
     while(m--)
     {
         cin>>u>>v;
         vt[u].push_back(v);
         vt[v].push_back(u);
     }
     p=0;
     for(i=1;i<=n;i++)
     {
         if(vis[i]==0)
         {
             p++;
             dfs(i);
         }
     }


     cout<<p-1<<endl;

    return 0;
}


Measured memory_bytes: 13456
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

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

    sort(a, a+n);

    int max = a[n-1];
    unsigned long long med = 0;
    for(int i=0;i<n-1;i++){
        if(abs(int(max/2-med))>=abs(int(max/2-a[i])) && med<a[i])med = a[i];
    }
    cout << max << " " << med << endl;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N, M, X;
	cin >> N >> M >> X;

	vector<bool> tb( N+1 );
	for( int i = 0; i < M; ++i ) {
		int x;
		cin >> x;
		tb[x] = true;
	}

	int a = 0;
	for( int i = X+1; i < N; ++i ) {
		a += tb[i];
	}

	int b = 0;
	for( int i = X-1; i > 0; --i ) {
		b += tb[i];
	}

	cout << min( a, b ) << endl;
	return 0;
}


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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
// constexpr ll mod = 1e9 + 7;

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


    if(S=="AAA" || S=="BBB"){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main() {

  int H,W,N = 0;
  cin >> H >> W >> N;
  int count = 0;
  int mass=0;
    while(mass < N){
      if(H >= W){
        mass = mass + H;
        count++;
      }
      else{
        mass = mass + W;
        count++;
      }
    }
    cout << count << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> a(3);
  for (auto &e : a) {
    cin >> e;
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    set<char> s;
    for (auto &e : a) {
      s.insert(e[i]);
    }
    r += (int)s.size() - 1;
  }
  cout << r << endl;
}


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

int main() {
  ll X;
  cin >> X;
  vector<bool> DP(X, false);
  for (int i = 99; i < 105; i++) {
    DP[i] = true;
  }
  for (int i = 105; i < X; i++) { //106円からX円までちえっく
    if (DP[i-100] || DP[i-101] || DP[i-102] || DP[i-103] || DP[i-104] || DP[i-105]) {
      DP[i] = true;
    }
  }
  if (DP[X-1]) {
    cout << "1" << endl;
  }
  else {
    cout << "0" << endl;
  }
}


Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline
h,w = map(int,input().split())
s = (np.array([list(input().strip()) for _ in range(h)])==".").astype(np.int)
l,r,u,d = s.copy(),s.copy(),s.copy(),s.copy()
for i in range(1,w):
  l[:,i] *= l[:,i-1] + 1
  r[:,w-i-1] *= r[:,w-i] + 1

for i in range(1,h):
  u[i] *= u[i-1] + 1
  d[h-i-1] *= d[h-i] + 1
print(max([max(i) for i in l+r+u+d-3]))

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

int main() {
  int n,m;
  cin >> n >> m;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  set<int> s;
  for(int i=n-1; i>=0; i--) {
    if(s.size()==m) break;
    if(s.count(a[i])) continue;
    cout << a[i] << endl;
    s.insert(a[i]);
  }
  return 0;
}


Measured memory_bytes: 5980
//***********************
//*** writer : Alan Hu **
//***********************
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<cstring>
#include<cmath>
using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	ll a,b=0,c;
	cin>>a;
	c=a;
	while (a>0)
	{
		int x=a%10;
		b+=x;
		a/=10;
	}
	if (c%b==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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 FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << v[K - 1] << endl; 
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    set<string>st;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    int cnt = 0;
    for (auto x : st) {
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 19228
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<vector<pair<int,ll>>> v(n);
	rep(i, m)
	{
		int l, r; cin >> l >> r;
		--l, --r;
		ll d; cin >> d;
		v[l].push_back(make_pair(r, d));
		v[r].push_back(make_pair(l, -d));
	}
	ll INF = 1e18;
	vector<ll> pos(n, INF);
	vector<bool> checked(n);
	queue<int> q;
	rep(i, n)
	{
		if (checked[i])continue;
		pos[i] = 0;
		for (auto p : v[i])
		{
			pos[p.first] = p.second;
			q.push(p.first);
		}
		checked[i] = true;
		while (!q.empty())
		{
			int now = q.front();
			q.pop();
			for (auto p : v[now])
			{
				int next = p.first;
				ll dist = p.second;
				if (checked[next])continue;
				if (pos[next] == INF)
				{
					pos[next] = pos[now] + dist;
					q.push(next);
				}
				else if (pos[next] != pos[now] + dist)
				{
					cout << "No" << endl;
					return 0;
				}
			}
			checked[now] = true;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 13824
def knaspsack(V,W,n,w):
    V = [0] + V ; W = [0] + W
    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1, n+1):
        for j in range(w+1):
            if j < W[i]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-W[i]]+V[i])
    return dp[n][w]
    
n,w=map(int,input().split())
V=[0]*n;W=[0]*n
for i in range(n):
    V[i],W[i]=map(int,input().split())
print(knaspsack(V,W,n,w))


Measured memory_bytes: 25516
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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)*}
    };

    ($next:expr, mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn solve() {
    input!(
        s: chars,
        t: chars,
    );
    let s: String = s.into_iter().collect();
    let t: String = t.into_iter().collect();
    println!("{}{}", t, s);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
lista = list(map(int, input().split()))
newlista = sorted(lista)

lowermedian = newlista[int(len(lista)/ 2- 1)]
highermedian = newlista[int(len(lista)/2)]

for i in range(N):
  if(lista[i] <= lowermedian):
    print(highermedian)
  else:
    print(lowermedian)

Measured memory_bytes: 25556
plst = [1 for i in range(1000001)]
slst = [0,0]
plst[0] = plst[1] = 0
count = 0
for i in range(2,1000001):
  if plst[i] == 1:
    count += 1
    for j in range(i * 2,1000001,i):
      plst[j] = 0
  slst.append(count)
while True:
  try:
    print(slst[int(input())])
  except EOFError:
    break



Measured memory_bytes: 23788
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second
 
#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; cin >> ___T; while (___T-- > 0) 
 
 
#define rep(it, st, en) for(ll it = st; it < en; it++)
#define rep1(it, st, en) for(ll it = st; it <= en; it++)
#define per(it, st, en) for(ll it = en - 1; it >= st; it--)
 
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;
 
ll INF = 1E9;
ll M = 1E9 + 7;
 
inline ll max_(ll a, ll b) { return (a>b)?a:b; }
inline ll min_(ll a, ll b) { return (a<b)?a:b; }
 
inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}
 
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
    boost;
    if(fopen("inp.txt", "r")){
      freopen("inp.txt", "r", stdin);
      freopen("outp.txt", "w", stdout);
    }

    ll n,m,r,i,j,k,u,v,w;
    cin>>n>>m>>r;

    ll num[r];

    for (i=0;i<r;i++)
        cin>>num[i];

    sort(num,num+r);

    ll graph[n+1][n+1],dist[n+1][n+1];

    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            graph[i][j]=(ll)1E15;

    while (m--) {
        cin>>u>>v>>w;

        graph[u][v]=w;
        graph[v][u]=w;
    }

    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            dist[i][j]=graph[i][j];

    //run floyd warshall
    for (k=1;k<=n;k++)
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++)
                if (dist[i][k]+dist[k][j]<dist[i][j])
                    dist[i][j]=dist[i][k]+dist[k][j];

    // for (i=1;i<=n;i++) {
    //     for (j=1;j<=n;j++)
    //         cout<<dist[i][j]<<" ";
    //     cout<<endl;
    // }

    ll ans=numeric_limits<ll>::max();

    do {
        ll d=0;
        for (i=0;i<r-1;i++)
            d+=dist[num[i]][num[i+1]];

        // cout<<d<<endl;

        ans=min_(ans,d);
    }
    while (next_permutation(num,num+r));

    cout<<ans;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,d,x;
  cin>>n>>d>>x;
  int ans=x;
for (int i = 0; i < n; i++) {
 int a;
  cin>>a;
  ans +=(d-1)/a+1;
}
  cout<<ans<<endl;

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    string s;
    string t;
    cin>>s>>t;
    int m=s.length();
    int n=t.length();
    int flag=0;
    if(m>n)
    {
        cout<<"No"<<endl;
    }
    else if(n-m==1)
    {
        for(int i=0;i<m;i++)
        {
            if(s[i]!=t[i])
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            cout<<"No"<<endl;
        else
           cout<<"Yes"<<endl;
    }
    else
       cout<<"No"<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> a(n + 1,0);
	for (int i = 0; i < m; i++) {
		int b;
		cin >> b;
		a.at(b) = 1;
	}
	int l=0, r=0;
	for (int i = 0; i < x; i++) {
		l += a.at(i);
	}
	for (int i = x; i < n + 1; i++) {
		r += a.at(i);
	}
	int sum=(l < r) ? l : r;
	cout << sum;
}

Measured memory_bytes: 3568
/**
    BISMILLAH
    @Author : Arham
*/
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    if(n % 2)
        cout << "No" << endl;
    else {
        int count = true;
        for(int i = 0, j = n / 2; i < n / 2; i++, j++) {
            if(s[i] != s[j]) {
                count = false;
                break;
            }
        }
        cout << (count ? "Yes" : "No") << endl;
    }

    return;
}

int main() {
    int t = true;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=(ll)1e18;
const ll maxs = (ll)100+5;
const ll mod = (ll)1e9+7;
const ll oo = (ll) 1e18;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n,k;
ll a[maxs][maxs];
ll res[maxs][maxs];

void mul(ll aa[maxs][maxs],ll b[maxs][maxs],ll flg)
{
    ll tmp[maxs][maxs];
    memset(tmp,0,sizeof tmp);
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            for(ll k=0;k<n;k++)
                tmp[i][j] = (tmp[i][j]%mod + (aa[i][k]*b[k][j])%mod)%mod;
     
     if(flg)
        {
             for(ll i=0;i<n;i++)
                for(ll j=0;j<n;j++)
                    res[i][j] = tmp[i][j];
        }
        else
        {
             for(ll i=0;i<n;i++)
                for(ll j=0;j<n;j++)
                    a[i][j] = tmp[i][j];
        }
}


void solve()
{
    for(ll i=0;i<n;i++)
        res[i][i] = 1;
    ll y = k;
    while(y)
    {
        if(y&1)
             mul(res,a,1);
        mul(a,a,0);
        y>>=1;
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            ans = (ans + res[i][j])%mod;
    
    cout<<ans;
}


int main() {
    fastio();
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	    for(ll j=0;j<n;j++)
	        cin>>a[i][j];
	solve();        
	return 0;
}

Measured memory_bytes: 384
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

long long f(long long b,long long n){
	if(n<b) return n;
	else return f(b,n/b)+(n%b);
}

int main(){

	long long n,s;
	cin>>n>>s;

	if(n<s){
		cout<<-1<<endl;
		return 0;
	}

	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}

	
	for(long long b=2;b*b<=n;b++){
		if(f(b,n)==s){
			cout<<b<<endl;
			return 0;
		}
	}

	long long res=-1;
	for(long long p=1;p*p<n;p++){
		if((n-s)%p) continue;
		if(f((n-s)/p+1,n)==s) res=(n-s)/p+1;
	}

	cout<<res<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#define INF 2e9
#define rep(i,m) for(int i=0;i<m;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)


using namespace std;

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

	rep(i, size(a))
	{
		if (a[i] == '?')a[i] = 'D';
	}
	cout << a << endl;
	return 0;
}
	

Measured memory_bytes: 3732
package main

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

type Point struct {
	a int
	b int
}

type Points []Point

func main() {
	var n int
	var dishes Points
	fmt.Scan(&n)

	dishes = make(Points, n)
	sc := bufio.NewScanner(os.Stdin)
	for i:=0; i<n; i++ {
		d := Point{}
		sc.Scan()
		fmt.Sscanf(sc.Text(), "%d %d", &d.a, &d.b)
		dishes[i] = d
	}

	sort.Sort(dishes)

	ans := 0
	for i:=0; i<n; i++ {
		if i%2 == 0 {
			ans += dishes[i].a
		} else {
			ans -= dishes[i].b
		}
	}

	fmt.Println(ans)
}

// Sortアルゴリズムを使用するためにインタフェースの実装
func (r Points) Len() int {
	return len(r)
}
func (r Points) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}
func (r Points) Less(i, j int) bool {
	return r[i].a+r[i].b > r[j].a+r[j].b
}

Measured memory_bytes: 4992
N,M=map(int,input().split())
L,H=map(int,input().split())
c=0
w=1
while c<M-1:
    l,h=map(int,input().split())
    if L<=l<=H:
        L=l
    elif l>H:
        w=0
        break
    if L<h<H:
        H=h
    c+=1
if w!=0:
    print(H-L+1)
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct Combination
{
	vector<ll> fact, inv, invFact;
	int MAX_FACT;
	ll MOD;
	Combination(int n, ll mod) : fact(n + 1), inv(n + 1), invFact(n + 1)
	{
		MAX_FACT = n + 1;
		MOD = mod;
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (auto i = 2; i < MAX_FACT; ++i)
		{
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}

	unsigned long long calcCombination(int n, int k)
	{
		if (n < k)
		{
			return 0;
		}
		if ((n < 0) || (k < 0))
		{
			return 0;
		}

		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
};

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

	auto mod = (ll)1e9 + 7;
	Combination c(N + 1, mod);

	for (auto i = 1; i <= K; ++i)
	{
		auto ans = c.calcCombination(K - 1, i - 1) * c.calcCombination(N - K + 1, i) % mod;
		cout << ans << endl;
	}

	return 0;
}

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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>vec(n);
    vector<int>dp(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
        dp.at(i) = inf;
    }
    dp.at(0)=0;

    for(int i=1;i<n;i++){
        for(int j=1;j<min(i,k)+1;j++){
            chmin(dp.at(i),dp.at(i-j) + abs(vec.at(i) - vec.at(i-j)));
        }

    }

    cout<<dp.at(n-1)<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
 ll mod=998244353;
 ll dp[2005][2005];
void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,t,y=0;
cin>>n>>x>>y;

rep(i,1,n) dp[i][i+1]=1; dp[x][y]=1;
rep(i,x+1,y+1)
{
    dp[x][i]=min(i-x,y-i+1);
}
rep(i,x+1,y)
{
    rep(j,i+1,y+1)
    {
        dp[i][j]=min(j-i,y-j+1+i-x);
    }
}

rep(i,1,n)
{
    rep(j,i+1,n+1)
    {
        if(i<x and j<=y)
        {
            dp[i][j]=min(j-i,x-i+dp[x][j]);
        }
        else if(i<=x and j>=y)
        {
            dp[i][j]=x-i+1+j-y;
        }
        else if(i>=x and j>=y )
        {
            dp[i][j]=min(j-i,i-x+1+j-y);
        }
    }
}

vector < ll > v(n+1);
rep(i,1,n)
{
    rep(j,i+1,n+1) v[dp[i][j]]++;
}

rep(i,1,n)  cout<<v[i]<<endl;



}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
         //cin>>t;
        while(t--)
        solve();
    }


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 10000007

int main()
{
    FastIO
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    long long p[a], q[b], r[c];
    for(int i=0; i<a; i++)
        cin >> p[i];
    for(int i=0; i<b; i++)
        cin >> q[i];
    for(int i=0; i<c; i++)
        cin >> r[i];
    sort(p, p+a, greater<int>());
    sort(q, q+b, greater<int>());
    sort(r, r+c, greater<int>());
    long long best[x+y];
    memset(best, 0, sizeof(best));
    for(int i=0; i<x; i++)
        best[i] = p[i];
    for(int i=0; i<y; i++)
        best[x+i] = q[i];
    sort(best, best+x+y);
    int pos = 0;
    while(r[pos] > best[pos] && pos < c)
    {
        best[pos] = r[pos];
        pos++;
    }
    long long ans = 0;
    for(int x : best)
        ans += x;
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int A;
  string op;
  int B;
  cin >> A >> op >> B;
  if (op == "+") {
    cout << A + B <<endl;
  }
  else if ( op == "-") {
    cout << A - B << endl;
  }

}

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



int main() {
    ll N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i,N) cin >> t.at(i);
    sort(t.begin(), t.end());
    ll Tend = 0;
    ll ans = 0;
    rep(i,N) {
        ans += max(0LL, min(T, t.at(i) + T - Tend));
        Tend = t.at(i) + T;
    }
    cout << ans << endl;
}



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

int main(){
    int N;
    int C[500], S[500], F[500];

    cin >> N;
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    
    for(int i=0;i<N;i++){
        int t=0;
        for(int j=i;j<N-1;j++){
            if(t<S[j]) t=S[j];
            if(t%F[j]!=0) t=t-(t%F[j])+F[j];
            t+=C[j];
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
temp_dict ={ i+1 : int(input()) for i, j in enumerate(range(N))}
reference_value = 1
for i in range(N):
    reference_value = temp_dict[reference_value]
    if reference_value == 2:
        print(i+1)
        break
    else:
        pass

if reference_value !=2:
    print(-1)

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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N + 1);
    rep(i, N - 1){
        long long tmp;
        cin >> tmp;
        A.at(tmp)++;
    }
    for (int i = 1; i < N + 1;i++){
        cout << A.at(i) << endl;
    }
}



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

int isBomb(char c) {
  if(c=='#') return 1;
  else return 0;
}

int main() {
  int H, W;
  cin >> H >> W;
  char c[H+2][W+2];
  for(int i=0; i<H+2; i++){
  	for(int j=0; j<W+2; j++){
      if(i==0 || i==H+1 || j==0 || j==W+1) c[i][j]='.';
      else cin >> c[i][j];
    }
  }
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      if(c[i][j]=='#') cout << '#';
      else cout << isBomb(c[i-1][j-1])+isBomb(c[i-1][j])+isBomb(c[i-1][j+1])
        +isBomb(c[i][j-1])+isBomb(c[i][j+1])
        +isBomb(c[i+1][j-1])+isBomb(c[i+1][j])+isBomb(c[i+1][j+1]);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys, math
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7

def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(K, N + 2):
        val = N * i - i * (i - 1) + 1
        #print("i={}, val={}".format(i, val))
        ans += val
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define close(x){cout<<x<<endl;return 0;}
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int x1,y1,x2,y2,x3,y3,x4,y4,dx,dy;
cin>>x1>>y1>>x2>>y2;
dx=x2-x1;dy=y2-y1;
x3=x1-dy;y3=y1+dx;
x4=x3+dx;y4=y3+dy;
cout<<x4<<" "<<y4<<" "<<x3<<" "<<y3<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll N,M;
ll A[200010], B[200010];
vector<ll> tree[100010];
vector<ll> tree_inv[100010];
ll h[100010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,N-1+M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        h[B[i]]++;
        tree_inv[B[i]].push_back(A[i]);
    }
    stack<ll> st;
    rep(i,0,N){
        if(h[i] == 0){
            st.push(i);
        }
    }
    vector<ll> ans;
    while(st.size()){
        ll k = st.top();
        st.pop();
        ans.push_back(k);
        for(auto &e: tree[k]){
            h[e]--;
            if(h[e] == 0) st.push(e);
        }
    }

    map<ll,ll> mp;
    rep(i,0,N){
        mp[ans[i]] = i;
    }
    ll v[100010] = {};
    rep(i,0,N){
        if(mp[i] == 0){
            v[i] = -1;
        }else{
            ll val = -1;
            ll tt = -1;
            for(auto &e: tree_inv[i]){
                if(val < mp[e]){
                    val = mp[e];
                    tt = e;
                }
            }
            v[i] = tt;
        }
    }
    rep(i,0,N){
        print(v[i]+1);
    }

}


Measured memory_bytes: 23032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef multiset<int>::iterator msi;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int a[3];
int cnt[3];
int main(){
	for(int i=0;i<3;i++){
		cin >> a[i];
		cnt[a[i]%2]++;
	}
	int ans = 0;
	if(cnt[0]==0||cnt[1]==0){
		sort(a,a+3);
		ans += (a[2]-a[0])/2;
		ans += (a[2]-a[1])/2;
 	}else{
		ans++;
		if(cnt[0]==1){
			for(int i=0;i<3;i++){
				if(a[i]%2==1)a[i]++;
			}
		}else{
			for(int i=0;i<3;i++){
				if(a[i]%2==0)a[i]++;
			}
		}
		sort(a,a+3);
		ans += (a[2]-a[0])/2;
		ans += (a[2]-a[1])/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string class_name[11]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
  double class_weight[11]={48,51,54,57,60,64,69,75,81,91,1000};
  double weight;
  while(cin>>weight){
    int i=0;
    while(weight>class_weight[i])i++;
    cout<<class_name[i]<<endl;
  }
}

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

void swap(int *a, int *b){
  *a = *a ^ *b;
  *b = *a ^ *b;
  *a = *a ^ *b;
}

int main(void)
{
  int n;
  int i;
  int sum[100];
  char str[10];
  int dice[6];
  int d;
  int c;

  c = 0;
  while (scanf("%d", &n), n != 0){
    i = n;
    dice[0] = 1; dice[1] = 2; dice[2] = 4; dice[3] = 5;
    dice[4] = 3; dice[5] = 6;
    sum[c] = 1;
    while (i--){
      scanf("%s", str);
      if (strcmp(str, "North") == 0){
        swap(&dice[0], &dice[3]);
        swap(&dice[0], &dice[1]);
        swap(&dice[1], &dice[5]);
        sum[c] += dice[0];
      }
      else if (strcmp(str, "East") == 0){
        swap(&dice[0], &dice[4]);
        swap(&dice[0], &dice[5]);
        swap(&dice[0], &dice[2]);
        sum[c] += dice[0];
      }
      else if (strcmp(str, "West") == 0){
        swap(&dice[0], &dice[4]);
        swap(&dice[4], &dice[5]);
        swap(&dice[5], &dice[2]);
        sum[c] += dice[0];
      }
      else if (strcmp(str, "South") == 0){
        swap(&dice[0], &dice[1]);
        swap(&dice[0], &dice[3]);
        swap(&dice[3], &dice[5]);
        sum[c] += dice[0];
      }
      else if (strcmp(str, "Right") == 0){
        swap(&dice[2], &dice[1]);
        swap(&dice[1], &dice[4]);
        swap(&dice[4], &dice[3]);
        sum[c] += dice[0];
      }
      else if (strcmp(str, "Left") == 0){
        swap(&dice[1], &dice[4]);
        swap(&dice[1], &dice[2]);
        swap(&dice[2], &dice[3]);
        sum[c] += dice[0];
      }
    }
    c++;
  }

  for (i = 0; i < c; i++){
    printf("%d\n", sum[i]);
  }

  return (0);
}

Measured memory_bytes: 604