akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dsu[MAXn],sz[MAXn];
ll fnd(ll x){
    if (dsu[x] == x) return x;
    return dsu[x] = fnd(dsu[x]);
}
void mrg(ll x,ll y){
    x = fnd(x), y = fnd(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x,y);
    dsu[y] = x;
    sz[x] += sz[y];
}
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    REP (i,n) dsu[i] = i,sz[i] = 1;
    REP (i,m) {
        ll x,y,z;
        cin >> x >> y >> z;
        mrg(x,y);
    }
    ll cnt = 0;
    REP (i,n) if (dsu[i] == i) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 1792
s;a;b;main(t){
    scanf("%d%d",&a,&b);
    t=b;
    while(t){
        t/=10;
        a*=10;
    }
    a+=b;    
    
    if( pow( (int)sqrt((double)a) ,2)==(double)a   ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    
}

Measured memory_bytes: 2052
import numpy as np
N = int(input())
H = [int(i) for i in input().split(" ")]
H = np.asarray(H)
ans = 0
A = []
for i in range(H.size-1):
  if H[i] >= H[i+1]:
    ans +=1
  else:
    A.append(ans)
    ans = 0
A.append(ans)
print(max(A))

Measured memory_bytes: 23400
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

string s,t;

bool is_sam(char x, char y){
	if(x == '?')return true;
	if(x == y)return true;
	return false;
}

string make_st(int pos){
	string ans;
	rep(i,s.size()){
		if(i==pos){ans+=t; i += t.size()-1;}
		else if(s[i]=='?')ans+='a';
		else ans+=s[i];
	}
	return ans;
}

int main(){
	cin>>s>>t;
	bool al = false;
	vector<string> ans;
	rep(i,s.size()-t.size()+1){
		bool ok = true;
		for(int j = 0; j<t.size(); ++j){
			if(is_sam(s[i+j],t[j]))continue;
			ok = false;
			break;
		}
		if(ok){
			ans.push_back(make_st(i));
			al = true;
		}
	}
	if(!al){cout<<"UNRESTORABLE"<<endl; return 0;}
	sort(all(ans));
	cout<<ans[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
using namespace std;

int read(); ll readll();

ll a[200009]; int cnt,b[200009]; pair<pii,int> c[200009];
void plu(int i,int j,int k){
	a[k]=a[i]+a[j]; assert(a[k]<=1000000000000000000ll);
	b[++cnt]=0; c[cnt]=mpr(mpr(i,j),k);
}
void comp(int i,int j,int k){
	a[k]=(a[i]<a[j]);	
	b[++cnt]=1; c[cnt]=mpr(mpr(i,j),k);
}
int main(){
	//scanf("%lld%lld",&a[0],&a[1]);
	int i,j,k,bin=10;
	plu(0,1,3); comp(2,3,bin);
	comp(2,3,3); plu(0,3,0); plu(1,3,1);
	//a[3]=1
	for (i=1; i<30; i++) plu(bin+i-1,bin+i-1,bin+i);
	int A=50,B=90,nA=150,nB=190;
	for (i=29; i>=0; i--){
		comp(0,0,4);
		for (j=i+1; j<30; j++) plu(4,A+j,4);
		plu(4,bin+i,4);
		comp(4,0,A+i);
		plu(nA+i,A+i,nA+i);
		for (j=1; j<=i; j++) plu(A+i,A+i,A+i);
	}
	for (i=29; i>=0; i--){
		comp(0,0,4);
		for (j=i+1; j<30; j++) plu(4,B+j,4);
		plu(4,bin+i,4);
		comp(4,1,B+i);
		plu(nB+i,B+i,nB+i);
		for (j=1; j<=i; j++) plu(B+i,B+i,B+i);
	}
	for (i=0; i<30; i++)
		for (j=0; j<30; j++){
			plu(nA+i,nB+j,4);
			comp(3,4,5);
			for (k=1; k<=i+j; k++) plu(5,5,5);
			plu(2,5,2);
		}
	printf("%d\n",cnt);
	for (i=1; i<=cnt; i++)
		if (!b[i]) printf("+ %d %d %d\n",c[i].fi.fi,c[i].fi.se,c[i].se);
		else printf("< %d %d %d\n",c[i].fi.fi,c[i].fi.se,c[i].se);
	//printf("%lld %lld\n",(a[0]-1)*(a[1]-1),a[2]);
	return 0;	
}
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}


Measured memory_bytes: 4148
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

ll cnt[100100];
ll cnt2[100100];

int main(){
    int n,q; cin >> n >> q;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        cnt[i+1]=a[i]+cnt[i];
    }
    cnt2[0]=a[0];
    cnt2[1]=a[1];
    for(int i=2;i<n;i++){
        cnt2[i]=a[i]+cnt2[i-2];
    }
    for(int i=0;i<q;i++){
        ll x; cin >> x;
        int l=0,r=n;
        while(r-l>1){
            int mid=(l+r)/2;
            if(n-2*mid+1<0||n-mid<0){
                r=mid;
                continue;
            }
            ll L=a[n-2*mid+1]; ll R=a[n-mid];
            if(abs(L-x)<=abs(R-x)){
                l=mid;
            }
            else{
                r=mid;
            }
        }
        ll ans=0;
        if(n-2*l-1>=0)ans+=cnt2[n-2*l-1];
        cout << ans+cnt[n]-cnt[n-l] << endl;
    }
}

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

int main() {
    int n, a;
    int org[210000], srt[210000];
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> a;
        org[i] = a;
        srt[i] = a;
    }
    sort(srt, srt+n);
    int med_right=srt[n/2], med_left=srt[n/2-1];
    for(int i=0; i<n; i++) {
        if(med_left < org[i]) cout << med_left << endl;
        else cout << med_right << endl;
    }
}

