akhauriyash/Code-Regression huggingface dataset:
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;
use petgraph::algo::dijkstra;
use petgraph::Directed;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use ascii::{AsciiChar, AsciiString};
use itertools::concat;
use lazy_static::lazy_static;
use libm::*;
use petgraph::Graph;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use std::sync::Mutex;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// lazy_static! {
//     static ref H: Mutex<Vec<i32>> = Mutex::default();
//     static ref W: Mutex<Vec<i32>> = Mutex::default();
// }

//abc079-D
// #[fastout]
fn main() {
    input![h: usize, w: usize, c: [[i64; 10]; 10], a: [[i64; w]; h]];

    // Graph::
    let mut edges = Vec::new();

    for i in 0..10 {
        for j in 0..10 {
            //revert edge
            edges.push((j, i, c[i][j]));
        }
    }

    // N, E, Ty(directed or undirected), Ix(size))
    let g: Graph<usize, _, Directed, _> = Graph::from_edges(edges.into_iter());
    // eprintln!("{:?}", g);

    let index = g
        .node_indices()
        .find(|i| {
            // eprintln!("{:?}: {}", i, g[*i]);
            i.index() == 1
        })
        .unwrap();

    let shortest_paths = dijkstra(&g, index, None, |a| *a.weight());

    let mut ans = 0;
    for hh in 0..h {
        for ww in 0..w {
            if a[hh][ww] != -1 {
                let index = g
                    .node_indices()
                    .find(|i| i.index() == a[hh][ww] as usize)
                    .unwrap();

                ans += shortest_paths.get(&index).unwrap();
            }
        }
    }

    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);


Measured memory_bytes: 2604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

Pi p[3];

double Do(Pi A, Pi B, Pi C){
	double a = hypot(A.Fi - B.Fi, A.Se - B.Se);
	double b = hypot(B.Fi - C.Fi, B.Se - C.Se);
	double c = hypot(C.Fi - A.Fi, C.Se - A.Se);
	double s = (a+b+c) / 2;
	double S = sqrt(s * (s-a) * (s-b) * (s-c));
	double h = 2 * S / c;
	return S / (s + h);
}

