akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
#include <list>
#define ll long long 
using namespace std;




int main()
{
 string s,t;
 cin>>s>>t;
 ll sl,tl;
 sl=s.size();
 tl=t.size();
 ll ans=tl;
 for(ll i=0;i<=sl-tl;i++)
 {
   ll temp=tl;
   for(ll j=0;j<tl;j++)
   {
     if(s[i+j]==t[j])
     temp--;

   }
   if(ans>temp)
   ans=temp;
 }
 cout<<ans<<endl;
 return 0;
}

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

namespace PaizaSkillCheck
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int k = int.Parse(line[1]);

            List<int> list = new List<int>(n);

            for(int i = 0; i < n; i++)
            {
                int height = int.Parse(Console.ReadLine());

                list.Add(height);
            }

            list.Sort();

            int result = int.MaxValue;
            int end = (n - k) + 1;

            for (int i = 0; i < end; i++)
            {
                result = Math.Min(result, list[i + k - 1] - list[i]);
            }

            Console.WriteLine(result);
            Console.ReadLine();
        }

    }

}


Measured memory_bytes: 15452
//
// Created by 童正阳 on 2018/9/14.
//
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, s;
ll f(ll b, ll n) {
    if (n < b) {
        return n;
    } else {
        return f(b, floor(n/b)) + (n % b);
    }
}
int main() {
    cin >> n >> s;
    if (n < s) {
        cout << -1 << endl;
    } else if (n == s) {
        cout << n+1 << endl;
    } else {
        ll ans1 = 1e12;
        for (ll b = 2; b*b <= n; b++) {
            if (f(b, n) == s) {
                ans1 = b;
                break;
            }
        }
        ll ans2 = 1e12;
        for (ll p = 1; p*p <= n && p <= s; p++) {
            ll q = s - p;
            if ((n - q) % p == 0) {
                ll b = (n - q) / p;
                if (b > p && b > q) {
                    ans2 = min(ans2, b);
                }
            }
        }
        ll ans = min(ans1, ans2);
        if (ans >= 1e12) {
            ans = -1;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let ab: Vec<_> = (0..n)
        .map(|_| (sc.read::<i64>(), sc.read::<i64>()))
        .collect();
    let mut a = ab.iter().map(|&t| t.0).collect::<Vec<_>>();
    let mut b = ab.iter().map(|&t| t.1).collect::<Vec<_>>();

    a.sort();
    b.sort();

    if n % 2 == 0 {
        let min = a[n / 2] + a[n / 2 - 1];
        let max = b[n / 2] + b[n / 2 - 1];
        println!("{}", max - min + 1);
    } else {
        let min = a[n / 2];
        let max = b[n / 2];
        println!("{}", max - min + 1);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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


int wa(int N)
{
    int ret = 0;
    while(N)
    {
        ret += N % 10;
        N /= 10;
    }
    return ret;
}

int main()
{
    int N, A, B;
    std::cin >> N >> A >> B;
    
    int ans = 0;
    for(int i = 1; i <= N; ++i)
    {
        int w = wa(i);
        if(A <= w && w <= B) ans += i;
    }
    std::cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define loop(i, n) for (int i = 0; i < (int)n; i++)

int main() {
    string s; cin >> s;
    string t; cin >> t;
    t.pop_back();
    for (int i = 0; i < s.size(); i++ ) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
void add(ll &a, ll b)
{
    a = (a + b) % MOD;
}
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(k+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++)
    {
        ll sum = 0;
        for(int j = 0; j <= k; j++)
        {
            add(sum, dp[i][j]);
            dp[i+1][j] = sum;
            if(j - a[i] >= 0) add(sum, -dp[i][j - a[i]]);
        }
    }
    add(dp[n][k], MOD);
    cout << dp[n][k] << endl;
}


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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLong();
            for (int i = 0;; i++)
            {
                if (N < i * i)
                {
                    Out((i - 1) * (i - 1));
                    return;
                }
            }
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }

    class UnionFind
    {
        private readonly int[] _array;

        public UnionFind(int N)
        {
            _array = new int[N];
            for (int i = 0; i < N; i++)
            {
                _array[i] = i;
            }
        }

        public int GetRootNode(int n)
        {
            if (_array[n] == n) return n;
            return _array[n] = GetRootNode(_array[n]);
        }

        public void UnionGroup(int a, int b)
        {
            var rootA = GetRootNode(a);
            var rootB = GetRootNode(b);
            if (rootA == rootB) return;
            _array[rootA] = rootB;
        }

        public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);

        public bool IsRoot(int n) => _array[n] == n;
    }
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, x;
    ll ans = 0;
    cin >> N >> x;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N - 1) {
        int y = A[i] + A[i + 1] - x;
        if (y <= 0) continue;
        ans += y;
        if (A[i + 1] >= y) {
            A[i + 1] -= y;
        } else {
            A[i] = x;
            A[i + 1] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int sum=0;
    for (int i=0;i<s.size();i++) {
        char c=s.at(i);
        int tmp=c-48;
        sum+=tmp;
    }
    if (stoi(s)%sum==0) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


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

const int MOD = 1e9+7;
int dp[101010][2];
//頂点iを白|黒で塗ったとき、それを根とした木の色の組み合わせ

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

  int n; cin >> n;
  vector<int> G[n];
  for(int i = 0; i < n-1; i++){
    int x,y; cin >> x >> y;
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  fill(dp[0],dp[101010-1]+2,1);
  vector<int> visited(n+1,false);
  function< int(int) > rec =
  [&](int i){ //白:0 黒:1
    visited[i] = true;
    for(int v : G[i]){
      if(visited[v]) continue;
      rec(v);
      dp[i][0] *= (dp[v][0] + dp[v][1]) % MOD;
      dp[i][0] %= MOD;
      dp[i][1] *= dp[v][0];
      dp[i][1] %= MOD;
    }
    return (dp[i][0] + dp[i][1]) % MOD;
  };
  cout << rec(0) << endl;

  return 0;
}


Measured memory_bytes: 16384
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()  {
	string s;
	cin>>s;
	if(s == "Sunny") {
		cout<<"Cloudy";
	}else if(s == "Cloudy") {
		cout<< "Rainy";
	}else if(s == "Rainy") {
		cout<<"Sunny";
	}
}

Measured memory_bytes: 256
l,r = map(int,input().split())
m = 2018
if r-l>=2019:
  print(0)
else:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      m = min(a,m)
  print(m)


Measured memory_bytes: 2940
t = int(input())
score = [0, 0]
for i in range(t):
    pair = input().split(" ")
    if pair[0] > pair[1]:
        score[0] += 3
    elif pair[0] < pair[1]:
        score[1] += 3
    else:
        score[0] += 1
        score[1] += 1
print(" ".join(map(lambda x: str(x), score)))



Measured memory_bytes: 5608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String A = sc.next();
      String B = sc.next();
      String C = sc.next();
      if(A.equals(B)&&(!(B.equals(C)))||B.equals(C)&&(!(C.equals(A)))||
         C.equals(A)&&(!(A.equals(B)))){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35392
#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(){
    int n, a[1000];
    cin >> n;

    rep(i,n) cin >> a[i];

    bool ans = true;

    rep(i,n){
        if (a[i] % 2 == 0){
            if (a[i] % 3 != 0 && a[i] % 5 != 0) ans = false;
        }
    }
    
    if (ans) cout << "APPROVED" << endl;
    if (!ans) cout << "DENIED" << endl;

    return 0;
    
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};


int main(){
  int N;
  cin >>N;
  vector<int> S(N);
  Rep(i,N){
    char s;
    cin >> s;
    S.at(i)= s-'0';
  }
  int ans=0;
  Rep(i,1000){
    int testhu=(i%1000)/100;
    int testte=(i%100)/10;
    int teston=(i%10);
    Rep(j,N){
      if(S.at(j) == testhu){
        for(intl k = j+1;k<N;k++){
          if(S.at(k)==testte){
            for(intl l=k+1; l<N;l++){
              if(S.at(l)==teston){ans++;break;}
            }
           break; 
          }
        }
        break;
      }
    }
  }
  cout <<ans;
}


Measured memory_bytes: 384
package main
 
import (
	"fmt"
	"strings"
)
 
func main() {
	var n int
	var s string
	fmt.Scan(&n,&s)
	ss := strings.Split(s,"")
 
	as := []string{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
 
	ans := ""
	for _,s := range ss {
		for k,a := range as {
			if s == a {
				ans += as[(k+n) % 26]
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define NIREP(i, n) for((i)=0; (i)<(n); (i)++) //non-initialized rep
const int limit = 20;
int dx[9] = {1, 1, 1, 0, 0, 0,-1,-1,-1};
int dy[9] = {1, 0,-1, 1, 0,-1, 1, 0,-1};
typedef vector<vector<bool> > vec2D;
vec2D defplane(2, vector<bool>(2, false));
bool canmove(int n, vec2D &a){
    REP(x,2) REP(y,2){
        int nx = x+dx[n];
        int ny = y+dy[n];
        if(a[x][y] && (nx<0 || 1<nx || ny<0 || 1<ny)){
            return false;
        }
    }
    return true;
}
bool canmove(int n, vector<vec2D> &a){
    REP(i, (int)a.size()){
        if(!canmove(n, a[i])) return false;
    }
    return true;
}
vector<vec2D> convert(int n, vector<vec2D> &a){
    vector<vec2D> ret(2, defplane);
    REP(x,2) REP(y,2) {
        int nx = x+dx[n];
        int ny = y+dy[n];
        if(0<=nx && nx<=1 && 0<=ny && ny<=1){
            REP(i,2) ret[i][nx][ny] = a[i][x][y];
        }
    }
    return ret;
}
bool isoverlap(vec2D &a, vec2D &b){
    REP(x,2) REP(y,2){
        if(a[x][y] && b[x][y]) return true;
    }
    return false;
}

int main(){
    while(1){
        int h,n;
        cin >> h >> n;
        if(h==0) break;
        
        vector<vec2D> c(limit, defplane);
        vector<vector<vec2D> > b(3, vector<vec2D>(2, defplane));
        REP(r,h) REP(i,2) REP(j,2){
            char in;
            cin >> in;
            if(in == '#') c[r][i][j] = true;
        }
        REP(k,n) REP(r,2) REP(i,2) REP(j,2){
            char in;
            cin >> in;
            if(in == '#') b[k][r][i][j] = true;
        }

        
        int ans = 0;
        int var[3];
        NIREP(var[0], 9) NIREP(var[1], 9) NIREP(var[2], 9){
            if(!canmove(var[0], b[0]) || !canmove(var[1], b[1]) || !canmove(var[2], b[2])){
                continue;
            }
            int count = 0;
            vector<vec2D> field = c;
            REP(i,3){
                //make block (moved)
                vector<vec2D> block = convert(var[i], b[i]);
                if(block[0] == defplane) swap(block[0], block[1]);
                //height of falling block
                int s=limit-2;
                while(s>0 && !isoverlap(block[0], field[s-1]) && !isoverlap(block[1], field[s])){
                    s--;
                }
                //put
                REP(r,2) REP(x,2) REP(y,2){
                    if(block[r][x][y]){
                        field[s+r][x][y] = true;
                    }
                }
                //delete and count
                for(int i=limit-1; i>=0; i--){
                    bool full = true;
                    REP(x,2) REP(y,2){
                        if(!field[i][x][y]) full = false;
                    }
                    if(full){
                        count++;
                        field.erase(field.begin()+i);
                        field.push_back(defplane);
                    }
                }
            }
            ans = max(ans, count);
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main()
{    
    int H, W;

    while(1){

        cin >> H >> W;

        if(H==0 && W==0){
            break;
        }

        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << "\n";
        }

        cout << "\n";

    }

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int dp[n+1][2];
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int i=0; i<n; i++) {
    dp[i+1][0] = min(dp[i][0]+(S[i]-'0'), dp[i][1]+10-(S[i]-'0'));
    dp[i+1][1] = min(dp[i][0]+(S[i]-'0')+1, dp[i][1]+9-(S[i]-'0'));
  }
  cout << dp[n][0] << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second

using namespace std;

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll n,h,w;
	cin >> n >> h >> w;

	ll x;
	int a = 0,b = 0,c = 0;
	for (int i = 0; i < n; ++i){
		cin >> x;
		if(x <= h){
			a++;
		}else if(x <= w) b++;
		else c++;
	}
	cout << min(a,min(c,b)) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
w_list = [input() for _ in range(n)]

flag = True

for i in range(1, n):
    if w_list[i-1][-1] != w_list[i][0]:
        flag = False
    elif w_list[i] in w_list[:i-1]:
        flag = False
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <bitset>

using namespace std;

int main()
{
	int N;
	cin>>N;
	
	vector<vector<int> > cost(N,vector<int>(N,10000001));
	cost[0][0]=0;
	pair<int,int> ddata;
	for(int i=0;i<N;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			cin>>ddata.first>>ddata.second;
			cost[u][ddata.first]=ddata.second;
		}
	}
	//
	
	vector<int> maxcost(N,10000001);
	
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > que;
	
	que.push(pair<int,int>(0,0));
	
	while(!que.empty()){
		int n=que.top().second;
		if(que.top().first<maxcost[n]){
			maxcost[n]=que.top().first;
		}
		for(int j=1;j<N;j++){
			if(que.top().first+cost[n][j]<maxcost[j]){
				maxcost[j]=que.top().first+cost[n][j];
				ddata.first=que.top().first+cost[n][j];
				ddata.second=j;
				que.push(ddata);
			}
		}
		que.pop();
	}
	
	for(int i=0;i<N;i++){
		cout<<i<<' '<<maxcost[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int n;
  cin >> n;
  if((n&1)==0){
    cout << 0.5000000 << endl;
  }
  else{
    printf("%.7lf\n", (double)(n/2+1)/n);
  }
}

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

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

    int ans=0;
    for(int i=0; i<4; i++){
        if( S.at(i)=='+' ){ ans++; }
        else{ ans--; }
    }
    cout << ans << endl;

}



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

int main(){
  int H,W;
  cin >>H>>W;
  bool a[H];
  for(int i=0;i<H;i++) a[i] = false;
  bool b[W];
  for(int j=0;j<W;j++) b[j] = false;
  char G[H][W];
  for(int i=0;i<H;i++){
    cin >> G[i];
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(G[i][j] == '#'){
        a[i] = true;
        b[j] = true;
      }
    }
  }
  for(int i=0;i<H;i++){
    bool x=false;
    for(int j=0;j<W;j++){
      if(a[i] && b[j]){
        cout << G[i][j];
        x=true;
      }
    }
    if(x) cout << endl;
  }
}

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

int main() {
   int  n,w,gmax=0;
   cin>>n>>w;
   vector<int> weights(n,0),values(n,0);

   for(int i=0;i<n;i++)
    cin>>weights[i]>>values[i];

   vector<long long int> dp(100001);

   for(int i=0;i<=n;i++)
   {
       for(int j=100000;j>=0;j--)
       {

           if(j==0)
           {
               dp[j]=0;
               continue;
           }

           if(i==0)
           {
               dp[j]=w+1;
               continue;
           }

           if(values[i-1]<=j)
           {
               dp[j]=min(weights[i-1]+dp[j-values[i-1]],dp[j]);
           }
       }
   }
    
    for(int j=0;j<100001;j++)
       {
           if(dp[j]<=w)
            gmax=max(gmax,j);
       }

   cout<<gmax;

   return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
ll h[N], c, n;
ll dp[N];
double X(int i) { return h[i]; }
double Y(int i) { return dp[i] + h[i]*h[i]; }
double slope(int i, int j) { return (Y(j)-Y(i))/(X(j)-X(i)); }
int q[N], head = 1, tail = 1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> c;
	for(int i=1; i<=n; i++) cin >> h[i];
	dp[1] = 0;
	q[tail++] = 1;
	for(int i=2; i<=n; i++)
	{
		dp[i] = (h[i]-h[1])*(h[i]-h[1])+c;
		while(head<tail && slope(q[head], q[head+1])<2*h[i]) head++;
		int j = q[head];
		dp[i] = min(dp[i], dp[j]+(h[i]-h[j])*(h[i]-h[j])+c);
		while(head<tail && slope(q[tail], i)<slope(q[tail-1],q[tail])) tail--;
		q[++tail] = i; 
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String text = input();

		char[] arrays = text.toCharArray();

		for (int i = 0; i < text.length(); i++) {

			if (Character.isUpperCase(arrays[i])) {

				arrays[i] = Character.toLowerCase(arrays[i]);

			} else {

				arrays[i] = Character.toUpperCase(arrays[i]);

			}
		}
		System.out.println(arrays);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26184
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

bool pairCompareF(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

int main()
{
    ll N;
    cin >> N;
    vector<P> v(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(a,b);
    }
    sort(all(v), pairCompareF);
    print(v.back().first + v.back().second);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    int count = 0;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s == "Y") {
            count++;
            break;
        }
    }
    
    if (count == 0) {
        cout << "Three" << endl;
    } else if (count == 1) {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(a.rbegin(), a.rend());
    ll ans = 0;
    ans += a[0];
    int cnt = 1;
    rep(i, n - 2) {
        ans += a[cnt];
        if (i % 2 != 0) cnt++;
    }
    cout << ans << endl;
    return 0;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int n, k;
    cin >> n >> k;

    vector<int> W(n, 0);

    LL P = 0;
    REP(i, n) {
        cin >> W[i];
        P += W[i];
    }

    LL low = 0, high = P;
    int p;
    int res = P;

    while(true){
        p = (high + low) / 2;

//        cout << "low: " << low << ", high: " << high << ", p: " << p << endl;

        int cnt = 0;
        int s = 0;
        bool flag = true;

        int i = 0;
        while (i < n) {
            if (s + W[i] > p) {
                s = 0;
                if (++cnt == k) {
                    flag = false;
                    break;
                }
                continue;
            }

            s += W[i++];
        }

        if (flag) {
            high = p;
            res = p;
        } else {
            low = p;
        }

        if ((high - low) < 2) break;
    }

    cout << res << endl;

}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long A, long long B){
  cout << max(A-2*B, (ll)0) << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
}


Measured memory_bytes: 256
d = dict()
N = int(input())
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] = d[s] + 1
    else:
        d[s] = 1

M = int(input())
for i in range(M):
    s = input()
    if s in d.keys():
        d[s] = d[s] - 1

print(max(0, max(d.values())))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn=1e5+10;
int n,a,b,c,d;
struct da{int a,b,c;char d;}pre[maxn][5][5][5];
bool dp[maxn][5][5][5];
char s[5],ans[maxn];
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	dp[0][min(a,4)][min(b,4)][min(c,4)]=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		if (s[1]=='A' && s[2]=='B')
		{
			for (int j=0;j<=4;j++)
			 for (int k=0;k<=4;k++)
			  for (int l=0;l<=4;l++)
			  if (dp[i-1][j][k][l])
			  {
			   	if (j>=1) dp[i][j-1][min(k+1,4)][l]=1,pre[i][j-1][min(k+1,4)][l]={j,k,l,'B'};
			   	if (k>=1) dp[i][min(j+1,4)][k-1][l]=1,pre[i][min(j+1,4)][k-1][l]={j,k,l,'A'};
			  }
		}
		if (s[1]=='A' && s[2]=='C')
		{
			for (int j=0;j<=4;j++)
			 for (int k=0;k<=4;k++)
			  for (int l=0;l<=4;l++)
			  if (dp[i-1][j][k][l])
			  {
			   	if (j>=1) dp[i][j-1][k][min(l+1,4)]=1,pre[i][j-1][k][min(l+1,4)]={j,k,l,'C'};
			   	if (l>=1) dp[i][min(j+1,4)][k][l-1]=1,pre[i][min(j+1,4)][k][l-1]={j,k,l,'A'};
			  }
		}
		if (s[1]=='B' && s[2]=='C')
		{
			for (int j=0;j<=4;j++)
			 for (int k=0;k<=4;k++)
			  for (int l=0;l<=4;l++)
			  if (dp[i-1][j][k][l])
			  {
			   	if (k>=1) dp[i][j][k-1][min(l+1,4)]=1,pre[i][j][k-1][min(l+1,4)]={j,k,l,'C'};
			   	if (l>=1) dp[i][j][min(k+1,4)][l-1]=1,pre[i][j][min(k+1,4)][l-1]={j,k,l,'B'};
			  }
		}
	}
	bool ok=0; da now={0,0,0,'A'};
	for (int i=0;i<=4;i++)
	 for (int j=0;j<=4;j++)
	  for (int k=0;k<=4;k++) 
	  if (dp[n][i][j][k]) {ok=1; now={i,j,k,'A'};}
	if (!ok) {printf("No\n"); return 0;}
	printf("Yes\n");
	for (int i=n;i>=1;i--) ans[i]=pre[i][now.a][now.b][now.c].d,now=pre[i][now.a][now.b][now.c];
	for (int i=1;i<=n;i++) printf("%c\n",ans[i]);
return 0;
}

Measured memory_bytes: 211452
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;




vector<vector<int>> A;


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

	if(S.length()<4)
	{
		cout << "No" << endl;

		return 0;
	}

	if (S[0] == 'Y'&&S[1] == 'A'&&S[2] == 'K'&&S[3] == 'I')
	{
		cout << "Yes" << endl;

		return 0;
	}

	cout << "No" << endl;

	return 0;

}



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

using pint = pair<int, int>;
#define x first
#define y second

int n, m, v[100004], w[100004];
vector<pint> g[100004];

bool dfs(int k, int x) {
    if (v[k]) return w[k] == x;
    v[k] = true; w[k] = x;
    bool ret = true;
    for (pint i : g[k]) ret &= dfs(i.x, x + i.y);
    return ret;
}

int main() {
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int x, y, k;
        cin >> x >> y >> k;
        g[x].emplace_back(y, k);
        g[y].emplace_back(x, -k);
    }

    bool ans = true;
    for (int i=1; i<=n; i++) if (!v[i]) ans &= dfs(i, 0);

    cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

bool dfs(int pos, int start, const vector<vector<int>> &graph, vector<bool> &visited) {
    if(visited[pos]) return false;

    visited[pos] = true;
    for(int v : graph[pos]) {
        if(v == start) return true;
        if(dfs(v, start, graph, visited)) return true;
    }
    return false;
}

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    vector<string> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    vector<vector<int>> graph(26);
    for(int i = 0; i < N-1; ++i) {
        const string &s1 = v[i];
        const string &s2 = v[i+1];
        if(s1.size() > s2.size() && s1.substr(0, s2.size()) == s2) {
            cout << "no" << endl;
            return true;
        }
        for(int j = 0; j < s1.size() && j < s2.size(); ++j) {
            if(s1[j] != s2[j]) {
                graph[s1[j]-'a'].push_back(s2[j]-'a');
                break;
            }
        }
    }
    for(int i = 0; i < 26; ++i) {
        vector<bool> visited(26, false);
        if(dfs(i, i, graph, visited)) {
            cout << "no" << endl;
            return true;
        }
    }
    cout << "yes" << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};

int main()
{
  ll N, M, A, B, C, D;
  string s, t;
  cin >> A >> B;
  vector<bool> data(4, false);
  data[A] = true;
  data[B] = true;
  for (int i = 1; i <= 3;i++){
    if(!data[i])
      cout << i << endl;
  }
}

Measured memory_bytes: 256
/**
 *    author:  Taichicchi
 *    created: 21.09.2020 22:45:50
 **/

#include <bits/stdc++.h>

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

    if ((a < c) & (b > c)) {
        cout << "Yes" << endl;
    } else if ((a > c) & (b < c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long LL;
const int maxn = 100000 + 5;
int mon[maxn];
LL n, a, b;

bool check(LL m)
{
    LL cnt1 = m * b, cnt2 = a - b;
    vector<LL> q;
    for(int i = 0; i < n; i++)
        if(mon[i] > cnt1)
            q.push_back(mon[i] - cnt1);

    LL cnt = 0;
    for(int i = 0; i < q.size(); i++)
    {
        if(q[i] % cnt2 != 0)
            cnt += q[i] / cnt2 + 1;
        else if(q[i] % cnt2 == 0)
            cnt += q[i] / cnt2;
    }
    if(cnt <= m)
        return true;
    return false;
}

int main()
{
    while(~scanf("%lld%lld%lld", &n, &a, &b))
    {
        for(LL i = 0; i < n; i++)
            scanf("%lld", &mon[i]);

        LL r = 1000000000 + 5, l = 1;

        while(l < r)
        {
            LL mid = l + (r - l) / 2;
            if(check(mid))
                r = mid;
            else
                l = mid + 1;
        }

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


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

if(n < 10):
    print(n)
elif(n < 100):
    print(9)
elif(n < 1000):
    print(9 + n - 100 + 1)
elif(n < 10000):
    print(909)
elif(n < 100000):
    print(909 + n - 10000 + 1)
else:
    print(9 + 900 + 90000)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> map = new HashMap<String, Integer>();
		int N = Integer.parseInt(sc.next());
		String s[] = new String[N];
		for(int i = 0; i < N; i++) {
			s[i] = sc.next();
			if(map.containsKey(s[i])) {
				map.put(s[i], map.get(s[i]) + 1);
			} else {
				map.put(s[i], 1);
			}
		}
		int M = Integer.parseInt(sc.next());
		String t[] = new String[M];
		for(int i = 0; i < M; i++) {
			t[i] = sc.next();
			if(map.containsKey(t[i])) {
				map.put(t[i], map.get(t[i]) - 1);
			} else {
				map.put(t[i], -1);
			}
		}
		
		int ans = 0;
		for(String key : map.keySet()) {
			ans = Math.max(ans, map.get(key));
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main(void)
{
    int N;
    int sub[200000] = {0};

    cin >> N;
    for(int i = 2; i <= N; i++){
        int a;
        cin >> a;
        sub[a-1]++;
    }
    for(int i = 0; i < N; i++){
        cout << sub[i] << endl;
    }
        return 0;
}


Measured memory_bytes: 4324
S = input()
#keyence
if S[0] == "k" and S[-6] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[-7] == "k" and S[-6] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[5] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[5] == "c" and S[6] == "e":
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, M; cin >> N >> M;
  vector<LL> A(N); cin >> A;
  vector<LL> S(N + 1); S[0] = 0;
  for (int i = 0; i < N; ++i) S[i + 1] = S[i] + A[i];

  map<LL, LL> m;
  for (int i = 1; i <= N; ++i) {
    m[S[i]%M]++;
  }

  LL key = 0;
  LL cnt = 0;
  for (int i = 1; i <= N; ++i) {
    cnt += m[key];
    key = S[i] % M;
    m[key]--;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 8640
#include<stdio.h>
#define MAX 100000

int a[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      t=a[i];
      a[i]=a[j];
      a[j]=t;
    }
  }
  t=a[i+1];
  a[i+1]=a[r];
  a[r]=t;
  return i+1;
}

int main(){
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    if(i==q)printf("[");
    printf("%d",a[i]);
    if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}



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

using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;
  for(int i = 0; i < n; i++) { cin >> R[i]; }
  int maxv = -2000000000;
  int minv = R[0];

  for (int i=1; i<n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 3872
num = [int(i) for i in input().split()]
res = 0
a = num[0]
b = num[1]
c = num[2]
k = num[3]

if a < k:
    res = a
    k -= a
elif a >= k:
    res = k
    print(res)
    exit()

if b < k:
    k -= b
elif b >= k:
    print(res)
    exit()

if c <= k:
    res -= c
elif k > 0:
    res -= k
print(res)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)))
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
const string M="Male",F="Female",N="Vacant";
int n;
map<int,int> mp;
/*---main code---*/ 

int get(int x)
{
	if(mp.find(x)!=mp.end())
	{
		return mp[x];
	}
	printf("%d\n",x);
	fflush(stdout);
	string s;
	cin>>s;
	if(s==N)
	{
		exit(0);
	}
	mp[x]=(s==M);
	return mp[x];
}

int main()
{
	FIO;
	cin>>n;
	get(0),get(n-1);
	int L=1,R=n-2;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		if(((mid%2)^(get(mid)==mp[0])))
		{
			L=mid+1;
		}
		else
		{
			R=mid-1;
		}
	}
	return 0;
}


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

class Proc{
    public:
    string nam;
    int tim;
    Proc(){
        nam = "";
        tim = 0;
    }
};

Proc Q[100001];

class Queue{
    private:
    int fp;
    int rp;
    
    public:
    Queue(){
        fp = 0;
        rp = 0;
    }
    int next(int p)const{
        return (p+1)%100001;
    }
    bool isFull()const{
        return (next(rp)==fp);
    }
    bool isEmpty()const{
        return (rp==fp);
    }
    void push(Proc p);
    Proc front();
    void pop();
};

void Queue::push(Proc p){
    if(isFull()){
        return;
    }

    Q[rp] = p;
    rp = next(rp);

}

Proc Queue::front(){
    if(isEmpty()){
        Proc e;
        e.tim = -1;
        return e;
    }

    return Q[fp];
}

void Queue::pop(){
    if(isEmpty()){
        return;
    }
    fp = next(fp);
}

int main(){
    Queue que;
    int n,t;
    cin >> n >> t;

    for(int i=0;i<n;i++){
        Proc x;
        cin >> x.nam >> x.tim;
        que.push(x);
    }

    int total = 0;

    while(!que.isEmpty()){
        Proc z = que.front();
        que.pop();

        if(z.tim<=t){
            total += z.tim;
            cout << z.nam << " " << total << endl;
        }else{
            total += t;
            z.tim -= t;
            que.push(z);
        }
    }

    return 0;
}


Measured memory_bytes: 6924
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'x') cnt++;
    }

    if (cnt <= 7) puts("YES\n");
    else puts("NO\n");
    return 0;
}

Measured memory_bytes: 256
num = int(input())

array = []
for i in range(num):
    array.append(int(input()))

res = -1
if 2 in array:
    judge = array[0]
    roop = 1
    while judge != 2 and roop != 100001:
        roop += 1
        judge = array[judge-1]
        if judge == 2:
            break
else:
    judge = 10000000

if judge == 2:
    res = roop

print(res)

Measured memory_bytes: 7208
#include<stdio.h>
int main(void)
{
	long long a,b,c,d,e,f,g;
	scanf("%lld %lld %lld",&a,&b,&c);
	if(a<0) a=-a;
	d=a/c;
	e=a%c;
	if(d<=b){
		f=d-b;
		if(f%2==0){
			printf("%lld\n",e);
		}
		else {
			printf("%lld\n",c-e);
		}
	}
	else {
		printf("%lld\n",a-(b*c));
	}
	return 0;
}


Measured memory_bytes: 1708
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a>b)
    {
        int term;
        term=a;
        a=b;
        b=term;
    }
    if((b-a)>=1)
        cout << 2*b-1 << endl;
    else
        cout << 2*b << endl;
    return 0;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        # tmp = (a ** 3) / (2 * ((a **2) * b - x)) これだと 0divになる
        tmp = (2/a)*(b-(x/a**2))
    else:
        tmp = (a * b * b) / (2 * x)
    return math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print('{:.10f}'.format(ans))






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

namespace AtCoder.Abc
{
    class A_162_Lucky7
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            long N = long.Parse(Console.ReadLine());
            string result = "";
            if (N.ToString().Contains("7"))
            {
                result = "Yes";
            }
            else
            {
                result = "No";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27476
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
#define s second
#define f first
const int MOD = 1e9+7;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

bool is_prime(int x){
	for (int i = 2; i*i <= x; i++){
		if (!(x%i)) return false;
	}
	return true;
}

ll gcd(ll x, ll y){
	if (y > x){
		ll temp = x;
		x = y;
		y = temp;
	}
	if (x%y) return gcd(y, x%y);
	return y; 
}


int main(){
	ll a, b;
	cin >> a >> b;
	cout << a*b/gcd(a, b) << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N,M,K;
	cin>>N>>M>>K;
	rep(i,0,N+1){
		rep(j,0,M+1){
			if(i*M+j*N-2*i*j==K){
				cout<<"Yes\n";
				return;
			}
		}
	}
	cout<<"No";
}

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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> mean(n);
  rep(i,n)  {
    double p; cin >> p;
    double m = (p+1) / 2;
    mean[i] = m;
  }
  double ans = 0;
  rep(i,k) ans += mean[i];
  double  r = ans;
  //rep(i,n) cout << mean[i] << ' ' ;
  for (int i = k; i < n; i++)
  {
    double now = r - mean[i-k] + mean[i];
    r = now;
    ans = max(ans, now);
  }
  
  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//文字から数値に変換
int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

//文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key %M;
}

int h2(int key) {
    return 1 + (key % (M -1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;;i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        }
        else if (strlen(H[h]) == 0) {
            return 0;
        }
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 17460