akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

LL gcd(LL a, LL b) {
  if(a < b) return gcd(b, a);
  LL r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    INIT;
    LL A, B, C, D;
    cin >> A >> B >> C >> D;
    LL ans = B-A;
    LL x = (A%C==0 ? A/C : (A+C)/C); 
    LL y = B/C; 
    ans -= y - x;
    x = (A%D==0 ? A/D : (A+D)/D); 
    y = B/D;
    ans -= y - x;
    LL z = C*D/gcd(C,D);
    x = (A%z==0 ? A/z : (A+z)/z); 
    y = B/z;
    ans += y - x;
    cout << ans;
}

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

char vd[4][4] = {"AC", "WA", "TLE", "RE"};

int main() {
    int n; scanf("%d", &n);
    int cnt[4] = {};
    while (n--) {
        char s[5]; scanf("%s", s);
        for (int i = 0; i < 4; i++) {
            if (strcmp(s, vd[i]) == 0){
                cnt[i]++; break;
            }
        }
    }
    for (int i = 0; i < 4; i++) {
        printf("%s x %d\n", vd[i], cnt[i]);
    }
}

Measured memory_bytes: 1712
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			int n=in.nextInt(),k=in.nextInt(),max=0;
			if(n==0)break;
			
			boolean CA[]=new boolean[n+1];
			int dp[]=new int[n+2];
			for(int i=0;i<k;i++) {
				int p=in.nextInt();
				CA[p]=true;
				if(p!=0)dp[p]=1;
			}
			
			for(int i=1;i<=n;i++) {
				if(dp[i]>0 && dp[i-1]>0) {
					dp[i]+=dp[i-1];
					max=Math.max(max, dp[i]);
				}
			}
			
			if(CA[0]) {
				for(int i=1;i<=n;i++) {
					if(dp[i]==0 && (CA[i-1] || CA[i+1])) {
						int L=dp[i-1],j=i+1,R=0;
						while(true) {
							if(dp[j]==0)break;
							R=dp[j];
							j++;
						}
						dp[i]=L+R+1;
					}
					max=Math.max(max, dp[i]);
				}
			}

			System.out.println(max);
		}
	}

}



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

typedef long long lnt;

lnt sum(string &str, int index, int lasteat, lnt until) {
	if(index == str.length()) {
		if(index-1 == lasteat) return until;
		else return 0;
	}
	lnt res = 0;

	res += sum(str, index+1, lasteat, until);
	res += sum(str, index+1, index, until + stoll(str.substr(lasteat+1, index-lasteat)));

	return res;
}

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

	cout << sum(str, 0, -1, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

const double pi = 3.141592653589793;
vector<double> x(101), y(101);
int n; 

inline double naiseki(const double& x1, const double& y1, const double& x2, const double& y2) {
  return x1 * x2 + y1 * y2;
}

// 角度 theta の方向を最終的に向くとして計算
// theta は radian
double calc(const double& theta) {
  double res = 0.0;
  double dx = cos(theta), dy = sin(theta);
  for (int i = 0; i < n; ++i) {
    res += max(0.0, naiseki(dx, dy, x[i], y[i]));
  }
  return res;
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];

  int step = 7777777;

  double ans = 0.0;

  for (int i = 0; i < step; ++i) {
    double theta = 2.0 * pi * i / step;
    chmax(ans, calc(theta));
  }

  cout << setprecision(15) << ans << '\n';

  return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int n, m;
bool flag[100005];
long long dp[100005];

int main() {
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < m; i++) {
		int x;
		scanf("%d", &x);
		flag[x] = 1;
	}
	
	dp[0] = 1LL;
	
	for (int i = 1; i <= n; i++) {
		if (flag[i]) continue;
		if (i - 2 >= 0) dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
		else dp[i] = dp[i - 1];
	}
	
	printf("%lld\n", dp[n]);
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
  char *line = NULL;
  size_t buffer_size;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int answer[4];
    int guess[4];
    sscanf(line, "%d %d %d %d", answer, answer+1, answer+2, answer+3);
    getline(&line, &buffer_size, stdin);  // Should be always success.
    sscanf(line, "%d %d %d %d", guess, guess+1, guess+2, guess+3);

    int hit = 0;
    for (int i = 0; i < 4; ++i) {
      if (answer[i] == guess[i]) { ++hit; }
    }
    sort(answer, answer+4);
    sort(guess, guess+4);
    int intersection[] = { -1, -1, -1, -1 };
    set_intersection(answer, answer+4, guess, guess+4, intersection);
    int blow = -hit;
    for (int i = 0; i < 4; ++i) {
      if (intersection[i] < 0) { break; }
      ++blow;
    }
    printf("%d %d\n", hit, blow);
  }
  free(line);

  return 0;
}

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

