akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
vector<long long> summing;
map<long long, long long> zip;
map<long long, long long> unzip;
long long segment_tree[10000000] = {};
void seg_set(long long now) {
	segment_tree[now] = segment_tree[now * 2] + segment_tree[now * 2 + 1];
	if (now != 1) seg_set(now / 2);
}
long long seg_find(long long left, long long right, long long want_left, long long want_right, long long now) {
	if (left >= want_right || right <= want_left) return 0;
	if (want_left <= left&&want_right >= right){
		return segment_tree[now];
    }
	return seg_find(left, (left + right) / 2, want_left, want_right, now * 2) + seg_find((left+right) / 2, right, want_left, want_right, now * 2 + 1);
}
int main() {
#define int long long
	long long ans = 0;
	long long n, k;
	cin >> n >> k;
	vector<long long> a;
	REP(i, n) {
		long long hoge;
		cin >> hoge;
		a.push_back(hoge-k);
	}
	summing.push_back(a[0]);
	for (int i = 1;i < a.size();++i) {
		summing.push_back(summing[i - 1] + a[i]);
	}
	for (int i = 0;i < a.size();++i) {
		if (summing[i] >= 0) ans++;
	}
	map<long long, long long> appeared;
	sort(summing.begin(), summing.end());
	int cnter = 0;
	for (int i = 0;i < a.size();++i) {
		if (appeared[summing[i]] == false){
			zip[summing[i]] = cnter;
			unzip[cnter] = summing[i];
			cnter++;
			appeared[summing[i]] = true;
		}
	}
	long long seg_size = 262144;
	for (int i = 0;i < summing.size();++i) {
		segment_tree[seg_size + zip[summing[i]]]++;
		seg_set((seg_size + zip[summing[i]]) / 2);
	}
	long long deleting = 0;
	for (int i = 0;i < a.size()-1;++i) {
		deleting += a[i];
		segment_tree[seg_size+zip[deleting]]--;
		seg_set((seg_size + zip[deleting]) / 2);
		long long top = cnter-1;
		long long bot = 0;
		while (top - bot > 1) {
			long long mid = (top + bot) / 2;
			if (unzip[mid] >= deleting) {
				top = mid;
			}
			else bot = mid;
		}
		long long consider = 0;
		if (unzip[bot] >= deleting) {
			consider = bot;
		}
		else if (unzip[top] >= deleting) {
			consider = top;
		}
		else goto nya;
		ans += seg_find(0,seg_size,consider,cnter, 1);
		nya:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 44656
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int x=a+b;
    int y=a-b;
    int z=a*b;
    if(x>=y&&x>=z){cout<<x;}
    else if(y>=x&&y>=z){cout<<y;}
    else{cout<<z;}
    return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n, cnt = 1;
	while(cin >> n,n){
		cout << "Case " << cnt << ": " << n << endl;
		cnt++;
	}

	return 0;
}

Measured memory_bytes: 1160
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let s: i64 = a.iter().sum();
    let x0: i64 = s - a
        .iter()
        .enumerate()
        .map(|(i, &a)| if i % 2 == 0 { 0 } else { 2 * a })
        .sum::<i64>();

    let mut x = vec![0; n];
    x[0] = x0;
    for i in 0..n - 1 {
        x[i + 1] = 2 * a[i] - x[i];
    }

    for x in x {
        print!("{} ", x);
    }
    println!();
}


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

# define ll long long

int countSteps(string s, char c){
  s = c + s + c;
  int prevPos = 0;
  int result = 0;
  for(int i=1; i<s.size(); i++){
    if(s[i] == c){
      result = max(result, i - prevPos - 1);
      prevPos = i; 
    }
  }
  return result;
}

int main(){
 
  string s;
  cin >> s;
  int ans = 1e9;
  for(char c : s){
    ans = min(ans, countSteps(s, c));
  }
  cout << ans << endl;
  
  return 0;
} 



Measured memory_bytes: 3632
from collections import deque

N=int(input())
a=[set() for v in range(N)] # 0-initial
for e in range(1,N):
    u,v,w=map(int,input().split())
    a[u-1].add((v-1,w))
    a[v-1].add((u-1,w))