void solve(){
	rep(i, 3)scanf("%d%d", &p[i].Fi, &p[i].Se);
	double ans = 0;
	rep(i, 3)ans = max(ans, Do(p[i], p[(i+1)%3], p[(i+2)%3]));
	printf("%.12f\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string a,b; cin >> a >> b;
    int n = stoi(a+b);

    REP(i,sqrt(n)+1){
        if(i*i==n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

char f[100];
int fl=0;

int main()
{
	scanf("%s",f+1);
	fl=strlen(f+1);
	for(int i=1;i<=fl-8;i++)
		printf("%c",f[i]);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
string u[256];
int main(){
	int n,m;
	cin >> n;
	bool op=0;
	rep(i,n) cin >> u[i];
	cin >> m;
	rep(i,m){
		string s;
		cin >> s;
		bool ok=false;
		rep(j,n){
			if(s==u[j]){
				if(op) cout << "Closed by " << s << endl;
				else cout << "Opened by " << s << endl;
				op=!op;
				ok=true;
				break;
			}
		}
		if(!ok) cout << "Unknown " << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
def main():
    MOD = 10**9 + 7
    N = int(input())
    C = [int(input()) - 1 for _ in range(N)]
    if N == 1:
        print(1)
        return
    # |---|
    # 1-2-1-2-2
    #   |---|
    latest_indices = [-1] * (2 * (10**5))
    next_indices = [-1] * N
    for cur_index, c in enumerate(C):
        latest_index = latest_indices[c]
        if latest_index >= 0:
            next_indices[latest_index] = cur_index
        latest_indices[c] = cur_index
    dp = [0] * N
    dp[0] = 1
    for cur_index in range(N - 1):
        next_index = next_indices[cur_index]
        if next_index > cur_index + 1:
            dp[next_index] += dp[cur_index]
            dp[next_index] %= MOD
        dp[cur_index + 1] += dp[cur_index]
        dp[cur_index + 1] %= MOD
    print(dp[N - 1])


if __name__ == '__main__':
    main()

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

struct garden
{
    int height, cnt;
};

int main()
{
    int n;
    garden v[100];

    while( cin >> n )
    {
        if( !n )
            break;

        for( int i = 0; i < 100; i++ )
        {
            v[i].height = 0;
            v[i].cnt = 0;
        }

        int a[n+1];
        for( int i = 0; i < n + 1; i++ )
            cin >> a[i];
        
        for( int i = 1; i < n + 1; i++ )
        {
            int x = a[i] - a[i-1];
            for( int j = 0; j < 100; j++ )
            {
                if( v[j].height == 0 )
                {
                    v[j].height = x;
                    v[j].cnt++;
                    break;
                }
                if( v[j].height == x )
                {
                    v[j].cnt++;
                    break;
                }
            }
        }

        int cnt = 0, maxv = 0;
        for( int i = 0; i < 100; i++ )
        {
            if( v[i].height == 0 )
                break;
            if( v[i].cnt > cnt )
            {
                cnt = v[i].cnt;
                maxv = v[i].height;
            }
        }

        for( int i = 1; i < n + 1; i++ )
        {
            int x = a[i] - a[i-1];
            if( x != maxv )
            {
                if( i < n && a[i+1] - a[i] != maxv )
                    cout << a[i] << endl;
                else if( i >= n )
                    cout << a[i] << endl;
                else
                    cout << a[i-1] << endl;
                break;
            }
        }
    }

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    if(S == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    for(ll i = 0;i < S.size();i++) {
        for(ll j = i;j < S.size();j++) {
            string temp;
            for(ll k = 0;k < S.size();k++) {
                if(k < i || j < k) temp.push_back(S[k]);
            }
            if(temp == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let x: Vec<i32> = (0..n).map(|_| read()).collect();

    let distance = x.iter().sum::<i32>() / n;
    let distance2 = (x.iter().sum::<i32>() + n - 1) / n;

    println!(
        "{}",
        std::cmp::min(
            x.iter().map(|x_i| (x_i - distance).pow(2)).sum::<i32>(),
            x.iter().map(|x_i| (x_i - distance2).pow(2)).sum::<i32>()
        )
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct Data{
    int a[100005], b[100005];
    int n;
    Data(){
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
    }
    void cul(){
        range(i,1,n + 1){
            a[i + 1] += a[i];
            b[i + 1] += b[i];
        }
    }
    void set(int _n){
        n = _n;
    }
    pair<int, int> get(int i, int j){
        return make_pair(a[j] - a[i], b[j] - b[i]);
    }
    void output(){
        rep(i,n + 1){ cout << a[i] << ' '; }
        cout << endl;
        rep(i,n + 1){ cout << b[i] << ' '; }
        cout << endl;
    }
};

int main(){
    Data s,t;
    {
        string x, y;
        cin >> x >> y;
        rep(i,x.size()){
            if(x[i] == 'A') s.a[i + 1]++;
            else s.b[i + 1]++;
        }
        rep(i,y.size()){
            if(y[i] == 'A') t.a[i + 1]++;
            else t.b[i + 1]++;
        }
        s.set(x.size());
        t.set(y.size());
    }
    s.cul();
    t.cul();
    //s.output();
    //t.output();


    int q;
    cin >> q;
    rep(i,q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        pair<int, int> x = s.get(a - 1, b);
        pair<int, int> y = t.get(c - 1, d);
        cout << ((x.first + x.second * 2) % 3 == (y.first + y.second * 2) % 3 ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 2228
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,ans;
string a,b,c;
int main()
{
	cin>>n>>a>>b>>c;
	for (int i=0;i<n;i++)
	{
		char t[3];
		t[0]=a[i];
		t[1]=b[i];
		t[2]=c[i];
		sort(t,t+3);
		int cnt=0;
		for (int j=1;j<3;j++) if (t[j]!=t[j-1]) cnt++;
		ans+=cnt;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();

    let mut ans = 0;
    let mut socket = 1;
    while socket < b {
        socket += a - 1;
        ans += 1
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
import numpy as np
h, w = map(int, input().split())
S = np.array([list(input()) for _ in range(h)]) == "."
U=np.zeros( (h,w),dtype=int )
D=np.zeros( (h,w),dtype=int )
L=np.zeros( (h,w),dtype=int )
R=np.zeros( (h,w),dtype=int )
for i in range(h):
    U[i]=(U[i-1]+1)*S[i]
    D[-i-1]=(D[-i]+1)*S[-i-1]
for j in range(w):
    L[:,j]=(L[:,j-1]+1)*S[:,j]
    R[:,-j-1]=(R[:,-j]+1)*S[:,-j-1]
print(np.max(U+D+R+L)-3)

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

int n,k,a[100011],b[100011];
long long ans = 0;
vector<int> ones;

int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;++i) scanf("%d %d",&a[i],&b[i]);
    for(int i = 0;i <= 30;++i)
        if(k & (1 << i)) ones.push_back(i);

    for(int j = 1;j <= n;++j)
        if((a[j] | k) == k) ans += b[j];
    for(int i = 0;i < ones.size();++i){
        long long tmp = 0;
        int x = k ^ (1 << ones[i]);
        for(int j = 0;j < ones[i];++j) x |= (1 << j);
        for(int j = 1;j <= n;++j)
            if((a[j] | x) == x) tmp += b[j];
        ans = max(ans,tmp);
    }
    cout << ans << endl;

    return 0;
}


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

#define MAX 1000000

bool v[MAX+1];

void set(int n){
	for (int i = n * 2; i < MAX; i += n){
		v[i] = true;
	}
}

int main(){
	int a,d,n;
	v[1] = true;
	for (int i = 2; i < MAX; i++){
		if (v[i]) continue;
		set(i);
	}

	while (1){
		cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0) break;
		int cnt = 0;
		for (int i = a;; i += d){
			if (!v[i]) cnt++;
			if (cnt == n){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2136
/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

macro_rules! eprintln (
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        x: i32,
    }

    // 全パターンを列挙しながら条件を満たすもののみカウント
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if 500 * i + 100 * j + 50 * k == x {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    vector<long long> num(3);
    cin >> num[0] >> num[1] >> num[2];
    cin >> n;
    sort(num.begin(),num.end());
    while(n--)  num[2]*=2;
    cout << num[0] + num[1] + num[2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}


//------------------------main function-------------------------------
void Main(){
    int N; cin >> N;
    for(int i = 9; i > 0; i--)if(N % i == 0 && N / i < 10){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}


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

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String str =  String.valueOf(n);
            out.println(str.contains("7") ? "Yes" : "No");
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 33944
#include<iostream>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
    int r, c;
    int num[101][101]={};
    cin>>r>>c;
    lp(i,r){
        lp(j,c){
            cin>>num[i][j];
        }
    }
    int sum=0;
    lp(i,r){
        lp(j,c){
            sum += num[i][j];
            num[r][c] = sum;
        }
    }
    lp(i,r){
        int sum=0;
        lp(j,c){
            sum += num[i][j];
            num[i][c] = sum;
        }
    }
    lp(j,c){
        int sum=0;
        lp(i,r){
            sum += num[i][j];
            num[r][j] = sum;
        }
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j) cout<<" ";
            cout<<num[i][j];
        }
        cout<<endl;
    }
    return 0;
    
}



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

const ll MOD = 1e9 + 7;

int main(){
 int K,T; cin >> K >> T;
  priority_queue<pair<int,int>> Q;

  for(int i = 0; i < T; i++){ int q; cin >> q; Q.push(make_pair(q,i));}
  
  vector<int> simulator;
  
  while( !Q.empty()){
    int p = Q.top().first; int q = Q.top().second;
    // qは種類、pはqの残りの数
    Q.pop();
    if( simulator.empty() || simulator.back()!= q || Q.empty()){
      simulator.push_back(q); p--;}
    else{
      int r = Q.top().first; int s = Q.top().second;
      Q.pop();
      simulator.push_back(s);
      r--;
      if( r != 0){ Q.push(make_pair(r,s));}}
    if( p != 0){Q.push(make_pair(p,q));}
  }
  int cnt = 0;
 for(int i = 1; i < (int) simulator.size(); i++){
   if(simulator[i] == simulator[i-1]){ cnt++;}}
  
  cout << cnt << endl; return 0;}
   
      
      
      

Measured memory_bytes: 384
input_1 = gets.split.map!(&:to_i)
input_2 = gets.split.map!(&:to_f)
if input_2.select{ |num| num >= (input_2.inject(:+) / (4 * input_1[1])).to_f }.length < input_1[1] then
  puts "No"
else
  puts "Yes"
end

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int N, M;
int A[5010];
int B[5010];
int dp[5010]; // Bテ」ツ?ッlengthテ」ツ?ォテ、ツクツ?ィツ?エ

int main() {

  cin >> N >> M;
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];

  int ans = 0;

  rep(s, M) {
    zero(dp);
    rep(i, N) {
      dp[i + 1] = max(dp[i + 1], dp[i]);
      if(s + dp[i] >= M) continue;
      if(A[i] == B[s + dp[i]]) {
        dp[i + 1] = max(dp[i + 1], dp[i] + 1);
      }
      ans = max(ans, dp[i + 1]);
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, a, b; cin >> n >> a >> b;
	vi h(n); rep(i, n) cin >> h[i];
	
	ll lo = 0, hi = 1e15, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		ll sum = 0;
		rep(i, n){
			//h[i] - a * x - b * (mid - x) <= 0
			double dx = (h[i] - 1.0 * b * mid + a - b - 1) / (a - b);
			if(dx <= 0) continue;
			
			ll x = (h[i] - b * mid + a - b - 1) / (a - b);
			sum += x;
		}
		if(sum <= mid) hi = mid;
		else lo = mid;
	}
	cout << hi << endl;
	return 0;
}

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

int main(void){
	char **c;
	int H,W;
	cin >> H;
	c = new char*[H];
	cin >> W;
	for(int i=0;i<H;i++) c[i] = new char[W];
	
	for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> c[i][j];
	
	
	for(int i=0;i<2*H;i++){
		for(int j=0;j<W;j++) cout << c[i/2][j];
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

L = read_int()[0]

def solve():
    return (pow(L/3, 3))

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3948
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)
	console.log(Math.max(A + B, A - B, A * B) + 0)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];
            for (var i = 0;; i++)
            {
                if (i % 2 == 0)
                {
                    c -= b;
                    if (c <= 0)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
                else
                {
                    a -= d;
                    if (a <= 0)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 28244
#include <iostream>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool color[8];
	fill(color, color + 8, false);
	int pro = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 400) color[0] = true;
		else if (a[i] < 800) color[1] = true;
		else if (a[i] < 1200) color[2] = true;
		else if (a[i] < 1600) color[3] = true;
		else if (a[i] < 2000) color[4] = true;
		else if (a[i] < 2400) color[5] = true;
		else if (a[i] < 2800) color[6] = true;
		else if (a[i] < 3200) color[7] = true;
		else pro++;
	}
 
	int count = 0;
	for (int i = 0; i < 8; i++) {
		if (color[i]) count++;
	}
	cout << max(1, count) << ' ' << count + pro << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = Vec::new();
    for _ in 0..n {
        v.push(get!(i32, i32, i32));
    }
    let mut now = (0, 0, 0);
    for i in 0..n {
        if (v[i].0 - now.0).abs() % 2 == (v[i].1 + now.1 - (v[i].2 + now.2)).abs() % 2 {
            if ((v[i].1 - now.1).abs() + (v[i].2 - now.2).abs()) <= v[i].0 - now.0 {
                now = v[i];
                continue;
            }
        }
        println!("No");
        return;
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;


int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a%b);
}

int main()
{
  int r,D,x;
  cin >> r >> D >> x;
  for(int i=0;i<10;i++){
    x = r*x - D;
    cout << x << "\n";
  }
}


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

int N;
vector<vector<int> > v;
vector<bool> used;

void rec(int n, vector<int> a){
    if(n == 0){
        v.push_back(a);
        return;
    }
    for(int i=0;i<N;i++){
        if(!used[i]){
            a.push_back(i+1);
            used[i] = true;
            rec(n-1, a);
            a.pop_back();
            used[i] = false;
        }
    }
    return;
}

int main(){
    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];
    }

    used.resize(N, false);
    rec(N,{});
    
    int a, b;
    for(int i=0;i<int(v.size());i++){
        if(v[i] == P) a = i;
        if(v[i] == Q) b = i;
    }
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 3256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;

int main(){
    int n;cin>>n;
    vector<pii> red(n),blue(n);
    for(int i=0;i<n;++i){
        int a,b;cin>>a>>b;
        red[i]=make_pair(a,b);
    }
    for(int i=0;i<n;++i){
        int c,d;cin>>c>>d;
        blue[i]=make_pair(c,d);
    }
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> used(n,false);
    int ans=0;
    for(int i=0;i<n;++i){
        int maxv=-1;
        int index=-1;
        for(int j=0;j<n;++j){
            if(!used[j]&&red[j].first<blue[i].first&&red[j].second<blue[i].second){
                if(red[j].second>maxv){
                    index=j;
                    maxv=red[j].second;
                }
            }
        }
        if(index!=-1){
            ans++;
            used[index]=true;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  rep(i, M)
  {
    cin >> s[i] >> c[i];
  }

  int ans = -1;

  rep(i, pow(10, N) + 1)
  {
    string num = to_string(i);
    if (num.size() != N)
      continue;
    bool is_ok = true;
    rep(i, M)
    {
      if (num[s[i] - 1] != c[i] + '0')
        is_ok = false;
    }
    if (is_ok)
    {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int gcd( int x, int y ){
	if( x < y ) swap(x, y);
    while (y > 0) {
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for( auto &i : a ) cin >> i;
	for( int i = 0; i < n-1; ++i ){
		a[i+1] = gcd(a[i], a[i+1]);
	}
	cout << a[n-1] << endl;
	return 0;
}

Measured memory_bytes: 640
import math
def factorization(n):
    fac_list = []
    tmp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            fac_list.append(cnt)
    if tmp != 1:
        fac_list.append(1)
    if fac_list == []:
        fac_list.append(1)
    return fac_list

n = int(input())
fac_list = factorization(n)
ans = 0

for x in fac_list:
    tmp = 1
    while x - tmp >= 0:
        x -= tmp
        tmp += 1
        ans += 1

print(ans if n != 1 else 0)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int min(int x,int y,int z){return min(x,min(y,z));}
inline int max(int x,int y,int z){return max(x,max(y,z));}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 3005
int f[N][N];
signed main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	f[a][b]=1;
	for(int i=a;i<=c;i++)
	{
		for(int j=b;j<=d;j++)
		{
			if(i==a&&j==b) continue;
			f[i][j]=sub(add(mul(f[i][j-1],i),mul(f[i-1][j],j)),mul(f[i-1][j-1],i-1,j-1));
		}
	}
	cout<<f[c][d]<<endl;
	return 0;
}




Measured memory_bytes: 38748
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2== 0) {
            System.out.println(n);
        } else {
            System.out.println(2*n);
        }

    }
}

Measured memory_bytes: 22484
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		string[] operands = Console.ReadLine().Split();
		var stack = new Stack<int>();
		foreach (var op in operands)
		{
			int output;
			if (int.TryParse(op, out output))
			{
				stack.Push(output);
			}
			else
			{
				int a = stack.Pop();
				int b = stack.Pop();
				switch (op)
				{
					case "+":
					stack.Push(b + a);
					break;
					case "-":
					stack.Push(b - a);
					break;
					case "*":
					stack.Push(b * a);
					break;
				}
			}
		}
		Console.WriteLine(stack.Pop());
	}
}

Measured memory_bytes: 10208
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll d,g;
vector<ll> c,p;

void input(){
    cin >> d >> g;
    c.resize(d);
    p.resize(d);
    for(int i=0;i<d;i++) cin >> p[i] >> c[i];
}

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

    ll res = 1<<29;
    for(int bit=0; bit < (1<<d); bit++){
        ll sum = 0;
        ll num = 0;
        for(int i=0;i<d;i++){
            if (bit & (1<<i)){
                sum += c[i] + p[i] * 100 * (i+1);
                num += p[i];
            }
        }
        if (sum >= g) res = min(num, res);
        else{
            for(int i=d-1; i>=0; i--){
                if (bit & (1<<i)) continue;
                for(int j=0; j<p[i]; j++){
                    if (sum >= g) break;
                    sum += 100 * (i+1);
                    num++;
                }
            }
            res = min(num, res); 
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
	int a, b, c, count=0;
	cin >> a >> b >> c;
	for (int i = a; i < b + 1; i++) {
		if (c % i == 0) {
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %lf", d, r, f);
	return 0;
}

Measured memory_bytes: 636
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    a, b = na()

    #a * i - (i-1) >= b
    c = ((b - 1) + (a - 2)) /(a - 1)
    print(int(c))


        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

#define MAX_N 200000

void printCompare(int n, int as[], int len);


int main()
{
    int n, k;
    int as[MAX_N];
    
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
	scanf("%d", &as[i]);
    }
    printCompare(n, as, k);

    return 0;
}


void printCompare(int n, int as[], int len)
{
    for (int i = 0; i < n - len; i++)
    {
        if (as[i] == 0)
        {
            printf("No\n");
            return;
        }
    }
    
    for (int i = 0; i < n - len; i++)
    {
        int former = as[i];
        int latter = as[i + len];

        if (former < latter)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


Measured memory_bytes: 2420
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,w = readline() |> split |> parseMap
	vw = Array{Int}(2,n)
	for i in 1:n
		vw[:,i] = readline() |> split |> parseMap
	end
	dp = zeros(Int,n,w+1)
	dp[1,vw[1,1]+1] = vw[2,1]
	for i in 2:n
		for j in 1:w
			if j-vw[1,i] >= 0
				dp[i,j+1] = max(dp[i-1,j+1],dp[i-1,j+1-vw[1,i]]+vw[2,i])
			else
				dp[i,j+1] = dp[i-1,j+1]
			end
		end
	end
	println(maximum(dp))
end

main()


Measured memory_bytes: 192924
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count=0;
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            
            if(h==0 && w==0){
                break;
            }else{
                while(true){
                    if(count==h)break;
                    System.out.print(write_odd(w));
                    System.out.println();
                    count++;
                    if(count==h)break;
                    System.out.print(write_even(w));
                    System.out.println();
                    count++;
                }
                System.out.println();
                count=0;
            }
        }
    }
    
    public static String write_odd(int w){
        String str ="";
        for(int i=1;i<w+1;i++){
           if(i%2!=0){ str = str+"#";}
           else{ str = str+".";}
        }
        return str;
    }
    
    public static String write_even(int w){
        String str ="";
        for(int i=1;i<w+1;i++){
           if(i%2!=0){ str = str+".";}
           else{ str = str+"#";}
        }
        return str;
    }
}

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

int main(){
  int64_t N;
  int64_t A,B;
  cin >> N >> A >> B;
  int64_t ans;
  ans = (N/(A+B))*A;
  int64_t x = N%(A+B);
  if(x>A){
    ans +=  A;
  }
  else{
    ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        n: usize,
        k: isize,
        x: [isize; n]
    }

    let mut ans = 0;
    for i in 0..n {
        ans += std::cmp::min(x[i], (k - x[i]).abs());
    }
    println!("{}", ans * 2);
}


Measured memory_bytes: 4352
typedef  long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<ll> d = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    std::cin >> k;
    std::cout << d[k-1] << std::endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0126 : Puzzle **/
int main()
{
	int board[9][9];
	bool wrong[9][9];
	int n;
	
	cin >> n;
	rep(k, n) {
		rep(y, 9) rep(x, 9)  {
			cin >> board[x][y]; board[x][y]--;
			wrong[x][y] = false;
		}

		int use[9];
		
		rep(i, 9) {
			// 横
			fill(use, use+9, -1);
			rep(j, 9) {
				int num = board[j][i];
				if (use[num]>=0) {
					wrong[j][i] = true;
					wrong[use[num]][i] = true;
				} else {
					use[num] = j;
				}
			}
			// 縦
			fill(use, use+9, -1);
			rep(j, 9) {
				int num = board[i][j];
				if (use[num]>=0) {
					wrong[i][j] = true;
					wrong[i][use[num]] = true;
				} else {
					use[num] = j;
				}
			}
			// 斜め
			fill(use, use+9, -1);
			int sx = (i%3)*3, sy = (i/3)*3;
			rep(ii, 3) {
				rep(jj, 3) {
					int num = board[sx+jj][sy+ii];
					if (use[num]>=0) {
						wrong[sx+jj][sy+ii] = true;
						wrong[sx+use[num]%3][sy+use[num]/3] = true;
					} else {
						use[num] = ii*3+jj;
					}
				}
			}
		}
		
		rep(y, 9) {
			rep(x,9) {
				if (wrong[x][y]) {
					cout << '*';
				} else {
					cout << ' ';
				}
				cout << ++board[x][y];
			}
			cout << endl;
		}
		if (k<n-1)
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(){
    int n,k,p,i,o;
    
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){

   		scanf("%d%d",&k,&p);
   		o=k%p;
        
        
   		if(o==0){
   		     printf("%d\n",p);
   		}
        
    	if(o!=0){
        	printf("%d\n",o);
    	}
        
    }      
    return 0;
}

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

using namespace std;

vector<int> A(100010);

int main() {
	
	int N,a;

	
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> a;
		A.at(i) = a;
	}

	int money = 0;
	int pos = 0;

	for (int j = 0; j < N+2; j++)
	{
		int dist = std::abs(pos - A[j]);
		money += dist;
		pos = A[j];
	}

	for (int i = 1; i <= N; i++)
	{
		int dist1 = std::abs(A[i-1] - A[i+1]);
		int dist2 = std::abs(A[i - 1] - A[i]) + std::abs(A[i] - A[i+1]);
		
		cout << money - std::abs(dist1 - dist2)  << endl;
	}

	return 0;
}


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

typedef long long ll;
typedef int i;
typedef string s;


#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(20);
    cout<<2*r*acos(-1);
    nl;
    return 0;
}



Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	printf("%d:" , h);
	printf("%d:" , m);
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 2728
#include<stdio.h>

int main(){
    char s[10];
    char t[10];
    int a,b;
    char u[10];

    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);

    int i = 0;
    int flag = 0;
    while(s[i] != '\0'){
        if(s[i] == u[i]){
            i++;
            flag = 1;
        }
        else{
            b = b-1;
            flag = 0;
            break;
        }
    }

    if(flag == 1){
        a = a-1;
    }

    printf("%d %d\n",a,b);

}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
int x,y;
  scanf("%d%d",&x,&y);
 
  for(int a=0;a<=x;a++){
    int b=x-a;
    if(2*a+4*b==y){printf("Yes");
                   return 0;
                  }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1728