int main() {
	int x, y;
	cin >> x >> y;
	if(y%2==1)
	{
		cout << "No" << endl;
	}
	else
	{
		if(y<2*x)
		{
			cout << "No" << endl;
		}
		else if(y>4*x)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder0822
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string N = Console.ReadLine();
            //long[] NXT = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            int[] nc = new int[N.Length];
            int ans = 0;

            for (var i=0; i<N.Length; i++)
            {
                string s = N[i].ToString();
                nc[i] = int.Parse(s);

                ans += nc[i];
            }

         if(ans % 9 == 0) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }
    }
}


Measured memory_bytes: 33792
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi v = get_n_array(n);
    vi v2;
    copy(all(v), back_inserter(v2));
    sort(all(v2));
    for (int i = 0; i < n; i++) {
        if (v[i] != v2[n-1]) {
            cout << v2[n - 1] << endl;
        }
        else {
            cout << v2[n - 2] << endl;
        }
    }
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll Lucas(ll n, ll m, ll p);
ll mod_pow(ll x, ll n, ll p);
ll comb(ll n, ll m, ll p);
int main()
{
    ll n, a,b, p=1e9+7;
    ll ans;
    cin>>n>>a>>b;
    ans=(mod_pow(2,n,p)-1+p)%p;
    ans=(ans-comb(n,a,p)+p)%p;
    ans=(ans-comb(n,b,p)+p)%p;
    cout<<ans;
    return 0;
}
ll mod_pow(ll x, ll n, ll p)
{
    ll res = 1;
    while(n)
    {
        if(n & 1) res =res * x % p;
        x = x * x % p;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll m, ll p)
{
    if(m > n) return 0;
    ll ret = 1;
    m = min(n - m, m);
    for(int i = 1; i <= m; i ++)
    {
        ll a = (n + i - m) % p;
        ll b = i % p;
        ret = ret * (a * mod_pow(b, p - 2, p) % p) % p;
    }
    return ret;
}

ll Lucas(ll n, ll m, ll p)
{
    if(m == 0) return 1;
    return comb(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string a, b;
    cin >> a >> b;
    if(a.size()>b.size()){
        out("GREATER");
        return 0;
    }
    else if(a.size()<b.size()){
        out("LESS");
        return 0;
    }
    else{
        rep(i,a.size()){
            if(a[i]!=b[i]){
                if(a[i]-'0'>b[i]-'0'){
                    out("GREATER");
                    return 0;
                }
                else{
                    out("LESS");
                    return 0;
                }
            }
        }
    }
    out("EQUAL");
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
	int a;
	int b;
	int x;
	int y;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)break;
	for(x = 0;x < a;x++){
		for(y = 0;y < b;y++){
		printf("#");}
		printf("\n");}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
// olaf_surgut
//        _        __                             _   
//   ___ | | __ _ / _|  ___ _   _ _ __ __ _ _   _| |_ 
//  / _ \| |/ _` | |_  / __| | | | '__/ _` | | | | __|
// | (_) | | (_| |  _| \__ \ |_| | | | (_| | |_| | |_ 
//  \___/|_|\__,_|_|___|___/\__,_|_|  \__, |\__,_|\__|
//                |_____|             |___/           
//
#pragma optimize ("Ofast")
#include <bits/stdc++.h>
#define st  first
#define nd  second
#define ll  long long
#define INF 1000000005LL
using namespace std;

void solve(){
  int n;
  cin >> n;
  vector<ll> a(n);
  long double ans = 1;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  if(*min_element(a.begin(), a.end()) == 0){
    cout << "0\n";
    return;
  }
  for(int i = 0; i < n; i++){
    ans *= a[i];
    if(ans > 1e18L){
      cout << "-1\n";
      return;
    }
  }
  if(ans > 1e18L) cout << "-1\n";
  else{
    cout << fixed << setprecision(0) << ans << '\n';
  }
}

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  int _ = 1;
  // cin >> _;
  while(_--)solve();
}

Measured memory_bytes: 3988
(defparameter data (read-line))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(if (< 21 (apply #'+ (mapcar #'parse-integer (split " " data))))
    (format t "bust")
    (format t "win"))

Measured memory_bytes: 9700
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a, v = inpl()
b, w = inpl()
t = inp()

dif = v - w
if abs(b - a) <= dif * t:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 68308
n,k = map(int,input().split())
arr = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(arr[1] - arr[0])
for i in range(2,n):
    for j in range(1,k+1):
        if i - j < 0: break
        if j == 1: dp[i] = dp[i-j]+abs(arr[i-j] - arr[i])
        else: dp[i] = min(dp[i], dp[i-j]+abs(arr[i-j] - arr[i]))
        
print(dp[-1])

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

using namespace std;
#define int long long int

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 2e15;


signed main(){
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	int n;
	cin>>n;
	int ans=inf;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ans =min(ans,n/i-1+ i-1);
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
map<long long,long long>mp;
int a[3]={2,3,5};
long long A[3],D;
inline long long solve(long long x)
{
	if(mp.find(x)!=mp.end())return mp[x];
	long long ans=0;
	if(x!=0)
	{
		if(1e18/D>=x)ans=D*x;
		else ans=1e18;
		for(int i=0;i<3;i++)
		{
			int ul;long long uf;
			ul=x%a[i],uf=(x-ul)/a[i];
			if(uf<x)ans=min(ans,ul*D+solve(uf)+A[i]);
			ul=a[i]-ul,uf=(x+ul)/a[i];
			if(uf<x)ans=min(ans,ul*D+solve(uf)+A[i]);
		}
	}mp[x]=ans;
	return ans;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int T=read();
    while(T--)
    {
    	mp.clear();
    	long long n;
    	scanf("%lld%lld%lld%lld%lld",&n,&A[0],&A[1],&A[2],&D);
    	printf("%lld\n",solve(n));
    }
    return 0;
}

Measured memory_bytes: 4404
n=int(input())
table=[[0 for i in range(13)]for j in range(4)]

for i in range (n):
    p,f=input().split()
    #picture, figure
    if p=="S":
        p=0
    elif p=="H":
        p=1
    elif p=="C":
        p=2
    elif p=="D":
        p=3
    table[int(p)][int(f)-1]=1

j=0
for i in range (13):
    if table[0][j]==0:
        print("S "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[1][j]==0:
        print("H "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[2][j]==0:
        print("C "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[3][j]==0:
        print("D "+str(j+1))
        j=j+1
    else:
        j=j+1


Measured memory_bytes: 5616
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] a = new int[11];
        a[in.nextInt()]++;
        a[in.nextInt()]++;
        a[in.nextInt()]++;
        if(a[7] == 1 && a[5] == 2) {
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr Int INF = 1e17;
	Int N;
	cin >> N;
	vector<Int> A(N + 1);
	for (int i = 0; i < N + 1; ++i) { cin >> A[i]; }

	if (N == 0) {
		cout << (A[0] == 1 ? 1 : -1) << endl;
		return 0;
	}
	if (N > 0 && A[0] > 0) {
		cout << "-1\n";
		return 0;
	}

	Int x = 1;
	for (int i = 1; i <= N; ++i) {
		x = min(INF, x * 2);
		if (x < A[i]) {
			cout << "-1\n";
			return 0;
		}
		x -= A[i];
	}

	vector<Int> sum(N + 2, 0);
	sum[N] = A[N];
	for (int i = N - 1; i >= 0; --i) { sum[i] = sum[i + 1] + A[i]; }

	vector<Int> v(N + 1, 0);
	v[0] = 1;
	x = 1;
	for (int i = 1; i <= N; ++i) {
		x = min(INF, x * 2);
		v[i] = min(x, A[i] + sum[i + 1]);
		x = v[i] - A[i];
	}

	Int ans = 0;
	for (int i = 0; i <= N; ++i) { ans += v[i]; }
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5636
from sys import setrecursionlimit
from functools import lru_cache

setrecursionlimit(999999)
@lru_cache(maxsize=None)
def calc(n):
    if n <= 1:
        return 1
    elif n == 2:
        return 2
    return calc(n - 1) + calc(n - 2)


K = 10 ** 9 + 7

n, m = map(int, input().split())
broken = []
no_reachable = False
for _ in range(m):
    a = int(input())
    if len(broken) and a == broken[-1] + 1:
        no_reachable = True
        break
    broken.append(a)

if not no_reachable:
    a = 0
    cb = 1
    for b in broken:
        stairs = b - a - 1
        cb *= calc(stairs)
        a = b + 1
    cb *= calc(n - a)
    print(cb % K)
else:
    print(0)


Measured memory_bytes: 647260
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>

#define REP(i, n) for(int i=0;i<n;i++)
#define ll long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

int par[250], rank_n[250];

void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    rank_n[i] = 0;
  }
}

int find_n(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find_n(par[x]);
  }
}

void unite(int x, int y){
  x = find_n(x);
  y = find_n(y);

  if(x == y)
    return;

  if(rank_n[x] > rank_n[y]){
    par[y] = x;
  }else{
    par[x] = y;
    if(rank_n[x] == rank_n[y])
      rank_n[y]++;
  }

}

int same(int x, int y){
  return find_n(x) == find_n(y);
}

int main(){

  int n, m;
  vector<int> a, b;
  
  scanf("%d %d", &n, &m);
  REP(i, m){
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    a.pb(t1 - 1); b.pb(t2 - 1);
  }

  int res = 0;
  REP(i, m){
    init(n);
    REP(j, m){
      if(i == j) continue;
      unite(a[j], b[j]);
    }
    REP(j, n){
      if(!same(0, j)){
        res++;
        break;
      }
    }
  }

      
  printf("%d\n", res);
  return 0;
}



Measured memory_bytes: 384
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main{


	public static void main(String[] args){

    	Scanner scan = new Scanner(System.in);

			while(true){
				try{
            int H=scan.nextInt();
			int W=scan.nextInt();
			if(H==0&&W==0)break;

			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i%2==0&&j%2==0){System.out.print('#');}
					else if(i%2==0&&j%2==1){System.out.print('.');}
					else if(i%2==1&&j%2==0){System.out.print('.');}
					else if(i%2==1&&j%2==1){System.out.print('#');}

				}System.out.print('\n');
			  }System.out.print('\n');

				}catch(InputMismatchException e){
					System.out.println("??¨??????:"+e);

				}

			}
        	scan.close();


	}

}

Measured memory_bytes: 39736
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

llint a, b, p, q, r;

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> a >> b >> p >> q >> r;
	double ub = 1e9, lb = b, mid;
	for(int i = 0; i < 100; i++){
		mid = (ub+lb)/2;
		if(q*(mid-a) >= p*b-(mid-b)*r) ub = mid;
		else lb = mid;
	}
	printf("%.11f\n", lb);
	
	return 0;
}


