akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string a[3];
	rep(i,3) cin>>a[i];
	int t = 0;
	while(1){
		if(a[t].size()==0){
			cout<<char('A'+t)<<endl;
			return;
		}
		int nt = a[t][0]-'a';
		a[t] = a[t].substr(1);
		t = nt;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	int k,a,b;
	cin >> k >> a >> b;
	int flag = 0;
	for(int i = a; i <= b; i++){
		if(i%k == 0) flag = 1;
	}
	if(flag) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3512
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

count = 0

for i in b:
    x = bisect.bisect_left(a, i)
    y = bisect.bisect_right(c, i)
    count += x * (len(c) - y)

print(count)


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

using namespace std;
int main()
{
   int a,b;
   cin>>a>>b;
   string s1=string(b,'0'+a);
   string s2=string(a,'0'+b);
    if(s1.size()!=s2.size())
    {
        if(s1.size()>s2.size()) cout<<s1;
        else cout<<s2;
    }
    else{
        if(s1>s2) cout<<s1;
        else cout<<s2;
    }
}


Measured memory_bytes: 3608
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<complex>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
const ll INF=9223372036854775807;
const ll mod=998244353;

ll  MOD(ll  a,ll  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b,ll c)
{
    return max(c,max(a,b));
}
ll min3(ll a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);//%mod;
        y = y>>1;
        x = (x*x);//%mod;
    }
    return res;//%mod;
}
ll  power1(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res%mod;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x)
{
    return power1(x,mod-2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    vll h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vll dp(n,INF);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if((i-j)>=0)
            {
                dp[i]=min(dp[i-j]+abso(h[i-j]-h[i]),dp[i]);
            }
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
if __name__ == '__main__':
	a, b = input().split()
	a, b = int(a), int(b)
	if a < b:
		x = b
		y = a
	else:
		x = a
		y = b
	while True:
		x, y= y, x % y
		if y == 0:
			print(x)
			break
		else:
			continue


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  int n, m = 100000;
  cin >> n;
  REP(i, n) m = ceil(m * 1.05 / 1000) * 1000;
  cout << m << endl;
}

Measured memory_bytes: 3004
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            var days = new string[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            var ans = 7 - Array.IndexOf(days, S);
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}


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

int main(){
    string s;
    cin >> s;
    if(s.size()>=8){
        if(s.substr(s.size()-8)=="FESTIVAL")s=s.substr(0,s.size()-8);
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
     
   int n;
   cin>>n;
   string str;
   cin>>str;
   int cmax=0;
   
   for(int i=1;i<str.length();i++)
   {
      string s1,s2;
      s1=str.substr(0,i);
      s2=str.substr(i,str.length()-i);
      set<char> s3,s4;
      for(int j=0;j<s1.size();j++)
      {
        s3.insert(s1[j]);
      }
      for(int j=0;j<s2.size();j++)
      {
        s4.insert(s2[j]);
      }
      int c=0;
      for(auto x: s3)
      {
        auto p=s4.find(x);
        if(p!=s4.end())
            c++;
      }
      cmax=max(cmax,c);
   }
   cout<<cmax;




 return 0;
}








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

bool isFieldMini(int ti,int tj,int w,int h,int f[5][5]){
	for(int i=ti;i<ti+h;i++)for(int j=tj;j<tj+w;j++)if(f[i][j] == 0)return false;
	return true;
}

bool isField(int w,int h,int f[5][5]){
	for(int i=0;i<=5-h;i++)for(int j=0;j<=5-w;j++)if(isFieldMini(i,j,w,h,f))return true;
	return false;
}

int main(void){
	int i,j,n,h,w,f[5][5],max;

	cin>>n;
	while(n--){
		max=0;
		for(i=0;i<5;i++)for(j=0;j<5;j++)cin>>f[i][j];
		for(h=1;h<=5;h++)for(w=1;w<=5;w++)if(isField(w,h,f)&&max<w*h)max=w*h;
		cout<<max<<endl;
	}
	return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll>> v(n+1);
  for (ll i=1;i<=n;i++)
    cin>>v[i].first>>v[i].second;
  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));
  for (ll i=1;i<=n;i++)
  {
    for (ll w=0;w<=W;w++)
    {
      if (w>=v[i].first)
        dp[i][w]=max(dp[i-1][w],dp[i-1][w-v[i].first]+v[i].second);
      else 
        dp[i][w]=dp[i-1][w];
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}      

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

int main(){ 
    int n;
    cin>>n;
    int a=0;
    int b=0;
    for(int i=1;i<32;i++){
        a=i;
        for(int j=0;j<10;j++){
          a=a*i;
          if(a<=n){
              b=max(b,a);
          }
    }
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let ans = n + n * n + n * n * n;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2172
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(x: i64);
    let mut v: i64 = 100;
    let mut t = 0;
    while v < x {
        v += v / 100;
        t += 1;
    }
    puts!("{}\n", t);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2248
from collections import deque
N = int(input())
G = [[] for _ in range(N + 1)]
dist = [-1 for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
zero = []
one = []
two = []
for i in range(1, N + 1):
    if i % 3 == 1:
        one.append(i)
    elif i % 3 == 2:
        two.append(i)
    else:
        zero.append(i)
q = deque([1])
dist[1] = 0

while q.__len__() != 0:
    s = q.popleft()
    for i in G[s]:
        if dist[i] == -1:
            q.append(i)
            dist[i] = (dist[s] + 1) % 2

red = 0
blue = 0

for i in range(1, N + 1):
    if dist[i] == 0:
        red += 1
    else:
        blue += 1
ans = []
if red > N / 3 and blue > N / 3:
    for i in range(1, N + 1):
        if dist[i] == 0 and one.__len__() != 0:
            ans.append(one.pop())
        elif dist[i] == 1 and two.__len__() != 0:
            ans.append(two.pop())
        else:
            ans.append(zero.pop())
elif red <= N / 3:
    for i in range(1, N + 1):
        if dist[i] == 0:
            ans.append(zero.pop())
        else:
            if one.__len__() != 0:
                ans.append(one.pop())
            elif two.__len__() != 0:
                ans.append(two.pop())
            else:
                ans.append(zero.pop())

else:
    for i in range(1, N + 1):
        if dist[i] == 1:
            ans.append(zero.pop())
        else:
            if one.__len__() != 0:
                ans.append(one.pop())
            elif two.__len__() != 0:
                ans.append(two.pop())
            else:
                ans.append(zero.pop())

print(*ans)


Measured memory_bytes: 109388
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] lst = line.split(" ");
        int n = Integer.parseInt(lst[0]);
        int l = Integer.parseInt(lst[1]);

        List<String> strArr = new ArrayList<>();
        for(int i = 0; i < n; i++){
            line = br.readLine();
            strArr.add(line);
        }

        Collections.sort(strArr);
        for(int i = 0; i < strArr.size(); i++){
            System.out.print(strArr.get(i));
        }
        System.out.println();


    }
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int a[26];

int main(){
    string s;cin >> s;
    REP(i,s.size()){
        int num = s[i]-'a';
        a[num]++;
    }
    if(s.size()!=26){
        cout << s;
        REP(i,26){
            if(a[i]==0){
                COUT((char)('a'+i));
                break;
            }
        }
    }
    else{
        string past = s;
        do{
            if(s>past){
                for(int i=0;i<26;i++){
                    if(s[i]==past[i])cout << s[i];
                    else{
                        COUT(s[i]);
                        return 0;
                    }
                }
            }
        }while(next_permutation(s.begin(),s.end()));
        COUT(-1);
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(q)]
def keisan(tup):
    ans_keisan = 0
    for j in A:
        if tup[j[1]-1] - tup[j[0]-1] == j[2]:
            ans_keisan += j[3]
    return ans_keisan
ans = 0
for i in combinations_with_replacement(range(m),n):
    ans = max(keisan(i), ans)
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
int main()
{
    fio;
   int n,x,k;
   cin>>n>>x>>k;
   int p =0 ;
   if(n%x==0)
    p = n/x;
   else
    p = n/x + 1;
   cout<<k*p<<endl;
    return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>
#define MN 200000
const int mod=998244353;

int n,q;

int m10[MN+5];

struct node{
	int sum,tag,bsc;
}T[MN*4+5];

void build(int k,int l,int r){
	T[k].tag = 0;
	if(l==r){
		T[k].sum = 1;
		T[k].bsc = T[k].sum;
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	T[k].sum = (1ll*T[k<<1].sum*m10[r-mid]+T[k<<1|1].sum)%mod;
	T[k].bsc = T[k].sum;
}

void pushtag(int k,int w){
	T[k].sum = (1ll*T[k].bsc*w)%mod;
	T[k].tag = w;
}

void pushdown(int k){
	if(T[k].tag){
		pushtag(k<<1,T[k].tag);
		pushtag(k<<1|1,T[k].tag);
		T[k].tag = 0;
	}
}

void modify(int k,int l,int r,int L,int R,int w){
	if(l==L&&r==R){
		pushtag(k,w);
		return;
	}
	int mid=(l+r)>>1;
	pushdown(k);
	if(R<=mid) modify(k<<1,l,mid,L,R,w);
	else if(L>mid) modify(k<<1|1,mid+1,r,L,R,w);
	else modify(k<<1,l,mid,L,mid,w),modify(k<<1|1,mid+1,r,mid+1,R,w);
	T[k].sum = (1ll*T[k<<1].sum*m10[r-mid]+T[k<<1|1].sum)%mod;
}

int main(){
	scanf("%d%d",&n,&q);
	m10[0] = 1;
	for(int i=1;i<=n;i++)
		m10[i] = (10ll*m10[i-1])%mod;
	build(1,1,n);
	for(int l,r,d;q--;){
		scanf("%d%d%d",&l,&r,&d);
		modify(1,1,n,l,r,d);
		printf("%d\n",T[1].sum);
	}
}

Measured memory_bytes: 10148
#include <iostream>
#include <cstdlib>  // abs() for integer
typedef long long int ll;
 
int main()
{
    ll A, V, B, W, T;
    std::cin >> A >> V;
    std::cin >> B >> W;
    std::cin >> T;

    if (abs(A - B) <= T * (V - W)) {
        std::cout << "YES";
    } else {
        std::cout << "NO";
    }
}

Measured memory_bytes: 3124
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int min = int.MaxValue;
        for (int i = 0; i <= s.Length - 3; i++)
        {
            min = Min(min, Abs(753 - int.Parse(s.Substring(i, 3))));
        }
        Console.WriteLine(min);
    }
}


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

int main()
{
    int N;
    cin>>N;
    vector<int> L(N);
    for (int &l: L)
        cin>>l;

    sort(L.begin(), L.end());
    int ans = 0;
    for (int i=0; i<N; i++)
    {
        int j = i+1;
        for (int k=i+2; k<N; k++)
        {
            while (j<k && L[i]+L[j]<=L[k])
                j++;
            ans += k-j;
        }
    }
    cout<<ans<<endl;
}


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

int n;
vector<int> v;

bool check(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++){
		if (v[i] != i + 1) return false;
	}
	return true;
}

void solve()
{
	int cnt = 0;
	while (true){
		if (check(v)){
			printf("%d\n", cnt);
			return;
		}
		else if (cnt > 10000){
			printf("-1\n");
			return;
		}
		
		int tmp = v.size();
		for (int i = 0; i < v.size(); i++){
			v[i]--;
			if (v[i] == 0){
				i = v.erase(v.begin() + i) - v.begin();
				--i;
			}
		}
		v.push_back(tmp);
		
		cnt++;
	}
}

int main()
{
	while (scanf("%d", &n), n){
		v.resize(n);
		for (int i = 0; i < n; i++){
			scanf("%d", &v[i]);
		}
		solve();
	}
}

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

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

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

int n;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn], c[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    long long ans = 0;
    priority_queue<pi> pq;
    for(int i = 0;i < n;i++){
        pq.push({b[i], i});
    }
    while(!pq.empty()){
        pi p = pq.top(); pq.pop();
        int id = p.se;
        int val = p.fi;
        int pre = (id + n - 1) % n;
        int nxt = (id + 1) % n;
        if(b[id] > b[pre] and b[id] > b[nxt] and b[id] - b[pre] - b[nxt] >= a[id]){
            int delta = b[id] - a[id];
            int t = delta / (b[pre] + b[nxt]);
            delta = t * (b[pre] + b[nxt]);
            b[id] -= delta;
            ans += t;
            pq.push({b[id], id});
        }
    }
    bool ok = true;
    for(int i = 0;i < n;i++){
        if(b[i] != a[i]){
            ok = false;
        }
    }
    if(ok){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 998244353;
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}

template<class T, class F = plus<T>>
struct Fenwick {
  i64 n;
  vector<T> c;
  F f;
  Fenwick(i64 n, F f = plus<T>(), T init = T())
    : n(n), c(n + 1, init), f(f) {}
  T sum(i64 i) {
    return i > 0 ? f(sum(i - (i & -i)), c[i]) : T();
  }
  void add(i64 i, i64 x) {
    if (i <= n) {
      c[i] = f(c[i], x);
      add(i + (i & -i), x);
    }
  }
};

template<class T, class F>
Fenwick<T, F> make_fenwick(i64 n, F f, T init = T()) {
  return Fenwick<T, F>(n, f, init);
}
i64 n;
using P = pair<i64, i64>;
vector<P> ps;
int main() {
  cin >> n;
  init_n(ps, n);
  for (i64 i = 0; i < n; ++i) cin >> ps[i].first >> ps[i].second;
  sort(begin(ps), end(ps), [](P p, P q) { return p.second < q.second; });
  for (i64 i = 0; i < n; ++i) ps[i].second = i + 1;
  sort(begin(ps), end(ps));
  for (i64 i = 0; i < n; ++i) ps[i].first = i + 1;

  vector<i64> xs(n + 1), ys(n + 1);
  for (auto p : ps) {
    i64 x, y;
    tie(x, y) = p;
    xs[y] = x;
    ys[x] = y;
  }

  // cxy
  vector<i64> c00(n + 1), c01(n + 1), c10(n + 1), c11(n + 1);

  Fenwick<i64> fen_l(n), fen_r(n);
  for (i64 i = 1; i <= n; ++i) {
    c00[i] += fen_l.sum(ys[i]);
    c01[i] += i - 1 - c00[i];
    fen_l.add(ys[i], 1);
  }
  for (i64 i = n; i > 0; --i) {
    c10[i] += fen_r.sum(ys[i]);
    c11[i] += n - i - c10[i];
    fen_r.add(ys[i], 1);
  }
  
  i64 ans = 0;
  for (i64 i = 1; i <= n; ++i) {
    i64 p00 = ipow(2, c00[i]),
        p01 = ipow(2, c01[i]),
        p10 = ipow(2, c10[i]),
        p11 = ipow(2, c11[i]);
    i64 s = 10 * mod + ipow(2, n) - 1;
    s -= p00 * p01 % mod;
    s -= p00 * p10 % mod;
    s -= p11 * p01 % mod;
    s -= p11 * p10 % mod;
    s += p00 + p01 + p10 + p11;
    ans = (ans + s) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <sstream>
#include <string>

using namespace std;

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

string tostr(int n) {
	stringstream ss;
	ss << n;
	return ss.str();
}

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

	for (int i = 0;; i++) {
		auto s = tostr(i);
		bool ok = false;
		if (s.size() < a.size()) {
			rep(j, n - s.size() + 1) {
				bool t = true;
				rep(k, s.size()) {
					if (s[k] - '0' != a[j + k]) {
						t = false; break;
					}
				}
				if (t)ok = true;
			}
		}
		if (ok == false) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3220
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll ans=0;
ll n;
string s;
ll cnt=0;
P p[1000001];
ll sz;
int main()
{
	cin>>s;
	sz=0;
	n=s.length();
	rep(i,n){
		if(i==0){
			if(s[0]=='J') p[sz]=P(1,0);
			else if(s[0]=='O') p[sz]=P(1,1);
			else p[sz]=P(1,2);
			sz++;
		}
		else{
			if(s[i]!=s[i-1]){
				if(s[i]=='J') p[sz]=P(1,0);
				else if(s[i]=='O') p[sz]=P(1,1);
				else p[sz]=P(1,2);
				sz++;
			}
			else{
				p[sz-1].fr++;
			}
		}
	}
	rep(i,sz-2){
		if(p[i].sc==0&&p[i+1].sc==1&&p[i+2].sc==2&&p[i].fr>=p[i+1].fr&&p[i+1].fr<=p[i+2].fr){
			ans = max(ans , p[i+1].fr );
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
    int m,d,f=0;
    cin>>m>>d;
    for(int j =1;j<=m;j++)
    {
        for(int i = 11;i<=d;i++)
        {
            int k10 = i%10;
            int k1 = i/10;
            if(k1>=2&&k10>=2)
            {
                
            
                if( k1*k10 == j)
                {
                    f++;
                }
            }
        }
    }
    
    cout<<f;
    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e2+50;
const int mod=1e9+7;
using namespace std;
int n,i1,i2,i;
char s[nmax],t[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>s[i];
	for(i=1;i<=n;i++)cin>>t[i];
	for(i=1;i<=2*n;i++)
	{
		if(i&1)cout<<s[++i1];
		else cout<<t[++i2];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int h,w,d[50][50];
string field[50];

signed main(){
	int cnt = 0;
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) d[i][j] = -1;
	}
	d[0][0] = 0;
	for(int i = 0;i < h;i++){
		cin >> field[i];
		for(int j = 0;j < w;j++) if(field[i][j] == '.') cnt++;
	}
	queue<P> que;
	que.push(P(0,0));
	for(int t = 0;;t++){
		int siz = que.size();
		if(!siz) break;
		for(int i = 0;i < siz;i++){
			P p = que.front();que.pop();
			for(int j = 0;j < 4;j++){
				int nx = p.first + dx[j],ny = p.second + dy[j];
				if(in(nx,ny,h,w) && d[nx][ny] == -1 && field[nx][ny] == '.'){
					d[nx][ny] = t + 1;
					que.push(P(nx,ny));
				}
			}
		}
	}
	if(d[h - 1][w - 1] == -1) cout << -1 << endl;
	else cout << cnt - d[h - 1][w - 1] - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int h,w,n;
	cin>>h>>w>>n;
	int ans=h;
	vc<pi> all;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		all.emplace_back(y,x);
	}
	sort(all.begin(),all.end());
	int cnt=0;
	for(auto u:all)
	{
		int x=u.second,y=u.first;
		if(x>y+cnt)
			ans=min(ans,x-1);
		if(x==y+cnt) cnt++;
	}
	print(ans);
}


Measured memory_bytes: 5328
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")
#define ret return 0

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

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)
		cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	
	ret;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int f[10004]={0};
int main()
{
    int n;
    cin>>n;
    for(int x=1;x<100;x++)
    {
        for(int y=1;y<100;y++)
        {
            for(int z=1;z<100;z++)
            {
                if(x*x+y*y+z*z+x*y+x*z+y*z<=10000)
                    f[x*x+y*y+z*z+x*y+x*z+y*z]++;
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        cout<<f[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut b = vec![];
    for x in a {
        b.push(x);
        b.push(x);
    }
    b.sort();
    let mut ans = 0;
    for i in n..n * 2 - 1 {
        ans += b[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 8964
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int a; cin>>a;
  string s; cin>>s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  vector<string> S(3);
  rep(i, 3) cin >> S[i];
  if (S[0][S[0].size() - 1] == S[1][0]) {
    if (S[1][S[1].size() - 1] == S[2][0]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

vector<int> T, V;
double G[20009];

class section{
    public:
        int begin;
        int end;
        int velocity;
        
        section(){}
        section(int begin, int end) : begin(begin), end(end){}
};

int main() {
    int N;
    cin >> N;
    
    vector<section> ss(N);
    int sum_t = 0;
    rep(i,N){
        int x;
        cin >> x;
        x *= 2;
        
        ss[i].begin = sum_t;
        ss[i].end = sum_t + x;
        sum_t += x;
    }
    
    rep(i,N){
        int x;
        cin >> x;
        ss[i].velocity = x*2;
    }
    
    vector<int> a(sum_t+1,INF);
    a[0] = 0;
    a[sum_t] = 0;
    
    for(const section& s:ss){
        for(int i=s.begin; i<=s.end; i++){
            a[i] = min( a[i], s.velocity );
        }
    }
    
    for(int i=sum_t-1; i>=0; i--){
        a[i] = min( a[i+1]+1, a[i]);
    }
    
    int speed = 0;
    int distance = 0;
    rep(i,sum_t){
        if( speed < a[i+1] ){
            speed++;
            distance += speed+1;
        }else if( speed > a[i+1] ) {
            speed--;
            distance += speed-1;
        }else{
            distance += speed;
        }
    }
    
    cout << std::fixed << std::setprecision(9) << (1.0 * distance / 4) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			long[] a = new long[n];
			long max = 0;
			long ret = 0;
			
			for(int i=0;i<n;i++) {
				a[i] = sc.nextLong();
				max = Math.max(max, a[i]);
				if(max>a[i]) {
					ret += (max-a[i]);
				}
			}
			System.out.println(ret);
			
			
	    }
				
	}
	


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

int main() 
{
		float d,t,s;
		cin>>d>>t>>s;
		if(d/s>t)
		cout<<"No"<<endl;
		else
		cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>min(a,b) && c<max(a,b))
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
   return 0;

}


Measured memory_bytes: 3592
#include <stdio.h>
#define RANGE 10010

int C[RANGE] = {0};

int main()
{
    int i, j;
    int N;
    int a;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &a);
        C[a]++;
    }
    
    int last = 0;
    for (i=0; i<RANGE; i++) {
        if (C[i] != 0) {
            last = i;
        }
    }
    
    for (i=0; i<last; i++) {
        for (j=0; j<C[i]; j++) {
            printf("%d ", i);            
        }
    }
    for (i=0; i<C[last]-1; i++) {
        printf("%d ", last);
    }
    printf("%d\n", last);
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<double> X(n);
    vector<double> Y(n);
    
    rep(i,n) cin >> X[i];
    rep(i,n) cin >> Y[i];
    
    double a1,a2,a3,a4;
    a1 = 0;
    a2 = 0;
    a3 = 0;
    a4 = 0;
    
    rep(i,n){
        a1 += abs(X[i]-Y[i]);
    }
    
    rep(i,n){
        a2 += pow(X[i]-Y[i],2);
    }
    
    a2 = sqrt(a2);
    
    rep(i,n){
        a3 += pow(abs(X[i]-Y[i]),3);
    }
    
    a3 = cbrt(a3);
    
    rep(i,n){
        a4 = max(a4,abs(X[i]-Y[i]));
    }
    
    cout << fixed << setprecision(10) << a1 << endl;
    cout << fixed << setprecision(10) << a2 << endl;
    cout << fixed << setprecision(10) << a3 << endl;
    cout << fixed << setprecision(10) << a4 << endl;
}



Measured memory_bytes: 3480
#include <bits/stdc++.h>
#include <unordered_map>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=b; i++)
using namespace std;

typedef long long int ll;

int main() {
    int n,k,a;
    cin >> n >> k;
    priority_queue<int, vector<int>, greater<int>> x;
    REP(i,0,n-1){
        cin >> a;
        x.push(a);
    }
    int ans=0;
    while(k--){
        ans+=(x.top());
        x.pop();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

bool ok(vector<string>& m, int st, int at){
	int use[11]={0};
	use[st-1]=1;
	
	rep(i,m.size()){
		rep(j,m[i].size()){
			if(m[i][j]=='1')swap(use[j],use[j+1]);
		}
	}
	if(use[at-1]==1)return true;
	return false;
}

int main(){
	int n,m,p,d;
	while(cin>>n,n){
		cin>>m>>p>>d;
		
		vector<string> board(d);
		rep(i,d){
			cin>>board[i];
		}
		
		if(ok(board, m, p))puts("0");
		else{
			rep(i,d){
				rep(j,board[i].size()){
					if(board[i][j]=='0' && (j==0 || board[i][j-1]=='0') && (j==board[i].size()-1 || board[i][j+1]=='0')){
						board[i][j]='1';
						if(ok(board, m, p)){
							printf("%d %d\n",i+1,j+1);
							goto A;
						}
						board[i][j]='0';
					}
				}
			}
			puts("1");
		}
		A:;
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll k = 0, m, nn = n, d = 0;
  while(nn > 0) {
    k++;
    m = nn;
    d += nn % 10;
    nn /= 10;
  }
  cout << max(d, m - 1 + 9 * (k - 1)) << endl;
}

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

int n;
int a[2005];
bitset <3000000> memo;
int sum;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), sum += a[i];
	memo[0] = 1;
	for (int i = 0; i < n; i++) memo |= memo << a[i];
	for (int i = (sum + 1) / 2; i <= sum; i++) if (memo[i]) {
		printf("%d\n", i); break;
	}
	return 0;
}


Measured memory_bytes: 4932
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
static const int INF = 1e9 + 7;
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    int n, x, y;
    cin >> n;
    x = n * 800;
    y = (n/15) * 200;
    cout << x - y << endl;
}


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

int main(){
	int d = 100000, n;
	cin >> n;
	for(int i = 0; i < n; i++){
		d *= 1.05;
		if(d % 1000){
			d /= 1000;
			d *= 1000;
			d += 1000;
		}
	}
	cout << d << endl;
    return 0;
}


Measured memory_bytes: 3000
N, K = map(int, input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
have_sweet = set(sum(A, []))
all_member = set([i for i in range(1, N+1)])
print(len(have_sweet ^ all_member))

Measured memory_bytes: 9252
// Rooted Trees
#include <stdio.h>
#define MAX 100000 // 接点の個数の上限
#define NIL -1     // 接点番号として使われない値を設定(とりあえず-1としておく)

struct node{
  int parent; // 各接点の親を参照
  int left;   // 左の子を参照
  int right;  // 右の兄弟を参照
};
struct node T[MAX];

int getDepth(int);
int printNodeType(int);
void printChildren(int);

int main(){
  int i, j, id, k, child, c, n;

  scanf("%d", &n);

  for(i=0; i < n; i++){
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  
  for(i=0; i < n; i++){
    scanf("%d%d", &id, &k);
    for(j=0; j < k; j++){
      scanf("%d", &child);
      if(j == 0)T[id].left = child;
      else T[c].right = child;
      c = child;
      T[child].parent = id;
    }
  }

  for(i=0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, getDepth(i));
    printNodeType(i);
    printChildren(i);
  }

  return 0;
}

int getDepth(int u){
  int d=0;
  while(T[u].parent != NIL){
    u = T[u].parent;
    d++;
  }
  return d;
}

int printNodeType(int u){
  if(T[u].parent == NIL)printf("root, ");
  else if(T[u].left == NIL)printf("leaf, ");
  else printf("internal node, ");
}

void printChildren(int u){
  int i, c;
  c = T[u].left;
  printf("[");
  for(i=0; c != NIL; i++){
    if(i != 0)printf(", ");
    printf("%d", c);
    c = T[c].right;
  }
  printf("]\n");
}



Measured memory_bytes: 2964