akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
bool isPowerOfTwo(int n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}
void solve() {
  int n;
  cin>>n;
  vector<int> v(n);
  int sum=0;
  map<int,int> mp;
 for(auto &i:v) {
      cin>>i;
      sum+=i;
      mp[i]++;
  }
  int q;
  int b,c;
  cin>>q;
  while(q--)
  {
      cin>>b>>c;
      //for(auto i:mp) cout<<i.first<<" "<<i.second<<"\n";
      if(mp.find(b)!=mp.end())
      {
          if(c>=b)
          sum+=mp[b]*abs(b-c);
          else
              sum-=mp[b]*abs(b-c);
          mp[c]+=mp[b];
          mp[b]=0;

      }

      cout<<sum<<"\n";
  }


}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //int t;cin>>t;while(t--)
        solve();
}

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

int main(){
// 10 7
// 14+15+92+65+35+89+79+32+38+46
    int n, k;
    cin >> n >> k;
    vector<int> int_seq(n);
    rep(i, n){cin >> int_seq.at(i);}
    rep(i, n){int_seq[i]--;}
    vector<int> cumulative_sum(n+1);
    for (int i = 0; i < (n); ++i){
        cumulative_sum[i+1] = (cumulative_sum[i] + int_seq[i]) % k;
        // printf("cum_sum %d\n", cumulative_sum[i]);
    }
    map<int, int> cntr;
    long long ans = 0;
    queue<int> q;
    for (int i = 0; i < (n+1); ++i){
        ans += cntr[cumulative_sum[i]];
        cntr[cumulative_sum[i]]++;
        q.push(cumulative_sum[i]);
        if (q.size() == k){
            cntr[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double sum=0;
	for(int i=n;i>=1;i--){
		if(i%2==1)
			sum++;
	}
	double a=n*1.0,b=sum*1.0,s;
	s=b/a;
	printf("%.10f",s);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,x;
ll a[100010];
ll ans;
int main(){
	scanf("%lld%lld",&n,&x);
	rep(i,0,n)scanf("%lld\n",a+i);
	rep(i,1,n){
		if(a[i-1]+a[i]>=x){
			ans+=a[i-1]+a[i]-x;
			a[i]=max(0,x-a[i-1]);
		}
	}
	printf("%lld\n",ans);
}

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

int main() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif


char s[N],t[N];
int n;
int check(int x,int y){
  t[0]=x; t[1]=y;
  REPP(i,1,n-1){
    if(s[i]=='o') {
      if(t[i]==1) t[i+1]=1-t[i-1];
      else t[i+1]=t[i-1];
    }else{
      if(t[i]==0) t[i+1]=1-t[i-1];
      else t[i+1]=t[i-1];
    }
  }
  if(s[0]=='o'){
    if(t[0]==0&&t[1]!=t[n-1]) return 0;
    else if(t[0]==1&&t[1]==t[n-1]) return 0;
  }else{
    if(t[0]==0&&t[1]==t[n-1]) return 0;
    else if(t[0]==1&&t[1]!=t[n-1]) return 0;
  }
  if(s[n-1]=='o'){
    if(t[n-1]==0&&t[0]!=t[n-2]) return 0;
    else if(t[n-1]==1&&t[0]==t[n-2]) return 0;
  }else{
    if(t[n-1]==0&&t[0]==t[n-2]) return 0;
    else if(t[n-1]==1&&t[0]!=t[n-2]) return 0;
  }
  REP(i,n) if(t[i]) t[i]='W'; else t[i]='S';
  return 1;
}
int main(){
  scanf("%d%s",&n,s);
  n=strlen(s);
  t[n]='\0';
  REP(i,2) REP(j,2){
    if(check(i,j)) {
      printf("%s\n",t);
      exit(0);
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 512
def addnum(a):
    a = str(a)
    sum = 0
    for i in range(len(str(a))):
        sum += int(a[i])
    return sum

N = int(input())
min = 10**9
tmp = 0
for A in range(1,N//2+2):
    B = N-A
    tmp = addnum(A)+addnum(B)
    if min>tmp:
        min = tmp
print(min)


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

long a[3002];
long long dp[3002][3002] = {};

long long rec(int begin, int end, int turn){
    if(dp[begin][end] != -1) return dp[begin][end];
    if(begin == end) return dp[begin][end] = turn*a[begin];

    long long ret;
    if(turn == 1){
        ret = -1e18;
        ret = max(ret, rec(begin+1, end, -turn) + turn*a[begin]);
        ret = max(ret, rec(begin, end-1, -turn) + turn*a[end]);
    }
    else{
        ret = 1e18;
        ret = min(ret, rec(begin+1, end, -turn) + turn*a[begin]);
        ret = min(ret, rec(begin, end-1, -turn) + turn*a[end]);
    }
    return dp[begin][end] = ret;
}

int main(){
    int N;
    cin >> N;
    for(int n=0;n<N;n++) cin >> a[n];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            dp[i][j] = -1;
        }
    }
    cout << rec(0, N-1, 1) << endl;
    return 0;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
typedef long long ll;
vector<int>v;

int vis[N];
ll k;

int main(){
    int n;
    scanf("%d %lld", &n, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    int now = 1;
    v.push_back(now);
    vis[now] = 1;
    while(1){
        now = a[now];
        v.push_back(now);
        if(vis[now]){
            break;
        }
        vis[now]++;
    }
    for(int i = 1; i <= n; i++){
        vis[i] = 0;
    }
    int cn = 0;
    int l, r;
    int pos;
    for(int i = 0; i < v.size(); i++){
        if(vis[v[i]]){
            cn = i - (vis[v[i]] - 1);
            pos = (vis[v[i]] - 1);
            l = vis[v[i]] - 1;
            r = i - 1 ;
            break;  
        }
        vis[v[i]] = i + 1;
    }
    // for(int i: v){
    //     cout << i << " ";
    // }
    // cout << endl;
    // cout << cn << endl;
    if(k < v.size()){
        printf("%d\n", v[k]);
    }else{
        k -= pos;
        k = k % cn;
       // cout << "k = " << k << endl;
        printf("%d\n", v[pos + k]);


    }


    
}

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

int main(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
  return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> se;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (se.count(a)) se.erase(a);
        else se.insert(a);
    }
    cout << se.size() << endl;
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int temp;
  int f=0;;

  cin >> n;
  temp=n;
  while(n!=0){
    f+=n%10;
    n/=10;
  }

  if(temp%f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,sum=0;
	cin >> n;
	long long a[21];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n - 1; i++)
	{
		if (a[i] > a[i - 1] && a[i] < a[i + 1]) sum++;
		else if (a[i] < a[i - 1] && a[i] > a[i + 1]) sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200010


int main() {
	char a[N + 1];
	char b[N + 1];
	f(i, N + 1) {
		a[i] = 0;
		b[i] = 0;
	}
	int n,m, k;
	int xl, xr, yl, yr, sx, sy;
	bool v = true;
	scanf("%d %d %d", &n, &m, &k);
	scanf("%d %d", &sx, &sy);
  sx--;
  sy--;
	scanf("%s", a);
	scanf("%s", b);
	xl = 0;
	xr = n - 1;
	yl = 0;
	yr = m - 1;
	for(int i=k-1;i>=0;i--) {
		if (b[i] == 'U') {
			xr++;
			if (xr > (n - 1))xr = n - 1;
		}
		else if (b[i] == 'D') {
			xl--;
			if (xl < 0)xl = 0;
		}
		else if(b[i] == 'L') {
			yr++;
			if (yr > (m - 1))yr = m - 1;
		}
		else {
			yl--;
			if (yl < 0)yl = 0;
		}
		if (a[i] == 'U') {
			xl++;
		}
		else if (a[i] == 'D') {
			xr--;
		}
		else if (a[i] == 'L') {
			yl++;
		}
		else {
			yr--;
		}
		if (xl > xr) {
			v = false;
			break;
		}
		if (yl > yr) {
			v = false;
			break;
		}
	}
	if (sx < xl || xr < sx)v = false;
	if (sy < yl || yr < sy)v = false;

	if(v)printf("YES\n");
	else printf("NO\n");


	return 0;
}

Measured memory_bytes: 512
D = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for _ in range(D)]
t = [int(input())-1 for _ in range(D)]
ans = 0
llst = [0]*26
def last(d,i): return llst[i]

for day,i in enumerate(range(D),1):
    llst[t[i]] = day
    ans += s[i][t[i]]
    for j in range(26): ans -= c[j]*(day-last(day,j))
    print(ans)

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

using namespace std;

int main(void){
	int K, A, B;
	long ans;
	cin >> K >> A >> B;
	if(B<=A+1){
		ans = K+1;
	}else if(K - 1 >= A){
		ans = long(A) + long((((K + 1) - A))/2)*long((B-A));
		if(((K + 1) - A)%2 == 1) ans++;
	}else ans = K + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    A, B = [int(x) for x in stdin.readline().rstrip().split()]

    if abs(A-B) % 2 == 0:
        if A < B:
            print(A + abs(A-B)//2)
        else:
            print(B + abs(A-B)//2)
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), v.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

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

	int n, k; cin >> n >> k;
	vector<double> v(n+1,0);
	FOR(i, n){
		int x; cin >> x;
		double add = (double) (x+1)/2;
		v[i+1] = v[i] + add;
	}

	double ans = 0;
	for(int i = k; i <= n; i++){
		ans = max(ans, v[i]-v[i-k]);
	}

	cout << setprecision(10) << fixed << ans << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=420;
const int mod=998244353;
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int jc[maxn],jcn[maxn],inv[maxn];
inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,400)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

int n,a[maxn],b[maxn],sa,sainv,p[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)a[i]=read(),b[i]=read(),sa+=a[i];
	sainv=power(sa,mod-2);
	REP(i,1,n)p[i]=(ll)a[i]*sainv%mod;
}

int dp[maxn][maxn];

inline void doing()
{
	dp[0][0]=1;
	REP(i,1,n)
	{
		DREP(j,400,0)DREP(k,400,0)if(dp[j][k])
		{
			int t=dp[j][k]; dp[j][k]=0;
			int xs=1;
			dp[j][k+a[i]]=(dp[j][k+a[i]]+t)%mod;
			REP(x,0,b[i]-1)
			{
				dp[j+x][k]=(dp[j+x][k]-(ll)t*xs%mod+mod)%mod;
				xs=(ll)xs*p[i]%mod*inv[x+1]%mod;
			}
		}
	}
	int ans=0;
	REP(j,0,400)REP(k,0,sa-1)if(dp[j][k])
	{
		int v=(ll)k*sainv%mod;
		int c=(mod-dp[j][k])%mod;
		ans=(ans+(ll)c*power(1-v+mod,mod-j-2)%mod*jc[j])%mod;
	}
	printf("%d\n",ans);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}


Measured memory_bytes: 896
// use procontools::prelude::*;
use proconio::input;
// macro_rules! p {
//     ($x:expr) => {
//         println!("{}", $x);
//     };
// }
fn main() {
    input! {
        n:u64,m:u64,
    }
    if n % 2 == 1 {
        for i in n / 2 - m + 1..=n / 2 {
            println!("{} {}", i, n - i);
        }
    } else if n % 4 == 0 {
        let mut flag = false;
        for i in (n / 2 + 1..n).take(m as usize) {
            let (l, r) = (n + 1 - i, i);
            // eprintln!("(l,r) = {:?}", (l,r));
            if r - l >= n / 2 {
                flag = true;
            }
            if flag {
                println!("{} {}", l, r+1);
            } else {
                println!("{} {}", l, r);
            }
        }
    } else {
        let mut flag = false;
        for i in (n / 2 + 1..n).take(m as usize) {
            let (l, r) = (n + 1 - i, i);
            // eprintln!("(l,r) = {:?}", (l,r));
            if r - l == n / 2 {
                flag = true;
            }
            if flag {
                println!("{} {}", l, r+1);
            } else {
                println!("{} {}", l, r);
            }
        }
    }
}


Measured memory_bytes: 2144
def test(array: list, index: int, calc: str, result: int):
    # print("index:{}".format(index))
    # print("calc:{}".format(calc))
    # 配列の最後までチェックしたら終了
    if index == len(array):
        if result == 7:
            print("{}=7".format(calc))
            exit(0)
    if index == 0:
        test(array,
             index + 1,
             array[index],
             int(array[index]))
    elif index <= len(array) - 1:
        test(array,
             index + 1,
             calc + "-" + array[index],
             result - int(array[index]))
        test(array,
             index + 1,
             calc + "+" + array[index],
             result + int(array[index]))


array = list(input())
test(array, 0, "", 0)


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

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 2000002;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    auto perm = [&](int n, int r){
        if(n < r || r < 0) return 0LL;
        return fact[n] * factInv[n-r] % MOD;
    };
    int r1, c1, r2, c2;
    while(cin >> r1 >> c1 >> r2 >> c2){
        int res = 0;
        for(int r=r1;r<=r2;r++){
            res += comb(r+c2+1, r+1);
            res %= MOD;
            res += MOD - comb(r+c1, r+1);
            res %= MOD;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  ll int n,k;
  cin>>n>>k;
  if(n<k){
    cout<<min(n,abs(n-k))<<endl;
  }
  else if(n==k){
    cout<<0<<endl;
  }
  else{
    ll int ans;
    ans = min(abs(k-n%k),n%k);
    cout<<ans<<endl;
  }
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  string S;
   cin >>S;
  if(((S.at(0)==S.at(1)) &&(S.at(2)==S.at(3))&&(S.at(1)!=S.at(2)))
    || ((S.at(0)==S.at(2)) &&(S.at(1)==S.at(3))&&(S.at(1)!=S.at(2)))
    || ((S.at(0)==S.at(3)) &&(S.at(2)==S.at(1))&&(S.at(1)!=S.at(0))))
  {
    cout <<"Yes" << endl;
  }
else {
cout << "No" << endl;
}
}

Measured memory_bytes: 256
import heapq  # heapqライブラリのimport
X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
dic={}
dic[(0,0,0)]=1
lst =[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(lst)
for r in range(K):
 a=lst[0][1]
 b=lst[0][2]
 c=lst[0][3]
 print(lst[0][0]*(-1))
 heapq.heappop(lst)
 if a<X-1 :
  if (a+1,b,c) not in dic:
   heapq.heappush(lst, (-(A[a+1]+B[b]+C[c]),a+1,b,c))
   dic[(a+1,b,c)]=1
 if b<Y-1 :
  if (a,b+1,c) not in dic:
   heapq.heappush(lst, (-(A[a]+B[b+1]+C[c]),a,b+1,c))
   dic[(a,b+1,c)]=1
 if c<Z-1 :
  if (a,b,c+1) not in dic:
   heapq.heappush(lst, (-(A[a]+B[b]+C[c+1]),a,b,c+1))
   dic[(a,b,c+1)]=1

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

class Program
{
    static void Main()
    {
		string a = Console.ReadLine();
		int b = 0;
		int c = 0;
		for(int i=0; i<a.Length; i++)
		{
			if(a[i] == 'A' || a[i] == 'C' || a[i] == 'G' || a[i] == 'T')
			{
				b++;
				if(b >= c) c = b;
			}
			else b = 0;
		}
      	Console.WriteLine(c);
    }
}


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

const int N = 110000;

long long L[N], R[N], len[N];

long long ans;
priority_queue<long long> que1, que2;
long long l, r, add1, add2;

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> L[i] >> R[i], len[i] = R[i] - L[i] + 1;
	
	for (int i = 1; i <= n; i++) {
		if (i == 1) {
			l = r = L[1];
			que1.push(l - add1), que2.push(-(r - add2));
			continue;
		}
		add1 -= len[i] - 1;
		add2 += len[i - 1] - 1;
		l -= len[i] - 1;
		r += len[i - 1] - 1;
		if (l <= L[i] && L[i] <= r) {
			l = r = L[i];
			que1.push(l - add1), que2.push(-(r - add2));
		} else if (L[i] < l) {
			que1.push(L[i] - add1);
			que1.push(L[i] - add1);
			que2.push(-(l - add2));
			r = l;
			que1.pop();
			l = que1.top() + add1;
			ans += abs(L[i] - r);
		} else if (r < L[i]) {
			que2.push(-(L[i] - add2));
			que2.push(-(L[i] - add2));
			que1.push(r - add1);
			l = r;
			que2.pop();
			r = -que2.top() + add2;
			ans += abs(L[i] - l);
		}
	}
	cout << ans << "\n";
	
	return 0;
}


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

using namespace std;

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


int solver() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }

    long long res = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i - 1] > a[i]) {
            res += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }

    cout << res << endl;
    return 0;
}

int main() {
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; ++i) {
        solver();
    }
    return 0;
}

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

int dp[100001][4];
// memset(dp,0,sizeof(dp));

int maxPoints(int arr[][3],int index,int flag,int n){
    int maxi=0;
    if (n==index)
       return 0;
    else if (dp[index][flag])
       return dp[index][flag];
    else if (flag==0){
        maxi=max(maxi,arr[index][0]+maxPoints(arr,index+1,1,n));
        maxi=max(maxi,arr[index][1]+maxPoints(arr,index+1,2,n));
        maxi=max(maxi,arr[index][2]+maxPoints(arr,index+1,3,n));
    }
    else if(flag==1){
        maxi=max(maxi,arr[index][1]+maxPoints(arr,index+1,2,n));
        maxi=max(maxi,arr[index][2]+maxPoints(arr,index+1,3,n));
    } 
    else if(flag==2){
        maxi=max(maxi,arr[index][0]+maxPoints(arr,index+1,1,n));
        maxi=max(maxi,arr[index][2]+maxPoints(arr,index+1,3,n));
    }
    else{
        maxi=max(maxi,arr[index][0]+maxPoints(arr,index+1,1,n));
        maxi=max(maxi,arr[index][1]+maxPoints(arr,index+1,2,n));
    }
    dp[index][flag]=maxi;
    return dp[index][flag];
}

int main() {
    int n=0;
    cin>>n;
    int arr[n][3];
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    cout<<maxPoints(arr,0,0,n);
}


Measured memory_bytes: 15644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll x;
    cin >> x;
    ll po5[10000];
    rep(i,10000)po5[i]=i*i*i*i*i;
    rep(i,10000){
        rep(j,10000){
            if(po5[i]-po5[j]==x){
                cout << i << ' ' << j;
                return 0;
            }
            if(po5[i]+po5[j]==x){
                cout << i << ' ' << -j;
                return 0;
            }
        }
    }


}

/*



 */



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

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
void print(vector<T>& V, bool spaced = true) {
    string space;
    spaced ? space = " " : space = "";
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << space;
    }cout<< '\n';
}

template<class T>
void printendl(vector<T>& V) {
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << '\n';
    }
}

template<class T>
T gcd(T a, T b) {
    T r;
    while (b != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

template <class T>
T lcm (T a, T b) {
    return a / gcd(a, b) * b;
}

template<class T>
T Max(T a, T b) {
    return (a < b) ? b : a;
}

template<class T>
T Min(T a, T b) {
    return (a < b) ? a : b;
}

//str

bool isPalindrome(string str){
    
    int length = str.length();
 
    for (int i = 0; i < (length / 2); i++)
        if (str[i] != str[length - 1 - i])
            return false;
 
    return true;    
}

void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}
 

//Read through the messages at the end when you're done
const double PI = 3.141592653589793238462643383279;
int main() {

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


    double r; cin>> r;
    cout <<fixed << setprecision(20) << 2*PI*r << '\n';

    
    

    return 0;
}

    //Use long long da5eel rabbak!
    //Dont use endl;
    //DONT SUBMIT IZA UR NOT SURE WALLAHI BTENDAM
    //Dear Amine, just because it worked for the test cases doesnt necessarily mean it is correct.
    //Dear Amine, try it on ur own test cases iza ur not SURE
    //In case u didnt use long long, CHECK FOR POTENTIAL OVERFLOWS
    //DONT FORGET TO MOD EVERYTHING IZA U NEED TO MOD



Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define pi pair<int, int>
using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false);
	int n, q, x, y, z;
	cin >> n >> q;
	pair <int, pi> coord[n];
	for (int i = 0; i < n; i++)
	{
		cin >> x >> y >> z;
		coord[i] = make_pair(z, make_pair(x - z, y - z - 1));
	}
	sort(coord, coord + n);
	
	set <int> p;
	map <int, int> ans;
	for (int i = 1; i <= q; i++)
	{
		cin >> x;
		p.insert(p.end(), x);
		ans[x] = -1;
	}
	
	for (int i = 0; i < n; i++)
	{
		x = coord[i].first;
		int start = coord[i].second.first;
		int end = coord[i].second.second;
		while (p.lower_bound(start) != p.end() && *p.lower_bound(start) <= end)
		{
			ans[*p.lower_bound(start)] = x; 
			p.erase(p.lower_bound(start));
		}
	}
	
	for (auto i: ans)
		cout << i.second << endl;
}