Measured memory_bytes: 3216
h, w = map(int, input().split())
s = ["."+input()+"." for _ in range(h)]
s = ["."*(w+2)]+s+["."*(w+2)]
flag = False

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
                flag = True

if flag:
    print('No')
else:
    print('Yes')


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

int main() {

    int n, l, r;
    scanf("%d", &n);
    int mysum = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &l, &r);
        mysum += r - l + 1;

    }
    printf("%d", mysum);


    return 0;

}

Measured memory_bytes: 128
kigou = ['S', 'H', 'C', 'D']

cards = []

for i in kigou:
    for j in range(1,14):
        cards.append([i, j])

n = int(input())

for i in range(n):
    card = input().split()
    card[1] = int(card[1])
    cards.remove(card)

for i in cards:
    print(' '.join(map(str, i)))


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
using namespace std;
int A, B, C, D;
int main() {
	cin >> A >> B >> C >> D;
	int cnt1 = 0, cnt2 = 0;
	for(int i = 0; i < A; i++) {
		for(int j = 0; j < B; j++) {
			cnt1++;
		}
	}
	for(int i = 0; i < C; i++) {
		for(int j = 0; j < D; j++) {
			cnt2++;
		}
	}
	cout << max(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;
    int l = s.length();
    if (l <= k) {
        cout << s;
    }
    else {
        cout << s.substr(0,k);
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
int vis1[200005],vis2[200005],h[200005],dis[200005],vis[200005],cur[200005],occ1,occ2,a[200005],b[200005],S,T,cnt=1,n,inf=1e9,ans;
struct l1{
	int to,next,v;
}p[400005];
void add(int x,int y,int v){
//	cout<<x<<' '<<y<<' '<<v<<endl;
	cnt++;
	p[cnt].to=y;
	p[cnt].next=h[x];
	h[x]=cnt;
	p[cnt].v=v;
}
void dfs1(int x){
	if(vis1[x]) return;
	vis1[x]=occ1;
	dfs1(a[x]);
}
void dfs2(int x){
	if(vis2[x]) return;
	vis2[x]=occ2;
	dfs2(b[x]);
}
int bfs(){
	queue<int>q;
	for(int i=1;i<=T;i++) dis[i]=-1;
	dis[S]=0;
	q.push(S);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		if(x==T) return 1;
		for(int i=h[x];i;i=p[i].next){
			int y=p[i].to;
//			cout<<x<<' '<<y<<' '<<p[i].v<<' '<<i<<endl;
			if(p[i].v&&dis[y]==-1){
				dis[y]=dis[x]+1;
				q.push(y);
			}
		}
	}
	return 0;
}
int dfs(int x,int maxf){
	int ret=0,dlt=0;
	if(x==T||!maxf) return maxf;
	vis[x]=1;
	for(int &i=cur[x];i;i=p[i].next){
		int y=p[i].to;
//		cout<<x<<' '<<y<<' '<<dis[y]<<' '<<dis[x]<<' '<<
		if(!vis[y]&&p[i].v&&dis[y]==dis[x]+1){
			dlt=dfs(y,min(maxf,p[i].v));
//			cout<<x<<' '<<y<<' '<<dlt<<endl;
			ret+=dlt,maxf-=dlt;
			p[i].v-=dlt;p[i^1].v+=dlt;
			if(!maxf){
				vis[x]=0;
				return ret;
			}
		}
	}
	vis[x]=0;
	return ret;
}
void solve(){
	while(bfs()){
		memcpy(cur,h,sizeof(cur));
		memset(vis,0,sizeof(vis));
		ans+=dfs(S,inf);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		b[i]++;
	}
	for(int i=1;i<=n;i++){
		if(!vis1[i]){
			occ1++;
			dfs1(i);
		}
//		cout<<vis1[i]<<' ';
	}
//	cout<<endl;
	for(int i=1;i<=n;i++){
		if(!vis2[i]){
			occ2++;
			dfs2(i);
		}
//		cout<<vis2[i]<<' ';
	}
//	cout<<endl;
	S=occ1+occ2+1;T=S+1;
	for(int i=1;i<=n;i++){
		if(a[i]==i&&b[i]==i) ans++;
		if(a[i]!=i&&b[i]==i){
			add(S,vis1[i],1);
			add(vis1[i],S,0);
		}
		if(a[i]==i&&b[i]!=i){
			add(vis2[i]+occ1,T,1);
			add(T,vis2[i]+occ1,0);
		}
		if(a[i]!=i&&b[i]!=i&&a[i]!=b[i]){
			add(vis2[i]+occ1,vis1[i],1);
			add(vis1[i],vis2[i]+occ1,0);
		}
		if(a[i]!=i&&b[i]!=i&&a[i]==b[i]){
			add(vis2[i]+occ1,vis1[i],1);
			add(vis1[i],vis2[i]+occ1,1);
		}
	}
	solve();
	printf("%d",n-ans);
}

Measured memory_bytes: 13864
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		
		String word = null;
		String prevWord = null;
		Set<String> wordSet = new HashSet<>();
		boolean failed = false;
		while (sc.hasNextLine()) {
			word = sc.nextLine();
			if (!wordSet.add(word)) {
				failed = true;
				break;
			}
			if (prevWord != null) {
				boolean chained = (prevWord.charAt(prevWord.length() - 1) == word.charAt(0));
				if (!chained) {
					failed = true;
					break;
				}
			}
			prevWord = word;
		}
		System.out.println(failed ? "No" : "Yes");
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long int k;
    vector<long long int> array;
    cin >> k;
    if(k == 0){
        cout << "2" << endl;
        cout << "0 0" << endl;
    }else{
        for(int i = 0;i < 50;i++){
            array.push_back(i);
        }
        for(int i = 0;i < 50;i++){
            array[i] += (i + k) / 50;
        }
        cout << "50" << endl;
        for(int i = 0;i < 50;i++){
            cout << array[i];
            if(i != 49){
                cout << " ";
            }
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int h1 = scan!int, m1 = scan!int, h2 = scan!int, m2 = scan!int, k = scan!int;
    int x1 = h1 * 60 + m1, x2 = h2 * 60 + m2;
    int ans = x2 - k - x1;
    ans.writeln;
}



Measured memory_bytes: 3320
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_sort = sorted(a)
a_max = a_sort[-1]
multiple_max = a_sort[-1] == a_sort[-2]
if not multiple_max:
    a_second = a_sort[-2]

for item in a:
    if item == a_max and not multiple_max:
        print(a_second)
    else:
        print(a_max)

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

#define ll long long int
#define llu unsigned long long int
#define MOD 1000000007
#define N 100001
using namespace std;
vector<vector<int>> dp(N,vector<int>(2,-1));
int fun(vector<int> v,int k,int c){
	if(k<0)
	return c;
	if(dp[k][c]==-1){
		dp[k][c]=c==1?0:1;
	for(int i=0;i<v.size();i++)
		if(fun(v,k-v[i],dp[k][c])==c){
			dp[k][c]=c;
			break;
		}
	}
return dp[k][c];

}

int main(){
int n,k;
cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++)
cin>>v[i];
if(fun(v,k,1)==1)
cout<<"First";
else cout<<"Second";
return 0;
}

Measured memory_bytes: 58880
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e3 + 5);
const int LOG = (int)(20);

struct node {
	int x, y, stp;
};

int n, m, k, stx, sty, w[4][2] = {1, 0, -1, 0, 0, -1, 0, 1}, ans = INT_MAX, mark[N][N];
char ar[N][N];
queue<node> q;

void bfs() {
	q.push({stx, sty, 0});
	while(!q.empty()) {
		node t = q.front();
		q.pop();
		if(mark[t.x][t.y])
			continue;
		mark[t.x][t.y] = 1;
		if(t.stp == k)
			continue;
		for(int i = 0; i < 4; i++) {
			int nx = t.x + w[i][0], ny = t.y + w[i][1];
			if(nx > 0 && ny > 0 && nx <= n && ny <= m && ar[nx][ny] != '#' && mark[nx][ny] == 0)
				q.push({nx, ny, t.stp + 1});
		}
	}
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++)
		cin >> ar[i] + 1;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(ar[i][j] == 'S')
				stx = i, sty = j;

	bfs();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(mark[i][j] == 1) {
				double t1 = abs(n - i), t2 = abs(i - 1), t3 = abs(m - j), t4 = abs(j - 1);
				ans = min(ans, (int)ceil(min(min(t1, t2), min(t3, t4)) / k));
			}
	cout << ans + 1;
}

