akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] == c[i]) {
    } else if (a[i] != b[i] && b[i] == c[i]) {
      count += 1;
    } else if (a[i] == b[i] && b[i] != c[i]) {
      count += 1;
    } else if (a[i] != b[i] && b[i] != c[i]) {
      if (a[i] == c[i]) {
        count += 1;
      } else {
        count += 2;
      }
    }
  }

  cout << count << endl;
}


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

using ll = long long;

struct edge{
	ll from, to, cost;
};

int main(){
	constexpr ll puni = -(1ll << 60);
	int n, m;
	cin >> n >> m;
	edge es[m];
	for(int i = 0; i < m; i++){
		cin >> es[i].from >> es[i].to >> es[i].cost;
		es[i].from--;
		es[i].to--;
	}
	ll score[n];
	fill(score, score + n, puni);
	score[0] = 0;
	for(int i = 0; i < 5000; i++){
		for(int j = 0; j < m; j++){
			edge& e = es[j];
			score[e.to] = max(score[e.to], score[e.from] + e.cost);
		}
	}
	ll a1 = score[n - 1];
	for(int i = 0; i < 5000; i++){
		for(int j = 0; j < m; j++){
			edge& e = es[j];
			score[e.to] = max(score[e.to], score[e.from] + e.cost);
		}
	}
	ll a2 = score[n - 1];
	cout << (a1 == a2 ? to_string(a1) : "inf") << endl;
}

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

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

   bool allEven=true;
   for(int i=0;i<N;i++){
      if(a[i]%2==1){
         allEven=false;
      }
   }
   cout<<(allEven? "second":"first")<<endl;
}


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

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] types = new int[9];
      int maxCnt = 0;
      for(int i = 0; i < n; i++) {
        int score = sc.nextInt();
        int idx = Math.min(score/400, 8);
        types[idx]++;
      }
      int min = 0;
      int max = 0;
      for(int i = 0; i < types.length - 1; i++) {
        if(types[i] > 0) {
          max++;
          min++;
        }
      }
      max += types[8];
      if(min == 0) min = 1;
      System.out.println(min + " " + max);
  }
}


Measured memory_bytes: 21972
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

char NextChar(char from,int count){
  return (from-'a' + count) % 26 + 'a';
}