d=[-1 for v in range(N)] # distance from 0

q=deque()
q.append(0);d[0]=0
while q:
    u=q.popleft()
    for v,w in a[u]:
        if d[v]==-1:
            d[v]=d[u]+w
            q.append(v)

for di in d:
    print(di%2)

Measured memory_bytes: 83872
#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;

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

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

/*permutation-id <-> sequence*/

#define MAX_DATASIZE 9

int encode(const int *data, int size){
  bool used[MAX_DATASIZE] = {};
  int num = 0;
  int t = 1;
  
  for(int i=1; i<=size; i++) t *= i;
  
  for(int i=size; i>=1; i--){
    t /= i;
    
    int s = 0;
    for(int j=0; j<data[size-i]; j++){
      if(!used[j]) s++;
    }
    
    used[data[size-i]] = true;
    num += s * t;
  }
  
  return num;
}

void decode(int num, int *data, int size){
  bool used[MAX_DATASIZE] = {};
  int t = 1;
  
  for(int i=1; i<=size; i++) t *= i;
  for(int i=size; i>=1; i--){
    t /= i;
    
    int s = num / t;
    for(int j=0;;j++){
      if(!used[j]){
        if(s == 0){
          data[size-i] = j;
          used[j] = true;
          break;
        }
        s--;
      }
    }
    num %= t;
  }
}



bool visited[9*8*7*6*5*4*3*2*1];

int bfs(const int pazzle[9]){
  queue<int> que;
  que.push(encode(pazzle, 9));

  int goal[9] = {1, 2, 3, 4, 5, 6, 7, 8, 0};
  int goalId = encode(goal, 9);
  
  for(int i=0;que.size();i++){
    queue<int> que2;
    while(que.size()){
      int id = que.front(); que.pop();
      if(visited[id]) continue;
      visited[id] = true;
      
      if(id == goalId) return i;

      int next[9];
      decode(id, next, 9);  

      for(int i=0;i<9;i++){  
        if(next[i] == 0){
          if(i/3 != 0){
            swap(next[i], next[i-3]);
            que2.push(encode(next, 9));
            swap(next[i], next[i-3]);
          }
          if(i/3 != 2){
            swap(next[i], next[i+3]);
            que2.push(encode(next, 9));
            swap(next[i], next[i+3]);
          }
          if(i%3 != 0){
            swap(next[i], next[i-1]);
            que2.push(encode(next, 9));
            swap(next[i], next[i-1]);
          }
          if(i%3 != 2){
            swap(next[i], next[i+1]);
            que2.push(encode(next, 9));
            swap(next[i], next[i+1]);
          }
          break;
        }
      }
    }
    que = que2;
  }

  return INF;
}

int main(){
  int pazzle[9];

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d", pazzle+(i*3+j));
    }
  }

  cout << bfs(pazzle) << endl;

  
  return 0;
}





Measured memory_bytes: 3880
import numpy as np

n, m, c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
a = np.array([[int(i) for i in input().split()] for _ in range(n)])

res = 0
for aa in a:
    if np.sum(aa*b)+c > 0:
        res += 1
print(res)


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

