akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(usize, usize, usize);
    if a + b == c || a == b + c || a + c == b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

constexpr unsigned int MAX_N = 10'000;
unsigned int A[MAX_N + 1];

int main(void){
    unsigned int n, W; scanf("%u%u", &n, &W);
    A[0] = 1;
    for(unsigned int i = 0; i < n; ++i){
        unsigned int v, w; scanf("%u%u", &v, &w);
        for(unsigned int i = 0, j = w; j <= W; ++i, ++j) if(A[j] < A[i] + v) A[j] = A[i] + v;
    }
    unsigned int res = 0;
    for(unsigned int i = 1; i <= W; ++i) if(res < A[i]) res = A[i];
    printf("%u\n", res - 1);

    return 0;
}


Measured memory_bytes: 2800
#include <iostream>
using namespace std;
void call(int n);
int main()
{
    int n;
    cin >> n;
    call(n);
    return 0;
}
void call(int n)
{
    int i = 1;
    while (true)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            if (++i <= n)
                continue;
            cout << endl;
            return;
        }

        while (true)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                if (++i <= n)
                    break;

                cout << endl;
                return;
            }
            x /= 10;
            if (x)
                continue;
            if (++i <= n)
                break;

            cout << endl;
            return;
        }
    }
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	bool flag = false;
	for (int i = 1; i <= 9; i ++) {
		for (int j = 1; j <= 9; j ++) {
			if (i * j == n) {
				flag = true;
				break;
			}
		}
	}	
	cout << ((flag) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
S = input("")

first_half = int(S[0:2])
second_half = int(S[2:4])

a = 0
if 0 < first_half < 13:
    a = 1

b = 0
if 0 < second_half < 13:
    b = 1

if a == 0 and b == 0:
    print("NA")
elif a == 1 and b == 0:
    print("MMYY")
elif a == 0 and b == 1:
    print("YYMM")
else:
    print("AMBIGUOUS")

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

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans = 0;
	long long ta = c, tb = d, r, tmp;
	if (ta < tb)
	{
		tmp = ta;
		ta = tb;
		tb = tmp;
	}
	r = ta % tb;
	while (r != 0)
	{
		ta = tb;
		tb = r;
		r = ta % tb;
	}
	tmp = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / (c * d / tb);
	ans = b - b / c - b / d + b / (c * d / tb);
	cout << ans - tmp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;
int a[300000];
int b[300000];

main(){
  cin>>n;

  FOR(i,1,n+1){
    cin>>a[i];
  }

  int dp[300000]={};
  dp[0]=1;
  FOR(i,1,n+1){
    dp[i]=dp[i-1];
    if(b[a[i]]+1==i||b[a[i]]==0){
      b[a[i]]=i;continue;
    }

    dp[i]=dp[i-1]+1+dp[b[a[i]]]-1;
    b[a[i]]=i;
    dp[i]%=M;
  }
  /*
     rep(i,n){
     cout<<dp[i]<<' ';
     }cout<<endl;
     */

  cout<<dp[n]<<endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int n;
int f(int a[][3], int n){
    int dp[n][3];
    
    for(int i=0;i<3;i++)
    dp[n-1][i]=a[n-1][i];
    
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            if(j==0)  dp[i][j]=max(dp[i+1][1]+a[i][j],dp[i+1][2]+a[i][j]);
            else if(j==1)  dp[i][j]=max(dp[i+1][0]+a[i][j],dp[i+1][2]+a[i][j]);
            else   dp[i][j]=max(dp[i+1][1]+a[i][j],dp[i+1][0]+a[i][j]);
        }
    }
    
    int ans=INT_MIN;
    for(int i=0;i<3;i++)
    if(dp[0][i]>ans) ans=dp[0][i];
    
    return ans;
}

