akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();
			int c = cin.Int();
			int x = cin.Int();
			int y = cin.Int();

			int ans = a * x + b * y;
			while (x > 0 || y > 0) {
				if (x > 0 && y > 0) {
					if (c * 2 < a + b) {
						--x;
						--y;
						ans -= (a + b) - c * 2;
					} else {
						break;
					}
				} else if (x > 0) {
					if (c * 2 < a) {
						--x;
						ans -= a - c * 2;
					} else {
						break;
					}
				} else {
					if (c * 2 < b) {
						--y;
						ans -= b - c * 2;
					} else {
						break;
					}
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
    int const max = 100000;
    int arr[max];
    long long M2, M1, C;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin>>arr[i];

    M2 = 0;
    C = M1 = abs(arr[1] - arr[0]);

    for (int j = 2; j < n; ++j)
    {
        C = min(M2 + abs(arr[j] - arr[j - 2]), M1 + abs(arr[j] - arr[j - 1]));
        M2 = M1;
        M1 = C;
    }

    cout << C;
    return 0;
}

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

using namespace std;

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

	int n;

	cin >> n;

	while(n>0)
	{
		if(n%10==7)
		{
			cout << "Yes" << '\n';
			return 0;
		}
		n/=10;
	}

	cout << "No" << '\n';
	return 0;
}

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

