akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int x, y, vis[1111111];
int main() {
	while (cin >> x >> y, x) {
		fill(vis, vis + y, -1);
		for (int i = 0; ; i++) {
			if (vis[x] != -1) {
				cout << vis[x] << ' ' << (x ? i - vis[x] : 0) << endl;
				break;
			}
			vis[x] = i; x *= 10;
			while (x >= y) x -= y;
		}
	}
}

Measured memory_bytes: 6900
n, a, b = map(int, input().split())
if (b-a)%2 == 0:
    ans = (b-a)//2
else:
    ans = 0
    if a-1 <= n-b:
        ans += a
        a, b = 1, b-a
        ans += (b-a)//2
    else:
        ans += n-b+1
        a, b = a+n-b+1, n
        ans += (b-a)//2
print(ans)


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;
    cin >> N;
    vector<int> retu(N);
    for (int i = 0; i < N; i++) {
        cin >> retu.at(i);
    }
    int ans = 0;
    int mini = 10000000;
    for (int j = 0; j < N; j++) {
        if (retu.at(j) <= mini) {
            mini = retu.at(j);
            ans++;
        }
        else if (retu.at(j) == 1) {
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count =0;
		for(int i=0;i<n;i++) {
			int l=scan.nextInt();
			int r=scan.nextInt();
			int dantai=r-l+1;
			count = count + dantai;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 24936
K, S = map(int, input().split())

def countPatterns(K, S):
  count = 0
  for x in range(0, K+1):
    for y in range(0, K+1):
      z = S - (x + y)
      if 0 <= z and z <= K:
        count += 1
        
  return count

print(countPatterns(K, S))

Measured memory_bytes: 3060
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0,0)
A.append(0)
S = 0
for i in range(1,N+2):
  S += abs(A[i] - A[i-1])
for i in range(1,N+1):
  tmp = [A[i-1],A[i],A[i+1]]
  tmp.sort()
  ans = 0
  if tmp[1] == A[i]:
    ans = S
  elif tmp[2] == A[i]:
    ans = S- (tmp[2]-tmp[1])*2
  else:
    ans = S - (tmp[1]-tmp[0])*2
  print(ans)

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie()

#define MAXX 10005


#define ll long long

ll a[MAXX], b[MAXX];
char str[MAXX];

int main()
{
	FAST;
	for(ll i = 97; i < 122; i++){
		str[i-96] = i;
	}
	str[0] = 'z';
	ll n, t , h = 0, ans= 0;;
	cin >> n ;
	string s = "";
	t = n;
	while(t){
		h ++;
		t /= 26;
	}
	if(n <= 26){
		cout << str[n%26] << endl;
		return 0;
	}
	else{
		while(n){
		ll ops = n % 26;
		if(!ops){
			n -= 26;
		}
		else{
			n -= ops;
		}
		s += str[ops];
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	}
return 0;

}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key)return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y=x->parent;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  while(y!= NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);
  
  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;
  
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
  
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20460
#include<iostream>
#include<cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int const maxn=1e3+5;
char str[1005];
int main(){
	scanf("%s",str);
	int len=strlen(str);
	if(str[len-1]=='s')
		printf("%ses\n",str);
	else printf("%ss\n",str);
	return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
  int n,t,a;

  scanf("%d",&n);
  scanf("%d %d",&t,&a);
  int h[n];

  for (int i = 0; i < n; i++) {
    scanf("%d",&h[i]);
  }

  double abs = 0,temp = 0;
  int palace = 0;


  temp = a - t + (double)h[0]*0.006;
  abs = fabs(temp);
  palace = 1;

  for (int i = 1; i < n; i++) {
   temp = a - t + (double)h[i]*0.006;
   if(abs > fabs(temp)){
    abs = fabs(temp);
    palace = i+1;
   }
  }

  printf("%d\n",palace);

  return 0;

}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n,0);
    vector<int> c(n,0);
    rep(i,n)cin >> v[i];
    rep(i,n)cin >> c[i];
    int ans = 0;
    for ( int i = 0; i < n ; ++ i ) {
        if ( v[i] > c[i]) {
        ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

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

vector<vector<int>> graph;

vector<int> color;

set<int> tot;

void dfs(int u) {

	tot.insert(u);
	color[u] = 1;

	for (auto adj : graph[u]) {

		if (!color[adj]) {
			dfs(adj);
		}
	}
}


void solve()
{
	int n;
	cin >> n;

	int m;
	cin >> m;

	graph.resize(n + 1);
	color.resize(n + 1);



	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;

		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	int mx = 0;

	for (int i = 1; i <= n; i++) {
		tot.clear();

		if (!color[i]) {
			dfs(i);
		}
		mx = max(mx, (int)tot.size());
	}

	cout << mx << nl;
}

int main()
{


	FIO;

	int t = 1;

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

	return 0;
}

Measured memory_bytes: 30592
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

                        namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long getLargestSquare(long[,] hwinfo)
        {
            var maxwidth = 0L;
            var h = hwinfo.GetLength(0);
            var w = hwinfo.GetLength(1);
            var dp = new long[h + 1, w + 1];
            for (var i = 1; i <= h; ++i)
                for (var j = 1; j <= w; ++j)
                    if (hwinfo[i - 1, j - 1] == 0)
                    {
                        dp[i, j] = Math.Min(Math.Min(dp[i, j - 1], dp[i - 1, j]), dp[i - 1, j - 1]) + 1;
                        maxwidth = Math.Max(maxwidth, dp[i, j]);
                    }
            return maxwidth;
        }
        static void Main(string[] args)
        {
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var hwinfo = new long[H, W];
            for(var i=0;i<H;++i)
            {
                var t = Sarray();
                for (var j = 0; j < W; ++j)
                    hwinfo[i, j] = t[j];
            }
            var max = getLargestSquare(hwinfo);
            WriteLine(max * max);

        }
    }
}


Measured memory_bytes: 69380
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const INFTIY: f64 = 1e10;

const R: usize = 0;
const L: usize = 1;
const U: usize = 2;
const D: usize = 3;

const DX: [f64; 4] = [1.0, -1.0, 0.0, 0.0];
const DY: [f64; 4] = [0.0, 0.0, 1.0, -1.0];

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut x_mins = [INFTIY; 4];
    let mut x_maxs = [-INFTIY; 4];
    let mut y_mins = [INFTIY; 4];
    let mut y_maxs = [-INFTIY; 4];
    for _ in 0..n {
        let x: f64 = scan(tokens);
        let y: f64 = scan(tokens);
        let d: String = scan(tokens);
        let d: usize = match d.chars().next().unwrap() {
            'L' => L,
            'R' => R,
            'U' => U,
            'D' => D,
            _ => unreachable!(),
        };
        x_mins[d] = x_mins[d].min(x);
        x_maxs[d] = x_maxs[d].max(x);
        y_mins[d] = y_mins[d].min(y);
        y_maxs[d] = y_maxs[d].max(y);
    }
    let mut min = 4.0 * INFTIY * INFTIY;
    {
        let mut check = |t: f64| {
            if t >= 0.0 {
                let mut x_min = INFTIY;
                let mut x_max = -INFTIY;
                let mut y_min = INFTIY;
                let mut y_max = -INFTIY;
                for d in 0..4 {
                    x_min = x_min.min(x_mins[d] + t * DX[d]);
                    x_max = x_max.max(x_maxs[d] + t * DX[d]);
                    y_min = y_min.min(y_mins[d] + t * DY[d]);
                    y_max = y_max.max(y_maxs[d] + t * DY[d]);
                }
                min = min.min((x_max - x_min) * (y_max - y_min));
            }
        };
        check(0.0);
        for d0 in 0..4 {
            for d1 in d0 + 1..4 {
                if DX[d0] != DX[d1] {
                    check(-(x_mins[d0] - x_mins[d1]) / (DX[d0] - DX[d1]));
                }
                if DX[d0] != DX[d1] {
                    check(-(x_maxs[d0] - x_maxs[d1]) / (DX[d0] - DX[d1]));
                }
                if DY[d0] != DY[d1] {
                    check(-(y_mins[d0] - y_mins[d1]) / (DY[d0] - DY[d1]));
                }
                if DY[d0] != DY[d1] {
                    check(-(y_maxs[d0] - y_maxs[d1]) / (DY[d0] - DY[d1]));
                }
            }
        }
    }
    println!("{}", min);
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    priority_queue<ll> p;
    for(ll i=0; i<n; i++){
        int x;
        cin>>x;
        p.push(x);
    }
    while(m--){
        ll maxx = p.top();
        maxx = maxx/2;
        p.pop();
        p.push(maxx);
   }
    ll sum = 0;
    for(ll i=0; i<n; i++){
        ll y = p.top();
        p.pop();
        sum = sum + y;
    }
    cout<<sum<<endl;

return 0;
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

int main() {
  cout << setprecision(18);
  i64 N, Y;
  cin >> N >> Y;
  if (Y % 1000 != 0) {
    cout << "-1 -1 -1" << endl;
  } else {
    for (i64 x = 0; x <= N; ++x) {
      for (i64 y = 0; y <= N - x; ++y) {
        i64 tmp = Y - (x * 10000 + y * 5000);
        i64 z = N - (x + y);
        if (Y > 0 && (tmp / 1000) == z) {
          cout << x << " " << y << " " << z << " ";
          return 0;
        }
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = sum%MOD*i%MOD;
    }
    return sum%MOD;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int dp[100010];
    Fill(dp,-1);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(v[0]-v[1]);
    for(int i = 3;i <= n;i++){
        dp[i] = min(dp[i-1]+abs(v[i-1]-v[i-2]),dp[i-2]+abs(v[i-1]-v[i-3]));
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 1024
//https://blog.csdn.net/hesorchen
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include <cmath>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
#define MAX 200005
map<string, int> p;
string a[100005];
int ct;
int main()
{
    int n, m;
    cin >> n;
    string temp;
    while (n--)
    {
        cin >> temp;
        a[ct++] = temp;
        p[temp]++;
    }
    cin >> m;
    while (m--)
    {
        cin >> temp;
        a[ct++] = temp;
        p[temp]--;
    }
    int ans = 0;
    for (int i = 0; i < ct; i++)
        ans = max(ans, p[a[i]]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7;
int n;
ll x[N], v[N], c;
ll gao() {
	priority_queue<pair<ll, int> > stk;
	stk.push({0ll, n});
	ll tmp = 0;
	per(i, 0, n) {
		tmp += v[i];
		stk.push({tmp - 2 * (c - x[i]), i});
	}
	ll ret = stk.top().fi;
	tmp = 0;
	rep(i, 0, n) {
		while (stk.top().se <= i) stk.pop();
		tmp += v[i];
		ret = max(ret, stk.top().fi + tmp - x[i]);
	}
	return ret;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n >> c;
	rep(i, 0, n) cin >> x[i] >> v[i];
	ll ans = gao();
	rep(i, 0, n) x[i] = c - x[i];
	reverse(x, x + n);
	reverse(v, v + n);
	ans = max(ans, gao());
	cout << ans;
	return 0;
}

Measured memory_bytes: 5972
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, c = inl()
print(min(c, b// a))


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PI;
#define MAX 99999999
char hoge[]={"mcxi"};
int main(){
    int  n;cin>>n;
    rep(Q,n){
        string s;
        string t;
        map<char,int>m;
        cin>>s>>t;
        rep(i,4)m[hoge[i]]=0;
        rep(i,s.size()){
            if(s[i]>=96){
                if(i-1>=0&&s[i-1]<96) m[s[i]]+=s[i-1]-48;
                else if(s[i]>=96) m[s[i]]++;
            }
        }
         //cout<<"c:"<<m['c']<</*" i"<<m['i']<<*/endl;
        rep(i,t.size()){
            if(t[i]>=96){
                if(i-1>=0&&t[i-1]<96) m[t[i]]+=t[i-1]-48;
                else if(t[i]>=96) m[t[i]]++;
            }
        }
        //cout<<"c:"<<m['c']<</*" i"<<m['i']<<*/endl;
        for(int i=3;i>=0;i--)
            if(m[hoge[i]]>=10) {
                int temp=0;
                temp=m[hoge[i]]/10;
                m[hoge[i]]%=10;
                m[hoge[i-1]]+=temp;
            }
        
       //cout<<"x:"<<m['x']<<" i"<<m['i']<<endl;
        rep(i,4){
            if(m[hoge[i]]>1)cout<<m[hoge[i]]<<hoge[i];
            if(m[hoge[i]]==1)cout<<hoge[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
*void exEuclid(int a, int b){
	if(b==0){x = 1; y=0; d=a; return ;}
	exEuclid(b, a%b);
	int x1=y;
	int y1=x-(a/b)*y;
	x=x1;
	y=y1;
} 
* */
//===========================================================//
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  vector<int> v;
  rep(i, n){
    if(s1.at(i) == s2.at(i)) v.push_back(0);
    else{
      v.push_back(1);
      i++;
    }
  }
  mint ans;
  if(v.front() == 0) ans = 3;
  else ans = 6;
  rep2(i, 1, v.size()){
    if(v.at(i) == 0){
      if(v.at(i-1) == 0) ans *= 2;
      else ans *= 1;
    }else{
      if(v.at(i-1) == 0) ans *= 2;
      else ans *= 3;
    }
  }
  cout << ans.x << endl;
  return 0;
}

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

bool is_palindrome(string s){ //parlindrome=回文
    string t;
    t = s;
    reverse(t.begin(),t.end());
    return s==t;
}

int main(){
    string s;
    cin >> s;
    int n;
    n = s.size();
    string t, u;
    t = s.substr(0,(n-1)/2);//0から(n-1)/2のサイズ分切り取り
    u = s.substr((n+1)/2);//(n+1)/2から最後まで
    if( is_palindrome(s) && is_palindrome(t) && is_palindrome(u) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




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

class Quaternion{
public:
	float x,y,z,w;
	void print(){
		cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
	};
	Quaternion(){
		x = y = z = w = 0;
	}
	Quaternion(float _x, float _y, float _z, float _w){
		x = _x;
		y = _y;
		z = _z;
		w = _w;
	}
};

Quaternion operator * (Quaternion a, Quaternion b){
	return Quaternion(a.x*b.x-a.y*b.y-a.z*b.z-a.w*b.w,a.y*b.x+a.x*b.y+a.z*b.w-a.w*b.z,a.x*b.z+a.z*b.x+a.w*b.y-a.y*b.w,a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x);
}


int main() {
	int n,x1,y1,z1,w1,x2,y2,z2,w2;
	Quaternion a,b;
	while(cin>>n,n){
		for(;n;--n){
			cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;
			a = Quaternion(x1,y1,z1,w1);
			b = Quaternion(x2,y2,z2,w2);
			(a*b).print();
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
long long inp[205];
vector<int> ans;
signed main(){
	long long n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> inp[i];
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<n;j++){
			ans.push_back(1);
			for(int k=1;k<n;k++){
				swap(inp[k-1],inp[k]);
			}
			if(inp[0]<inp[n-1]){
				ans.push_back(n-1);
				swap(inp[0],inp[n-1]);
			}
		}
		ans.push_back(1);
		for(int j=1;j<n;j++){
			swap(inp[j],inp[j-1]);
		}
	}
	cout << ans.size()<<endl;
	for(auto x: ans){
		cout << x<<endl;
	}
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());

    int m;
    cin >> m;
    vector<tuple<int, long long, int> > v(m);
    for(int i=0; i<m; ++i){
        cin >> get<0>(v[i]);
        get<2>(v[i]) = i;
    }
    for(int i=0; i<m; ++i)
        cin >> get<1>(v[i]);
    sort(v.begin(), v.end());

    vector<bool> ans(m);
    int k = 0;
    long long score = 0;
    for(int i=0; i<m; ++i){
        int b, index;
        long long c;
        tie(b, c, index) = v[i];

        while(k < n && a[k] <= b){
            score += a[k];
            ++ k;
        }
        ans[index] = (c <= score);
    }

    for(int i=0; i<m; ++i){
        if(ans[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 9400
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 10000

struct Node {
	int p, left, right;
};

int n, D[MAX], H[MAX];
Node T[MAX];

void setDepth(int u, int d) {
	if (u == -1) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != -1) h1 = setHeight(T[u].left) + 1;
	if (T[u].right != -1) h2 = setHeight(T[u].right) + 1;
	return H[u] = max(h1, h2);
}

int getSibling(int u) {
	if (T[u].p == -1) return -1;
	if (T[T[u].p].left != u && T[T[u].p].left != -1)
		return T[T[u].p].left;
	if (T[T[u].p].right != u && T[T[u].p].right != -1)
		return T[T[u].p].right;
	return -1;
}

void print(int u) {
	int deg = 0;
	if (T[u].left != -1) deg++;
	if (T[u].right != -1) deg++;
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
		u, T[u].p, getSibling(u), deg, D[u], H[u]);
	if (T[u].p == -1) printf("root\n");
	else if (T[u].left == -1 && T[u].right == -1) printf("leaf\n");
	else printf("internal node\n");
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = -1;
	int id, left, right;
	for (int i = 0; i < n; ++i) {
		cin >> id >> left >> right;
		T[id].left = left;
		T[id].right = right;
		if (left != -1) T[left].p = id;
		if (right != -1) T[right].p = id;
	}
	int root;
	for (int i = 0; i < n; ++i)
		if (T[i].p == -1) root = i;
	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; ++i) print(i);

	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

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

    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll max_ = 1;
    rep(i,n){
        ans += (a[i] - 1) / max_;
        if(a[i] == max_)max_++;
        if(max_ == 1)max_++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let s = get!([char]);
    let t = get!([char]);
    let mut ans = (1 << 29);
    for i in 0..=(s.len() - t.len()) {
        let mut count = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        ans = ans.min(count);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int d, n;
  cin >> d >> n;
  int cnt = 0;
  rep3(i, 1, 10000000) {
    int c = 0;
    int j = i;
    while (j % 100 == 0) {
      j /= 100;
      c++;
    }
    if (c == d) {
      cnt++;
      if (cnt == n) {
        cout << i << endl;
        return;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define sp(x) setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define PI 3.141592653589793238462643383279502884

//#define sumup(x)	(x*(x+1))/2
using namespace std;

int sumup(int n)
{
	return (n*(n+1))/2;
}

int32_t main()
{
	string str,str2,u;
	int a,b;
	cin>>str>>str2>>a>>b>>u;
	if(u==str)
	{
		a--;
	}
	else
		b--;
	cout<<a<<" "<<b;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, len;
    string s, t;
    cin >> n >> s >> t;
    int res = 2 * n;
    rep (i, n) {
        string u, v;
        u = s.substr(i, n - i);
        v = t.substr(0, n - i);
        if (u == v) {
            res -= n - i;
            break;
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	int odd=0;
	FOR(i,1,n+1){
		if(i%2 == 1){
			odd++;
		}
	}
	double ans = 1.0 * odd / n;
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n, k;
    scan(n, k);
    auto a = readln.split.to!(int[]);

    auto dp = new int[](k + 1);
    dp[0] = 0;

    // 0: 先手負け(=後手勝ち)、 1: 先手勝ち
    foreach (i ; 1 .. k + 1) {
        dp[i] = 0;
        foreach (ai ; a) {
            if (i - ai < 0) {
                break;
            }
            if (dp[i - ai] == 0) {
                dp[i] = 1;
                break;
            }
        }
    }

    debug {
        writeln(dp);
    }

    writeln(dp[k] ? "First" : "Second");
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2556
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
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 SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

vector <vector <LL> > adj;
vector <bool> visited;
LL N_;
bool dfs(LL p, LL d){
    visited[p]=true;
    if(p==N_ && d==2)return true;
    else if(d<2){
        for(LL i=0; i < adj[p].size(); i++){
            if(!visited[adj[p][i]] && dfs(adj[p][i], d+1)){
                return true;
            }
        }
    }
    return false;
}

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    N_=N;
    REP(i,N+1){
        vector<LL> l;
        visited.PB(false);
        adj.PB(l);
    }
    REP(i, M){
        adj[a[i]].PB(b[i]);
        adj[b[i]].PB(a[i]);
    }
    if(dfs(1, 0))cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return;
}

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


Measured memory_bytes: 16752
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		in.nextLine();
		int[] yoko = new int[W];
		char[][] ans = new char[H][W];
		//System.out.println(H);
		for(int i=0; i<H; i++) {
			String s = in.nextLine();
			if(s.contains("#")) {
				//System.out.println(i + " contain:" + s);
				ans[i] = s.toCharArray();
				for(int j=0; j<W; j++) {
					if(ans[i][j]=='#') {
						yoko[j]=1;
					}
				}
			}
		}
		
		for(int i=0; i<H; i++) {
			if(ans[i][0]!='.' && ans[i][0]!='#') {
				continue;
			}
			for(int j=0; j<W; j++) {
				if(yoko[j]==1) {
					System.out.print(ans[i][j]);
				}
			}
			System.out.println();
		}
		
	
		in.close();
	}
}


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

int n , rk[123456];

struct base {
    int w ;
    int used ;
    int pos ; 
} rt[123456] ; 

int cmp(base x,base y) {
    return x.w<y.w ; 
}

int main() {
    scanf( "%d" , &n ) ;
    bool all0 = 0 ; 
    for ( int i = 1 ; i <= n ; i++ ) {
	scanf( "%d" , &rt[i].w ) ;
	rt[i].pos = i ;
	all0 |= rt[i].w > 0 ;
    }
    
    sort( rt+1 , rt+n+1 , cmp ) ;

    for ( int i = 0 ; i <= n+1 ; i++ ) {
	rt[i].used = -1 ;
	rk[rt[i].pos] = i ;
    }  

    int ans = 0 , answer = all0 , getMore = 0 ; 
    
    for ( int i = 1 ; i <= n ; i++ ) {
	rt[i].used = i ; ans++ ;
	if ( rt[i].pos == 1 ) getMore++ ;
	if ( rt[i].pos == n ) getMore++ ; 	
	if ( rt[rk[rt[i].pos-1]].used != -1 ) {
	    ans-- ; 
	}
	if ( rt[rk[rt[i].pos+1]].used != -1 ) {
	    ans-- ; 
	}
	if ( rt[i+1].w > rt[i].w || i == n ) answer = max( answer , 1+ans-getMore ) ;
    }

    printf( "%d\n" , answer ) ;
    
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  sum=P[0];
  num=P[0];
  rep(i,1,N){
    chmax(num,P[i]);
    sum=gcd(sum,P[i]);
  }
  if(K>num||K%sum)Out("IMPOSSIBLE");
  else Out("POSSIBLE");
}
  

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#include <vector> 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
#define pb push_back
#define popb pop_back
#define si size()
#define sof sizeof()
#define be begin()
#define en end()
#define all(v) v.be,v.en
#define le length()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define ump unordered_map
#define forr(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define maxe *max_element
#define mine *min_element
#define hii ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define o(a) cout<<a<<" "
#define ol(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define mod 998244353
using namespace std;
int main() 
{ 
    float l;
    cin>>l;
    float x= (float)l/3;
    printf("%.12f",x*x*x);
	return 0; 
} 


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

let i = 0;
while (line = lines.shift()) {
	i++;
	const number = Number.parseInt(line);

        if (number ===0 ) break;

	console.log(`Case ${i}: ${number}`);
}



Measured memory_bytes: 22396
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind A(n);
    A.init(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        A.merge(a, b);
    }
    
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans = max(ans, A.size(i));
    }
    

    cout << ans << endl;
}


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

int main(){
  int n; long m; cin >> n >> m;
  long a[n];
  map<int, long> mod;
  mod[0]++;
  long s = 0;
  rep(i, n){
    cin >> a[i];
    s += a[i];
    mod[(int)(s%m)]++;
  }
  long ans = 0;
  for(auto itr=mod.begin(); itr!=mod.end(); itr++){
    long num = itr->second;
    if(num < 2) continue;
    ans += num*(num-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992