akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int h,w,k = 0,tp = 0; cin >> h >> w;
    char a[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,h){
        bool yoko = true;
        rep(j,w){
            if(a[i][j] == '#'){
                yoko = false;
                break;
            }
        }
        if(yoko){
            rep(k,w){
                a[i][k] = 'p';
            }
        }
    }

    rep(i,w){
        bool tate = true;
        rep(j,h){
            if(a[j][i] == '#'){
                tate = false;
                break;
            }
        }
        if(tate){
            rep(k,h){
                a[k][i] = 'p';
            }tp++;
        }
    }
  
  char ans[h*w];
  rep(i,h){
        int kai = 0;
        rep(j,w){
            if(a[i][j] == 'p') continue;
            else{
                    ans[k] = a[i][j];
                    k++;
            }
        }
    }
    cout << ans[0];
    for(int i=1;i<k;i++){
        if(i % (w-tp) == 0){
            cout << endl;
          	cout << ans[i]; 
        }else{
            cout << ans[i];
        }
    }
}

Measured memory_bytes: 256
//たて a cm よこ b cm の長方形の面積と周の長さを求めるプログラム
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_C&lang=jp

#include <iostream>;

int main() {
    int a {};   //　長方形の横の長さ
    int b {};   //  長方形の縦の長さ
    int perimeter {};   //　周長
    int area {};    //　面積

    std::cin >> a >> b;
    
    perimeter = 2 * (a + b);
    area = a * b;

    std::cout << area << " " << perimeter << std::endl;
}


Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <map>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll N, K;
    cin>>N>>K;
    map<ll, ll> As;
    for (ll n = 0; n < N; n++) {
        ll a;
        cin>>a;
        As[a]++;
    }
    vector<ll> ks;
    for (auto kv : As) ks.push_back(kv.second);
    sort(begin(ks), end(ks));
    ll ans = 0;
    for (ll i = 0; i < (ll)ks.size() - K; i++) ans += ks[i];
    cout<<ans<<endl;

    return 0;
}

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

int main() {
	int n , m;

	cin >> n >> m;


	int nokori_day=n;

	int l,i=0,days[m];
    while(cin>>l){
        days[i] = l;
        i++;
    }

	for(i=0;i<m;i++) {
		nokori_day -= days[i];
	}

	if(nokori_day < 0) {
		cout << -1 << endl;
	}
	else {
		cout << nokori_day << endl;
	}



	return 0;
}

Measured memory_bytes: 3224
#pragma comment(linker, "/STACK:1024000000,1024000000")  
#include<iostream>  
#include<algorithm>  
#include<ctime>  
#include<cstdio>  
#include<cmath>  
#include<cstring>  
#include<string>  
#include<vector>  
#include<map>  
#include<set>  
#include<queue>  
#include<stack>  
#include<list>  
#include<numeric>  
using namespace std;  
#define LL long long  
#define ULL unsigned long long  
#define INF 0x3f3f3f3f  
#define mm(a,b) memset(a,b,sizeof(a))  
#define PP puts("*********************");  
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }  
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }  
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}  
// 0x3f3f3f3f3f3f3f3f  
//0x3f3f3f3f  
  