int main() {

	cin>>n;
	int a[n][3];
	
	for(int i=0;i<n;i++)
	for(int j=0;j<3;j++)
	cin>>a[i][j];
	
	cout<<f(a,n)<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int a, p;
	scanf("%d%d", &a, &p);
	printf("%d\n", (a*3 + p) / 2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
const int maxn=5000010;
long long fac[maxn],ifac[maxn],inv[maxn],d[2010][2010];
int n,k;
int main(){
	cin>>n>>k;
	if(k==1){
		cout<<1<<endl;
		return 0;
	}
	fac[0]=inv[0]=ifac[0]=fac[1]=inv[1]=ifac[1]=1;
	for(int i=2;i<=n*k+10;++i){
		fac[i]=(fac[i-1]*i)%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		ifac[i]=(ifac[i-1]*inv[i])%mod;
	}
	d[0][1]=1;
	for(int i=2;i<=n;++i)
		d[0][i]=d[0][i-1]*(fac[i*(k-1)-1]*ifac[k-2]%mod*ifac[(i-1)*(k-1)]%mod)%mod;
	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;++j){
			d[i][j]=(d[i-1][j]+d[i][j-1]*(fac[i+j*(k-1)-1]*ifac[k-2]%mod*ifac[i+(j-1)*(k-1)]%mod)%mod)%mod;
		}
	}
	cout<<d[n][n]*fac[n]%mod<<endl;
	return 0;
}


Measured memory_bytes: 129280
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = new(std::io::stdin());
    let mut v:Vec<(i32, usize)> = vec![];

    let n:usize = sc.next();
    for i in 0..n {
        v.push((sc.next(), i));
    }
    v.sort();
    let mut res = vec![0;n];
    for i in 0..n {
        res[v[i].1] = if i * 2 < n {v[n / 2].0} else {v[n / 2 - 1].0}
    }
    for i in 0..n {
        println!("{}", res[i]);
    }
}


pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: ")).unwrap()
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 17512
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    double a,b,h;
    cin >> a >> b >> h;
    double s = (a + b) * h / 2.0;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    scanInt(R);
    vector<unordered_map<int, ll>> edges(N);
    vector<int> r;
    loop(i, R){
        scanInt(ri); --ri;
        r.emplace_back(ri);
    }
    loop(i, M){
        scanInt(Ai); --Ai;
        scanInt(Bi); --Bi;
        scanInt(Ci);
        edges[Ai].emplace(Bi, Ci);
        edges[Bi].emplace(Ai, Ci);
    }
    // ワーシャルフロイド
    vector<vector<ll>> d(N, vector<ll>(N));
    loop(i, N){
        loop(j, N){
            if (0 < edges[i].count(j)){
                d[i][j] = edges[i][j];
            }else{
                d[i][j] = -1;
            }
        }
    }
    loop(k, N){
        loop(i, N){
            loop(j, N){
                if (d[i][k] != -1 && d[k][j] != -1 && (d[i][j] == -1 || d[i][k] + d[k][j] < d[i][j])){
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
    // rの順列を全探索
    sort(r.begin(), r.end());
    ll result = LLONG_MAX;
    do {
        ll temp_result = 0;
        loop(i, R - 1){
            temp_result += d[r[i]][r[i + 1]];
        }
        // printf("%lld\n", temp_result);
        result = min(result, temp_result);
    } while(next_permutation(r.begin(), r.end()));
    printf("%lld\n", result);
}


Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
a = list()
b = list()

if N%2 == 0:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))       
else:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))   
    a.append(max(A))

print(sum(a) - sum(b))

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putStrLn . flip replicate 'x' . length

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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<int> v;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end(), greater<int>());

    double ans = 0;
    for (int i = 0; i < N-1; ++i) {
        ans += v[i] / pow(2, i+1);
    }
    ans += v[N-1] / pow(2, N-1);
    printf("%f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int A[n];
  int B[n];
  int C[n-1];
  int sum=0;
    for(i=1;i<=n;i++)
    {
      cin>>A[i];
    }
    for(i=1;i<=n;i++)
    {
    cin>>B[i];
    sum=sum+B[i];
    }
    for(i=1;i<n;i++)
    {
      cin>>C[i];
    }
  for(i=1;i<n;i++)
  {
     if(A[i]==A[i+1]-1)
      {
        sum=sum+C[A[i]];
      }
  }
  cout<<sum;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x=x2-x1,y=y2-y1;
  int x3=x2-y,y3=y2+x;
  cout<<x3<<' '<<y3<<' ';
  int x4=x3-x,y4=y3-y;
  cout<<x4<<' '<<y4<<'\n';
  return(0);
}


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

