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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

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

  int ans = 0;
  for ( int i = -1; i < N; i++ ) {
    for ( int j = i+1; j <= N; j++ ) {
      int sum = 0;
      vector<int> tmp;      
      for ( int k = 0; k < N; k++ ) {
	if ( k <= i || j <= k ) {	  
	  sum += V[k];
	  tmp.push_back(V[k]);	  
	}
      }
      if ( tmp.size() > K ) continue;      
      sort(tmp.begin(), tmp.end());
      // cout << i << " " << j << " " << sum << endl;      
      for ( int l = 0; l < min(K-(int)tmp.size(), (int)tmp.size()); l++ ) {
	// cout << l << endl;
	if ( tmp[l] < 0 ) sum -= tmp[l];	
      }      
      // cout << i << " " << j << " " << sum << endl;      
      ans = max(ans, sum);    
    }
  }

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


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


int main() {
    string S,T;
    cin >> S >> T;
    bool flag=false;
    int maxi;
    for(int i=0;i<S.size()-T.size()+1;i++){
        for(int j=0;j<T.size();j++){
            if(S[i+j]=='?' || S[i+j]==T[j]){
                if(j==T.size()-1){
                    flag = true;
                    maxi=i;
                }
                else continue;
            } 
            else  break;
        }
    }
    if(flag){
        for(int l=0;l<S.size();l++){
            if(l>=maxi && l<maxi+T.size()){
                S[l]=T[l-maxi];
            }
            else if(S[l]=='?') S[l]='a';
        }
        cout << S << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
import itertools
def solve(a, b, c, d):

    for operators in itertools.product(["+", "-"], repeat=3):
        ans = str(a)
        tmp = a
        for n, op in zip([b,c,d], operators):
            ans += op + str(n)
            if op == "+":
                tmp += n
            else:
                tmp -= n
        if tmp == 7:
            break

    return ans + "=7"

if __name__ == "__main__":
    a,b,c,d = [int(i) for i in input()]
    print(solve(a, b, c, d))


Measured memory_bytes: 3064
N = int(input())

m = -float("inf")
m2 = -float("inf")
max_idx = None
for i in range(N):
    el = int(input())    
    if (el > m):
        m2 = m
        m = el
        max_idx = i
    elif (el > m2):
        m2 = el


for i in range(max_idx):
    print(m)

print(m2)

for i in range(N-max_idx-1):
    print(m)


Measured memory_bytes: 4668
$in = <STDIN>;
if($in%111 == 0){
	print $in;
    exit(0);
}
else{
	$i = 111;
	do{
    	if($i>=$in){
        	print $i;
        	exit(0);
        }
        $i+=111;
    }while($i<$in)
}
print $i;

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

public class Main{
    public static void main(String[] args){
	try{
	    //Scanner s = new Scanner(new BufferedReader(new FileReader("input.txt")));
	    Scanner s = new Scanner(System.in);
	    int n;
	    int[] v = {0, 0, 0, 0, 0, 0};
	    n = s.nextInt();
	    for ( int i = 0; i < n; i++ ){
		double h = s.nextDouble();
		if ( h < 165.0 ) v[0]++;
		else if ( 165.0 <= h && h < 170.0 ) v[1]++;
		else if ( 170.0 <= h && h < 175.0 ) v[2]++;
		else if ( 175.0 <= h && h < 180.0 ) v[3]++;
		else if ( 180.0 <= h && h < 185.0 ) v[4]++;
		else if ( 185.0 <= h ) v[5]++;
	    }
	    for ( int i = 0; i < 6; i++ ){
		System.out.print(i+1 + ":");
		for ( int j = 0; j < v[i]; j++ ) System.out.print('*');
		System.out.println();
	    }
	} catch (Exception e){}
    }
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin)),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;T f=1;
	char ch=gc();
	while(!isdigit(ch)) {if(ch=='-') f=-1; if(ch==EOF) return EOF; ch=gc();}
	while(isdigit(ch)) ans=ans*10+ch-'0',ch=gc();
	ans*=f;
	return 1;
}

typedef long long ll;

