akhauriyash/Code-Regression huggingface dataset:
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = input[0][0];

  return N.includes("7") ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N;
    cin >> N;

    map<string,int> Map;
    vector<string> memo;
    rep(i,N){
        string s;
        cin >> s;
        if(Map[s]==0) memo.pb(s);
        Map[s]++;
    }

    cout << memo.size() << endl;
}

Measured memory_bytes: 25100
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
int a[120];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }

    sort(a,a+n);
    ll sum=0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            for(int k=j+1; k<n; k++)
            {
                if(a[k]<a[j]+a[i]&&a[i]>a[k]-a[j]&&a[k]!=a[i]&&a[j]!=a[i]&&a[k]!=a[j])
                {
                    sum++;
                }
            }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3612
function Main(input){
  input = input.split(' ');
  var x = Number(input[0]);
  var y = Number(input[1]);

  var group_a = [1,3,5,7,8,10,12];
  var group_b = [4,6,9,11];
  var group_c = [2];

  if( group_a.indexOf(x) > -1 && group_a.indexOf(y) > -1 || 
  group_b.indexOf(x) > -1 && group_b.indexOf(y) > -1 ||
  group_c.indexOf(x) > -1 && group_c.indexOf(y) > -1) {
      console.log('Yes');
  } else {
      console.log('No');
  }

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

Measured memory_bytes: 9420
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n % 2 == 0:
        dp = [[-10**18]*2, [-10**18]*2]
        dp[0][0] = 0
        for i in range(n):
            dp2 = [[-10**18]*2, [-10**18]*2]
            # 使う場合
            dp2[1][0] = max(dp2[1][0], dp[0][0]+a[i])
            dp2[1][1] = max(dp2[1][1], dp[0][1]+a[i])
            # 使わない場合
            dp2[0][1] = max(dp2[0][1], dp[0][0])
            # 更新
            dp2[0][0] = max(dp2[0][0], dp[1][0])
            dp2[0][1] = max(dp2[0][1], dp[1][1])
            dp = dp2
        print(max(dp[1][1], dp[0][0]))
        return
    dp = [[-10**18]*3, [-10**18]*3]
    dp[0][0] = 0
    for i in range(n):
        # 使う場合
        dp2 = [[-10**18]*3, [-10**18]*3]
        dp2[1][0] = max(dp2[1][0], dp[0][0]+a[i])
        dp2[1][1] = max(dp2[1][1], dp[0][1]+a[i])
        dp2[1][2] = max(dp2[1][2], dp[0][2]+a[i])
        # 使わない場合
        dp2[0][1] = max(dp2[0][1], dp[0][0])
        dp2[0][2] = max(dp2[0][2], dp[0][1])
        # 更新
        dp2[0][0] = max(dp2[0][0], dp[1][0])
        dp2[0][1] = max(dp2[0][1], dp[1][1])
        dp2[0][2] = max(dp2[0][2], dp[1][2])
        dp = dp2
    print(max(dp[1][2], dp[0][1]))


main()

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

long long N;
long long A[100005];

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
	}
	set<pair<long long, long long>> cur;

	for(long long i = 0; i < N; i++){
		long long num = A[i];

		auto it = cur.lower_bound(make_pair(num, -1));
		if(it == cur.begin()){
			cur.insert(make_pair(num, i));
		}else{
			it--;
			cur.erase(it);
			cur.insert(make_pair(num, i));
		}
	}
	cout << cur.size() << endl;
}

Measured memory_bytes: 7296
s=input()
if s[1]==s[1].upper() or s[-1]==s[-1].upper():
    print("WA")
    exit()