Measured memory_bytes: 4224
/* Madar Bozorg migoft : "dorost mishavad"
va hamishe badash b aseman negah mikard o mikhandid
hatm daram k chiz haii ""DARBARE KHODA"" midanest
k ma az an bi khabar budim :) */
//RTn_E
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
#define piii pair < int , pair < int , int > >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 100;
const ll inf = 1e18;

//Main CODE :/\

vector < int > inv(2e5);
int main() {
    ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        p--;
        inv[p] = i;
    }
    int maxv = 0;
    int tmp = 0;
    for (int i = 1; i < n; i++){
        if (inv[i - 1] < inv[i])
            tmp++;
        else {
          maxv = max(maxv, tmp);
          tmp = 0;
        }
    }
    maxv = max(maxv, tmp);
    int ans = n - maxv - 1;
    cout << ans << "\n";
    return 0;
}
//The_End
//Game Over :D


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a[]={1,4,7,9};
    vi b(4);
    rep(i,4)cin>>b[i];
    sort(all(b));
    bool f=true;
    rep(i,4)f&=a[i]==b[i];
    YES(f);
}

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

int main() {
	int h, w;
	string s[100];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < h; i++) {
		cout << s[i] << endl << s[i] << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(input())
        for j in range(m):
            x, y = map(int, input().split())
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h = set()
        u = set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        b = True
        for k in list(h):
            k -= 1
            h |= A[k][1]
            u |= A[k][0]
            if h & u:
                b = False
        if b:
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,c;
	cin >> n >> c;
	vector<pair<int,int>> vpi[c+10];
	vector<vector<int>> tv(c+20,vector<int>(100010,0));
	rep(i,n){
		int s,t,cc;
		cin >> s >> t >> cc;
		vpi[cc].push_back({s,t});
	}
	rep(i,c+10){
		sort(vpi[i].begin(),vpi[i].end());
	}
	rep(cc,c+10){
		for(auto u : vpi[cc]){
			int s = u.first, t = u.second;
			if(tv[cc][s]==-1) tv[cc][s] = 0;
			else tv[cc][s] = 1;
     		tv[cc][t] = -1;
		}
	}
	int ans = 0;
	int now = 0;
	rep(i,100010){ 
		rep(j,c+10){
			if(tv[j][i]==1) now++; 
		}
		ans = max(ans,now);
		rep(j,c+10){
			if(tv[j][i]==-1) now--; 
		}
	}
	cout << ans << endl;
	return 0;
}


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