int main() {

  ll A,B,C,K,count=0;
  cin >> A >> B >> C >> K;
  
  vector<ll> ans(3,0);

  for(ll i=0;i<A;i++){
    count++;
    K--;
    if(K<=0){
      cout << count << endl;
      return 0;
    }
  }

  for(ll i=0;i<B;i++){
    K--;
    if(K<=0){
      cout << count << endl;
      return 0;
    }
  }

  for(ll i=0;i<C;i++){
    count--;
    K--;
    if(K<=0){
      cout << count << endl;
      return 0;
    }
  }




}


Measured memory_bytes: 3620
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()
total=0
for j in range(N):
    b=B[j]
    p_a=bisect.bisect_left(A,b)
    p_b=bisect.bisect_right(C,b)
    total+=p_a*(N-p_b)
print(total)

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var w = firstLine[0];
			var h = firstLine[1];
			var n = firstLine[2];

			var vertexes = new int[4] { 0, w, 0, h };

			for(int i = 0; i < n; i++)
			{
				var input = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
				
				if(input[2] == 1)
				{
					vertexes[0] = Math.Max(vertexes[0], input[0]);
				}
				else if(input[2] == 2)
				{
					vertexes[1] = Math.Min(vertexes[1], input[0]);
				}
				else if (input[2] == 3)
				{
					vertexes[2] = Math.Max(vertexes[2], input[1]);
				}
				else if (input[2] == 4)
				{
					vertexes[3] = Math.Min(vertexes[3], input[1]);
				}
			}



			if(vertexes[1] - vertexes[0] <= 0 || vertexes[3] - vertexes[2] <= 0)
			{
				Console.WriteLine("0");
			}
			else
			{
				Console.WriteLine((vertexes[1] - vertexes[0]) * (vertexes[3] - vertexes[2]));
			}
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int i=0;
  ll ans=0;
  ll num=0;
  while(i<N){
    if(S.at(i)=='A'){
      num++;
      i++;
    }else if(i!=N-1){
      if(S.at(i)=='B'&&S.at(i+1)=='C'){
        ans+=num;
        i+=2;
      }else{
        i++;
        num=0;
      }
    }else{
      i++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

ll digitsum(ll i) {
	ll d = 0;
	while (i > 0) { d += i % 10; i /= 10; }
	return d;
}
int main() {
	double m = 0;
	int K; cin >> K;
	ll x = 0;
	ll d = 1;
	ll table[16] = {
		1,
		10,
		100,
		1000,
		10000,
		100000,
		1000000,
		10000000,
		100000000,
		1000000000,
		10000000000,
		100000000000,
		1000000000000,
		10000000000000,
		100000000000000,
		1000000000000000
	};
	double s[16];
	for (int c = 0; c < K; c++) {
		for (int i = 0; i < 16; i++) {
			s[i] = (double)(x + table[i]) / (double)digitsum(x + table[i]);
		}
		int k = 0;
		double b = s[0];
		for (int i = 1; i < 16; i++) {
			if (b > s[i]) {
				b = s[i];
				k = i;
			}
		}
		x += table[k];
		cout << x << endl;
	}
	return 0;
}


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

int main(void) {
  int K;
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2] >> K;
  sort(v.begin(), v.end(), greater<int>());
  cout << v[0] * pow(2, K) + v[1] + v[2] << endl;
  return 0;
}

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

int num[1001][1001];
bool visited[1001][1001];

int main(){

  int H,W,ans=0;
  cin >> H >> W;
  char a[H][W];
  queue<int> x,y;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> a[i][j];
    }
  }

  for(int i=0; i<1001; i++){
    for(int j=0; j<1001; j++){
      num[i][j] = -1;
    }
  }

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(a[i][j] == '#'){
        x.push(i);
        y.push(j);
        visited[i][j] = true;
        num[i][j] = 0;
      }
    }
  }

  while(x.size()){
    int xco,yco;
    xco = x.front();
    yco = y.front();
    if(xco != 0 && !visited[xco-1][yco]){
      num[xco-1][yco] = num[xco][yco] + 1;
      visited[xco-1][yco] = true;
      x.push(xco-1);
      y.push(yco);
    }
    if(xco != H-1 && !visited[xco+1][yco]){
      num[xco+1][yco] = num[xco][yco] + 1;
      visited[xco+1][yco] = true;
      x.push(xco+1);
      y.push(yco);
    }
    if(yco != 0 && !visited[xco][yco-1]){
      num[xco][yco-1] = num[xco][yco] + 1;
      visited[xco][yco-1] = true;
      x.push(xco);
      y.push(yco-1);
    }
    if(yco != W-1 && !visited[xco][yco+1]){
      num[xco][yco+1] = num[xco][yco] + 1;
      visited[xco][yco+1] = true;
      x.push(xco);
      y.push(yco+1);
    }
    x.pop();
    y.pop();
  }

  for(int i=0; i<1001; i++){
    for(int j=0; j<1001; j++){
      ans = max(ans, num[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

    int K; cin >> K;

    ll S = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                S += gcd(a, gcd(b, c));
            }
        }
    }

    cout << S << "\n";

    return 0;
}


