akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
typedef struct {char suit,value;}Card;

void bubble(Card A[],int N){
  int i,j;
  Card t;
  for(i = 0; i<N; i++){
    for(j=N-1;j>=i;j--){
      if(A[j].value<A[j-1].value){
        t=A[j];A[j]=A[j-1];A[j-1]=t;
      }
    }
  }
}

void selection(Card A[],int N){
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
    t=A[i];A[i]=A[minj];A[minj]=t;
  }
}

void print(Card A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[],Card C2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit!=C2[i].suit){
        return 0;
    }
  }
  return 1;
}

void str2Card(Card *t,char str[]){
    t->suit=str[0];
    t->value=str[1]-'0';
}

int main(void){
  Card C1[100],C2[100];
  int N,i;
  char str[3];
  scanf("%d",&N);
  for(i=0;i<N; i++){
    scanf("%s",str);
    str2Card(&C1[i],str);
  }
  for(i=0; i<N; i++){
      C2[i]=C1[i];
  }
  bubble(C1,N);
  selection(C2,N);
  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  return 0;
}


Measured memory_bytes: 2116
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n,k = MI()
a = sorted(LI())
print(sum(a[:k]))


Measured memory_bytes: 9192
/**
 * Created by hiramekun at 07:31 on 2020-03-31.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << 6 - a - b << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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


int main()
{
    string S, T;
    cin >> S >> T;

    int sLen = S.size();
    int tLen = T.size();
    if (tLen > sLen) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int ed = sLen - tLen;
    int findIndex = -1;
    for (int sPos = 0; sPos <= ed; sPos++) {
        bool find = true;
        for (int tPos = 0; tPos < tLen; tPos++) {
            char sc = S[sPos + tPos];
            char tc = T[tPos];
            if (sc != '?' && sc != tc) {
                find = false;
                break;
            }
        }
        if (find) {
            findIndex = sPos;
        }
    }
    if (findIndex < 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    string ans = "";
    for (int i = 0; i < sLen; i++) {
        if (i >= findIndex && i < findIndex + tLen) {
            ans += T[i - findIndex];
        } else if (S[i] == '?') {
            ans += "a";
        } else {
            ans += S[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val Array(h, w) = StdIn.readLine().split(' ').map(_.toInt)

  val tiles = (0 until h).map(_ => StdIn.readLine().split(' ')).toArray
  val square = Array.fill[Int](h, w)(1)

  (0 until h).foreach { i =>
    (0 until w).foreach { k =>
      square(i)(k) = if (tiles(i)(k) == "1") {
        0
      } else if (i == 0) {
        square(i)(k)
      } else {
        square(i - 1)(k) + 1
      }
    }
  }

  case class Rect(height: Int, pos: Int)

  def pop(lst: List[Rect], row: Array[Int], index: Int): (List[Rect], Int, Int) = {
    val currentH = if (index == row.length) 0 else row(index)
    val (heigher, least) = lst.partition(e => e.height >= currentH)
    val rh = heigher.foldLeft((0, 0)) { (acc, e) =>
      (scala.math.max(acc._1, e.height * (index - e.pos)), e.pos)
    }
    (least, rh._1, rh._2)
  }

  def loop(row: Array[Int]): Int = {
    (0 to w).foldLeft(List.empty[Rect], 0) { (acc, index) =>
      val (lst, temp) = acc
      if (lst.isEmpty) {
        (Rect(row(index), index) :: lst, temp)
      } else if (index == row.length) {
        val (l, max, pos) = pop(lst, row, index)
        (l, scala.math.max(max, temp))
      } else {
        if (lst.head.height < row(index)) {
          (Rect(row(index), index) :: lst, temp)
        } else if (lst.head.height > row(index)) {
          val (l, max, pos) = pop(lst, row, index)
          (Rect(row(index), pos) :: l, scala.math.max(max, temp))
        } else {
          (lst, temp)
        }
      }
    }._2

  }


  val result = square.foldLeft(0) { (acc, elm) =>
    //println(elm.mkString(" "))
    //println(s"$acc")
    scala.math.max(acc, loop(elm))
  }

  println(result)
}



Measured memory_bytes: 522056
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
int main()
{
    LL n,a=0;
    cin >> n;
    vector<LL>t(n+1),y(n);
    REP(i,n+1)cin>>t[i];
    REP(i,n)cin>>y[i];
    REP(i,n){
    if(y[i]>=t[i]+t[i+1]){
        a+=t[i]+t[i+1];
        t[i+1]=0;
    }else if(y[i]>=t[i]){
        a+=t[i];
        y[i]-=t[i];
        a+=y[i];
        t[i+1]-=y[i];
    }else if(y[i]<t[i]){
        a+=y[i];
    }
    }
  cout <<a;
}


Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = sorted(IR(n))
ans = sum(L)
if ans % 10:
    print(ans)
else:
    for i in L:
        if i % 10:
            print(ans - i)
            break
    else:
        print(0)







Measured memory_bytes: 39152
function Main(input) {
    let count = 0;
    let max = 0;
    let streak = true;
    for (i of [0, 1, 2]) {
        if (input.slice(i, i + 1) == "R") {
            count++;
            if (count > max) {
                max = count;
            }
        } else {
            count = 0;
        }
    }
    console.log(max);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e6 + 50, INF = 1e15, MOD = 1e9 + 7;
ll N, heights[max_N], K;
ll DP[max_N];

ll min_cost(ll pos)
{
    if (pos == N - 1)
        return 0;
    ll &res = DP[pos];
    if (res != -1)
        return res;
    res = INF;
    for (ll i = 1; i <= K; ++i)
    {
        if (pos + i >= N)
            continue;
        res = min(res, min_cost(pos + i) + abs(heights[pos] - heights[pos + i]));
    }
    return res;
}

int32_t main()
{
    cin >> N >> K;
    for (ll i = 0; i < N; ++i)
        cin >> heights[i];
    memset(DP, -1, sizeof(DP));
    cout << min_cost(0) << "\n";
    return 0;
}

Measured memory_bytes: 16772
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	long long int k, n;
	long long int count = 0;

	cin >> n >> k;

	count = k;

	FOR(i, 2, n) {
		count *= (k - 1);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll H,W;

int main(){

	scanf("%lld %lld",&H,&W);

	ll ans = 0;
	ll tmp;

	for(ll row = 0; row <= H-1; row++){
		for(ll col = 0; col <= W-1; col++){

			scanf("%lld",&tmp);

			ans += tmp*(col+1)*(W-col)*(row+1)*(H-row);
		}
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3232
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();
        int counter = 0;

        while (counter == 0) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

            switch (op) {
                case "+" : A.add(a + b); break;
                case "-" : A.add(a - b); break;
                case "*" : A.add(a * b); break;
                case "/" : A.add(a / b); break;
                default: {
                    for (int i=0; i<A.size(); i++) {
                        System.out.println(A.get(i));
                    }
                    counter = 1;
                    break;
                }
            }
        }

    }
}


Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	ll k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<int> s;
	vector<int> ord(n+1,-1);
	int c=1,l=0;
	int v=1;
	while(ord[v]==-1) {
		ord[v]=s.size();
		s.push_back(v);
		v=a[v-1];
	}
	c=s.size()-ord[v];
	l=ord[v];
	if(k<l) cout<<s[k]<<endl;
	else {
		k-=l;
		k%=c;
		cout<<s[k+l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5840
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;
template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}

uint64_t GetXor (uint64_t A, uint64_t B) {
    uint64_t ret;
    for (uint64_t i = A; i <=B; i++) {
        if (i == A) ret = i;
        else ret ^= i;
    }
    return ret;
}

int main() {
    uint64_t A(in<uint64_t>()), B(in<uint64_t>());
    uint64_t diff = B - A + 1;
    uint64_t ret;
//uint64_t exa = GetXor(A, B);

    if (diff < 6) {
        ret = GetXor(A, B);
    } else {
                
        if ((A & 1) == 0) {
            
            diff = (diff & 3);
            A = B - diff + 1;
            ret = GetXor(A, B);
           
        } else if ((B & 1) == 1) {
            diff = (diff & 3);
            B = A + diff - 1;
            ret = GetXor(A, B);

        // Both are odd numbers
        } else {
            uint64_t A1 = A + 1;
            diff--;
            diff = (diff & 3);
            A1 = B - diff + 1;
            ret = A ^ GetXor(A1, B);
        }
    }   
//     cout << exa << endl; 
    cout << ret << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static int Pm(int[] A) {
		
		int count = 0;
		
		for(int i=0;i<A.length;i++) {
			boolean NumberF = true;
			for(int j=2;j<= Math.sqrt(A[i]);j++) {
				
				if(A[i] < 2) {
					NumberF = false;
					break;
				}else if(A[i] == 2) {
					break;
				}else if(A[i] % 2 == 0) {
					NumberF = false;
					break;
				}
				
				if(A[i] % j == 0) {
					NumberF = false;
					break;
				}
				
			}
			
			if(NumberF) count++;
		}
		
		return count;
		
	}
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
    	int n = sc.nextInt();
    	
    	int[] box = new int[n];
    	
    	for(int i=0;i<n;i++) {
    		box[i] = sc.nextInt();
    	}
    	
    	System.out.println(Pm(box));
    	
    }
}


Measured memory_bytes: 40860
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool isgood =true;
  if(s[0]==s[1])isgood=false;
  if(s[1]==s[2])isgood=false;
  if(s[2]==s[3])isgood=false;
  if(isgood){
    cout<< "Good" << endl;}
  else{
    cout << "Bad" << endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
     
using namespace std;
     
int main(){
  int n;
  vector<int> input;
      
  cin >> n;
  for(int i = 0;i < n;i++){
    input.push_back(0);
    cin >> input[i];
  }
      
  long double a = 0;
  long double b = 1;
      
  for(int i = 0;i < n;i++){
    b *= input[i];
  }
      
  for(int i = 0;i < n;i++){
    a += b / input[i];
  }
      
  cout << (long double)b / a << endl;
      
  return 0;
}


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

int main(){
 int n, a, b, a_sum, b_sum;
 while(cin>>n, n){
  a_sum=b_sum=0;
  while(n--){
   cin>>a>>b;
   if(a>b)a_sum+=a+b;
   else if(a<b)b_sum+=a+b;
   else a_sum+=a, b_sum+=b;
  }
  printf("%d %d\n", a_sum,b_sum);
 }
 return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
using Int = int64_t;
int solve() {
    Int X, c = 100;
    cin >> X;
    for (int i = 1; i <= 100000; i++) {
        c = (Int)(c * 1.01l);
        if (c >= X) return i;
    }
    return -1;
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main() {
	int N;
	int X;
	int x[100000];
	scanf("%d %d", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}

	int num = x[0]-X;
	if (num < 0)num *= -1;
	for (int i = 1; i < N; i++) {
		int a = num;
		int b = x[i]-X;
		if (b < 0)b *= -1;
		if (a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}

		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		num = b;
	}
	printf("%d", num);

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200050
using namespace std;
char a[200020];
int c[200020];
int d[N];
int main()
{
    int n;
    cin>>n>>a;
    int ans=0,sum=0;
    int x=0,y=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]=='W')
        {
            c[x++]=i;
        }
        else if(a[i]=='R')
        {
            d[y++]=i;
        }
    }
    for(int i=0;i<x;i++)
    {
        if(c[i]<n-x)
        {
            ans++;
        }
    }
    for(int i=0;i<y;i++)
    {
        if(d[i]>y-1)
        {
            sum++;
        }
    }
    if(sum==ans)
    {
        cout<<ans<<endl;
    }
    else if(ans==0||sum==0)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<max(ans,sum)<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> fights(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		fights[i] = { b, a };
	}

	sort(begin(fights), end(fights));
	
	int ans = 0;
	int ryonaPos = -1;
	for (int i = 0; i < m; i++) {
		if (fights[i].second <= ryonaPos) {
			continue;
		}

		ryonaPos = fights[i].first - 1;
		ans++;
	}

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


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
int a[26] = {},b[26] = {};
signed main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		a[s[i] - 97]++;
		b[t[i] - 97]++;
	}
	sort(a, a + 26);
	sort(b, b + 26);
	rep(i, 26) {
		if (a[i] != b[i]) { cout << "No" << endl; endre; }
	}
	cout << "Yes" << endl;
	endre;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,f,x;
  cin>>a>>b>>x;
  if(x>=(a*a*b)/2)
  {
  f = (2/a)*(b - (x/(a*a)));
  }
  else
  {
    f = (a*b*b)/(2*x);
  }
  printf("%.8f",atan(f)*(180/(3.14159265359)));
  return 0;
}


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

int main()
{
  int *a, *c;
  int i, n, k, tail, minlen, nzero;
  scanf("%d %d", &n, &k);
  a = (int*)malloc(sizeof(int)*n);
  c = (int*)malloc(sizeof(int)*(k+1));
  nzero = k;
  for (i=0; i<n; i++)  scanf("%u", &a[i]);
  tail = -1;
  minlen = n+1;
  for (i=0; i<n; i++) {
    if (a[i]>k) continue;
    if (tail<0) tail = i;
    if (c[a[i]]++==0) nzero--;
    while (nzero==0) {
      if (i-tail+1<minlen) minlen = i-tail+1;
      if (c[a[tail++]]--==1) nzero++;
    }
  }
  printf("%d\n", minlen>n?0:minlen);
  return 0;
}



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

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long ll;

const int MAXN = 100100;

int N, M, A[MAXN], C[MAXN];

int main(void) {
  ios_base::sync_with_stdio(false);

  cin >> N >> M;
  A[0] = 1;
  REP(i, N) C[i] = 1;

  REP(i, M) {
    int u, v; cin >> u >> v; --u; --v;
    A[v] |= A[u];
    ++C[v];
    --C[u];
    if (!C[u]) A[u] = 0;
  }

  int ans = 0;
  REP(i, N) ans += A[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
def resolve():
    n = int(input())
    W = list(input() for _ in range(n))
    f = False
    if n==len(set(W)):
        if all(W[i][0] == W[i-1][-1] for i in range(1,len(W))):
            f = True
    print('Yes') if f else print('No')
resolve()

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int n, k;
  cin >> n >> k;
  vint a(n);
  rep(i, n) cin >> a[i];
  cout << (n-1+k-2)/(k-1) << endl;

  return 0;
}


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();
		long[] A = new long[N];
		Arrays.setAll(A, i -> sc.nextLong());
		long ans = 0, t = 0;
		int i = 0, j = 0;
		while(j < N) {
			if(i < N && (A[i] ^ t) == A[i] + t) {
				ans++;
				t += A[i];
				i++;
			}
			else {
				t -= A[j];
				j++;
				ans += i - j;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 90400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x; cin>>x;
	for(int i=1;i<=3333;i++)
	{
		if((i*x)%360==0){cout<<i<<'\n'; return 0;}
	}
}


Measured memory_bytes: 3604
H,W,K = map(int,input().split())

li = [input() for _ in range(H)]
ans = 0
for h in range(2**H):
    for w in range(2**W):
        c = 0
        for i in range(H):#Heightと同じ回数判定する。
            for j in range(W):
                if (h>>i)&1==0 and (w>>j)&1==0:
                    if li[i][j] == '#':
                        c +=1
        if c==K:
            ans+=1
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll K, i, ans[100001];
queue<ll> que;

void bfs(){
    while(1){
        ll p = que.front();
        if(i==100001) break;
        que.pop();

        ll m = p%10;

        if(m>=1){que.push(p*10+m-1); ans[i]=p*10+m-1; i++;}
        que.push(p*10+m); ans[i]=p*10+m; i++;
        if(m<=8){que.push(p*10+m+1); ans[i] = p*10+m+1; i++;}
    }
}

int main(void)
{   
    cin >> K;

    for(i=1; i<=9; i++){
        ans[i] = i;
        que.push(ans[i]);
    }

    i = 10;
    bfs();

    cout << ans[K] << endl;

    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
 
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
 
int solve(){
  int n;cin>>n;
  int i;
  int h[n];
  FIN{
    cin>>h[i];
  }
  ll dp[n]={0};
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<cmath>
#define maxn 55
const double eps =1e-10;
const double g =9.8;
using namespace std;

int N,V,X,Y;
int L[maxn],B[maxn],R[maxn],T[maxn];

//int dcmp(double d){
//	if(d<-eps) return -1;
//	else if(d>eps) return 1;
//	else return 0;
//}

double cal(double vy,double t){
	return vy*t-0.5*g*t*t;
}

int cmp(double lb,double ub,double a){
	return a<lb+eps?-1:ub<a+eps?1:0;
}

bool check(double qx,double qy){
	double a=0.25*g*g,b=g*qy-V*V,c=1.0*qx*qx+qy*qy;
	double D=b*b-4*a*c;
	if(D<0&&D>-eps) D=0;
	if(D<0) return false;
	for(int d=-1;d<=1;d+=2){
		double t2=(-b+d*sqrt(D))/2/a;
		if(t2<=0) continue;
		double t=sqrt(t2);
		
		double vx=qx/t,vy=(qy+0.5*g*t*t)/t;
		double yt=cal(vy,X/vx);
		if(yt<Y-eps) continue;
		
		bool ok=true;
		for(int i=0;i<N;i++){
			if(L[i]>=X) continue;
			if(R[i]==X&&Y<=T[i]&&B[i]<=yt) ok=false;
			
			int yL=cmp(B[i],T[i],cal(vy,L[i]/vx)),
		     	yR=cmp(B[i],T[i],cal(vy,R[i]/vx)),
		     	xH=cmp(L[i],R[i],vx*(vy/g)),
		     	yH=cmp(B[i],T[i],cal(vy,vy/g));
		    if(xH==0&&yH>=0&&yL<0) ok=false;
		    if(yL*yR<=0) ok=false;
		}
		if(ok) return true;
	}
	return false;
}

void slove(){
	for(int i=0;i<N;i++)
		R[i]=min(X,R[i]);
	bool ok=check(X,Y);
	for(int i=0;i<N;i++){
		ok|=check(L[i],T[i]);
		ok|=check(R[i],T[i]);
	}
	printf("%s\n",ok?"Yes":"No");
}

void MAIN()
{
	scanf("%d%d%d%d",&N,&V,&X,&Y);
	for(int i=0;i<N;i++) scanf("%d%d%d%d",&L[i],&B[i],&R[i],&T[i]);
	slove();
}

int main()
{
//	freopen("in#pro.txt","r",stdin);
//	freopen("out#pro.txt","w",stdout);
	MAIN();
	return 0;
}

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

const long long mod=1000000007;

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	set<int> a;
	int b;
	for (int i = 0; i < m; ++i)
	{
		cin>>b;
		a.insert(b);
	}
	long long ans[n+5];
	ans[0]=1LL;
	ans[1]=1LL;
	if (a.count(1)==1)
	{
		ans[1]=0LL;
	}
	for (int i = 2; i <= n; ++i)
	{
		ans[i]=ans[i-1]+ans[i-2];
		ans[i]%=mod;
		if (a.count(i)==1)
		{
			ans[i]=0LL;
		}
	}
	cout<<ans[n]<<endl;
	return 0;
}


Measured memory_bytes: 5760
S = input()
l = ['A', 'C', 'G', 'T']

start = False
counts = [0]

for i, c in enumerate(S):
	if c in l:
		if start == False:
			start = True
			count = 1
		else:
			count += 1
			
		if i == len(S) - 1:
			counts.append(count)
	else:
		if start == False:
			continue
		else:
			start = False
			counts.append(count)
			count = 0

print(max(counts))

Measured memory_bytes: 9108
def main():
    N = int(input())
    A = list(map(int, input().split()))
    l, t, n = 0, 0, 0
    for r, a in enumerate(A):
        while a & t:
            t ^= A[l]
            l += 1
        t |= a
        n += r - l + 1
    return n

print(main())


Measured memory_bytes: 23560
#include <stdio.h>

#define WIDTH 10
#define HEIGHT 10

int field[ WIDTH + 4 ][ HEIGHT + 4 ];
const int dx[ 3 ][ 4 ] = { { -1, 0, 1, 0 }, { -1, 1, -1, 1 }, { -2, 0, 2, 0 } };
const int dy[ 3 ][ 4 ] = { { 0, -1, 0, 1 }, { -1, -1, 1, 1 }, { 0, -2, 0, 2 } };

int main( void ) {
	int i, j, x, y, size, white, max;

	while ( scanf( "%d,%d,%d", &x, &y, &size ) == 3 ) {
		x += 2;
		y += 2;

		field[ x ][ y ]++;

		for ( i = 0; i < size; i++ )
			for ( j = 0; j < 4; j++ )
					field[ x + dx[ i ][ j ] ][ y + dy[ i ][ j ] ]++;
	}

	white = 0;
	max = 0;
	for ( y = 2; y < HEIGHT + 2; y++ )
		for ( x = 2; x < WIDTH + 2; x++ )
			if ( !field[ x ][ y ] )
				white++;
			else if ( max < field[ x ][ y ] )
				max = field[ x ][ y ];

	printf( "%d\n%d\n", white, max );

	return 0;
}

Measured memory_bytes: 600
import math
import copy

class Score:
    def set_data(self, town, score, idx):
        self.town = set_town
        self.score = set_score
        self.idx = set_idx

inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

prev = c

for i in range(10):
    next = a * prev - b
    print(next)

    prev = next


Measured memory_bytes: 38256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=300+10,mo=1000000007;
int f[maxn][maxn][maxn],h[maxn],go[maxn],dis[maxn],nxt[maxn];
int i,j,k,l,r,t,n,m,ans,tot;
void add(int x,int y,int z){
	go[++tot]=y;
	dis[tot]=z;
	nxt[tot]=h[x];
	h[x]=tot;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d%d",&l,&r,&t);
		if (r==1&&t!=1){
			printf("0\n");
			return 0;
		}
		add(r,l,t);
	}
	f[1][0][0]=1;
	fo(i,1,n-1){
		fo(j,0,i)
			fo(k,j,i)
				if (f[i][j][k]){
					if (j||k){
						(f[i+1][k][i]+=f[i][j][k])%=mo;
						(f[i+1][j][i]+=f[i][j][k])%=mo;
					}
					else (f[i+1][0][i]+=f[i][j][k])%=mo;
					(f[i+1][j][k]+=f[i][j][k])%=mo;
				}
		t=h[i+1];
		while (t){
			l=go[t];
			fo(j,0,i)
				fo(k,j,i){
					r=1;
					if (j>=l) r++;
					if (k>=l) r++;
					if (r!=dis[t]) f[i+1][j][k]=0;
				}
			t=nxt[t];
		}
	}
	fo(j,0,n)
		fo(k,j,n){
			r=1;
			if (j) r++;
			if (k) r++;
			if (r==1) (ans+=(ll)f[n][j][k]*3%mo)%=mo;
			else (ans+=(ll)f[n][j][k]*6%mo)%=mo;
		}
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

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

using namespace std;
typedef long long ll;

int main(){
    int n,m,ans = 0;
    cin>>n>>m;
    vector<int> h(n),good(n,1),a(m),b(m);
    rep(i,n) cin>>h[i];
    rep(i,m) cin>>a[i]>>b[i];

    rep(i,m){
       if(h[a[i]-1] < h[b[i]-1]){
           good[a[i]-1] = 0;
       } 
       else if(h[a[i]-1] > h[b[i]-1]){
           good[b[i]-1] = 0;
       }
       else{
           good[a[i]-1] = 0;
           good[b[i]-1] = 0;

       }
    }
    rep(i,n){
        if(good[i]) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<int> a(n),b(n);
    vector<int> cnt(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        cnt[b[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        if(cnt[i] > n){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    reverse(ALL(b));
    queue<int> q;
    int p = -1;
    for (int i = 0; i < n; i++) {
        if(a[i] == b[i]){
            p = a[i];
            break;
        }
    }
    if(p != -1){
        for (int i = 0; i < n; i++) {
            if(a[i] != p and b[i] != p){
                q.push(i);
            }
        }
        for (int i = 0; i < n; i++) {
            if(a[i] == b[i]){
                int t = q.front();q.pop();
                swap(b[i], b[t]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << b[i] << (i + 1 == n ? "\n": " ");
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    map<int, int> mp;
    auto med = mp.begin();
    int l = 0, r = 0, N = 0;
    ll lsum = 0, rsum = 0, B = 0;
    rep(_, Q) {
        int t; cin >> t;

        if (t == 1) {
            int a, b; cin >> a >> b;
            N++;
            mp[a]++;
            B += b;
            if (N == 1) {
                med = mp.begin();
                continue;
            }

            if (med->first < a) {
                r++;
                rsum += a;
                while (l + med->second < (N+1)/2) {
                    l += med->second;
                    lsum += (ll)med->first * med->second;
                    med++;
                    r -= med->second;
                    rsum -= (ll)med->first * med->second;
                }
            }

            else if (med->first > a) {
                l++;
                lsum += a;
                while (l >= (N+1)/2) {
                    r += med->second;
                    rsum += (ll)med->first * med->second;
                    med--;
                    l -= med->second;
                    lsum -= (ll)med->first * med->second;
                }
            }

            else if (med->first == a) {
                while (l + med->second < (N+1)/2) {
                    l += med->second;
                    lsum += (ll)med->first * med->second;
                    med++;
                    r -= med->second;
                    rsum -= (ll)med->first * med->second;
                }
            }
        }

        if (t == 2) {
            ll ans = 0;
            ans += (ll)l * med->first - lsum;
            ans += rsum - (ll)r * med->first;
            ans += B;
            cout << med->first << " " << ans << endl;
        }
    }
}

Measured memory_bytes: 8280
use std::cmp;

pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

impl  Scanner{
   #[allow(dead_code)]
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   #[allow(dead_code)]
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
}


fn main() {
    let mut scan = Scanner::new();
    let x:usize  = scan.next();
    let y:usize  = scan.next();
    let a:usize  = scan.next();
    let b:usize  = scan.next();
    let c:usize  = scan.next();
    let mut v1 : Vec<i32>= Vec::with_capacity(a);
    let mut v2 : Vec<i32>= Vec::with_capacity(b);
    let mut v3 : Vec<i32>= Vec::with_capacity(c);
    for _ in (0..a){
        v1.push(scan.next());
    }
    for _ in (0..b){
        v2.push(scan.next());
    }
    for _ in (0..c){
        v3.push(scan.next());
    }
    v1.sort();
    v2.sort();
    v3.sort();

    let mut sum : i64 = 0;
    for i in (0..x){
        sum += v1[a - 1 - i] as i64;
    }
    for i in (0..y){
        sum += v2[b - 1 - i] as i64;
    }
    let mut ans = sum;
    let d = cmp::min(x+y, c);
    let mut idx1 : usize = a - x;
    let mut idx2 : usize = b - y;
    for i in 0..d as usize {
        if idx1 != a && (idx2 == b || v1[idx1] < v2[idx2]){
            sum -= v1[idx1] as i64;
            idx1 += 1;
        } else{
            sum -= v2[idx2] as i64;
            idx2 += 1;
        }
        sum += v3[c - 1 - i] as i64;
        ans = cmp::max(ans, sum);
    }

    println!("{}", ans);
}


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

int main(){
  const int M= 2019;
  string N;
  cin >> N;
  const int Nlen= N.size();

  int64_t ans= 0;
  vector<int64_t> mod(M);
  int modM= 0;
  mod.at(modM)++;
  for(int i=Nlen, t=1; i>0; i--, t= t*10 % M){
    int dig_i= N.at(i-1)- '0';
    modM= (modM+ t*dig_i) % M;
    mod.at(modM)++;
  }

  for(int i=0; i<M; i++){
    ans+= mod.at(i)*(mod.at(i)- 1)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  rep(i,10){
    c=c*a-b;
    cout << c << endl;
  }
}  


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

int main()
{ char a[200];
     int i,k,b[5];




           gets(a);
              k=strlen(a);
            for(i=0;i<k;i++)
                 b[i]=0;
          for(i=0;i<k;i++)
     if(a[i]=='+'||a[i]=='-')

     {for(i=0;i<k;i++)
       { if(a[i]=='+') b[0]++;

         if(a[i]=='-')  b[0]--;


        } printf("%d",b[0]);

             b[i]=0;
        }
             else
 printf("Print the integer in Takahashi's mind after he eats all the symbols.");
 return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;

    string s = "";
    if(n == 0){ cout << 0 << endl; return 0; }
    while(n != 0){
        if(n % 2){
            s = "1" + s;
            n -= 1;
        }else{
            s = "0" + s;
        }
        n /= -2;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct list {
	char chData;
	struct list* pstNext;
}LIST;

void vdSearchAddress(int iValue, LIST** ppstCurrent);

// 文字列Tを、先頭から入力hまでの文字を末尾に連結するシャッフルをM回繰り返して最後に出力
// "abcde"をh=3でシャッフルすると"deabc"となる
int main()
{
	int iInputM, iInputH;
	LIST* pstHead;		// 構造体配列の先頭アドレス
	LIST* pstCurrent;	// 現在見ている構造体のアドレス
	LIST astList[200];
	char achInput[200];
	int iCnt, iCnt2;
	int iInputLength;

	// 改行文字まで読み込み(文字列長取得)
	scanf("%s", achInput);
	while (achInput[0] != '-')
	{
		// リストの先頭アドレスを格納
		pstHead = &astList[0];

		iInputLength = 0;
		while (achInput[iInputLength] != '\0')
		{
			// 一文字目が'-'なら終了
			astList[iInputLength].chData = achInput[iInputLength];
			astList[iInputLength].pstNext = &astList[iInputLength + 1];
			iInputLength++;
		}

		// 末尾のポインタをNULL
		if (iInputLength > 0) {
			astList[iInputLength - 1].pstNext = NULL;
		}
		else
		{
			// 1文字も入力されていないなら終了
			pstHead = NULL;
			return 0;
		}

		scanf("%d", &iInputM);

		// シャッフル（リストのポインタの付け替え）
		for (iCnt = 0; iCnt < iInputM; iCnt++)
		{
			scanf("%d", &iInputH);

			// 末尾のポインタを先頭に付け変え
			pstCurrent = pstHead;
			vdSearchAddress(iInputLength, &pstCurrent);
			pstCurrent->pstNext = pstHead;

			// 先頭ポインタを付け変え
			pstCurrent = pstHead;
			vdSearchAddress(iInputH, &pstCurrent);
			pstHead = pstCurrent->pstNext;

			// 末尾をNULL
			pstCurrent = pstHead;
			vdSearchAddress(iInputLength, &pstCurrent);
			pstCurrent->pstNext = NULL;
		}


		// 次のポインタがNULLになるまで先頭から順にたどって出力
		pstCurrent = pstHead;
		while (pstCurrent->pstNext != NULL)
		{
			printf("%c", pstCurrent->chData);
			pstCurrent = pstCurrent->pstNext;
		}
		printf("%c\n", pstCurrent->chData);

		scanf("%s", achInput);
	}

	return 0;
}

// ppstCurrentの先のポインタにiValue番目のリストのアドレスセット
void vdSearchAddress(int iValue, LIST** ppstCurrent)
{
	while (iValue > 1)
	{
		//printf("%c", (*ppstCurrent)->chData);
		*ppstCurrent = (*ppstCurrent)->pstNext;
		iValue--;
	}
	return;
}




Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	
	int dx = tx - sx, dy = ty - sy;
	
	string ans = "";
	REP(i, dy) ans += "U";
	REP(i, dx) ans += "R";
	
	REP(i, dy) ans += "D";
	REP(i, dx) ans += "L";
	
	ans += "LU";
	REP(i, dy) ans += "U";
	REP(i, dx) ans += "R";
	ans += "RD";
	
	ans += "RD";
	REP(i, dy) ans += "D";
	REP(i, dx) ans += "L";
	ans += "LU";
	
	cout << ans << endl;
	return 0;
}

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

int main(){
  ll x;
  cin >> x;
  ll a = 100;
  ll k = 0;
  while(a < x) {
    ll b =  a/100;
    a += b;
    k++;
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, sum[100007], dp[100007], is, pre[3] = { 0,-1,-1 };
char s[100007];
int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
		sum[i] = (sum[i - 1] + (s[i] - 'a' + 1)) % 3;
	for (int i = 2; i <= n; i++)
		if (s[i] == s[i - 1])is = 1;
	if (!is) { cout << 1 << endl; return 0; }
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (i < n && !sum[i])dp[i] = 1;
		dp[i] = (dp[i] + dp[i - 1]) % mod;
		int v = (sum[i] + (s[i] - 'a' + 1)) % 3;
		if (pre[v] != -1)dp[i] = (dp[i] + dp[pre[v]]) % mod;
		pre[sum[i]] = i;
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vs field(n);
		rep(i,n)
			cin>>field[i];
		
		vvi dp(n,vi(n));
		rep(i,n){
			dp[0][i]=field[0][i]=='.';
			dp[i][0]=field[i][0]=='.';
		}
		repi(i,1,n)
			repi(j,1,n){
				if(field[i][j]=='*')
					dp[i][j]=0;
				else
					dp[i][j]=1+min(min(dp[i-1][j-1],dp[i-1][j]),dp[i][j-1]);
			}
		int res=0;
		rep(i,n)
			rep(j,n)
				res=max(res,dp[i][j]);
		cout<<res<<endl;
	}
	
	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e2 + 10;
const int mod = 1e9 + 7;


map<int,int> mp;

int32_t main(){
	boost;
	int n;
	cin >> n;

	int ans = n/11;
	ans <<= 1;
	int rem = n%11;

	if(rem){
		ans += rem/6;
		rem %= 6;

		if(rem)
			ans += 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	bool flag=true;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			flag=false;
			break;
		}
		else
		continue;
	}
	if(flag==false)
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// double じゃ精度足りない
#define mod 1000000007
ll dp[201][100001];

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

    sort(S.begin(), S.end());
    // dp[残り回数][現在のX] = 期待値
    for (int i = 0; i <= X; ++i) {
        dp[0][i] = i;
    }
    for (int i = 1; i <= N; ++i) {
        // 1/i の確率で採択
        for (int j = 0; j <= X; ++j) {
            dp[i][j] = dp[i-1][j % S[i-1]];
            dp[i][j] += dp[i-1][j] * (i - 1);
            dp[i][j] %= mod;
            // 分母のiと最後のN!で相殺
        }
    }
    cout << dp[N][X];
    return 0;
}

Measured memory_bytes: 157312
import java.io.*;
 
class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String str = br.readLine();

        String[] strarr = str.split(" ");
        int[] intarr = new int[3];

        for(int i=0; i<3; i++)
        {
            intarr[i] = Integer.parseInt(strarr[i]);
        }
        
        if(intarr[0] < intarr[1] && intarr[1] < intarr[2])
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

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

int main() {
  size_t N, M;
  std::cin >> N;
  std::cin >> M;

  std::vector<std::pair<size_t, size_t>> Reqs(M);

  for (auto i=0; i<M; i++) {
    size_t a, b;
    std::cin >> a;
    std::cin >> b;
    Reqs[i] = std::make_pair(a, b);
  }

  std::sort(Reqs.begin(), Reqs.end());

  size_t min_r = N;
  size_t ans = 1;

  for (auto r : Reqs) {
    if (r.first > min_r) {
      ans++;
      min_r = r.second - 1;
    } else {
      min_r = std::min(min_r, r.second - 1);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1792
n = int(input())
ans = float("inf")

for i in range(1,n):
  num1 = i
  num2 = n-i
  keta1 = str(num1)
  keta1 = sum([int(keta1[j]) for j in range(len(keta1))])
  keta2 = str(num2)
  keta2 = sum([int(keta2[j]) for j in range(len(keta2))])
  ans = min(ans,keta1+keta2)

print(ans)

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

int main(void){
  int x;

  cin >> x;

  // x/100:上1桁 x%100:下2桁 x%100%10:下2桁の下1桁
  if(x/100 == x%100%10) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main() {
    const long long Mod=1000000007;
    int n;
    cin >> n;
    //int a[100005];
    long long s=1;
    int c[100005];
    for(int i=0; i<n; i++) c[i] = 0;
    for(int i=0; i<n; i++){
        long long x;
        cin >> x;
        //bool flag = true;
        if(x==0){
            if(c[0]==3){
                cout << 0 << endl;
                return 0;
            }
            s *= 3-c[x];
            s %= Mod;
            c[x]++;
        } else {
            if (c[x]==3 | c[x-1] <= c[x]) {
                cout << 0 << endl;
                return 0;
            }
            s *= c[x-1]-c[x];
            s %= Mod;
            c[x]++;
        }
    }
  
    cout << s << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll calc(ll x,ll y,ll z){
  ll A=x*x*x+y*y*y;
  return (A<=z*z*z) ? A:0;
}

int main(){
  ll z;
  while(cin>>z,z){

    ll mx=0;
    for(int i=1;i<2000;i++)
      for(int j=1;j<2000;j++)mx=max(mx,calc(i,j,z));
    cout<<z*z*z-mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;

int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    cout << min(n*a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
import sys
input = sys.stdin.readline
A = [0] * N
for i in range(Q):
  s = int(input().rstrip())
  A[s-1] += 1
for k in A:
  if K - (Q - k) >= 1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9920