int main(){
  int N;

  while(~scanf("%d",&N)){
    if(N==0) break;
    char buf[128];    
    scanf("%s",buf);

    vector<P> ops;
    for(int i=0;i<N;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      ops.push_back(P(a,b));
    }
    reverse(ops.begin(),ops.end());
    for(int i=0;i<N;i++){
      int a = ops[i].first;
      int b = ops[i].second;
      int diff = abs(a-b);
      buf[a-1] = NextChar(buf[a-1],diff);
      buf[b-1] = NextChar(buf[b-1],diff);
      swap(buf[a-1],buf[b-1]);
    }
    printf("%s\n",buf);
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
map<ll,ll> fact(ll N){
    map<ll, ll> mp;
    repe(i,2,(ll)sqrt(N)+1){
        while(N%i==0){
            N /= i;
            mp[i]++;
        }
    }
    if (N != 1) mp[N]++;
    return mp;
}
int main() {
    init();
    ll N, ans = 0;
    cin >> N;
    ll Nm = N - 1;

    map<ll, ll> mp2 = fact(Nm);

    ll tmp = 1;
    for(auto &p:mp2){
        tmp *= (p.second+1);
    }
    ans += tmp - 1;

    vl cand={N};
    ll sqN = (ll)sqrt(N);
    repe(i,2,sqN+1){
        if(N%i==0){
            cand.eb(i);
            if (i != N/i) cand.eb(N / i);
        }
    }
    // verr(cand);

    for(auto& v:cand){
        ll tn = N;
        while (tn % v == 0) tn /= v;
        if (tn%v == 1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int M = 0;
		int cnt=(N-1)*(N-2)/2-K;
		if (cnt<0) {
			System.out.println(-1);
		} else {
			for (int i=2;i<=N;i++) {
//				System.out.println(1 + " " + i);
				M++;
			}
			for (int i=2;i<=N;i++) {
				for (int j=i+1;j<=N;j++) {
					if (cnt>0) {
//						System.out.println(i + " " + j);
						M++;
					}
					if (cnt==0) {
						break;
					}
					cnt--;
				}
			}
			System.out.println(M);
			cnt=(N-1)*(N-2)/2-K;
			for (int i=2;i<=N;i++) {
				System.out.println(1 + " " + i);
			}
			for (int i=2;i<=N;i++) {
				for (int j=i+1;j<=N;j++) {
					if (cnt>0) {
						System.out.println(i + " " + j);
					}
					if (cnt==0) {
						break;
					}
					cnt--;
				}
			}
		}
	}
}

Measured memory_bytes: 24148
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
ll n;
ll a[MAX_N + 2];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i + 1];
  a[0] = 0;
  a[n + 1] = 0;
  ll b[n];
  ll sum = 0;
  REP(i, n) {
    b[i] = abs(a[i + 1] - a[i]) + abs(a[i + 2] - a[i + 1]) - abs(a[i + 2] - a[i]);
  }
  REP(i, n + 1) sum += abs(a[i + 1] - a[i]);

  REP(i, n) cout << sum - b[i] << endl;

  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	string s,t; cin>>s>>t;
	s.push_back(t[t.size()-1]);
	if(s==t) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;	
}



Measured memory_bytes: 3576
import math as m

a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
c=m.radians(c)
S=0.5*a*b*m.sin(c)
L=a+b+m.sqrt(a*a+b*b-2*a*b*m.cos(c))
H=b*m.sin(c)
print(S)
print(L)
print(H)

Measured memory_bytes: 7964
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

l=[[0,0] for i in range(N*M+1)]

for a in A:
    if l[a][0]==1:
        print(0)
        exit()
    l[a][0]+=1
for b in B:
    if l[b][1]==1:
        print(0)
        exit()
    l[b][1]+=1

A=0
B=0
ans=1

for i in range(N*M):
    n=N*M-i
    if l[n]==[1,1]:
        A+=1
        B+=1
    elif l[n]==[1,0]:
        A+=1
        ans*=B
    elif l[n]==[0,1]:
        B+=1
        ans*=A
    else:
        ans*=A*B-(N*M-n)

    ans%=10**9+7

print(ans)


Measured memory_bytes: 134648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine(111 + 999 - F);
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  cin >> d;
  if (d == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  if (d == 24) {
    cout << "Christmas Eve" << endl;
  }
  if (d == 25) {
    cout << "Christmas" << endl;
  }
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		assert solve(2, 2) == 8;
		assert solve(3, 2) == 12;
		assert solve(1, 8) == 0;
		assert solve(100000, 100000) == 530123477;

		int n = cin.nextInt();
		int m = cin.nextInt();

		long ans = solve(n, m);
		cout.println(ans);
	}

	private static long solve(int n, int m) {
		if (n + 1 != m && n != m + 1 && n != m)
			return 0;
		long mod = (int) 1e9 + 7;
		long dogs = 1;
		long monkeys = 1;
		for (int i = 1; i <= n; i++)
			dogs = (dogs * i) % mod;
		for (int i = 1; i <= m; i++)
			monkeys = (monkeys * i) % mod;
		long ans = (dogs * monkeys) % mod;
		if (n == m)
			ans = (2 * ans) % mod;
		return ans;
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

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

}


Measured memory_bytes: 23380
sizeStr = STDIN.gets
sizeAry = sizeStr.split(" ")
$h = sizeAry[0].to_i
$w = sizeAry[1].to_i

photoAry = Array.new

# read
$h.times{
    str = STDIN.gets.chomp
    photoAry.push(str)
}

def outputHorizontalFrame()
    ($w+2).times{
        print "#"
    }
    print "\n"
end

# write
outputHorizontalFrame()
$h.times{ |hi|
    puts "#" << photoAry[hi] << "#"
}
outputHorizontalFrame()

Measured memory_bytes: 1788
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    N, K = list(map(int, input().split()))
    A = list(input().split())

    D = collections.defaultdict(lambda: 0)

    for a in A:
        D[a] += 1

    L = []
    for v in D.values():
        L.append(v)

    L.sort(reverse=True)

    i = 0
    S = 0
    U = min(K, len(L))
    while i < U:
        S += L[i]
        i += 1

    print(sum(L) - S)


main()


Measured memory_bytes: 37228
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {    
      int n,m;
      cin>>n>>m;
      if(n%m)
      cout<<n/m+1;
      else
      cout<<n/m;
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3580
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(c: "List[List[int]]"):
    flag = True
    for i in range(2):
        D = []
        for j in range(3):
            d = c[i+1][j] - c[i][j]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    for i in range(2):
        D = []
        for j in range(3):
            d = c[j][i+1] - c[j][i]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [ [ int(next(tokens)) for _ in range(3) ] for _ in range(3) ]  # type: "List[List[int]]"
    solve(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, x;
int a[2010];

// i を飼う、魔法を j 回使う
int dp[2010][2010];

signed main() {
    cin >> N >> x;
    rep(i,0,2010) rep(j,0,2010) dp[i][j] = INF;
    rep(i,0,N) {
        cin >> a[i];
        dp[i][0] = a[i];
    }

    rep(j,1,N) rep(i,0,N) {
        dp[i][j] = min(dp[i][j-1], a[(i-j+N)%N]);
    }

    int ans = INF;
    rep(j,0,2010) {
        int temp = x * j;
        rep(i,0,N) {
            temp += dp[i][j];
        }
        chmin(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31872
#include <stdio.h>
#include <string.h>

int R(char arr[], int n, int k, int index);

int main()
{
    char arr[100001] = {0};
    scanf("%s", arr);

    int k, len = strlen(arr);
    scanf("%d", &k);

    int ch_move[100001] = {0};

    for (int i=0; i<len; i++)
    {
        if (arr[i] == 'a')
            ch_move[i] = 0;
        else
            ch_move[i] = 26 - (arr[i] - 'a');
    }

    int i = 0;
    while (k && i < len)
    {
        k = R(arr, ch_move[i], k, i);
        i++;
    }
    k %= 26;
    arr[i-1] += k;

    puts(arr);

    return 0;
}

int R(char arr[], int n, int k, int index)
{
    if (n > k)
        return k;
    arr[index] = 'a';
    return (k - n);
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=1e6+9;
const ll mod=1e9+7;
const ll inf=2e10;
int prime[N],vis[N];
void seive()
{
    for(int i=1;i<N;i++) prime[i]=i;
    for(int i=2;i<N;i+=2) prime[i]=2;
    for(int i=3;i*i<N;i+=2) {
        if(prime[i] == i) {
            for(int j=i*i;j<N;j+=i) {
                if(prime[j] == j) prime[j]=i;
            }
        }
    }
}
vector<int> chk(int v)
{
    vector<int>ans;
    while (v != 1)
    {
        int p=prime[v];
        ans.push_back(p);
        while (v%p==0) v/=p;
    }
    return ans;
}
void slv()
{
    seive();
    int n;
    cin >> n;
    int a[n+3],gcd=0;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        gcd=__gcd(gcd,a[i]);
    }
    bool ok=0;
    for(int i=0;i<n;i++) {
        vector<int>ans = chk(a[i]);
        for(auto x : ans)
        {
            if(vis[x]==1) ok=1;
            vis[x]=1;
        }
        if(ok) break;
    }
    if(!ok) puts("pairwise coprime");
    else {
        if(gcd == 1) puts("setwise coprime");
        else puts("not coprime");
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while (t--)
    {
        slv();
    }
    return 0;
}


Measured memory_bytes: 11720
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N >> K;
        vector<int> vec(N);
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
        }

        sort(vec.begin(), vec.end());
        int ans = (int)1e9 + 5000;
        for (int i = 0; i < N - K + 1; i++)
        {
                int cnt;
                cnt = vec[i + K - 1] - vec[i];
                ans = min(ans, cnt);
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

ll ans = INF;

void f(ll h, ll w){
    rep(i,h+1){
        ll ma1 = max(i*w, max((h-i)*(w/2), (h-i)*((w+1)/2)));
        ll mi1 = min(i*w, min((h-i)*(w/2), (h-i)*((w+1)/2)));
        ll ma2 = max(i*w, max((h-i)/2*w, (h-i+1)/2*w));
        ll mi2 = min(i*w, min((h-i)/2*w, (h-i+1)/2*w));
        chmin(ans, ma1-mi1);
        chmin(ans, ma2-mi2);
    }
    return;
}

int main(){
    ll H, W;
    cin >> H >> W;
    f(H,W);f(W,H);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    long[][] c = new long[10][10];
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        c[i][j] = sc.nextLong();
      }
    }
    long[][] dp = new long[10][10];
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        dp[i][j] = c[i][j];
      }
    }
    for(int k = 0; k < 10; k++) {
      for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
          dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]); 
        }
      }
    }
    long ans = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        int d = sc.nextInt();
        if(d > -1) ans += dp[d][1];
      }
    }
    System.out.println(ans);
  }
}

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

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