def pcheck(n):
    if n == 1:
        return False
    else:
        root = int(n ** 0.5)
        for i in range(2, root + 1):
            if n % i == 0:
                return False
        return True

if n == 1:
    print('0')
elif n == 6:
    print('2')
elif pcheck(n) == True:
    print('1')
else:
    rootn = int(n ** 0.5)
    k = 0
    for i in range(2, rootn + 2):
        if n == 1:
            print(k)
            break
        elif n % i == 0:
            j = 1
            p = i
            while n % p == 0:
                k += 1
                n //= p
                j += 1
                p = i ** j
            p //= i
            while n % i == 0:
                if n % p != 0:
                    p //= i
                    continue
                n //= p
    else:
        if pcheck(n) == True:
            k += 1
            print(k)
        else:
            print('1')
    

Measured memory_bytes: 63940
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	result := n / 2
	extra := n % 2

	fmt.Fprint(out, result+extra)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

namespace BasicMath {
    static Int Min(const Int a, const Int b);
    // 二つの値の最小値を求める関数
    Int Min(const Int a, const Int b) {
        if (a <= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

int main(void) {
    string s, t, u;
    cin >> s;
    t = ""; u = "";
    Int len = (Int)s.length();
    for (Int i = 0; i < len; ++i) {
        if (i % 2 == 0) {
            t += '0';
            u += '1';
        } else {
            t += '1';
            u += '0';
        }
    }
    Int difft = 0;
    Int diffu = 0;
    for (Int i = 0; i < len; ++i) {
        if (s[i] != t[i]) {
            difft++;
        }
        if (s[i] != u[i]) {
            diffu++;
        }
    }
    cout << Min(difft, diffu) << endl;
    return 0;
}



Measured memory_bytes: 3964
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const ll MAX_N=1e5;
ll N,Q,A[MAX_N*2],B[MAX_N*2],c[MAX_N*2];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>Q;
	REP(i,N*2)cin>>A[i];
	REP(i,N*2)cin>>B[i];
	REP(i,N*2)c[i]=A[i]-B[i];
	ll bsm,mx;
	bsm=mx=0;
	multiset<ll> st[2];
	REP(i,N*2-2){
		int inx;
		if(c[i+1]>=0){
			inx=0;
			mx+=c[i+1];
		}else{
			inx=1;
		}
		st[inx].insert(c[i+1]);
	}
	REP(i,N*2)bsm+=B[i];
	REP(q,Q){
		ll p,x,y;
		cin>>p>>x>>y;
		p--;
		bsm-=B[p];
		int inx;
		multiset<ll>::iterator ite;
		if(0<p && p<N*2-1){
			if(c[p]>=0){
				inx=0;
				mx-=c[p];
			}else{
				inx=1;
			}
			ite=st[inx].find(c[p]);
			st[inx].erase(ite);
		}
		A[p]=x;
		B[p]=y;
		c[p]=x-y;
		bsm+=y;
		if(0<p && p<N*2-1){
			if(c[p]>=0){
				inx=0;
				mx+=c[p];
			}else{
				inx=1;
			}
			st[inx].insert(c[p]);
		}
		ll ans;
		if(st[0].size()%2==0){
			ans=mx;
		}else{
			ite=st[0].begin();
			ans=mx-*ite;
			ite=st[1].end();
			ite--;
			ans=max(ans,mx+*ite);
		}
		cout<<ans+bsm+c[0]+c[N*2-1]<<endl;
	}
}

Measured memory_bytes: 15744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = Math.abs(scanner.nextInt());
		int t = 0;
		long sum = 0;
		while(true){
			sum += t;
			if(sum >= x){
				System.out.println(t);
				break;
			}
			t++;
		}

	}

}


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