Measured memory_bytes: 3632
S = list(input())
S = [int(i) for i in S]
sum1,sum2 = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            sum1 += 1
    else:
        if S[i] == 1:
            sum1 += 1

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)


Measured memory_bytes: 4652
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]int)
	var d int
	for i := 0; i < n; i++ {
		fmt.Scan(&d)
		m[d] = 0
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 512
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int H, W;
  while (cin >> H >> W, H||W)
    {
      for ( int i = 0; i < H; i++ ){
        for ( int j = 0; j < W; j++ ){
          if ((i+j)%2==0)
            {
              cout << "#";
            }
          else
            {
              cout << ".";
            }
        }
        cout << endl;
      }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
    unsigned long long w,i,j,k,n,m,l;
    cin>>n>>w;
    char field[n][w];
    for(i=0;i<n;i++){
        for(j=0;j<w;j++){
            cin>>field[i][j];
        }
    }
    unsigned long long chart[n][w];
    for(i=0;i<n;i++){
        for(j=0;j<w;j++){
            if(i==0&&j==0){
                chart[i][j]=1;
                continue;
            }
            if(field[i][j]=='#'){
            chart[i][j]=0;
            continue;
            }
            if(i==0){
                chart[i][j]=chart[i][j-1];
                continue;
            }
            if(j==0){
                chart[i][j]=chart[i-1][j];
                continue;
            }
            chart[i][j]=(chart[i][j-1]+chart[i-1][j])%1000000007;
        }
    }
    cout<<chart[n-1][w-1]<<endl;
    return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;

    if(s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3624
H,W = map(int, input().split())
S = [list(input()) for _ in range(H)]

w_score = [[0]*W for _ in range(H)]
h_score = [[0]*W for _ in range(H)]

begin = -1
streak = 1
for hi in range(H):
    for wi in range(W):
        if begin == -1 and S[hi][wi]=='.':
            begin = wi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if wi ==W-1 or(begin != -1 and S[hi][wi]=='#'):
            if wi == W-1 and S[hi][wi]=='.':
                w_score[hi][wi]=streak
            for i in range(W)[begin:wi]:
                w_score[hi][i] = streak
            streak = 1
            begin = -1

# for s in w_score:
#     print(s)
# print('-'*10)

begin = -1
streak = 1
for wi in range(W):
    for hi in range(H):
        if begin == -1 and S[hi][wi]=='.':
            begin = hi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if hi ==H-1 or(begin != -1 and S[hi][wi]=='#'):
            if hi == H-1 and S[hi][wi]=='.':
                h_score[hi][wi]= streak
            for i in range(H)[begin:hi]:
                h_score[i][wi] = streak
            streak = 1
            begin = -1

# for s in h_score:
#     print(s)
# print('-'*10)

ans = 0
score = [[0]*W for _ in range(H)]
for hi in range(H):
    for wi in range(W):
        w =w_score[hi][wi] 
        h= h_score[hi][wi] 
        score_ = w+h
        score_ += -1 if w>0 and h>0 else 0
        ans = max(ans,score_)
        score[hi][wi] = score_
        
# for s in score:
#     print(s)

print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

array<vector<ll>,2> Dijkstra(vector<vector<ll>> g, vector<vector<ll>> w, ll istart){
    auto n = g.size();
    priority_queue<array<ll,2>> q;
    vector<ll> d(n, numeric_limits<ll>::max());
    vector<ll> prev(n, -1);

    d[istart] = 0;
    q.push(array<ll,2>{-0, istart});

    while(!q.empty()){
        auto u = q.top()[1]; q.pop();
        for(size_t i=0; i<g[u].size(); i++){
            auto v = g[u][i];
            auto alt = d[u] + w[u][i];
            if(alt < d[v]){
                d[v] = alt;
                prev[v] = u;
                q.push(array<ll,2>{-alt, v});
            }
        }
    }
    return array<vector<ll>,2>{d, prev};
}

int main()
{
    ll H, W;
    cin >> H >> W;
    ll aij, cij;
    vector<vector<ll>> g(10, vector<ll>(10, 0));
    vector<vector<ll>> w(10, vector<ll>(10, 0));
    vector<ll> A;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin >> cij;
            g[i][j] = j;
            //w[i][j] = cij;
            w[j][i] = cij;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> aij;
            if(aij==-1) continue;
            A.push_back(aij);
        }
    }

    auto d = Dijkstra(g,w,1)[0];

    ll res = 0;
    for(auto i : A){
        res += d[i];
    }
    cout<<res<<endl;

    return 0;
}


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

using namespace std;

int main() {
  for (;;) {
    int t, n, s = 0;
    cin >> t;
    if (!t) return 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int b, e;
      cin >> b >> e;
      s += e - b;
    }
    if (s >= t)
      cout << "OK" << endl;
    else
      cout << t - s << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

int r(){int x;cin>>x;return x;}

void solve() 
{   
    int n,k;cin>>n>>k;
    int a[n];REP(i,n)cin>>a[i];
    bool dp[k+1];REP(i,k+1)dp[i]=0;
    rep(i,1,k+1)REP(j,n){
        if(i>=a[j])dp[i]|=!dp[i-a[j]];
    }
    cout<<(dp[k]?"First":"Second")<<endl;
}

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


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

int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  int Lmax = 0;
  int Rmin = N;
  for(int i = 0; i < M; i++) {
    cin >> L[i];
    Lmax = max(Lmax, L[i]);
    cin >> R[i];
    Rmin = min(Rmin, R[i]);
  }
  if(Rmin - Lmax >= 0) cout << Rmin - Lmax + 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ll x[n],l[n];
    vector<pll> v;
    rep(i,0,n){
        cin>>x[i]>>l[i];
        v.push_back({x[i]-l[i],x[i]+l[i]});
    }
    sort(v.begin(),v.end());
    ll ans=0,now=-inf;
    rep(i,0,n){
        ll f=v[i].first,g=v[i].second;
        if(f>=now){
            ans++;
            now=g;
        }
        else{
            now=min(now,g);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<' '<<y<<' '<<z<<endl;
  return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.Map;
//import java.util.HashMap;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[][] map = { {"Sunny", "Cloudy"}, {"Cloudy", "Rainy"}, {"Rainy", "Sunny"} };
    
 	String s = sc.next();

    int i = 0;
    for ( i = 0; i < map.length; i++) {
      if (map[i][0].equals(s)) {
        break;
      }
    }
    String result = map[i][1];
    
    

    System.out.println(result);
  }
}



Measured memory_bytes: 26976
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w;
char s[50][50];
bool used[50][50];

struct grid { int x, y, c; };

int bfs() {
  queue<grid> que;
  que.push({ 0, 0, 0 });
  used[0][0] = true;

  bool goaled = false;
  int count = 0;
  while(!que.empty()) {
    grid gr = que.front(); que.pop();

    if(gr.x == h - 1 && gr.y == w - 1) {
      goaled = true;
      count = gr.c;
      break;
    }

    REP(i, 4) {
      int nx = gr.x + dx4[i];
      int ny = gr.y + dy4[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '.' && !used[nx][ny]) {
        used[nx][ny] = true;
        que.push({nx, ny, gr.c + 1});
      }
    }
  }

  return (goaled ? count : -1);
}

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

  cin >> h >> w;

  int sum = 0;
  REP(i, h) REP(j, w) {
    cin >> s[i][j];
    if(s[i][j] == '.') sum++;
  }

  int d = bfs();
  cout << (d == -1 ? -1 : ((sum - 1) - d)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, m, x[SIZE], d[SIZE];

  scanf("%d%d", &n, &m);


  for(int i=0;i<m;i++){
    scanf("%d", x+i);
  }
  sort(x, x+m);

  for(int i=0;i<m-1;i++){
    d[i] = x[i+1] - x[i];
    debug(d[i]);
  }

  sort(d, d+m-1);

  ll ans = 0;

  for(int i=0;i<m-n;i++)
    ans += d[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

template <typename T>
void print(T vec) { for(auto i : vec) cout<<i<<" ";}
template <typename T>
void print2D(T matrix) {for(auto vec:matrix) {print(vec);cout<<'\n';}}


int main() {
    int n;
    cin>>n;
    vector<int> A(n);
    for(int i =0;i<n;i++) cin>>A[i];
    vector<vector<ll>> dp(n+1, vector<ll>(n+1));
    auto sum = [&](int L, int R) {
        ll s= 0;
        for(int i= L; i<=R;i++) {
            s+=A[i];
        }
        return s;
    };
    
    for(int L = n-1;L>=0;L--) {
        for(int R = L; R<n;R++) {
            if(R == L) {
                dp[L][R] = 0;
            }
            else{
                dp[L][R] = 1e18+5;
                ll s = sum(L, R);
                for(int i=L;i<=R;i++) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R]+ s);
                }
            }
        }
    }
    //print2D(dp);
    cout<<dp[0][n-1]<<'\n';
    return 0;

}

Measured memory_bytes: 1536
import java.util.Scanner;


public class Main {
	
	private static int[] cache;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();

		// ボトムアップ型
		cache = new int[n + 1];
		cache[0] = 1;
		cache[1] = 1;
		for (int i = 2; i <= n; i++) {
			cache[i] = cache[i - 1] + cache[i - 2];
		}
		int ret = cache[n];
		
		System.out.println(ret);
		
         sc.close();
	}
}