Measured memory_bytes: 23040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		int n = io.nextInt();
		int m = io.nextInt();
		int[][] e = new int[n][n];
		
		for(int i=0;i<m;i++){
			int x = io.nextInt()-1;
			int y = io.nextInt()-1;
			e[x][y] = 1;
			e[y][x] = 1;
		}
		System.out.println(goWay(e,new boolean[n],0));
		
	}
	
	public static int goWay(int[][] e, boolean[] visited,int node){
		visited[node] = true;
		int total = 0;
		int allnode = 0;
		for(int i=0;i<visited.length;i++){
			if(visited[i]==true){
				allnode ++;
			} else if(e[node][i]==1){
				total += goWay(e,visited,i);
			}
		}
//		System.out.println("NODE:"+(node+1)+" allnode:"+allnode+" total"+total);
		visited[node] = false;
		if(allnode == visited.length) return 1;
		return total;
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll gcd(ll x, ll y){ return y==0? x: gcd(y, x%y); }

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	vector<string> mt={"dream", "dreamer", "erase", "eraser"};
	VI sno = {5, 7, 5, 6};
	
	while(sz(s) >0){
		bool ok=false;
		rep(j, 4){
			//dbg(sz(s), sno[j]);
			if(sz(s) >= sno[j] && s.substr(sz(s)-sno[j]) == mt[j]){
				s = s.substr(0, sz(s)-sno[j]);
				ok = true; break;
			}
		}
		if(!ok){ puts("NO"); return 0;}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define xll __int128
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

int factors(int n){
	int pro=1;
	int sum=0;
	while(n%2==0){
		n=n/2;
		sum++;	
	}
	pro*=sum+1;
	for(int i=3;i*i<=n;i+=2){
		sum=0;
		while(n%i==0){
			n=n/i;
			sum++;	
		}
		pro*=sum+1;	
	}
	if(n>1){
		pro*=2;	
	}
	return pro;	
} 
int main(){
	int n;
	cin>>n;
	int res=0;
	Fo(i,1,n){
		int val = n-i;
		res+= factors(val);	
	}
	cout<<res<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


Measured memory_bytes: 3584
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(0,a+1):
        for j in range(0,b+1):
                for k in range(0,c+1):
                        cost = 500*i + 100*j + 50*k
                        if cost == x:
                                count += 1
print(count)

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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    int n,m;
    cin >>n>>m;
    
    priority_queue<int> que;

    for (int i = 0; i < n; i++)
    {
        int a;
        cin >>a;
        que.push(a);
    }
    

    for (int i = 0; i < m; i++)
    {
        int max = que.top();
        que.pop();
        max /= 2;
        que.push(max);
    }
    
    for (int i = 0; i < n; i++)
    {
        ans += que.top();
        que.pop();
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int n, a[100000];
int num[100001], ans = 0;
vector<int> two;

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

	for (int i = 1; i < 100001; i++) {
		if (num[i] > 0) {
			if(num[i] % 2 == 1){
				ans++;
			}
			else {
				two.push_back(i);
			}
		}
	}

	if (two.size() % 2 == 1) {
		ans--;
	}
	ans += two.size();

	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys, math,os
from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
# from decimal import Decimal
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 998244353


n=int(data())
a=mdata()
a.sort(reverse=True)
ans=a[0]
ind=1
k=0
for i in range(2,n):
   ans+=a[ind]
   k+=1
   if k==2:
       k=0
       ind+=1
out(ans)








Measured memory_bytes: 94124
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll m = 1e9+7;
const ll N = 1e4+1;
vll k;
ll d;
ll nk;
ll dp[N][2][110];

ll go(ll x , ll small, ll sumi)
{
	if(x == nk)
		return sumi%d ==0 ;

	ll &ans = dp[x][small][sumi];
	if(ans != -1)
		return ans;
	ans = 0;

	if(small)
	{
		for(ll i = 0 ; i<=9 ; ++i)
		{
			ans += go(x+1 , small , (sumi+i)%d);
			ans %= m;
		}
	}
	else
	{
		for(ll i = 0 ; i<k[x] ; ++i)
		{
			ans += go(x+1 , small^1 , (sumi+i)%d);
			ans %=m;
		}

		ans += go(x+1 , small , (sumi+k[x])%d);
		ans%=m;

	}
	return (ans+m)%m;

}

signed main()
{
	fast;
	memset(dp , -1 , sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;

	for(auto c: s)
	{
		ll a = c - '0';
		k.pb(a);
	}

	nk = k.size();

	cin >> d;

	cout<<(go(0 , 0 , 0) - 1 + m)%m<<endl;

	
	return 0;
}


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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = new int[5];
            var min = int.MaxValue;
            var idx = -1;
            for(var i = 0; i < 5; i++){
                x[i] = int.Parse(Console.ReadLine());

                if(x[i] % 10 != 0){
                    if(min > x[i] % 10){
                        min = x[i] % 10;
                        idx = i;
                    }
                }
            }

            var t = 0;
            for(var i = 0; i < 5; i++){
                if(i != idx){
                    t += x[i] % 10 == 0 ? x[i] : (x[i] / 10 + 1) * 10;
                }
            }
            t += idx != -1 ? x[idx] : 0;

            Console.WriteLine(t);
        }
    }
}


Measured memory_bytes: 11092
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let K = read::<i32>();
    let mut mpl = K;
    for i in 0..N-1 {
        mpl *= (K-1);
    }

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


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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            double a, b;
            double ans;
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            a = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            b = int.Parse(str[1]);

            //double val = 1.5;
            //double ret1 = Math.Ceiling(val);

            ans = Math.Ceiling( (a + b)/2 );
            int ans2 = (int)ans;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std; 
 
long long int n,k,a[1000], dp[1000009];
// dp[k][turn];
 
int main(){
  
  cin>>n>>k;
  for(int i = 1; i<=n;i++)
    cin>>a[i];
  
  for(int i = 1; i<=k; i++){
    for(int j = 1; j<=n; j++){
      if(i-a[j]>=0){
          // dependencies of dynamic relation 
          dp[i]|=!(dp[i-a[j]]);
      }
    }
  }
  
  if(dp[k]) cout<<"First"<<endl;
  else 
    cout<<"Second"<<endl;
 
  return 0;
}

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

using namespace std;



int main(){
	long long n,a,b,x,ac=0;
	cin >> a >> b ;


	if (max(a,b) > 9) cout << -1 << endl;
	else cout << a*b << endl;

//	cin >> n;
	return 0;

	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

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

	int count = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '1')
		{
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
S = input()

w = ""
l = ""
L = []
for s in S:
    w += s
    if w == "A":
        l += w
        w = ""
    elif w == "B":
        continue
    elif w == "C":
        w = ""
        if l != "":
            L.append(l)
            l = ""

    elif w == "BC":
        l += "X"
        w = ""
    elif w == "BA":
        w = ""
        if l != "":
            L.append(l)
            l = ""
        l += "A"
    elif w == "BB":
        w = ""
        if l != "":
            L.append(l)
            l = ""

if l != "":
    L.append(l)
    l = ""


def count(S):
    T = S[::-1]

    res = 0
    x_count = 0
    for t in T:
        if t == "X":
            x_count += 1
        elif t == "A":
           res += x_count
    return res

print(sum(count(l) for l in L))


Measured memory_bytes: 5068
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
if len(set(A)) == N:
	print("YES")
else:
	print("NO")


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

int main() {
  int N, p = 0;
  cin >> N;
  
  for (int i = 0; i < N; i ++) {
    int l, r;
    cin >> l >> r;
    p += r - l + 1;
  }
  
  cout << p << endl;
}

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

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

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

    for(int i=0; i<n; i++){
        sort(s[i].begin(),s[i].end());
        //cout << s[i] << endl;
    }

    unordered_map<string, long long int> table;
    long long int answer = 0;
    for(int i=0; i<n; i++){
        if(table.find(s[i]) == table.end()){
            table.insert({s[i], 1});
        }else{
            answer += table[s[i]];
            table[s[i]] += 1;
        }
    }

    cout << answer << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const ll mod = 998244353;
int main() {
	ll n, k;
	cin >> n >> k;
	vector<int> l(k), r(k);
	rep (i, k) {
		cin >> l[i] >> r[i];
	}
	vector<int> dp(n + 10);
	dp[1] = 1;
	for (int i = 1; i < n; i++) {
		dp[i] += dp[i-1];
		dp[i] %= mod;
		rep(j, k) {
			int num = min(i + r[j] + 1, (int)(n + 1));
			int nu = min (i + l[j], (int)(n + 1));
			dp[nu] += dp[i];
			dp[nu] %= mod;
			dp[num] -= dp[i];
			if (dp[num] < 0) dp[num] += mod;
		}
	}
	dp[n] %= mod;
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 4000
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

const int maxn = 1e5 + 100;
int n;
int l, t;
int speed[maxn], a[maxn];

bool read() {
  if (scanf("%d%d%d", &n, &l, &t) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, speed + i);
    if (speed[i] == 2) {
      speed[i] = -1;
    }
  }
  return true;
}

int b[maxn];

void solve() {
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += speed[i];
  }
  sum *= t;
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    b[i] = a[i] + speed[i] * t;
    b[i] %= l;
    if (b[i] < 0) {
      b[i] += l;
    }
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    sum += a[i] - b[i];
  }
  sum %= (ll) l * n;
  if (sum < 0) {
    sum += (ll) l * n;
  }
  assert(sum % l == 0);
  int first = sum / l;
  for (int i = 0; i < n; i++) {
    printf("%d\n", b[(i + first) % n]);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::io::Write;
use std::collections::VecDeque;

fn main() {
    input!{
      n: usize,
      k: usize,
      tds: [(usize, usize); n],
    }
    let mut tds = tds;
    tds.sort_by_key(|&(t, d)| d);
    tds.reverse();

    let mut ate = vec![false; n+1];
    let mut kind = 0;
    let mut ans = 0;
    let mut s1 = VecDeque::new();
    let mut s2 = VecDeque::new();
    for i in 0..k {
        let (t, d) = tds[i];
        if ate[t] == false {
            ate[t] = true;
            kind += 1;
        } else {
            s1.push_back((t, d));
        }
        ans += d;
    }
    for i in k..n {
        let (t, d) = tds[i];
        if ate[t] == false {
            ate[t] = true;
            s2.push_back((t, d));
        }
    }
    ans += kind*kind;

    let mut v = ans;
    while let Some((t, d)) = s1.pop_back() {
        v -= d;
        if let Some((t1, d1)) = s2.pop_front() {
            kind += 1;
            v += d1 + kind*kind - (kind-1)*(kind-1);
            ans = max(v, ans);
        } else {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import Control.Monad

main = do
  n <- read <$> getLine
  xs <- forM [1..n] $ \t -> do
    (a:b:c:xs) <- map read . words <$> getLine
    return (a,b,c)
  putStrLn $ if solve ((0,0,0):xs) then "Yes" else "No"

solve :: [(Int,Int,Int)] -> Bool
solve (x:[]) = True
solve all@((t1,x1,y1):(t2,x2,y2):xs) = 
  let dt = t2 - t1
      dist = (abs (x2-x1)) + (abs (y2-y1))
  in if dt >= dist && (dt-dist) `mod` 2 == 0 then
    solve (tail all)
  else
    False


Measured memory_bytes: 81276
n = int(input())
a = list(map(int, input().split()))
p = 1000
k = 0
for i in range(n-1):
    if k>0 and a[i]>a[i+1]:
        p += k*a[i]
        k = 0
    elif k==0 and a[i]<a[i+1]:
        k = p//a[i]
        p %= a[i]
if k>0:
    p += k*a[-1]
print(p)

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

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    int q;
    std::cin >> q;
    std::vector<int> t(q);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i];
    }

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (s[j] == t[i]) {
                cnt++;
                break;
            }
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>

using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A'&&S[i + 1] == 'B'&&S[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string grid[101];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>grid[i];
    for(int i=0;i<n;i++){
        int all=1;
        for(int j=0;j<m;j++)
            if(grid[i][j]!='.'){
                all=0;
                break;
            }
        if(all){
            for(int j=i+1;j<n;j++)
                grid[j-1]=grid[j];
            i--,n--;
        }
    }
    for(int i=0;i<m;i++){
        int all=1;
        for(int j=0;j<n;j++)
            if(grid[j][i]!='.'){
                all=0;
                break;
            }
        if(all){
            for(int j=i+1;j<m;j++)
                for(int k=0;k<n;k++)
                    grid[k][j-1]=grid[k][j];
            i--,m--;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            putchar(grid[i][j]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 256