if s[0]=="A":
    count=0
    for i in range(2,len(s)-1):
        if s[i]=="C":
            count+=1
        else:
            if s[i]==s[i].upper():
                print("WA")
                exit()
    if count==1:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3064
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(check(s) ? "YES" : "NO");
    }
    public static bool check(string s)
    {
        if (s.Replace("A", "") != "KIHBR") return false;
        if (s.Substring(0, 3) != "KIH" && s.Substring(0, 4) != "AKIH") return false;
        string s2;
        if (s.Substring(0, 3) == "KIH") s2 = s.Substring(3);
        else s2 = s.Substring(4);
        string[] c = { "BARA", "BRA", "BAR", "BR", "ABARA", "ABRA", "ABAR", "ABR" };
        foreach (var x in c)
            if (s2 == x) return true;
        return false;
    }
}


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

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

  int sum = 0;
  
  vector<int> vote(N); // N個の商品の得票数データ

  // 得票数データを受け取る
  for (int i = 0; i < N; i++) {
    cin >> vote.at(i);
    sum = sum + vote.at(i);
  }
  
  sort(vote.begin(), vote.end());
    
  reverse(vote.begin(), vote.end());

  string answer = "No";
  
  // M個の商品が総得票数の1/4Mを満たしているかを確認
  for (int i = 0; i < M; i++) {
    if (vote.at(i)*4*M < sum ) {
      answer = "No";
      break;
    }
    
    else {
      answer = "Yes";
    }
    
  }
  
  cout << answer << endl;

}


Measured memory_bytes: 256
#include <iostream> 

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int cnt = 0;

	for (int i = a; i <= b; i++) {
		if (c%i == 0) cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;

/**
 * Delivery Fee
 */
public class Main {

	static Main main = new Main();
	static TreeMap<Parcel, Integer> fee = new TreeMap<Parcel, Integer>() {
		{
			put(main.new Parcel(60, 2), 600);
			put(main.new Parcel(80, 5), 800);
			put(main.new Parcel(100, 10), 1000);
			put(main.new Parcel(120, 15), 1200);
			put(main.new Parcel(140, 20), 1400);
			put(main.new Parcel(160, 25), 1600);
		}
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {
			int n, sum = 0;
			n = Integer.parseInt(line);
			for (int i = 0; i < n; ++i) {
				Parcel p = main.new Parcel(br.readLine());
				Entry<Parcel, Integer> e;
				if ((e = fee.ceilingEntry(p)) != null) {
					sum += e.getValue();
				}
			}
			System.out.println(sum);
		}
	}

	class Parcel implements Comparable<Parcel> {
		int size, weight;

		Parcel(int size, int weight) {
			this.size = size;
			this.weight = weight;
		}

		Parcel(int x, int y, int h, int w) {
			this(x + y + h, w);
		}

		Parcel(String info) {
			StringTokenizer st = new StringTokenizer(info);
			int x, y, h, w;
			x = Integer.parseInt(st.nextToken());
			y = Integer.parseInt(st.nextToken());
			h = Integer.parseInt(st.nextToken());
			w = Integer.parseInt(st.nextToken());
			size = x + y + h;
			weight = w;
		}

		@Override
		public int compareTo(Parcel o) {
			int r1 = this.weight - o.weight;
			int r2 = this.size - o.size;
			if (r1 > 0 || r2 > 0) {
				return 1;
			} else if (r1 == 0 && r2 == 0) {
				return 0;
			} else {
				return -1;
			}
		}
	}
}

Measured memory_bytes: 24788
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n;
    cin >> n;
    int a[2][n];
    for (int i = 0; i < n; i++) cin >> a[0][i];
    for (int i = 0; i < n; i++) cin >> a[1][i];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll sum = 0;
        for (int j = 0; j <= i; j++) sum += a[0][j];
        for (int j = i; j < n; j++) sum += a[1][j];
        chmax(ans, sum);
    }
    cout << ans << endl;
}

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

using namespace std;

using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define cot(x) cerr << #x << " " << x << " ";
#define cotd(x) cerr << #x << " " << x << endl;
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T > void check(T & a, const T & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }
LL mulmod(LL a, LL b, const LL & m) { LL q = (LL)(((LD)a*(LD)b) / (LD)m); LL r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, const T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }

const int N = (int)1e5 + 10; 
LL pre[N]; vi a; int n, dp[N]; 

bool ch(int mid){
	//her; 
	if(mid == 1) return true; 
	int idx = n - mid; 
	LL sum = pre[idx]; 

	for(int i = idx + 1; i < n; i++){
		if(a[i] > 2*sum) return false; 
		sum += a[idx]; 
	}
	return true; 
}