const int MAXN = 200050, SIZE = 26;  
struct SAM {  
    int len[MAXN], link[MAXN], next[MAXN][SIZE];  
    int total, last;  
    inline int newNode(int L) {  
        len[++total] = L; link[total] = 0;  
        for(int i = 0; i < SIZE; ++i) next[total][i] = 0;  
        return total;  
    }  
    inline void Add(int c) {  
        int i, p = last, cur = newNode(len[last] + 1);  
        for(; p && !next[p][c]; p = link[p]) next[p][c] = cur;  
        if(!p) link[cur] = 1;//令其指向初始状态  
        else {  
            int q = next[p][c];  
            if(len[q] == len[p] + 1) link[cur] = q;  
            else {//>  
                int clone = newNode(len[p] + 1);  
                for(i = 0; i < SIZE; ++i) next[clone][i] = next[q][i];  
                link[clone] = link[q];  
                link[q] = link[cur] = clone;  
                for(; p && next[p][c] == q; p = link[p]) next[p][c] = clone;  
            }  
        }  
        last = cur;  
    }  
    void Init () {//根节点是1  
        total = 0;  
        last = newNode(0);  
    }  
}sam;  
char str[MAXN];  
int num[MAXN],idx[MAXN];  
int dp[MAXN];  
void solve(int k){  
    int now=1,L=0;  
    while(k){  
        for(int j=0;j<SIZE;j++){  
            if(sam.next[now][j]==0)  
                continue;  
            int x=sam.next[now][j];  
            if(k>dp[x])  
                k-=dp[x];  
            else{  
                str[L++]='a'+j;  
                now=x;  
                k--;  
                break;  
            }  
        }  
    }  
    str[L]='\0';  
    puts(str);  
}  
int main(){  
  
    int Q,k;  
    scanf("%s",str);  
        sam.Init();  
        for(int i=0;str[i]!='\0';i++)  
            sam.Add(str[i]-'a');  
        for(int i=1;i<=sam.total;i++)  
            num[i]=0;  
        for(int i=1;i<=sam.total;i++)  
            num[sam.len[i]]++;  
        for(int i=1;i<=sam.total;i++)  
            num[i]+=num[i-1];  
        for(int i=1;i<=sam.total;i++)  
            idx[num[sam.len[i]]--]=i;  
  
        for(int i=sam.total;i>=1;i--){  
            int now=idx[i];  
            dp[now]=1;  
            for(int j=0;j<SIZE;j++)  
                dp[now]+=dp[sam.next[now][j]];  
        }  
       // scanf("%d",&Q);  
       // while(Q--){  
            scanf("%d",&k);  
            solve(k);  
       // }  
    return 0;  
}

Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n{};
    double sum{};
    cin>>n;
    for(int i=0;i<n;i++){
        double temp{};
        cin>>temp;
        sum+= (1/temp);
    }
    cout<<1/sum<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const long long inf=1e16;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	int dp[100100]={0};
	rep(i,n){
		int a,b;
		scanf("%d %d",&a,&b);
		dp[a]++;dp[b+1]--;
	}
	int ma=0;
	rep(i,100099)dp[i+1]+=dp[i];
	rep(i,100099){
		if(i-1<=dp[i])ma=max(ma,i-1);
	}
	cout<<ma<<endl;
}

Measured memory_bytes: 1644
use std::io::stdin;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


fn main() {
    let mut tmp = String::new();
    stdin().read_line(&mut tmp).expect("error");
    let _N = tmp.trim().parse::<u64>().unwrap();

    let mut tmp =  String::new();
    stdin().read_line(&mut tmp).expect("error");
    let A: Vec<u64> = tmp.trim().split(' ').map(|s| s.parse::<u64>().unwrap()).collect();

    let B: Vec<u64> = read_vec();


    let mut mask: u64 = 0;
    let mut ans: u64 = 0;
    for i in 0..29{
        mask = (mask << 1) + 1;
        let mut B_:Vec<i64> = B.iter().map(|b| (*b as i64 % 2i64.pow(i+1) * 10)).collect();
        B_.sort();
        // println!("{:?}", B_);
        let mut b = 0;
        for j in 0..A.len(){
            let T = 1<<i;
            let a = (A[j] as i64 % 2i64.pow(i+1));
            let mut t1 = B_.binary_search(&((T-a) * 10 - 5 )).unwrap_or_else(|e| e);
            let mut t2 = B_.binary_search(&((2*T-a) * 10 - 5 )).unwrap_or_else(|e| e);
            let mut t3 = B_.binary_search(&((3*T-a) * 10 - 5 )).unwrap_or_else(|e| e);
            let mut t4 = B_.binary_search(&((4*T-a) * 10 - 5 )).unwrap_or_else(|e| e);
            b += (t2-t1) as u64;
            b += (t4-t3) as u64;

            // println!("{}, {}, {}, {}, {}", a, t1, t2, t3, t4);
        }   
        ans += (1 << i) * (b % 2);
        // println!("{}, {}", i, b);
    }

    println!("{}", ans)
}

Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long mod=1000000007;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long h,w;
    cin>>h>>w;
   	
   	char grid[h+1][w+1];
   	long long dp[h+1][w+1];
   	for(long long i=0;i<=h;i++){
   		for(long long j=0;j<=w;j++){
   			dp[i][j]=0;
   		}
		
	}
   	for(long long i=1;i<=h;i++)
   		for(long long j=1;j<=w;j++){
   			cin>>grid[i][j];
   			
   		}

	for(int i=0;i<=h;i++)
	{
   		for(int j=0;j<=w;j++)
   		{
   			if(i==1&&j==1)
   			{	
   				dp[i][j]=1;
   				continue;
   			}
   			if(i==0 && grid[i][j]=='#')
   				break;

   			if(grid[i][j]=='.')
   				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;



   		}
   	}


   	cout<<dp[h][w]%mod;
    return 0;
}