int main() {
//	freopen("test.in","r",stdin);
	int n,a,flag=0;
	read(n);
	while(n--) {
		read(a);
		if(a%2) flag=1;
	}
	if(flag) puts("first");
	else puts("second");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pp long long int
#define pb push_back
int main()
{
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
   pp r,D,arr[11];
    cin>>r>>D>>arr[0];
    for(pp i=1;i<11;i++)
        arr[i]=(r*arr[i-1])-D;
     for(pp i=1;i<11;i++) cout<<arr[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
for i in range(N):
    a,b,c=map(str,input().split())
    a=int(a)
    b=int(b)
    if c=="W":
        b+=K
    x[i]=a%(2*K)
    y[i]=b%(2*K)
board=[[0 for i in range(2*K+1)] for i in range(2*K+1)]
for i in range(N):
    if x[i]>=K and y[i]>=K:
        x[i]-=K
        y[i]-=K
    if x[i]<K and y[i]>=K:
        x[i]+=K
        y[i]-=K
    if x[i]>=K and y[i]<K:
        board[0][y[i]+1]+=1
        board[0][y[i]+K+1]-=1
        board[x[i]-K+1][y[i]+1]-=2
        board[x[i]-K+1][y[i]+K+1]+=2
        board[x[i]-K+1][0]+=1
        board[x[i]+1][0]-=1
        board[x[i]+1][y[i]+1]+=2
        board[x[i]+1][y[i]+K+1]-=2
    if x[i]<K and y[i]<K:
        board[x[i]+1][y[i]+1]+=2
        board[x[i]+K+1][y[i]+K+1]+=2
        board[x[i]+1][y[i]+K+1]-=2
        board[x[i]+K+1][y[i]+1]-=2
        board[0][0]+=1
        board[x[i]+1][0]-=1
        board[0][y[i]+1]-=1
        board[x[i]+K+1][0]+=1
        board[0][y[i]+K+1]+=1
tmp=[[0 for i in range(2*K)] for i in range(2*K)]
bs=[[0 for i in range(2*K)] for i in range(2*K)]
for i in range(2*K):
    for j in range(2*K):
        if i==0:
            tmp[i][j]=board[i][j]
        else:
            tmp[i][j]=board[i][j]+tmp[i-1][j]
for i in range(2*K):
    for j in range(2*K):
        if j==0:
            bs[i][j]=tmp[i][j]
        else:
            bs[i][j]=tmp[i][j]+bs[i][j-1]
ans=bs[0][0]
for i in range(2*K):
    for j in range(2*K):
        if bs[i][j]>ans:
            ans=bs[i][j]
print(ans)


Measured memory_bytes: 141260
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int n;
	scanf("%d", &n);
	vector < int > a(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(all(a));
	vector < bool > used(n);
	multiset < int > st;
	for (int i = 0; i < n; i++)
		st.insert(a[i]);
	int ans = 0;
	for (int i = n - 1; i >= 0; i--)
	{	
		if (st.find(a[i]) == st.end())
			continue;
		st.erase(st.find(a[i]));
		int degree = 0;
		while((1 << degree) <= a[i])
			degree++;
		if (st.find((1 << degree) - a[i]) != st.end())
			st.erase(st.find((1 << degree) - a[i])), ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 10368
#include<stdio.h>

int main(void){
  int num[3];
  int five_count,seven_count;

  five_count=0;
  seven_count=0;

  scanf("%d",&num[0]);
  scanf("%d",&num[1]);
  scanf("%d",&num[2]);
  
  for(int i=0;i<3;i++){
    if(num[i]==5)five_count++;
    if(num[i]==7)seven_count++;
  }

  if(five_count==2 && seven_count==1){
    printf("YES");
  }else printf("NO");

  return 0;
}


Measured memory_bytes: 128
import itertools

N,M,Q=map(int,input().split())

A=[]
for i in range(Q):
    A.append(list(map(int,input().split())))
    A[i][0] -= 1
    A[i][1] -= 1

score = 0
max = 0

for iter in itertools.combinations_with_replacement(range(1,M+1),N):

    score = 0
    for i in range(Q):
        if iter[A[i][1]] - iter[A[i][0]] == A[i][2]:
            score += A[i][3]

    if max < score:
        max = score


print(max)

Measured memory_bytes: 9220
#include <stdio.h>
#include <stdlib.h>


int main(){
	int H,W;

	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}else{
			for(int i=0;i<W;i++){
				printf("#");
			}
			printf("\n");
			for(int i=1;i<(H-1);i++){
				printf("#");
				for(int j=1;j<(W-1);j++){
					printf(".");
				}
				printf("#\n");
			}
			for(int i=0;i<W;i++){
				printf("#");
			}
			printf("\n\n");

		}
	}
	
	return 0;
}


Measured memory_bytes: 2568
import sys
n=int(input())
lst=[]
for i in range(n):
  x,y,h=map(int,input().split())
  lst.append([x,y,h])
  
for j in range(101):
  for k in range(101):
    for i in range(n):
      H=abs(j-lst[i][0])+abs(k-lst[i][1])+lst[i][2]
      if H>0:
        if all(max(H-abs(j-lst[l][0])-abs(k-lst[l][1]),0)==lst[l][2] for l in range(n)):
          print(j,k,H)
          sys.exit()
        
  
  


Measured memory_bytes: 72796
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[][] k=new int[n][10];
for(int i=0;i<n;i++){
for(int j=0;j<10;j++){
k[i][j]=sc.nextInt();
}
}
for(int g=0;g<n;g++){
if(dfs(g,0,0,0,k)==true){System.out.println("YES");}
else{System.out.println("NO");}
}
}
public static boolean dfs(int i,int j,int r,int l,final int[][] k){
if(j==10){return true;}
else if(k[i][j]>r&&k[i][j]>l){
if(r>l){r=k[i][j];}
else{l=k[i][j];}
}
else if(k[i][j]>r){r=k[i][j];}
else if(k[i][j]>l){l=k[i][j];}
else{return false;}
return dfs(i,j+1,r,l,k);
}
}

Measured memory_bytes: 18344
#include<stdio.h>
#define N 250

typedef struct
{
  int key,l,r,p;
}Bin;

void cbt(Bin *,int );
void Print(Bin *,int);

int main()
{
  int i,n;
  Bin H[N];

  scanf("%d",&n);

  for(i=1;i<=n;i++)
  {
    scanf("%d",&H[i].key);
    H[i].l = H[i].r = 0;
  }

cbt(H,n);

Print(H,n);
  return 0;
}

void cbt(Bin *H,int n)
{
  int i;
  for(i=1;i<=n;i++)
  {
    if(2*i <= n)H[i].l = H[2*i].key;
    if(2*i+1 <= n)H[i].r = H[2*i+1].key;
    if(i!=0)H[i].p = H[i/2].key;
  }
}

void Print(Bin *H,int n)
{
  int i;
  for(i=1;i<=n;i++)
  {
    printf("node %d: key = %d, ",i,H[i].key);
    if(i!=1)printf("parent key = %d, ",H[i].p);
    if(H[i].l != 0 )printf("left key = %d, ",H[i].l);
    if(H[i].r != 0)printf("right key = %d, ",H[i].r);
    printf("\n");
  }
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
    int k; cin >> k;
    set<string> t;
    for(int i = 0; i < s.size(); i++){
            string h = "";
            h += s[i];
            t.insert(h);
        for(int j = i+1; j < min(i+k, (int)s.size()); j++){
            h += s[j];
            t.insert(h);
        }
    }
    auto itr = t.begin();
    for(int i = 1; i < k; i++) itr++;
    cout << *itr << endl;
    system("pause");
}

Measured memory_bytes: 1912
N = gets.to_i

array = []
N.times do |i|
  tmp = gets.split
  array << { s: tmp[0], p: tmp[1].to_i, n: i+1 }
end

def bubble_sort(array)
  ary = array.dup
  pos_max = ary.length - 1
  (0...(pos_max)).each{ |n|
    (0...(pos_max - n)).each{ |ix|
      # 隣と比較して前が大きかったら後ろと交換
      iy = ix + 1
      ary[ix], ary[iy] = ary[iy], ary[ix] if ary[ix][:s] > ary[iy][:s]
      if (ary[ix][:s] <=> ary[iy][:s]) == 0
        ary[ix], ary[iy] = ary[iy], ary[ix] if ary[ix][:p] < ary[iy][:p]
      end
    }
  }
  ary
end
ary = bubble_sort(array)

ary.each do |i| 
 puts i[:n]
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F=0, M=N;

  for (int i = 0; i < 8; i++) {
    if (M>9){
      int x = M%10;
      M /= 10;
      F += x;
    }
    else{
      F += M;
      break;
    }
  }
  cout << (N%F == 0 ? "Yes" : "No") << endl;   
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t n = s.size();

    if (s.front() != '1') {
        cout << -1 << endl;
        return 0;
    }
    if (s.back() != '0') {
        cout << -1 << endl;
        return 0;
    }

    for (auto i : irange(1L, n / 2 + 1)) {
        // 1-indexed
        if (s[i - 1] != s[n - i - 1]) {
            cout << -1 << endl;
            return 0;
        }
    }

    int64_t p = n, v = 1;
    for (auto i : irange(1L, n) | reversed) {
        // 1-indexed
        if (s[i - 1] == '0') {
            continue;
        }

        auto u = v;
        for (auto _ : irange(0L, p - i)) {
            cout << v << " " << ++u << "\n";
        }
        p = i;
        v = u;
    }
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    
    static Scanner cin = new Scanner();
    static void Main() {
        //string X = Console.ReadLine();
        //string tmp = "";
        //long cnt = 0; //減らす文字数
        //for (int i = 0; i < X.Length; i++) {
        //    if(X[i] == 'S') {
        //        if (tmp == "") tmp += "S";
        //        else if (tmp[tmp.Length - 1] == 'S') tmp += "S";
        //        else {
        //            cnt += 2 * Math.Min(tmp.ToCharArray().Count(x => x == 'S'), tmp.ToCharArray().Count(x => x == 'T'));
        //            tmp = "S";
        //        }
        //    }
        //    else {
        //        if (tmp != "") tmp += "T";
        //    }
        //}

        //cnt += Math.Min(tmp.ToCharArray().Count(x => x == 'S'), tmp.ToCharArray().Count(x => x == 'T'));
        //Console.WriteLine(X.Length - cnt);

        int N = cin.Int();
        var L = cin.ArrayInt(2*N);
        Array.Sort(L);
        int ans = 0;
        for (int i = L.Length - 2; i >= 0; i -= 2) {
            ans += L[i];
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 11220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int a, b; cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define N 100005
#define M 100005
#define inf 1000000000
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n;
vector<int> edges[N];
int k;
int L[N], R[N], odd[N];
int ans[N];
bool ok;
void dfs1(int u, int p) {
  for (int i = 0; i < edges[u].size(); ++i) {
    int v = edges[u][i];
    if (v==p) continue;
    dfs1(v, u);
    L[u] = max(L[u], L[v]-1);
    R[u] = min(R[u], R[v]+1);
    if (odd[v] >= 0) {
      if (odd[u] < 0) odd[u] = !odd[v];
      else if (odd[u] != !odd[v]) {
        ok = false;
        return ;
      }
    }
  }
}
void dfs2(int u, int p) {
  if (p != 0) {
    L[u] = max(L[u], L[p]-1);
    R[u] = min(R[u], R[p]+1);
    if (odd[u] < 0) odd[u] = !odd[p];
    else if (odd[u] != !odd[p]) {
      ok = false;
      return ;
    }
  }
  if (L[u] > R[u] || (L[u]==R[u] && (L[u]%2!=odd[u]))) {
    ok = false;
    return ;
  }
  for (int i = 0; i < edges[u].size(); ++i) {
    int v = edges[u][i];
    if (v != p) {
      dfs2(v, u);
    }
  }
}
void dfsans(int u, int p) {
  if (!p) {
    ans[u] = L[u];
  } else {
    ans[u] = ans[p]-1;
    if (ans[u] < L[u]) {
      ans[u] += 2;
    }
  }
  for (int i =0; i < edges[u].size(); ++i) {
    int v = edges[u][i];
    if (v != p) {
      dfsans(v, u);
    }
  }
}
int main() {
  cin>>n;
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  scanf("%d", &k);
  for (int i = 1; i <= n; ++i) {
    L[i] = -inf;
    R[i] = inf;
    odd[i] = -1;
  }
  for (int i = 1; i <= k; ++i) {
    int v,p;
    scanf("%d%d", &v, &p);
    L[v] = p;
    R[v] = p;
    odd[v] = (p%2);
  }
  if (k==0) {
    L[1] = 0, R[1] = 0;
    odd[1] = 0;
  }
  ok = true;
  dfs1(1, 0);
  if (!ok) {
    cout<<"No"<<endl;
    return 0;
  }
  dfs2(1, 0);
  if (!ok) {
    cout<<"No"<<endl;
    return 0;
  }
  dfsans(1, 0);
  if (!ok) {
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
    for (int i = 1; i <= n; ++i) {
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}


Measured memory_bytes: 15744
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	S, T = input().split()

	ans = ""
	for i in range(N):
		ans += S[i]
		ans += T[i]

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
i64 k;
int main() {
  cin >> s >> k;
  i64 n = s.size();
  using P = pair<i64, i64>;
  auto comp = [&](const P& p, const P& q) {
    auto it = begin(s);
    return lexicographical_compare(
      it + p.first, it + p.second,
      it + q.first, it + q.second
    );    
  };
  set<P, decltype(comp)> t(comp);
  for (i64 i = 0; i < n; ++i) {
    for (i64 l = 1; l <= k && i + l <= n; ++l) {
      t.emplace(i, i + l);
    }
  }
  auto it = t.begin();
  for (i64 i = 1; i < k; ++i) ++it;
  cout << s.substr(it->first, it->second - it->first) << '\n';
  return 0;
}


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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  string a="";
  for(int i=0;i<n;i++)
  {
    a.pb(s[i]);
    a.pb(t[i]);
  }
  cout<<a;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  //TIME
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b[100],n,t,i,c;
	while(1){
		for(t=0;t<100;t++){
			b[t]=0;
		}
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(t=0;t<n;t++){
			for(i=0;i<5;i++){
				scanf("%d",&a);
				b[t]+=a;
			}
		}
		for(t=0;t<n;t++){
			for(i=1;i<n;i++){
				if(b[i-1]<b[i]){
					c=b[i];
					b[i]=b[i-1];
					b[i-1]=c;
				}
			}
		}
		printf("%d %d\n",b[0],b[n-1]);
	}
	return 0;
}

Measured memory_bytes: 600
bt = {"A":0, "B":0, "AB":0, "O":0}
while True:
    try:
        i, _bt = raw_input().split(",")
    except EOFError as e:
        break
    bt[_bt] += 1
print(bt["A"])
print(bt["B"])
print(bt["AB"])
print(bt["O"])

Measured memory_bytes: 4228
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
    string str ;
    cin>>str; 
    for (int i = 0; i < str.length(); ++i) { 
  
        if (str[i] == ',') { 
  
            str[i] = ' '; 
        } 
    } 
    cout << str << endl; 
   return 0; 
} 

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
n,m = map(int, input().split())
p = list(map(int, input().split()))
xy=[]
for i in range(m):
    tmp = list(map(int,input().split()))
    xy.append(tmp)

link = [[] for _ in range(n)]
for tmp in xy:
    link[tmp[0]-1].append(tmp[1]-1)
    link[tmp[1]-1].append(tmp[0]-1)

from collections import deque
Q = deque()

from collections import defaultdict
visited = defaultdict(int)
ans=0
for i in range(n):
    if visited[i] != 0:
        continue
    ans_1=[]
    ans_2=[]

    Q.append(i)
    ans_1.append(i+1)
    ans_2.append(p[i])
    visited[i] = 1

    while Q:
        now=Q.popleft()
        for nxt in link[now]:
            if visited[nxt] != 0:
                continue
            Q.append(nxt)
            ans_1.append(nxt+1)
            ans_2.append(p[nxt])
            visited[nxt]=1
    ans+=len(set(ans_1) & set(ans_2))
print(ans)

Measured memory_bytes: 115344
#include<bits/stdc++.h>
using namespace std;
long long ar[200010];
int main()
{
	long long n,i;
	scanf("%lld",&n);
	long long xo=0;
	for(i=0;i<n;i++)
	{
		scanf("%lld",ar+i);
		xo^=ar[i];
	}
	for(i=0;i<n;i++)
		printf("%lld ",xo^ar[i]);
	printf("\n");
}


Measured memory_bytes: 5308
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int K = sc.nextInt();
        double[] p = new double[N];
 
        for(int i=0; i<N; i++){
            p[i] = sc.nextDouble();
        }

        double[] s = new double[N];
        double[] sum = new double[N];
        for(int i=0; i<N; i++){
            s[i] = (1 + p[i]) / 2;
            if(i==0){
                sum[i] += s[i];
            }
            else{
                sum[i] += s[i] + sum[i - 1];
            }
        }
 
        double max = sum[K - 1];
        for(int i=K; i<N; i++){
            
            max = Math.max(max, sum[i] - sum[i - K]);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 163320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.nextLine();
        if (S.contains("AC") ){
            System.out.println("Yes");
        }
        else  {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
a, b, c, x, y = map(int, input().split())

ans = 0

if c*2 < a+b:
    ans += min(x, y) * c * 2
    if x > y:
        ans += min(a, 2*c) * abs(x-y)
    elif x < y:
        ans += min(b, 2*c) * abs(x-y)
else:
    ans += a * x + b * y

print(ans)

Measured memory_bytes: 9196
N = int(input())
monster = [int(i) for i in input().split()]
while(len(monster) != 1):
    Min = min(monster)
    index = monster.index(min(monster))
    index2 = 0
    for i in monster:
        monster[index2] = i % Min
        index2 += 1
    monster[index] = Min

    for i in reversed(range(0,len(monster))):
        if monster[i] == 0:
            del monster[i]

print(monster[0])



Measured memory_bytes: 14252
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

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

    for (int i = 0; i < s.size(); i += 2) {
        cout << s.at(i);
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 512
def make_prime_checker(n):
    # nまでの自然数が素数かどうかを表すリストを返す  O(nloglogn)
    is_prime = [False, True, False, False, False, True] * (n//6+1)
    del is_prime[n+1:]
    is_prime[1:4] = False, True, True
    for i in range(5, int(n**0.5)+1):
        if is_prime[i]:
            is_prime[i*i::i] = [False] * (n//i-i+1)
    return is_prime

P = make_prime_checker(101010)
X = int(input())
for i in range(X, 101010):
    if P[i]:
        print(i)
        exit()


Measured memory_bytes: 10328
// 2020-08-11 22:41:57
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

using ull = unsigned long long;
int n;
vector<vector<int> > A[64];
vector<int> ST[2];
vector<int> UV[64][2];
void transpose(int b) {
  rep(i, n) REP(j, i+1, n) swap(A[b][i][j], A[b][j][i]);
}
bool solve(int b) {
  A[b].assign(n, vector<int>(n, -1));
  rep(k, 2) {
    rep(i, n) {
      if(ST[k][i] == 0 && UV[b][k][i] == 1) {
        rep(j, n) {
          if(A[b][i][j] == 0) return false;
          A[b][i][j] = 1;
        }
      } else if(ST[k][i] == 1 && UV[b][k][i] == 0) {
        rep(j, n) {
          if(A[b][i][j] == 1) return false;
          A[b][i][j] = 0;
        }
      }
    }
    transpose(b);
  }
  rep(_, 2) {
    rep(k, 2) {
      rep(i, n) {
        if(ST[k][i] != UV[b][k][i]) continue;
        bool ok = false;
        vector<int> idx;
        int x = ST[k][i];
        rep(j, n) {
          if(A[b][i][j] == x) {
            ok = true;
          } else if(A[b][i][j] == -1) {
            idx.push_back(j);
          }
        }
        if(ok) continue;
        if(idx.size() == 0) return false;
        if(idx.size() == 1) A[b][i][idx[0]] = x;
      }
      transpose(b);
    }
  }
  set<int> is, js;
  rep(i, n) rep(j, n) if(A[b][i][j] == -1) {
    is.insert(i);
    js.insert(j);
  }
  int base = 1;
  for(int i : is) {
    base = 1 - base;
    int c = base;
    for(int j : js) {
      A[b][i][j] = c;
      c = 1 - c;
    }
  }
  return true;
}
void answer() {
  cin >> n;
  rep(k, 2) rep(i, n) {
    int x;
    cin >> x;
    ST[k].push_back(x);
  }
  rep(k, 2) rep(i, n) {
    ull x;
    cin >> x;
    rep(j, 64) UV[j][k].push_back((x>>j)&1);
  }
  rep(b, 64) if(!solve(b)) {
    cout << -1 << '\n';
    return;
  }
  rep(i, n) {
    rep(j, n) {
      ull x = 0;
      rep(b, 64) x |= (ull(A[b][i][j])<<b);
      if(j) cout << ' ';
      cout << x;
    }
    cout << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n,k;

    cin >> n >> k;

    vector<ll> h(n, INT_MAX);
    vector<ll> sol(n, INT_MAX);

    sol[0] = 0;
    for (ll i = 0; i<n; i++) {
        cin >> h[i];
        for (ll j = i-1; j>=0 && j>=(i-k); j--) {
            sol[i] = min(sol[i], sol[j] + abs(h[i]-h[j]));
        }
    }

    cout << sol[n-1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[11];
    int i,j=1,c=0,a=2;
    scanf("%s",s);
    for(i=2;i<=strlen(s)-2;i++)
        if(s[i]=='C')
            c++;
    while(s[j]!='\0'){
        if((s[j]>='a')&&(s[j]<='z'))
            a++;
        j++;
    }
    if((s[0]=='A')&&(c==1)&&(a==strlen(s)))
        printf("AC\n");
    else printf("WA\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  LL n,k;cin >> n >> k;
  n -= k*(n/k);
  LL ans = n;
  umin(ans,abs(n-k));
  cout << ans << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(B/A, C) << endl;
  return 0;
}

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

q = -1
w = -1
r = -1

for a in range(N + 1):
    for b in range(N + 1 - a):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            q = a
            w = b
            r = c

print('{} {} {}'.format(q, w, r))

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

int main() {
  string S, T;
  cin >> S >> T;
  int a=0;
  rep(i,S.size()){
    if(S.at(i)==T.at(i)){
      a++;
    }
  }
  if(a==S.size()){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No"<< endl;
  }  
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long int
#define pb push_back
#define sx 300007
int main()
{
    map<int,int> m;
    int n ;
    cin>>n;
    for(int i=1; i<=10000; i++)
    {
        int ans=(i*i)+(1*1)+(1*1)+(i*1)+(1*1)+(i*1);
        if(ans>10000)
            break;
        for(int j=1; 1; j++)
        {
            int ans=(i*i)+(j*j)+(1*1)+(i*j)+(j*1)+(i*1);
            if(ans>10000)
                break;
            for(int k=1; 1; k++)
            {
                int ans=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
                m[ans]++;
                if(ans>10000)
                    break;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<m[i]<<endl;
    return 0;
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); b <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = (N - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    ll result = 0;
    const ll NK = N / K;
    result += NK * NK * NK;
    if (K % 2 == 0){
        const int K2 = K / 2;
        if (K2 <= N){
            const ll NK2 = ((N - K2) / K) + 1;
            result += NK2 * NK2 * NK2;
        }
    }
    cout << result << endl;
}

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

public class Main {
	private static final char BASE = 'a';
	private static final int ALPHABETS = 26;

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int n = sc.nextInt();
		int[] commonChars = new int[ALPHABETS];
		Arrays.fill(commonChars, Integer.MAX_VALUE);
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			int[] charCnt = countChars(s);
			for (int j = 0; j < ALPHABETS; j++) {
				commonChars[j] = Math.min(commonChars[j], charCnt[j]);
			}
		}

		StringBuilder answer = new StringBuilder();
		for (int i = 0; i < ALPHABETS; i++) {
			char c = (char) (BASE + i);
			for (int j = 0; j < commonChars[i]; j++) {
				answer.append(c);
			}
		}
		System.out.println(answer.toString());

		sc.close();
	}

	public int[] countChars(String str) {
		int[] chars = new int[26];
		for (int i = 0; i < str.length(); i++) {
			chars[str.charAt(i) - BASE]++;
		}
		return chars;
	}
}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N)cin >> d[i];
    long long s = 0;
    for(int i = 0;i < N;i++){
        for(int j = i+1;j < N;j++){
            s += d[i]*d[j];
        }
    }
    cout << s;
}


Measured memory_bytes: 256
x = int(input())
ok = [False for _ in range(100001)]

ok[100] = True
ok[101] = True
ok[102] = True
ok[103] = True
ok[104] = True
ok[105] = True

for i in range(106, 100001):
    ok[i] = (
        ok[i-100] or ok[i-101]
        or ok[i - 102] or ok[i-103] or ok[i-104] or ok[i-105]
    )

print('1' if ok[x] else '0')


Measured memory_bytes: 3912
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let (_, k) = get::tuple::<usize,usize>();
  let mut xs = get::list::<usize>();
 
  xs.sort();
  let mut gs = group_by(&xs, |x,y|x==y);
  gs.sort_by(|g1,g2|g2.len().cmp(&g1.len()));

  let ans = gs.iter().skip(k).flat_map(|g|g.iter()).count();

  println!("{}", ans)

}

fn group_by<T: PartialEq + Clone, F>(vec: &Vec<T>, f: F) -> Vec<Vec<T>> where F: Fn(&T, &T) -> bool {
  let l = vec.len();
  let mut gs = vec![];
  let mut g = vec![];
  for i in 0 .. l {
    g.push(vec[i].clone());
    if i < l-1 && !f(&vec[i], &vec[i+1]) {
      gs.push(g.clone());
      g.clear()
    }
  }
  gs.push(g.clone());
  gs
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 15552
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    if n % k:
        print(1)
    else:
        print(0)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <iostream>
#include <map>
#include <queue>
#include <sstream>

using namespace std;

vector<string> next(string s){
	vector<string> v;
	int i = s.find('0', 0);
	if(i < 4){
		if(i > 0){
			v.push_back(s.substr(0, i-1)+s[i]+s[i-1]+s.substr(i+1));
		}
		if(i < 3){
			v.push_back(s.substr(0, i)+s[i+1]+s[i]+s.substr(i+2));
		}
		v.push_back(s.substr(0,i)+s[i+4]+s.substr(i+1,3)+s[i]+s.substr(i+5));
	}else{
		if(i < 7){
			v.push_back(s.substr(0, i)+s[i+1]+s[i]+s.substr(i+2));
		}
		if(i > 4){
			v.push_back(s.substr(0, i-1)+s[i]+s[i-1]+s.substr(i+1));
		}
		v.push_back(s.substr(0,i-4)+s[i]+s.substr(i-3,3)+s[i-4]+s.substr(i+1));
	}
	return v;
}

int main(){
	int n[8];
	priority_queue<pair<int,string>, vector<pair<int,string>>, greater<pair<int,string>>> q;
	q.push(pair<int,string>(0,"01234567"));
	map<string,int> mintime;
	mintime["01234567"] = 0;
	while(!q.empty()){
		auto p = q.top();
		q.pop();
		auto v = next(p.second);
		for(auto s: v){
			if(mintime.find(s) == mintime.end()){
				mintime[s] = p.first+1;
				q.push(pair<int,string>(p.first+1, s));
			}
		}
	}
	while(cin >> n[0]){
		for(int i = 1; i < 8; ++i){
			cin >> n[i];
		}
		string s;
		stringstream ss;
		for(int i = 0; i < 8; ++i){
			ss << n[i];
		}
		cout << mintime[ss.str()] << endl;
	}
}

Measured memory_bytes: 3484
/*9*9*/
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a>9||b>9){
    printf("-1\n");
  }
  else{
    printf("%d\n",a*b);
  }return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	int a = -1, b = -1;
	bool flag = false;
	rep(i, SZ(s) - 1) {
		if (s[i] == s[i + 1]) { a = i + 1; b = i + 2; }
	}
	rep(i, SZ(s) - 2) {
		if (s[i] == s[i + 2]) { a = i + 1; b = i + 3; }
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 512
from collections import defaultdict


def main():
    num = int(input())

    link = defaultdict(set)
    weight = defaultdict(int)
    for i in range(num - 1):
        a, b, c = map(int, input().split())
        link[a].add(b)
        link[b].add(a)
        weight[(min(a, b), max(a, b))] = c

    q_num, k = map(int, input().split())

    dist_data = [-1 for i in range(num + 1)]
    dist_data[k] = 0
    now_check = set()
    next_check = set()
    now_check.add(k)

    while len(now_check) > 0:
        for ele in now_check:
            now_dist = dist_data[ele]
            for now_ele in link[ele]:
                if dist_data[now_ele] != -1:
                    continue
                next_check.add(now_ele)
                dist_data[now_ele] = now_dist + weight[(min(now_ele, ele), max(now_ele, ele))]
        now_check = next_check
        next_check = set()

    for i in range(q_num):
        a, b = map(int, input().split())
        print(dist_data[a] + dist_data[b])



if __name__ == '__main__':
    main()



Measured memory_bytes: 114648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
bool is(string &s)
{
    string t = s;
    reverse(all(t));
    return (s==t);
}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       string s;
       cin>>s;
       int n = sz(s);
       string ft = s.substr(0,(n-1)/2);
       string st = s.substr((n+3)/2-1,n);
       if(is(s)&&is(ft)&&is(st))
        cout<<"Yes"<<el;
       else
        cout<<"No"<<el;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        if(Character.isUpperCase(input.charAt(0))){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	a, b, c, d := iScan(), iScan(), iScan(), iScan()
	fmt.Println(max([]int{a * c, a * d, b * c, b * d}))
}


Measured memory_bytes: 1776