int main(void){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    if(S[A]!='-'){
        cout << "No" << endl;
        return(0);
    }

    for(int i{0}; i<A; ++i){
        if(S[i]-'0'<0 or S[i]-'0'>9){
            cout << "No" << endl;
            return(0);
        }
    }

    for(int i{A+1}; i<A+B; ++i){
        if(S[i]-'0'<0 or S[i]-'0'>9){
            cout << "No" << endl;
            return(0);
        }
    }

    cout << "Yes" << endl;
    return(0);
}


Measured memory_bytes: 256
N = int(input())

L = list(map(int,input().split()))
count = 0 
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                a = max(L[i],L[j],L[k])
                if a < L[i]+L[j]+L[k]-a:
                    count+=1
print(count)

Measured memory_bytes: 73968
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]

def solve():
    while 1:
        try:
            n, a, b = LI()
            if abs(a - b) % 2:
                print("Borys")
            else:
                print("Alice")

            break
        except:
            break
solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  map<int,int> m;
  for(int i=0;i<n;i++) m[a[i]]++;
  int x=0,y=0;
  for(auto p:m){
    if(p.second<2) continue;
    if(p.first>x){
      y=max(y,x);
      x=p.first;
      p.second-=2;
    }
    if(p.second<2) continue;
    if(p.first>y){
      x=max(x,y);
      y=p.first;
      p.second-=2;
    }
  }
  //cout<<x<<" "<<y<<endl;
  cout<<x*y<<endl;
  return 0;
}


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