Measured memory_bytes: 9088
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=51;
lint cc[N][N];

void init(){
  cc[0][0]=1;
  rep(i,N-1){
    cc[i+1][0]=1;
    rep(j,N-1){
      cc[i+1][j+1]=cc[i][j]+cc[i][j+1];
    }
  }
}


int main(){
  init();
  int n,a,b;
  cin>>n>>a>>b;
  vector<lint>v(n);
  rep(i,n)cin>>v[i];
  sort(v.rbegin(),v.rend());
  lint ma=0;
  int maxi=-1;
  lint tot=0;
  rep(i,a){
    tot+=v[i];
  }
  ma=tot;
  maxi=a;
  printf("%.15f\n",(double)ma/maxi);
  rep(i,n)v[i]=maxi*v[i]-ma;
  int c=1;
  rep(i,a-1){
    if(v[a-i-1]!=v[a-i-2])break;
    c++;
  }
  int d=0;
  while(d+a-c<n){
    if(v[a-c]!=v[d+a-c])break;
    d++;
  }
  lint ans=0;
  if(c==a){
    for(int j=a;j<=b;++j)ans+=cc[d][j];
  }else{
    ans=cc[d][c];
  }
  cout<<ans<<endl;
}


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


int main() {
    ll counter[26];
    rep(i,26)counter[i] = 0;
    char c;
    while(cin >> c){
        if(c >= 65 && c <=90){
            c += 32;
        }
        if(c-'a' <= 122){
            counter[c-'a']++;
        }
    }
    char a = 'a';
    rep(i,26){
        cout << a << " : " << counter[i] << endl;
        a++;
    }
    return 0;
}

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


Measured memory_bytes: 3076
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0

for i in range(N):
    if i == 0:
        ans += 1
        next_pos = A[i]
        if next_pos == 2:
            break
        else:
            continue
        
    ans += 1
    next_pos = A[next_pos-1]

    if next_pos == 2:
        break
    else:
        continue

if ans < N:
    print(ans)
else:
    print(-1)
        

Measured memory_bytes: 7084
n = int(input())
numlist = [int(_) for _ in input().split()]
numdic = {}
nsum = 0

for i in range(n):
    if numlist[i] in numdic:
        numdic[numlist[i]] += 1
    else:
        numdic[numlist[i]] = 1

for k in numdic:
    nsum += numdic[k] * (numdic[k] - 1) // 2

for j in range(n):
    ans = nsum
    cal = numdic[numlist[j]]
    if cal >= 2:
        ans = ans - (cal-1)
    print(ans)

Measured memory_bytes: 25768
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u64>();
    let (x, y, z) = (line[0], line[1], line[2]);

    println!("{}", (x-z)/(z+y));
}


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

#define MODSIZE 1000000007

long long sum[200005];
long long ans[200005];

int main(){
  int n;
  int k;
  int i;
  long long max;
  long long min;
  long long t = 0;

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

  sum[0] = 0;
  sum[1] = 0;

  for(i = 2;i <= n + 1;i++){
    sum[i] = sum[i - 1] + i - 1;
  }

  for(i = k;i <= n + 1;i++){
    min = sum[i];
    max = sum[n + 1] - sum[n + 1 - i];

    ans[i] = max - min + 1;
  }

  for(i = k;i <= n + 1;i++) t += ans[i];

  printf("%lld\n", t % MODSIZE);

  return 0;
}


Measured memory_bytes: 4856
N, K = map(int, input().split())
x = sum(range(1,K))
y = sum(range(N+1,N+2-K,-1))
a = K-1
b = N+3-K
ans = 0
MOD = 10**9+7
for i in range(K,N+2):
  x += i
  y += N+2-i
  ans += y-x+1
  ans %= MOD
print(ans%MOD)

Measured memory_bytes: 67076
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int N = sc.nextInt();
        char[] ch = sc.next().toCharArray();
        
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] + N <= 'Z') {
                ch[i] += N;
            } else {
                ch[i] += N - 26;
            }
            out.print(ch[i]);
        }
        
        out.println();

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 22996
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int height = inpt[0];
        int width = inpt[1];
        bool[,] map = new bool[height, width];

        for (int i = 0; i < height; i++)
        {
            bool[] line = Reader.ReadLine().Select(a => a == '#').ToArray();

            for (int j = 0; j < width; j++) {
                map[i, j] = line[j];
            }
        }


        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < height; i++) {
            StringBuilder line = new StringBuilder();
            for (int j = 0; j < width; j++) {
                if(map[i,j]) {
                    line.Append("#");
                    continue;
                }
                int cnt = 0;
                for (int k = Math.Max(0, i - 1); k <= Math.Min(height - 1, i + 1); k++) {
                    for (int l = Math.Max(0, j - 1); l <= Math.Min(width - 1, j + 1); l++) {
                        if(map[k,l]) {
                            cnt++;
                        }
                    }
                }
                line.Append(cnt);
            }
            ans.AppendLine(line.ToString());
        }
        Console.Write(ans.ToString());


    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

