akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[200005], y[500005], z[200005];
bool used[500005];
char s[500005];
ll query;

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

    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> y[i];
        x[i] = i + 1;
    }
    for(ll i=0;i<n;i++){
        cin >> z[i];
    }
    ll cnt = 0;
    do{
        bool is_y = true, is_z = true;
        for(ll i=0;i<n;i++){
            if(x[i] != y[i])is_y = false;
            if(x[i] != z[i])is_z = false;
        }
        if(is_y){
            a = cnt;
        }
        if(is_z){
            b = cnt;
        }
        cnt ++;
    }while(next_permutation(x, x + n));
    p(abs(a - b));


    return 0;
}











Measured memory_bytes: 15872
#include<stdio.h>
 
int main(){ 
    int Num, zikan, hun, byou;
     
    scanf("%d", &Num);
     
    zikan = Num   / 3600;
    Num  -= zikan * 3600;
    hun   = Num / 60;
    Num  -= hun * 60;
    byou  = Num;
     
    printf("%d:%d:%d\n", zikan, hun, byou);
    return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
int main()
{
    int x,a;
    scanf("%d%d",&x,&a);
    if(x<a){
        printf("0");
    }
    else if(x>a){
        printf("10");
    }
    else if(x==a){
        printf("10");
    }
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100
#define MAX_W 1'000'000'000
#define MAX_V 1000
#define MAX_S_V 100'000
#define INF 1'000'000'000'000
i64 N, W;
i64 w[MAX_N];
i64 v[MAX_N];
i64 dp[MAX_N + 1][MAX_S_V + 1];

void solve() {
    i64 sv = 0;
    REP(i, N) sv += v[i];

    REP(i, N) REP(j, sv + 1) dp[i][j] = INF;
    dp[0][0] = 0;

    REP(i, N) {
        REP(j, sv + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j - v[i] >= 0) {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }

    i64 res = 0;
    REP(v, sv + 1) {
        if (dp[N][v] <= W) chmax(res, v);
    }
    cout << res << endl;
}

int main() {
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];

    solve();

    return 0;
}

Measured memory_bytes: 79232
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 13:42:57 2018
//
package main

import (
	"fmt"
)

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func primes() []int {
	ret := make([]int, 0)
	for i := 2; i <= 55555; i++ {
		if isPrime(i) {
			ret = append(ret, i)
		}
	}
	return ret
}

func main() {
	var N int
	fmt.Scan(&N)

	ps := primes()
	ans := make([]int, 0)
	for i := range ps {
		if ps[i]%5 == 1 {
			ans = append(ans, ps[i])
			if len(ans) == N {
				break
			}
		}
	}

	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}
	fmt.Println()
}


Measured memory_bytes: 768
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] list = new int[(int)Math.ceil((Math.pow(10, 9)+1)/31.0)];
		int c = sc.nextInt();
		int n;
		int index;
		int bitno;
		int a = 0;
		for (int i = 0; i<c; i++) {
			n = sc.nextInt();
			index = (int) Math.floor(n/31.0);
			bitno = n%31;
			list[index] = list[index]^(1<<bitno);
			if ((1<<bitno & list[index]) > 0) {
				a += 1;
			} else {
				a -= 1;
			}
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 173516
x,n = map(int, input().split())
if n!=0 :
    P = list(map(int, input().split()))
else:
    print(x)
    exit()

P.sort()
olp=lowp=min(P)-2
ohp=hip=max(P)+2
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        if olp<x :
            lowp=x
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

# print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )

Measured memory_bytes: 9172
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

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

    a = []
    for i in range(N):
        a.append(int(input()))

    button = 1
    for i in range(N+1):
        if button == 2:
            print(i)
            exit()
        button = a[button - 1]
    print(-1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 49240
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

using pii = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<pii> AB(N);
    for(int i = 0; i < N; ++i){
        cin >> AB[i].first >> AB[i].second;
    }

    sort(begin(AB), end(AB));

    priority_queue<pii, vector<pii>, function<bool(pii, pii)>> q(
        [](const pii& a, const pii& b){
            return (a.second == b.second) ? (a.first > b.first) : (a.second < b.second);
        }
    );

    int d = 0;
    int j = 0;
    // for(int i = 0; i < N; ++i){
    //     if(AB[i].first != d){
    //         break;
    //     }else{
    //         q.emplace(AB[i]);
    //         ++j;
    //     }
    // }

    int ans = 0;
    while(d <= M && j <= N){
        if(!q.empty()){
            ans += q.top().second;
            q.pop();
        }
        
        ++d;
        for(int i = j; i < N; ++i){
            if(AB[i].first != d){
                break;
            }else{
                q.emplace(AB[i]);
                ++j;
            }
        }
    }

    cout << ans << endl;
}

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

int main(){

  int n;

  cin>>n;

  int i = 3;

  while(1) {

    int x = i;

    if ( x % 3 == 0 ){

      cout<<" "<<i;

    }

    else {

      while(1){
	if( x % 10 == 3){

	  cout<<" "<<i;
	  break;
	}

	x /= 10;
	if ( x == 0 ) break;
      }

    }

    if ( ++i > n ) break;

  }

  cout<<endl;

  return 0;

}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>


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

    int n; std::cin >> n;
    std::string s, ans; std::cin >> s;
    ans = s[0];
    for(int i=1; i<n; i++)
    {
        if(s[i]!=s[i-1]) ans += s[i];
    }

    std::cout << ans.length() << std::endl;
    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main() {
  ll K; cin >> K;
  ll sum=0;
  
  rep(i,K+1){
    sum = sum*10 +7;
    sum%=K;
    if(sum == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var listR = 0;
            var ListB = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i].ToString() == "R")
                {
                    listR++;
                }
                if (s[i].ToString() == "B")
                {
                    ListB++;
                }
            }

            if (listR > ListB)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a = ni()
b = ni()
h = ni()

print((a+b)*h // 2)

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

int main(){
  int A,B,C;
  cin >> A >> B;
  if(B>=0){
    C = A+B;
    if(C>=A*B){
    cout << C;
  }
  else if(C<A*B){
    cout << A*B;
  }
    
  }
  else{
    C = A-B;
    if(C>=A*B){
    cout << C;
  }
  else if(C<A*B){
    cout << A*B;
  }
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

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

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

fn main() {
  input! {
    x: [i32; 3],
  }
  let mut x = x;
  x.sort();

  println!("{}", x[0] + x[1]);
}


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

inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
} 

int k, n, m;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout); 
	
	cin >> k >> n >> m;
	
	for(int i=n; i<=m; i++){
		if(i%k==0){
			cout << "OK";
			return 0;
		}
	}
	
	cout << "NG";
	 
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(H);
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    str.at(i) = "#" + s + "#";
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << str.at(i) << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 3608
import Data.List (sort)

main :: IO ()
main = do
    getLine
    a <- map read . words <$> getLine
    let ans = solve a
    putStr $ show (fst ans) ++ " " ++ show (snd ans)

solve :: [Int] -> (Int, Int)
solve a = (max 1 coll, coll + prol) where
    hai  = filter (\x ->    1 <= x && x <=  399) a
    cha  = filter (\x ->  400 <= x && x <=  799) a
    mid  = filter (\x ->  800 <= x && x <= 1199) a
    miz  = filter (\x -> 1200 <= x && x <= 1599) a
    ao   = filter (\x -> 1600 <= x && x <= 1999) a
    ki   = filter (\x -> 2000 <= x && x <= 2399) a
    dai  = filter (\x -> 2400 <= x && x <= 2799) a
    aka  = filter (\x -> 2800 <= x && x <= 3199) a
    pro  = filter (\x -> 3200 <= x) a
    col  = [hai, cha, mid, miz, ao, ki, dai, aka]
    coll = length $ filter (not . null) col
    prol = length pro

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 100005
#define MOD 998244353
int main()
{
    FILE *input=stdin;
    //input=fopen("in.txt","r");
    int t,T=1;
    //fscanf(input,"%d",&T);
    for(t=1; t<=T; t++)
    {
        int n=6,i,j;
        //fscanf(input,"%d",&n);
        char arr[n];
        for(i=0; i<n; i++)
        {
            fscanf(input,"%c",&arr[i]);
        }
        fscanf(input,"%*c");
        if(arr[2]==arr[3]&&arr[4]==arr[5])
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
        if(t!=T) printf("\n");
    }
    fclose(input);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
const int maxn = 1e5+5;
int h[maxn], vis[maxn];

int main(){
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> h[i];
	int u, v; 
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		if(h[u] > h[v]) vis[v] = 1;
		if(h[v] > h[u]) vis[u] = 1;
		if(h[u] == h[v]) vis[u] = vis[v] = 1;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(!vis[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 4404
#include<stdio.h>
int main()
{
    int A,N;
    scanf("%d%d",&N,&A);
    int b;
    b=N;
    if(N>500)
    {
         while(b>=500)
        {
            b=b-500;
        }
        if(b<=A)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    if(N==500)
    {
        printf("Yes");
    }
    if(N<500)
    {
        if(N<=A)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second

signed main()
{
    fast;
    int n;
    cin>>n;
    int ans = 1e18;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            int x = i;
            int y = n/i;
            ans = min(ans,abs(x-1)+abs(y-1));
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
     
    using namespace std;
     
    #define sim template < class c
    #define ris return * this
    #define dor > debug & operator <<
    #define eni(x) sim > typename \
      enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug {
    #ifdef LOCAL
        ~debug() { cerr << endl; }
        eni(!=) cerr << boolalpha << i; ris; }
        eni(==) ris << range(begin(i), end(i)); }
        sim, class b dor(pair < b, c > d) {
        ris << "(" << d.first << ", " << d.second << ")";
        }
        sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
        }
    #else
    sim dor(const c&) { ris; }
    #endif
    };
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
     
    # define forn(i, n) for (ll i = 0; i < int(n); i++)
    # define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
    # define all(V) V.begin(), V.end()
    # define rall(V) V.rbegin(), V.rend()
    # define len(V) (int)V.size()
    # define ll long long
    # define ld long double
    # define ff first
    # define ss second
    # define pb push_back
    # define mp make_pair
    # define endl '\n'
    # define M_PI 3.14159265358979323846
     
    void solve()
    {
            int n; cin >> n;
            forn(i, 50001)
            {
                    ld check = i * 1.080000000000000000;
                    if((int)(floor(check)) == (int)n)
                    {
                            cout << i;
                            return;
                    }
            }
            cout << ":(";
    }
     
    int main()
    {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            solve();
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int a[N];

signed main(){

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

	a[N] = 0;
	sort(a,a+n+1);
	int zero = find(a,a+n,0) - a;
  ll ans = 1e9;

	for(int i = zero; i >= 0; i--){
		if(i+k > n) continue;
		ll res = abs(a[i]*2) + a[i+k];
		ans = min(ans,res);
	}

	for(int i = zero; i < n+1; i++){
		if(i < k) continue;
		ll res = abs(a[i-k]) + a[i]*2;
		ans = min(ans,res);
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int s, d, m;
	while(cin >> s >> d >> m){
		int num = 0;
		vector<int> w;
		vector<int> p;
		vector<int> a;
		vector<P> idx;
		rep(i, s){
			int k;
			cin >> k;
			idx.push_back(MP(num, num+k-1));
			num += k;
			rep(j, k){
				int we, pr;
				cin >> we >> pr;
				w.push_back(we);
				p.push_back(pr);
				a.push_back(0);
			}
		}
		rep(i, d){
			int f;
			cin >> f;
			for(int j = idx[f].first; j <= idx[f].second; j++) a[j]++;
		}

		int n = a.size();
		vector<vector<int> > dp(n+1, vector<int>(301, -1));
		dp[0][0] = 0;
		rep(i, n){
			rep(j, 301){
				if(dp[i][j] == -1) continue;
				for(int k = 0; k <= a[i]; k++){
					if(j+p[i]*k > 300) break;
					dp[i+1][j+p[i]*k] = max(dp[i+1][j+p[i]*k], dp[i][j] + w[i]*k);
				}
			}
		}
		int answ = 0;
		int ansp = 0;
		rep(i, m+1){
			if(answ < dp[n][i]){
				answ = dp[n][i];
				ansp = i;
			}
		}
		cout << answ << ' ' << ansp << endl;
	}

	return 0;
}

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

int main()
{
    int n, m, tmp, res = 0;
    cin >> n >> m;

    for(int i = 0; i < m; ++i)
    {
        cin >> tmp;
        res += tmp;
    }

    res = n - res;
    cout << (res < 0 ? -1 : res) << "\n"; 
}

Measured memory_bytes: 3588
using System;

namespace _102_1
{
    class Program
    {
        static void Main(string[] args)
        {
			int N = int.Parse(Console.ReadLine());

			if (N % 2 == 1)
			{
				Console.WriteLine(N * 2);
			}
			else Console.WriteLine(N);
        }
    }
}


Measured memory_bytes: 11092
let kInf = 1010101
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let q = Queue.create ()
let ds = Array.make_matrix h w kInf
let a_ss = Array.init h @@ fun i -> Array.init w @@ fun j -> Scanf.scanf " %c" @@ fun a ->
  if a = '#' then (ds.(i).(j) <- 0; Queue.push (i, j) q); a
let _ =
  while not @@ Queue.is_empty q do
    let y0, x0 = Queue.pop q in
    let f (dy, dx) =
      let y, x = y0 + dy, x0 + dx in
      if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) > ds.(y0).(x0) + 1 then
        (ds.(y).(x) <- ds.(y0).(x0) + 1; Queue.push (y, x) q) in
    List.iter f [-1, 0; 0, -1; 1, 0; 0, 1]
  done;
  Array.fold_left (Array.fold_left max) 0 ds |> Printf.printf "%d\n"

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

const int inf = 1e9, maxn = 1 << 18;

struct data {
    data() : mx(-inf), mn(inf) {}
    data(int k) : mx(k), mn(k) {}
    data(int mx, int mn) : mx(mx), mn(mn) {}
    int mx, mn;
};

struct segt {
    data t[maxn*2];
    data merge(data a, data b) { return data(max(a.mx, b.mx), min(a.mn, b.mn)); }
    void update(int s, int e, int x, int p, data v) {
        if (s==e) t[x] = v;
        else {
            int m = (s+e)/2;
            if (p<=m) update(s, m, 2*x, p, v);
            else update(m+1, e, 2*x+1, p, v);
            t[x] = merge(t[2*x], t[2*x+1]);
        }
    }
    void update(int p, data v) { return update(0, maxn-1, 1, p, v); }
    data query(int s, int e, int x, int l, int r) {
        if (l<=s and e<=r) return t[x];
        else if (l<=e and s<=r) {
            int m = (s+e)/2;
            return merge(query(s, m, 2*x, l, r), query(m+1, e, 2*x+1, l, r));
        } else return data();
    }
    data query(int l, int r) { return query(0, maxn-1, 1, l, r); }
} t;

struct segt2 {
    int t[maxn*2];
    int merge(int a, int b) { return min(a, b); }
    void update(int s, int e, int x, int p, int v) {
        if (s==e) t[x] = v;
        else {
            int m = (s+e)/2;
            if (p<=m) update(s, m, 2*x, p, v);
            else update(m+1, e, 2*x+1, p, v);
            t[x] = merge(t[2*x], t[2*x+1]);
        }
    }
    void update(int p, int v) { return update(0, maxn-1, 1, p, v); }
    int query(int s, int e, int x, int l, int r) {
        if (l<=s and e<=r) return t[x];
        else if (l<=e and s<=r) {
            int m = (s+e)/2;
            return merge(query(s, m, 2*x, l, r), query(m+1, e, 2*x+1, l, r));
        } else return 1;
    }
    int query(int l, int r) { return query(0, maxn-1, 1, l, r); }
} t2;

int n, k, a[200004];

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

    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        t.update(i, data(a[i]));
        if (i) t2.update(i, a[i-1] <= a[i]);
    }

    int ans = 0, cnt = 0;
    for (int i=0; i+k<=n; i++) {
        // a[i], ..., a[i+k-1]이 중복이 아닌지
        if (t2.query(i+1, i+k-1) == 0) {
            if (i == 0) ans++;
            else {
                data d = t.query(i, i+k-2);
                if (not (a[i-1] <= d.mn and d.mx <= a[i+k-1])) ans++;
            }
        } else if (cnt++ == 0) ans++;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 6912
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll r,d,f;
  cin >> r >> d >> f;
  for(int i=0; i<10; i++) {
    f=f*r-d;
    cout << f << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    char ch;
    while(1){
        scanf("%c", &ch);
        if(ch == '\n')break;
        if(islower(ch)){
            ch = toupper(ch);
        } else if(isupper(ch)){
            ch = tolower(ch);
        } else {
            ;
        }
        printf("%c", ch);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include"bits/stdc++.h"
using namespace std ;
#define ll unsigned long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bug(x) cerr<< #x << '=' <<x <<endl ;

int n , temp;
string s , t;
int32_t main() {
   IOS
      cin >> s >> t ;
    
      n = s.size() ;

      for(int i=0 ;i < n ;i ++)
          if(s[i] == t[i])temp++;
      
      cout << n - temp << endl;











}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,K;
  cin>>n>>K;
  vector<int> can(11,1);
  for(int i=0;i<K;i++){
    int d;
    cin>>d;
    can[d] = 0;
  }
  
  auto check = [&](int num){
    while(num){
      if(can[num%10] == 0) return 0;
      num/=10;
    }
    return 1;
  };

  int ans = n;
  for(;check(ans) == 0; ans++);
  cout<<ans<<endl;

  
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int A, B, C, w;
  scanf("%d %d %d", &A, &B, &C);
  w = B+C-A;
  if(w <= 0)
    printf("0\n");
  else
    printf("%d\n", w);
  
  return 0;
}

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

int main(){
    int n, q, S[10000], T[500];

    cin >> n;
    for(int i=0; i<n; i++) cin >> S[i];
    cin >> q;
    for(int i=0; i<q; i++) cin >> T[i];

    int cnt=0;
    for(int i=0; i<q; i++){
        for(int j=0; j<n; j++){
            if(T[i] == S[j]){
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int R,C,M;
char Room[50][50];
int Cost[3][50][50];
pii TaskRoom[1001];
vector<int> Time[50][50];

int grid2ind(pii grid){
    return grid.first * C + grid.second;
}
pii ind2grid(int ind){
    return {ind/C,ind%C};
}

int d[4] = {1,0,-1,0};
int NowTime = 0;
int NextTime = -1;
bool visited[50][50];
bool check(int y,int x,int ty,int tx,int dep = 0){
    if(visited[y][x]) return false;
    visited[y][x] = true;
    if(y == ty && x == tx){
        NextTime = NowTime+dep;
        Time[y][x].push_back(NowTime+dep);
        return true;
    }
    
    for(int k = 0; k < 4;k++){
        int ny = y + d[k];
        int nx = x + d[k^1];
        if(ny < 0 || ny >= R || nx < 0 || nx >= C) continue;
        if(Room[ny][nx]=='#') continue;
        if(check(ny,nx,ty,tx,dep+1)){
            Time[y][x].push_back(NowTime+dep);
            return true;
        }
    }
    return false;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> R >> C >> M;
    for(int i = 0; i < R;i++){
        for(int j = 0; j < C;j++){
            cin >> Room[i][j];
        }
    }
    for(int i = 0; i < 3;i++){
        for(int j = 0; j < R;j++){
            for(int k = 0; k < C;k++){
                cin >> Cost[i][j][k];
            }
        }
    }
    for(int i = 0; i < M;i++) cin >> TaskRoom[i].first >> TaskRoom[i].second;
    
    int py,px; tie(py,px) = TaskRoom[0];
    for(int i = 1; i < M;i++){
        fill(*visited,*visited+50*50,false);
        check(py,px,TaskRoom[i].first,TaskRoom[i].second);
        NowTime = NextTime;
        tie(py,px) = TaskRoom[i];
    }
    
    ll ans = 0;
    for(int i = 0; i < R;i++){
        for(int j = 0; j < C;j++){
            sort(Time[i][j].begin(),Time[i][j].end());
            
//            cout << "(" << i << "," << j << ")" << endl;
//            for(auto t:Time[i][j]) cout << t << " "; cout << endl;
            
            if(Time[i][j].empty()) continue;
            ans += Cost[1][i][j] + Cost[2][i][j];
            
            for(int k = 1; k < Time[i][j].size();k++){
                ll dt = Time[i][j][k] - Time[i][j][k-1];
                ans += min(dt*Cost[0][i][j],(ll)Cost[1][i][j] + Cost[2][i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8160
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+111;
set<int> st;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    while(k--){
        int d;
        scanf("%d",&d);
        while(d--){
            int x;
            scanf("%d",&x);
            st.insert(x);
        }
    }
    printf("%d\n",n-st.size());
    return 0;
}

Measured memory_bytes: 3824
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
          a[i] = sc.nextInt();
        }
        int[] c = Arrays.stream(a).distinct().toArray();
        System.out.println(c.length);
    }
}

Measured memory_bytes: 27604
#include <bits/stdc++.h>
using namespace std;
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n,a[100003];
int dp[100003],k;
int main(){std::ios::sync_with_stdio(false);
cin>>n>>k;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
dp[1]=0;
dp[2]=abs(a[1]-a[2]);
for(int i=3;i<=n;i++){
	dp[i]=lmax;
	for(int j=1;j<=k&&i-j>=1;j++){
		dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
}
cout<<dp[n]<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





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

int main(){

  char c;

  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    int n;cin>>n;
    ll h;cin>>h;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int res=0;
    ll ma=a[n-1];
    for(int i=n-1;i>=0;i--){
        if(b[i]<ma) break;
        h-=b[i];
        res++;
        if(h<=0) break;
    }
    if(h<=0){
        cout<<res<<endl;
        return 0;
    }
    res+=(h/ma);
    if(h%ma) res++;
    cout<<res<<endl;
}

Measured memory_bytes: 1792
def dfs(v):
    if was[v] == clr: return 0
    was[v] = clr
    for u in g[v]:
        if mt[u] == -1 or dfs(mt[u]):
            mt[u] = v
            return 1
    return 0

read = lambda: map(int, input().split())
n = int(input())
n2 = n * 2
a = [0] * n2
b = [0] * n2
g = [list() for i in range(n2)]
for i in range(n):
    a[i], b[i] = read()
for i in range(n):
    a[i+n], b[i+n] = read()
for i in range(n):
    for j in range(n, n2):
        if a[i] < a[j] and b[i] < b[j]:
            g[i].append(j)
            g[j].append(i)
mt = [-1] * n2
was = [0] * n2
clr = 1
ans = 0
for i in range(n):
    if dfs(i):
        ans += 1
        clr += 1
print(ans)

Measured memory_bytes: 3064
while True:
  n =int(input())
  if n==0:
    break
  a0=a1=a2=a3=a4=a5=a6=0
  for i in range(n):
    a=int(input())
    if a<10:
      a0+=1
    elif a<20:
      a1+=1
    elif a<30:
      a2+=1
    elif a<40:
      a3+=1
    elif a<50:
      a4+=1
    elif a<60:
      a5+=1
    else:
      a6+=1
  print(a0)
  print(a1)                        
  print(a2)
  print(a3)
  print(a4)
  print(a5)
  print(a6)


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

int main() {
	int N, K; cin >> N >> K;
	int min;
	for(int i = 0; i < N; i++){
		int tmp; cin >> tmp;
		if(tmp == 1) min = i;
	}

	int left = min, right;
	if(min % (K - 1) == 0){
		right = N - min - 1;
	}else{
		right = N - min - K + min % (K - 1);
	}
	cout << ceil((float)left/(K-1)) + ceil((float)right/(K-1)) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  string t, p; cin >> t >> p;
  int best = SZ(p);
  F0R (i, SZ(t) - SZ(p) + 1) {
    int diff = 0;
    F0R (j, SZ(p)) diff += t[i + j] != p[j];
    ckmin(best, diff);
  }
  cout << best << endl;

  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    string s;
    getline(cin, s);
    REP(i,s.length()) {
        if (islower(s[i])) cout << (char)toupper(s[i]);
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	cout<<(a+b)%24;
	return 0;
}


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

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if(a < b){
        return gcd(b, a);
    }
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> as(n);
    for(int i = 0; i < n; ++i){
        cin >> as.at(i);
    }
    vector<ll> lgcds(n), rgcds(n);
    lgcds.at(0) = as.at(0);
    for(int i = 1; i < n; ++i){
        lgcds.at(i) = gcd(lgcds.at(i - 1), as.at(i));
    }
    rgcds.at(n - 1) = as.at(n - 1);
    for(int i = n - 2; i >= 0; --i){
        rgcds.at(i) = gcd(rgcds.at(i + 1), as.at(i));
    }

    ll ans = rgcds.at(1);
    for(int i = 0; i < n; ++i){
        if(i == 0){
            ans = max(ans, rgcds.at(1));
        }else if(i == n - 1){
            ans = max(ans, lgcds.at(n - 2));
        }else{
            ans = max(ans, gcd(lgcds.at(i - 1), rgcds.at(i + 1)));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;

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

int main() {
	long long S;

	cin >> S;
  
    auto Ss = (long long)ceil(sqrt(S)), rest = S - Ss * Ss;
  
  long long x = Ss, y = 0, z = 0, w = Ss, a = Ss, b = Ss;

  b = S / 1000000000LL + 1LL;
  a = S % 1000000000LL;
  if (a == 0LL) {
    a += 1000000000LL;
    b -= 1LL;
  }
	cout << "1000000000 0 0 1 " << a << " " <<  b << endl;

	return 0;
}


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

int main(void) {
  string mcs;
  int maxlength;
  string mls;
  map<string, int> index;
  string s;
  int flag;
  flag = 0;
  maxlength = -1;
  while(cin >> s) {
    index[s]++;
    if((int)s.length() > maxlength) {
      maxlength = s.length();
      mls = s;
    }
    if(flag) {
      if(index[s] > index[mcs]) {
	mcs = s;
      }
    }else {
      mcs = s;
      flag = 1;
    }
  }
  cout << mcs << " " << mls << endl;

  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;
        public long[] A;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadLongArray();

            bool even = A.Where(v => v < 0).Count() % 2 == 0;

            A = A.Select(v => Math.Abs(v)).ToArray();
            Array.Sort(A);

            if (even)
            {
                Console.WriteLine(A.Sum());
            }
            else
            {
                Console.WriteLine(A.Sum() - A[0] * 2);
            }

        }

        // validation: AOJ 0005
        public static int GCD(int a, int b)
        {
            return b == 0 ? a : GCD(b, a % b);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

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

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

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

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

#define MAX 100000
typedef long long ll;

int n,k;
ll T[MAX];

int check(ll P){
  int i = 0;
  for (int j = 0; j < k; j++) {//Track の数
    ll s = 0;
    while( s + T[i] <= P ) {
      s += T[i];
      i++;
      if( i == n ) return n;
    }
  }
	return i;
}

int solve() {
  ll left = 0;
  ll right = 100000 * 10000;
  ll mid;
  while (right - left > 1) {
		// cout << "right = " << right << " left = " << left << endl;
    mid = (left + right) / 2;
		// cout << "mid = " << mid <<endl;
    int v = check(mid);// Pに対して何個つめるか？
		// cout << "v = " << v <<endl;
    if ( v== n) right = mid;
    else left = mid;
  }
  return right;
}

int main() {
  cin >> n >> k;
  for (int i = 0;i < n; i++) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;
	return 0;
}



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


int N, M;
vector<ll> X, Y, Z;
vector<vector<ll>> dp;
const ll INF = -1e15;


void input() {
    cin >> N >> M;
    X = Y = Z = vector<ll>(N);
    rep(i, N) cin >> X[i] >> Y[i] >> Z[i];
}


ll solve(int x, int y, int z) {
    dp = vector<vector<ll>>(N + 1, vector<ll>(M + 1, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        dp[i][0] = 0;
        for (int j = 1; j <= M && j <= i; j++) {
            ll w = X[i-1] * x + Y[i-1] * y + Z[i-1] * z;
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-1] + w);
        }
    }
    return dp[N][M];
}


int main() {
    input();
    ll ans = 0;
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) {
            for (int k = -1; k <= 1; k += 2) {
                ans = max(ans, solve(i, j, k));
            }
        }    
    }
    cout << ans << endl;
}


Measured memory_bytes: 16024
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int x, y, z;

  cin >> x >> y >> z;

  cout << z SP x SP y << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int M[10][10];
int main(){
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++) cin>>M[i][j];
    }
    int n,tem;cin>>n;
    while(n--){
        cin>>tem;
        for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) if(M[i][j]==tem) M[i][j]=0;
    }
    for(int i=1;i<=3;i++){
        bool ok=1;
        for(int j=1;j<=3;j++){
            if(M[i][j]!=0) {ok=0;break;}
        }
        if(ok) return 0*puts("Yes");
    }
    for(int j=1;j<=3;j++){
        bool ok=1;
        for(int i=1;i<=3;i++){
            if(M[i][j]!=0) {ok=0;break;}
        }
        if(ok) return 0*puts("Yes");
    }
    if(M[1][1]==0&&M[2][2]==0&&M[3][3]==0) return 0*puts("Yes"); 
    if(M[1][3]==0&&M[2][2]==0&&M[3][1]==0) return 0*puts("Yes"); 
    return 0*puts("No");
}

Measured memory_bytes: 256
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=200200;
ll a[N];

int main(){
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=0 ; i<n ; i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }

    ll ans=0;
    for(int i=0 ; i<n ; i++){
        sum-=a[i];
        ans+=(sum%mod*a[i]%mod)%mod;
        ans%=mod;
    }

    printf("%lld",ans);
}


Measured memory_bytes: 5380