#define pb push_back
#define ll long long
#define MAXN 100005

using namespace std;

const int mod = 1e9 + 7;

vector<int> graph[MAXN], g[MAXN];
int dp[MAXN];
bool visited[MAXN];

int add(int a, int b) {

    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

int mul(int a, int b) {

    ll x = (ll)a * (ll)b;
    x %= mod;
    return (int)x;
}

void dfs(int u) {

    visited[u] = true;
    for(int v: g[u]) {
        if(!visited[v]) {
            graph[u].pb(v);
            dfs(v);
        }
    }
}

int sol(int u) {

    if(dp[u])
        return dp[u];
    
    int ans1 = 1, ans2 = 1;
    for(int v: graph[u]) {
        ans1 = mul(ans1, sol(v));

        for(int p: graph[v])
            ans2 = mul(ans2, sol(p));
    }

    return (dp[u] = add(ans1, ans2));
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;

        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0);

    cout << sol(0) << endl;
    return 0;
}


Measured memory_bytes: 21932
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc83_c
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] input = ReadLine().Split().Select(long.Parse).ToArray();
            long x = input[0];
            long y = input[1];
            int count=1;
            while(x * 2 <= y){
                count++;
                x *= 2;
            }
            WriteLine(count);
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0];
}


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

using namespace std;
int n,p[12345],a;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	sort(p,p+n);
	
	for(int i=0;i<n-1;i++){
		a+=p[i];
	}
	a+=p[n-1]/2;
	cout<<a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<tuple>