3 5
.....
.#.#.
.....

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cmath>
#define RI register int
using namespace std;
const int LIM=1e9;
long long s; int a,b,c,d;
int main()
{
    scanf("%lld",&s); a=d=(int)sqrt(s);
    while (1LL*a*d<s) if (a<d) ++a; else ++d;
    long long left=1LL*a*d-s; for (RI i=1;1LL*i*i<=left;++i)
    if (left%i==0&&i<=LIM&&left/i<=LIM) { b=i; c=left/i; break; }
    return printf("0 0 %d %d %d %d",a,b,c,d),0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 510;
string s[N];
int main() {
	int h,w;
	cin >> h >> w;
	for (int i=0;i<h;i++) cin >> s[i];
	for (int j=0;j<w;j++) cout << "#";
	cout << endl;
	for (int i=1;i<h-1;i++) {
		for (int j=0;j<w;j++) {
			if (j%2) cout << "#";
			else cout << s[i][j];
		}
		cout << endl;
	}
	cout << s[h-1] << endl;
	cout << endl;

	cout << s[0] << endl;
	for (int i=1;i<h-1;i++) {
		for (int j=0;j<w;j++) {
			if (j%2 == 0) cout << "#";
			else cout << s[i][j];
		}
		cout << endl;
	}
	for (int j=0;j<w;j++) cout << "#";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1024
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
#define MOD 998244353
using namespace std;
int n,k,l[15],r[15],dp[200005],sum[200005];
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    dp[1]=1;
    sum[1]=1;
    for(int i=1;i<=k;++i)
    {
        cin>>l[i]>>r[i];
    }
    for(int i=2;i<=n;++i)
    {
        for(int j=1;j<=k;++j)
        {
            dp[i]=(dp[i]+sum[max(i-l[j],0ll)]-sum[max(i-r[j]-1,0ll)]+MOD)%MOD;
        }
        sum[i]=(sum[i-1]+dp[i])%MOD;
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 6768
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser :: String -> [String]
parser = tail . lines 
printer :: Int -> String
printer = (++"\n") . show

solver [[],[],[]] = 0
solver [a:as,b:bs,c:cs] = calc a b c + solver[as,bs,cs]



calc a b c 
  | a==b && b==c = 0
  | a==b && b/=c = 1
  | b==c && c/=a = 1
  | c==a && a/=b = 1
  | otherwise = 2


Measured memory_bytes: 508
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

int h, w, n;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> h >> w >> n;
int x = max(h, w);
cout << ((n + x - 1) / x) << endl;

return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, i;
    int A[100];
  	double x = 0, y;
  	
  	scanf("%d", &N);
  	for(i=0;i<N;i++)
      	scanf("%d", &A[i]);
    
  	for(i=0;i<N;i++)
      	x += 1.0/A[i];

    printf(" %lf", 1/x);	
  	
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  ll ans;

  if (abs(N - M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (N == M) {
    ans = 2;
  } else {
    ans = 1;
  }
  for (int i = 1; i < N + 1; ++i) {
    ans = (ans * i) % MOD;
  }
  for (int i = 1; i < M + 1; ++i) {
    ans = (ans * i) % MOD;
  }
  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++)
#define PI 3.14159265359

int main(void)
{
    double r;
    double men, en;

    cin >> r;

    men = (double)r * r * PI;
    en = 2.0 * r * PI;

    cout << fixed << setprecision(6) << men << " " << en << endl;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0;i<n;i++)
#define double long double
#define mod 998244353
#define F first
#define S second
#define pb push_back

using namespace std;



signed main()
{
	fast;
	int test=1;
	// cin>>test;
	for(int index=1;index<=test;index++)
	{	
		int a,b,c,k;
		cin>>a>>b>>c>>k;
		if(k<=a)
		{
			cout<<k<<endl;
		}
		else if(k>a && k<=(a+b))
		{
			cout<<a<<endl;
		}
		else if(k>(a+b))
		{
			cout<<(a-(k-(a+b)))<<endl;
		}
		
    }
}

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

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

  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size() - i; j++) {
      s.erase(s.begin() + i, s.begin() + i + j);
      if (s == "keyence") {
        cout << "YES" << endl;
        return 0;
      } else {
        s = d;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
from collections import Counter

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

cnt = Counter(lis)

for _ in range(m):
    b,c = map(int,input().split())
    cnt[c] += b

anslis = sorted(cnt.items(), key=lambda x:x[0], reverse=True)

ans = 0
for key, value in anslis:
    if n > value:
        ans += key*value
        n -= value
    else:
        ans += n*key
        print(ans)
        break


Measured memory_bytes: 47064
package main

import (
	"fmt"
)

func main() {
	var X int
	fmt.Scan(&X)

	ans := func() int {
		over := X % 100
		amount := X / 100
		if over <= 5*amount {
			return 1
		}
		return 0
	}()

	fmt.Println(ans)

}


Measured memory_bytes: 512
N,M=map(int,input().split())
graph={i:[] for i in range(1,N+1)}
for _ in range(M):
    x,y=map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)
visited=[False for i in range(N+1)]
par=[-1 for i in range(N+1)]
from collections import deque
d=deque()
visited[1]=True
d.append(1)
e=deque()
while d:
    while d:
        x=d.popleft()
        for node in graph[x]:
            if visited[node]==False:
                par[node]=x
                visited[node]=True
                e.append(node)
    if e:
        d=e
        e=deque()
    else:
        d=deque()
flag=True
for i in range(2,N+1):
    if par[i]<0:
        flag=False
        break
if flag:
    print("Yes")
    for i in range(2,N+1):
        print(par[i])
else:
    print("No")


Measured memory_bytes: 42156
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

int w,h,n;

vector<int> cols;

vector<vector<int>> mapa;

main()
{
    ios_base::sync_with_stdio(false);
    cin >> h >> w >> n;
    mapa.resize(w+1,vector<int>(h+1));
    for(int i = 0; i < n; ++i)
    {
        int temp; cin >> temp;
        cols.pb(temp);
    }
    pp cur = {1,1};
    while(1)
    {
        while(cols.size() > 0 and cols.back() == 0) cols.pop_back();
        if(cols.size() == 0) break;
        mapa[cur.ff][cur.dd] = cols.size();
        //cout << " col of " << cur.ff << " " << cur.dd << " " << cols.size() << endl;
         cols.back()--;
        if(cur.dd & 1)
        {
            cur.ff++;
            if(cur.ff > w)
            {
                cur.dd++;
                cur.ff--;
            }
        }
        else
        {
            cur.ff--;
            if(cur.ff == 0)
            {
                cur.dd++;
                cur.ff++;
            }
        }
    }

    for(int b = h; b >= 1; --b)
    {
        for(int a = 1; a <= w; ++a)
        {
            cout << mapa[a][b] << " ";
        }
        cout << endl;
    }
}



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

int main() {
  long long x;
  cin >> x;
  
  long long sum = 0;
  
  while(x>=500){
    x -= 500;
    sum += 1000;
  }
  while(x>=5){
    x -= 5;
    sum += 5;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
def combi(a,b,n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(mod)
          
x,y=map(int,input().split())
power=find_power(666670)
invpower=find_inv_power(666670)
if (2*x-y)%3==0 and (2*y-x)%3==0:
    if (2*x-y)>=0 and (2*y-x)>=0:
        a=(2*y-x)//3
        b=(2*x-y)//3
        print(combi(power,invpower,a+b,b,10**9+7))
    else:
        print(0)
else:
    print(0)
    

Measured memory_bytes: 112176
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 1010
ll x[N],y[N],n;
int NOE(){
    cout<<-1<<endl;
    return 0;
}
int main(){
    cin>>n;
    set<bool> sl,sr;
    lol(i,n){
	ll X,Y;cin>>X>>Y;
	x[i]=X+Y;
	y[i]=X-Y;
	sl.insert(x[i]&1);
	sr.insert(y[i]&1);
    }
    
    if(sl.size()>1||sr.size()>1)return NOE();
    if(*sl.begin()!=*sr.begin())return NOE();
    
    vector<ll> d;
    if(*sl.begin()==0)d.push_back(1);
    for(ll i=0;i<32;i++)d.push_back(1LL<<i);
    cout<<d.size()<<endl;
    lol(i,d.size()){
	if(i)cout<<" ";
	cout<<d[i];
    }cout<<endl;
    
    ll sum=0; for(auto z:d)sum+=z;
    lol(i,n){
	ll X=sum-x[i],Y=sum-y[i];
	for(ll j=0;j<d.size();j++){
	    ll z=d[j]*2,res=0;
	    if(z&X)X-=z,res++;
	    if(z&Y)Y-=z,res+=2;
	    string ans="RDUL";
	    cout<<ans[res];
	}cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
maxPossible = (n - 2) * (n - 1) // 2
if k > maxPossible:
    print(-1)
    exit()
ret = []
for i in range(2, n + 1):
    ret.append((1, i))
add = []
for i in range(2, n):
    for j in range(i + 1, n + 1):
        add.append((i, j))
for i in range(maxPossible - k):
    ret.append(add[i])
print(len(ret))
print('\n'.join('%d %d' % (u, v) for u, v in ret))

Measured memory_bytes: 3700
d, g = map(int, input().split())
A, B = [], []
for _ in range(d):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
ans = float('inf')

for i in range(2**d):
    s, k = 0, 0 #s:得点, k:解いた問題数

    for j in range(d):
        if (i>>j)&1:
            s+=A[j]*(j+1)*100 + B[j] #pj+1問全て解く
            k+=A[j] #解いた問題数
    if s >= g:
        ans = min(ans, k)
    else:
        for l in range(d-1, -1, -1):
            if (i>>l)&1 == 0: #これまでにまだ解いていない問題
                if s+(l+1)*100*A[l]<g: #全部解いても超えない
                    s+=(l+1)*100*A[l]
                    k+=A[l]
                else:
                    rem = g-s #目標点までの残りの点数
                    k += -(-rem//(l+1)//100)
                    ans = min(ans, k)
print(ans)                


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

set<char> nums;
char a;

int main()
{
    ios_base::sync_with_stdio(false);
    for (int i = 0; i < 3; i++)
    {
        cin >> a;
        nums.insert(a);
    }

    cout << (nums.count('7') > 0 ? "Yes" : "No");
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;

int main ()
{

    int N; cin >> N;
    double T,A; cin >> T >> A;

    vector < double > H(N);
    REP(i,N) cin >> H[i];

    int idx = -1;
    double diff = 1.0e18;

    REP(i,N) {
        double temp = T - 0.006 * H[i];
        double dt = abs(temp - A);
        if (diff > dt) {
            diff = dt;
            idx = i;
        }
    }

    cout << idx + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+5;
map<int, int> dict;
int main(){
    int n, m;
    cin >> n;
    for(int i = 0; i < n; i++){
        int d;
        cin >> d;
        dict[d] += 1;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int t;
        cin >> t;
        dict[t] -= 1;
        if(dict[t] < 0) {
            cout << "NO" << "\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 9728
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)
	N = nextInt()

	V := make([]float64, N)
	for i := 0; i < N; i++ {
		tmp := nextInt()
		V[i] = float64(tmp)
	}

	sort.Float64s(V)
	ans := (V[0] + V[1]) / 2
	if N > 2 {

		for i := 2; i < N; i++ {
			ans = (ans + V[i]) / 2
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  int i,sum=0;
  for(i=0;i<3;i++){
    cin >> a[i];
    sum+=a[i];
  }
  if(sum>21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

int n,m;

int main(){
    cin>>n>>m;
    /*
    one run t = (n-m)*100+m*1900
    pass p = 1/(2^m)
    1*p+2*p*(1-p)+ ... + k*p*(1-p)^(k-1)
    =p/(1-p)(1*(1-p)+2*(1-p)^2+ ... + k*(1-p)^k)
    =p/(1-p)((1-p)/p/p)
    =1/p
    */
    cout<<((n-m)*100+m*1900)*(1<<m)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO

#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define ll long long
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
#define LSB(i) ((i)&(-i))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define infl 0x7ffffffffffffff
#define infi  0x7fffffff
#define fill_(a,b) fill(a.begin(),a.end(),b)
#define pb push_back
#define xx first
#define yy second
int main(){
    int n;
    sci(n);
    vector<int> data(3*n);
    int i;
    ll ans=0;
    for(i=0;i<3*n;i++){
        sci(data[i]);
    }
    sort(data.begin(),data.end());
    for(i=n;i<3*n;i+=2){
        ans+=data[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int N,K;
    cin >> N >> K;
    vl V(N);
    priority_queue<ll,vector<ll>,greater<ll> > pq;

    //手に入れる＋戻す回数でたかだかK回
    //K-i回取り出してi回戻す時、両端からK-iのものは入手可能　ただし手に入ったものを戻すのはi回まで
    //戻すのは最後でもいい　取り出すのはコスト１　戻すのはコスト１　よってまいないすのものを戻したかったら２回行動消費
    for(int i=0;i<N;i++){
        cin >> V[i];
    }

    //とる宝石の回数を決める K通り　宝石の戻し方はpqでO(1) 宝石のとり方はK+1通り
    ll ans = -10000000000;
    for(int k=0;k<=min(K,N);k++){ //どのKで行くか
        for(int popleft=0;popleft<=k;popleft++){ //左から何回とるか
            vector<bool> tmpv(N,false);
            for(int i=0;i<popleft;i++){
                pq.push(V[i]);
                tmpv[i]==true;
            }
            for(int i=0;i<k-popleft;i++){ //右からとる
                if(tmpv[N-1-i])break;
                pq.push(V[N-1-i]);
            }
            int canpop = K-k;
            while(!pq.empty()&&canpop>0){
                if(pq.top()<0){
                    pq.pop();
                    canpop--;
                }
                else break;
            }
            ll tmp = 0;
            while(!pq.empty()){
                tmp += pq.top();
                pq.pop();
            }   

            ans = max(ans,tmp);
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
# coding: utf-8
L, R = map(int, input().split())
mod = 2019
ans = float("inf")
for i in range(L, R + 1):
    i_mod = i % mod
    if i_mod == 0:
        ans = 0
        break
    for j in range(i + 1, R + 1):
        j_mod = j % mod
        if j_mod == 0:
            ans = 0
            break
        else:
            ans = min(ans, i * j % mod)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vi a(n);
	ll total = 0;
	rep(i,0,n) {
		cin >> a[i];
		total += (ll)a[i];
	}
	map<int, int> r;
	rep(i,0,n) {
		if(r.find(a[i]) != r.end()) {
			r[a[i]]++;
		} else {
			r[a[i]] = 1;
		}
	}
	rep(i,1,n) {
		a[i] = max(a[i-1],a[i]);
	}
	vi idx;
	idx.pb(0);
	rep(i,1,n) {
		if(a[i] != a[i-1]) {
			idx.pb(i);
		}
	}
	int m = idx.size();
	vl ans(n);
	ll subtotal = 0;
	per(i,1,m) {
		int j = idx[i];
		int x = a[j-1];
		int y = a[j];
		auto start = r.lower_bound(x);
		auto end = r.lower_bound(y);
		ll ret = 0;
		for (auto it = start; ; ++it) {
			int diff = (it->F) - x;
			if(diff == 0) continue;
			int cnt = it->S;
			ret += ((ll)diff * cnt);
			r[x] += cnt;
			it->S = 0;
			if(it == end) {
				break;
			}
		}
		ans[j] = ret;
		subtotal += ret;
	}
	ans[0] = total - subtotal;
	rep(i,0,n) {
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 7420
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int flag[N];
int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    flag[0]=1;
    rep(i,0,s.size()-1){
        if(flag[i]==0) continue;
        if(i+5<=s.size()&&(s.substr(i,5)=="dream")) flag[i+5]=1;
        if(i+7<=s.size()&&(s.substr(i,7)=="dreamer")) flag[i+7]=1;
        if(i+5<=s.size()&&(s.substr(i,5)=="erase")) flag[i+5]=1;
        if(i+6<=s.size()&&(s.substr(i,6)=="eraser")) flag[i+6]=1;
        
    }
    if(flag[s.size()]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 848
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val a,b,c,d = s.nextInt
    Math.max(0, Math.min(b,d) - Math.max(a,c)).toString
  }

  val tests = List(
    """0 75 25 100""" -> """50""",
    """0 33 66 99""".stripMargin -> """0""",
    """10 90 20 80""" -> "60"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25544
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;

int p[105][4][4][4];

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

	p[0][3][3][3] = 1;
	
	for (int len = 0; len < n; len++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					if (!p[len][i][j][k])continue;

					for (int a = 0; a < 4; a++) {
						if (a == 2 && i == 1 && j == 0)continue;
						if (a == 2 && i == 0 && j == 1)continue;
						if (a == 1 && i == 2 && j == 0)continue;
						if (a == 2 && i == 1 && k == 0)continue;
						if (a == 2 && j == 1 && k == 0)continue;
						p[len + 1][a][i][j] += p[len][i][j][k];
						p[len + 1][a][i][j] %= 1000000007;
					}

				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += p[n][i][j][k];
				ans %= 1000000007;
			}
		}
	}
	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
int i,j,n,m;
scanf("%d %d\n",&n ,&m);
int a[n][m],b[m],add[n];
for(i=0;i < n;i++){
for(j=0;j < m;j++){
scanf("%d",&a[i][j]);
}
scanf("\n");
add[i]=0;
}
for(j=0;j < m;j++){
scanf("%d\n",&b[j]);
}
for(i=0;i < n;i++){
for(j=0;j < m;j++){
add[i] += a[i][j]*b[j];
}
printf("%d\n",add[i]);
}
return 0;
}

Measured memory_bytes: 640
N = int(input())
L = [111,222,333,444,555,666,777,888,999,1111]
for i in range(len(L)) :
    if L[i] == N :
        print(N)
        break
    elif L[i] < N < L[i+1] :
        print(L[i+1])
        break
    elif N < 111 :
        print(111)
        break
        
        
        

Measured memory_bytes: 3060
inp = list(map(int,raw_input().split()))
x = inp[0]
k = inp[1]
d = inp[2]
x = abs(x)
if(x >= k*d):
    print(x-k*d)
else:
    res=10000000000000000000000000000000000000
    tmp = int(x/d)
    for y in range(-100,100):
        if((y+tmp)<=k and y+tmp >=0):
            rem = k-y-tmp
            if(rem%2 == 0):
                res=min(res,abs(x-(y+tmp)*d))
    print(res)


Measured memory_bytes: 85028
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

  int onesDigit = n % 10;
  set<int> hon = {2, 4, 5, 7, 9};
  set<int> pon = {0, 1, 6, 8};
  if (hon.count(onesDigit)) {
    cout << "hon" << endl;
  } else if (pon.count(onesDigit)) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    string ans;
    if (s == "Sunny") ans = "Cloudy";
    else if (s == "Rainy") ans = "Sunny";
    else ans = "Rainy";
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(){
  int i;
  char a[10];
  cin >> a;
  for(i=0; i<3; i++)
    if(a[i]==a[i+1]){
      cout << "Bad";
      return 0;
    }
  cout << "Good";
  return 0;
}


Measured memory_bytes: 256
/*
 * Triangle.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(void) {

	int a, b, theta;
	cin >> a >> b >> theta;

	// 面積
	double dArea = 0.5 * (double)a * (double)b * sin(theta * M_PI / 180);

	// 周の長さ
	double dLength = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(theta * M_PI / 180));

	// 高さ
	double dHigh = 2.0 * dArea / a;

	cout << fixed << setprecision(8) << dArea << endl;
	cout << fixed << setprecision(8) << dLength << endl;
	cout << fixed << setprecision(8) << dHigh << endl;

	return 0;
}

Measured memory_bytes: 1288
from collections import Counter
N,K = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x%K, A))

"""
j - i < K and
Sj - Si == j - i (mod K)
Sj - j == Si - i (mod K) この変形が肝だ…
"""

S = [0 for _ in range(N+1)]
for i in range(N):
  S[i+1] = (S[i] + A[i] - 1) % K
ans = 0
C = Counter(S[:K])
for k,v in C.items():
  ans += v * (v-1) // 2
  
for i in range(K,N+1):
  deln = S[i-K]
  C[deln] -= 1
  addn = S[i]
  if addn in C:
    ans += C[addn]
    C[addn] += 1
  else:
    C[addn] = 1
    
print(ans)

Measured memory_bytes: 44408
#include <iostream>
#include <utility>
#include <cstring>
using namespace std;

void swap(int*,int*,int);
int main()
{
  int w,n,i;
  cin>>w>>n;
  int *numline = new int[w];
  for(i=0;i<w;++i){
    numline[i]=i+1;
  }
  int *swapline = new int[2*n];
  for(i=0;i<2*n;i+=2){
    char innum[10];
    cin >>innum;
    int m=0;
    while(innum[m]!=',') ++m;
    if(m==1){
      swapline[i]=innum[0]-48;
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[2]-48;
      else swapline[i+1]=10*(innum[2]-48)+(innum[3]-48);
    }
    else{
      swapline[i]=10*(innum[0]-48)+(innum[1]-48);
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[3]-48;
      else swapline[i+1]=10*(innum[3]-48)+(innum[4]-48);
    }
  }
  swap(numline,swapline,n);
  for(i=0;i<w;++i){
  cout<<numline[i]<<endl;
  }
  delete[] numline;
  delete[] swapline;
  return 0;
}

void swap(int numline[],int swapline[],int n)
{
  for(int i=0;i<2*n;i+=2){
    swap(numline[swapline[i]-1],numline[swapline[i+1]-1]);
  }
}


Measured memory_bytes: 3088