int main(){
	SYNC; 
	cin >> n; a.resize(n); 

	REP(i , n)
		cin >> a[i]; 

	sort(ALL(a));

	REP(i , n){
		pre[i] = ( i ? pre[i - 1] + a[i] : a[i]); 
	}

	dp[n-1] = true; int ans = 1; 

	for(int i = n - 2; i >= 0; i--){
		LL s = pre[i]; 
		if(a[i + 1] <= pre[i] * 2 && dp[i+1])
			ans++, dp[i] = true ; 
	}

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

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


int main() {

    int n;
    cin >> n;
    for (int i = 0; i <= 25; ++i) {
        for (int j = 0; j <= 25; ++j) {
            if (4*i + 7*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
	int n;
	string t, h;
	int tc, hc ;
	tc = hc = 0;
	cin>>n;
	while(n--)
	{
		cin>>t>>h;
		if(t==h)
		{
			tc++;
			hc++;
		}
		if(t>h) {tc+=3;}
		if(h>t) {hc+=3;}
	}
	cout<< tc <<" " << hc << "\n";
	return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

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

	return 0;

}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int score[] = new int[1000];
		double avg = 0.0;
		double a = 0.0;
		while(n != 0){
			avg = 0.0;
			a = 0.0;
			for(int i = 0; i < n; i++){
				score[i] = sc.nextInt();
				avg += (double)score[i];
			}
			avg /= (double)n;
			for(int i = 0; i < n; i++){
				a += (score[i] - avg) * (score[i] - avg);
			}
			a = Math.sqrt(a/(double)n);
			System.out.println(a);
			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 31200
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <climits>
#include <limits>
#include <queue>
#include <utility>

using namespace std;



#define ll long long
#define mod 998244353
	int main() {

		int a, b, c, d;
		cin >> a >> b >> c >> d;
		vector<vector<ll>> dp(c, vector<ll>(d, 1));

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				dp[i][j] = 1;
			}
		}
		for (int i = a; i < c; i++) 
			dp[i][b - 1] = ((dp[i-1][b-1]%mod)*b) % mod;
		for (int j = b; j < d; j++)
			dp[a - 1][j] = ((dp[a - 1][j - 1]%mod)*a) % mod;

		for (int i = a; i < c; i++) {
			for (int j = b; j < d; j++) {
				dp[i][j] = (((dp[i - 1][j]%mod) * (j + 1))%mod + ((dp[i][j - 1]%mod) * (i + 1))%mod - 
					(dp[i - 1][j - 1]%mod) * (i*j))%mod;
				if (dp[i][j] < 0)
					dp[i][j] += mod;
			}
		}

		cout << endl;

		//for (int i = 0; i < c; i++) {
		//	for (int j = 0; j < d; j++) {
		//		cout << dp[i][j] << ", ";
		//	}
		//	cout << endl;
		//}

		cout << dp[c - 1][d - 1]%mod << endl;
	
		return 0;
	}




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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  vector<int> a(n);
  for(int i=0; i<n; i++){
    a.at(i) = vec.at(i);
  }
  sort(a.begin(), a.end());
  for(int i=0; i<n; i++){
    if(vec.at(i) != a.at(n-1)){
      cout << a.at(n-1) << endl;
    }
    else{
      cout << a.at(n-2) << endl;
    }
  }
}


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	char a,b,c;
	cin >> a >> b >> c;
	if(a != c)
	{
		cout << "No\n";
	}
	else
		cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll h,w; cin>>h>>w;
        ll ans1,ans2;
        if(h==1 or w==1) {
            cout<<1; return 0;
        }
        ans1 = w/2+w%2,ans2 = w/2;
        ll ans = (h/2)*(ans1+ans2);
        if(h%2) ans+=ans1;
        cout<<ans;
    }   
}


Measured memory_bytes: 3588
def B(n):
    r = ""
    c = 0
    for _ in range(len(n)):
        s = ""
        for i in n[c:]:
            c+=1  
            if i in ["A","T","G","C"]:
                s+=i
            else:
                break
        
        if len(s) > len(r):
            r = s 
    return r

b = input()
print(len(B(b)))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int func(int x){
   int temp;

   temp = x%2;

   if(temp == 0){ 
       x = x/2;
   }

   return temp;

}

