akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

double Dxy(int* x,int* y,int n, int p);

int main(void){
        int n=0;
        int x[100]={0};
        int y[100]={0};
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>x[i];
        }
        for(int i=0; i<n; i++) {
                cin>>y[i];
        }
        for(int i=1;i<=3;i++){
            printf("%lf\n",Dxy(x,y,n,i));
        }

        int p_inf=0;
        for(int i=0;i<n;i++){
            p_inf=max(abs(x[i]-y[i]),p_inf);
        }
        cout<<p_inf<<endl;

        return 0;
}


double Dxy(int* x,int* y,int n, int p){
    double d=0;
    for(int i=0;i<n;i++){
        d+=pow(abs(x[i]-y[i]),p);
    }
    d=pow(d,1.0/p);
    return d;
}



Measured memory_bytes: 3396
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int arr[26] = {0};
    forn(i,s.size()){
        arr[s[i]-'a']++;
    }
    forn(j,26){
        if(arr[j]%2 != 0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll k, n;
    cin >> k >> n;
    vll a(n + 1);
    ll s = 0;
    REP(i, n) {
        cin >> a[i];
    }
    a[n] = a[0] + k;
    ll res = 1e10, d;
    REP(i, n) {
        d = a[i + 1] - a[i];
        res = min(res, k - d);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
h,w,m=map(int,input().split())

H,W=[0]*h,[0]*w
P=set()

for i in range(m):
  y,x=map(int,input().split())
  H[~-y]+=1
  W[~-x]+=1
  P.add(~-y*w+~-x)

mh,mw=max(H),max(W)
MH=[i for i,h in enumerate(H) if h==mh]
MW=[i for i,v in enumerate(W) if v==mw]
for y in MH:
  for x in MW:
    if y*w+x not in P:
      print(mh+mw)
      exit()

print(mh+mw-1)


Measured memory_bytes: 61712
x, k, d = map(int, input().split())

x = abs(x)

ans = 0

t = x // d
s = x % d

if abs(x) > k * d:
    print(abs(x) - k * d)
elif t % 2 == k % 2:
    print(s)
else:
    print(d - s)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n;
  vector<pair<int,int>> v(n);
  for(int i = 0;i < n;i++){
    cin >> a >> b;
    v.at(i).first = a;
    v.at(i).second = b;
    }
    sort(v.begin(),v.end());
    for(int l = 0;l < n;l++){
      cout << v.at(l).first << " " <<v.at(l).second << endl;
    }
  }
  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int A,B;
    cin >> A >> B;
    if ((A!=1) &&(B!=1))
    cout << 1 <<endl;
    if ((A!=2) &&(B!=2))
    cout << 2 <<endl;
    if ((A!=3) &&(B!=3))
    cout << 3 <<endl;

    
    // system("pause");
    return 0;
}

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

int main() {
  int n,m;
  bitset<100000> bad;
  cin >> n >> m;
  vector<int> hight(n);
  rep(i,n)cin >> hight.at(i);
  rep(i,m){
   int a,b; 
   cin >> a >> b;
   if(hight.at(a-1) <= hight.at(b-1))bad.set(a-1,1);
   if(hight.at(b-1) <= hight.at(a-1))bad.set(b-1,1);
  }
  int result = n;
  rep(i,n)if(bad.test(i))result--;
  cout << result <<endl;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

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

  int n;
  cin >> n;

  ll sum = 0;

  REP(i, n) {
    REP(j, n) {
      REP(k, n) {
        sum += gcd(i, gcd(j, k));
      }
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int r,g,b;
  scanf("%d %d %d",&r, &g, &b);
  int val = (r * 100) + (g * 10) + b;
  if((val % 4) == 0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int sum = (a + b) * h / 2;
        System.out.println(sum);
    }
}

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

int main() {
  int sum = 0;
  int x = 10;
  for (int i = 0; i < 5; i++) {
      int A;
      cin >> A;
      if(A%10==0) {
          sum += A;
          continue;
      }
      sum += A/10*10+10;
      x = min(x, A%10);
  }
  cout << sum - 10 + x << endl;
}

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

inline bool chmax(float a, float b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

float i, j;

int main()
{
    int l;

    cin >> l;

    printf("%.12f\n", (double)l * l * l / 27);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE];
map<int,int>H;
int main(){
   DRI(N);
 REP(i,N){RI(a[i]);H[a[i]]=i&1;}
 sort(a,a+N);
 int an=0;
 REP(i,N)an+=H[a[i]]^(i&1);
 cout<<an/2<<endl;
 return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int N, m = 0, x = 0;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if(A.at(i) > m) 
        {
            x = m;
            m = A.at(i);
        }
        else if (A.at(i) > x)
        {
            x = A.at(i);
        }
    }
    for(int i = 0; i < N; i++)
    {
        if(A.at(i) < m) cout << m <<endl;
        else cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max(0ll, min(b, d) - max(a, c));

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s, t;
    cin >> s >> t;
    
    rep(i, 1001)
    {
        if (stoi(s + t) == i * i)
        {
            OP("Yes");
            return 0;
        }
    }
    OP("No");
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

u={i:[] for i in range(1,n+1)}

for i in range(m):
    ui,vi=map(int,input().split())
    u[ui].append(vi)

s,t = map(int,input().split())
current=[s]
dist={s:0}
for i in range(n):
    for j in range(3):
        next=set()
        for uj in current:
            for vj in u[uj]:
                next.add(vj)
        current=next
    current=[]
    for vj in next:
        if vj not in dist:
            dist[vj]=i+1
            current.append(vj)
    if len(current)==0:
        break

print(-1 if t not in dist else dist[t])


Measured memory_bytes: 41576
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,M,V,P=map(int,input().split())
A=sorted(list(map(int,input().split())))
_SUM=sum(A[:N-(P-1)])



def main(i):

    B=[A[m] for m in range(N-(P-1)) if m!=i]

    C=A[i]+M
    a=V-P

    if C<A[-P]:
        return(0)
    else:
        if a>0:
            Votenum=a*M
            for b in B:
                Votenum-=min(C-b,M)
                if Votenum<=0:
                    return(1)

            return(0)
        else:
            return(1)




if main(0):
    print(N)
    exit()
st=0
end=N-P+1

while 1:
    a=(st+end)//2
    if main(a):
        end=a
    else:
        st=a

    if end-st<=1:
        break

if main(st):
    print(N-st)
else:
    print(N-end)


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

int main(){
  int N,maxcount=0,maxA=1;
  cin >> N;
  for(int i=0;i<N;i++){
    int A=i+1,count=0;
    while(true){
      if(A%2==1){
        break;
      }
      else{
        A/=2;
        count++;
      }
    }
    if(maxcount<count){
      maxcount=count;
      maxA=i+1;
    } 
  }
  cout << maxA << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin>>n;
  ll mini = INF;
  for (ll i = 1; i <= sqrt(n);i++){
    if(n%i==0){
      ll a = i, b = n / i;
      ll sza = 0, szb = 0;
      while (a > 0){
        a /= 10;
        sza++;
      }
      while(b>0){
        b /= 10;
        szb++;
      }
      ll m = max(sza, szb);
      chmin(mini, m);
    }
  }
  print(mini);
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] input = new int[n];
        for(int i=0;i<n;i++){
            input[i] = sc.nextInt();
        }

        long maxcount =0;
        long count= 0;
        for(int i=1;i<n;i++){
            if(input[i-1] >= input[i]){
                count++;
            }else{
                if(maxcount < count){
                    maxcount = count;
                }
                count=0;
            }
        }

        if(maxcount < count){
            maxcount = count;
        }


        System.out.println(maxcount);



    }
    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }


}

Measured memory_bytes: 50080
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
    //10^9<INT_MAX(2,147,483,647)<10^10
    public void run() {
        long a=sc.nextLong(),b= sc.nextLong();
        ln(String.format("%d %d %.8f", a/b,a%b,(double)a/b));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 26564
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Xml;
class M
{

    public static int Main()
    {
        test t = new test();
        t.calc();
        return 0;
    }
}

class test
{
    int[] dp = new int[2010];

    public void calc()
    {
        int MOD = (int)Math.Pow(10.0, 9) + 7;
        for(int i = 3;i < 2010; i++)
        {
            dp[i] = 1;
            for(int j = 3; j <= i / 2; j++)
            {
                if (j == i - j)
                {
                    dp[i] += dp[j];
                }
                else
                {
                    dp[i] += (dp[j] + dp[i - j]) % MOD;
                }
                dp[i] %= MOD;
            }
        }

        Console.WriteLine(dp[int.Parse(Console.ReadLine())]);
    }
}



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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    rep(i, x) {
        cin >> a[i];
    }
    rep(i, y) {
        cin >> b[i];
    }
    rep(i, z) {
        cin >> c[i];
    }
    
    ll sum12[x*y];
    int t1 = 0;
    rep(i, x) {
        rep(j, y) {
            sum12[t1] = a[i] + b[j];
            t1++;
        }
    }

    sort(sum12, sum12+x*y);
    reverse(sum12, sum12+x*y);

    int m = min(x*y, k);
    ll d[m];
    rep(i, m) {
        d[i] = sum12[i];
    }
    
    int t2 = 0;
    ll sum[m*z];
    rep(i, m) {
        rep(j, z) {
            sum[t2] = d[i] + c[j];
            t2++;
        }
    }

    sort(sum, sum+m*z);
    reverse(sum, sum+m*z);

    rep(i, k) {
        cout << sum[i] << "\n";
    }
    
    return 0;
}

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

bool pos[200010];

int main(){
  int N;
  int M;
  std::cin>>N>>M;
  for(int i=0;i<M;++i){
    int x;
    std::cin>>x;
    x+=1e5;
    pos[x]=true;
  }
  int s=0,t=200010;
  while(!pos[s])++s;
  while(!pos[t-1])--t;
  int ans=t-s;
  std::priority_queue<int> pq;
  int cnt=0;
  for(int i=s;i<t;++i){
    if(!pos[i])++cnt;
    if((i==t-1&&!pos[i])||pos[i]){
      pq.push(cnt);
      cnt=0;
    }
  }
  for(int i=0;i<N-1&&!pq.empty();++i){
    ans-=pq.top();
    pq.pop();
  }
  ans=std::max(ans-N,0);
  std::cout<<ans<<std::endl;
  
  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	ll ans = 0;
	cin >> n;

	int f[n + 1], s[n + 1];
	
	f[0] = 0; s[0] = 0;
	
	for (int i = 1; i <= n; i++)
	{
		cin >> k;
		f[i] = f[i - 1] + k;
		s[i] = s[i - 1] ^ k;
	}
	
	int l = 1;
	
	for (int r = 1; r <= n; r++)
	{
		while ((f[r]-f[l-1]) != (s[r]^s[l-1])) l++;
		ans += r - l + 1;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var amount = parseInt(tmp[0], 10);
	var total = parseInt(tmp[1], 10);
  	var current = amount*500
	//出力
	if(current >= total) {
	  return console.log('Yes') 
    } else {
      return console.log('No')
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
// Problem : F - Intervals on Tree
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

int n;

void solve(){
    cin>>n;
    int ans = n*(n+1)*(n+2)/6;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--, v--;
        if(u > v) swap(u,v);
        ans -= (u+1)*(n-v);
    }
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	try{
		//while(1)
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
#ifdef XS
		printf("%s","exception");
#endif
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 2e5+100;
ll sum[N];
void inp(){
	int n;
	scanf("%d",&n);
	MS(sum);
	for(int i =1;i<=n;i++){
		scanf("%lld",&sum[i]);
		sum[i]+=sum[i-1];
	}
	ll ans = abs(sum[n]-sum[n-1] - sum[n-1]);
	for(int i =1;i<n;i++){
		ll a = sum[i];
		ll b = sum[n]-sum[i];
		ans  = min(ans, abs(b-a));
	}
	printf("%lld\n", ans);
}
//C.cc by xsthunder at Sat Jul 15 20:02:11 2017


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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 GetDigit(int num) {
  int digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

void solve() {
  int n;
  cin >> n;
  vi A;
  rep(i, 0, n) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  int m = 1;
  rep(i, 0, n) {
    if (1000000000000000000 / m < A[i]) {
      m = -1;
      break;
    }
    m = m * A[i];
  }

  rep(i, 0, n) {
    if (A[i] == 0) {
      m = 0;
      break;
    }
  }

  cout << m << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 4284
#include <cstdio>
#include <cstring>
using namespace std;

#define M 1046527
#define L 14

char H[M][L];

/* https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_C
input:
6
insert AAA
insert AAC
find AAA
find CCC
insert CCC
find CCC

output:
yes
no
yes

input2:
13
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
insert T
find TTT
find T

output2:
yes
no
no
yes
yes
yes
 */
int getChar(char ch) {
    if(ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M-1)); }
long long getKey(char str[]) {
    long long sum = 0, p = 1;
    for (int i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
int insert(char str[]) {
    long long key, h;
    key = getKey(str);
    for (int i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}
int find(char str[]) {
    long long key, h;
    key = getKey(str);
    for (int i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}
int main() {
    int n;
    char com[10], str[12];

    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%s %s", &com, str);
        
        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 16800
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<vector>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
typedef double DB;
const DB pi=acos(-1.0);
int main(){
	char d[25]="CODEFESTIVAL2016";
	char s[26];
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	rep(i,0,n-1)if(s[i]!=d[i])ans++;
	printf("%d\n",ans);
	return 0;
}











Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
//			System.out.println(Math.min(a, b));
			 System.out.println(a - 1 + (a <= b ? 1 : 0));
		}
	}
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    map<char, int> cnt;
    char ch;
    for (int i = 0; i < n; ++i) {
        cin >> ch;
        ++cnt[ch];
    }

    if (1 <= cnt['Y']) cout << "Four\n";
    else cout << "Three\n";

    return 0;
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    /// a + b = x
    /// 2a + 4b = y

    int x, y;
    cin >> x >> y;

    if (y % 2 != 0) {
        return cout << yn(0) << "\n", 0;
    }

    int z = y - 2 * x;
    if (z < 0 || z % 2 != 0) {
        return cout << yn(0) << "\n", 0;
    }

    int b = z / 2;
    int a = x - b;

    if (a < 0) {
        return cout << yn(0) << "\n", 0;
    }

    cout << yn(1) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3624
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    if (K == 0) {
        std::cout << N*N << std::endl;
        return 0;
    }
    
    int64_t ans = 0;
    for (int64_t b = K+1; b <= N; ++b) {
        ans += (N+1)/b * (b-K);
        ans += std::max((int64_t)0, (N+1)%b - K);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long counter[100005];

int main(){
	int n;
	cin>>n;
	long long total=0;
	while(n--){
		int a;
		cin>>a;
		total+=a;
		counter[a]++;
	}
	int q;
	cin>>q;
	while(q--){
		int from,to;
		cin>>from>>to;
		total-=counter[from]*from;
		total+=counter[from]*to;
		counter[to]+=counter[from];
		counter[from] = 0;
		cout<<total<<'\n';
	}
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[515115];
int p[515115];
int dp[515115];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; a[i]--; p[a[i]]=i;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		dp[i] = 1;
		if(i>0&&p[i]>p[i-1])
		{
			dp[i] = max(dp[i], dp[i-1]+1);
		}
		ans=max(ans,dp[i]);
	}
	cout<<n-ans<<'\n';
}	


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

using namespace std;


int main(int argc, char** argv){
    int N;
    string S;
    cin >> N >> S;

    vector<int> W(N);
    if (S[0] == '.') W[0] = 1;
    else W[0] = 0;
    for (int i=1; i<N; i++){
        if (S[i] == '.') W[i] = W[i-1]+1;
        else W[i] = W[i-1];
    }

    vector<int> rev(N);
    for (int i=0; i<N; i++)
        rev[i] = (i+1-W[i]) + (W[N-1]-W[i]);

    /*
    for (int i=0; i<N; i++) cerr << W[i] << " ";
    cerr << "\n";
    for (int i=0; i<N; i++) cerr << rev[i] << " ";
    cerr << "\n";
    */
    int ans = *min_element(rev.begin(), rev.end());
    ans = min(ans, W[N-1]);
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 2180
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<char,char> pcc;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> t3;

#define rep(i,a) for(ll i = 0;i < a;i++)

template <class T>
void cmax(T& a, const T b){a=max(a,b);}

int main(void) {
    ll h,w;
    cin >> h >> w;
    vector<vector<ll>> grid(h, vector<ll>(w, 0));
    rep(y,h)rep(x,w){
        cin >> grid[y][x];
    }
    vector<tuple<int,int,int,int>> ans;
    rep(y,h-1){
        if(y%2 == 0)
        {
            rep(x, w-1){
                if(grid[y][x] % 2 == 1){
                    grid[y][x]--;
                    grid[y][x+1]++;
                    ans.emplace_back(x,y,x+1,y);
                }
            }
            if(grid[y][w-1] % 2 == 1){
                grid[y][w-1]--;
                grid[y+1][w-1]++;
                ans.emplace_back(w-1,y,w-1,y+1);
            }
        }
        else{
            rep(x, w-1){
                int dx = w-1-x;
                if(grid[y][dx] % 2 == 1){
                    grid[y][dx]--;
                    grid[y][dx-1]++;
                    ans.emplace_back(dx,y,dx-1,y);
                }
            }
            if(grid[y][0] % 2 == 1){
                grid[y][0]--;
                grid[y+1][0]++;
                ans.emplace_back(0,y,0,y+1);
            }
        }
    }
    int y = h-1;
    if(y%2 == 0)
    {
        rep(x, w-1){
            if(grid[y][x] % 2 == 1){
                grid[y][x]--;
                grid[y][x+1]++;
                ans.emplace_back(x,y,x+1,y);
            }
        }
    }
    else{
        rep(x, w-1){
            int dx = w-1-x;
            if(grid[y][dx] % 2 == 1){
                grid[y][dx]--;
                grid[y][dx-1]++;
                ans.emplace_back(dx,y,dx-1,y);
            }
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans){
        int x1,y1,x2,y2;
        tie(x1,y1,x2,y2) = p;
        cout << y1+1 << " " << x1+1 << " " << y2+1 << " " << x2+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 6128
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
	int n,k;
	cin>>n>>k;
	
	double res = 0;
	
	for (int i=1; i<=n; i++) {
		double tmp = 1.0/n;
		int cur = i;
		while(cur < k) {
			cur*=2;
			tmp/=2;
		}
		res+=tmp;
	}
	
	printf("%.12f\n",res);
	return 0;
}


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

int main(){
    int x, a, b;
    cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b)){
        cout<<"A"<<endl;
    }
    else{
        cout<<"B"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<long>();
            var gcd = 1L;
            for (var i = 1L; i * i <= M; ++i)
            {
                if (M % i == 0 && (N <= i || N <= M / i))
                {
                    var t = Max(N <= i ? M / i : 1L, N <= M / i ? i : 1L);
                    gcd = Max(gcd, t);
                }
            }
            WriteLine(gcd);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

int inf=1e9;
struct segtree{
	static const int N=1<<18;
	int seg[N*2];
	segtree(){
		rep(i,N*2) seg[i]=0;
	}
	segtree(vector<int>& vi){
		rep(i,N*2) seg[i]=0;
		rep(i,vi.size()) seg[N+i]=vi[i];
		for(int i=N-1;i>0;i--) seg[i]=max(seg[i*2],seg[i*2+1]);
	}


	void update(int x,int v){
		x+=N;
		chmax(seg[x],v);
		x/=2;
		while(x){
			seg[x]=max(seg[x*2],seg[x*2+1]);
			x/=2;
		}
	}
	int getmax(int a,int b,int l=0,int r=N,int k=1){
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];
		return max(getmax(a,b,l,(l+r)/2,k*2),getmax(a,b,(l+r)/2,r,k*2+1));
	}
}seg[2];

vector<int> xs;
const int MN=100000;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int a[MN],b[MN],c[MN];
int main(){
	int N;
	cin>>N;
	vector<PP> vp;
	rep(i,N) cin>>a[i]>>b[i];
	rep(i,N) xs.pb(a[i]),xs.pb(b[i]);
	sort(all(xs));
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	rep(i,N) a[i]=lower_bound(all(xs),a[i])-xs.begin(),b[i]=lower_bound(all(xs),b[i])-xs.begin();
	rep(i,N){
		vp.pb(PP(P(a[i],-b[i]),0));
		vp.pb(PP(P(b[i],-a[i]),1));
	}
	sort(all(vp));

	int K = xs.size();
	int ans=0;

	vector<P> upd[2];
	rep(i,N*2){
		PP pp=vp[i];
		int x = pp.fs.fs,y=-pp.fs.sc,c=pp.sc;
		int mx = seg[c].getmax(0,y)+1;
		chmax(ans,mx);
//		seg[1-c].update(y,mx);
		upd[1-c].pb(P(y,mx));
		if(i==N*2-1 || x!=vp[i+1].fs.fs){
			rep(t,2){
				for(P p:upd[t]) seg[t].update(p.fs,p.sc);
				upd[t].clear();
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13476
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
 
int N, M;
vector<bool> issafe; // issafe[v] := v が壊れていないかどうか
 
int main() {
    cin >> N >> M;
    issafe.assign(N+1, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false; // a 段目は壊れてる
    }
 
    // DP テーブル
    vector<int> dp(N+1, 0); // 各段について 0 で初期化しておく
 
    // 初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;
 
    // ループ
    for (int n = 2; n <= N; ++n) {
        if (issafe[n-1]) dp[n] += dp[n-1]; // n-1 段目が安全なら
        if (issafe[n-2]) dp[n] += dp[n-2]; // n-2 段目が安全なら
        dp[n] %= MOD; // 1000000007 で割る
    }
    cout << dp[N] << endl;
}





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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);

    sort(a.begin(), a.end());

    int x = 0, y = 0;
    bool t = true;
    for (int i = n-1; i >= 0; i--) {
        if (t) {
            x += a.at(i);
            t = false;
        } else {
            y += a.at(i);
            t = true;
        }
    }

    cout << x - y << endl;

    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;
class TSAL
    {
        static void Main(string[] args)
        {
            int tmp;

            string[] input = Console.ReadLine().Split(' ');

            int k = int.Parse(input[0]);

            int n = int.Parse(input[1]);

            int[] a = Console.ReadLine().Split(' ').Select((x) => int.Parse(x)).ToArray();

            int maxD = a[0] - a[n-1] + k;

            for (int i = 1; i < a.Length; i++)
            {
                tmp = a[i] - a[i - 1];
                if (maxD < tmp)
                {
                    maxD = tmp;
                }
            }
            Console.WriteLine(k - maxD);
        }
    }

Measured memory_bytes: 32732
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
using namespace std;

long K;

int main() {
  cin >> K;
  long N = 50;
  long rem = K%N;
  long base = K/N + (N-1);
  cout << N << endl;
  if (K < 50) {
    rep(i,N) {
      if (i < K) {
        cout << 50;
      } else {
        cout << 0;
      }
      if (i!=N-1) {
        cout << ' ';
      }
    }
    cout << endl;
    return 0;
  }
  
  rep(i,N) {
    long ans = base;
    if (i < rem) {
      ans = ans + N - rem + 1;
    } else {
      ans = ans - rem;
    }
    cout << ans;
    if (i!=N-1) {
      cout << ' ';
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);
		int eles[];
		eles=new int[3];

		eles[0] = kb.nextInt();
		eles[1] = kb.nextInt();
		eles[2] = kb.nextInt();
		
		int tmp;
		for( int i=0; i<3; i++) {
			for( int j=i+1; j<3; j++) {
				if( eles[j] < eles[i] ) {
					tmp=eles[i];
					eles[i]=eles[j];
					eles[j]=tmp;
				}
			}
		}
		System.out.println( eles[0]+" "+eles[1]+" "+eles[2] );	
	}
}

Measured memory_bytes: 17180
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES(t)           ll t;cin>>t;while (t--)
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
using namespace std;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    string s;
    cin>>s;
    for (ll i=0;s[i];i++)
    {
        if (s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
static const int MAX =100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin>>e;
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  cout<<prim()<<endl;
  return 0;
  
}



Measured memory_bytes: 3112
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		int min = 753;
		for(int i = 0; i < st.length() - 2; i ++) {
			min = Math.min(min, Math.abs(Integer.parseInt(st.substring(i, i + 3)) - 753));
		}
		System.out.println(min);
	}
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b<a)swap(a,b);
    if(c<b)swap(b,c);
    if(b<a)swap(a,b);
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

const int mod = 1e9 + 7;

inline int add(int a, int b)
{
	auto res = (a + b) % mod;
	if(res < 0)
		res += mod;

	return res;
}

inline int mult(int a, int b)
{
	auto res = (1LL*a*b)%mod;
	if(res < 0)
		res += mod;
	return res;
}

int power(int base, int exp)
{
	if(exp == 0)
		return 1;

	auto half = power(base, exp/2);
	auto full = mult(half, half);
	if(exp %2 != 0)
		full = mult(full, base);

	return full;
}

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

	int ans = power(10, n);
	ans = add(ans, mult(-2, power(9, n)));
	ans = add(ans, power(8, n));

	cout << ans << endl;
}

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

	solve();
	return 0;
}


Measured memory_bytes: 3632
import numpy as np

N = int(input())

cnt1 = np.cumsum(list(map(int, input().split())))
cnt2 = list(map(int, input().split()))
cnt2 = cnt2[::-1]
cnt2 = np.cumsum(cnt2)
cnt2 = cnt2[::-1]

max_candies = 0

for i in range(N):
    if max_candies <= cnt1[i] + cnt2[i]:
        max_candies = cnt1[i] + cnt2[i]

print(max_candies)


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

typedef long long ll;

ll N, M, S, T;
vector<vector<ll>> Out;
// v, 0/1/2, dist
typedef tuple<ll, ll, ll> Info;
queue<Info> Queue;
vector<vector<bool>> Seen;

ll solve() {
  Queue.push(make_tuple(S, 0, 0));
  Seen.resize(N);
  for (auto &seen : Seen) seen.resize(3);
  while (!Queue.empty()) {
    ll v, s, d;
    tie(v, s, d) = Queue.front();
    Queue.pop();
    if (v == T && s == 0) return d;
    if (Seen[v][s]) continue;
    Seen[v][s] = true;
    for (ll w : Out[v]) {
      Queue.push(make_tuple(w, (s + 1) % 3, d + (s == 0 ? 1 : 0)));
    }
  }
  return -1;
}
int main() {
  cin >> N >> M;
  Out.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll u, v;
    cin >> u >> v;
    --u;
    --v;
    Out[u].push_back(v);
  }
  cin >> S >> T;
  --S;
  --T;
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}


template <typename T>
struct fenwick_tree {
    int n, power; // min power s.t. n <= power && power = 2^k;
    vector<T> data;
    fenwick_tree(int n=0) : n(n), data(n+1) {
        power = 1;
        while (power < n) power <<= 1;
    }
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) data[i] += x;
    }
    // [0, i)
    T sum(int i) {
        T res = 0;
        for (; i; i -= i&-i) res += data[i];
        return res;
    }
    // [l, r)
    T sum(int l, int r) { return sum(r) - sum(l);} 
    // min x s.t. v0 + v1 + v2 + ... + vx　>= w
    int lower_bound(T w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int i = power; i; i >>= 1) {
            if (i+x <= n && data[i+x] < w) {
                w -= data[i+x];
                x += i;
            }
        }
        return x;
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) cin >> c[i], c[i]--;

    vector<tuple<int, int, int>> rlid(q);
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        rlid[i] = make_tuple(r, l, i);
    }
    sort(rlid.begin(), rlid.end());
    
    vector<int> ans(q);
    fenwick_tree<int> ft(n);
    vector<int> last(n, -1);

    int nowr = -1;
    rep(i, q) {
        int l, r, id;
        tie(r, l, id) = rlid[i];
        while (nowr < r) {
            nowr++;
            if (last[c[nowr]] != -1) ft.add(last[c[nowr]], -1);
            ft.add(nowr, 1);
            last[c[nowr]] = nowr;
        }
        ans[id] = ft.sum(l, r + 1);
    }
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 17384