Measured memory_bytes: 17304
#include <iostream>
#include <algorithm>
using namespace std;
long long int lcm(long long int c, long long int d);
int main()
{
    long long int a,b,c,d,res;
    
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    
long long int     p=b/c;
long long int     q=(a-1)/c;
long long int     r=b/d;
long long int     s=(a-1)/d;
long long int     t=b/lcm(c,d);
long long int     u=(a-1)/lcm(c,d);
    
    res=(b-(a-1))-(p-q+r-s-(t-u));
    
    printf("%lld",res);
    
}
long long int lcm(long long int c,long long int d)
{   
   long long  int p=(c*d)/__gcd(c,d);
    return p;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> t(n), v(n);
  REP(i, n) cin >> t[i];
  REP(i, n) cin >> v[i];
  vector<int> l(v), r(v);
  l[0] = 0;
  REP(i, n) {
    if (i > 0) chmin(l[i], r[i - 1]);
    chmin(r[i], l[i] + t[i]);
  }
  r[n - 1] = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (i + 1 < n) chmin(r[i], l[i + 1]);
    chmin(l[i], r[i] + t[i]);
  }
  // REP(i, n) cout << l[i] << ' ' << r[i] << '\n';
  double ans = 0;
  REP(i, n) {
    if (v[i] - l[i] + v[i] - r[i] <= t[i]) {
      ans += (l[i] + v[i]) * (v[i] - l[i]) / 2.0;
      ans += v[i] * (t[i] - (v[i] - l[i]) - (v[i] - r[i]));
      ans += (r[i] + v[i]) * (v[i] - r[i]) / 2.0;
    } else {
      double a = (r[i] - l[i] + t[i]) / 2.0;
      assert(a >= 0);
      ans += (l[i] + l[i] + a) * a / 2;
      ans += (r[i] + r[i] + t[i] - a) * (t[i] - a) / 2;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int n,m,a[100][100]={0},b[1000]={0},i,j,c[100]={0};
    scanf("%d%d",&n,&m);
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < m;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0;i < m;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < m;j++)
        {
            c[i] += a[i][j]*b[j];
        }
        printf("%d\n",c[i]);
    }
    return 0;

}

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

