akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Sequence as Sq
import Text.Printf
import Debug.Trace

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

readIntBS = fst . fromJust . BS.readInt

main :: IO ()
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  field <- map (map readIntBS . BS.words) . BS.lines <$> BS.getContents :: IO [[Int]]

  check <- newArray ((1,1),(w,h)) False :: IO (IOUArray (Int,Int) Bool)
  f <- newArray ((1,1),(w,h)) 0 :: IO (IOUArray (Int,Int) Int)

  forM_ (zip [1..h] field) $ \(y,l) -> do
    forM_ (zip [1..w] l) $ \(x,c) -> do
      writeArray f (x,y) c
  
  let
    solve :: StateT (Sq.Seq (Int,Int)) IO [(Int,Int,Int,Int)]
    solve = do
      queue <- get
      let ((x,y) Sq.:< rest) = Sq.viewl queue
      put rest

      s <- lift $ readArray f (x,y)

      when (x<w) $ do
        (lift $ readArray check (x+1,y)) >>= \checked -> unless checked $ (modify (Sq.|> (x+1,y)))
        lift $ writeArray check (x+1,y) True
      when (y<h) $ do
        (lift $ readArray check (x,y+1)) >>= \checked -> unless checked $ (modify (Sq.|> (x,y+1)))
        lift $ writeArray check (x,y+1) True
      
      if
        | x == w && y == h -> return []
        | otherwise -> do
            if
              | odd s -> do
                  if
                    | x == w -> (lift $ modifyArray f (x,y) (+(-1)) >> modifyArray f (x,y+1) (+1)) >> ((y,x,y+1,x):) <$> solve
                    | y == h -> (lift $ modifyArray f (x,y) (+(-1)) >> modifyArray f (x+1,y) (+1)) >> ((y,x,y,x+1):) <$> solve
                    | otherwise -> (lift $ modifyArray f (x,y) (+(-1)) >> modifyArray f (x+1,y) (+1)) >> ((y,x,y,x+1):) <$> solve
              | otherwise -> solve

  ans <- evalStateT solve (Sq.singleton (1,1))

  print $ length ans
  forM_ ans $ \(a,b,c,d) -> do
    printf "%d %d %d %d\n" a b c d
    

Measured memory_bytes: 31868
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int N, M;
vector<string> partTemp(int, int, vector<string>);