int main(){
    int n;
    int A[200];
    int hanteishi[200];
    int temp=0;
    int count=0;

 cin >> n;

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

while(1){
    if(temp !=0) break;

    for(int i =0;i<n;i++){
     hanteishi[i] = func(A[i]);
     if(hanteishi[i]==0)A[i]=A[i]/2;
    }
    for(int i=0;i<n;i++){
        temp+=hanteishi[i];
    }
    count++;
}

cout << count-1 << endl;

 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	long long a[200020], b[200020];

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i] - i;
	}

	sort(b, b + n);

	long long cen = b[n / 2];

	long long sad = 0;
	for (int i = 0; i < n; i++) {
		sad += abs(b[i] - cen);
	}

	cout << sad << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &Ai : A) {
    cin >> Ai;
  }
  sort(A.begin(), A.end());
  bool flag = false;
  for (int i = 0; i < A.size() - 1; ++i) {
    if (A[i] == A[i + 1]) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin >> n;
    
    vector<int> a, b;
    if (n % 2 == 1) {
        for (int i = 0; i < n - 1; i++) {
            a.push_back(i + 1);
            b.push_back(n);
        }
        
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                if (i + j != n) {
                    a.push_back(i);
                    b.push_back(j);
                }
            }
        }
        
        cout << a.size() << endl;
        for (int i = 0; i < a.size(); i++) {
            cout << a[i] << " " << b[i] << endl;
        }
        
    }
    else {
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (i + j != n + 1) {
                    a.push_back(i);
                    b.push_back(j);
                }
            }
        }
        
        cout << a.size() << endl;
        for (int i = 0; i < a.size(); i++) {
            cout << a[i] << " " << b[i] << endl;
        }
        
    }
    
    
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    print("First" if((len(S)&1)^(S[0]==S[-1])) else "Second")
resolve()

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;
int a[N], c[N];