constexpr ll powm(ll x, ll y, ll mod = 1e9 + 7)
{
    ll ans = 1;
    while (y > 0) {
        if (y % 2) {
            ans = (ans * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}

constexpr ll nCr(ll n, ll r, ll mod = 1e9 + 7)
{
    auto min_r = min(r, n - r);
    ll x = 1;
    for (ll i = 0; i < min_r; i++) {
        x *= n - i;
        x %= mod;
    }
    ll y = 1;
    for (ll i = 0; i < min_r; i++) {
        y *= i + 1;
        y %= mod;
    }

    x *= powm(y, mod - 2, mod);
    return x % mod;
}

void main_()
{
    ll X, Y;

    cin >> X >> Y;

    if ((X + Y) % 3 != 0 || X > Y * 2 || Y > X * 2) {
        cout << 0 << endl;
        return;
    }

    auto dist = (X + Y) / 3;
    ll ans = nCr(dist, X - dist);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[100040] = {};
int main() {
	long long int n;
	cin >> n;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		dp[a]++;
		sum = sum + a;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		long long int b, c;
		cin >> b >> c;
		if (dp[b] > 0) {
			sum = sum + (c * dp[b] - b * dp[b]);
			dp[c] = dp[c] + dp[b];
			dp[b] = 0;
		}
		cout <<sum<< endl;
	}
}

Measured memory_bytes: 4340
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

 */
int n;
int main(){
  cin >> n;
  int ans=0;
  for(size_t i = 0; i * i <= n; i++)
  {
    ans = i * i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
ans = [0]
for i in range(len(s)):
    for j in range(len(s)):
        l = s[i:j+1]
        if  all(x=='A'or x=='C' or x=='G' or x=='T' for x in l):
            ans.append(len(l))
print(max(ans))
            

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


int main()
{
  int K,T;
  scanf("%d%d",&K,&T);
  int a[100];
  for(int i=0;i<T;i++){
    scanf("%d",a+i);
  }
  int M=0;
  for(int i=0;i<T;i++){
    M=max(M,a[i]);
  }
  printf("%d\n",max(0,M-1-(K-M)));
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a + b) / 2 + ((a + b) % 2 == 0 ? 0 : 1));
    }
}


Measured memory_bytes: 23636
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,W;
ll dp[101][100514]={0};
int main(){
	cin>>N>>W;
	rep(i,N){
		int w;
		ll v;
		cin>>w>>v;
		rep(nimo,W+1){
			dp[i+1][nimo]=dp[i][nimo];
			if(nimo>=w)dp[i+1][nimo]=max(dp[i+1][nimo],dp[i][nimo-w]+v);
		}
	}

	cout<<dp[N][W]<<endl;
}

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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = (int)1e6+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n;
int a[N];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin >> n;
    rep(i, 0, n+n) cin >> a[i];
    sort(a, a+n+n);
    ll res = 0;
    rep(i, 0, n+n) if (i % 2 == 0) res += a[i];
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256