Measured memory_bytes: 3712
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int N = sc.nextInt();
    int A[] = new int[N];
    int longest=0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
    }
    for(int i=0;i<N-1;i++){
      if(longest<A[i+1]-A[i]){
        longest=A[i+1]-A[i];
      }
    }
    if((K-A[N-1])+A[0]>longest){
      longest=(K-A[N-1])+A[0];
    }
    System.out.println(K-longest);
  }
  

  
}

Measured memory_bytes: 85200
import java.util.*;
class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 1;
        for(long i = 1;i<=n;i++){
            ans *= i;
            ans %= 1000000007L;
        }
        System.out.println(ans);
    }
}


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

int cost[100001];

void _initialise(int n){
	for(int i=0;i<n;i++){
		cost[i] = -1;
	}
}

int cal_cost(int* a, int n, int k)
{
	if(n==0){
		return 0;
	}
	else if(n==1){
		cost[n] = abs(a[n]-a[n-1]);
		return cost[n];
	}
	if(cost[n]!=-1){
		return cost[n];
	}
	int c = INT_MAX;
	for(int i=1;i<=k;i++){
		if(n-i>=0){
			c = min(c , cal_cost( a , n-i , k ) + abs(a[n] - a[n-i] ));
		}
	}
	cost[n] = c;
	return cost[n];
}


int main(int argc, char const *argv[])
{
	int i,j,k,n;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	_initialise(n);
	cout<<cal_cost(a,n-1,k);
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int N,M;
    ll X,min=INF;
    cin >> N >> M >> X;
    vector<vector<ll>> A(N,vector<ll>(M+1));

    for(int i = 0;i < N;i++)
        for(int j = 0;j < M+1;j++)
            cin >> A.at(i).at(j);

    vector<ll> B(M+1);

    for(ll i = 0;i < M+1;i++)
        B.at(i) = 0;
    
    bool fla,henka=false;

    for(int tmp = 0;tmp < (1 << 12);tmp++){
        bitset<12>s(tmp);

        fla = true;

        for(ll i = 0;i < M+1;i++)
            B.at(i) = 0;

        for(int i = 0;i < N;i++){
            if(s.test(i)){
                for(int j = 0;j < M+1;j++)
                    B.at(j) += A.at(i).at(j);
            }
        }

        for(int j = 1;j < M+1;j++){
            if(B.at(j) < X){
                fla = false;
                break;
            }
        }

        if(fla == true and B.at(0) < min){
            min = B.at(0);
            henka = true;
        }

    }
    if(henka)
        cout << min << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(){
  int a, b, c;
  
  scanf("%d %d %d", &a, &b, &c);
  if(a == b){
    printf("%d", c);
  } else if(a == c){
    printf("%d", b);
  } else if(b == b){
    printf("%d", a);
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.nextLine();
		String[] a2 = a.split("");
		String b = scan.nextLine();
		String[] b2 = b.split("");
		int al = a.length();
		int bl = b.length();
		if(al<bl){
			int n=al; al=bl; bl=n;
			String[] nu=a2; a2=b2; b2=nu;
		}
		int[][] dp = new int[bl+1][al+1];
		for(int i=1;i<=al;++i){
			dp[0][i]=dp[0][i-1]+1;
		}
		for(int i=1;i<=bl;++i){
			dp[i][0]=dp[i-1][0]+1;
		}
		for(int i=1;i<=bl;++i){
			for(int j=1;j<=al;++j){
				int min=0;
				if(b2[i-1].equals(a2[j-1])==true){
					min = Min(dp[i-1][j-1],dp[i][j-1]+1,dp[i-1][j]+1);
				} else {
					min = Min(dp[i-1][j-1]+1,dp[i][j-1]+1,dp[i-1][j]+1);
				}
				dp[i][j]=min;
			}
		}
		System.out.println(dp[bl][al]);
	}

	public static int Min(int a, int b, int c){
		int min=a;
		if(a>b){
			min=b;
		}
		if(min>c){
			min=c;
		}
		return min;
	}
}



Measured memory_bytes: 31432
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

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

  if (s == "ABC")
    cout << "ARC";
  else
    cout << "ABC";
  return 0;
}