int main()
{
	cin >> N;
	cin >> M;
	vector<string> A(N);
	vector<string> B(M);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}
	
	for (int i = 0; i + M -1 < N ; i++)
	{
		for (int j = 0; j + M - 1 < N; j++)
		{
			vector<string> sub = partTemp(j, i, A);
			if (B==sub)
			{
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

vector<string> partTemp(int dx, int dy, vector<string> A)
{
	vector<string> part(M);
	for (int i = dy; i < dy+M; i++)
	{
		part[i-dy]=A[i].substr(dx, M);
	}
	return part;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    ll n,k;
    cin >> n >> k;
    pair<int,int> p[n];
    
    rep(i,0,n){
	int a,b;
	cin >> a >> b;
	p[i] = make_pair(a,b);
    }
    sort(p,p+n);
    
    ll s = 0;
    rep(i,0,n){
	s += p[i].sd;
	if(k <= s){
	    P(p[i].ft);
	    ret 0;
	}
    }
    return  0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int inf = ~(1 << 31);
constexpr ll llinf = ~(1LL << 63);
constexpr int mod = 1e9 + 7;
constexpr ld pi = 3.14159265358979323846L;

constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};
struct Pos { int x, y; };

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()
#define DEBUG cerr << "DEBUG: DONE" << endl;

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    ll a, b, x;
    cin >> a >> b >> x;

    auto f = [](ll n, ll x) -> ll {
        if (n == -1) return 0;
        return n/x + 1;
    };
    ll ans = f(b, x) - f(a-1, x);

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


Measured memory_bytes: 3672
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string s;
    cin >> s;

    int ans = INT_MAX;

    map<char, bool> M;
    for (int i = 0; i < s.size(); i++) M[s[i]] = true;

    for (int i = 0; i < 26; i++) {
        char c = (char) ('a' + i);
        if (!M[c])continue;

        int count = 0;
        string t = s;
        while (true) {
            bool good = true;
            for (int j = 0; j < t.size(); j++) if (t[0] != t[j]) good = false;
            if (good) break;
            string _t = "";
            for (int j = 0; j < t.size() - 1; j++) {
                if (t[j] == c || t[j + 1] == c) _t += c;
                else _t += t[j];
            }
            t = _t;
            count++;
        }
        ans = min(ans, count);
    }

    cout << ans << endl;

    return 0;
}




















































































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

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

    int n; cin >> n;
    string s; cin >> s;
    map<char, ll> m;
    ll ans = 0LL;
    rep(i,n) m[s[i]]++;
    ans = m['R']*m['G']*m['B'];

    rep(i,n){
        for(int j = i+1; j < n; ++j){
            int k = 2*j-i; if(j >= k || k >= n) continue;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	cin >> s;
	int count = 0;

	REP(i, 6){
		if (s[i] == '1') count++;
	}

	cout << count << endl;
}


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

vector<int> Input(const int n)
{
    vector<int> W;
    for(int i = 0; i < n; i++){
        int w;
        cin >> w;
        W.push_back(w);
    }
    return W;
}
 
bool IsAllLoaded(int P, vector<int>& W, int k)
{
    int TrackIndex = 0;
    int CurrentSum = 0;
    int i = 0;
    for(i = 0; i < W.size(); i++){
        if(W[i] > P){
            return false;
        }
        if(CurrentSum + W[i] > P){
            TrackIndex++;
            if(TrackIndex == k){
                return false;
            }
            CurrentSum = 0;
        }
        CurrentSum += W[i];
    }
    return true;
}
 
int Calc(vector<int>& W, int k)
{
    int Sum = accumulate(W.begin(), W.end(), 0 );
    int P = (Sum + k - 1) / k;
    while(!IsAllLoaded(P, W, k)){
        P++;
    }
    return P;
}
 
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> W = Input(n);
    int P = Calc(W, k);
    cout << P << endl;
    return 0;
}

Measured memory_bytes: 3532
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean OK=true;
        for(int i=1;i<=n;i++){
            if(i%3==0) System.out.print(" " + i);
            else{
                int x = i;
                while(OK){
                    if(x%10==3){
                        System.out.print(" " + i);
                        OK = false;
                    }
                    x /= 10;
                    if(x==0) OK = false;
                }
                OK = true;
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 28760
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var sn = Console.ReadLine().Trim().Split(' ');
            var nn = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var str = Console.ReadLine();

            if(str == sn[0]) nn[0]--;
            else nn[1]--; 
            Console.WriteLine($"{nn[0]} {nn[1]}");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <climits>

using namespace std;


int H, W;
char field[50][51];
int chkd[50][50];

void search(int px, int py, int score, int &min)
{
	if (px == W - 1 && py == H - 1)
	{
		if (min > score) min = score;
		return;
	}

	int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
	for (int i = 0; i < 4; i++)
	{
		int x = px + dx[i], y = py + dy[i];
		if (x < 0 || x >= W || y < 0 || y >= H) continue;
		if (chkd[y][x] <= score + 1) continue;
		if (field[y][x] == '#') continue;
		chkd[y][x] = score + 1;
		search(x, y, score + 1, min);
	}
}

int main()
{
	cin >> H >> W;

	int black = 0;
	for (int i = 0; i < H; i++)
	{
		cin >> field[i];
		for (int j = 0; j < W; j++)
		{
			if (field[i][j] == '#') black++;
			chkd[i][j] = INT_MAX;
		}
	}

	int ans = INT_MAX;
	search(0, 0, 0, ans);
	if (ans != INT_MAX)
		cout << (W * H - black - ans - 1) << endl;
	else
		cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define ARRAY_LENGTH(X) (sizeof(X) / sizeof(X[0]))

int main(){
    int N;
    int X[101];
    int buf = 2147483647;
    int sum,min;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    for(int i=1;i<ARRAY_LENGTH(X);i++){
        for(int j=0;j<N;j++){
            sum += (X[j]-i) * (X[j]-i);
        }
        if(buf>sum){
            min = sum;
            buf = min;
        } 
        sum = 0;
    }
    cout << min << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }

    int max_H = H[0];
    int ans = 1;
    for(int i = 1; i < N; i++) {
        if(H[i] >= max_H) {
            ans++;
            max_H = H[i];
        }
    }   

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] x = sc.IntArray();
        int[] x2 = x.OrderBy(i => i).ToArray();

        int m1 = x2[x2.Length / 2 - 1];
        int m2 = x2[x2.Length / 2];

        foreach (var num in x)
        {

            int answer = num <= m1 ? m2 : m1;
            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 40648
#include <iostream>

using namespace std;

int main(void)
{
  int age;
  
  cin >> age;
  
  if(age == 3 || age == 5 || age == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  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 rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

V<char> b = { 'A','C','G','T' };

int main() {
	
	string s;
	cin >> s;
	int cnt = 0, ans = 0;
	rep(i, s.size()){
		bool acgt = false;
		rep(j, 4)if (s[i] == b[j])acgt=true;
		if (acgt)cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;

}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0;i < n;i++)cin >> a[i];

    sort(a.begin(),a.end());
    
    if(n == 1){
        cout << 1 << endl;
    }
    else if(n % 2 == 0){
        int now = 1;
        for(int i = 0;i < n;i++){
            if(a[i] == a[i+1] && a[i] == now){
                now += 2;
                i++;
            }
            else{
                cout << 0 << endl;
                return 0;
            }
        }
        
        ll ans = 1;
        for(int i = 0;i < n/2;i++){
            ans *= 2;
            ans %= MOD;
        }

        cout << ans << endl;
    }
    else{
        if(a[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        
        int now = 2;
        for(int i = 1;i < n;i++){
            if(a[i] == a[i+1] && a[i] == now){
                i++;
                now += 2;
            }
            else{
                cout << 0 << endl;
                return 0;
            }
        }

        ll ans = 1;
        for(int i = 0;i < n/2;i++){
            ans *= 2;
            ans %= MOD;
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 640
N=int (input())
while N != 0:
    Jcou = 0
    JUE=[]
    for i in range(N):
        JUE.append(list(map(int, input().split())))
    M=int(input())
    RO=[10,10]
    for j in range(M):
        m1=list(map( str,input().split()))
        if(m1[0]=="N"):
            for k in range(int(m1[1])):
                RO[1]+=1
                if RO in JUE:
                    JUE.remove(RO)
                    Jcou+=1
        elif(m1[0]=="S"):
            for k in range(int(m1[1])):
                RO[1]-=1
                if RO in JUE:
                    JUE.remove(RO)
                    Jcou+=1
        elif(m1[0]=="E"):
            for k in range(int(m1[1])):
                RO[0]+=1
                if RO in JUE:
                    JUE.remove(RO)
                    Jcou+=1
        elif(m1[0]=="W"):
            for k in range(int(m1[1])):
                RO[0]-=1
                if RO in JUE:
                    JUE.remove(RO)
                    Jcou+=1
    if (Jcou == N):
        print("Yes")
    else :
        print("No")


    
    N=int(input())


Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> n_vec(n);
  std::iota(n_vec.begin(), n_vec.end(), 1);
  // std::vector<std::pair<int, int>>vec;
  std::vector<int> p_vec(n);
  std::vector<int> q_vec(n);
  for (int i = 0; i < n; i++)
  {
    std::cin>>p_vec[i];
  }
  for (int i = 0; i < n; i++)
  {
    std::cin>>q_vec[i];
  }
  // std::map<std::vector<int>> a;
  int first_ind = 0;
  int second_ind = 0;
  int count = 1;
  do{
    if(n_vec == p_vec){
      first_ind = count;
    }
    if(n_vec == q_vec){
      second_ind = count;
    }
    count ++;
  }while(std::next_permutation(n_vec.begin(), n_vec.end()));
  std::cout <<std::abs(first_ind - second_ind) << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      if(N%10==2 || N%10==4 || N%10==5 || N%10==7 || N%10==9){
        System.out.println("hon");
      }else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
        System.out.println("pon");
      }else if(N%10==3){
        System.out.println("bon");
      }
    }
}

Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

template<typename T>
T gcd(T a, T b) {
    if(b == 0){
        return a;
    }else if(a == 0){
        return b;
    }else{
        return gcd(b, a % b);
    }
}

template<typename T>
T lcm(T a,T b){
    if(a == 0||b == 0){
        return 0;
    }else{
        return (a/gcd(b, a % b))*b;
    }
}
int main(){

    llint n,k;
    cin>>n>>k;
    n -= (n / k) * k;
    llint result = n;
    REP(i,10000){
        n = abs(n - k);
        result = min(n, result);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 500009
using namespace std;
 
int n,m,q[N];
struct node{ double x,y,z; }a[N];
int main(){
	scanf("%d%d",&n,&m);
	int i,k,head=1,tail=0; double now=0,ans=0;
	for (i=1; i<=n; i++){
		scanf("%lf%lf",&a[i].x,&a[i].y);
		ans+=a[i].x*a[i].y;
		a[i].z=now=now+a[i].y;
		for (; head<=tail && a[k=q[head]].z<=now-m; head++)
			ans-=a[k].x*a[k].y;
		ans-=a[k].x*a[k].y;
		a[k].y=a[k].z-(now-m);
		ans+=a[k].x*a[k].y;
		for (; head<=tail && a[k=q[tail]].x>a[i].x; tail--){
			a[i].x=(a[i].x*a[i].y+a[k].x*a[k].y)/(a[i].y+a[k].y);
			a[i].y+=a[k].y;
		}
		q[++tail]=i;
		printf("%.10f\n",ans/m);
	}
	return 0;
}

Measured memory_bytes: 24192
#include<stdio.h>
int main(){
  int i,day,num,vol,total,ans;
  total = 0;
  scanf("%d%d",&day,&num);
  for(i=0;i<num;i++){
    scanf("%d",&vol);
    total = total + vol;
  }
  ans = day - total;
  if(ans<0)
    ans = -1;
  printf("%d\n",ans);
  return 0;
}

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


#define INF 1000000000000


signed main()
 {
   int c[3][3];
   rep(i,3){
     rep(j,3){
       cin>>c[i][j];
     }
   }
int sa1,sa2;
sa1=c[0][1]-c[0][0];
sa2=c[0][2]-c[0][1];
rep(i,2){
  if(c[i+1][1]-c[i+1][0]!=sa1||c[i+1][2]-c[i+1][1]!=sa2){
    cout<<"No";
    exit(0);
  }
}
cout<<"Yes";

 }


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif










int main(int argv, char* argc[])
{
    FASTIO

    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";

    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int i=0;
  char s[101];
  scanf("%s",&s);
  printf("%c",s[0]);
  while(s[i]!='\0'){
    i++;
  }
  printf("%d",i-2);
  printf("%c",s[i-1]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int a[56];

int pcheck(int p){
  int i;
  for (i=2;i<=sqrt(p);++i){
    if (p%i==0) {
      return 1;
    }
  }
  return 0;
}

int main(){
  int N,M=0,p,i;
  cin >> N;
  p=11;
  while (M < N) {
    if (pcheck(p) == 0) {
      a[M]=p;
      M++;
    }
    p+=10;
  }
  for (i=0;i<N;++i) {
    cout << a[i];
    if (i <N-1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import math

n = int(input())

ans = 0
MOD = 10**9 + 7
if (n == 2):
    ans = 2
elif (n < 2):
    ans = 0
else:
    ans = ((10 ** n) - (2 * 9**n) + 8**n) % MOD 
print(ans)


Measured memory_bytes: 11052
a=->q{
puts"? "+q*" "
$>.flush
gets
}
s="! "
I=[*1..2*N=gets.to_i]
f=a[I[0,N]]
l,r=0,N
f==a[I[m=(l+r)/2,N]]?l=m:r=m while r-l>1
x=I[r,N-1]
I.map{|i|
s+=a[[i]+(x.index(i)?I-I[l,N+1]:x)][0]
}
puts s

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

int main() {
	int N, red = 0, blue = 0;
	string s;
	cin >> N >> s;

	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') {
			red++;
		}
		else {
			blue++;
		}
	}
	if (red > blue) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fir first
#define sec second
#define MOD 1000000007
#define vvi vector<vector<int> >
#define vvs vector<vector<string> >
#define ss string
#define pa pair<int, int>
#define pp pair<int, pa>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vvl vector<vl>
#define loopin(i, n) for(int i = 0; i < (n); i++)
#define loopa(i, a, n) for(int i = a; i <= (n); i++)
#define loopdec(i, n) for(int i = n-1; i >= 0; i--)
const int mod=1e9+7;


void solve(){
	int n,l;
	cin>>n>>l;
	vs s;
	for(int i=0;i<n;i++){
		string temp;
		cin>>temp;
		s.pb(temp);
	}
	sort(s.begin(),s.end());
	string ans="";
	int i=0;
	while(i<s.size()){
		ans=ans+s[i];
		i++;
	}
	cout<<ans<<endl;


}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>ws;

        solve();


return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>

int main(void) {
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			printf("%d\n",a+b);
		}
		else if(op=='-'){
			printf("%d\n",a-b);
		}
		else if(op == '*'){
			printf("%d\n",a*b);
		}
		else if(op == '/'){
			printf("%d\n",a/b);
		}
		else {
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
using namespace std;

int main(int argc, char** argv)
{
	int a, b;
	scanf("%d%d", &a, &b);
	for(int x=0; ; x++)
	{
		int ya = x * 0.08, yb = x * 0.1;
		if(ya > a || yb > b)
		{
			puts("-1");
			return 0;
		}
		if(ya == a && yb == b)
		{
			printf("%d\n", x);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
main=putStrLn.solve.unfoldr(B.readInteger.B.dropWhile isSpace)=<<B.getContents
solve[a,b]=case compare a b of
  GT -> "GREATER"
  LT -> "LESS"
  EQ -> "EQUAL"

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

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);++i)

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main(void){

  int a,ans;
  cin>>a;
  ans=a+a*a+a*a*a;
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 3612
def bubble_sort(A):
    can_continue = True
    i = 0
    global count
    while can_continue:
        can_continue = False
        for j in range(i, len(A)-1):
           if A[j+1] < A[j]:
                A[j], A[j+1] = A[j+1], A[j]
                count += 1
                can_continue = True
        if not can_continue:
            i += 1
            can_continue = True
        if i >= len(A)-1:
            break

n = int(input())
A = list(map(int, input().split()))
count = 0
bubble_sort(A)
print(*A)
print(count)


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


void in(){
    
}

void solve(){

    map<string, int> mp;
    int n; cin >> n;

    while(n--){
        string t; cin >> t;
        mp[t]++;
    }

    int m; cin >> m;
    while(m--){
        string t; cin >> t;
        mp[t]--;
    }

    int ans = 0;
    for(auto e : mp){
        ans = max(ans, e.second);
    }

    cout << ans << endl;


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdlib>

using namespace std;
typedef long long int ll;

bool debug = false;
#define show(x) if (debug) {cout << "" # x << " = " << x << endl;}
#define rep(x, a, b) for (int x = a; x < b; x++)

int main()
{
  int k, t;

  cin >> k >> t;

  vector<int> a(t);

  rep (i, 0, t) {
    cin >> a[i];
  }

  sort(a.begin(), a.end(), [](auto x, auto y){return x > y;});

  cout << max(2 * a[0] - k - 1, 0) << endl;
  
  return 0;
}


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

using ll = long long;

int main() {
    int T, D, L;
    while(cin >> T >> D >> L, T) {
        int now = 0;
        int res = 0;
        for(int i = 0; i < T; ++i) {
            int x;
            cin >> x;
            res += now > 0;
            now--;
            if(x >= L) {
                now = D;
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string s;   cin >> s;
    vector<char>ans;
    rep(i, s.size()){
        switch(s[i]){
            case '0':
            ans.push_back('0');
            break;
            case '1':
            ans.push_back('1');
            break;
            case 'B':
            if(!ans.empty()){
                ans.pop_back();
            }
            break;
        }
    }
    rep(i, ans.size()){
        printf("%c", ans[i]);
    }
    printf("\n");
}


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

fn main() {
    let (n, w) = scan!(usize, usize);
    let items = scan!(i64,i64;n);

    let mut dp = vec![vec![0; w + 1]; n + 1];
    for i in 0..items.len() {
        for j in 0..dp[i].len() {
            if j >= items[i].0 as usize {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - items[i].0 as usize] + items[i].1)
            } else {
                dp[i + 1][j] = dp[i][j]
            }
        }
    }

    println!("{}", dp[n].iter().max().unwrap())
}


Measured memory_bytes: 106748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long N,X,s;
  vector<long long> S;
  long long inf=1000000007;
  cin>>N>>X;
  for(int i=0;i<N;++i){
    cin>>s;
    S.push_back(s);
  }
  long long dp[210][100010]={};
  sort(S.begin(),S.end(),std::greater<long long>());
  dp[0][X]=1;
  long long tmp;
  for(int i=0;i<N;++i){
    tmp=S[i];
    for(int j=0;j<=X;++j){
      dp[i+1][j]+=dp[i][j]*(N-1-i);
      dp[i+1][j]%=inf;
      dp[i+1][j%tmp]+=dp[i][j];
      dp[i+1][j%tmp]%=inf;
    }
  }
  
  long long ans=0;
  for(int i=0;i<=X;++i){
    ans=ans+dp[N][i]*i;
    ans%=inf;
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 164352
S = input()

arr = [[]]
renzoku = True
for char in S:
    if char in ["A","C", "G", "T"]:
        if renzoku:
            arr[-1].append(char)
        else:
            arr.append([char])
            renzoku = True
    else:
        renzoku = False

leng = []
for a in arr:
    leng.append(len(a))
print(max(leng))

Measured memory_bytes: 3064
H, W = map(int, input().split())
a = [[int(j) for j in input().split()] for i in range(H)]
N = 0
ans = []
for i in range(H):
    for j in range(W):
        if a[i][j] % 2 == 0:
            continue
        if i + 1 >= H and j + 1 >= W:
            continue
        ti = i
        tj = j
        if i + 1 >= H:
            tj += 1
        else:
            ti += 1
        a[i][j]-=1
        a[ti][tj] += 1
        N += 1
        ans.append((i+1,j+1,ti+1,tj+1))

print(N)
for i in ans:
    print(*i)

Measured memory_bytes: 26540
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000


using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1e18 + 5;
const ll MAX_N = 1e5 + 5;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str{
    ll a, b;
};

vector<ll> adj[MAX_N];
ll dp[MAX_N];
ll ans = 1;
void _dfs(ll s) {
    dp[s] = 1;
    
    // cout << "s " << s << endl;


    for(ll i = 0; i < adj[s].size(); i++) {
        ll ch = adj[s][i];
        if(dp[ch] == 0) {
            _dfs(ch);
        }
        dp[s] = max(dp[s], dp[ch] + 1);
    }
}


void solve(){
    ll n, m;
    cin >> n >> m;
    ll u, v;
    ll in_deg[n + 1];
    memset(in_deg, 0, sizeof(in_deg));
    for(ll i = 0; i < m; i++) {
        cin >> u >> v;
        in_deg[v] += 1;
        adj[u].push_back(v);
    }

    // cout << "in_deg ";
    // for(ll i = 1; i <= n; i++) {
    //     cout << in_deg[i] << " ";
    // }cout << endl;

    memset(dp, 0, sizeof(dp));
    for(ll i = 1; i <=n; i++) {
        if(in_deg[i] == 0) {

            // cout << "root i "<< i << endl;

            _dfs(i);
        }
    }

    // cout << "dp ";
    // for(ll i = 1; i <=n; i++) {
    //     cout << dp[i] << " ";
    // } cout << endl;

    ll ans = 1;
    for(ll i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    ans--;

    cout << ans << endl;

}   



int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    



    ll t=1;


    // cin>>t;
    


    while(t--){
        solve();
    }
    return 0;
}

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


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

	vector <int> A(N, 0);

	for (int i = 0; i < N; i++){
		cin >> A[i];
	}//????´???°N??????????????????????????£???

	for (int i = 0; i < N ; i++){
		int v,j;
		v = A[i];//A[N-2]
		j = i - 1;//j=N-3

		while (j >= 0 && A[j]>v){
		
			A[j + 1] = A[j];//A[N-2]=A[N-3]
			j -- ;
			A[j + 1] = v;
		}

		for (int k = 0; k < N; k++){
			cout << A[k];
			if (k != N - 1)cout << " ";
		}cout << endl;

	
	}



	return 0;
}

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

class MyClass
{
    static int Search(long[] dp, long target, int min, int max)
    {
        while (min < max)
        {
            var mid = min + ((max - min) / 2);
            if (dp[mid] < target)
            {
                min = mid + 1;
            }
            else
            {
                max = mid;
            }
        }
        return min;
    }

    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = new long[n];
        var dp = new long[n + 1];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
            dp[i] = long.MaxValue;
        }
        dp[n] = long.MaxValue;
        for (int i = 0; i < n; i++)
        {
            var j = Search(dp, a[i], 0, i);
            dp[j] = a[i];
        }

        for (int i = 0; i < n + 1; i++)
        {
            if (dp[i] == long.MaxValue)
            {
                Console.WriteLine(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23112
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())
    ans = []
    for _ in range(m):
        a = input().strip()
        ans.append(d.get(a, a))
    print("".join(ans))

Measured memory_bytes: 8644
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		int w = Integer.parseInt(in.nextLine());
		for(int i = 0; i < s.length(); i += w){
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/
bool comp(string a,string b)
{
  return a.length()<b.length();
}
void solve()
{
  ll n,i;
  cin>>n;
  std::vector<pll> v(n);
  for(i=0;i<n;i++)
  {
    cin>>v[i].F;
    v[i].S=i+1;
  } 
  sort(all(v));
  for(i=0;i<n;i++)
    cout<<v[i].S<<" ";
}
int main()
{ 
  ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 2432
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll sum=0;
    ll N;
    cin>>N;
    vector<ll> vec1;
    
    REP2(i,1,15001){
        sum+=2*i;
        if(sum%3==0){
            vec1.push_back(i);
        }
    }

    ll a,b;
    REP(i,vec1.size()){
        ll idx=N-vec1[i];
        ll num=3+6*(idx-1);
        if(num<=30000&&idx>=1&&idx%2==0){
            a=vec1[i];
            b=idx;
            break;
        }
    }
    
    if(N==3){
        cout<<"2 5 63"<<endl;
    }else{
        priority_queue<ll,vector<ll>,greater<ll>> que;
        REP2(i,1,a+1) que.push(2*i);
        REP(i,b) que.push(3+6*i);
        
        while(!que.empty()){
            ll ans=que.top();
            que.pop();
            cout<<ans;
            if(!que.empty()){
                cout<<" ";
            }else{
                cout<<endl;
            }
        }
    }
    

    
    
}

Measured memory_bytes: 3844
#include <stdio.h>

int main (void){
    int i,j,tmp;
    int a[10];

    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<10;i++){
        for(j=9;j>i;j--){
            if(a[j]>a[j-1]){
                tmp=a[j];
                a[j]=a[j-1];
                a[j-1]=tmp;
            }

        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    ll a, b, c, d;
    cin >> n;
    cin >> a >> b >> c >> d;
    ll dif = abs(b - a);
    n--;
    for (int cnt = 0; cnt <= n; cnt++) {
        ll a1 = cnt * c;
        ll a2 = cnt * d;
        ll b1 = -(n - cnt) * d;
        ll b2 = -(n - cnt) * c;
        if (a1 + b1 <= dif && dif <= a2 + b2) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256