akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n; cin >> n;
    int ans = 0;
    int a[n];rep{
        cin >> a[i];
    }
    int i = 1;
    while(i<n){
        if(a[i-1]==a[i]){
            ans+=1; i+=2;
        }else{
            i++;
        }
    }
    cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	double sum=0;
	for (int i=0; i<N; i++) {
	    int A;
        cin >> A;
	    sum+=1.0/A;
	}
	double ans=1.0/sum;
	cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll i,N,x=inf,id=0;
  cin>>N;
  vec v(N);
  rep(i,N){
    cin>>v[i];
    if(chmin(x,v[i]))id=i;
  }
  cout<<id+1<<endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

struct mint{
  ll x;
  mint(ll x=0) : x((x%mod+mod)%mod) { }
  mint& operator+=(const mint a){
    if((x+=a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  mint inv() const{
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination{
  vector<mint> fact,ifact;
  combination(int n):fact(n+1),ifact(n+1){
    assert(n < mod);
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n,int k){
    if(k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin >> n >> k;
  combination c(n);
  mint ans = 0;
  for(int i=0; i<=min(k,n-1); i++){
    ans += c(n,i) * c(n-1,n-i-1);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int a, b, c, d, e, f;
  cin>>a>>b>>c>>d>>e>>f;

  double cmax=0, ctemp;
  int wans=a*100, sans=0;
  REP(i, f/a+1){
    REP(j, f/b+1){
      if(a*i*100+b*j*100>f) break;
      REP(k, f/c+1){
        if(a*i*100+b*j*100+c*k>f) break;
        if((a*i+b*j)*e<c*k) break;
        REP(l, f/d+1){
          if(a*i*100+b*j*100+c*k+d*l>f) break;
          if((a*i+b*j)*e<c*k +d*l) break;
          ctemp = (double)(c*k+d*l)/(a*i*100+b*j*100+c*k+d*l);
          if(cmax<ctemp){
            cmax=ctemp;
            wans = a*i*100+b*j*100+c*k+d*l;
            sans = c*k+d*l;
          }
        }
      }
    }
  }
  cout<<wans<<" "<<sans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)){
    if(s.at(2)==s.at(3)&&s.at(0)!=s.at(2)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if(s.at(0)==s.at(2)){
    if(s.at(1)==s.at(3)&&s.at(0)!=s.at(1)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if(s.at(0)==s.at(3)){
    if(s.at(1)==s.at(2)&&s.at(0)!=s.at(1)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = [0]+list(map(int,input().split()))+[0]#size N+2

ans = 0
for i in range(N+1):#当初の計画
    ans+=abs(A[i+1]-A[i])

for i in range(1,N+1,1):#やめること
    sabun= -abs(A[i]-A[i-1])-abs(A[i+1]-A[i])
    sabun += abs(A[i+1]-A[i-1])
    print(ans+sabun)


Measured memory_bytes: 86456
#include <iostream>

using namespace std;

int main(){
  	string source;
  	int n;
  	cin >> n;
  	cin >> source;
  	int cnt = 0;
  	for(unsigned int i = 0; i< source.size() - 2; i++){
    	if(source[i] == 'A' && source[i+1] == 'B'  && source[i+2] == 'C'){
        	cnt++;
        }
    }
  
  	cout << cnt << endl;
	return 0;
}

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

#define task "B"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next nextalscjaowjico
#define prev prevoua0wucckjsl
#define y1 y1kscj9u20cjeijc
#define left leftljascjljl
#define right rightsocjolkjl
#define y0 y0cqu3jioajc

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
ll n, a, b;
int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
#else
   // freopen(task".in","r",stdin);
    //freopen(task".out","w",stdout);
#endif
    cin >> n >> a >> b;
    ll s = a + b;
    ll res = (n / s) * a;
    n %= s;
    res += min(a, n);
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int ans = n * 500;
    if (ans >= m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    int a, b, c, x, y;
    int res_a=0, res_b=0, res_c=0;
    cin >> a >> b >> c >> x >> y;
    int min_ab = (x > y) ? y : x;
    
    if((a + b) <= c * 2){
        res_a += min_ab;
        res_b += min_ab;
    }else{
        res_c += min_ab * 2;
    }

    
    if (x > y){
        if(a > c * 2){
            res_c += (x - min_ab) * 2;
        }else{
            res_a += x - min_ab;
        }
    }else{
        if(b > c * 2){
            res_c += (y - min_ab) * 2;
        }else{
            res_b += y - min_ab;
        }
    }

    cout << a*res_a + b*res_b + c*res_c << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();

		int S1=Integer.valueOf(S.substring(0,2));
		int S2=Integer.valueOf(S.substring(2,4));


		if (!(S1 - 12 > 0 || S1 == 0)) {
			if (!(S2 - 12 > 0 || S2 == 0))
				System.out.println("AMBIGUOUS");
			else
				System.out.println("MMYY");
		} else {
			if (!(S2 - 12 > 0 || S2 == 0))
				System.out.println("YYMM");
			else
				System.out.println("NA");
		}

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int32_t main() {
    string s;
    cin >> s;
    if (s.back() == 's') {
        s += 'e';
        s += 's';
    }
    else {
        s += 's';
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

    int main(){
      string s, t; cin >> s >> t;
      int N = s.size();
      int M = t.size();

      s += s;

      vector<vector<int>> pos(26);
      for (int i = 0; i < 2 * N; i++) pos[s[i] - 'a'].push_back(i);

      bool ok = true;
      for (int i = 0; i < M; i++){
        if (pos[t[i] - 'a'].size() == 0) ok = false;
      }

      if (!ok) cout << -1 << endl;

      else {
        ll ans = -1;
        for (int i = 0; i < M; i++){
          auto itr = upper_bound(pos[t[i] - 'a'].begin(), pos[t[i] - 'a'].end(), ans % N);
          ans += *itr - ans % N;
        }
        cout << ans + 1 << endl;
      }
    }


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

int main(void){
	int X;
	int t;

	scanf("%d %d", &X, &t);

	if (X >= t) {
		X = X - t;
	}
	else
	{
		X = 0;
	}

	printf("%d\n", X);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int i,j;
  char str[102];
  int len;
  int tmp;

  while(scanf("%s",str)!=EOF){
    len=0;
    while(str[len]!='\0')len++;

    for(i=0;i<len;i++){
      if(str[i] == '@'){
	tmp = str[i+1] -'0';
	for(j=0;j<tmp;j++)printf("%c",str[i+2]);
	i += 2;
      }else{
	printf("%c",str[i]);
      }
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int64_t total=0;
    for(int64_t i=k;i<=n+1;i++){
        total += fmod(i*n+i+1-i*i,pow(10,9)+7);
    }
    total = fmod(total, pow(10,9)+7);
    cout << (int64_t)total;

    return 0;
}

Measured memory_bytes: 3648
import java.io._
import scala.io.StdIn.{readLine, readInt}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0

  def toZero(x:Double) = if(x == -0.0) 0.0 else x
  def main(args:Array[String]) = {
   val p = readLine.split(" ").map(_.toDouble)
   val n = readInt

   val (x0,y0,x1,y1) = (p(0),p(1),p(2),p(3))
   for(i<-0 until n) {
     val p1 = readLine.split(" ").map(_.toDouble)
     val (x2,y2) = (p1(0),p1(1))
     val sqrt = Math.pow(x1-x0,2) + Math.pow(y1-y0,2)
     val inner = (x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)
     val (xt,yt) = (inner*(x1-x0)/sqrt + x0, inner*(y1-y0)/sqrt + y0)
     out.write(toZero(xt).toString)
     out.write(" ")
     out.write(toZero(yt).toString)
     out.write("\n")
     if(count<10) count += 1
     else {
      out.flush
      count = 0
     }
   }
   out.flush
   out.close
  }
}

Measured memory_bytes: 46696
N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])

Q,K=map(int,input().split())

SD=[0]*N
seen=[0]*N
stack=[]
stack.append([K-1,0])
seen[K-1]=1
while stack:
    x,d=stack.pop()
    for y,d0 in G[x]:
        if seen[y]==0:
            SD[y]=d+d0
            stack.append([y,d+d0])
            seen[y]=1
for i in range(Q):
    x,y=map(int,input().split())
    ans=SD[x-1]+SD[y-1]
    print(ans)



Measured memory_bytes: 58780
import random
def score(D,c,s,t):
    v=list()
    last=[0]*26
    legacy=0
    for i in range(D):
        minus=0
        v.append(legacy)
        v[i]+=s[i][t[i]-1]
        last[t[i]-1]=i+1
        for j in range(26):
            minus+=c[j]*(i+1-last[j])
        v[i]-=minus
        legacy=v[i]
    return v[D-1]
s=list()
t=list()
D=int(input())
c=list(map(int,input().split()))
for i in range(D):
    s.append(list(map(int,input().split())))
t=[random.randint(1,26)]*D
for i in range(100):
    d=random.randint(1,D)
    q=random.randint(1,26)
    old=t[d-1]
    oldscore=score(D,c,s,t)
    t[d-1]=q
    if score(D,c,s,t)<oldscore:
        t[d-1]=old
for i in range(D):
    print(t[i])

Measured memory_bytes: 9732
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,A[1001]={0},i,j,k,ans;

int main()
{
  cin >>N;

  for(i=0;i<N;i++)
  {
    cin >> j;
    A[j]++;
  }
  ans=0;
  for(i=1;i<1001;i++)
  {
    for(j=i;j<1001;j++)
    {
      for(k=j;k<1001;k++)
      {
        if(k<i+j)
        {
          if(i==j && j!=k) ans+=A[i]*(A[i]-1)*A[k]/2;
          else if(i!=j && j==k) ans+=A[i]*A[j]*(A[j]-1)/2;
          else if(i==j && j==k) ans+=A[i]*(A[i]-1)*(A[i]-2)/6;
          else ans+=A[i]*A[j]*A[k];
        }
      }
    }
  }
  
  cout <<ans;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i, j, x, y;
    cin >> n;
    bool out = false;
    for(i = 0; i*i*i*i*i <= 1e14; i++) {
        x = i*i*i*i*i;
        for(j = 0; j*j*j*j*j <= 1e14; j++) {
            y = j*j*j*j*j;
            if(x - y == n) {
                out = true;
                break;
            } else if (x + y == n) {
                ll tmp = i;
                i = j;
                j = -tmp;
                out = true;
                break;
            }
        }
        if(out) {
            break;
        }
    }
    cout << i << " " << j << "\n";
    return 0; 
}

Measured memory_bytes: 18648
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main()
{
  int N,i;

  cin>>N;

  for (i = 1; i*i <= N; i++) ;

  cout<<(i-1)*(i-1)<<endl;

  return 0;
}

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

int main() {
  long long k;
  cin >> k;
  
  long long num=(7%k);
  long long count=0;
  
  long long c = (7%k);
  
  for(long long i=0; i<1000000000000000000; i++){
    if(k % 2 == 0 || k % 5 == 0)
      break;
    
    if(i>0){
    c *= 10;
    c %= k;
    num += c;
    num %= k;
    }
    
    if(num % k == 0){
      count++;
      break;
    }
    else
      count++;
  }
  
  if(k % 2 == 0 || k % 5 == 0)
    cout << -1 << endl;
  else
    cout << count << endl;
}

Measured memory_bytes: 3600
//                          **********  YATIN KWATRA  ********** 

//AC bakshi Rabha

#include <bits/stdc++.h>
#define ll                      long long 
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uo                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<long,long>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
// #define node                    Node

using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}


void solve()
{ 
       int n,m,x;
       cin >> n >> m >> x;

       vvii v(n,vii(m));
       vii c(n);

       fo(i,0,n-1)
       {
        cin >> c[i];
        fo(j,0,m-1) cin >> v[i][j];
       }

       // Try all the combinations

       ll ans = LLONG_MAX;
       ll curans = 0;
       
       for(int mask = 0; mask < (1<<n) ; mask++)
       {
            vii cur(m,0);
            curans = 0;

            // For each book check if the current book is included in the
            // subset or not

            fo(i,0,n-1)
            {
                if(mask&(1<<i))
                {
                    curans += c[i];

                    fo(j,0,m-1)
                    {
                        cur[j] += v[i][j];
                    }
                }
            }

            int ok = 0;

            fo(i,0,m-1)
            {
                if(cur[i] < x){
                    ok = 1;
                    break;
                }
            }

            if(!ok) ans = min(ans,curans);

       }

       if(ans == LLONG_MAX) cout << "-1\n";
       else cout << ans << endl;

       
}
int main() {
    
    FIO
 //    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


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

int main(){
  ll x,y;
  cin>>x>>y;
  ll ans=0;
  if(y>x)ans=min(y-x,abs(abs(x)-abs(y))+1);
  else{
    ans=abs(abs(x)-abs(y));
    ans+=((x>0&&y>0)||(x<0&&y<0))?2:1;
  }
  cout <<ans<<endl;
  return 0;
}


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

const int INF = 1e9 + 10;

int main() {
  int n;
  cin>>n;
  int ac=0, wa=0, tle=0, re=0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      ac++;
    }
    if (s == "WA") {
      wa++;
    }
    if (s == "TLE") {
      tle++;
    }
    if (s == "RE") {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            int[] hw = ReadAndParseIntArr();
            int h = hw[0];
            int w = hw[1];
            int[,] s = new int[h, w];
            for(int i=0;i<h;++i)
            {
                string sz = Console.ReadLine();
                for(int j=0; j<w;++j)
                {
                    s[i, j] = sz[j] == '#' ? 1 : 0;
                }
            }

            // 孤立した#があると無理
            for(int i=0;i<h;++i)
            {
                for(int j=0;j<w;++j)
                {
                    if(s[i,j] == 1)
                    {
                        if (IsOrphan(i, j, s))
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("Yes");
         }
        private static bool IsOrphan(int i, int j, int[,] s)
        {
            // 隣接が0なら孤立
            return SafeCheckZero(i + 1, j, s) && SafeCheckZero(i - 1, j, s) && SafeCheckZero(i, j + 1, s) && SafeCheckZero(i, j - 1, s);
        }
        private static bool SafeCheckZero(int i, int j, int[,] s)
        {
            if( 0 <= i && i < s.GetLength(0))
            {
                if( 0 <= j && j < s.GetLength(1))
                {
                    return s[i, j] == 0;
                }
            }
            return false;
        }
    }
}


Measured memory_bytes: 13248
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) for(auto i=0; i != n; ++i)
#define REP(i, k, n) for(auto i=k; i != n; ++i)
#define rrep(i, n) for(auto i=n; i != 0; --i)
#define RREP(i, n, k) for(auto i=n; i != k; --i)


int sea[60][60];
int w,h;
void dfs(int x, int y){
    int dx[] = {0, 1, -1};
    int dy[] = {0, 1, -1};

    if(sea[x][y] == -1) return ;

    if(sea[x][y] == 1){
        sea[x][y] = -1;
    }

    for(int xx=-1; xx<=1; xx++){
        for(int yy=-1; yy<=1; yy++){
            if(xx==0 && yy==0){
                continue;
            }

            if(sea[x + xx][y + yy] == 1){
                dfs(x+xx, y+yy);

            }

        }
    }



}

int main (){
    while (true){
        cin>>w>>h;
        if(w==0 && h==0){ break;}
        rep(i, 60){
            rep(j,60){
                sea[i][j] = -1;
            }
        }

        rep(i, h){
            rep(j,w){
                cin>>sea[i+1][j+1];
            }
        }


        int ans = 0;
        rep(i, h){
            rep(j,w){
                if(sea[i+1][j+1] == 1){
                    dfs(i+1,j+1);
                    ans++;
                }
            }
        }

        cout<<ans<<endl;

    }

}


Measured memory_bytes: 3256
fun main(args: Array<String>) {

    val n = readLine()!!.toByte()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var b = true

    val e = a.filter { it % 2 == 0 }
    for(i in 0 until e.size) {
        if(e[i] % 3 == 0 || e[i] % 5 == 0) {
        }else {
            b= false
        }
    }

    val res = if(b) "APPROVED" else "DENIED"
    println(res)
}

Measured memory_bytes: 37836
#include <iostream>

using namespace std;

int main ()
{
    int D, N;
    cin >> D >> N;
    long long int ans=1;

    for (int i=0; i<D; i++) {
        ans *= 100;
    }
    if (N == 100) ans *= (N+1); 
    else ans *= N;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
using namespace std;
int main(){
    ll n;cin>>n;
    ll a[n+1];
    for(int i=1;i<=n;++i)
        cin>>a[i];
    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;++i)
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    import math
    from functools import reduce

    def gcd(*numbers):
        return reduce(math.gcd, numbers)

    K = int(input())
    ans = 0

    for i in range(1,K+1):
        for j in range(1,K+1):
            for l in range(1,K+1):
                ans = ans + gcd(i,j,l)
    print (ans)

if __name__ == "__main__":
    main()



Measured memory_bytes: 69568
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int n;
vector<int> v,ans(100001);
vector<vector<int>> adj(100001);

int main(){
	cin >> n;
	int start=0;
	for (int i=0; i<n-1; ++i){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
/*	for (int i=0; i<n; ++i){
		if (adj[i].size() == 1)  start=i;
	}
*/	for (int i=0; i<n; ++i){
		int a;
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(),v.end());
	int ret=0;
	for (int i=0; i<n-1; ++i){
		ret += v[i];
	}
	cout << ret << '\n';
	vector<bool> vu(n);
	int idx=0;
	while (idx < n){
		for (int j=0; j<n; ++j){
			if (vu[j]) continue;
			int cnt=0;
			for (auto& i:adj[j]){
				if (!vu[i]) ++cnt;
				if (cnt == 2) break;
			}
			if (cnt == 1 or cnt == 0){
				vu[j]=true;
				ans[j]=v[idx];
				idx++;
			}
			if (idx == n) break;
		}
//		++idx;
	}
	for (int i=0; i<n; ++i){
		cout << ans[i] << ' ';
	}
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>

static int blocks[100];
static int block_num;
static int max_climb_up;
static int max_climb_down;

void init_parameter(){
    scanf("%d",&block_num);
    for (int i=0;i<block_num;i++)
        scanf("%d",blocks+i);
    max_climb_up=0;
    max_climb_down=0;
}

void run(){
    for (int i=0;i<block_num-1;i++){
        if (blocks[i]<blocks[i+1])
            max_climb_up=(blocks[i+1]-blocks[i])>max_climb_up?(blocks[i+1]-blocks[i]):max_climb_up;
        else if (blocks[i]>blocks[i+1])
            max_climb_down=(blocks[i]-blocks[i+1])>max_climb_down?(blocks[i]-blocks[i+1]):max_climb_down;
    }
    printf("%d %d\n",max_climb_up,max_climb_down);
}


int main() {
    int data_set_num=0;
    scanf("%d",&data_set_num);

    for (int i=0;i<data_set_num;i++){
        init_parameter();
        run();

    }

    return 0;
}


Measured memory_bytes: 2020
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
 
/*--------------------------------------------------------------------------------

--------------------------------------------------------------------------------*/

ll b[200005];

int main(){
    ll n; cin >> n;
    Vl p(n);
    rep(i, 0, n) cin >> p[i];

    rep(i, 0, n){
        if(p[i]==1) b[1]++;
        else b[p[i]] = b[p[i]-1]+1;
    }
    ll k = 0;
    Rep(i, 1, n) chmax(k, b[i]);
    // Rep(i, 1, n) cout << b[i] << " \n"[i==n];
    co(n-k);

    return 0;
}


Measured memory_bytes: 6460
#define rep(i,n)for(int i=0;i<n;i++)
#define mi(x,y) (x<y?x:y)
#define N 100003//overflow防止
int main(){
	int A,B,M,a[N],am=1e5,b[N],bm=1e5,x,y,c,cm=2e5;
	scanf("%d%d%d",&A,&B,&M);
	rep(i,A){scanf("%d",&a[i+1]);am=mi(am,a[i+1]);}
	rep(i,B){scanf("%d",&b[i+1]);bm=mi(bm,b[i+1]);}
	rep(i,M){
		scanf("%d%d%d",&x,&y,&c);
		cm=mi(cm,a[x]+b[y]-c);
	}
	printf("%d",mi(cm,am+bm));
}

Measured memory_bytes: 1024
N=int(input())
Check=[]
Key=True

for i in range(N):
    W=input()
    Check.append(W)
    W=list(W)
    if 0<i and W[0]!=tmp:
        Key=False
        break
    tmp=W[len(W)-1]
    
for i in Check:
    if 1<Check.count(i):
        Key=False
        break

if Key==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
R,G,B,N = map(int,input().split())
ans = 0

if R == 1 and G == 1:
  for b in range(N//B+1):
    ans += N-b*B+1

else:
  for r in range(N//R+1):
    for g in range(N//G+1):
      bB=N-r*R-g*G
      if bB >= 0 and bB%B == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9184
#include <stdio.h>

int n;
int a[100010];

int main(void)
{
	scanf("%d", &n);
	
	for(int x = 1 ; x <= 50000 ; x++)
	{
		int gg = (double)x * 1.08;
		
		a[gg] = x;
	}
	
	if(a[n] == 0)
		printf(":(");
	else
		printf("%d", a[n]);
	
	return 0;
}

Measured memory_bytes: 384
use std::collections::HashSet;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let t: Vec<char> = s.trim().chars().collect();

    let mut set = HashSet::new();
    for c in "ACGT".chars(){
        set.insert(c);
    }

    let ans = t
        .split(|c| !set.contains(c))
        .map(|x| x.len())
        .max()
        .unwrap();
    println!("{}", ans);
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 100001
bool is_prime[MAXN];
bool similar_2017[MAXN];
int cum_count[MAXN];

int main(){
  rep(i, MAXN)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2; i<MAXN; i++){
    for(int j=i*2; j<MAXN; j+=i)is_prime[j]=false;
  }

  rep(i, MAXN)similar_2017[i]=false;
  for(int c=1; c<MAXN; c+=2)similar_2017[c]=(is_prime[c] && is_prime[(c+1)/2]);

  rep1(i, MAXN-1)cum_count[i]=(similar_2017[i] ? 1 : 0)+cum_count[i-1];

  int n;cin>>n;
  rep(i, n){
    int l, r;cin>>l>>r;
    cout<<cum_count[r]-cum_count[l-1]<<endl;
  }

  return 0;

rep(i, 20)cout<<is_prime[i]<<' ';cout<<endl;
rep(i, 20)cout<<similar_2017[i]<<' ';cout<<endl;
rep(i, 20)cout<<cum_count[i]<<' ';cout<<endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if (n & 1)
    {
        for (ll i = 1; i <= 3500; i++)
            for (ll j = 1; j <= 3500; j++)
            {
                ll a = (n * i * j);
                ll b = (4 * i * j - n * j - n * i);
                if (b > 0 && a % b == 0)
                    return cout << i << " " << j << " " << a / b << endl, 0;
            }
    }
    else
        cout << n << " " << n << " " << n / 2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    while(cin>>n){
        string s;
        int c=0;
        rep(i,n){
            char a;int b;
            cin>>a>>b;
            if(a=='('){
                c+=b;
            }
            else c-=b;
            if(c<0){
                cout<<"NO"<<endl;
                goto next;
            }
        }
        if(c==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        next:;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, b[N], a[N];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",b+i);
	for(int i=1;i<=n;++i) {
		for(int j=n-i+1;j>=1;--j)
			if(b[j]==j) {
				a[i]=j; break;
			}
		if(!a[i]) return puts("-1"),0;
		for(int j=a[i];j<=n-i;++j) b[j]=b[j+1];
	}
	for(int i=n;i>=1;--i) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<string>
#include<math.h>

using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define mod 1000000007
	ll r,c,K;
ll dp[3005][3005][4];
ll col[3005][3005]={0};
ll cd(ll a,ll b)
{
	if(a==0)return b;
	else if (b==0)return a;
	else return cd(b,a%b);
}
ll f(ll x,ll y,ll cou)
{
	if(x>r||y>c)return -1e16;

	if(dp[x][y][cou]!=-1)return dp[x][y][cou];
	if(x==r&&y==c)
	{
		if(cou<3)return col[x][y];
		else return 0;
	}
	else
	{
		ll tem=0;
		if(cou<3)
		{
			tem=max(tem,col[x][y]+f(x,y+1,cou+1));
			tem=max(tem,col[x][y]+f(x+1,y,0));
			tem=max(tem,f(x,y+1,cou));
			return dp[x][y][cou]=tem;
		}
		else
		{
			tem=max(tem,f(x,y+1,cou));
			tem=max(tem,f(x+1,y,0));
			return dp[x][y][cou]=tem;
		}
		
	}
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>r>>c>>K;
	for(int i=0;i<3005;i++)
	{
		for(int j=0;j<3005;j++)
		{
			col[i][j]=0;
			for(int k=0;k<4;k++)dp[i][j][k]=-1;
		}
	}
	
	for(int i=0;i<K;i++)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		col[x][y]=z;
	}
	ll ans=f(1,1,0);
	cout<<ans<<endl;
	return 0;
	
}




Measured memory_bytes: 356392
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		long n[]=new long[3],t;
		int i,j;
		for(i=0;i<3;i++) n[i]=stdIn.nextLong();
		for(i=0;i<2;i++) {
			for(j=2;j>i;j--) {
				if(n[j-1]>n[j]) {
					t=n[j-1];
					n[j-1]=n[j];
					n[j]=t;
				}
			}
		}
		System.out.print(n[0]*n[1]*((n[2]+1)/2)-n[0]*n[1]*(n[2]/2));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

typedef pair<int, int> pint;
typedef vector<pint> vpint;

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

    string s;
    int p;
    map<string, vpint> mp;
    rep(i, n) {
        cin >> s >> p;
        mp[s].push_back(pint (p, i+1));
    }

    for (auto S : mp) {
        vpint tmp = S.se;
        sort(rall(tmp));
        for (pint x : tmp) {
            cout << x.se << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 220000
using namespace std;
int Next[N],v[N],w[N],h[N],f[N],du[N],tot;
int n;
vector<int>ans;
int add(int x,int y){
	tot++;
	Next[tot]=h[x];
	v[tot]=y;
	h[x]=tot;
	du[x]++;
	du[y]++;
}
int dfs(int x,int fa){
	bool flag=false;
	for(int i=h[x];i;i=Next[i]){
		if(v[i]==fa)continue;
		dfs(v[i],x);
		f[x]+=f[v[i]];
		if(!f[v[i]]){
			if(!flag)flag=true;
			else ans.push_back(v[i]),f[x]++;
		}
	}
}
int main(){
	int T=1;
//	scanf("%d",&T);
	while(T--){
		ans.clear();
		memset(h,0,sizeof(h));
		memset(f,0,sizeof(f));
		memset(du,0,sizeof(du));
		scanf("%d",&n);
		for(int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			x++;
			y++;
			add(x,y);
			add(y,x);
		}
		bool flag=true;
		for(int i=1;i<=n;i++){
			if(du[i]>4){
				dfs(i,0);
				printf("%d\n",f[i]);
			//	for(int i=0;i<ans.size();i++)printf("%d ",ans[i]);
			//	printf("\n");
			flag=false;
				break;
			}
		}
		if(flag)printf("%d\n",1);
		
	}
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll N;
  cin>>N;
  vector <vector <ll>> a(N,vector <ll> (2));
  vector <vector <ll>> b(N,vector <ll> (2));
  for(ll i = 0;i<N;i++){
    cin>>a[i][0] >> a[i][1];
    b[i][0] = a[i][0]-a[i][1];
    b[i][1] = a[i][0]+a[i][1];
  }
  ll aa = -INF,bb = INF,cc = -INF,dd = INF;
  for(ll i = 0;i<N;i++){
    aa = max(aa,b[i][0]);
    bb = min(bb,b[i][0]);
    cc = max(cc,b[i][1]);
    dd = min(dd,b[i][1]);
  }
  //cout << aa << bb << cc << dd << endl;
  cout << max((aa-bb),(cc-dd)) << endl;
  return 0;
}

Measured memory_bytes: 25176
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    unsigned long long int x;
    cin>>x;
    if(x<=6){
        cout<<"1";
        return 0;
    }
    if(x<=11){
        cout<<"2";
        return 0;
    }
    unsigned long long int result=x/11;
    unsigned long long int rem=x%(result*11);
    if(rem<=6){
        result*=2;
        if(rem!=0)
        result++;
    }
    else
    {
        result*=2;
        result+=2;
    }
    cout<<result;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n>>x>>y;
    cout<<min(n*x,y);    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

vector<int> G[100010];
int dp[100010];

int dfs(int v) {
	if (dp[v] >= 0) return dp[v];
	for (auto to : G[v]) {
		dp[v] = max(dp[v], dfs(to) + 1);
	}
	return max(0, dp[v]);
}

int main()
{
	int N,M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}
	for (int i = 0; i < N; i++) dp[i] = -1;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, dfs(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 7424
n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    b,c = 0,0
    for i in range(len(a)):
        if b < a[i]:
            b = a[i]
            continue
        if c < a[i]:
            c = a[i]
            continue
        print("NO")
        break
    else:
        print("YES")

Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N;
double p[maxn];
double f[3030][3030];
int main(){
    // debug;
    ios;

    cin>>N;
    for(int i = 1;i<=N;i++) cin>>p[i];
    f[1][1] = p[1]; f[1][0] = 1-p[1];
    for(int i = 2;i<=N;i++){
        for(int j = 0;j<=i;j++){
            if(j == 0) {
                f[i][0] = f[i-1][0] * (1-p[i]);
                continue;
            }
            if (j-1>=0) f[i][j] += f[i-1][j-1] * p[i];
            f[i][j] += f[i-1][j] * (1-p[i]);
        }
    }
    double ans = 0;
    for(int i = 1;i<=N;i++){
        if(i > N-i) ans += f[N][i];
    }
    cout.precision(10);
    cout<<ans<<'\n';

    
    return 0;
}


Measured memory_bytes: 72320
n,k = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
x = sorted(x,key=lambda x:x[0])
tem = x[0][1]
i = 0
while k-tem > 0:
    i += 1
    tem += x[i][1]
print(x[i][0])

Measured memory_bytes: 29912