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

using namespace std;

long long prime = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    deque<char> d;
    for (char c : s) {
        d.push_back(c);
    }
    int num_queries;
    cin >> num_queries;
    bool reversed = false;
    for (int i = 0; i < num_queries; ++i) {
        int t;
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
        } else {
            int f;
            string s_c;
            cin >> f >> s_c;
            if ((f == 2) == reversed) {
                d.push_front(s_c[0]);
            } else {
                d.push_back(s_c[0]);
            }
        }
    }
    if (!reversed) {
        for (char c : d) {
            cout << c;
        }
    } else {
        for (int i = (int) d.size() - 1; i >= 0; --i) {
            cout << d[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 976
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


typedef long long i64;
const int mod = (int)1e9 + 7;

void add(int& x, int v)
{
	x = (x + v) % mod;
}

int main()
{
	int n, m;

	scanf("%d%d", &n, &m);

	vector<vector<int>> dp[2];

	for(auto& d : dp) {
		d.resize(n);
		for(auto& v : d)
			v.resize(n, 0);
	}

	dp[0][0][0] = 1;

	for(int e_num = 0; e_num < m; ++e_num) {

		int dp_cur_idx = e_num & 1;
		int dp_next_idx = 1 - dp_cur_idx;
		vector<vector<int>>& cur = dp[dp_cur_idx];
		vector<vector<int>>& next = dp[dp_next_idx];

		for(auto& v : next)
			fill(v.begin(), v.end(), 0);

		for(int range = 0; range < n; ++range) {
			for(int bi_v = 0; bi_v <= range; ++bi_v) {

				int c = cur[range][bi_v];
				i64 r = range - bi_v;
				i64 s = bi_v + 1;

				if(range < n - 1)
					add(next[range + 1][bi_v], c);
				add(next[range][bi_v], (int)(r * c % mod));
				add(next[range][range], (int)(s * c % mod));
			}
		}
	}

	int ans = dp[m & 1][n - 1][n - 1];
	for(i64 i = 1; i <= n - 1; ++i)
		ans = ans * i % mod;

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

	return 0;
}


Measured memory_bytes: 896
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static long v = long.Parse(input[0]);
static long e = long.Parse(input[1]);
static long[] parents = new long[v];//親
static long[][] edges = new long[e][];
static long answer = 0;
  
	static void Main()
	{
    for(long i = 1; i < v; i++)
    {
    parents[i] = i;
    }

    for(long i = 0; i < e; i++)
    {
      edges[i] = new long[3];
      string[] memo = Console.ReadLine().Split(' ');
      edges[i][0] = long.Parse(memo[0]);
      edges[i][1] = long.Parse(memo[1]);
      edges[i][2] = long.Parse(memo[2]);
    }
    Array.Sort(edges, (a, b) => a[2].CompareTo(b[2]));//長さでソート
    
    for(long i = 0; i < e; i++)//クラスカル法
    {
      if(whatParent(edges[i][0]) != whatParent(edges[i][1]))
      {
        parents[whatParent(edges[i][0])] = whatParent(edges[i][1]);//親を結合して統一。親が2人できることはない。
        answer += edges[i][2];
      }
    }
    Console.WriteLine(answer);
	}

  static long whatParent(long child)
  {
    if(parents[child] == child) return child;
    else return parents[child] = whatParent(parents[child]);
  }
  
}


Measured memory_bytes: 28436
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main(){
    int a, b;
    vector<int> v, v2;
    v2.push_back(100000);
    cin>>a;
    for(int i=1;i<a;i++){
        cin>>b;
        v.push_back(min(b, v2.back()));
        v2.push_back(b);
    }
    v.push_back(b);
    int c=0;
    rep(i, a)
        c+=v[i];
    cout<<c<<endl;
}

Measured memory_bytes: 256
oni_pos, oni_V = map(int, input().split())
nige_pos, nige_W = map(int, input().split())
T_s = int(input())

diff = abs(oni_pos - nige_pos)
d_V = oni_V - nige_W


if (oni_V == nige_W):
    print('NO')
    exit()

time = diff / d_V

if (d_V < 0):
    print('NO')
    exit()
    
if (time <= T_s):
    print('YES')
else:
    print('NO')



Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> cnt(60, 0);
  rep(i, n) rep(j, 60) if ((a[i] >> j) & 1) cnt[j]++;
  ll ans = 0;
  rep(i, 60) {
    ans += ((1L << i) % mod * ((n - cnt[i]) * cnt[i] % mod)) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

int v[15][15];
int n;

int resp = 0;

int teste(int hon) {
	int cont = 0;

	for(int i = 0; i < 15; i++) {
		if((1 << i) & hon) {
			cont++;
			for(int j = 0; j < 15; j++) {
				if(i == j) continue;
				if(v[i][j] == 1 and !((1 << j) & hon)) return 0;
				if((1 << j) & hon) {
					if(v[i][j] == 0) return 0;
				}
			}
		}
	}

	return cont;
}

void solve(int index, int hon) {
	if(index == n) {
		resp = max(resp, teste(hon));
		return;
	}

	solve(index+1, hon | (1 << index));
	solve(index+1, hon);
}	

int main() {
	scanf("%d", &n);

	for(int i = 0; i < 15; i++) {
		for(int j = 0; j < 15; j++) {
			v[i][j] = -1;
		}
	}

	for(int i = 0; i < n; i++) {
		int qt;
		scanf("%d", &qt);
		while(qt--) {
			int x,y;
			scanf("%d %d", &x, &y);
			x--;
			v[i][x] = y;
		}
	}

	solve(0, 0);
	printf("%d\n",resp );

	return 0;
}


Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        for (int i = 0; i < inp[0]; i++)
        {
            var ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (ab[0] >= inp[1] && ab[1] >= inp[2]) ans++;
        }
        Console.WriteLine(ans);
    }
}

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

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

void Main() {
  int x;
  cin >> x;
  ll ans = 0;
  while(x >= 500) {
    ans += 1000;
    x -= 500;
  }
  while(x >= 5) {
    ans += 5;
    x -= 5;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

int main(int argc, char* argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> Ls(N);
  for (auto&& L : Ls) {
    std::cin >> L;
  }
  int max_L = *std::max_element(std::begin(Ls), std::end(Ls));
  int sum   = 0;
  std::for_each(std::begin(Ls), std::end(Ls),
                [&](const decltype(Ls)::value_type& e) { sum += e; });
  sum -= max_L;
  std::cout << (max_L < sum ? "Yes" : "No") << std::endl;
  return 0;
}


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }

    int ans = 0;

    for(int bit = 0; bit < (1<<h); ++bit){
        vector<int> s;
        for(int i = 0; i < h; ++i){
            if(bit & (1<<i)){
                s.push_back(i);
            }
        }
        for(int bit_2 = 0; bit_2 < (1<<w); ++bit_2){
            vector<int> s_2;
            for(int i = 0; i < w; ++i){
                if(bit_2 & (1<<i)){
                    s_2.push_back(i);
                }
            }

            int cou = 0;
            for(int i = 0; i < h; i++){
                auto itr = find(s.begin(), s.end(), i);
                if(itr == s.end()){
                    for(int j = 0; j < w; j++){
                        auto itr_2 = find(s_2.begin(), s_2.end(), j);
                        if(itr_2 == s_2.end()){
                            if(c[i][j] == '#'){
                                cou++;
                            }
                        }
                    }
                }
            }

            if(cou == k){
                ans++;
            }
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define out (x1+dx[i]<1||x1+dx[i]>h||y1+dy[i]<1||y1+dy[i]>w)
#define inf 0x3f3f3f3f
using namespace std;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
const int maxn=55;
char a[maxn][maxn];
int d[maxn][maxn];
bool vis[maxn][maxn];
void init(int h,int w){
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
        d[i][j]=inf,vis[i][j]=false;
}
void bfs(int h,int w)
{
    vis[h][w]=true;d[h][w]=1;
    queue<int>p1;p1.push(h);queue<int>p2;p2.push(w);int x1,y1;
    while (!p1.empty()&&!p2.empty()) {
        x1=p1.front();y1=p2.front();p1.pop();p2.pop();
        for(int i=0;i<4;i++)if(!out&&a[x1+dx[i]][y1+dy[i]]=='.'){
            if(!vis[x1+dx[i]][y1+dy[i]])
            {
                d[x1+dx[i]][y1+dy[i]]=min(d[x1+dx[i]][y1+dy[i]],d[x1][y1]+1);
                vis[x1+dx[i]][y1+dy[i]]=true;
                p1.push(x1+dx[i]);p2.push(y1+dy[i]);
            }
        }
    }
}
int main()
{
    int h,w;
    while (scanf("%d%d",&h,&w)==2&&h) {
        for(int i=1;i<=h;i++)scanf("%s",a[i]+1);
        init(h, w);bfs(h, w);
        if(d[1][1]>=inf){printf("-1\n");continue;}
        int sum=0;
        for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
            if(a[i][j]=='.')sum++;
        printf("%d\n",sum-d[1][1]);
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		int H,W,N;
		cin >> H >> W >> N;
		if(H==0&&W==0&&N==0)break;
		int mp[H+2][W+2];
		int dp[H+2][W+2];
		for(int i=0;i<H+2;i++)
		{
			for(int j=0;j<W+2;j++)
			{
				mp[i][j]=-1;
			}
		}
		memset(dp,0,sizeof(dp));
		dp[1][1]=N-1;
		for(int i=1;i<=H;i++)
		{
			for(int j=1;j<=W;j++)
			{
				cin >> mp[i][j];
			}
		}
		for(int i=1;i<=H;i++)
		{
			for(int j=1;j<=W;j++)
			{
				if(dp[i][j]%2==1)
				{
					if(mp[i][j]==0)
					{
						dp[i+1][j]+=(dp[i][j]+1)/2;
						dp[i][j+1]+=(dp[i][j]-1)/2;
					}
					else
					{
						dp[i][j+1]+=(dp[i][j]+1)/2;
						dp[i+1][j]+=(dp[i][j]-1)/2;
					}
				}
				else
				{
					dp[i+1][j]+=dp[i][j]/2;
					dp[i][j+1]+=dp[i][j]/2;
				}
			}
		}
		int i=1,j=1;
		while(1)
		{
			if(mp[i][j]==-1)break;
			if(mp[i][j]&&dp[i][j]%2)i++;
			else if(mp[i][j]&&!(dp[i][j]%2))j++;
			else if(!mp[i][j]&&dp[i][j]%2)j++;
			else i++;
		}
		cout << i << ' ' << j << endl;
	}
	return 0;
}

Measured memory_bytes: 9008
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    int n,S[1000]={};
    while(true){
        int count=0;
        double m,sigma=0,a;
        cin>>n;
        if(n==0) break;
        for(int i=0;i<n;i++){
            cin>>S[i];
            count+=S[i];
        }
        m=1.0*count/n;
        for(int i=0;i<n;i++){
            sigma+=(S[i]-m)*(S[i]-m);
        }
        a=sqrt(sigma/n);
        printf("%f\n",a);
    }
    return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
#define N 10000

int main( void )
{
	int i, j, c = 0, n, q, s[N], t;
	
	scanf( "%d", &n );
	
	for ( i = 0; i < n; i++ ) {
		scanf( "%d", &s[i] );
	}
	
	scanf( "%d", &q );
	
	for ( i = 0; i < q; i++ ) {
		scanf( "%d", &t );
		for ( j = 0; j < n; j++ ) {
			if ( t == s[j] ) {
				t = -1;
			}
		}
		if ( t == -1 ) {
			c++;
		}
	}
	
	printf( "%d\n", c );
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int a[20][20];

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

    rep(i,n){
        int m; cin >> m;
        rep(j,m){
            int x, y;
            cin >> x >> y;
            x--;
            if(y == 1)a[i][x] = 1;
            if(y == 0)a[i][x] = -1;
        }
    }

    int ans = 0;

    rep(loop, 1 << n){
        int f[n] = {};
        int ii = loop;
        int cnt = 0;
        rep(i,n){
            f[i] = ii % 2;
            ii /= 2;
            cnt += f[i];
        }
        int flag = 1;
        rep(i,n){
            rep(j,n){
                if(f[i] == 1 && a[i][j] == 1 && f[j] == 0)flag = 0;
                if(f[i] == 1 && a[i][j] == -1 && f[j] == 1)flag = 0;
            }
        }

        if(flag)ans = max(ans, cnt);
    }

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



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

int main() {
  long n,ans=0;
  cin >> n;
  vector<char> march={'M','A','R','C','H'};
  vector<long> a(5);
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    for(int j=0;j<5;j++) {
      if(s[0]==march[j]) {
        a[j]++;
        break;
      }
    }
  }
  for(int i=0;i<5;i++) {
    for(int j=i+1;j<5;j++) {
      for(int k=j+1;k<5;k++) {
        ans+=a[i]*a[j]*a[k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long 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 ll INF = 1LL << 60;

int main() {
    vector<int> a(3);
    vector<int> b(3);
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    a[0] = 0;
    for (int j = 0; j < 3; j++) {
        b[j] = c[0][j];
    }
    for (int i = 1; i < 3; i++) {
        a[i] = c[i][0] - b[0];
    }

    bool flag = true;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (c[i][j] != a[i] + b[j]) flag = false;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<map>
using namespace std;
int  main(){
	int n,r;
	scanf("%d%d",&n,&r);
	if(n>=10)
	printf("%d\n",r);
	else
	printf("%d\n",r+100*(10-n)); 
	
	
}









Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        long product = (long)a * b;

        System.out.println(product / gcd(a, b));
    }

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


Measured memory_bytes: 21972
package main

import (
	"fmt"
	"sort"
)

type Manual []int

func (manual Manual) asValue() Manual {
	var intSlice []int
	for _,val := range manual {
		intSlice = append(intSlice,val)
	}

	return Manual(intSlice)
}

func (manual Manual) remove(index int) {
	copy(manual[index:],manual[index + 1:])

	manual = manual[:len(manual) - 1]
}

func (manual Manual) noDuplication() Manual {
	var noDup Manual
	m := manual.asValue()
	sort.Sort(sort.IntSlice([]int(m)))

	before := make(map[int]bool)
	for _,val := range m {
		if ok := before[val];!ok {
			before[val] = true
			noDup = append(noDup,val)
		}
	}
	return noDup
}

func (manual Manual) evenNumber() Manual {
	sampleManual := manual.asValue()
	sort.Sort(sort.IntSlice([]int(sampleManual)))

	countInt := make(map[int]int,sampleManual.count())
	for _,val := range sampleManual {
		countInt[val]++
	}

	var m Manual
	for key,val := range countInt {
		if !isEven(val) {
			m = append(m,key)
		}
	}

	return m
}

func (manual Manual) count() int {
	return len(manual)
}

func isEven(num int) bool {
	if num % 2 == 0 {
		return true
	}
	return false
}

func main() {
	var manual Manual
	var N int
	var num int

	fmt.Scan(&N)
	manual = make(Manual,N)
	for count := 0;count < N; count++ {
		fmt.Scan(&num)
		manual[count] = num
	}

	fmt.Println(manual.evenNumber().count())
}


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

int main(){
  int k, t;
  cin >> k >> t;
  int maxa = 0, tota = 0;
  for(int i=0; i<t; ++i){
    int a;
    cin >> a;
    maxa = max(maxa, a);
    tota += a;
  }
  if(tota%2){
    maxa = max(0, maxa -(tota+1)/2);
    cout << maxa *2 << endl;
    return 0;
  }
  maxa = max(0, maxa -tota/2);
  if(maxa) maxa = maxa *2 -1;
  cout << maxa << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int h,w;
  cin>>h>>w;
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];

  vector<vector<int>> ans(h,vector<int>(w));

  int crnt = 0;
  rep(i,h)rep(j,w){
    ans[i][j] = crnt+1;
    vec[crnt]--;
    if(vec[crnt]==0) crnt++;
  }

  rep(i,h) if(i%2==1) reverse(all(ans[i]));

  rep(i,h) rep(j,w) cout << ans[i][j] << " \n"[j==w-1];

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int H = sc.nextInt();
    int W = sc.nextInt();
    
    System.out.println((N-W+1)*(N-H+1));
  }
}

Measured memory_bytes: 22740
sx,sy,tx,ty = ( int(x) for x in input().split() )

rx = tx - sx
ry = ty - sy

ans = []
# 'U' 'D' 'L' 'R'
# 1
for i in range( ry ):
    ans.append( 'U' )
for i in range( rx ):
    ans.append( 'R' )
# 2
for i in range( ry ):
    ans.append( 'D' )
for i in range( rx ):
    ans.append( 'L' )
# 3
ans.append( 'L' )
for i in range( ry + 1 ):
    ans.append( 'U' )
for i in range( rx + 1 ):
    ans.append( 'R' )
ans.append( 'D' )
# 4
ans.append( 'R' )
for i in range( ry + 1 ):
    ans.append( 'D' )
for i in range( rx + 1 ):
    ans.append( 'L' )
ans.append( 'U' )

print( ''.join(ans) )

Measured memory_bytes: 9100
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<string> vs;
    typedef vector<ll> vl;
    typedef vector<vector<int, int> > vvi;
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define in insert
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    const int INF = 1e9 + 5;
    int main(){
        string s;
        cin >> s;
        stack<char> c;
        for(int i = 0; i < s.size(); i++){
            if(s[i]=='0' || s[i]=='1'){
                c.push(s[i]);
            }
            else if(s[i]=='B'){
                if(c.size()!=0){
                    c.pop();
                }
            }
        }
        string t = "";
        while(c.size()!=0){
            t+=c.top();
            c.pop();
        }
        reverse(all(t));
        cout << t;
    }

Measured memory_bytes: 384
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        half = a // 2
        a = half
        b += half
    else:
        if b % 2 == 1:
            b -= 1
        half = b // 2
        b = half
        a += half

print(a, b)

Measured memory_bytes: 3064
#!/usr/bin/env python3

import math

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

A = list(map(int,input().split(" ")))
#print(A)
s = []
t = []
u = []
for i in range(m):
    b,c = list(map(int,input().split(" ")))
    t.append((c,b))
t.sort()
#print(t)
#print(t[-1][0])
for i in range(n):
    if A[i] < t[-1][0]:
        u.append(A[i])
    else:
        s.append(A[i])
#print(u)
#print(s)
u.sort()
#print(u)
x = 0
y = 0
ans = 0
count = 0
for i in range(len(u)):
    #print(x,y)
    if u[i] < t[-x-1][0]:
        u[i] = t[-x-1][0]
    if i == y + t[-x-1][1] - 1:
        x += 1
        y += i+1 - y
        if x == len(t):
            break
#print(u)
ans += sum(s)
ans += sum(u)
print(ans)

Measured memory_bytes: 21888
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
vector <int> to[100001];
queue <int> que;
int n,m,a,b,ans[100001],d;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	d=n-1;
	for(int i=1;i<=m;++i)
	{
		cin>>a>>b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	fill(ans+2,ans+1+n,INF);
	que.push(1);
	while(!que.empty())
	{
		int now=que.front();
		que.pop();
		for(int i=0;i<to[now].size();++i)
		{
			if(ans[to[now][i]]==INF)
			{
				ans[to[now][i]]=now;
				--d;
				que.push(to[now][i]);
			}
		}
	}
	if(!d)
	{
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;++i)
		{
			cout<<ans[i]<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 12940
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MAX_N 110000
#define INF 10000000000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll n;
vector<ll> G[MAX_N];
vector<ll> d(MAX_N,INF);
vector<ll> pr(MAX_N,-1);
ll col[MAX_N]={};
bool used[MAX_N]={};
void dij(int s){
  d[s] = 0;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(P(0,s));
  while(!que.empty()){
    P tmp = que.top();
    que.pop();
    ll v=tmp.second,dis = tmp.first;
    if(d[v] < dis){
      continue;
    }
    for(auto nv:G[v]){
      if(d[nv] > d[v]+1){
        d[nv] = d[v]+1;
        pr[nv] = v;
        que.push(P(d[nv],nv));
      }
    }
  }
}
vector<ll> g_path(int t){
  vector<ll> path;
  for(; t!=-1;t=pr[t]){
    path.push_back(t);
  }
  reverse(path.begin(),path.end());
  return path;
}
void dfs(int v,int nc){
  if(used[v]) return;
  if(col[v]!=0&&col[v]!=nc){
    return;
  }
  col[v] = nc;
  used[v] = true;
  for(auto nv:G[v]){
    dfs(nv,nc);
  }
}
signed main(){
  init_io();
  ll n,len;
  cin >> n;
  vector<ll> a(n-1),b(n-1);
  for(int i=0;i<n-1;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  dij(0);
  vector<ll> tmp = g_path(n-1);
  ll id = 1;
  len = tmp.size();
  for(auto v:tmp){
    if((len+1)/2 >= id){
      col[v] = 1;
    }else{
      col[v] = 2;
    }
    id++;
  }
  dfs(0,1);
  dfs(n-1,2);
  ll sc = 0,fc=0;
  for(int i=0;i<n;i++){
    if(col[i]==1) fc++;
    else if(col[i]==2)sc++;
  }
  if(fc>sc) cout <<"Fennec\n";
  else cout <<"Snuke\n";
}


Measured memory_bytes: 12660
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
//#include "Header.h"
int main()
{
	static ll n,i=0,j=0,alp[30],ans=1;
	ll mod = 1e9 + 7;
	string s;
	cin >> n >> s;
	for (i = 0; i < n; i++)
	{
		alp[s[i]]++;
	}
	for (i = 'a'; i <= 'z'; i++)
	{
		ans *= alp[i] + 1;
		ans %= mod;
		//printf("%d:%d", i, alp[i]);
	}
	cout << ans-1 << endl;
}


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

using namespace std;
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<pair<int,int>>a;
signed main(){
    IOS;
    int n,x,y;
    cin >> n;
    for(int i =1;i<=n;i++){
        cin >> x >> y;
        a.push_back({y,x});
    }
    sort(a.begin(),a.end());
    int t=0;
    for(int i =0;i<n;i++){
        t+=a[i].second;
        if(t>a[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

return 0;}




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

int dp[105][4][2];

int main() {
  int x, ans;
  cin >> x;
  
  if( x <= 1999 && x >= 1800 )ans = 1;
  else if ( x <= 1799 && x >= 1600 )ans = 2;
  else if ( x <= 1599 && x >= 1400 )ans = 3;
  else if ( x <= 1399 && x >= 1200 )ans = 4;
  else if ( x <= 1199 && x >= 1000 )ans = 5;
  else if ( x <= 999 && x >= 800 )ans = 6;
  else if ( x <= 799 && x >= 600 )ans = 7;
  else if ( x <= 599 && x >= 400 )ans = 8;
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, t, dp[3100][3100], dp2[3100][3100], dm[3100][3100], dm2[3100][3100], a[3100], b[3100], ans;
int main(){
    cin >> n >> t;
    REP(i,n) cin >> a[i] >> b[i];
    REP(i, n){
        REP(j, t + 1){
            if(j + a[i] <= t) dp[i + 1][j + a[i]] = max(dp[i + 1][j + a[i]], dp[i][j] + b[i]);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    REPR(i, n - 1){
        REP(j, t + 1){
            if(j + a[i] <= t) dp2[i][j + a[i]] = max(dp2[i][j + a[i]], dp2[i + 1][j] + b[i]);
            dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
        }
    }
    REP(i,n + 1) {
        REP(j, t + 1){
            dm[i][j + 1] = max(dm[i][j], dp[i][j + 1]);
        }
    }
     REPR(i,n) {
        REP(j, t + 1){
            dm2[i][j + 1] = max(dm2[i][j], dp2[i][j + 1]);
        }
    }
    REP(i, n){
        REP(j, t){
            ans = max(ans, b[i] + dm[i][j] + dm2[i + 1][t - j - 1]);
        }
        REP(j, t + 1){
            ans = max(ans, dm[i][j] + dm2[i + 1][t - j]);
        }
    }
    cout << ans <<endl;
}


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

int main() {
  string S = "";
  cin >> S;
  
  int cnt = 0;
  
  if (S.length() >= 2) {
    for (int i = 0; i < S.length() - 1; ++i) {
      if (S[i] == '1' && S[i + 1] == '1') {
        cnt++;
        S.replace(i + 1, 1, "0");
      } else if (S[i] == '0' && S[i + 1] == '0') {
        cnt++;
        S.replace(i + 1, 1, "1");
      }
    }
  }
  
  cout << min(cnt, static_cast<int>(S.length()) - cnt) << endl;
}

Measured memory_bytes: 512
import sys


def main():
    s = sys.stdin.readline().strip()

    n = len(s)
    # n: 3, half: 2
    # n: 4, half: 2
    # n: 5, half: 3
    half = n // 2 + (n % 2)

    ans = 0
    for i in range(half):
        if s[i] != s[-1-i]:
            ans += 1
    print(ans)


main()


Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int calc(string s) {
  int ret = 0, n = s.size();
  int i = 0;
  while (i < n) {
    int cnt = 0, j = i;
    while (j < n && s[i] == s[j]) {
      j++;
      cnt++;
    }
    ret += cnt / 2;
    i = j;
  }
  // debug(ret);
  return ret;
}

void solve() {
  string s; cin >> s;
  ll k; cin >> k;

  int n = s.size();
  int l = 0, r = 0;
  while (l < n && s[0] == s[l]) l++;
  while (n - 1 - r >= 0 && s[0] == s[n - 1 - r]) r++;

  // debug2(l, r);

  if (l == n) outl(n * k / 2);
  else if (l == 1 && r == 0) outl(calc(s) * k);
  else {
    string sub = s.substr(l, n - r - l);
    // debug3(l, r, sub);
    // debug(calc(sub));

    outl(l / 2 + (l + r) / 2 * (k - 1) + calc(sub) * k + r / 2);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
  int n, a, ans=0;
  scanf("%d", &n);
  for(int i=1;i<=n;i++) {
    scanf("%d", &a);
    if(i % 2 != 0 && a % 2 != 0) ans++;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1724
'use strict'
function Main(input) {
  const numP = input.trim().split("\n").map(Number);
  let numG = numP.shift();
  // console.log({ numG, numP });

  let btlNeck = Math.min(...numP);
  let Ans = Math.ceil(numG / btlNeck) + 4;
  console.log(Ans);

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

Measured memory_bytes: 7372
N, M, K = map(int, input().split())
MOD = 998244353

def make_table(n, mod = MOD):
    # 元テーブル
    g1 = [0] * (n + 1)
    g1[0] = 1
    g1[1] = 1

    # 逆元テーブル
    g2 = [0] * (n + 1)
    g2[0] = 1
    g2[1] = 1

    # 逆元計算用テーブル
    inverse = [0] * (n + 1)
    inverse[0] = 0
    inverse[1] = 1

    for i in range(2, n + 1):
        g1[i] = (g1[i - 1] * i) % mod
        inverse[i] = (-inverse[mod % i] * (mod // i)) % mod
        g2[i] = (g2[i - 1] * inverse[i]) % mod

    return tuple(g1), tuple(g2), tuple(inverse)

g1, g2, inverse = make_table(N)

def cmb_from_table(n, r, mod = MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

ans = 0
for i in range(K+1):
    ans += M * pow(M-1, N-1-i, MOD) * cmb_from_table(N-1, i, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 37300
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayDeque;

public class Main {
	void run() throws IOException {
		ArrayDeque<String> qu = new ArrayDeque<String>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			switch (str[0]) {
			case "insert":
				qu.addFirst(str[1]);
				break;
			case "delete":
				qu.remove(str[1]);
				break;
			case "deleteFirst":
				qu.removeFirst();
				break;
			case "deleteLast":
				qu.removeLast();
				break;
			default:
				break;
			}
		}
		boolean check = true;
		for (String str : qu) {
			if (check) {
				check = false;
				System.out.print(str);
			} else {
				System.out.print(" " + str);
			}
		}
		System.out.println();
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 229016
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
s=input().rstrip()
count=0
for i in range(n):
    if s[i]=='L' and i>=1:
        if s[i-1]=='L':
            count+=1
    elif s[i]=='R' and i<=n-2:
        if s[i+1]=='R':
            count+=1
Max=n-1
ans=count
for i in range(k):
    ans=min(ans+2,Max)
print(ans)
            



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

int n,ans=0;

map<int,bool> p;

inline int read()
{
    int x=0,f=0;char c=getchar();
    while (!isdigit(c)) f|=c=='-',c=getchar();
    while (isdigit(c))  x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return f?-x:x;
}

int main()
{
    n=read();
    for (register int i=1;i<=n;++i)
    {
        int x=read();
        if (!p[x])
            ++ans,p[x]=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAXN=100000;
static const int NIL=-1;
 vector<int>G[MAXN];
 int color[MAXN];
 int n;
 void dfs(int r,int c)
 {
      stack<int>S;
      S.push(r);
      color[r]=c;
      while(!S.empty()){
        int u=S.top();S.pop();
            for(int i=0;i<G[u].size();i++){
                int v=G[u][i];
                if(color[v]==NIL){
                    color[v]=c;
                    S.push(v);
                }
            }
      }
 }
 void assignColor()
 {
     int id=1;
     for(int i=0;i<n;i++)color[i]=NIL;
     for(int u=0;u<n;u++){
        if(color[u]==NIL)dfs(u,id++);
     }
 }
int main()
{
    int b,q;
    cin>>n>>b;
    int s,t;
    for(int i=0;i<b;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }else{
        cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8988
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

        if (counter <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}


Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.io.*;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

//    public static void main(String[] args)
////    {
////        System.out.println("Hello World!");
////
//////    ArrayList<int> arr= new ArrayList<int>(1,2,3,4,5);
////        var arr= new ArrayList<Integer>();
////        arr.add(1);
////        arr.add(4);
////        arr.add(3);
////        arr.add(5);
////        arr.add(2);
////        Collections.sort(arr);
////        var max = Collections.max(arr);
////        var min = Collections.min(arr);
////        for (var value:
////             arr) {
////            System.out.println(value);
////        }
////        System.out.println(max);
////        System.out.println(min);
////    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int x=sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for (int i=0;i<m;i++){
            arr.add(sc.nextInt());
        }

        int tmp1 = 0, tmp2 = 0;
        for(Integer value : arr){
            if (value < x){
                tmp1++;
            }else{
                tmp2++;
            }
        }
        System.out.println(Math.min(tmp1,tmp2));
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  ll a = n / 15;
  print(800 * n - 200 * a);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
#define cint(...) ll __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__);

int main() {
	cint(a, b);
	cout << (a + b + 1) / 2 << endl;
}

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

using namespace std;

int main()
{
    int m, n, k;
    
    // n <= 21
    while (scanf("%d %d %d", &n, &m, &k) && n){
        double dp[2][10001];
        
        for (int i = 0; i <= m * n; i++){
            dp[0][i] = dp[1][i] = 0;
        }
        
        int t = 0;
        dp[0][0] = 1;
        
        for (int i = 1; i <= n; i++){
            for (int j = 0; j <= m * n; j++) dp[1 - t][j] = 0;
            for (int j = 0; j <= m * (n - 1); j++){
                for (int d = j + 1; d <= j + m; d++){
                    dp[1 - t][d] += dp[t][j] / m;
                }
            }
            t = 1 - t;
        }
        
        double r = 0;
        for (int i = 1; i <= m * n; i++) r += max(1, i - k) * dp[t][i];
        
        printf("%.10f\n", r);
    }
    
    return (0);
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
#define  fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
int main()
{
	fuckit();
	int n,w,h,x,y,a,r = 0,l = 0,u = 0,d = 0,i;
	cin>>w>>h>>n;
	for(i=0;i<n;i++){
		cin>>x>>y>>a;
		if(a==1){
			l=max(l,x);
		}
		else if(a==2){
			r=max(r,w-x);
		}
		else if(a==3){
			d=max(d,y);
		}
		else{
			u=max(u,h-y);
		}
	}
	w=max(0,w-l-r);
	h=max(0,h-u-d);
	cout<<h*w<<"\n";
	return 0;	
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
   a, op, b = input().split()
   a = int(a)
   b = int(b)
   if op == "?": break

   if op == "+":
      print(a + b)
   elif op == "-":
      print(a - b)
   elif op == "*":
      print(a * b)
   else:
      print(int(a / b))



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

using namespace std;


int countt(int i,int j,int u){
    if (i==j && i==u)
        return 1;
    if (i!=j && i!=u && j!=u)
        return 6;
    return 3;
}

int solve(int ind){
    int ans=0;
    for (int i=1;i*i<=ind;i++){
        for (int j=i;j*j<=ind;j++){
            for (int u=j;u*u<=ind;u++){
                if (i*i+j*j+u*u+i*j+i*u+j*u==ind)
                    ans+=countt(i,j,u);
            }
        }
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++){
        cout<<solve(i)<<"\n";
    }


    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		
		String A = S.substring(0, 2);
		String B = S.substring(2, 4);
		
		int C = Integer.valueOf(A);
		int D = Integer.valueOf(B);
		
		if(C == 0 || (13 <= C && C <= 99))
		{
			if(D == 0 || (13 <= D && D <= 99))
			{
				System.out.println("NA");
			}else
			{
				System.out.println("YYMM");
			}
		}else
		{
			if(D == 0 || (13 <= D && D <= 99))
			{
				System.out.println("MMYY");
			}else
			{
				System.out.println("AMBIGUOUS");
			}
		}
	}
}

Measured memory_bytes: 25044
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a;
		int c = 1;
		while(true) {
			a = sc.nextInt();
			if(a == 0) break;
			System.out.println("Case " + c + ": " + a);
			c++;
		}
	}
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	string s;
	cin>>s;
	int len = SIZE(s);

	int c = 0;
	REP(i,len/2){
		if(s[i] != s[len-i-1]){
			c++;
		}
	}
	cout << c << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
parttime = []

for i in range(N):
	a, b = map(int, input().split())
	parttime.append((a, b))
	
parttime.sort()
index = 0
ans = 0
myheap = []

for day in range(M, -1, -1):
	for i in range(index, N):
		if (parttime[i][0] + day) <= M:
			heapq.heappush(myheap, -parttime[i][1])
			index = i + 1
		else:
			index = i
			break
			
	if myheap:
		ans -= heapq.heappop(myheap)
		
print(ans)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int h,w;
  
  cin >> h >> w;
  
  vector<vector<int>> a(h+2,vector<int>(w+2));
  
  char t53;
  
  FOR(i,1,h+1){   
    
    FOR(j,1,w+1){
      
      cin >> t53;      
      if(t53 == '.') a.at(i).at(j) = 0;      
      else a.at(i).at(j) =1;     
      
    }
    
  }
  
  int count;
  
  FOR(i,1,h+1){
    
    FOR(j,1,w+1){
      
      count = 0;
      
      if(a.at(i).at(j) == 1){
        
          count+=a.at(i-1).at(j);
          count+=a.at(i).at(j-1);
          count+=a.at(i).at(j+1);
          count+=a.at(i+1).at(j);
        
        if(count == 0){cout<<"No"<<endl;return 0;}
        
      }
      
    }
    
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

INF = int(1e18)

class BellmanFord:
  N = -1
  edge = []
  
  def __init__(self, N):
    self.N = N
  
  def addEdge(self, a, b, cost):
    self.edge.append((a, b, cost))
  
  def addBiEdge(self, a, b, cost):
    self.addEdge(a, b, cost)
    self.addEdge(b, a, cost)

  def calc(self, start):
    dist = [INF] * self.N
    dist[start] = 0
    update = True
    cnt = 0
    while update:
      update = False
      cnt += 1
      if cnt > self.N:
        return -INF
      for a, b, cost in self.edge:
        ncost = dist[a] + cost
        if dist[a] == INF or ncost >= dist[b]:
          continue
        dist[b] = ncost
        update = True
    return dist

def main():
  v, e, r = na()
  BF = BellmanFord(v)
  for _ in range(e):
    BF.addEdge(*na())

  ans = BF.calc(r)
  if ans == -INF:
    print("NEGATIVE CYCLE")
  else:
    for i in range(v):
      print('INF' if ans[i] == INF else ans[i])

main()


Measured memory_bytes: 6024
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            bool[] check = new bool[Max];
            for(int i=3; i < Max; i += 2) {
                for(int l = 2; i * l < Max; ++l) {
                    check[l * i] = true;
                }
            }
            string num;
            int cnt;
            while((num = Console.ReadLine()) != null) {
                int val = int.Parse(num);
                cnt = val >= 2 ? 1 : 0;
                for(int i=3; i <= val; i += 2) {
                    if(!check[i]) {
                        ++cnt;
                    }
                }
                Console.WriteLine(cnt);
            }
        }
    }
}

Measured memory_bytes: 6584