int main() {
    ans = INT_MAX;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        int cnt = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ++cnt;
        }
        c[i] = cnt;
    }
    for (int i = 0; i < n; ++i) {
        ans = min(ans, c[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    int all = 0;
    cin >> n;
    int a[n];
    int r[n + 1];
    r[0] = 0;
    rep(i, n) {
        cin >> a[i];
        all += a[i];
        r[i + 1] = r[i] + a[i];
    }
    int ans = INF;
    rep(i, n - 1) {
        int x = r[i + 1];
        int y = all - r[i + 1];
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(i = 0; i <= n; i++)

int main(void)
{
    int K,S;
    int x,y,z;
    cin >> K >> S;
    int cnt = 0;
    REP(x, K) {
        REP(y, K) {
            z = S - x - y;
            if(z >=0 && z <= K) {
//                cout << x << " " << y << endl;
                cnt ++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(Math.max(a * b, c * d));
	}
}


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

bool check(vector<P> A) {
    int a = 0;
    rep(i, A.size()) {
        int b = A[i].first;
        if (a+b < 0) return false;
        a += A[i].second;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<P> ls, rs;
    int t = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int a = 0, b = 0;
        rep(j, s.size()) {
            if (s[j] == '(') ++a;
            else --a;
            b = min(a, b);
        }
        if (a > 0) ls.emplace_back(b, a);
        else rs.emplace_back(b-a, -a);
        t += a;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());
    if (check(ls) && check(rs) && t == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 18884
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
N = 10 ** 6

#逆元テーブル
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def comb(n, r):
    ret = 1
    for i in range(1, r + 1):
        ret = (ret * (n - i + 1) * inv_t[i]) % mod
    return ret

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
        x = x * x % mod
        n //= 2

    return K * x % mod

print((pow_k(2, n) - 1 - comb(n, a) - comb(n,b))%mod)


Measured memory_bytes: 42668
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<ll,int> pli;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);i++)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
string ys = "Yes\n";
string no = "No\n" ;
const double EPS = 1e-6;
const int inf = 2e9;
const ll M  = 998244353 ;
const int N = 100100;
/////  for (int i= -inf ; i < inf ; i++)   Hi  :P



main()
{
    speed;
    int n;
    cin >> n;
    if ( n  < 1000) {
        cout << "ABC";
    }else {
        cout << "ABD";
    }

}

Measured memory_bytes: 256
from collections import deque

def main():
    n, x, y = map(int, input().split())
    cnt = [0]*n
    q = deque()
    
    for i in range(n):
        q.appendleft([i, 0])
        dist = [None]*n
        dist[i] = 0
        while q:
            j, d = q.pop()
            cnt[d] += 1
            if j > 0 and dist[j-1] is None:
                dist[j-1] = d+1
                q.appendleft([j-1, d+1])
            if j < n-1 and dist[j+1] is None:
                dist[j+1] = d+1
                q.appendleft([j+1, d+1])
            if j == x-1 and dist[y-1] is None:
                dist[y-1] = d+1
                q.appendleft([y-1, d+1])
            elif j == y-1 and dist[x-1] is None:
                dist[x-1] = d+1
                q.appendleft([x-1, d+1])
    for i in range(1, n):
        print(cnt[i]//2)
                

if __name__ == "__main__":
    main()

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

#define vi vector<int>
#define pb push_back


int main(){
    ll a, b, bef = 0, aft = 0, mid = 0;
    cin >> a >> b;
    if (a % 2 != 0) {
        bef = a; 
        a++;
    }
    if (b % 2 == 0) {
        aft = b;
        b--;
    }

    if (((b - a) + 1) / 2 % 2 == 0) mid = 0;
    else mid = 1;
    cout << (aft ^ mid ^ bef) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }

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

	int q;
	cin >> q;

	string pre, post;
	bool b = true;

	rep(i, q) {
		int t;
		cin >> t;
	
		if (t == 1) {
		  b ^= true;
		}
		else {
			int f; char c;
			cin >> f >> c;

			if (f == 1) {
				if (b) {
				  pre.push_back(c);
				}
				else {
				  post.push_back(c);
				}
			}
			else {
				if (b) {
					post.push_back(c);
				}
				else {
					pre.push_back(c);
				}
			}
		}
	}

	reverse(pre.begin(), pre.end());

	string ans = pre + s + post;
	if (b) cout << ans << endl;
	else { reverse(ans.begin(), ans.end()); cout << ans << endl; }
}




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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool solve(int N, string S, int ans) {
    if(ans == 0) return true;

    set<string> memo;
    queue<string> tmp;
    REP(j, ans) tmp.push("");
    REP(i, N) {
        memo.insert(tmp.front());
        tmp.pop();

        if(memo.count(S.substr(i, ans))) {
            return true;
        }
        tmp.push(S.substr(i, ans));
    }

    return false;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    int left = -1;
    int right = S.size() / 2 + 1;

    while(right - left > 1) {
        int mid = left + (right - left) / 2;
        if(solve(N, S, mid)) left = mid;
        else right = mid;
    }

    cout << left << endl;
}


Measured memory_bytes: 9704
S = input()

s_len = len(S)
count_0 = 0
count_1 = 0

for i in range(s_len):
    if S[i] == "0":
        count_0 += 1
    else:
        count_1 += 1

ans = min(count_0, count_1) * 2

print(ans)
        
               
            

Measured memory_bytes: 3188
object Main extends App {

  import scala.io.StdIn._

  val Array(y, m, d) = readLine.trim.split(' ').map(_.toInt)
  val Array(z, n, e) = readLine.trim.split(' ').map(_.toInt)
  val diff = Date(y, m, d) - Date(z, n, e)
  println(
    (diff.abs + 371) / 372
  )
  case class Date(year: Int, month: Int, day: Int) {
    def -(that: Date): Int = toInt - that.toInt
    private def toInt: Int = year * 372 + (month - 1) * 31 + day - 1
  }
}



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

int main()
{
	string in,large="";
	map<string,int> cnt;
	getline(cin,in);
	string tmp="";
	for(int i=0;i<in.size();i++)
	{
		if(in[i]==' '||i==in.size()-1)
		{
			if(i==in.size()-1&&in[i]!=' ') tmp+=in[i];
			large=large.size()<tmp.size()?tmp:large;
			cnt[tmp]++;
			tmp="";
		}
		else
		{
			tmp+=in[i];
		}
	}
	map<string,int>::iterator it=cnt.begin();
	string ans; int num=0;
	while(it!=cnt.end())
	{
		//cout<<(*it).first<<" "<<(*it).second<<endl;
		if((*it).second>num)
		{
			ans=(*it).first;
			num=(*it).second;
		}
		it++;
	}
	cout<<ans<<" "<<large<<endl;
	return 0;
}

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

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

    if (n % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> d(n);
    rep(i,n) cin >> d[i];

    sort(d.begin(), d.end());

    if (d[d.size()/2] == d[d.size()/2-1]) {
        cout << 0 << endl;
    }
    else {
        cout << d[d.size()/2]-d[d.size()/2-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	vi a(n),b(n),c(n-1);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];
	int ans = 0;
	int pre;
	rep(i,n){
		ans += b[--a[i]];
		if(a[i]==pre+1) ans += c[a[i]-1];
		pre = a[i];
	}
	out(ans);
}




Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    let mut a = 0;
    let mut b = 0;
    let mut ba = 0;
    for _ in 0..n {
        let s: Vec<char> = itr.next().unwrap().chars().collect();
        for i in 0..s.len() - 1 {
            if s[i] == 'A' && s[i + 1] == 'B' {
                ans += 1;
            }
        }
        if s[0] == 'B' && s[s.len() - 1] == 'A' {
            ba += 1;
        } else if s[0] == 'B' {
            b += 1;
        } else if s[s.len() - 1] == 'A' {
            a += 1;
        }
    }
    if ba > 0 {
        ans += ba - 1;
        if a > 0 {
            a -= 1;
            ans += 1;
        }
        if b > 0 {
            b -= 1;
            ans += 1;
        }
    }
    ans += std::cmp::min(a, b);

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


Measured memory_bytes: 4352
#include <iterator>
#include <typeinfo>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
string Addition(string a,string b) {
	string ans = "";
	int bef = 0;
	int be1 = 0;
	for (int i = a.length() - 1; i >= 0; i--) {
		int added = stoi(a.substr(i, 1)) + stoi(b.substr(i, 1))+be1;

		if (added >= 10) {
			bef = 1;
			added -= 10;
		}
		else {
			bef = 0;
		}

		ans = to_string(added)+ans;
		/*/
		stringstream ss;
		ss << added;

		ans = ss.str() + ans;*/
		be1 = bef;
		if (i == 0)
		{
			break;
		}
	}
	if (be1 == 1) {
		ans = "1" + ans;
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	rep(o1, n) {
		string a, b;
		cin >> a >> b;
		if (a.length() < b.length()) {
			swap(a, b);
		}
		string b1 = b;
		for (int i = 0; i < a.length() - b1.length(); ++i) {
			b = '0' + b;
		}
		string ans = Addition(a, b);
		if (ans.length() > 80) { cout << "overflow" << endl; }
		else {
			cout << ans << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3132
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇

    let (X, Y) = (io.read::<i64>(), io.read::<i64>());
    // 終わるとき：　 [2, 0] となっているときに石をとったほうがかち

    io.writeln(if (X - Y).abs() <= 1 { "Brown" } else { "Alice" });
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    fast;
    string S;   cin>>S;
    std::reverse(std::begin(S), std::end(S));
    while(!S.empty()){
        // cout<<S<<endl;
        if(S.substr(0,5)=="esare" || S.substr(0,5)=="maerd" ){
            S= S.substr(5,S.length());
        }
        else if(S.substr(0,6)=="resare"){
            S= S.substr(6,S.length());
        }
        else if(S.substr(0,7)=="remaerd"){
            S= S.substr(7,S.length());
        }
        else{
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 512
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

c = [[a[0][0], a[1][0], a[2][0]]] + [[a[0][1], a[1][1], a[2][1]]] + [[a[0][2], a[1][2], a[2][2]]] + [[a[0][0], a[1][1], a[2][2]]] + [[a[0][2], a[1][1], a[2][0]]]  + a
ans = "No"
for i,n1 in enumerate(c):
    a1 = 0
    for k,n2 in enumerate(n1):
        for j in b:
            if n2 == j:
                a1 += 1
        if a1 == 3:
            ans = "Yes"
            break
    else:
        continue
    break

print(ans)

Measured memory_bytes: 38384
N, A, B = map(int, input().split())
sum_1 = 0
for i in range(1,N+1):
    sum_order = 0
    i_str = str(i)
    n = len(i_str)
    for j in range(0,n):
        sum_order += int(i_str[j])
    if A <= sum_order <= B:
        sum_1 += i
print(sum_1)

Measured memory_bytes: 9096
#include <iostream>
    #include <fstream>
    #include <bits/stdc++.h>
    #include <map>
    #define pb push_back
    #define ll long long
    using namespace std;
    ll dp[1010][1010];
    bool checker[1010];
    bool a[1010][1010];
    ll mod = 1000000007;
    int main()
    {
        int H,W,i,j;
        char c;
        cin>>H>>W;
        for(i=1;i<=H;i++)
        {
            for(j=1;j<=W;j++)
            {
                cin>>c;
                if(c=='.')
                    a[i][j]=true;
                else
                    a[i][j]=false;
            }
        }
        dp[1][1]=1;
        for(i=1;i<=H;i++)
        {
            for(j=1;j<=W;j++)
            {
                if(i!=1 || j!=1)
                {
                    if(a[i][j]==true)
                        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                }
            }
        }
        cout<<dp[H][W]%mod;
        return 0;
    }

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
        cin >> h[i];
    h.push_back(h[n - 1]);
    long long dp[n]{0};
    dp[0] = 0;
    dp[1] = dp[0] + abs(h[1] - h[0]);
    for(int i = 1; i < n - 1; i++)
        dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]));
    
    cout << dp[n - 1] << '\n';

  
    return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/


int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S;
    cin >> S;

    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
	/* code */
	string str;

	cin >> str;

	int length = str.length();

	for (int i = 0; i < length; ++i)
	{
		str.pop_back();
		/* code */
		if(str.length()%2==0){
			string substr_1 = str.substr(0,str.length()/2);
			string substr_2 = str.substr(str.length()/2,str.length());

			if(substr_1==substr_2){
				cout << str.length() << endl;
				break;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<=5)
    {
        printf("0\n");
    }
    else if(a>=6&&a<=12)
    {
        printf("%d\n",b/2);
    }
    else
    {
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll k = (c-a-b)*(c-a-b);
    if(c > a+b && 4*a*b < k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	ll n,m;
	cin >> n >> m;
	ll a[n],ans = 0;
	REP(i,n){
		cin >> a[i];
		ans += a[i];
	}
	sort(a, a + n);
	P p[m];
	REP(i,m) cin >> p[i].second >> p[i].first;
	sort(p, p + m);
	reverse(p, p + m);
	ll j = 0,k = 0;
	REP(i,n){
		if(p[j].first - a[i] <= 0 || j > m - 1) break;
		ans += p[j].first - a[i];
		k++;
		if(k >= p[j].second){
			k = 0;
			j++;
		}
	}
	cout << ans << endl;
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;
	cout << (c / (a * 7 + b)) * 7 + min((c % (a * 7 + b) + a - 1) / a, 7) << endl;

	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k=0;
    cin>>k>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
     int m=0;
    for(int i=0;i<n-1;i++)
    {   
        int k=abs(arr[i]-arr[i+1]);
         m=max(m,k);
    }
    int j=k-arr[n-1]+arr[0];
    m=max(j,m);
    cout<<k-m;
     
}

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

int main () {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<bool> a(n,1);
  
  for (int i = 0; i < k; i++) {
    int b, c;
    cin >> b;
    for (int j = 0; j < b; j++) {
      cin >> c;
      a[c-1] = 0;
    }
  }
  
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  int count = 0;
  while (q > 0)
  {
    int n;
    cin >> n;
    if(n == 1){
      count++;
      q--;
    }
    if (n == 2)
    {
      int m;
      string c;
      cin >> m >> c;
      if (m == 1)
      {
        if (count % 2 == 0)
        {
          s.insert(0, c);
        }
        else
        {
          s += c;
        }
      }
      if (m == 2)
      {
        if (count % 2 == 0)
        {
          s += c;
        }
        else
        {
          s.insert(0, c);
        }
      }
      q--;
    }
  }
  if (count % 2 == 1)
  {
    reverse(s.begin(), s.end());
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x; --x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 1;
	long long a = 0, b = 0, x, y, i, j;
	rep(m, n)
	{
		cin >> x >> y;
		ans = (ans / (x + y) + (bool)(ans % (x + y))) * (x + y); 

		i = ans / (x + y) * x;
		j = ans / (x + y) * y;
		
		if (i < a || j < b)
		{
			long long t = (a - i) / x + bool((a - i) % x);
			long long h = (b - j) / y + bool((b - j) % y);
			t = max(h, t);
			ans += t * (x + y);
		}
		a = ans / (x + y) * x;
		b = ans / (x + y) * y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256