akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    for(ll i = 0; i < n; i++) cin>>a[i];
    ll sum = 0;
    vl suff(n, 0);
    for(ll i = n - 2; i >= 0; i--)
        suff[i] = (suff[i + 1] + a[i + 1]) % MOD;
    //for(auto i : suff)
    //    cout<<i<<" ";
    for(ll i = 0; i < n; i++)
    {
        sum = (sum + (a[i] * suff[i]) % MOD) % MOD;
    }
    cout<<sum;
    
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 6348
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      m: usize,
    }

    let c2 = m/2;
    if n>=c2 {
        println!("{}", c2);
    } else {
        println!("{}", (m+2*n)/4);
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        
        n = n % 500;
        
        if(n > a){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int h = in.nextInt(), w = in.nextInt();
        char[][] areaCharred = new char[h][w];
        int[][] horizontalLight = new int[h][w];
        int[][] verticalLight = new int[w][h];
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < h; i++){
            areaCharred[i] = in.next().toCharArray();
        }
        for (int i = 0; i < h; i++){
            int prevH = 0;
            for (int j = 0; j < w; j++){
                if (areaCharred[i][j] == '#'){
                    Arrays.fill(horizontalLight[i], prevH, j, j - prevH);
                    prevH = j + 1;
                }
            }
            Arrays.fill(horizontalLight[i], prevH, w, w - prevH);
        }
        for (int i = 0; i < w; i++){
            int prevV = 0;
            for (int j = 0; j < h; j++){
                if (areaCharred[j][i] == '#') {
                    Arrays.fill(verticalLight[i], prevV, j, j - prevV);
                    prevV = j + 1;
                }
            }
            Arrays.fill(verticalLight[i], prevV, h, h - prevV);
        }
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                max = Math.max(horizontalLight[i][j] + verticalLight[j][i] - 1, max);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 115964
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
long long dp[100][100][5000]; long long n, k, x[100];
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> x[i]; dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 5000; k++) {
				if (dp[i][j][k] == 0)continue;
				dp[i + 1][j+1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; i++)sum += dp[n][i][k*i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 151808
using System;
using System.Text;

namespace ConsoleApplication{
    public class Program{
        static string answer;
        public static void Main(string[] args){
            answer = Console.ReadLine();
            int count = int.Parse(Console.ReadLine());
            
            for (int i = 0; i < count; i++){
                string[] input = Console.ReadLine().Split(' ');
                
                switch (input[0]){
                    case "replace":
                        answer = ReplaceAnswer(input);
                        break;
                    case "reverse":
                        answer = ReverseAnswer(input);
                        break;
                    default:
                        PrintAnswer(input);
                        break;
                }
            }
        }
        private static string ReplaceAnswer(string[] input){
            StringBuilder tempWords = new StringBuilder();

            tempWords.Append(answer.Substring(0,int.Parse(input[1])));
            tempWords.Append(input[3]);
            tempWords.Append(answer.Substring(int.Parse(input[2]) + 1));

            return tempWords.ToString();
        }
        private static string ReverseAnswer(string[] input){
            string reverseString = null;
            StringBuilder tempString = new StringBuilder();
            //reverse target string
            reverseString = answer.Substring(int.Parse(input[1]), (int.Parse(input[2]) - int.Parse(input[1])) + 1);
            for (int i = 1; i <= reverseString.Length; i++){
                tempString.Append(reverseString[reverseString.Length-i]);
            }
            reverseString = tempString.ToString();
            //replace target string
            string[] change = {"replace", input[1], input[2], reverseString};
            return ReplaceAnswer(change);
        }
        private static void PrintAnswer(string[] input){
            Console.WriteLine(GetTarget(input));
        }
        
        ///To get target strings from input
        private static string GetTarget(string[] input){
            StringBuilder temp = new StringBuilder();
            for(int i=int.Parse(input[1]); i<=int.Parse(input[2]); i++){
                temp.Append(answer[i]);
            }
            return temp.ToString();
        }
    }
}

Measured memory_bytes: 9040
n = int(input())
biga = []
for _ in range(n):
    a = float(input())
    a = round(a * 10 ** 9 + 0.1)
    biga.append(a)

def fact25(n):
    cnt2=0
    cnt5=0
    while n%2==0:
        n//=2
        cnt2+=1
    while n%5==0:
        n//=5
        cnt5+=1
    return cnt2,cnt5

arr = [[0 for _ in range(20)] for _ in range(20)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]+=1

ans=0
for i in range(20): # 2
    for j in range(20): # 5
        if arr[i][j]==0:
            continue
        for k in range(20): # 2
            for l in range(20): # 5
                if i+k>=18 and j+l>=18:
                    if i==k and j==l:
                        ans+= (arr[i][j]-1)*arr[k][l]
                    else:
                        ans+= arr[i][j]*arr[k][l]

print(ans//2)

Measured memory_bytes: 111640
n = int(input())
lis = [0]
lis2 = list(map(int,input().split()))
lis_a = lis+lis2
if n %2 ==0:
    flag_a = [0] * (int(n/2)+1)
    for i in range(int(n/2),n):
        flag_a.append(lis_a[i+1])
else:
    flag_a = [0] * (int(n//2)+1)
    for i in range((n//2),n):
        flag_a.append(lis_a[i+1])
for i in range((n//2),0,-1):
    temp_sum = 0
    j = 2
    while (i*j <=n):
        temp_sum += flag_a[i*j]
        j += 1
    if temp_sum % 2 == 0:
        if lis_a[i] == 1:
            flag_a[i] = 1
        else:
            flag_a[i] = 0
    else:
        if lis_a[i] == 1:
            flag_a[i] = 0
        else:
            flag_a[i] = 1

print(flag_a.count(1))
anslis = []
for i in range(n+1):
    if flag_a[i] == 1:
        anslis.append(i)
strin = ""
for item in anslis:
    strin += str(item) + " "
if len(anslis):
    print(strin)

Measured memory_bytes: 15536
import bisect

MAX = 50050

#エラトステネスの篩
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

while True:
  try:
    n = int(input())
    ind = bisect.bisect_left(primes, n)
    if primes[ind] == n:
      print(primes[ind - 1], primes[ind + 1])
    else:
      print(primes[ind - 1], primes[ind])

  except EOFError:
    break


Measured memory_bytes: 6088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    string o, e;
    cin >> o >> e;
    int n = max(o.size(), e.size());
    rep(i, n)
    {
        if (i < o.size())
            cout << o[i];
        if (i < e.size())
            cout << e[i];
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp>
  using namespace __gnu_pbds;
  using namespace std;
  #define int         long long
  #define mod         1000000007
  #define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  #define f(i,n)      for(int i=0;i<n;i++)
  #define fp(i,k,n)   for(int i=k;i<=n;i++)
  #define fr(i,k,n)   for(int i=k;i>=n;i--)
  #define pb          push_back
  #define pii         pair<int,int>
  #define vi          vector<int>
  #define vii         vector<pii>
  #define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
  #define F           first
  #define S           second
  #define sz(x)       (int)(x).size()
  #define lb          lower_bound
  #define ub          upper_bound
  #define mems(x)     memset(x,0,sizeof(x))
  #define all(a)      a.begin(),a.end()
  typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

  /*---------------------------------------------------------------------------------------------------*/

  void solve()
  {
    int k;
    cin >> k;
    if(k%2==0 || k%5==0)
      cout << "-1\n";
    else
    {
      int cnt=1;
      int ans=7;
      while((ans%k)!=0)
      {
        ans*=10;
        ans+=7;
        ans%=k;
        cnt++;
      }
      cout << cnt << '\n';
    }
    return;
  } 

  signed main()
  {
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    FAST
    int T=1;
    // cin >> T;
    while(T--)
    {
      solve();
    }
    return 0;
  }


Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x, y,z,w,h, sum= 0, ans = 0;
int main() {
    cin >> n;
    rep(i, n) {
        cin >> x;
        if (x % 2 == 1) ans = 1;
    }if (ans) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

	//ツ　0208 Room Numbers of a Hospital
	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//		String data = "1\n"+
//		BufferedReader reader = new BufferedReader(new StringReader(data));

		for(int loop = 0;;loop++) {
			
			String s = reader.readLine();
			int old = Integer.parseInt(s);
			if (old == 0)
				break;
			String oct = Integer.toOctalString(old);
			oct = oct.replace('7', '9');
			oct = oct.replace('6', '8');
			oct = oct.replace('5', '7');
			oct = oct.replace('4', '5');
			System.out.printf("%s\n", oct);
		}
		
		reader.close();
	}
}

Measured memory_bytes: 12000
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();

        int b = in.nextInt();

        if(b<a) a--;

        System.out.println(a);

        in.close();
    }

}


Measured memory_bytes: 21204
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#bfs内で処理すると使い回しが効かないのでsearch_color とか幅探索後の具体的な処理は別個にしたほうがいい
def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True

    #次見る頂点を格納するキュー
    queue=deque([s])

    visited_num=1

    #問題固有の配列
    ans=[-1 for _ in range(n)]
    ans[0]=0
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return []

        now_vertex=queue.popleft()
        #インデックスがない場合は
        #for next_vertex in node[now_vertex]:
        for each_node_arr in node[now_vertex]:
            #探索する頂点とインデックス
            next_vertex=each_node_arr[0]
            next_ind=each_node_arr[1]

            if check[next_vertex]==True:
                continue
            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            ans[next_vertex]=now_vertex+1
            visited_num+=1

    return ans



n,m=input_list()
node=[[] for _ in range(n)]
for i in range(m):
    u,v=input_list()
    u-=1
    v-=1
    node[u].append([v,i])
    node[v].append([u,i])

#print(np.array(node))

ans=bfs(0,n,node)
if len(ans)==0:
    print("No")
    exit()

print("Yes")
for each in ans[1:]:
    print(each)








Measured memory_bytes: 93444
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  int ans = INF;
  for (int i = -100; i <= 100; ++i) {
    int cost = 0;
    rep(j,n) {
      cost += (a[j] - i)*(a[j] - i);
    }
    ans = min(ans, cost);
  }

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

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

class Edge {
	Integer node;
	Integer d;

	Edge(Integer _n, Integer _d) {
		node = _n;
		d = _d;
	}
}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	boolean dfs(int idx, int newPos) {

		// 訪問済みノードの場合、記録済みの座標と新しい座標のチェックをする。（異なっていれば矛盾あり）
		if (!notVisited.contains(idx)) {
			if (pos.get(idx) == newPos) {
				return true;
			} else {
				return false;
			}
		}

		// 座標を記録し、未訪問ノードから削除する
		pos.put(idx, newPos);
		notVisited.remove(idx);

		int currentPos = newPos;
		List<Edge> edges = g.get(idx);
		for (Edge e : edges) {
			if (!dfs(e.node, currentPos + e.d)) {
				return false;
			}
		}
		return true;
	}

	Map<Integer, List<Edge>> g = new HashMap<>();
	Set<Integer> notVisited;
	Map<Integer, Integer> pos = new HashMap<>();

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		for (int i = 0; i < M; i++) {
			final int l = sc.nextInt();
			final int r = sc.nextInt();
			final int d = sc.nextInt();

			g.compute(l, (k, v) -> {
				if (v == null) {
					List<Edge> list = new ArrayList<>();
					list.add(new Edge(r, d));
					return list;
				} else {
					v.add(new Edge(r, d));
					return v;
				}
			});
			g.compute(r, (k, v) -> {
				if (v == null) {
					List<Edge> list = new ArrayList<>();
					list.add(new Edge(l, -d));
					return list;
				} else {
					v.add(new Edge(l, -d));
					return v;
				}
			});

		}

		sc.close();

		notVisited = new HashSet<>(g.keySet()); // 複製

		String ans = "Yes";

		Iterator<Integer> it;
		while ((it = notVisited.iterator()).hasNext()) {
			int idx = it.next();
			if (!dfs(idx, 0)) {
				ans = "No";
				break;
			}
		}

		out.println(ans);

	}

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

}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int L;

	cin >> L;

	int r = 0;
	while (pow(2, r) <= L)r++;
	r--;

	vector<tuple<int, int, int>> ans;
	rep(i, 1, r + 1)
	{
		ans.push_back(make_tuple(i, i + 1, 0));
		ans.push_back(make_tuple(i, i + 1, pow(2, i - 1)));
	}

	rrep(i, 1, r + 1)
	{
		if (pow(2, r) + pow(2, i - 1) <= L)
		{
			ans.push_back(make_tuple(i, r + 1, L - pow(2, i - 1)));
			L -= pow(2, i - 1);
		}
	}

	cout << r + 1 <<" "<< SZ(ans) << endl;
	for (auto t : ans)
	{
		cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int i,j,hoge,num,n,x[20],y[20],z[20];
	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		scanf("%d",&x[i]);
	}
	
	for(i = 0; i < n; i++){
		scanf("%d",&y[i]);
	}
	
	for(i = 0; i < n; i++){
		z[i] = x[i] - y[i];
	}
	
	for(i = 0; i < n-1; i++){
		for(j =i+1 ; j < n; j++){
			if(z[i] < z[j]){
				hoge = z[i];
				z[i] = z[j];
				z[j] = hoge;
			}
		}
	}
	
	num = 0;
	
	for(i = 0; i < n; i++){
		if(z[i] >= 0){
			num = num + z[i];
		}
	}
	
	printf("%d",num);
	
	return 0;
}

Measured memory_bytes: 128
use std::io;
use std::str::FromStr;
use std::u64::MAX;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

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

fn solve(cut_line: &Vec<u64>, chocolate: &Vec<Vec<char>>, limit: u64) -> u64 {
    let mut prev_cut = 0;
    let mut count = 0;
    let mut whites: Vec<u64> = vec![0; cut_line.len() - 1];
    for i in 0..(chocolate[0].len() - 1) {        
        for j in 0..(cut_line.len() - 1) {
            // println!("{}, {}", i, j);
            let mut white_count = whites[j];
            // println!("{}", white_count);
            for k in cut_line[j]..cut_line[j+1] {
                if chocolate[k as usize][i] == '1' {
                    white_count += 1;
                }
            }
            // println!("{}", white_count);
            if white_count > limit {
                return 100000000;
            }
            whites[j] = white_count;            
        }
        for j in 0..(cut_line.len() - 1) {
            let mut white_count = whites[j];
            for k in cut_line[j]..cut_line[j+1] {
                if chocolate[k as usize][i+1] == '1' {
                    white_count += 1
                }
            }
            if white_count > limit {
                count += 1;
                whites = vec![0; cut_line.len() - 1];
                break;
            }
        }
    }
    count
}

fn main() {
    let (h, w, k) = input_tuple();
    let mut chocolate: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let row: String = input();
        let row: Vec<char> = row.chars().collect();
        chocolate.push(row);
    }
    // println!("{:?}", chocolate);

    let mut min = MAX;

    for bit in 0..1<<(h-1) {
        let mut cut_line: Vec<u64> = Vec::new();
        cut_line.push(0);
        for i in 0..(h-1) {
            if bit & (1<<i) != 0 {
                cut_line.push(i + 1);
            }
        }
        cut_line.push(h);
        let buf = solve(&cut_line, &chocolate, k);
        if buf + cut_line.len() as u64 - 2 < min {
            min = buf + cut_line.len() as u64 - 2;
        }

        // println!("{:?}, {}", cut_line, buf);
    }
    println!("{}", min);
    
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N,K;
    cin>>N>>K;
    int c,d,x;

    c=N%K;
    if(c==0){
        cout<<0;
    } else{
        d=c-1;
        x=c-d;
        cout<<x;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;

	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
		for (int k = 1; k <= 9; k++)
		{
			if (k==9)
			{
				b++;
			}
			else if (x[i] < k*400)
			{
				if (y[k]!=1)
				{
					ans++;
				}
				y[k] = 1;
				break;
			}
		}
	}
	
	if (ans==0)
	{
		cout << 1 << endl;

	}
	else
	{
	cout << ans << endl;

	}
	cout << b+ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
using namespace std;
string a;
int v[30];
int main() {
	int i, j;
	cin>>a;
	for(i=0; a[i]; i++) v[a[i]-'a'] = 1;
	if(a.size()<26) {
		for(i=0; v[i]; i++);
		cout<<a<<(char)(i+'a');
		return 0;
	}
	for(i=24; i>=0 && a[i]>a[i+1]; i--);
	if(i==-1) {cout<<-1; return 0;}
	cout<<a.substr(0, i);
	for(j=25; a[j]<a[i]; j--);
	cout<<a[j];
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ar(n);
    rep(i,n){
        cin >> ar[i];
    }
    int cnt = 0;
    int mi;
    int e;
    int le, ri;
    rep(i,n-1){
        mi = ar[i];
        e = i;
        repp(j,n,i+1){
            if (mi > ar[j]){
                mi = ar[j];
                e = j;
            }
        }
        if (e != i){
            le = ar[e];
            ri = ar[i];
            ar[i] = le;
            ar[e] = ri;
            cnt++;
        }
    }
    rep(i,n-1){
        cout << ar[i] << " ";
    }
    cout << ar[n-1] << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <climits>

using namespace std;

void sbit(int &n, int i) {
    n |= (1<<i);
}

int cbit(int n, int i) {
    return n & (1<<i);
}

int main() {
    int N;
    cin >> N;

    vector<pair<int, int> > brush;
    vector<int> pats;
    for(int i = 0; i < N; ++i) {
        int h, w;
        cin >> h >> w;
        brush.push_back(make_pair(h, w));

        for(int bx = -4; bx <= 3; ++bx) {
            for(int by = -4; by <= 3; ++by) {
                int mask = 0;
                for(int x = 0; x < 4; ++x) {
                    for(int y = 0; y < 4; ++y) {
                        if(bx <= x && x < bx+w && by <= y && y < by+h) sbit(mask, y*4+x);
                    }
                }
                if(mask != 0) pats.push_back(mask);
            }
        }
    }

    vector<string> correct(4);
    for(int i = 0; i < 4; ++i) {
        cin >> correct[i];
    }

    int cmask[3] = {};
    {
        string cstr = "RGB";
        for(int i = 0; i < 3; ++i) {
            for(int y = 0; y < 4; ++y) {
                for(int x = 0; x < 4; ++x) {
                    if(correct[y][x] == cstr[i]) sbit(cmask[i], y*4+x);
                }
            }
        }
    }

    vector<int> memo(1<<16, INT_MAX);
    queue<pair<int, int> > q;

    int ans = 0;
    memo[0] = 0;
    q.push(make_pair(0, 0));
    while(!q.empty()) {
        int cost = q.front().first;
        int pat = q.front().second;
        q.pop();

        if(pat == 0xffff) {
            ans = cost;
            break;
        }

        //if(memo[pat] <= cost) continue;
        //memo[pat] = cost;

        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < pats.size(); ++j) {
                int mask = pats[j] & cmask[i];
                int next = pat;
                next &= ~pats[j];
                next |= mask;
                if(memo[next] == INT_MAX) {
                    memo[next] = cost+1;
                    q.push(make_pair(cost+1, next));
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define all int i=0; i<n; i++
#define pb push_back
#define pf push_front
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
#define INF 0x3f3f3f3f3f
#define mp make_pair
#define pii pair<int,int>
#define T int t;cin>>t;while(t--)
#define I 
#define think 
#define we 
#define should 

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
int abso(int k){
	if(k==0)return 0;
	else if(k<0) return -1*k;
	else return k;
}
int32_t main() 
{ 
	int n;
	cin>>n;
	int a[n];
	int b[n];
	int c[n];
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	dp[1][0] = max(dp[0][1], dp[0][2]) + a[1];
	dp[1][1] = max(dp[0][0], dp[0][2]) + b[1];
	dp[1][2] = max(dp[0][0], dp[0][1]) + c[1];
	for(int i=2; i<n; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}




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

int main(){
    string N;
    
    cin >> N;
    
    size_t size = N.length();

    
    int count = 0;
    if(size%2 == 0){
        for(int i=0;i<size/2;i++){
            if(N[i] != N[size-i-1]) {
                count=count+1;
        }
    }
    }
    else{
        for(int i=0;i<size/2;i++){
            if(N[i] != N[size-i-1]) count=count+1;
        }
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vl a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vl ans(n);
    for (ll i = n; i >= 1; --i) {
        ll x = a[i - 1];
        for (ll j = i + i; j <= n; j += i) {
            if (ans[j - 1]) x = 1 - x;
        }
        ans[i - 1] = x;
    }

    ll cnt = 0;
    for (ll i = 0; i < n; ++i) {
        cnt += ans[i];
    }

    cout << cnt << endl;
    for (ll i = 0; i < n; ++i) {
        if (ans[i]) cout << (i + 1) << " ";
    }
    cout << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  
  for(int i = 0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int c = 1;
  
  for(int i = 0;i<N-1;i++){
    if(v[i] != v[i+1]) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int count = 0;
		for (int i = 0; i < N; i++) {
			long x = sc.nextLong();
			long y = sc.nextLong();
			double d = Math.sqrt(x * x + y * y);
			if (d <= D) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  int N = SZ(S);
  int len = 7;
  for(int i=0;i<N;++i){
    int b = N-(len-i);
    if(b < 0 || N < b) continue;
    string t = S.substr(0, i) + S.substr(b);
    if(t == "keyence"){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int a = Integer.parseInt(S.substring(0,2));
		int b = Integer.parseInt(S.substring(2,4));
		boolean A=false;
		boolean B=false;
		if (1<=a && a<=12) {
			A=true;
		}
		if (1<=b && b<=12) {
			B=true;
		}
		
		if (A && B) {
			System.out.println("AMBIGUOUS");
		} else if (A && !B) {
			System.out.println("MMYY");
		} else if (!A && B) {
			System.out.println("YYMM");
		} else {
			System.out.println("NA");
		}

	}
}

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


int main(){
    int N, Y, a =0 , b=0,c=0 ;


    cin >>N >> Y;
    Y /= 1000;

    for(int i =0; i <= N; i++){
        for(int j =0; j <= N- i; j++ ){
            if (i * 10 + j * 5 + N-i-j == Y){
                cout << i << " "<< j << " " << N-i-j << endl;
                return 0;
    
            }

        }
    }
    cout << "-1 -1 -1" << endl;
    
    return 0;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n, cap, w[100], v[100];
long long dp[100][100001];
long long calc(int i, int c) {
	if (i == n) return 0;
	if (dp[i][c] != -1) return dp[i][c];
	long long res = calc(i + 1, c);
	if (w[i] <= c) res = max(res, calc(i + 1, c - w[i]) + v[i]);
	return dp[i][c] = res;
}
int main() {
	scanf("%d %d", &n, &cap);
	for (int i = 0; i < n; i++) scanf("%d %d", &w[i], &v[i]);
	memset(dp, -1, sizeof(dp));
	long long ans = calc(0, cap);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,N) for(ll i=0;i<N;++i)
using namespace std;
using ll = long long;

pair<ll, ll> search(vector<ll> &A, ll left, ll right) {
	if (right - left <= 2) return make_pair(left, right);
	ll first_third = left + (right - left)/3;
	ll second_third = left + 2*(right - left)/3;

	ll first_sum, second_sum;
	first_sum = second_sum = 0;
	REP(i,A.size()) first_sum += abs(A[i] - first_third);
	REP(i,A.size()) second_sum += abs(A[i] - second_third);
	//cout << "left = " << left << ", right = " << right << ", first_sum = " << first_sum << ", second_sum = " << second_sum << endl;
	// finding the minimal	
	if (first_sum < second_sum) {
		return search(A, left, second_third);
	} 
	else if (first_sum > second_sum) {
		return search(A, first_third, right);
	}
	return search(A, first_third, second_third);
}

int main () {
	ll N;
	cin >> N;
	vector<ll> A(N);
	// 0-base
	REP(i,N) {
		scanf("%lld", &A[i]);
		A[i] -= (i+1);
	}
	/// searching by ternary search
	//REP(i,N) cout << " " << A[i];
	//cout << endl;
	sort(A.begin(), A.end());
	pair<ll,ll> bounds = search(A, -1000000000, 1000000000);
	//cout << "b = " << b << endl;
	ll sum = 0;
	REP(i,A.size()) sum += abs(A[i] - bounds.first);
	for (ll b = bounds.first+1; b<=bounds.second; ++b) {
		ll temp = 0;
		REP(i,A.size()) temp += abs(A[i] - b);
		sum = min(sum, temp);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
s = list(input())
t = list(input())
u = len(s) - len(t) + 1

ans = 1000

for i in range(u):
    num = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            num += 1
    if num <= ans:
        ans = num

print(ans)

Measured memory_bytes: 9120
import math
import decimal

decimal.getcontext().prec = 112

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

a = decimal.Decimal(a)
b = decimal.Decimal(b)
c = decimal.Decimal(c)


if a.sqrt() + b.sqrt() < c.sqrt():
    ans = 'Yes'
else:
    ans = 'No'

'''
print(decimal.Decimal(math.sqrt(a)))
print(math.sqrt(b))
print(math.sqrt(c))
print(math.sqrt(a) + math.sqrt(b))
'''
'''
left_cal = a + b + 2 * math.sqrt(a * b)

if left_cal < c:
    ans = 'Yes'
else:
    ans = 'No'
'''
print(ans)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
  int n,m,i,j,b[1001][1001];
  char a[1001][1001];
  string s;
int main()
{
  cin>>n>>m;
  for (i=1;i<=n;i++)
    for (j=1;j<=m;j++)
      {
	   cin>>a[i][j];
	   b[i][j]=0;
      }
	  
  for (i=1;i<=n;i++)
    for(j=1;j<=m;j++)
	  if (a[i][j]=='#')
	    {
	      b[i][j-1]++;
	      b[i][j+1]++;
	      b[i-1][j-1]++;
	      b[i-1][j]++;
	      b[i-1][j+1]++;
	      b[i+1][j-1]++;
	      b[i+1][j]++;
	      b[i+1][j+1]++;
			  }  	
			  
  for (i=1;i<=n;i++)
    {
	for (j=1;j<=m;j++)
      if (a[i][j]=='#')
        cout<<'#';
      else
        cout<<b[i][j];
    cout<<endl;    
    }
}

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

int main() {
    int N;
    cin >> N;
    cout << fixed << setprecision(10);
    if ((N % 2) == 0) {
        cout << 0.5 << endl;
        return 0;
    }
    else {
        int n1 = N / 2;
        int n2 = N / 2 + 1;
        double prob = 1.0 * n2 / (n1 + n2) ;
        cout << prob << endl;
        return 0;
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

A.sort()
max_el = A[-1]
median = max_el//2
import bisect
median_ind = bisect.bisect_left(A,median)

if median_ind == 0:
    print(A[-1],A[0])
    exit()
if median_ind == N-1:
    print(A[-1],A[-2])
    exit()

abs_right = abs(A[median_ind]-median)
abs_left = abs(A[median_ind-1]-median)

if abs_right>abs_left:
    print(A[-1],A[median_ind-1])
    exit()

print(A[-1], A[median_ind])

Measured memory_bytes: 20124
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		mylist ls=new mylist();
		int n=Integer.parseInt(in.next());
		for(int i=0;i<n;i++)ls.insert(Integer.parseInt(in.next()));
		ls.unique();
		ls.printls();
		
	}

}

class node{
	int v;
	node prev,next;
}

class mylist{
	node END,NOW;
	int size;
	
	mylist(){
		END=new node();
		END.prev=END;
		END.next=END;
		size=0;
	}
	
	void insert(int n) {
		node NEW=new node();
		NEW.v=n;
		NEW.next=END;
		NEW.prev=END.prev;
		NEW.prev.next=NEW;
		END.prev=NEW;
		size++;
	}
	
	private void pdelete(node N) {
		NOW.next.prev=NOW.prev;
		NOW.prev.next=NOW.next;
	}
	
	void unique() {
		NOW=END.next;
		int n=NOW.v,dsize=0;
		NOW=NOW.next;
		for(int i=1;i<size;i++) {
			if(NOW.v==n) {
				pdelete(NOW);
				dsize++;
			}
			else n=NOW.v;
			NOW=NOW.next;
		}
		size-=dsize;
	}
	
	void printls() {
		NOW=END.next;
		for(int i=0;i<size-1;i++) {
			System.out.print(NOW.v+" ");
			NOW=NOW.next;
		}
		System.out.println(NOW.v);
	}
}


Measured memory_bytes: 73792
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
$ans=0
def dfs(s)
    return if N<s.to_i
    $ans+=1 if s.include?("7") and s.include?("5") and s.include?("3")
    dfs(s+"7")
    dfs(s+"5")
    dfs(s+"3")
end
dfs("0")
puts $ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.rbegin(), a.rend())
using namespace std;

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

    ll n, k;
    cin>>n>>k;
    if(k==1) return cout<<0<<"\n", 0;
    else if(n==0) return cout<<0<<"\n", 0;
    else if(n&2==0 && k==2) return cout<<0<<"\n", 0;
    else if(k==n) return cout<<0<<"\n", 0;
    else{
        n = n%k;
        cout<<min(n, abs(n - k))<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print((i + j) % 2 == 0 ? "#" : ".");
				}
				System.out.println();
			}System.out.println();
		}
	}
}

Measured memory_bytes: 26676
#include<stdio.h>
int main(){
  int a;
  int b;
  int c;
  int i;
  int check[10000];
  int count = 0;

  scanf("%d %d %d",&a,&b,&c);

  for(i = a;i <= b;i++){
    if(c%i == 0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ld a, b;
    cin >> a >> b;
    
    cout << fixed << setprecision(16) << (a/b) << endl;
    return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    LL K;
    R(s,K);
    char c;
    int one=0;
    REP(i,SZ(s)){
        if(s[i]=='1')one++;
        else{
            c=s[i];
            break;
        }
    }
    if(K<=one)W(1);
    else W(c);
    return 0;
}


Measured memory_bytes: 256