akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

/**
 * ABC118A
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0) {
            System.out.println(A + B);
        } else {
            System.out.println(B - A);
        }

        sc.close();
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, aa;
	cin >> nn >> aa;
	nn %= 500;
	if(nn <= aa)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
from bisect import bisect_left, bisect_right

N = int(input())

color = []
color.append(int(input()))

for i in range(N-1):
  A = int(input())
  
  if color[-1] >= A:
    color.append(A)

  else:
    color.reverse()
    l = bisect_left(color,A)
    color[l-1] = A
    color.reverse()


print(len(color))

Measured memory_bytes: 49880
#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include<iostream>

using namespace std;

string s;
int main()
{
    //  10 30 40 50 20

    int n,k;
    scanf("%d %d", &n,&k);
    int dp[n];
    for(int i=0;i<n;i++)scanf("%d", &dp[i]);

    int a[n] = {};
    a[0]= 0;
    a[1] = abs(dp[0]- dp[1]);

    for(int i=2;i<n;i++){
            a[i] = INT_MAX;
        for(int j = i-1;j>=i-k && j>=0;j--){
                a[i] = min(a[i], abs(dp[i]- dp[j]) + a[j]);
        }
    }

    cout<< a[n-1];

   return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
      var str = Console.ReadLine();
      var ans3 = "";
      for (int i = 0; i < str.Length; i++)
      {
        if ((i + 1) % 2 != 0)
          ans3 += str[i];
      }
      Console.WriteLine(ans3);
	}
}

Measured memory_bytes: 34772
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,ans=1;
    cin >> n;
    string s;
    cin >> s;
    for (ll i=1;i<n;i++){
        if (s[i-1]!=s[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
    void BubbleUp(std::size_t Index)
    {
        assert(FArray.size() > Index);
        if(Index == 1) return;
        int Parent = Index / 2;
        if(FArray[Index] <= FArray[Parent]){
            return;
        }
        std::swap(FArray[Index], FArray[Parent]);
        BubbleUp(Parent);
    }
    void BubbleDown(std::size_t Index)
    {
        assert(FArray.size() > Index);
        std::size_t Size = FArray.size();
        std::size_t Left, Right;
        while(Index < Size){
            Left = Index * 2;
            Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();
        if(FArray.size() == 1) return; // dummy???????????????
        BubbleDown(1);
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6240
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    ll A[N+1];
    ll S[N+1];
    S[0] = 0;
    ll len = 0;
    for(int i = 1; i < N + 1; i++){
        cin >> A[i];
        len += A[i];
        S[i] = S[i-1] + A[i];
    }
    ll mn_dif = len;
    if(len % 2 == 0){
        for(int i = 1; i < N + 1; i++){
            ll sub = abs(S[i] - (len/2));
            mn_dif = min(mn_dif, sub);
        }
        cout << mn_dif * 2 << endl;
    }else{
        for(int i = 1; i < N + 1; i++){
            double sub = abs(S[i] - (double)len / 2);
            mn_dif = min((double)mn_dif, sub);
        }
        cout << (ll)mn_dif * 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
q, h, s, d = gets.chomp.split(" ").map(&:to_i)
n = gets.to_i
result = 0
q1, h1, s1 = q*4, h*2, s
cospa1 = [q1, h1, s1].min
q, h, s, d = q*8, h*4, s*2, d
cospa = [q, h, s, d].min
if n%2 == 1
	result += cospa1
	n -=1
end

result += cospa*(n/2)

puts result


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0023
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= int.Parse( Console.ReadLine() );
			for( int i = 0; i < n; i++ ) {
				var	c	= Array.ConvertAll( Console.ReadLine().Split(), cc => double.Parse( cc ) );
				var	x	= c[ 0 ] - c[ 3 ];
				var	y	= c[ 1 ] - c[ 4 ];
				var	ra	= c[ 2 ];
				var	rb	= c[ 5 ];
				var	d	= Math.Sqrt( x * x + y * y );
				if( d > ra + rb ) {
					Console.WriteLine( "0" );
				} else if( d + rb < ra ) {
					Console.WriteLine( "2" );
				} else if( d + ra < rb ) {
					Console.WriteLine( "-2" );
				} else {
					Console.WriteLine( "1" );
				}
			}
		}
	}
}

Measured memory_bytes: 5652
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  lxyz = [[0]*3 for _ in range(n)]
  for i in range(n):
    lxyz[i] = list(map(int, input().split()))
  
  def binary(x, k, t=1, f=0):
    return [t if (x >> ik)%2 else f for ik in range(k)]
  
  ans = -1
  for lh in [binary(i, 3, f=-1) for i in range(8)]:
    ans = max(ans, abs(sum(sorted([sum(map(lambda x: x[0]*x[1], zip(lh, lxyz[i]))) for i in range(n)], reverse=True)[:m]))) 
  print(ans)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 3316
#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, K;
  cin >> N >> K;
  vector<int> x(N);
  rep(i,N) cin >> x[i];
  int ans=0;
  rep(i,N) ans+=min(x[i],abs(K-x[i]));
  cout << ans*2 << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; j++) {
      sum++;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>

long long dp[200001][2][3];

int main()
{
	int n;
	scanf("%d", &n);
	int a[200000];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", a + i);
	}
	dp[1][0][0] = -1e18;
	dp[1][0][1] = 0;
	dp[1][0][2] = -1e18;

	dp[1][1][0] = a[0];
	dp[1][1][1] = -1e18;
	dp[1][1][2] = -1e18;

	for (int i = 2; i <= n; ++i)
	{
		dp[i][0][0] = dp[i - 1][1][0];
		dp[i][0][1] = std::max(dp[i - 1][1][1], dp[i - 1][0][0]);
		dp[i][0][2] = std::max(dp[i - 1][1][2], dp[i - 1][0][1]);

		dp[i][1][0] = std::max(a[i - 1] + dp[i - 1][0][0], (long long)-1e18);
		dp[i][1][1] = std::max(a[i - 1] + dp[i - 1][0][1], (long long)-1e18);
		dp[i][1][2] = std::max(a[i - 1] + dp[i - 1][0][2], (long long)-1e18);
	}
	long long ans = -1e18;
	if (n % 2 == 0)
	{
		ans = std::max(dp[n][0][0], dp[n][1][1]);
	}
	else
	{
		ans = std::max(dp[n][0][1], dp[n][1][2]);
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {

    int N, K;
    string S;

    cin >> N >> K >> S;
    
    if (S[K-1] == 'A')
    {
        S[K - 1] = 'a';
    } 
    else if (S[K-1] == 'B')
    {
        S[K-1] = 'b';
    } 
    else
    {
        S[K - 1] = 'c';
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const int inf = 3000;
int main(){
  string s;
  string t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,inf)); 

  for(int i = 1;i <= s.size();i++)dp[i][0] = i;
  for(int i = 1;i <= t.size();i++)dp[0][i] = i;

  dp[0][0] = 0;
  for(int i = 0;i < s.size();i++){
    for(int j = 0;j < t.size();j++){
      if(s[i] == t[j])dp[i+1][j+1] = dp[i][j];
      else dp[i+1][j+1] = min({dp[i][j+1],dp[i][j],dp[i+1][j]})+1;  
    }
  }

  cout << dp[s.size()][t.size()] << endl; 
}


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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}


ll a[1010101];

int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	ll mi=2,mx=2;
	for(int i=n;i>=1;i--){
		if(mi%a[i]!=0) mi=mi/a[i]*a[i]+a[i];
		mx=(mx/a[i]+1)*a[i]-1;
	} 
	if(mx>=mi){
		printf("%lld %lld",mi,mx);
	}
	else printf("-1");
	return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N,M; cin>>N>>M;
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == s[i + 1]
			&& s[i] == s[i + 2]
			&& s[i + 1] == s[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0;
  rep(i,(s.size()/2)){
    if(s[i]!=s[s.size() - 1 - i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<algorithm>

using namespace std;

int a[200200];
int N;

int rev_a[200200];

long long solve(){
	for(int i = 1; i <= N; ++i){
		rev_a[a[i]] = i;
	}
	long long ans = 0;
	set<int> se;
	se.insert(0);
	se.insert(N + 1);
	for(int i = 1; i <= N; ++i){
		se.insert(rev_a[i]);
		set<int>::iterator it = se.find(rev_a[i]);
		it++;
		int nxt = *it;
		it--;
		it--;
		int prv = *it;
		long long d1 = nxt - rev_a[i];
		long long d2 = rev_a[i] - prv;
		ans += d1 * d2 * i;
	}
	return ans;
}

void input(){
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i){
		scanf("%d", a + i);
	}
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


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

struct Pair
{
    int pos;
    int dis;
};

int main() {
    int n, m;
    while(cin >> n >> m && n != 0)
    {
        int last_p = 0;
        Pair set[n];
        for(int i = 0;i<n;i++)
            cin >> set[i].dis >> set[i].pos;
        for(int i = 0; i< n; i++)
            for(int j = i+1; j < n; j++)
            {
                if(set[i].pos < set[j].pos)
                {
                    Pair rem = set[i];
                    set[i] = set[j];
                    set[j] = rem;
                }
            }
        
        for(int i = 0; i<n;i++)
        {
            if(m >= set[i].dis)
                m -= set[i].dis;
            else if(m < set[i].dis)
            {
                set[i].dis -= m;
                m = 0;
                last_p += set[i].dis * set[i].pos;
            }
        }
        cout << last_p << endl;
    }
        
    return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));
long long n,k;
cin>>n>>k;
vector<long long> h;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    h.emplace_back(x);
}
sort(h.begin(),h.end());
//ikarai+k-1   n-k; kara n-1
long long ans=h[n-1]-h[0];
for(long long i=0;i<=n-k;i++){
    ans=min(ans,h[i+k-1]-h[i]);
}

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

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20,M=61;
ll pw[80],a[N],b[N],c[N],d[N];
ll x[N];
void init()
{
    pw[0]=1;
    x[0]=1;
    for(int i=1;i<=M+1;i++)
        pw[i]=pw[i-1]*2ll,x[i]=x[i-1]*2+1ll;
}
int main()
{
    int n,cas=0;
    init();
        ll ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%lld",&a[i]);
        for(int i=1;i<=n;i++)
            scanf("%lld",&b[i]);
        for(int k=0;k<=M;k++)
        {
            for(int i=1;i<=n;i++)
            {
                c[i]=x[k]&a[i];
                d[i]=x[k]&b[i];
            }
            sort(c+1,c+1+n);
            sort(d+1,d+1+n);
            int le=n,rg=n;
            int st=n,ed=n;
            int num=0;
            for(int i=1;i<=n;i++)
            {
                while(le>=1&&d[le]+c[i]>=pw[k])
                    le--;
                while(rg>=1&&d[rg]+c[i]>=pw[k+1])
                    rg--;
                while(st>=1&&d[st]+c[i]>=pw[k]+pw[k+1])
                    st--;
                while(ed>=1&&d[ed]+c[i]>=pw[k+2])
                    ed--;
                num+=rg-le;
                if(ed>=1)
                num+=ed-st;
            }
            if(num%2)
                ans+=pw[k];
        }
        printf("%lld\n",ans);
    return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  vector<int> v(n,0);
  vector<int> mask(n,0);
  rep(i,n){
    int a;
    cin >> a;
    rep(j,a){
      int x,y;
      cin >> x >> y;
      x --;
      v[i] |= (y << x);
      mask[i] |= (1 << x);
    }
  }
  int ans = 0;
  rep(i,(1 << n)){
    int bits = 0;
    rep(j,n){
      bool bit = (i >> j)&1;
      bits += bit;
      if(bit){
        int check = i^v[j];
        check &= mask[j];
        if(check > 0){
          bits = 0;
          break;
        }
      }
    }//j
    ans = max(ans,bits);
  }//i
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

int main() {
    cin>>A>>B;
    ll x, y;
    ll d = extgcd(max(A,B), min(A,B), x, y);
    ll ans = 1, D = d;
    for(ll i = 2; i*i <= D; ++i){
        if(d%i == 0){
            ++ans;
            while(d%i == 0) d /= i;
        }
        if(d == 1) break;
    }
    ans += d != 1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
List = list(map(int,input().split()))
Q = int(input())

arr = [0 for i in range(10**5+1)]
S = 0

for i in range(N):
  a = List[i]
  arr[a] += 1
  S += int(a)
  
for i in range(Q):
  a,b = map(int,input().split())
  aa = arr[a]
  arr[b] += aa
  arr[a] = 0
  S += int ( (b-a) * aa )
  print(int(S))

Measured memory_bytes: 83672
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;


int main()
{
    SRK;
    int d,t,s;
    cin >> d >> t >> s;
    ll ans = t * s;
    if (ans >= d)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }


}


Measured memory_bytes: 3648
#include <iostream>
#include<string>
#include <algorithm>
#include <math.h>
using namespace std;
 
int main() {
  long int N, X, M, a[100002]={}, ans = 0, ak, anss[100002]={}, ansnum[100002]={};
  cin >> N >> X >> M;
  for(long int i = 0; i<M; i++){
    a[i] = i*i%M;
  }
  ak = X;
  for(long int j = 0; j<N; j++){
    ans += ak;
    if(anss[ak]==0){
      anss[ak]= ans;
      ansnum[ak] = j;
    }
    else{
      long int num = (N-j-1)/(j-ansnum[ak]);
      ans += num*(ans-anss[ak]);
      j+=num*(j-ansnum[ak]);
    }
    ak = a[ak];
    if(ak == 0)break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5972
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	if (s.find("AC") != string::npos)
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    while(scanf("%d", &n) != EOF){
        int cnt=0;
        int a, b, c, d;
        for (a=9;a>=0;a--)
            for (b=9;b>=0;b--)
                for (c=9;c>=0;c--)
                    for (d=9;d>=0;d--)
                        if (a+b+c+d == n)
                            cnt++;
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 596
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cerr << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cerr << e << " "; } cerr << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************

int main() {

    int N;
    cin >> N;
    vector<double> P(N);
    for (auto& p : P) {
        cin >> p;
    }

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[0][0] = 1;

    REP(i, N) REP(j, i + 1) {
        dp.at(i + 1).at(j) += dp.at(i).at(j) * (1 - P[i]);
        dp.at(i + 1).at(j + 1) += dp.at(i).at(j) * P[i];
    }

    double ans = 0;
    FOR(i, ceil(N / 2.0), N + 1) ans += dp.back().at(i);

    cout << setprecision(10) << ans << endl;

    return 0;
}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5, oo = 1e9;
const double pi = acos(-1);
using namespace std;

int main()
{
    string a, b; cin>>a>>b;
    cout<<((a[0] == b[2] and a[1] == b[1] and a[2] == b[0])? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 3624
main = do
  [a, b] <- (map read . words) <$> getLine
  putStrLn . show $ solved a b

solved:: Int -> Int -> Int
solved a b
  | mab = div ab 2 + 1
  | otherwise = div ab 2
  where
    ab = a + b
    mab = mod ab 2 /= 0

Measured memory_bytes: 508
package main

import "fmt"

var (
	N int
	X int
	Y int
)

func main() {
	fmt.Scan(&N, &X, &Y)

	m := make(map[int]int)
	for i := 1; i <= N-1; i++ {
		for j := i + 1; j <= N; j++ {
			m[d(i, j)]++
		}
	}
	for k := 1; k < N; k++ {
		fmt.Println(m[k])
	}
}

func min(x1, x2 int) int {
	if x1 < x2 {
		return x1
	}
	return x2
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func d(i, j int) int {

	// 1. i -> j
	// 2. i -> X -> j
	// 3. i -> Y -> j
	// 4. i -> X -> Y -> j

	d1 := abs(j - i)
	d4 := abs(X-i) + 1 + abs(Y-j)

	return min(d1, d4)
}


Measured memory_bytes: 768
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);
    for _ in 0..s.len() {
        print!("x");
    }
    println!("");
}


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

#define Solved int main()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define forn(i, n) for(int i = 1; i <= n; i++)
#define rep(i, x, y) for(int i = x; i <= y; i++)
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define ll long long
#define ull unsigned long long
#define ld long double
#define mii map<int, int>
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
using namespace std;

inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

const int maxn = 1e9;
const ll inf = 1e18;
//const int mod = 998244353;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int n, m, dp[1010][1010];
char a[1010][1010];

void solve() {
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];

    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i + j == 2) continue;

            if (a[i - 1][j] != '#') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            if (a[i][j - 1] != '#') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m];
}

Solved {
    SpeedForce;
	int tt = 1;
    //cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

pair<int, int> target_element(vector<int> vec)
{
    int index = 0;
    int val = vec[0];
    rep (i, 1, vec.size()) {
        if (abs(val) > abs(vec[i])) {
            index = i;
            val = vec[i];
        }
    }
    return make_pair(index, val);
}

int main()
{
    int N, L; cin >> N >> L;
    vector<int> tastes;
    rrep (i, 1, N) tastes.push_back(L + i - 1);

    pair<int, int> pair = target_element(tastes);
    tastes.erase(tastes.begin() + pair.first);
    int sum = accumulate(tastes.begin(), tastes.end(), 0);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int n, s, a[2005], d[2005][2005][2];
int f(int p, int q, int w) {
	int i, mx;
	if(d[p][q][w] != -1) return d[p][q][w];
	mx = max(p, q);
	if(mx == n+1) return abs(a[p] - a[q]);
	if(w == 0) {
		if(p == 0) return d[p][q][w] = f(mx+1, q, 0);
		else return d[p][q][w] = max(f(mx+1, q, 0), f(p, mx+1, 1));
	} else return d[p][q][w] = min(f(mx+1, q, 0), f(p, mx+1, 1));
}

int main() {
	cin>>n>>a[0]>>a[1];
	for(int i=2; i<n+2; i++) scanf("%d", &a[i]);
	memset(d, -1, sizeof(d));
	cout<<f(0, 1, 0);
return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    int n;
    string s;

    int count = 0;
    
    cin>>n;
    cin>>s;

    for(int i=0;i<n-2;i++){
        if(s.compare(i, 3, "ABC")==0){
            count +=1;
        }
    }
    cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	string s;
	cin>>n>>s;
	if(n%2){
		cout<<"No";
		re 0;
	}
	int x=n/2;
	if(s.substr(0,x)==s.substr(x)) cout<<"Yes";
	else cout<<"No";
	re 0;
}

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

using namespace std;

int main() {

	long N, M;
	cin >> N >> M;

	vector<long> H(N);
	for (long i = 0; i < N; ++i)
	{
		cin >> H[i];
	}

	vector<long> A(M);
	vector<long> B(M);
	for (long i = 0; i < M; ++i)
	{
		cin >> A[i] >> B[i];
	}

	vector<long> S(N);
	for (int i = 0; i < N; ++i)
	{
		S[i] == 0;
	}

	for (long i = 0; i < M; ++i)
	{
		if (H[A[i] - 1] > H[B[i] - 1]) {
			S[B[i] - 1] = -1;
		}
		else if (H[A[i] - 1] < H[B[i] - 1]) {
			S[A[i] - 1] = -1;
		}
		else {
			S[A[i] - 1] = -1;
			S[B[i] - 1] = -1;
		}
	}

	long sum = 0;

	for (int i = 0; i < N; ++i)
	{
		if (S[i] == 0) {
			sum++;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  ll l = 4*a*b;
  ll r = (c-a-b) * (c-a-b);
	if(c-a-b <= 0) {
		cout << "No" << endl;
		return 0;
	}
  if(l < r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
d,e,f = map(int,input().split())
g,h,i = map(int,input().split())

num = int(input())

ref = [int(input()) for i in range(num)]
jud = 0

for pp in range(num):
    if ref[pp] == a:
        a=0
    if ref[pp] == b:
        b=0
    if ref[pp] == c:
        c=0
    if ref[pp] == d:
        d=0
    if ref[pp] == e:
        e=0
    if ref[pp] == f:
        f=0
    if ref[pp] == g:
        g=0
    if ref[pp] == h:
        h=0
    if ref[pp] == i:
        i=0


if a == b == c == 0:
    jud = 1
if d == e == f == 0:
    jud = 1
if g == h == i == 0:
    jud = 1
if a == d == g == 0:
    jud = 1
if b == e == h == 0:
    jud = 1
if c == f == i == 0:
    jud = 1
if a == e == i == 0:
    jud = 1
if c == e == g == 0:
    jud = 1

if jud == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[3000];
int s;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i+=2)
	{
		s+=a[i];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import sys
from sys import stdin
def input(): return sys.stdin.readline().strip()

modn = 10 ** 9 + 7
H , W = map(int, input().split())
ahw = [input() for _ in range(H)]
dp = [[0] * W for _ in range(H) ]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if ahw[i][j] == '.':
            if i > 0:
                dp[i][j] += dp[i-1][j]
            if j > 0:
                dp[i][j] += dp[i][j-1]
            dp[i][j] = dp[i][j] % modn
print(dp[-1][-1])

Measured memory_bytes: 43700
# similar to problem if n person are arranged in a row and have 3 different hats to wear
# no of ways of wearing hats so that every adjacent person wears different hats
# so ith person cannot wear more than 3 no of different ways
mod = 10**9+7
def main():
	ans =1
	n = int(input())
	arr = list(map(int , input().split()))
	col=[0 for i in range(0 , 6)]
	for i in range(0 , n):
		cnt , cur =0 , -1
		if arr[i]==col[0]:
			cnt = cnt+1
			cur = 0
		if arr[i]==col[1]:
			cnt = cnt+1
			cur = 1
		if arr[i]==col[2]:
			cnt = cnt+1
			cur = 2
		if cur ==-1:
			print(0)
			exit()
		col[cur]=col[cur]+1
		ans = (ans*cnt)%mod
		ans = ans%mod
	print(ans)

if __name__ =="__main__":
	main()

Measured memory_bytes: 83936
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	int n;
	ll h;
	cin>>n>>h;
	vector<int> a(n),b(n);
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	int aa=a[a.size()-1];
	ll x=0;
	int ans=0;
	while(x<h){
		if(b.empty() || b[0]<=aa){
			if((h-x)%aa!=0) ans+=(h-x)/aa+1;
			else ans+=(h-x)/aa;
			break;
		}else{
			ans++;
			x+=b[0];
			b.erase(b.begin());
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int fr, to;
    cin >> fr >> to;
    sum += to - fr + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,R,T;
int a[1001];
int t[1001];
int u[1001];
int main(){
  cin>>N>>R>>T;
  for(int i=0;i<N;i++)cin>>a[i],t[i]=0;
  int ans=0;
  for(int i=0;i<T;i++){
    for(int j=0;j<N;j++){
      int to=t[j]=(t[j]+a[j])%R;
      if(u[to]==0)ans++,u[to]=1;
      u[to]--;
    }
    if(i)for(int j=0;j<N;j++)u[t[j]]++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1172
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
    
   	ll n=2e5+1,i;
	vector<char> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (ll i = 2; i <= n; i++) {
	    if (is_prime[i] && (long long)i * i <= n) {
	        for (ll j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
	vector<ll> v;
	f(i,1,n)
	{
		if(is_prime[i])
			v.pu(i);
	}
	ll m;
	cin>>m;
	int x=lower_bound(all(v),m)-v.begin();
	cout<<v[x]<<'\n';
 
    return 0;
}

Measured memory_bytes: 896
n = int(input())
v = list(map(int, input().split()))
v.sort(reverse=True)
w = 0
for i in range(n-1):
    w = (v[-1] + v[-2]) / 2
    v.pop(-1)
    v.pop(-1)
    v.append(w)
print(v[0])

Measured memory_bytes: 3060
from sys import stdin
import math

li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse = True)

point = 0
su = sum(li)%2
sai = li[0]%2

if sum(li) == 1:
    print(1)
    exit()

else:
    if su != sai:
        li[0] += 1
        point += 1
    point += (li[0]*2-li[1]-li[2])//2

print(point)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

#define MAX 1e18

int main(){
  int N;
  bool flag = false, zero = false;
  cin >> N;
  long double A[N], ans=1;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++){
    ans *= A[i];
    if(ans > MAX) flag = true;
    if(A[i] == 0)  zero = true;
  }
  if(zero){
    cout << 0 << endl;
  }else{
    if(flag) cout << -1 << endl;
    else cout << (long long int)ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			long l = in.nextLong();
			int[] is = new int[10];
			for (int i = 0; i < 10; i++) {
				is[i] = (int) (l % 10);
				l = l / 10;
			}
			int[] is2 = new int[9];
			while (is.length > 1) {
				is2 = new int[is.length - 1];
				for (int i = 0; i < is2.length; i++) {
					is2[i] = (is[i] + is[i + 1]) % 10;
				}
				is = is2;
			}
			System.out.println(is[0]);
		}
	}
}

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

v = list(map(float, input().split()))

dp = [[0.0] * (len(v)+1) for i in range(len(v))]
for x in range(n):
	for a in range(x + 2):
		if x == 0 and a == 0:
			dp[x][a]=v[x]
		elif x == 0 and a == 1 and n != 1:
			dp[x][a]=1-v[x]
		elif a > n/2:
			dp[x][a]=dp[x-1][a]*v[x]
		else:
			dp[x][a]=dp[x-1][a]*v[x]+dp[x-1][a-1]*(1-v[x])
#import numpy
#print(numpy.matrix(dp));			
print(sum(dp[n-1]))
		

Measured memory_bytes: 112220
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }

void solve() {

    int t = 1;
    //cin >> t;
    while(t--){
     int n,m,ans=0;
     cin>>n>>m;
     set<pair<int,int>>mp;
     for(int i=0;i<m;i++){
            int x,y;
        cin>>x>>y;
        mp.insert({min(x,y),max(x,y)});
     }
     vector<vector<int>>v(n);
     for(auto it:mp){
        v[it.first-1].push_back(it.second-1);
        v[it.second-1].push_back(it.first-1);
     }
     vector<int>vis(n,0);
     queue<int>q;
     for(int i=0;i<n;i++){
        q.push(i);
        int k=1;
        vis[i]=1;
        while(!q.empty()){
            auto it=q.front();
            q.pop();
            vis[it]=1;
            //k++;
            for(int j=0;j<v[it].size();j++){
                if(vis[v[it][j]]==0){
                    vis[v[it][j]]=1;
                    q.push(v[it][j]);
                    k++;
                }
            }
        }
        ans=max(ans,k);
     }
     cout<<ans;

    }
}

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

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);1

    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


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

typedef long long ll;

int main()
{
    //freopen("in.txt","r",stdin);
    int n,m;
    cin >> n;
    ll ans =0;
    int r = 1;
    vector< int > rains(n);
    vector< ll > mountains(n);
    for(int i=0;i<n;i++){
        cin >> rains[i];
        ans += rains[i]*r;
        r *= (-1);
    }
    mountains[0] = (ans)/2;
    for(int i=0;i<n-1;i++){
        mountains[i+1] = rains[i] - mountains[i];
        cout << 2*mountains[i] << " ";
    }
    cout << 2*mountains[n-1] << endl;
}


Measured memory_bytes: 2432
package main

import (
	"fmt"
)

func main() {
	var n, x int
	fmt.Scanf("%d %d", &n, &x)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &p[i])
		p[i] = abs(p[i] - x)
	}
	answer := findMaxD(n, p)
	fmt.Println(answer)
}

func findMaxD(n int, p []int) int {
	if n == 1 {
		return abs(p[0])
	}
	answer := gcd(p[0], p[1])
	for i := 2; i < n; i++ {
		answer = gcd(answer, p[i])
	}
	return abs(answer)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 5504
L, R = map(int, input().split(" "))

if R-L >= 2019:
    print(0)
    exit()

l = [i%2019 for i in range(L, R+1)]
min_num = 10**18
for i in range(len(l)):
    for j in range(i+1, len(l)):
        m = (l[i]*l[j])%2019
        if m < min_num:
            min_num = m

print(min_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
using namespace std;
typedef long long ll;
ll ans = 1, dp[300010][2], mod = 998244353;
int n, vis[300010];
vector<int>p[3];
char s[300010];
int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    ff(i, 1, 3 * n) {
        if(s[i] == 'R')
            p[0].push_back(i);
        else if(s[i] == 'G')
            p[1].push_back(i);
        else
            p[2].push_back(i);
    }
    int temp[5];
    ll mul = 1;
    ff(i, 1, n) {
        int sz = i - 1;
        temp[0] = p[0][sz];
        temp[1] = p[1][sz];
        temp[2] = p[2][sz];
        sort(temp, temp + 3);
        vis[temp[0]] = 1;
        vis[temp[1]] = 2;
        vis[temp[2]] = 3;
        mul = mul * (ll)i % mod;
    }
    ff(i, 1, 3 * n) {
        dp[i][1] = dp[i - 1][1];
        dp[i][0] = dp[i - 1][0];
        if(vis[i] == 1)
            dp[i][0] = (dp[i][0] + 1) % mod;
        else if(vis[i] == 2) {
            ans = ans * dp[i][0] % mod;
            dp[i][0] = (dp[i][0] - 1 + mod) % mod;
            dp[i][1] = (dp[i][1] + 1) % mod;
        }
        else {
            ans = (ans * dp[i][1]) % mod;
            dp[i][1] = (dp[i][1] - 1 + mod) % mod;
        }
    }
    ans = ans * mul % mod;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 7792
/*
*   Author : Ligyagami // Tushar Goyal
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define en '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
 
int main()
{
   fast;
  
  string s;
  cin>>s;
  
  for(int i=0;i<s.length();i++)
  {
      if(s[i] == '7')
      {
          cout<<"Yes";
          return 0;
      }
  }
  
  cout<<"No";
  return 0;
 
}


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

int main() {
    int N, Q; cin >> N >> Q;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> ans(N);
    for(int i = 0; i < Q; ++i) {
        int p, x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    auto dfs = [&](auto &&dfs, int cur, int pre) -> void {
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            ans[to] += ans[cur];
            dfs(dfs, to, cur);
        }
    };
    dfs(dfs, 0, 0);
    for(int i = 0; i < N; ++i) cout << ans[i] << " ";
    cout << '\n';
    return 0;
}


Measured memory_bytes: 21248