akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;

const long long MAX = 200100; // Set
vllvll Graph(MAX, vll(0));
vll dist(MAX);
vector<bool> seen(MAX);

template<class T>
void bfs(T start)
{
    fill(dist.begin(), dist.end(), inf);
    dist[start] = 0;
    fill(seen.begin(), seen.end(), false);

    queue<T> q;
    q.push(start);

    while (! q.empty()) {
    auto now = q.front(); q.pop();
        for (auto adj : Graph[now]) {
            if (dist[adj] == inf) {
                dist[adj] = dist[now] + 1;
                q.push(adj);
            }
        }
    }
}

// Prepare for `Graph`
int main()
{
        ll N, M;
        cin >> N >> M;
        rep(i, 0, M) {
                ll a, b;
                cin >> a >> b;
                Graph[a].push_back(b);
                Graph[b].push_back(a);
        }

        bfs(1);
        if (dist[N] <= 2) {
                cout << "POSSIBLE" << endl;
        } else {
                cout << "IMPOSSIBLE" << endl;
        }
}


Measured memory_bytes: 14824
#include <stdio.h>

int main(void){
  int S;
  int h,m,s;
  h=0;
  m=0;
  s=0;
  scanf("%d",&S);
  while(S>=60*60){
    h++;
    S=S-60*60;
  }
  while(S>=60){
    m++;
    S=S-60;
  }
  s=S;
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

const int DIGS = 10;

bool forbidden [DIGS];

bool fits (int x) {
  while (x != 0) {
    if (forbidden[x % 10]) {
      return false;
    }
    x /= 10;
  }
  return true;
}

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

  for (int i = 0; i < forbc; i++) {
    int d;
    cin >> d;
    forbidden[d] = 1;
  }

  for (int i = n; true; i++) {
    if (fits(i)) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


const int N = 2e5+5;
int n;

int32_t main()
{
	IOS;
	int n;
	cin>>n;
	vector<int>v(n);
	vector<int> freq(n+1);

	for(int i=0;i<=n;i++)
		freq[i]=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
		freq[v[i]]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(freq[i]>=2){
			ans+= (freq[i]* (freq[i]-1))/2;
			//cout<<ans<<" ";
		}
		
	}
	int temp_ans=ans;
	for(int i=0;i<n;i++){
		ans= temp_ans;
		if(freq[v[i]]>=3){
			ans= ans- ((freq[v[i]]* (freq[v[i]]-1))/2) + ((freq[v[i]]-1)* (freq[v[i]]-2))/2;
			//cout<<(freq[v[i]]* (freq[v[i]]-1))/2<<endl;
		}
		else
			ans-= ((freq[v[i]]* (freq[v[i]]-1))/2);
		cout<<ans<<endl;

	}
	return 0;
}

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

ll f(ll n) {
    return n * (n + 1) / 2;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll mod = pow(10, 9) + 7;
    ll sum = 0;
    for (ll i = K; i <= N + 1; i++) {
        sum += f(N + 1) - f(N + 1 - i) - f(i) + 1;
        sum %= mod;
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int a,b;
  cin>>a>>b;
  if(a+b>=10){
    cout<< "error"<<"\n";
  }
  else{
    cout<< a+b<<"\n";
  }
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long

int main(){
  int n,m;
  scanf("%d%d",&n,&m);

  int ans=n*(n-1)/2+m*(m-1)/2;
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
use std::collections::HashMap;
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n: i32 = lines.next().unwrap().unwrap().parse().unwrap();
    let mut s = HashMap::new();
    for _ in 0..n {
        let s_i = lines.next().unwrap().unwrap();
        *s.entry(s_i).or_insert(0) += 1;
    }

    let count_max = s.values().max().unwrap();
    let mut s_max: Vec<&String> = s
        .iter()
        .filter(|&(_, val)| val == count_max)
        .map(|(key, _)| key)
        .collect();
    s_max.sort();

    for s_ans in s_max {
        println!("{}", s_ans);
    }
}


Measured memory_bytes: 20320
#include <iostream>
#include <cctype>

using namespace std;



int main(){
	int n, x;
	int count = 0;
	while (1){
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		int i, j, k;
		for (i = 1; i <= n; ++i){
			for (j = i + 1; j <= n; ++j){
				for (k = j + 1; k <= n; ++k){
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)
void err()
{
    cout<<-1;
    exit(0);
}
int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    queue<int> arr[n+1];
    rep(i,1,n+1)
    {
        rep(j,0,n-1)
        {
            cin>>t;
            arr[i].push(t);
        }
    }
    
    int nxt[n+1]={0};
    queue<pii> q;
    q.push({-1,-1});
    rep(i,1,n+1)
    {
        nxt[i]=arr[i].front();
        arr[i].pop();
        if(i==nxt[nxt[i]])
        {
            q.push({i,nxt[i]});
        }
    }
    int day=0;
    pii p;
    while(1)
    {
        if(q.size()==1) break;
        p=q.front();
        q.pop();
        if(p.F==-1)
        {
            day++;
            q.push(p);
        }
        else
        {
            if(!arr[p.F].empty())
            {
                nxt[p.F]=arr[p.F].front();
                arr[p.F].pop();
                if(p.F==nxt[nxt[p.F]])
                {
                    q.push({p.F,nxt[p.F]});
                }
            }
            if(!arr[p.S].empty())
            {
                nxt[p.S]=arr[p.S].front();
                arr[p.S].pop();
                if(p.S==nxt[nxt[p.S]])
                {
                    q.push({p.S,nxt[p.S]});
                }
            }
        }
    }
    rep(i,1,n+1) if(!arr[i].empty()) err();

    cout<<day;

    return 0;
}



Measured memory_bytes: 4736
from math import log10
n, m = map(int, input().split())
P = [[] for i in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    P[p-1].append((y, i+1))
for i in range(n):
    P[i].sort(key=lambda x:x[0])
res = []
for i in range(n):
    for j in range(len(P[i])):
        a = int(log10(i+1)) + 1
        b = int(log10(j+1)) + 1
        c = (6-a) * "0"
        c += str(i+1)
        c += (6-b) * "0"
        c += str(j+1)
        res.append((c, P[i][j][1]))
res.sort(key=lambda x:x[1])
for i in range(len(res)):
    print(res[i][0])

Measured memory_bytes: 42580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int m,k;
    cin>>m>>k;
    if(m==0){
        if(k==0){
            cout<<0<<" "<<0<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }else if(m==1){
        if(k==0){
            cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }else{
        if((1<<m)-1<k){
            cout<<-1<<endl;
            return 0;
        }
        for(int i=0;i<1<<m;i++){
            if(i!=k)cout<<i<<" ";
        }
        cout<<k<<" ";
        for(int i=(1<<m)-1;i>=0;i--){
            if(i!=k)cout<<i<<" ";
        }
        cout<<k<<endl;
    }
}


Measured memory_bytes: 1792
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Cin.Int()
    Console.WriteLine((Math.Ceiling(n / 2)).ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

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


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.BallCount = inpt[0];
        this.ColorCount = inpt[1];

        long ans = ColorCount;
        for (int i = 1; i < BallCount; i++)
        {
            ans *= (ColorCount - 1);

        }
        Console.WriteLine(ans);


    }

    private int ColorCount;
    private int BallCount;




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

2 2


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            c++;
    }
    cout<<c;
  }
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    string S; cin >> S;
    int SL = S.size();
    string T; cin >> T;
    int TL = T.size();

    string ans = "UNRESTORABLE";
    for(int i=SL-1; i>=0; i--) {
        bool match = true;
        for(int j=0; j<TL; j++) {
            if (i-j<0 || (S[i-j]!='?' && S[i-j]!=T[TL-1-j])){
                match = false;
                break;
            }
        }
        if (match) {
            int b = i - TL + 1;
            ans = S.substr(0, b) + T + S.substr(b + TL);
            for(int k=0; k<ans.size(); k++) {
                if (ans[k] == '?') ans[k] = 'a';
            }
            break;
        }
    }    

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int a[3][3],i,j;
    bool c;
    for(j=0;j<3;j++)
        for(i=0;i<3;i++)
            cin>>a[i][j];
    c=(a[0][0]+a[1][1]==a[0][1]+a[1][0])&&(a[0][0]+a[2][2]==a[0][2]+a[2][0])&&(a[2][2]+a[1][1]==a[2][1]+a[1][2]);
    cout <<(c?"Yes":"No")<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()
     
using namespace std;
using ll = long long;
using P = pair<int, int>;
     
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( a > b ) { a = b; return 1; } return 0; }
     
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
  int N; cin >> N;
  if( N % 2 == 0 ) cout << N << endl;
  else cout << 2 * N << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	ll N;
	vector<ll> a;
	cin >> N;
	rep(i, 0, N){
		ll temp;
		cin >> temp;
		a.push_back(temp);
	}
	sort(begin(a), end(a), greater<ll>());
	ll sumA = 0, sumB = 0;
	rep(i, 0, N){
		if (0 == i % 2){
			sumA += a[i];
		}
		else{
			sumB += a[i];
		}
	}
	cout << sumA - sumB << endl;

	return 0;
}


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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n + 1, vi(m + 1, 0));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            int a = INT_MIN;
            int b = INT_MIN;
            int c = INT_MIN;

            if (s[i] == t[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            }
            else {
                b = dp[i + 1][j];
                c = dp[i][j + 1];
                dp[i][j] =  max(b, c);
            }

        }
    }
    // rep(i, 0, n + 1) {
    //     rep(j, 0, m + 1) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int ans = dp[0][0];
    //cout << ans << endl;
    string res = "";
    int i = 0;
    int j = 0;
    while (ans > 0) {
        if (s[i] == t[j]) {
            res += s[i];
            i++;
            j++;
            ans--;
        }
        else {
            if (dp[i + 1][j] < dp[i][j + 1]) {
                j++;
            }
            else {
                i++;
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 73616
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxi=2000000000;
const int maxq=1000000000;
const ll mod=1000000007LL;
#define f(i,a,b) for(ll  i=(a); i<(b);++i)
/*
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
*/

/*
const int maxx=9000000;
void SieveOfEratosthenes(vector<int> &primes){
    bool IsPrime[maxx+1];
    memset(IsPrime, true, sizeof(IsPrime));
    for(int p=2;p*p<=maxx ;p++){
        if(IsPrime[p]){
            for(int i=p*p;i<maxx ;i+=p) IsPrime[i]=false;
        }
    }
    f(p,2,maxx +1){
        if(IsPrime[p]) primes.push_back(p);
    }
    }
*/
int aa[1000001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ll n,sum=0;
    cin>>n;
    ll a[n];
    f(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll x;
    cin>>x;
    while(x--){
        ll c,d;
        cin>>c>>d;
        f(i,0,n){
        if(a[i]==c){
            a[i]=d;
            sum=sum+d-c;
        }

        } cout<<sum<<endl;
    } */
    ll n,sum=0;
    cin>>n;
    ll a[n];
    f(i,0,n){
        cin>>a[i];
        aa[a[i]]++;
        sum+=a[i];
        //cout<<aa[a[i]]<<' ';
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        ll num1=aa[b];
        //int num2=aa[c];
        //cout<<aa[b]*b<<' '<<aa[b]*;
       sum= sum-(num1*b)+(num1*c);
       aa[b]=0;
       aa[c]+=num1;
       cout<<sum<<endl;
    }
    return 0;
}




Measured memory_bytes: 4768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

#define ll long long

using namespace std;

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

	int n, x ,t;

	cin >> n >> x >> t;
	if ((n % x ) == 0)
	{
		cout << (n / x)* t;
	}
	else {
		cout << (n / x)*t + t;
	}
	return 0;
}

Measured memory_bytes: 3664
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll N,a[100010],A[2];
    cin>>N;
    rep(i,0,N)cin>>a[i];
    sort(a,a+N,greater<>());
    int now=0,cn=0;
    rep(i,0,N){
        if(a[now]==a[now+1]){
            now++;
            A[cn]=a[now];
            cn++;
        }
        now++;
        if(cn==2)break;
    }
    if(cn!=2)cout<<0<<endl;
    else cout<<A[0]*A[1]<<endl;
}






Measured memory_bytes: 1024
<?php
//error_reporting(0);
//list($A,$B,$C) =  explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));

$r = substr_count($S,"R");
$b = $N - $r;
if ($r > $b) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {
    int N, K, i, j, tmp, ans, digits;
    bool hates;
    vector<int> D;
    // get input --------------------------------
    cin >> N >> K;
    for(i = 0; i < K; i++) {
        cin >> tmp;
        D.push_back(tmp);
    }
    // search ----------------------------------
    ans = N-1;
    do {
        hates = false;
        ans++;
        // get N digit -----------------------
        digits = 1;
        tmp = ans;
        while((tmp=tmp/10) != 0) digits++;
        // check ----------------------------
        for(i = 0; i < digits; i++) {
            //cout << i << ":" << tmp << endl;
            tmp = ans%(int)(round(pow(10, (i + 1))));
            //cout << " " << tmp  << "(" << __LINE__ << ")" << endl;
            tmp /= (int)(round(pow(10, i)));
            //cout << " " << (int)(pow(10, i))  << "(" << __LINE__ << ")" << endl;
            //cout << " " << tmp << "(" << __LINE__ << ")" << endl;
            for(j = 0; j < K; j++) {
                if(D[j] == tmp) {
                    hates = true;
                }
            }
        }
    } while(hates);
    // disp answer ------------------------------
    cout << ans << endl;
    return 0;
}



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

int main(int argc, char const *argv[]) {

  int a;
  cin >> a;
  if(a%2 == 1)
  {
    cout << a/2 * (a/2+1) << endl;
  }else{
    cout << a/2 * a/2;
  }
  return 0;
}


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

vector<int> a(3);
int n, m, X, Y;

int main() {
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    for (int i = 0; i < m; i++) {
        cin >> y.at(i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (x.at(n - 1) < y.at(0) && y.at(0) >= X + 1 && x.at(n - 1) < Y) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  ll sum = 0;
  rep(i,n){
    ll a = i+1;
    rep(j,n){
      ll b = j+1;
      rep(k,n){
        ll c = k+1;
        sum += gcd(gcd(a,b),c);
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    ll h,w,ans=0;cin>>h>>w;

    vector<vector<ll>> c(10,vector<ll>(10));
    for(int i=0;i < 10;i++)
    {
        for(int j=0;j < 10;j++)
        {
            cin>>c[i][j];
        }
    }

    vector<int> num(10,0);
    for(int i=0;i < w;i++)
    {
        for(int j=0;j < h;j++)
        {
            int a;cin>>a;
            if(0<=a)num[a]++;
        }
    }

    for(int k=0;k < 10;k++)
    {
        for(int i=0;i < 10;i++)
        {
            for(int j=0;j < 10;j++)
            {
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }

    for(int i=0;i < 10;i++)
    {
        ans+=c[i][1]*num[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B;
    cin >> A >> B;
    lint add = A + B, sub = A - B, mul = A * B;
    lint res;
    if (add >= sub and add >= mul) res = add;
    else if (sub >= add and sub >= mul) res = sub;
    else res = mul;
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	int res = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if(s[i] != t[i]) res++;
	}
	cout << res << endl;
	return 0;
}


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

int c = 0;

void merge(int A[], int left, int mid, int right) {
  int i,j,k;

  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1];
  int R[n2];

  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }

  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = 1000000001;
  R[n2] = 1000000001;

  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    c++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  int n;
  int S[500001];
  cin >> n;

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

  mergeSort(S, 0, n);

  cout << S[0];
  for (int i = 1; i < n; i++) {
    cout << " " << S[i];
  }
  cout << endl;
  cout << c << endl;
}

Measured memory_bytes: 5108
/**
 *		author:  zvm
 *		created: 27.09.2020 16:43:36
**/

#include <bits/stdc++.h>

using namespace std ;

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

	int n ;
	cin >> n ;

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

	auto even = [&]( vector<int>& a ) {
		for( int i = 0 ; i < n ; ++i ) {
			if( a[i]&1 ) {
				return false ;
			}
			a[i] /= 2 ;
		}
		return true ;
	};

	int ans = 0 ;
	for( ; even(a) ; ) {
		ans++ ;
	}

	cout << ans << endl ;
}


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n);
	for(auto &x: a) cin >> x;
	ll xorVal = 0;
	
	for(auto x: a) xorVal = xorVal^x;
	
	for(int i=0 ; i < n ; i++) {
		a[i] = xorVal^a[i];
	}
	
	for(auto x: a) cout << x << " ";
	return 0;
}


Measured memory_bytes: 3972
// atcoder/abc142/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> v(n);
    cin >> v;
    each (i, v) --i;

    map<int, int> m;
    for (int i = 0; i < v.size(); ++i) {
      m[v[i]] = i;
    }

    for (int i = 0; i < n; ++i) {
      cout << m[i] + 1 << ' ';
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int h,a;
    cin>>h>>a;
    int ans=0;
    ans=(h+a-1)/a;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from itertools import permutations
from itertools import combinations

#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
S = input()

l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

print(7-l.index(S))




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

#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

a,b,c,d = map(int, input().split())
cnt=0
while a>0 and c>0:
    if cnt%2==0:
        c-=b
    else:
        a-=d
    cnt+=1
if a>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin), idx##_sz = (int)(end); idx < idx##_sz; ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

//template <lint MOD = 1000000007> class modint {
//private:
//	modint& set(lint val) {
//		val = (val < MOD) ? v : v - MOD;
//		return *this;
//	}
//public:
//	lint m;
//
//	modint(lint x = 0) { set(x % MOD + MOD); }
//
//	modint operator-() { return modint(0) - *this}
//	modint operator+=(const modint &x) { return modint.set(m + x.m); }
//	modint operator-=(const modint &x) { return modint.set(m + MOD - x.m); }
//	modint operator*=(const modint &x) { return modint.set(m * x.m % MOD); }
//	modint operator/=(const modint &x) { return }
//
//
//};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint H, W, N;
	cin >> H >> W >> N;

	vector<pair<int, int>> blk(N);
	for (int i = 0; i < N; i++) cin >> blk[i].first >> blk[i].second;

	map<lint, lint> sqmap;
	vector<int> dxdy{-1, 0, 1};

	for (int i = 0; i < N; i++) {

		for (const auto &dx : dxdy) {
			for (const auto &dy : dxdy) {

				lint x = blk[i].second + dx;
				lint y = blk[i].first + dy;

				if (1 < x && x < W && 1 < y && y < H) {
					sqmap[(y - 1) * W + x - 1]++;
				}

			}
		}

	}

	vector<lint> ans(10);
	for (const auto &elem : sqmap) ans[elem.second]++;

	ans[0] = (H - 2) * (W - 2) - (lint)(sqmap.size());

	for (const auto &elem : ans) cout << elem << "\n";

	return 0;
}

Measured memory_bytes: 57344
use std::io::*;
use std::collections::VecDeque;

fn main() {
    let i = stdin();
    solve(&mut i.lock(), &mut stdout());
}

fn solve(i: &mut BufRead, o: &mut Write) {
    let nums = read_nums(i);
    let h = nums[0];
    let w = nums[1];
    let mut colors = Vec::new();
    for _ in 0..h {
        colors.push(read_colors(i));
    }

    let sol = || {
        if !colors[0][0] || !colors[h - 1][w - 1] {
            return None;
        }
        if w == 1 && h == 1 {
            return Some(0);
        }

        let mut d = vec![vec![usize::max_value(); w]; h];
        d[0][0] = 0;
        let mut ps = VecDeque::new();
        let mut ps_next = VecDeque::new();
        ps.push_back((0, 0));
        while ps.len() > 0 {
            ps_next.clear();
            while let Some(c) = ps.pop_back() {
                let d_new = d[c.0][c.1] + 1;
                let mut step = |y: usize, x: usize| {
                    if colors[y][x] {
                        let dr = &mut d[y][x];
                        if d_new < *dr {
                            if y + 1 == h && x + 1 == w {
                                return true;
                            }
                            *dr = d_new;
                            ps_next.push_back((y, x));
                        }
                    }
                    false
                };
                if (c.0 > 0 && step(c.0 - 1, c.1)) || (c.0 + 1 < h && step(c.0 + 1, c.1))
                    || (c.1 > 0 && step(c.0, c.1 - 1))
                    || (c.1 + 1 < w && step(c.0, c.1 + 1))
                {
                    return Some(d_new);
                }
            }
            std::mem::swap(&mut ps, &mut ps_next);
        }
        None
    };
    let whites = colors.iter().flat_map(|x| x).filter(|x| **x).count();
    let res = sol().map(|step| (whites - step - 1) as isize);
    writeln!(o, "{}", res.unwrap_or(-1)).unwrap();
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}
fn read_nums(i: &mut BufRead) -> Vec<usize> {
    read_line(i)
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect()
}
fn read_colors(i: &mut BufRead) -> Vec<bool> {
    read_line(i).chars().map(|x| x == '.').collect()
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int N=gi();
        double T=gd();
        double A=gd();
        
        double min=Integer.MAX_VALUE;
        int n=0;
        for(int i=0; i<N;i++) {
        	double h=gd();
        	double t=T-h*0.006;
        	if(Math.abs(A-t) <min) {
        		min=Math.abs(A-t);
        		n=i+1;
        	}
        }
	    System.out.println(n);
	    
//        if (min==Integer.MAX_VALUE) {
//        	System.out.println("TLE");
//        }else {
//        	System.out.println(min);
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 40040
#include<stdio.h>
#include<string.h>
int main(){
    int A[3][3],B,N,f;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            scanf("%d",&A[i][j]);
        }
    }
    scanf("%d",&N);
    for (int n=0; n<N; n++) {
        scanf("%d",&B);
        f=0;
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                if (A[i][j]==B) {
                    f=1;
                    A[i][j]=0;
                    break;
                }
            }
            if (f) {
                break;
            }
        }
    }
    for (int i=0; i<3; i++) {
        f=1;
        for (int j=0; j<3; j++) {
            if(A[i][j]!=0){
                f=0;
            }
        }
        if (f) {
            printf("Yes\n");
            return 0;
        }
        f=1;
        for (int j=0; j<3; j++) {
            if(A[j][i]!=0){
                f=0;
            }
        }
        if (f) {
            printf("Yes\n");
            return 0;
        }
    }
    if (A[0][0]==0 && A[1][1]==0 && A[2][2]==0) {
        printf("Yes\n");
        return 0;
    }
    if (A[2][0]==0 && A[1][1]==0 && A[0][2]==0) {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    pair<int,int> s[n];
    int oishii[n];
    memset(oishii,-1,sizeof(oishii));
    for(int i=0;i<n;i++){
        int t,d;
        cin>>t>>d;
        s[i]={-d,t-1};
        oishii[t-1]=max(oishii[t-1],d);
    }
    sort(s,s+n);
    int cnt[n];
    memset(cnt,0,sizeof(cnt));
    ll sum=0,num=0;
    priority_queue<int> p,q;
    for(int i=0;i<k;i++){
        sum-=s[i].first;
        cnt[s[i].second]++;
        if(cnt[s[i].second]==1){
            num++;
        }else{
            p.push(s[i].first);
        }
    }
    int ma=n;
    for(int i=0;i<n;i++){
        if(oishii[i]==-1){
            ma--;
            continue;
        }
        if(cnt[i]==0&&oishii[i]!=-1){
            q.push(oishii[i]);
        }
    }
    ll ans=sum+num*num;
    for(int i=num+1;i<=min(ma,k);i++){
        int t1=-p.top();
        p.pop();
        int t2=q.top();
        q.pop();
        sum=sum-t1+t2;
        num++;
        ans=max(ans,sum+num*num);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,k;
	char grid[10][10],tmp[10][10];
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
		{
			cin>>grid[i][j];
			tmp[i][j]=grid[i][j];
		}
	int ans=0;
	for(int mask1=0;mask1<(1<<n);mask1++)
		for(int mask2=0;mask2<(1<<m);mask2++)
		{
			for(int l=0;l<m;l++)
				for(int bb=0;bb<n;bb++)
					if(mask1&(1<<bb))
						grid[bb][l]='A';
			for(int l=0;l<n;l++)
				for(int bb=0;bb<m;bb++)
					if(mask2&(1<<bb))
						grid[l][bb]='A';
			int cnt=0;
			for(int l1=0;l1<n;l1++)
				for(int l2=0;l2<m;l2++)
					if(grid[l1][l2]=='#')
						cnt++;
			if(cnt==k)
				ans++;
			for(int l1=0;l1<n;l1++)
				for(int l2=0;l2<m;l2++)
					grid[l1][l2]=tmp[l1][l2];
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int N;
	string S;
	cin >> N >> S;
	int x = 0;
	int mx = 0;
	rep(i, N) {
		if (S[i] == 'I')x++;
		else x--;
		mx = max(mx, x);
	}
	cout << mx;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int MOD = (int)(1e9) + 7;
const int INF = (1ll << 31) - 1;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Segtree {
	int n;
	vector<int>d;
	Segtree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int a, int b, int x = -1, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
			return;
		}
		else {
			if (d[k] != INF) {
				d[2 * k] = d[2 * k + 1] = d[k];
				d[k] = INF;
			}
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
	int find(int i) {
		update(i, i + 1);
		return d[n + i];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	Segtree seg(N);
	rep(i, 0, Q) {
		int com; cin >> com;
		if (com) {
			int x; cin >> x;
			cout << seg.find(x) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 3880
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main()
{
    int N, i;
    cin >> N >> i;
    cout << N-i+1;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }
#define MOD 1000000007

int main(){
    const long long MAX = 1000000000;
    long long S;
    cin >> S;

    long long x1, y1, x2, y2, x3, y3;
    if(S <= MAX){
        x1 = y1 = 0;
        x2 = 0; y2 = 1;
        x3 = S, y3 = 0;
    }else{
        long long a = (S+MAX-1) / MAX;
        long long rem = a * MAX - S;
        x1 = 0; y1 = 0;
        x2 = MAX; y3 = a;
        x3 = 1; y2 = rem;
    }

    long long T = (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1);
    cerr << S << " " << T << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
MOD = 10 ** 9 + 7

MN = M * N
A_gt = [0] * MN
B_gt = [0] * MN
ans = 1
for Ai in A:
    if A_gt[Ai - 1] > 0:
        ans = 0
        break
    A_gt[Ai - 1] = 1
for Bi in B:
    if B_gt[Bi - 1] > 0:
        ans = 0
        break
    B_gt[Bi - 1] = 1

if ans != 0:
    for i in range(MN - 2, -1, -1):
        A_gt[i] += A_gt[i + 1]
        B_gt[i] += B_gt[i + 1]
    ans = A_gt[MN - 1] * B_gt[MN - 1]
    for i in range(MN - 2, -1, -1):
        is_max_in_A = A_gt[i] != A_gt[i + 1]
        is_max_in_B = B_gt[i] != B_gt[i + 1]
        if is_max_in_A and is_max_in_B:
            ans *= 1
        elif is_max_in_A:
            ans *= B_gt[i]
        elif is_max_in_B:
            ans *= A_gt[i]
        else:
            ans *= A_gt[i] * B_gt[i] - (MN - 1 - i)
        ans %= MOD
print(ans)


Measured memory_bytes: 56668
N = int(input())
S = [input() for _ in range(N)]

top = [0 for _ in range(N)]
last = [0 for _ in range(N)]

res = 0
n = 0
for s in S:
    for i in range(len(s)-1):
        if s[i] == 'A' and s[i+1] == 'B':
            res += 1
            
    if s[0] == 'B':
        top[n] = 1
        
    if s[-1] == 'A':
        last[n] = 1
        
    n += 1
 
d = 0
t = 0
l = 0
for i in range(N):
    if top[i] == 1 and last[i] == 1:
        d += 1
    elif top[i] == 1:
        t += 1
    elif last[i] == 1:
        l += 1
     

if d >= 1:
    res += d - 1



if d > 0 and min(t, l) >= 1:
    res += min(t-1, l-1)
    res += 2
    
elif d > 0 and min(t, l) < 1 and max(t, l) >= 1:
    res += 1
    
else:
    res += min(t, l)
    
    
print(res)

Measured memory_bytes: 46680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll mn = min_element(all(a)) - a.begin();
  ll mx = max_element(all(a)) - a.begin();
  vector<P> p;
  if(a[mn] == a[mx]) {
    cout << 0 << endl;
    return 0;
  } else if(abs(a[mn]) < abs(a[mx])) {
    rep(i, n) {
      if(a[i] >= 0) continue;
      a[i] += a[mx];
      p.push_back(P(mx + 1, i + 1));
    }
    rep(i, n - 1) {
      a[i + 1] += a[i];
      p.push_back(P(i + 1, i + 2));
    }
  } else {
    rep(i, n) {
      if(a[i] <= 0) continue;
      a[i] += a[mn];
      p.push_back(P(mn + 1, i + 1));
    }
    for(int i = n - 1; i >= 1; i--) {
      a[i - 1] += a[i];
      p.push_back(P(i + 1, i));
    }
  }
  cout << p.size() << '\n';
  rep(i, p.size()) cout << p[i].first << ' ' << p[i].second << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll gcd(ll x, ll y) {
    if (y == 0) {
        return x;
    } else {
        return gcd(y, x % y);
    }
}

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

    ll g = gcd(a, b);

    int ans = 0;
    for (ll i = 2; i * i <= g; i++) {
        if (g % i == 0) {
            ans++;
            while (g % i == 0) {
                g /= i;
            }
        }
    }

    ans += g != 1 ? 2 : 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256