int main() {
	int n, p;
	
	while (cin >> n >> p) {
		if (!n) break;
		
		int i;
		int stones[50] = {0};
		int wan = p;
		
		for (i = 0; ; i = (i + 1) % n) {
			if (wan > 0) {
				wan--;
				stones[i]++;
				if (stones[i] == p) {
					break;
				}
			}
			else {
				wan = stones[i];
				stones[i] = 0;
			}
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <atcoder/modint>

#include <atcoder/math>
#include <atcoder/fenwicktree>
#include <atcoder/convolution>
#include <atcoder/scc>

#include <cstdio>

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

using namespace std;
typedef long long ll;

using namespace atcoder;

ll mod2 = 998244353;

int main()
{
    ll n, m;
    scanf("%lld %lld", &n, &m);
    scc_graph G(n);

    FOR(i, 0, m) {
        ll u, v;
        scanf("%lld %lld", &u, &v);
        G.add_edge(u, v);
    }

    auto scc = G.scc();

    printf("%lld\n", ll(scc.size()));

    for (auto v : scc) {
        printf("%lld ", ll(v.size()));
        for (ll x : v) {
            printf("%lld ", x);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 40588
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println("a " + (a < b ? "<" : (a > b ? ">" : "==")) + " b");
	}
}


Measured memory_bytes: 26140
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    cnt = 0
    while A >= B:
        B = B * 2
        cnt += 1
    
    while B >= C:
        C = C * 2
        cnt += 1
    
    if cnt <= K:
        print('Yes')
    else:
        print('No')
main()



Measured memory_bytes: 9052
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a > b {
		fmt.Println("a > b")
	} else if a < b {
		fmt.Println("a < b")
	} else {
		fmt.Println("a == b")
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int a,b;cin >> a >> b;
    int c;cin >> c;
    if(c*b>=a)cout << "Yes" ;
    else cout << "No";
    cout << endl;
}

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

int main() {
  ll N = 0, x = 0, y = 0, A = 0, B = 0,ans = 0;
  cin >> N >> A >> B;
  if(A >= N){
    cout << N;
    return 0;
  }
  if(A + B >= N){
    cout << A;
    return 0;
  }
  x = N % (A + B);
  y = N / (A + B);
  if(A >= x){
    ans = A * y + x;
    cout << ans;
    return 0;
  }
  else{
    ans = A * (y + 1);
    cout << ans;
    return 0;
  }
}

Measured memory_bytes: 256
import sys
import numpy as np

X,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(X)
    sys,exit()
pp = list(map(lambda x: abs(x-X), p))
pp.sort()
for i in range(1,100):
    tmp=X-pp[0]-i
    if not tmp in p:
        print(tmp)
        sys.exit()
    tmpp=X-pp[0]+i
    if not tmpp in p:
        print(tmpp)
        sys.exit()


Measured memory_bytes: 27180
# -*- coding: utf-8 -*-


def main():
    x = int(input())

    # dpによる解法
    # See:
    # https://atcoder.jp/contests/sumitrust2019/submissions/8726444
    dp = [False for _ in range(x + 200)]  # 配列を大きめに確保
    dp[0] = True  # 初期化

    for i in range(x + 10):
        if not dp[i]:
            continue

        # ある値に+100～+105できるとき
        for j in range(100, 106):
            dp[i + j] = True

    if dp[x]:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <functional>
#include <array>
#include <algorithm>

using namespace std;

int main()
{
	unsigned long long A ,B ,C;
	int ans;

	cin >> A >> B >> C;

	if (A % B > 0)
	{
		ans = C * (A / B) + C;
	}
	else
	{
		ans = C * (A / B);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3592
# educational DP contest F

X = input()
Y = input()
x = len(X)
y = len(Y)

dp = [[0 for _ in range(y + 1)] for _ in range(x + 1)]
for i in range(x):
    for j in range(y):
        if X[i] == Y[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])

# print(dp[x][y])

ans = ''
while x > 0 and y > 0:
    if dp[x][y] == dp[x][y - 1]:
        y -= 1
    elif dp[x][y] == dp[x - 1][y]:
        x -= 1
    else:
        ans += X[x - 1]
        x -= 1
        y -= 1

print(ans[::-1])


Measured memory_bytes: 119772
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

int main()
{
	int n, m;
	cin >> n >> m;
	deque<pair<int, int>>num;
	rep(i, n) {
		int a;
		cin >> a;
		num.push_back(make_pair(1, a));
	}
	rep(i, m) {
		int b, c;
		cin >> b >> c;
		num.push_back(make_pair(b, c));
	}
	sort(all(num), ps4);
	int i = 0;
	int count = 0;
	ll ans = 0;
	//rep(i, num.size()) {
		//cout << num[i].first << " " << num[i].second << endl;
	//}
	while (1) {
		count += num[i].first;
		ans += (ll)num[i].first * num[i].second;
		if (count < n) {
			i++;
		}
		else if(count==n){
			break;
		}
		else {
			ans -=(ll) (count - n) * num[i].second;
			break;
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1920
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
		char[][] aims = new char[h][];
    for(int i = 0; i < h; i++)
    {
      string s = Console.ReadLine();
      aims[i] = new char[w];
      for(int j = 0; j < w; j++)
      {
        aims[i][j] = s[j];
      }
    }
    char[][] answersTop = new char[h][];
    char[][] answersDown = new char[h][];
    for(int i = 0; i < h; i++)
    {
      answersTop[i] = new char[w];
      answersDown[i] = new char[w];
      for(int j = 0; j < w; j++)
      {
        answersTop[i][j] = '.';
        answersDown[i][j] = '.';//初期化

        if(j == 0) answersTop[i][j] = '#';
        if(j == w-1) answersDown[i][j] = '#';
        if(i%2 == 0 && j!= w-1) answersTop[i][j] = '#';
        if(i%2 == 1 && j!=0) answersDown[i][j] = '#';
        if(aims[i][j] == '#')
        {
          answersTop[i][j] = '#';
          answersDown[i][j] = '#';
        }
      }
    }

    for(int i = 0; i < h; i++)
    {
      Console.WriteLine(string.Join("", answersTop[i]));
    }
    Console.WriteLine("");
    for(int i = 0; i < h; i++)
    {
      Console.WriteLine(string.Join("", answersDown[i]));
    }
    
	}
}

Measured memory_bytes: 19524
#include <iostream>
#include <algorithm>
using namespace std;
int n, k, s, a[55];
int main() {
	int i;
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	for(i=n-k; i<n; i++) s += a[i];
	cout<<s;
	return 0;
}

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

int main(){
	int n;
  	string s;
  	cin >> n >> s;
  
  	int ans = 0;
	rep(i, n){
      	int j = i+1;
    	while(s[i] == s[j]){
        	j++;
        }
      	ans++;
      	i = j-1;
    }
  
	cout << ans << endl;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

constexpr int bit_size = 80*159+1;

int main() {
    int h = 0, w = 0;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> a.at(i).at(j);
        }
    }
    vector<vector<int>> b(h, vector<int>(w));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> b.at(i).at(j);
        }
    }

    vector<vector<int>> field(h, vector<int>(w));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            field.at(i).at(j) = abs(a.at(i).at(j) - b.at(i).at(j));
        }
    }
    
    vector<vector<bitset<bit_size>>> dp(h, vector<bitset<bit_size>>(w));
    dp.at(0).at(0).set(field.at(0).at(0)); 
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (i != h-1) {
                int tmp = field.at(i+1).at(j);
                dp.at(i+1).at(j) |= (dp.at(i).at(j) << tmp);
                dp.at(i+1).at(j) |= (dp.at(i).at(j) >> tmp);
                for (int k=0; k<tmp; k++) {
                    if (dp.at(i).at(j).test(k)) {
                        dp.at(i+1).at(j).set(tmp-k);
                    }
                }
            }
            if (j != w-1) {
                int tmp = field.at(i).at(j+1);
                dp.at(i).at(j+1) |= (dp.at(i).at(j) << tmp);
                dp.at(i).at(j+1) |= (dp.at(i).at(j) >> tmp);
                for (int k=0; k<tmp; k++) {
                    if (dp.at(i).at(j).test(k)) {
                        dp.at(i).at(j+1).set(tmp-k);
                    }
                }
            }
        }
    }

    for (int i=0; i<bit_size; i++) {
        if (dp.at(h-1).at(w-1).test(i)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 10368
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N, M;

//---------- 組み合わせ ----------
int comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = p * (n - i + 1) / i;
	}
	return p;
}