#include<stack>
using namespace std;
vector<tuple<int,int,int>> v[100001];
int dis[100001];
bool check[100001]={},ans=true;

bool dfs(int z){
	stack<tuple<int,int,int>> s;
	for(int i=0;i<v[z].size();i++) s.push(v[z][i]);
	while(!s.empty()){
		int x=get<0>(s.top());
		int y=get<1>(s.top());
		int d=get<2>(s.top());
		s.pop();
		check[x]=1;
		if(check[y]){
			if(dis[y]!=dis[x]+d) return false;
			continue;
		}
		dis[y]=dis[x]+d;
		for(int i=0;i<v[y].size();i++) s.push(v[y][i]);
	}
	return true;
}

int main(){
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		v[l].push_back(make_tuple(l,r,d));
		v[r].push_back(make_tuple(r,l,-d));
	}
	for(int i=1;i<=n;i++){
		if(!check[i]) {
			ans=dfs(i);
			if(!ans) break;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}

int main(){
    int a,b;
    cin >> a >> b;
    //doubelにする強引な方法
    // int x = ((double)a+(double)b)/2.0 + 0.999999999;

    //組み込み関数ceilを使う方法
    // int x = ceil(((double)a+(double)b)/2);

    //
    int x = a+b;
    if(x%2!=0) x = (x+1)/2;
    else x /= 2 ;

    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a[20] = {0};
	while(scanf("%d",&a[0]) != EOF){
        int sum = a[0];
        for(int i = 1; i < 10; i++){
            scanf(",%d",&a[i]);
            sum += a[i];
        }
        int v1,v2;
        scanf(",%d,%d",&v1,&v2);
        double ans;
        ans = (double)(v1*sum)/(v1+v2);
        int x;
        sum = 0;
        for(int i = 0; i < 10; i++){
            sum += a[i];
            if(sum > ans){
                x = i + 1;
                break;
            }
            else if(sum == ans){
                x = i + 1;
                break;
            }

        }
        cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();
    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let mut A = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();
    let mut ans = 0;
    for i in 1..N{
        if A[i-1]==A[i] {
            ans+=1;
            A[i] = 0;
        }
    }

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

Measured memory_bytes: 4352
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
t = S()
ret = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ret += 1

print(ret)

Measured memory_bytes: 78388