int main(){
    string s,t="abcdefghijklmnopqrstuvwxyz",u="None";
    vector<int>a(26);
    cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<26;j++){
            if(s[i]==t[j]){
                a[j]++;
            }
        }
    }
    for(int i=0;i<26;i++){
        if(a[i]==0){
            u=t[i];
            break;
        }
    }
    cout<<u<<endl;
    return 0;
}

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

int main() {
 string T,P; cin>>T>>P;
 if(T.size()<P.size()) return 0;
 rep(i,T.size()-P.size()+1){
  bool ok=true;
  rep(j,P.size()) if(T[i+j]!=P[j]) ok=false;
  if(ok) printf("%u\n",i);
 }
 return 0;
}



Measured memory_bytes: 3344
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e18;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
 
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solutions

int32_t main()
{
    IOS

    string s;
    cin>>s;
    int q;
    cin>>q;
    string front="";
    string back="";
    int x=0;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            x++;
        }
        else
        {
            int b;
            cin>>b;
            b--;
            char ch;
            cin>>ch;
            if(x%2!=0)
            {
                b=!b;
            }
            if(b==0)
            {
                front+=ch;
            }
            else
            {
                back+=ch;
            }
        }
    }
    reverse(front.begin(),front.end());
    s=front+s+back;
    if(x%2!=0)
    {
        reverse(s.begin(),s.end());
    }
    cout<<s;

}       

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	int ans;
	if (a == b)ans = c;
	else if (b == c)ans = a;
	else ans = b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int main(){
  IOS;
  int a,b,c, rec, loz;
  char cha;
  rec=0; loz=0;
  while(cin>>a>>cha>>b>>cha>>c){
    if(pow(a,2)+pow(b,2)==pow(c,2)){
      rec+=1;
    } else if(a==b){
      loz+=1;
    }
  }
  cout << rec << endl;
  cout << loz << endl;
  return 0;
}