signed main()
{
	cin >> N >> M;
	int ans = 0;
	
	ans += comb(N, 2);
	ans += comb(M, 2);

	cout << ans << endl;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
const Int MAX = 5050;
Int dp[MAX][MAX];
signed main(){
  Int n,m;
  cin>>n>>m;
  for(Int i=0;i<m;i++){
    Int a,b,x;
    cin>>a>>b>>x;
    dp[a][b]++;
    dp[a][b+1]--;
    dp[a+x+1][b]--;
    dp[a+x+2][b+1]++;
    dp[a+x+1][b+2+x]++;
    dp[a+x+2][b+2+x]--;
  }
  
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j+1<MAX;j++)
      dp[i][j+1]+=dp[i][j];
  
  for(Int j=0;j<MAX;j++)
    for(Int i=0;i+1<MAX;i++)
      dp[i+1][j]+=dp[i][j];
  
  for(Int i=0;i+1<MAX;i++)
    for(Int j=0;j+1<MAX;j++)
      dp[i+1][j+1]+=dp[i][j];

  Int ans=0;
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      ans+=!!dp[i][j];

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



Measured memory_bytes: 202324
use std::io::BufRead;

fn main() {
    let handle = std::io::stdin();
    let mut s = String::new();
    handle.lock().read_line(&mut s).unwrap();
    for line in handle.lock().lines().skip(1) {
        let line = line.unwrap();
        let mut line = line.trim().split_whitespace();
        let command = line.next().unwrap();
        let start: usize = line.next().unwrap().parse().unwrap();
        let end: usize = line.next().unwrap().parse().unwrap();
        match command {
            "print" => { println!("{}", &s[start..end+1])},
            "reverse" => { 
                let mut reverse = s.drain(start..end+1)
                    .collect::<Vec<_>>();
                reverse.reverse();
                s.insert_str(start, &reverse.into_iter().collect::<String>());
            },
            "replace" => { 
                let c = line.next().unwrap();
                s.drain(start..end+1);
                s.insert_str(start, c);
            },
            _ => {println!("wtf");}
        }
    }
}


Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    ll a;
    string s;
    cin >> a >> s;
    ll b = 100*(int)(s[0]-'0') + 10*(int)(s[2]-'0') + (int)(s[3]-'0');
    ll ans = a * b / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
	int a;
	int ans;
	cin>>a;
	if (a==1){
		cout<<"Hello World"<<endl;
	}
	else if (a==2){
		int b,c;
		cin>>b>>c;
		ans=b+c;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int n;
void print(int a[])
{
	for(int i=0;i<n-1;i++) cout<<a[i]<<' ';
	
	cout<<a[n-1]<<'\n';
}
int main()
{
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	print(a);
	for(int i=1;i<n;i++)
	{
		int f=a[i];
		int j=i-1;
		while(a[j]>f && j>=0)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=f;
		print(a);
	}
	return 0;
} 


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

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

const ll MOD = 1e9+7;

inline void in() {}
template<class T, class... Ts>
inline void in(T& x, Ts&... xs) {
	int c, s=0; x=0;
	while (c=getchar(), c!='-'&&(c<'0'||c>'9'));
	if (c=='-') s=1, c=getchar();
	do x=x*10+(c-'0'); while (c=getchar(), c>='0'&&c<='9');
	if (s) x=-x;
	in(xs...);
}
inline void ins(char *s) {
    char c; while(c=getchar(), c<33); do *s++=c; while(c=getchar(), c>32); *s=0;
}

ll f[51][2501];

int main() {
	int n,a; int x[50];
	in(n,a);
	rep(i,0,n) in(x[i]);
	ll ans = 0;
	rep(l,1,n+1) {
		int t = a*l;
		memset(f,0,sizeof(f));
		f[0][0]=f[1][x[0]]=1;
		rep(i,1,n) {
			rrep(j,n,1) {
				rrep(k,t,x[i]) {
					f[j][k]+=f[j-1][k-x[i]];
				}
			}
		}
		ans += f[l][t];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="abc")cout<<"Yes"<<endl;
  else if(s=="acb")cout<<"Yes"<<endl;
  else if(s=="bac")cout<<"Yes"<<endl;
  else if(s=="bca")cout<<"Yes"<<endl;
  else if(s=="cab")cout<<"Yes"<<endl;
  else if(s=="cba")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys

def binary_search(array, num, left, right):
    if right < left + 1:
        return False
    center = (right + left) / 2
    if array[center] == num:
        return True
    elif array[center] < num:
        return binary_search(array, num, center + 1, right)
    elif array[center] > num:
        return binary_search(array, num, left, center)

n = int(sys.stdin.readline().strip())
S = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
n = int(sys.stdin.readline().strip())
T = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))

res = 0

for t in T:
    if binary_search(S, t, 0, len(S)):
        res += 1

print res
        

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

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

int N, S;
int A[3000 + 10];

ll dp[3000 + 10][3000 + 10][3];//0->まだ取り始めていない　1->Lが決まっていて、Rが未定 2->LもRも決まってる

int main() {
	cin >> N >> S;
	for (int i = 0; i < N; i++)cin >> A[i];

	dp[0][0][0] = 1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= S; j++) {
			(dp[i + 1][j][0] += dp[i][j][0]) %= MOD;
			(dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;//何も決めてない+ここでLを決めた
			(dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= MOD;//何も決めてない+ここでRを決めた+ここでLとRを決めた
			if (j + A[i] <= S) {
				(dp[i + 1][j + A[i]][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
				//何かしらを選ぶので、無からLを選ぶのと、Lの後に別の要素を選ぶのを、まとめてかける。dp[i][jが0でない][0]=0だし
				(dp[i + 1][j + A[i]][2] += dp[i][j][0] + dp[i][j][1]) %= MOD;
				//ここでj+A[i]の和を足して、そのままRを選んで区間を閉じた場合。if文外のように、後ろで閉じてもいい。
			}
		}
	}
	cout << dp[N][S][2] << endl;
	return 0;
}

Measured memory_bytes: 211968
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    long long  H,W;
    queue<pair<ll,ll>> q;
    queue<pair<ll,ll>> next_q;
    cin >> H >> W;
    string *data = new string[H];
    ll count = 0;

    for(int i = 0; i< H;i++){
        cin >> data[i];
    }

    // cout << H << W << endl;
    for(int i = 0; i< H;i++){
        for (int j = 0;j < W;j++){
            if (data[i][j] == '#'){
                // cout << "inseterd" << endl;
                q.push(make_pair(i,j));
            }
        }
    }

    while(!q.empty()){
        pair<ll,ll> p = q.front();
        q.pop();
        if (p.first > 0 && data[p.first-1][p.second] != '#'){
            data[p.first-1][p.second] = '#';
            next_q.push(make_pair(p.first-1,p.second));
        }

        if (p.first < H - 1 && data[p.first+1][p.second] != '#'){
            data[p.first+1][p.second] = '#';
            next_q.push(make_pair(p.first+1,p.second));
        }

        if (p.second > 0 && data[p.first][p.second-1] != '#'){
            data[p.first][p.second-1] = '#';
            next_q.push(make_pair(p.first,p.second-1));
        }

        if (p.second < W - 1 && data[p.first][p.second+1] != '#'){
            data[p.first][p.second+1] = '#';
            next_q.push(make_pair(p.first,p.second+1));
        }

        if (q.empty() && !next_q.empty()){
            count++;
            // for (int i = 0; i< H;i++){
            //     cout << data[i] << endl;
            // }
            while(!next_q.empty()){
                q.push(next_q.front());
                next_q.pop();
            }
            // cout << count << endl;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 17716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i= (begin) - ((begin) > (end)); i!= (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BBounding {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N, x;
    cin >> N >> x;
    rep(i,0,N){
        int t;
        cin >> t;
        x -= t;
        if(x < 0){
            cout << i + 1 << endl;
            return;
        }
    }
    cout << N + 1 << endl;
}
};


#undef int
int main() {
	BBounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int H[100000];

int main(void) {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N;++i) {
    scanf("%d", H + i);
  }

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      cnt++;
      if (ans < cnt)
        ans = cnt;
    } else {
      cnt = 0;
    }
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 2084
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	ll ax = abs(x);
	ll syo = ax / d;
	ll ans = Inf;
	if (syo <= k)
	{
	
		if (syo % 2 == 1)
		{
			if (k % 2 == 1){
				ans = ax % d;
			} else
			{
				ans = d - (ax % d);
			}
		} else
		{
			if (k % 2 == 1){
				ans = d - (ax % d);
			} else
			{
				ans = ax % d;
			}
		}
	} else
	{
		ans = ax - (k * d);
	}
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
 
std::string N;
 
int main()
{
	in >> N;
	if (N[0] == N[2]) { out << "Yes" << std::endl; }
	else { out << "No" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int j = 0; j < H; j++) {

			for (int i = 0; i < W; i++) {
				cout << '#';

			}
			cout << endl;
		}
		cout << endl;



	}


	return 0;
}




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

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

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

Measured memory_bytes: 512
N=int(input())
n=list(map(int,input().split()))
cnt=0
ans="YES"
c=""
for i in range(N):
    if n[i] != i+1:
        if cnt == 0:
            c=n[i]
        elif cnt >= 2:
            ans="NO"
            break
        else:
            if c != i+1:
                ans="NO"
                break
        cnt+=1

print(ans)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

// ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++; // counting divisors
bool isPrime(ll n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

map<int, int> yes;	 

ll cnt(ll n){
	int c = 0;
	for(int i{1}; i<=sqrt(n); i++){
		if(n%i==0){
			if(n/i == i){
				if(isPrime(i)) ++c;
			}
			else{
				if(isPrime(i)) ++c;
				if(isPrime(n/i)) ++c;
			}
				
		}
	}
	return c+1;
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	ll x,y; cin >> x >> y;
	cout << cnt(__gcd(x,y)) << "\n";

}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

  for(int i=0;i<m;i++){
    set<string> pattern;
    string arrival;
    cin >> arrival;
    for(int j=1;j<arrival.size();j++){
      string train[2];
      train[0]=arrival.substr(0,j);
      train[1]=arrival.substr(j);

      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);
      
      reverse(train[0].begin(),train[0].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);

      reverse(train[1].begin(),train[1].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);

      reverse(train[0].begin(),train[0].end());
      pattern.insert(train[0]+train[1]);
      pattern.insert(train[1]+train[0]);      
    }
    cout << pattern.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 3268
N,x=map(int,input().split())
a=list(map(int,input().split()))

count=0
if a[0]>x:
    count=(a[0]-x)
    a[0]=x

for i in range(1,N):
    if a[i]+a[i-1]>x:
        count+=(a[i]+a[i-1]-x)
        a[i]=x-a[i-1]
print(count)

Measured memory_bytes: 63856
n,k = STDIN.gets.split.map(&:to_i)
p_i = STDIN.gets.split.map(&:to_i)

p_i.map!{|i| (1.0+i)/2}

sum = p_i[0, k].inject(:+)
max = sum
left,right = 0, k-1

while
  right += 1
  break if right == n
  sum -= p_i[left]
  sum += p_i[right]
  max = [sum, max].max
  left += 1
end

puts max


Measured memory_bytes: 18700
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int K;
	cin >> K;
	int kisu = 0;
	int gusu = 0;
	for (int i = 1; i <= K; i++) {
		if (i % 2 == 0) {
			gusu++;
		}
		else {
			kisu++;
		}
	}
	cout << gusu * kisu;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication91
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = a[0] * a[1];
            Console.WriteLine(Math.Min(a[2], b));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    cout<<(m2>m1?"1":"0")<<endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    string  s;
    cin >> s;
    int cnt = 0;

    for (int i = 0; i < n-2; i++) {
        if (s.substr(i,3) == "ABC") cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3620
import math
x = int(input())
if (x <= 2):
    print(2)
    exit()
ans = 100003
if (x%2 == 0):
    x += 1
for num in range(x, 10**5, 2):
    flag = True
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if(num % i == 0):
            flag = False
            break
    if(flag):
        ans = num
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int R, G, B, N, A = 0;
  std::cin >> R >> G >> B >> N;


  for (int r = 0; r <= N; r+=R) {
    for (int rg = r; rg <= N ; rg+=G) {
      
        if ((N-rg)%B==0 ) {
          A += 1;
        }
      
    }
  }

  std::cout << A << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[214514];
ll ran[214514];
ll n,m;
ll root(ll x){
	return par[x]==x?x:par[x]=root(par[x]);
}
void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	if(ran[x]<ran[y])par[x]=y;
	else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)par[i]=i;
	for(int i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		unite(a,b);
	}
	ll ans=0;
	map<ll,ll>mp;
	for(int i=1;i<=n;i++){
		mp[root(i)]++;
		ans=max(ans,mp[root(i)]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 17508
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        g: [(String, i64); n],
    }

    let mut g: Vec<_> = g
        .into_iter()
        .enumerate()
        .map(|(i, (s, p))| (s, -p, i + 1))
        .collect();
    g.sort();
    for (_, _, i) in g {
        println!("{}", i);
    }
}


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

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(b-1, n);
    cout << a*x/b - a*(x/b) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
	
	int A,B,C,D,M,N=0;
	// 1<=A<=10^4,1<=B<=10^4,1<=C<=10^4,1<=D<=10^4
	
    scanf("%d %d %d %d",&A,&B, &C, &D);	
	
	
	M=A*B;
	
	N=C*D;
	
	if(M>=N)
   {
	    printf ("%d",M);
}
	else
	
	{
		printf("%d",N);
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

#include<vector>
using namespace std;

int main() {
	int n,m;cin>>n>>m;
	vector<int> l(m),r(m);
	vector<int> count(n+2,0);
	for(int i=0;i<m;i++){
		cin>>l[i]>>r[i];
		count[l[i]]++;
		count[r[i]+1]--;
	}
	for(int i=1;i<n+1;i++){
		count[i]+=count[i-1];
	}
	int ans=0;
	for(int i=1;i<n+1;i++){
		if(count[i]==m){
			ans++;
		}
//		cout<<count[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1408
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j;
    ll x;
    for(i=1;i<=5;i++)
    {
        cin>>x;
        if(x!=i)
        {
            cout<<i;
            return 0;
        }
    }
    return 0;

}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <string>
#include <stack>
using namespace std;


int main(){
    string S;
    stack<int> st;
    cin >> S;
    
    for(int i=0;i<S.length();i++){
        if(st.empty()){
            st.push(S[i] - '0');
            continue;
        }else if(st.top() != S[i] - '0'){
            st.pop();
        }else{
            st.push(S[i] - '0');
        }
    }
    cout << S.length() - st.size() << endl;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,m,a[N];
vector<int>v[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=m;i++){
    int s,t;
    cin>>s>>t;
    v[s].pb(t);
    v[t].pb(s);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    for(auto k:v[i]){
      if(a[i]>a[k]){
        cnt++;
      }
    }
    if(cnt==v[i].size())ans++;
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 11516
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var result = "";
            var s = Console.ReadLine().Trim();
            var number = "";
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j] != '0') number += s[j].ToString();
                else
                {
                    if (number != "")
                    {
                        result += Kakutei(int.Parse(number[0].ToString()) , number.Length);
                        number = "";
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
    public static string Kakutei(int button, int times)
    {
        var btn = new string[] { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
        var p = times % btn[button - 1].Length - 1;
        if (p < 0) p += btn[button - 1].Length;
        return btn[button - 1][p].ToString();
    }
}

Measured memory_bytes: 9452
N = int(input())
M = [0]*N
edge = [0]*N
for i in range(N):
  edge[i]=[0]*N
sum=0
for i in range(N):
    M[i] = list(map(int,input().split()))
for i in range(N):
    for k in range(i+1,N):
        edge[i][k] = pow(((M[i][0]-M[k][0])**2 + (M[i][1]-M[k][1])**2),0.5)
        sum+=edge[i][k]
average = sum/N*2
print(average)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#define Max 2000000

int H,A[Max+1];
void maxheap(int i){
  int l,r,max,tmp;
  l=2*i;
  r=2*i+1;

  if(l <= H && A[l]>A[i])max=l;
  else max=i;
  if(r<=H && A[r]>A[max])max=r;

  if(max!=i){
    tmp=A[i];A[i]=A[max];A[max]=tmp;
    maxheap(max);
  }
}


int main(){
  int i;
  
  scanf("%d",&H);
  
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  
  for(i=H/2;i>=1;i--)maxheap(i);
  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  
  return 0;
}



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

struct UnionFind{
        vector<long long> p;
        vector<long long> size;
        vector<long long> rank;
        UnionFind(long long n) : p(n),size(n,1),rank(n,1){
                for(long long i=0;i<n;++i) p.at(i) = i;
        }

        long long Root(long long x){
                return p.at(x)==x ? x : p.at(x) = Root(p.at(x));
        }

        void Unite(long long x, long long y){
                x = Root(x);
                y = Root(y);
                if(x==y) return;
                if(rank.at(x) < rank.at(y)){
                        p.at(x) = y;
                        size.at(y) += size.at(x);
                }
                else{
                        p.at(y) = x;
                        size.at(x) += size.at(y);
                        if(rank.at(x)==rank.at(y)) ++rank.at(x);
                }
        }

        long long Size(long long x){
                x = Root(x);
                return size.at(x);
        }

        long long Rank(long long x){
                x = Root(x);
                return rank.at(x);
        }
};

int main(){
        int i,N,M,K,A,B;
        cin >> N >> M >> K;
        vector<vector<int>> f(N);
        vector<int> b(N);
        UnionFind uf(N);
        for(i=0;i<M;++i){
                cin >> A >> B;
                --A; --B;
                f.at(A).push_back(B);
                f.at(B).push_back(A);
                uf.Unite(A,B);
        }
        for(i=0;i<K;++i){
                cin >> A >> B;
                --A; --B;
                if(uf.Root(A)==uf.Root(B)){ ++b.at(A); ++b.at(B);}
        }
        for(i=0;i<N;++i) cout << uf.Size(i)-f.at(i).size()-b.at(i)-1 << " ";
        cout << endl;
        return 0;
}

Measured memory_bytes: 11576
n = int(input())

a = [int(input()) for _ in range(n)]

a = sorted(a)

ans = n
flag = 0
for i in range(1, n):
    if a[i] != a[i-1] or flag == 1:
        flag = 0
    else:
        flag = 1
        ans -= 2

print(ans)

Measured memory_bytes: 8284
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int[] ipt = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var lst = new List<int>();

        lst.Add(ipt[0] + ipt[1]);
        lst.Add(ipt[0] - ipt[1]);
        lst.Add(ipt[0] * ipt[1]);
        WriteLine(lst.Max());
    }
}


Measured memory_bytes: 13268
import math

N,K = map(int,input().split())
ans = 0

def combination(n,r):
    return(math.factorial(n) // (math.factorial(n-r) * math.factorial(r)))

for i in range(K,N+2):
    low = (i-1)*i // 2
    high = (N+N-i+1)*i // 2
    ans += (high-low+1)
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 9092
<?php

[$N, $M, $Q] = fscanf(STDIN, "%d%d%d");
$smap = array_fill(1, $N,array_fill(1,$N,0));
for($i=0;$i<$M;$i++){
    [$L, $R] = fscanf(STDIN, "%d%d");
    $smap[$L][$R]++;
}
$ansmap = array_fill(0,$N+1,array_fill(0,$N+1,0));

for($i=1;$i<=$N;$i++){
    for($j=$i;$j<=$N;$j++){
        $ansmap[$i][$j] = $ansmap[$i][$j-1] + $smap[$i][$j];
    }
}


for($j=0;$j<$Q;$j++){
    [$L, $R] = fscanf(STDIN, "%d%d");
    $ans = 0;
    for($i=$L;$i<=$R;$i++){
        $ans += $ansmap[$i][$R];
    }

    echo $ans.PHP_EOL;
}

[$N, $M, $Q] = fscanf(STDIN, "%d%d%d");
$smap = array_fill(1, $N, array_fill(1, $N, 0));
for ($i = 0; $i < $M; $i++) {
    [$L, $R] = fscanf(STDIN, "%d%d");
//    if(!isset($smap[$L][$R])){
//        $smap[$L][$R] = 1;
//    } else{
    $smap[$L][$R]++;
//    }
}
$ansmap = array_fill(0, $N + 1, array_fill(0, $N + 1, 0));

for ($i = 1; $i <= $N; $i++) {
    for ($j = $i; $j <= $N; $j++) {
        $ansmap[$i][$j] = $ansmap[$i][$j - 1] + $smap[$i][$j];
    }
}


for ($j = 0; $j < $Q; $j++) {
    [$L, $R] = fscanf(STDIN, "%d%d");
    $ans = 0;
    for ($i = $L; $i <= $R; $i++) {
        $ans += $ansmap[$i][$R];
    }

    echo $ans . PHP_EOL;
}

Measured memory_bytes: 31984
N=int(input())
L=[0]*(10**5+1)
A=list(map(int,input().split()))
A.sort()
for i in A:
  L[i]+=1
ans=0
for i in range(10**5-1):
  ans=max(ans,L[i]+L[i+1]+L[i+2])
print(ans)

Measured memory_bytes: 21516