Measured memory_bytes: 3572
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)

using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    // #endif    

    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a<=8 and b<=8)
        {
            cout<<"Yay!";
        }
        else
        {
            cout<<":(";
        }
    }
    
}//Goodbye...

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n,k = LI()
    a = LI()
    dp = [0 for i in range(k+1)]
    f = [0 for i in range(k+1)]
    for i in range(k+1):
        if not f[i]:
            for j in a:
                if i-j >= 0:
                    dp[i] = 1-dp[i-j]
                    if dp[i] == 0:
                        break
            else:
                dp[i] = 1
    print(["First","Second"][dp[k]])
#B
def B():

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 46644
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left,  bisect_right #(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

cnt = 0
lenC = len(C)
for b in B:
    uecnt = bisect_left(A, b)
    shitacnt = lenC - bisect_right(C, b)
    val = uecnt*shitacnt
    cnt += val

print(cnt)



Measured memory_bytes: 93096
#include <stdio.h>

int main(){
    int i, h, n;
    int sum=0;
    scanf("%d",&h);
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(h > sum)
        printf("No");
    else
        printf("Yes");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int H,W;
  scanf("%d%d",&H,&W);
  bool S[H+2][W+2];
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      S[i][j]=false;
    }
  }
  string temp;
  for (int i = 1; i <= H; i++) {
    std::cin >> temp;
    for (int j = 1; j <= W; j++) {
      if(temp[j-1]=='#'){
        S[i][j]=true;
      }else{
        S[i][j]=false;
      }
    }
  }

  int ans[H+2][W+2],bomb;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if(S[i][j]==true){
        ans[i][j]=-1;
      }else{
        bomb=0;
        for (int k = i; k < i+3; k++) {
          for (int z = j; z < j+3; z++) {
            if(S[k-1][z-1]==true){
              ++bomb;
            }
          }
        }
        ans[i][j]=bomb;
      }
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if(ans[i][j]==-1){
        printf("#");
      }else{
        printf("%d",ans[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int K = sc.nextInt();
		long[] a = new long[K];
		for (int i = 0; i < K; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		long max = 2;
		long min = 2;

		for (int i = K - 1; i >= 0; i--) {
			min = ((min - 1) / a[i] + 1) * a[i];
			max = ((max) / a[i]) * a[i] + a[i] - 1;
			if (min > max) {
				System.out.println(-1);
				return;
			}

		}
		System.out.println(min + " " + max);

	}

}


Measured memory_bytes: 56684
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=r&&x+r<=W&&y>=r&&y+r<=H){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// #define INF (1<<29)

const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;
int main() {
    ios::sync_with_stdio(false);
    int D,T,S;
    cin>>D>>T>>S;

    isYes(T*S>=D);
    return 0;
} 
 

Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main() {
	int rate[9] = { 1,400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
	int count[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
	int all=0;

	int n;
	cin >> n;
	int a[n];

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

	for (int i = 0; i < n; i++) {
		for (int k = 0; k < 8; k++) {
			if (rate[k] <= a[i] && a[i] < rate[k+1]) {
				count[k] += 1;
			}
		}
		if(a[i]>=3200){
			all++;
		}
	}
	int min=0;
	for(int i=0;i<8;i++){
		if(count[i]>0){
			min++;
		}
	}
	int max=0;
		if(all>0){
			max=all+min;
		}else{
			max=min;
		}
	if(min==0){
		min=1;
	}
	if(max==0){
		max=1;
	}


	cout<<min<<" "<<max<<endl;
}

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

typedef struct {
	int k;
	int a[100];
	int b[100];
} zikantai_t;

void read_zikantai(zikantai_t* zikantai) {
	int i;
	if(scanf("%d",&zikantai->k)!=1)exit(1);
	for(i=0;i<zikantai->k;i++) {
		int ah,am,bh,bm;
		if(scanf("%d:%d-%d:%d",&ah,&am,&bh,&bm)!=4)exit(1);
		zikantai->a[i]=60*ah+am;
		zikantai->b[i]=60*bh+bm;
	}
}

int main(void) {
	static zikantai_t zyugyo;
	int n,m;
	static zikantai_t sensei[100];
	static zikantai_t seito[100];
	int morikubosyotaro=0;
	int i;
	read_zikantai(&zyugyo);
	if(scanf("%d",&n)!=1)return 1;
	for(i=0;i<n;i++)read_zikantai(&sensei[i]);
	if(scanf("%d",&m)!=1)return 1;
	for(i=0;i<m;i++)read_zikantai(&seito[i]);
	for(i=0;i<zyugyo.k;i++) {
		int horieyui=0;
		int asumikana=0;
		int j,k;
		for(j=0;j<n;j++) {
			for(k=0;k<sensei[j].k;k++) {
				if(sensei[j].a[k]<=zyugyo.a[i] && zyugyo.b[i]<=sensei[j].b[k]) {
					horieyui++;
					break;
				}
			}
		}
		for(j=0;j<m;j++) {
			for(k=0;k<seito[j].k;k++) {
				if(seito[j].a[k]<=zyugyo.a[i] && zyugyo.b[i]<=seito[j].b[k]) {
					asumikana++;
					break;
				}
			}
		}
		morikubosyotaro+=(horieyui<asumikana?horieyui:asumikana);
	}
	printf("%d\n",morikubosyotaro);
	return 0;
}

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

ll sum(ll n) {
    ll sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    ll k;
    cin >> k;
    ll ans = 1, toAdd = 1;
    while (k--) {
        cout << ans << endl;
        if (sum(ans + toAdd) * (ans + toAdd * 10) < sum(ans + toAdd * 10) * (ans + toAdd))
            toAdd *= 10;
        ans += toAdd;
    }
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  int k=0;
  rep(i,n) if (p[i]!=i+1) k++;
  if (k <= 2) cout << "YES" << endl;
  else cout << "NO" << endl; 
}


int main() {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
#include <vector>
#include <algorithm>
using namespace std;
static const long long MOD = 1000000007LL;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main()
{
	int n;
	cin>>n;
	vector<ll> h(n);
	bool abc=true;
	for(int i=0;i<n;i++)
		cin>>h[i];
	for(int i=n-1;i>=1;i--)
	{
		if(h[i-1]>h[i])
			h[i-1]--;
		if(h[i-1]>h[i])
			abc=false;		
	}
	if(abc==true)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    long long int n,k,ans=0;
    cin>>n>>k;
    vector<long long int> h(n);
    rep(i,n) cin>>h[i];
    sort(h.begin(),h.end());
    rep(i,n-k) ans+=h[i];
    cout<<ans;
}

Measured memory_bytes: 4760
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>

using namespace std;

typedef long long ll;

int get_LCS(string x, string y){
  int nx = x.size(), ny = y.size();
  int dp[nx+1][ny+1];
  for(int i=0;i<=ny;i++) dp[0][i] = 0;
  for(int i=0;i<=nx;i++) dp[i][0] = 0;
  for(int i=1;i<=nx;i++){
    for(int j=1;j<=ny;j++){
      if(x[i-1] == y[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
    }
  }
  /*for(int i=1;i<=nx;i++){
    for(int j=1;j<=ny;j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  return dp[nx][ny];
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int q; cin >> q;
  for(int i=0;i<q;i++){
    string x, y; cin >> x >> y;
    cout << get_LCS(x, y) << endl;
  }
}


Measured memory_bytes: 7088
t=input()
a=int(t[0])
b=int(t[1])
c=int(t[2])
d=int(t[3])
if a+b+c+d==7:
  print(t[0]+"+"+t[1]+"+"+t[2]+"+"+t[3]+"=7")
elif a+b+c-d==7:
  print(t[0]+"+"+t[1]+"+"+t[2]+"-"+t[3]+"=7")
elif a+b-c+d==7:
  print(t[0]+"+"+t[1]+"-"+t[2]+"+"+t[3]+"=7")
elif a+b-c-d==7:
  print(t[0]+"+"+t[1]+"-"+t[2]+"-"+t[3]+"=7")
elif a-b+c+d==7:
  print(t[0]+"-"+t[1]+"+"+t[2]+"+"+t[3]+"=7")
elif a-b-c+d==7:
  print(t[0]+"-"+t[1]+"-"+t[2]+"+"+t[3]+"=7")
elif a-b-c-d==7:
  print(t[0]+"-"+t[1]+"-"+t[2]+"-"+t[3]+"=7")
elif a-b+c-d==7:
  print(t[0]+"-"+t[1]+"+"+t[2]+"-"+t[3]+"=7")

Measured memory_bytes: 3064
#include <stdio.h>

///((((((;゜Д゜)))))//ナンカスゴイコードニナッタ

int main(void)
{
	int road[17][17];
	int a, b, n;
	int i, j, flg;
	int x[40], y[40];
	
	flg = 0;
	
	while (1){
		for (i = 0; i < 17; i++){
			for (j = 0; j < 17; j++){
				road[j][i] = 1;
			}
		}
		
		scanf("%d %d", &a, &b);
		
		if (a == 0 && b == 0){
			break;
		}
		
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &x[i], &y[i]);
			road[x[i] - 1][y[i] - 1] = 0;
		}
		
		if (road[0][0] == 0){
			printf("0\n");
		}
		else {
			for (i = 0; i < b; i++){
				for (j = 0; j < a; j++){
					if (road[j][i] != 0){
						if (i == 0 || j == 0){
							if (i > j){
								 if(road[j][i - 1] != 0){
									road[j][i] = 1;
								 }
								 else {
								 	road[j][i] = 0;
								 }
							}
							else if (i < j){
								if(road[j - 1][i] != 0){
									road[j][i] = 1;
								}
								else {
									road[j][i] = 0;
								}
							}
							else {
								road[j][i] = 1;
							}
						}
						else {
							road[j][i] = road[j - 1][i] + road[j][i - 1];
						}
					}
				}
			}
			printf("%d\n", road[j - 1][i - 1]);
		}
	}
	return (0);
}

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

int main() {
  string O,E,A;
  cin >> O >> E;
  for(int i=0; i<O.size()+E.size(); i++){
    if(i%2==0){
      A+=O[i/2];
    }else{
      A+=E[i/2];
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200;

int n, m, r;
int d[maxn][maxn];
ll ans = INF;
vector<vector<int>> perm;
int vinum[8]; bool viused[8];

void P(vector<int> v) {
	if (v.size() == r) {
		perm.push_back(v);
	}
	else {
		rep(i, r) {
			if (!viused[i]) {
				viused[i] = true;
				v.push_back(vinum[i]);
				P(v);
				viused[i] = false;
				v.pop_back();
			}
		}
	}

	return;
}



int main() {

	cin >> n >> m >> r;

	rep(i, r) {
		cin >> vinum[i];
		vinum[i]--;
	}

	rep(i, n) {
		rep(j, n) {
			if (i == j) {
				d[i][j] = 0;
			}
			else {
				d[i][j] = d[j][i] = INF;
			}
		}
	}

	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}

	rep(i, r) {
		viused[i] = false;
	}

	vector<int> pre;

	rep(i, r) {
		if (!viused[i]) {
			pre.push_back(vinum[i]);
			viused[i] = true;
			P(pre);
			pre.pop_back();
			viused[i] = false;
		}
	}

	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}

	rep(i, perm.size()) {
		vector<int> v = perm[i];
		ll sum = 0;
		rep(j, v.size() - 1) {
			sum += d[v[j]][v[j + 1]];
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[][] dp = new int[2][n];

		for(int i=0;i<n;i++) {
			if(i==0) {
				dp[0][0]=sc.nextInt();
			} else {
				dp[0][i]=sc.nextInt()+dp[0][i-1];
			}
		}

		for(int i=0;i<n;i++) {
			if(i==0) {
				dp[1][0]=sc.nextInt()+dp[0][0];
			} else {
				dp[1][i]=sc.nextInt()+Math.max(dp[0][i],dp[1][i-1]);
			}
		}
		System.out.println(dp[1][n-1]);
	}

}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[100][2];
    for(int i=0; i<n; i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    for(int i=0; i<n-2; i++)
    {
        if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])

        {
            cout<<"Yes"<<endl;
            return 0;
        }

    }

            cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    vector<ll>a(4);
    rep(i,4){
        cin>>a[i];
    }
    sort(all(a));
    cout<<abs(a[3]+a[0]-a[2]-a[1])<<endl;
}


Measured memory_bytes: 3168
n = int(input())
taro_p, hanako_p = 0, 0
for i in range(n):
    taro, hanako = input().split()
    x, y = [(3,0), (1,1), (0,3)][(taro < hanako) + (taro <= hanako)]
    taro_p += x
    hanako_p += y
print(taro_p, hanako_p)


Measured memory_bytes: 5596
<?php

fscanf(STDIN, "%d %d", $n, $k);
#$inputs = array_map(function($x) { return (1+$x)/2;}, explode(" ", trim(fgets(STDIN))));
$inputs = array_map("intval", explode(" ", trim(fgets(STDIN))));

$cumsum = [0];
for ($i = 0; $n > $i; $i++) {
    #$cumsum[$i+1] = $cumsum[$i] + $inputs[$i];
    $cumsum[$i+1] = $cumsum[$i] + (1+$inputs[$i])/2;
}
#echo join(',', $cumsum) . "\n"; #debug

#累積和を出す（既に期待値になってる）
$x = -1;
for ($i = 1; $n - ($k - 1) >= $i; $i++) {
    $y = $cumsum[$i+$k-1] - $cumsum[$i-1];
    if ($x < $y) {
        $x = $y;
    }
}

printf("%f", $x);


Measured memory_bytes: 29168
#include<stdio.h>
#include<math.h>
int main()
{
    int a[100]={0},N;
    scanf("%d",&N);
    int i,j,temp;
    for(i=0;i<N;i++)
        scanf("%d",&a[i]);
    for(i=0;i<N;i++)
    {
        for(j=i+1;j<N;j++)
        {
            if(a[i]<a[j])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    int s1=a[0],s2=0;
    for(i=1;i<N;i++)
    {
        if(i%2==0)
            s1+=a[i];
        else
            s2+=a[i];
    }
    printf("%d\n",s1-s2);
}


Measured memory_bytes: 128
#include <iostream>
#include <limits>
#include <set>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

using Z = int;
constexpr Z INF = numeric_limits<Z>::max();

#ifdef DEBUG
# define dump(x) cerr << "dump@" << __LINE__ << " : " << #x << " = " << (x) << endl
# define mesg(m) cerr << "mesg@" << __LINE__ << " : " << m << endl
# define debug if (true)
#else
# define NDEBUG
# define dump(x)
# define mesg(m)
# define debug if (false)
# define at operator[]
#endif
#define rep(i, n) for (auto i = 0; i < n; i++)
#define rrep(i, n) for (auto i = n; i >= 0; i--)
#define all(c) begin(c), end(c)

class fenwick {
  private:
    Z n;
    vector<Z> data;
  public:
    fenwick(Z n): n(n), data(n + 1) {}

    Z sum(Z x) {
      x++;
      Z total = 0;
      for (Z i = x; i > 0; i -= i & -i)
        total += data.at(i);
      return total;
    }

    void add(Z x, Z v) {
      x++;
      for (Z i = x; i <= n; i += i & -i)
        data.at(i) += v;
    }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  using pz = pair<Z, Z>;
  Z n, K, q;
  cin >> n >> K >> q;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<Z> as(n);
  for (auto& a : as) cin >> a;
  vector<pz> sorted(n);
  rep (i, n) {
    sorted[i].first = as[i];
    sorted[i].second = i;
  }
  sort(all(sorted));
  set<Z> removed;
  Z minimum = INF;
  rep (i, n) {
    dump(i);
    Z first = -1, last = -1;
    Z k = i;
    fenwick fwt(n);
    rep (j, n)
      if (!removed.count(j))
        fwt.add(j, 1);
    mesg("fenwick init complete");
    rep (j, q) {
      for (; k < n; k++) {
        auto right = removed.lower_bound(sorted[k].second);
        Z li, ri;
        ri = right == end(removed) ? n : *right;
        if (right == begin(removed))
          li = -1;
        else {
          right--;
          li = *right;
        }
        dump(li);
        dump(ri);
        Z sz = fwt.sum(ri - 1) - fwt.sum(li);
        dump(fwt.sum(ri - 1));
        dump(fwt.sum(li));
        dump(sz);
        if (sz >= K) {
          mesg("update");
          fwt.add(sorted[k].second, -1);
          if (j == 0)
            first = sorted[k].first;
          last = sorted[k].first;
          k++;
          break;
        }
      }
    }
    if (k == n) break;
    dump(first);
    dump(last);
    minimum = min(minimum, last - first);
    dump(minimum);
    removed.insert(sorted[i].second);
  }
  cout << minimum << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,Q;
	cin>>N>>Q;
    string S;
	cin>>S;
    vector<vector<int>>vec(Q,vector<int>(2));
    for(int i=0;i<Q;i++){
        for(int k=0;k<2;k++) cin>>vec.at(i).at(k);
    }
    vector<int>coun(N);
    int count=0;
    for(int i=0;i<N-1;i++){
        if(S.at(i)=='A'&&S.at(i+1)=='C'){
            count++;
        }
            coun.at(i+1)=count;
    }
    for(int i=0;i<Q;i++){
        cout<<coun.at(vec.at(i).at(1)-1)-coun.at(vec.at(i).at(0)-1)<<endl;
    }
}

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

int main()
{
  ll n;
  cin >> n;
  map<string, int> map;
  for (ll i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    map[s]++;
  }
  vector<string> ans;
  ll maxv = 0;
  for (auto itr = map.begin(); itr != map.end(); itr++)
  {
    if (itr->second > maxv)
    {
      ans.clear();
      maxv = itr->second;
    }
    else if (itr->second < maxv)
    {
      continue;
    }

    ans.push_back(itr->first);
  }
  for (int i = 0; i < ans.size(); i++)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 27164
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

exist = True

# aの合計は1~nの和の倍数
if sum(a) % (n*(n+1)//2) != 0:
    exist = False

if exist:
    # 操作の回数
    com = sum(a) // (n*(n+1)//2)
    
    # となりとの差
    diff = [a[i] - a[i-1] for i in range(n)]
    ed = []
    for diffi in diff:
        if (com-diffi) % n != 0:
            exist = False
            break
        else:
            ed.append((com-diffi) // n)
    
    if exist:
        if sum(ed) != com or any([edi < 0 for edi in ed]):
            exist = False
        
if exist:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 15044
n = int(input())
a = input()
b = input()
c = input()
res = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        res += 1
    else:
        res += 2
print(res)


Measured memory_bytes: 3060
def main():
    s = input()
    x = "01" * (len(s)//2+1)
    y = "10" * (len(s)//2+1)

    x = sum(map(lambda t: t[0]==t[1], zip(s,x)))
    y = sum(map(lambda t: t[0]==t[1], zip(s,y)))
    print(min(x,y))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
	vc a(n);
	Ff(i,0,n)
	cin>>a[i];

	ll ans=0;
	sortall(a);
	Ff(i,0,n)
	{
		Ff(j,i+1,n)
		{
			Ff(k,j+1,n)
			{
				if (a[i] != a[j] && a[j] != a[k] && a[k] < a[i] + a[j])
                    ans++;
			}
		}
	}
	cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10696
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b,q;
  cin >> a >> b >> q;
  ll s[a],t[b];
  for(ll i=0;i<a;i++)cin >> s[i];
  for(ll i=0;i<b;i++)cin >> t[i];

  ll c[a],d[b];

  for(ll i=0;i<a;i++){
    ll e=lower_bound(t,t+b,s[i])-t;
    if(e==b)c[i]=abs(s[i]-t[b-1]);
    else if(e==0)c[i]=abs(s[i]-t[0]);
    else c[i]=min(abs(s[i]-t[e]),abs(s[i]-t[e-1]));
  }

  for(ll i=0;i<b;i++){
    ll e=lower_bound(s,s+a,t[i])-s;
    if(e==b)d[i]=abs(t[i]-s[a-1]);
    else if(e==0)d[i]=abs(t[i]-s[0]);
    else d[i]=min(abs(t[i]-s[e]),abs(t[i]-s[e-1]));
  }

  vector<ll> v;

  for(ll i=0;i<q;i++){
    ll x;
    cin >> x;
    ll m=inf;
    ll e=lower_bound(s,s+a,x)-s;
    if(e==a){
      ll n=abs(x-s[a-1]);
      n+=c[a-1];
      m=min(m,n);
    }
    else if(e==0){
      m=min(m,abs(x-s[0])+c[0]);
    }
    else{
      m=min(m,abs(x-s[e])+c[e]);
      m=min(m,abs(x-s[e-1])+c[e-1]);
    }

    e=lower_bound(t,t+b,x)-t;
    if(e==b){
      ll n=abs(x-t[b-1]);
      n+=d[b-1];
      m=min(m,n);
    }
    else if(e==0){
      m=min(m,abs(x-t[0])+d[0]);
    }
    else{
      m=min(m,abs(x-t[e])+d[e]);
      m=min(m,abs(x-t[e-1])+d[e-1]);
    }
    v.push_back(m);

  }

  for(ll i=0;i<q;i++)cout << v[i] << endl;

}

Measured memory_bytes: 7396
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long n, k;
vector<long long> a(n), b(n);

bool check(long long x){
    long long num = 0;
    for(int i = 0; i < n; i++){
        long long c = x / b[i];
        num += max<long long>(0, a[i] - c);
    }
    return num <= k;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    b.resize(n);
    for(auto&& i : a){
        cin >> i;
    }
    for(auto&& i : b){
        cin >> i;
    }
    sort(begin(a), end(a));
    sort(rbegin(b), rend(b));
    long long s = -1, g = 1e12;
    while(g - s > 1){
        long long mid = (s + g) / 2;
        if(check(mid)){
            g = mid;
        }else{
            s = mid;
        }
    }
    cout << g << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 100000 + 10;

char s[MAXN];

int main() {
	scanf("%s", s);
	int n = strlen(s), w = 0, l = 0, cnt = 0;
	for(int i=0; i<n; i++) {
		if(!cnt) {
			cnt++;
			if(s[i] == 'p')	l++;
		}
		else {
			cnt--;
			if(s[i] == 'g')	w++;
		}
	}
	printf("%d\n", w-l);
    
    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum;
LL ans,a;
LL no;
string s,t;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		ans += i;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
string a,b,c;
cin >> a>> b>> c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
    cout << "YES" << endl;
}else{
    cout << "NO" << endl;
}
return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        mut g: [usize; n]
    }

    g.sort();
    g.reverse();
    let mut set = HashSet::new();
    for (a, b) in g.windows(2).map(|x| (x[0], x[1])) {
        if a == b {
            set.insert(a);
        }
    }
    let mut used = HashSet::new();
    let mut b = vec![false; 1000005];

    let mut ans = 0usize;
    while !g.is_empty() {
        let p = g.pop().unwrap();
        // dbg!(p);
        if !b[p] && !set.contains(&p) {
            ans += 1;
        }
        if !used.contains(&p) {
            (2..)
                .map(|x| x * p)
                .take_while(|x| *x < 1000005)
                .for_each(|x| {
                    b[x] = true;
                });
            used.insert(p);
        }
    }

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

/// 配列に含まれる要素(T: Ord + Copy)別にその個数を数えて
/// `BTreeMap<T, usize>`の形にして返す
pub fn unique_count<T: Ord + Copy>(v: &[T]) -> BTreeMap<T, usize> {
    let mut map = BTreeMap::new();
    for e in v {
        let h = map.entry(*e).or_insert(0);
        *h += 1;
    }
    map
}


Measured memory_bytes: 10792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main () {
  int a, b;
  cin >> a >> b;
  int c = 0;
  if (b > 1 && b <= a) {
    c = 1;
  } else if(b >a){
    c = ((b - a)%(a-1)==0 ? (b-a)/(a-1):(b-a)/(a-1)+1);
    c ++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()

def check( SS ):
    n = 0
    for i in SS:
        if n%2 == 0:
            if i != "R" and i != "U" and i != "D":
                return False
        elif n%2 == 1:
            if i != "L" and i != "U" and i != "D":
                return False
        n += 1
    return True


if check(S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
const ll L = 3e3 + 5;
ll dp[L][L];
string s,t;
string rec(ll n,ll m)
{
	if(n == 0 || m == 0)
	{
		string v;
		return v;
	}
	else if(s[n-1] == t[m-1])
		return rec(n-1,m-1) + s[n-1];
	else
	{
		if(dp[n-1][m] == max(dp[n-1][m],dp[n][m-1]))
			return rec(n-1,m);
		else
			return rec(n,m-1);
	} 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	cin >> s >> t;
 	ll i,j;
 	ll n = sz(s);
 	ll m = sz(t);
 	for(i=1;i<=n;i++)
 		for(j=1;j<=m;j++)
 		{
 			if(i == 0 || j == 0)
 				dp[i][j] = 0;
 			else if(s[i-1] == t[j-1])
 				dp[i][j] = dp[i-1][j-1] + 1;
 			else
 				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
 		}
 	cout << rec(n,m) << endl;
	return 0;
}

Measured memory_bytes: 71040
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string n;
	cin >> n;
	bool ok = true;
	for (int i = 0; i < n.size(); i++)
	{
		if (n[i] != '9') ok = false;
	}
	if (ok) cout << 9 * n.size() << endl;
	else
	{
		ok = true;
		for (int i = 1; i < n.size(); i++)
		{
			if (n[i] != '9') ok = false;
		}
		if (ok) cout << n[0] - '0' + 9 * (n.size() - 1)<<endl;
		else cout << n[0] - '1' + 9 * (n.size() - 1)<<endl;
	}
    return 0;
}

Measured memory_bytes: 256