Measured memory_bytes: 3092
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n;
    cin >> n;
    int a = 0, b = 0, c = 0;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x % 4 == 0){
            a++;
        }
        else if(x % 2 == 0){
            b++;
        }
        else{
            c++;
        }
    }
    // cout << a << b << c;
    if(a > c - 1){
        cout << "Yes";
    }
    else{
        if(a == c - 1 && b == 0){
            cout << "Yes";
            return 0;
        }
        cout << "No";
    }
}

Measured memory_bytes: 3664
#include <stdio.h>

void swap( int *x, int *y ){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
  
}

int main(void)
{
  int x[3000];
  int y[3000];
  int n = 0;
  int i;
  
  do{
    scanf("%d %d", x+n, y+n);
    n++;
  }while(*(x+n-1) + *(y+n-1));
  
  for( i = 0; i < n-1; i++ ){
    if( x[i] > y[i] ) swap( &x[i], &y[i] );
    printf("%d %d\n", x[i], y[i] );
  }

  return 0;
  
}

Measured memory_bytes: 624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a[][] = new int[3][3];
        for(int i = 0;i < 3;i++){
          for(int j = 0;j < 3;j++){
            a[i][j] = sc.nextInt();
          }
        }
		int n = sc.nextInt();
        int b,count = 0;
        
        while(count < n){
          b = sc.nextInt();
          for(int i = 0;i < 3;i++){
            for(int j = 0;j < 3;j++){
              if(b == a[i][j]){
                a[i][j] = 0;
              }
            }
          }
          count += 1;
        }
      
        for(int i = 0;i < 3;i++){
          if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
            System.out.println("Yes");
            return;
          }
        }
        for(int i = 0;i < 3;i++){
          if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0){
            System.out.println("Yes");
            return;
          }
        }
        if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0){
            System.out.println("Yes");
            return;          
        }
        if(a[2][0] == 0 && a[1][1] == 0 && a[2][0] == 0){
            System.out.println("Yes");
            return;          
        }        
        
        System.out.println("No");
    }
}