int main(){
	int h[10000], w[10000], i, j, k;
	for(i = 0; i <= 9999; i++){
		cin >> h[i] >> w[i];
		if((h[i] == 0) and (w[i] == 0)){
			break;
		}
	}
	
	for(i = 0; i <= 9999; i++){
		if((h[i] == 0) and (w[i] == 0)){
			break;
		}
		for(j = 1; j <= h[i]; j++){
			for(k = 1; k <= w[i]; k++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;

signed main(){
    int n;
    cin >> n;
    double ans = 1.0 * ((n+1)/2) / n;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 - i):
    if i * 10000 + j * 5000 + (n - (i + j)) * 1000 == y:
      print(i, j, n - (i + j))
      exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if(i % 2 ==0){
            if(S.at(i) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(S.at(i) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func sumDigits(x int) (sum int) {
	var r int
	for x != 0 {
		r = x % 10
		sum += r
		x /= 10
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)
	if n%sumDigits(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  vector< vector<double> > hoge;
  double n, d, tmp;
  int count = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++){
    vector<double> fuga;
    for (int v = 0; v < d; v++){
      cin >> tmp;
      fuga.push_back(tmp);
    }
    hoge.push_back(fuga);
  }

  for (int i = 0; i < n - 1 ; i++){
    vector<double> a;
    vector<double> b;
    a = hoge[i];
    for (int v = i + 1; v < n; v++){
      b = hoge[v];
      double sum = 0;
      for (int e = 0; e < d; e++){
        sum += pow(fabs(a[e] - b[e]), 2.0);
      }
      sum = pow(sum, 0.5);
      if (ceil(sum) == floor(sum)){
        count += 1;
      }else{
        // cout << sum << endl;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	int sum = 1;
	rep(i, N) {
		if (A[i] % 2 == 0) {
			sum *= 2;
		}
		else {
			sum *= 1;
		}
	}
	cout << pow(3, N) - sum << endl;
}


Measured memory_bytes: 640
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

#define M 1000000007

typedef long long int ll;
typedef long double ld;

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

	int n;

	cin >> n;

	cout << (n - 2) * 180 << endl;

	return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: usize, b: usize);
    let c = if a == 1 {
        if b == 2 {
            3
        } else {
            2
        }
    } else if a == 2 {
        if b == 1 {
            3
        } else {
            1
        }
    } else {
        if b == 1 {
            2
        } else {
            1
        }
    };
    println!("{}", c);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
  cin>>N;
  
  cout<<(N+1)*N/2-N<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
using namespace std;
typedef vector<int> vi;

const int N=105;
int a[N],n,K,mn,cur,last;
vi ans;

int main(){
	cin>>n>>K;
	rep(i,1,n)cin>>a[i];
	rep(i,1,K+1){
		mn=1e9,cur=0;
		rep(j,1,n)
			if(j!=last&&a[j]<mn)
				mn=a[j],cur=j;
		rep(j,1,n)
			if(j!=last&&j!=cur){
				ans.pb(j);
				if(!(a[j]--))return puts("-1"),0;
			}
		ans.pb(cur);
		if(!(a[cur]--))return puts("-1"),0;
		last=cur;
	}
	printf("%d\n",(int)ans.size());
	for(auto x:ans)printf("%d ",x);
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++)
    cin >> P[i];
  for (int i = 0; i < N; i++)
    cin >> Q[i];
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);
  int i = 1;
  int a = -1, b = -1;
  do
  {
    bool A = true, B = true;
    for (int j = 0; j < N; j++)
    {
      if (v[j] != P[j])
        A = false;
      if (v[j] != Q[j])
        B = false;
    }
    if (A)
      a = i;
    if (B)
      b = i;
    i++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }.sorted()


  var list = a
  var min = 0
  while (list.size > 1) {
    min = list[0]
    val list2 = mutableListOf<Int>()
    list2.add(min)
    for (i in 1 until list.size) {
      val tmp = list[i] % min
      list2.add(tmp)
    }
    list = list2.filter { it > 0 }.sorted()
  }

  println(min)


}

Measured memory_bytes: 63480
import           Control.Applicative
import           Control.Monad
import           Data.Foldable       (toList)
import           Text.Printf

import qualified Data.Sequence       as S

solve :: Int
      -> Int
      -> S.Seq (String, Int)
      -> S.Seq (String, Int)
      -> [(String, Int)]
solve q time result queue =
    case S.viewl queue of
        S.EmptyL -> toList result
        (s, t) S.:< xs
            | t <= q -> solve q (time + t) (result S.|> (s, time + t)) xs
            | otherwise -> solve q (time + q) result (xs S.|> (s, t - q))

main :: IO ()
main = do
    [_, q] <- fmap read . words <$> getLine :: IO [Int]
    ts <- fmap ((\[a, b] -> (a, read b)) . words) . lines <$> getContents :: IO [( String, Int)]
    let answer = solve q 0 S.empty (S.fromList ts)
    let print' = printf "%s %d\n"
    mapM_ (\(n, t) -> print' n t) answer



Measured memory_bytes: 47304
import java.io.*;
import java.util.Scanner;

class Main
{
    // Returns length of LCS for X[0..m-1], Y[0..n-1]
    static void lcs(String X, String Y, int m, int n)
    {
        int[][] L = new int[m+1][n+1];

        // Following steps build L[m+1][n+1] in bottom up fashion. Note
        // that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1]
        for (int i=0; i<=m; i++)
        {
            for (int j=0; j<=n; j++)
            {
                if (i == 0 || j == 0)
                    L[i][j] = 0;
                else if (X.charAt(i-1) == Y.charAt(j-1))
                    L[i][j] = L[i-1][j-1] + 1;
                else
                    L[i][j] = Math.max(L[i-1][j], L[i][j-1]);
            }
        }

        // Following code is used to print LCS
        int index = L[m][n];
        int temp = index;

        // Create a character array to store the lcs string
        char[] lcs = new char[index+1];
        lcs[index] = ' '; // Set the terminating character

        // Start from the right-most-bottom-most corner and
        // one by one store characters in lcs[]
        int i = m, j = n;
        while (i > 0 && j > 0)
        {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (X.charAt(i-1) == Y.charAt(j-1))
            {
                // Put current character in result
                lcs[index-1] = X.charAt(i-1);

                // reduce values of i, j and index
                i--;
                j--;
                index--;
            }

            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (L[i-1][j] > L[i][j-1])
                i--;
            else
                j--;
        }

        // Print the lcs
        //System.out.print("LCS of "+X+" and "+Y+" is ");
        for(int k=0;k<=temp;k++)
            System.out.print(lcs[k]);
    }

    // driver program
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String X = sc.next();
        String Y = sc.next();
        int m = X.length();
        int n = Y.length();
        lcs(X, Y, m, n);
    }
}

// Contributed by Pramod Kumar


Measured memory_bytes: 83276
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;


int main() {
    IO;
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)		 \
	for (auto i : v) \
		cout << i << ' ';

void solve() 
{
	string s;
	cin >> s;
	int ai = -1, zi;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A' && ai==-1)
			ai = i;
		if(s[i]=='Z')
			zi = i;
	}
	cout << zi - ai + 1;
}

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
using namespace std;
int m[8][8]={1,2,1,2,1,4,1,4,1,2,1,4,1,4,1,2,1,4,1,2,1,2,1,4,1,4,1,4,1,2,1,2,2,1,2,1,4,1,4,1,2,1,4,1,4,1,2,1,4,1,2,1,2,1,4,1,4,1,4,1,2,1,2,1};
int main(){
	int c[8];
	while(cin>>c[0]){
	for(int i=1;i<8;i++)cin>>c[i];
	int best=1000000000,set;
	for(int i=0;i<8;i++){
		int cnt=0;
		for(int j=0;j<8;j++){
			cnt+=max(0,c[j]-m[i][j]);
		}
		if(cnt<best){
			best=cnt;
			set=i;
		}
	}
	for(int i=0;i<7;i++){
		cout<<m[set][i]<<" ";
	}
	cout<<m[set][7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N,M = map(int,input().split())

flgs = [0]*M
for i in range(M):
	k,*vals = map(int,input().split())
	for v in vals:
		flgs[i] |= 1 << (v-1)

p = list(map(int,input().split()))

cnt = 0
for bit in range(2**N):
	cnt_tmp = 1
	for i,f in enumerate(flgs):
		if len([j for j in range(N) if ((f&bit) & (1<< j)) != 0]) % 2 != p[i]:
			cnt_tmp = 0
	cnt += cnt_tmp
print(cnt)

Measured memory_bytes: 43628
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
H, W, K = [int(_) for _ in input().split()]
C = [input() for i in range(H)]

def calc(lis):
    global C, K

    c = copy.copy(C)

    for i in lis:
        if i // 10 == 1:
            c[i%10-1] = "-" * W
        else:
            for j in range(H):
                tmp = list(c[j])
                tmp[i-1] = "-"
                c[j] = "".join(tmp)

    ct = 0
    for i in c:
        a = Counter(i)
        ct += a["#"]
    
    if ct == K:
        return 1
    return 0
                
count = 0
lis = list(range(1, W + 1)) + list(range(11, 10 + H + 1))

ret = 0
for i in range(H+W):
    for com in list(combinations(lis, i)):
        ret += calc(com)

print(ret)


Measured memory_bytes: 10464
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
print( max(0,N-ans))

Measured memory_bytes: 18656
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
//    int A, B, C; cin >> A >> B >> C;
    string S; cin >> S;

    if(stoi(S.substr(0,4)) <= 2019){
        if(stoi(S.substr(5,2)) <= 4) {
            if (stoi(S.substr(5, 2)) <= 30) cout << "Heisei";
            return 0;
        }
    }

    cout << "TBD";
    return 0;
//    cout << S.substr(0,4) << endl;
//    cout << S.substr(5,2) << endl;
//    cout << S.substr(8,2) << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;

    cin >> s;

    int len = s.size();
    char first = s[0];
    char last = s[len - 1];

    cout << first << len - 2 << last << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
w = [str(input()) for _ in range(n)]
w_split = [0]*n
res = "Yes"
for i in range(n) :
  w_split[i] = list(w[i])
for i in range(n-1) :
  if(w_split[i][-1] != w_split[i+1][0]) : res = "No"

set(w)
if(len(w) != len(set(w))) : res = "No"
print(res)

Measured memory_bytes: 3064
using System;

namespace ITP1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string[] inputs = Console.ReadLine().Split(' ');

                int height = Convert.ToInt32(inputs[0]);
                int width = Convert.ToInt32(inputs[1]);

                if (height == 0 && width == 0) break;

                for(int i = 0; i < height; i++)
                {
                    for(int j = 0; j < width; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5372
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

long long int w[107];
long long int v[107];
long long int dp[107][100007];
int main()
{
    int N,W;
    scanf("%d %d\n",&N,&W);
    for(int i=1; i<=N; i++)
    {
        scanf("%lld %lld\n",&w[i],&v[i]);
    }

    long long int v_max=0;
    for(int i=1;i<=N;i++){ v_max+=v[i]; }
    for(int i=1;i<=v_max;i++){ dp[0][i]=(long long int)1000000000*107; }
    for(int i=1;i<=N;i++)
    {
        for(int k=0;k<=v_max;k++)
        {
            if(k-v[i]>=0)
            {
                dp[i][k]=min(dp[i-1][k-v[i]]+w[i], dp[i-1][k]);
            }
            else
            {
                dp[i][k]=dp[i-1][k];
            }
        }
    }

    for(int i=v_max; i>=0;i--)
    {
        if(dp[N][i]<=W){ printf("%d\n",i); break; }
    }

    //printf("%lld\n",dp[N][W]);
    return 0;
}

Measured memory_bytes: 80000
import java.util.*;
public class Main {
  public static void main(String...args) {
    final Scanner sc = new Scanner(System.in);
    final char[] s = sc.next().toCharArray();
    final char[] t = sc.next().toCharArray();
    Arrays.sort(s);
    Arrays.sort(t);
    final int ans = new String(s).compareTo(new StringBuilder(new String(t)).reverse().toString());
    System.out.println(ans < 0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int len = T.length();
    int ans = len;
    for(int i=0; i<S.length()-len+1; i++) {
        int w = 0;
        for(int j=i, k=0; j<i+len; j++, k++) {
            if(S[j]!=T[k]) {
                w++;
            }
        }
        ans = min(ans, w);
    }
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
int main()
{
    int N;
    char YIN;
  
    int i=0;
    int j=0;
    scanf("%d", &N);
//    int k=0;
    for(i=0;i<N;i++){
      scanf("%c", &YIN);
      if('Y'==YIN){
        printf("Four\n");
        return 0;
      }
    }

  printf("Three\n");

return 0;
}


Measured memory_bytes: 128
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Feb  5 12:14:53 2019
//
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type tuple struct {
	t, x, y int
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()

	ts := make([]tuple, N)
	for i := range ts {
		ts[i].t, ts[i].x, ts[i].y = nextInt(), nextInt(), nextInt()
	}
	for i := range ts {
		var t, d int
		if i == 0 {
			t = ts[0].t
			d = abs(ts[0].x) + abs(ts[i].y)

		} else {
			t = ts[i].t - ts[i-1].t
			d = abs(ts[i].x-ts[i-1].x) + abs(ts[i].y-ts[i-1].y)
		}

		if t < d || (d-t)%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 4224
implicit none

character(10)s
integer:: counts=0,max_len=0
integer i,length

read(5,*) s

length=len_trim(s)

do i=1,length

if(s(i:i)=="A".or.s(i:i)=="C".or.s(i:i)=="G".or.s(i:i)=="T") then
counts=counts+1
max_len=max(max_len,counts)
else
 counts=0
endif

enddo

write(6,*) max_len







end

Measured memory_bytes: 256
def f(D):
    n = len(D)
    sum_ = 0
    for first in range(n):
        for second in range(first + 1, n):
            deliciousness = D[first] * D[second]
            sum_ += deliciousness
    return sum_

assert f([3, 1, 2]) == 11
assert f([5, 0, 7, 8, 3, 3, 2]) == 312

N = int(input())
D = list(map(int, input().split()))
ans = f(D)
print(ans)


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

int main (){
    int n;
    cin >> n;
    int A[n];
    int B[n];
    int C[n];

    for(int i=0;i<n;i++){
        int a,b,c;
        cin >> a >> b >> c;
        A[i] = a;
        B[i] = b;
        C[i] = c;
    }
    int a_happiness[n];
    int b_happiness[n];
    int c_happiness[n];
    a_happiness[0] = A[0];
    b_happiness[0] = B[0];
    c_happiness[0] = C[0];

    for(int i=1;i<n;i++){
        a_happiness[i] = max(b_happiness[i-1],c_happiness[i-1]) + A[i];
        b_happiness[i] = max(c_happiness[i-1],a_happiness[i-1]) + B[i];
        c_happiness[i] = max(a_happiness[i-1],b_happiness[i-1]) + C[i];
    }

    int maxi = max(a_happiness[n-1],b_happiness[n-1]);
    maxi = max(maxi,c_happiness[n-1]);

    cout << maxi << endl;

    return 0;
}


Measured memory_bytes: 5984
#include <stdio.h>

int main(void) {
	// your code goes here
	int N,X;
	scanf("%d %d",&N,&X);
	int arr[N];
	for (int i=0;i<N;i++){
	    scanf("%d",&arr[i]);
	}
	int D = 0;
	int count = 0;
	if (D<=X){
	    count++;
	}
	for (int i=1;i<=N;i++){
	    D = D + arr[i-1];
	    if (D<=X){
	        count++;
	    }
	    else{
	        break;
	    }
	}
	printf("%d\n",count);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

long long dp[3004][3004];

int main(){
  int A, B, C, D;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  int H = C-A;
  int W = D-B;
  long long mod = 998244353;
  dp[0][0]=1;
  for (int i=0; i<=H+W; i++){
    for (int h=0; h<=H; h++){
      int w=i-h;
      if (w<0 || w>W) continue;
      // delete
      if (h>0 && w>0){
	dp[h][w] -= dp[h-1][w-1]*(A+h-1)*(B+w-1);
	while (dp[h][w]<0){
	  dp[h][w] += mod;
	}
      }
      //printf("dp[%d][%d]=%lld\n", h, w, dp[h][w]);
      // add
      if (h+1<=H){
	dp[h+1][w] += dp[h][w]*(B+w);
	dp[h+1][w] %= mod;
      }
      if (w+1<=W){
	dp[h][w+1] += dp[h][w]*(A+h);
	dp[h][w+1] %= mod;
      }
    }
  }
  std::cout << dp[H][W] << std::endl;
  return 0;
}
 

Measured memory_bytes: 73656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int A, B, K;
	cin >> A >> B >> K;
	
	set<int> nums;
	for (int i = A; i <= A + K - 1; i++){
		nums.insert(i);
		if (i == B) {
			break;
		}
	}

	for (int i = B; i >= B - K + 1; i--) {
		nums.insert(i);
		if (i == A) {
			break;
		}
	}

	for (int v:nums) {
		cout << v << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    while(1){
        int a,b,i,j;
        cin >> a >> b;
        if(a==0 && b==0){
            break;
        }
        else{
            for(j=0; j<a; j++){
                if(j%2==0){
                    for(i=0; i<b; i++){
                        if(i==(b-1) && i%2==0){
                            cout << "#" << endl;
                        }
                        else if(i==(b-1) && i%2==1){
                            cout << "." << endl;
                        }
                        else if(i%2==0){
                            cout << "#";
                        }
                        else{
                            cout << ".";
                        }
                    }
                }
                else{
                    for(i=0; i<b; i++){
                        if(i==(b-1) && i%2==0){
                            cout << "." << endl;
                        }
                        else if(i==(b-1) && i%2==1){
                            cout << "#" << endl;
                        }
                        else if(i%2==0){
                            cout << ".";
                        }
                        else{
                            cout << "#";
                        }
                    }
                }
            }
            cout << endl;
        }
    }
    return 0;
}



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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;

 long double pi=3.14159;

signed main(){
	
	cin>>a;

	cout<<2*a*pi;

 return 0;
}


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

typedef struct
{
	string N;
	int M;
} Lottery;

class GreaterLength
{
public:
	bool operator() (const Lottery& lhs, const Lottery& rhs)
	{
		return lhs.N.size() > rhs.N.size();
	}
};

int main()
{
	int n, m;
	while (cin >> n >> m) {
		if (n == 0)
			break;

		vector<Lottery> l(n);
		for (int i = 0; i < n; ++i) {
			cin >> l[i].N >> l[i].M;
			l[i].N = l[i].N.substr(l[i].N.find_first_not_of("*"));
		}
		sort(l.begin(), l.end(), GreaterLength());

		int ans = 0;
		for (int i = 0; i < m; ++i) {
			string B;
			cin >> B;
			for (int j = 0; j < n; ++j) {
				if (B.find(l[j].N, B.size()-l[j].N.size()) != string::npos) {
					ans += l[j].M;
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 936
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i
    character(3):: n

    read*, n
    do i=1,3
        if (n(i:i) == '1') then
            n(i:i) = '9'
        else if (n(i:i) == '9') then
            n(i:i) = '1'
        end if
    end do
    print'(a)', n
end program main

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;



int main() {
    int N;
    string S;
    string check;
    int num = 0;

    cin >> N >> S;
    rep(i,1000){
        check = "000" + to_string(i);
        check = check.substr(check.size()-3,3);
        int point = 0;

        rep(j,S.size()){
            if(S[j] == check[point]){
                point+=1;
            }
            if(point > 3) break;
        }
        if(point > 2){
            num += 1;
        } 
    }

    cout << num;
}


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

int main() {
    int N, l, r;
    int seats = 0;
    cin >> N;

    for(int i = 0; i < N; i++) {
        cin >> l >> r;
        seats += r - l + 1;
    }

    cout << seats << endl;
}


Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main(){
    char b;

    cin >> b;

    switch(b){
        case 'A':
            b = 'T';
            break;
        case 'T' :
            b = 'A';
            break;
        case 'C':
            b = 'G';
            break;
        case 'G':
            b = 'C';
            break;
    }

    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int h,w;
string s[55];
int d[55][55];
vector<P> to[55][55];
int c;

void Push_back(int x,int y,int i,int j){
  if(i>=0 && j>=0 && i<h && j<w){
    if(s[x][y] == '.' && s[i][j] == '.'){
      to[x][y].push_back(P(i,j));
    }
  }
}

void bfs(){
  queue<P> q;
  q.push(P(0,0));
  d[0][0] = 1;
  while(!q.empty()){
    P t = q.front();q.pop();
    for(P nt : to[t.first][t.second]){
      int x=nt.first,y=nt.second;
      if(d[x][y]==-1 && s[x][y]=='.'){
        d[x][y] = d[t.first][t.second]+1;
        q.push(P(x,y));
      }
    }
  }
}

int main(){
  rep(i,0,55) rep(j,0,55) d[i][j]=-1;
  cin >> h >> w;
  rep(i,0,h) {
    cin >> s[i];
  }
  rep(i,0,h) rep(j,0,w){
    if(s[i][j] == '.')c++;
    Push_back(i,j,i-1,j);
    Push_back(i,j,i+1,j);
    Push_back(i,j,i,j+1);
    Push_back(i,j,i,j-1);
  }

  bfs();
  if(d[h-1][w-1]==-1)cout << -1 << endl;
  else cout << c-d[h-1][w-1] << endl;

  return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
    vector<int> a(5);
    int k;
    r(i,5)cin>>a.at(i);
    cin>>k;
    bool flag=1;

    r(i,5){
      r(j,5){
      if(abs(a.at(j)-a.at(i))>k)flag=0;
      
    }
  }
    if(flag)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;

return 0;}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		char[] c = sc.next().toCharArray();
		int n = c.length;
		StringBuilder s = new StringBuilder();
		for (int i = 0; i < n; i++) {
			if (c[i] == 'A' || c[i] == 'Z') {
				s.append(c[i]);
			}
		}
		c = s.toString().toCharArray();
		n = c.length;
		s = new StringBuilder();
		for (int i = 0; i < n; i++) {
			if (s.length() == 0 || s.charAt(s.length() - 1) != c[i]) {
				s.append(c[i]);
			}
		}
		if (0 < s.length() && s.charAt(0) == 'Z') {
			s.deleteCharAt(0);
		}
		if (0 < s.length() && s.charAt(s.length() - 1) == 'A') {
			s.deleteCharAt(s.length() - 1);
		}
		if (0 < s.length()) {
			System.out.println(s);
		} else {
			System.out.println(-1);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */
int main(){
    lint n, a, b; cin>>n>>a>>b;
    lint q = n / (a+b), m = n % (a+b);
    lint ans = q * a;
    if(m >= a) ans += a;
    else ans += m;
    out(ans);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String s = reader.readLine();
            System.out.println("2018" + s.substring(4));
        } catch (IOException e) {}
    }
}

Measured memory_bytes: 21332
# your code goes here
#grab
import math
e=int(input())
#e=1250
while e>0:
    z=0
    t=z**3
    f=e-t
    q=math.sqrt(f)
    y=int(q)
    if q-y>0.999999:
        y+=1
    x=y*y
    x=f-x
    m=x+y+z
    while t<=e:
        f=e-t
        q=math.sqrt(f)
        y=int(q)
        if q-y>0.999999:
            y+=1
        x=y*y
        x=f-x
        l=x+y+z
        if l<m:
            m=l
        z+=1
        t=z**3
    print(m)
    e=int(input())

Measured memory_bytes: 7724
#include <stdio.h>
#include <string.h>
int main(void) {
	int A,B,k,l,m;
	int mem = 0;
	int ans = 0;
	char s[6];
	scanf("%d %d", &A, &B);
	for(k=A;k<=B;k++)
	{
		mem = 0;
		sprintf(s,"%d",k);
		l=strlen(s);
		if(l%2 == 0)
		{
			for(m=1;m<=l/2;m++)	
			{	
				if(s[m-1] == s[l-m])
				mem++;
			}
			if(mem == l/2)
			ans++;
		}
		if(l%2 == 1)
		{
			for(m=1;m<=(l-1)/2;m++)
			{
				if(s[m-1] == s[l-m])
				mem++;
			}
			if(mem == (l-1)/2)
			ans++;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
 const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;
// const ll MAX = 1e6 + 1;

unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
unsigned long long factorial(int n)
{
    const unsigned int M = 1000000007;
 
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;  // Now f never can
                        // exceed 10^9+7
    return f;
}

// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCrModPFermat(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    unsigned long long fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
void solve()
{
   int n;
   cin>>n;
   if(n==1)
   {
       cout<<0;
       return;
   }
   int ans= power(10,n,PRIME);
   ans= (ans - (2*power(9,n,PRIME)%PRIME) +PRIME)%PRIME;
   ans= (ans + power(8,n,PRIME) )%PRIME ;
   cout<<ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // int k = 1;
    // cin >> t;
    t = 1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


Measured memory_bytes: 3652