Measured memory_bytes: 35620
def main():
	D,G = map(int,input().split())
	ListPC = [list(map(int,input().split())) for d in range(D)]
	ans = sum([i[0] for i in ListPC])

	for i in range(2**D):
		# 点数,正解数,解いてない最高点数idx
		TempPoint,num,restmax = 0,0,-1
		# 全埋め問題加算
		for j in range(D):
			if i>>j & 1:
				TempPoint += 100*(j+1)*ListPC[j][0]+ListPC[j][1]
				num += ListPC[j][0]
			else:
				restmax = max(j,restmax)
		# 合格なら更新
		if TempPoint >= G:
			ans = min(num,ans)
		# 最高問題解いて合格なら更新
		elif (G - TempPoint) // ((restmax + 1) * 100) <= ListPC[restmax][0]:
			ans = min(num + (G - TempPoint - 1) // ((restmax + 1) * 100) + 1, ans)
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 9100
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;




int main(){
    int N,K; cin >> N >> K;
    vector<int> P(N);
    
    rep(i,N){
        cin >> P[i];
    }
    set<int> Pk;
    rep(i,K) Pk.insert(P[i]);
    int min = *Pk.begin();
    set<int> :: iterator it = Pk.end();
    it--;
    int max = *(it);
    
    int add = 0;
    int ans = N - K + 1;
    FOR(i,K,N){
        add = P[i];
        if(add>max && min == P[i-K]){
            ans--;
        }
        Pk.insert(add);
        Pk.erase(P[i-K]);
        it = Pk.end();
        it--;
        max = *it;
        min = *Pk.begin();
    }
    
    int island = 0;
    int islandLength = 1;
    
    rep(i,N-1){
        if (P[i] < P[i+1]){
            islandLength++;
        }
        else{
            if (islandLength>=K){
                island ++;
            }
            islandLength = 1;
        }
    }
    if (islandLength >= K) island ++;
    cout << ((island > 0) ? (ans - island + 1): (ans));
    rn 0;
    
}



Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,x,i,j,k,ans=0;
  cin>>n>>x;
  ll a[n],b[n];
  for(i=0;i<n;i++) cin>>a[i],b[i]=a[i],ans+=a[i];
  for(k=0;k<n;k++){
    j=0;
    for(i=0;i<n;i++){
      b[i]=min(b[i],a[(i+n-k)%n]);
      j+=b[i];
    }
    ans=min(ans,x*k+j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

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

void solve(long long N, long long K, std::vector<long long> A){
    sort(A.begin(), A.end());
    if(K > A[A.size()-1]){
        cout << NO << endl;
        return;
    }
    ll k = A[0];
    rep(i, N){
        k = gcd(A[i], k);
    }
    if(K % k == 0)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

int main() {
  int n,k,ans = 1;
  cin >> n >> k;
  for(int i = 0;i < n;i++){
    if(ans*2 <= ans + k){
      ans *= 2;
    }
    else{
      ans += k;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import numpy as np
H,W=map(int,input().split())
S=[list(input()) for h in range(H)]
S=[[1 if s=='.' else 0 for s in S[h]] for h in range(H)]
S=np.array(S,dtype=int)
L=S.copy()
R=S.copy()
U=S.copy()
D=S.copy()
for w in range(1,W):
    L[:,w]=(L[:,w-1]+1)*S[:,w]
    R[:,-(1+w)]=(R[:,-w]+1)*S[:,-(1+w)]
for h in range(1,H):
    U[h,:]=(U[h-1,:]+1)*S[h,:]
    D[-(1+h),:]=(D[-h,:]+1)*S[-(1+h),:]
print((L+R+U+D).max()-3)

Measured memory_bytes: 248740
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string A,B,C;
int N,i,cnt;

inline void solve(){
  IN(N);
  IN3(A,B,C);
  REP(i,N){
    if((A[i]!=B[i]&&B[i]==C[i])||
  (A[i]==C[i]&&A[i]!=B[i])||
    (A[i]==B[i]&&B[i]!=C[i])){
      cnt++;
    }else if(A[i]!=B[i]&&B[i]!=C[i]){
      cnt+=2;
    }
  }
  OUT(cnt);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/agc026/tasks/agc026_a
fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>();
    let mut cnt = Vec::new();
    let mut prev = an[0];
    let mut same = 1;
    for i in 1..n {
        if an[i] == prev { same += 1; }
        else { cnt.push(same); same = 1; prev = an[i]; }
        if i == n - 1 { cnt.push(same); }
    }
    // println!("{:?}", cnt);
    let ans = cnt.iter().map(|&n| n / 2).sum::<usize>();
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
void solveA();
void solveB();
void solveC();
void solveD();
 
int main() {
  solveC();
}

void solveA(){
  int d;
  cin >> d ;
  string s = "Christmas";

  for(int i = 0; i<25-d; i++){
    s += " EVE";
  }
 
  cout << s <<  endl;
}

void solveB(){
  int n;
  cin >> n ;
  int a[n];

  for(int i = 0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  a[n-1] = a[n-1]/2;
    
    int ans = 0;
  for(int i = 0; i<n; i++){
    ans += a[i];
  }
 
  cout << ans <<  endl;
}

void solveC(){
  int n,k;
  cin >> n >> k;
  k--;
  int a[n];

  for(int i = 0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
    
  int ans = INT_MAX;
  for(int i = 0; i<n-k; i++){
    int dif = a[i+k] - a[i];
    if (dif<ans) ans = dif;
  } 
  cout << ans <<  endl;
}


Measured memory_bytes: 640
from collections import Counter

n = int(input())
d_input=list(map(int,input().split()))
m=int(input())
t_input=list(map(int,input().split()))

d_count = Counter(d_input)
t_count = Counter(t_input)

for key,value in t_count.items():
    if key not in d_count:
        print('NO');exit()
    if d_count[key]<value:
        print('NO');exit()
print('YES')


Measured memory_bytes: 57076
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
for i in range(N):
    ii=int(input())
    if ii in A1:
        A1[A1.index(ii)]=0
    if ii in A2:
        A2[A2.index(ii)]=0
    if ii in A3:
        A3[A3.index(ii)]=0
ans="No"
l=[0,0,0]
if A1[0]==0 and A2[1]==0 and A3[2]==0:
    ans="Yes"
elif A1[2]==0 and A2[1]==0 and A3[0]==0:
    ans="Yes"
elif A1==l or A2==l or A3==l:
    ans="Yes"
elif A1[0]==0 and A2[0]==0 and A3[0]==0:
    ans="Yes"
elif A1[1]==0 and A2[1]==0 and A3[1]==0:
    ans="Yes"
elif A1[2]==0 and A2[2]==0 and A3[2]==0:
    ans="Yes"
print(ans)    
           
          

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,k,x,y;
	cin>>n>>k>>x>>y;
	ll s=0;
	for(int i=0;i<min(n,k);i++)
	s+=x;
	for(int i=k;i<n;i++)
	s+=y;
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int x[5][4][11]={0},a,v,b,c,d,e,q;
	scanf("%d",&a);
	for(v=0;v<a;v++){
		scanf("%d %d %d %d",&b,&c,&d,&e);
		x[b][c][d]=e+x[b][c][d];
	}
	for(b=1;b<5;b++){
		for(c=1;c<5;c++){
			if(c==4){
				if(b==4)break;
				printf("####################\n");
				break;
				}
			for(d=1;d<11;d++){
				if(d==10){
					printf(" %d\n",x[b][c][d]);
				}else if(d<10){
					printf(" %d",x[b][c][d]);
				}
				}
			}
	}
	
	
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, X; cin >> N >> X;

    int ans = N;
    int a = min(X, N - X), b = max(X, N - X);

    while(true){
        int q = b / a, r = b % a;
        if(r == 0){
            ans += a * (2 * q - 1);
            break;
        }
        ans += a * 2 * q;
        b = a;
        a = r;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384
 
std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}
 
int main() {
	ll a,b;
	cin>>a>>b;
	cout<<((a%b!=0)?a:-1)<<endl;
}

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

const int N=2e5+10;
long long s[N];

int main()
{
    int n;
    scanf("%d",&n);
    int x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        s[i]=s[i-1]+x;
    }
    sort(s,s+n+1);
    long long ans=0,ll,num;
    for(int i=0;i<=n;)
    {
        ll=s[i];
        num=0;
        for(;i<=n&&s[i]==ll;i++)
            num++;
        ans=ans+num*(num-1)/2;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
  int n, ans=0, m=0;
  cin>>n;
  vector<int> h(n,0);

  REP(i,n) cin>>h.at(i);
  
  REP(i,n-1){
    if(h.at(i)>=h.at(i+1)){
      ans++;
      m=max(m,ans);
    }else ans=0;
  }

  cout<<m<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define ll long long
#define INF 0x3f3f3f3f
const int N=1005;
using namespace std;

ll a,b,ans,top=1e18;

int main()
{
	cin>>a>>b;
	if(a>=b&&a%b==0){
		puts("-1");
		return 0;
	}
	ans=a*2;
	while(ans%b==0){
		ans=ans+a;
		if(ans>top){
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(M: int):
    print(48 - M)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    solve(M)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

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

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

    long n, m;

    cin >> n;

    map<long, long> table;
    long x;

    long i;

    for (i = 0; i < n; i++) {
        cin >> x;

        table[x]++;
    }

    cin >> m;

    for (i = 0; i < m; i++) {
        cin >> x;

        if (0 < table[x]) {
            table[x]--;
        } else {
            cout << "NO" << '\n';

            return 0;
        }
    }

    cout << "YES" << '\n';

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>

int* E;
int N, M;
int eval(int ind,std::vector<int>& route)
{
	if (route.size() == N)
		return 1;

	int ans = 0;



	for (int i = 0; i < N; i++)
	{
		std::vector<int> route_n = route;

		if (!E[ind*N + i])
			continue;

		std::vector<int>::iterator iter = std::find(route.begin(), route.end(), i);

		if (iter != route.end())
			continue;

		route_n.push_back(i);

		ans += eval(i, route_n);
	}

	return ans;
}

int main()
{


	std::cin >> N >> M;

	E = new int[N*N];

	std::fill(E, E + N*N, 0);

	for (int i = 0; i < M; i++)
	{
		int a, b;

		std::cin >> a >> b;

		E[(a-1)*N + b-1] = E[(b-1)*N + a-1] = 1;
	}

	std::vector<int> route;
	route.push_back(0);

	int ans = eval(0,route);
	
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    IO
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main()
{

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  int ans = 1;
  int up = 0;
    
  for (int i = 0; i < N - 1; i++)
  {
    if (up == 1 && A.at(i) > A.at(i + 1))
    {
      ans++;
      up = 0;
    }
    else if (up == 2 && A.at(i) < A.at(i + 1))
    {
      ans++;
      up = 0;
    }
    else if (up == 0 && A.at(i) < A.at(i + 1))
    {
      up = 1;
    }
    else if (up == 0 && A.at(i) > A.at(i + 1))
    {
      up = 2;
    }
  }
  cout <<  ans << endl;
  return 0;
}

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

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

    int64_t A[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }

    int64_t dp[N][2];
    dp[0][0] = A[0];
    dp[0][1] = INT32_MIN;
    for (int i = 1; i < N; ++i) {
        dp[i][0] = std::max(dp[i-1][0] + A[i], dp[i-1][1] + A[i]);
        dp[i][1] = std::max(dp[i-1][0] - 2 * A[i-1] - A[i], dp[i-1][1] + 2 * A[i-1] - A[i]);
    }

    std::printf("%ld\n", std::max(dp[N-1][0], dp[N-1][1]));

    return 0;
}


Measured memory_bytes: 2560