akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
const int M=2005;
LL dp[M][M];

vector<PII> vec;

int main()
{
	int n;
	scanf("%d",&n);
	int ai;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&ai);
		vec.push_back({ai,i});
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++)
		dp[i][i]=abs(vec[0].second-i)*vec[0].first;
	for(int len=2;len<=n;len++)
	{
		for(int l=0,r=len-1;r<n;l++,r++)
		{
			LL p=vec[len-1].second,ai=vec[len-1].first;
			dp[l][r]=max(dp[l+1][r]+abs(p-l)*ai,dp[l][r-1]+abs(p-r)*ai);
		}
	}
	printf("%lld\n",dp[0][n-1]);
	return 0;
}

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

using namespace std;
int vis[100005];
int res=0;
vector<vector<int>> adj(100005);
void dfs(int cur){
    vis[cur]=1;
    for(int i=0;i<adj[cur].size();i++){
        int ch=adj[cur][i];
        if(!vis[ch]){
            dfs(ch);
        }
    }
}

int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int x[m],y[m],z[m];
    for(int i=0;i<m;i++){
        cin>>x[i]>>y[i]>>z[i];
        adj[x[i]].push_back(y[i]);
        adj[y[i]].push_back(x[i]);
    }
    for(int i=1;i<=n;i++){
        if(adj[i].size()==0){
            res++;
        }
        else{
            if(!vis[i]) {
                dfs(i);
                res++;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int n;
int A[1000000];
long cnt;
vector<int>G;

void insertionSort(int A[], int n, int g){
    for(int i=g; i<n; i++){
        int v=A[i];
        int j=i-g;
        while(j>=0 && A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shellSort(int A[], int n){
    //数列G｛１，４，１３，４０，、、、｝
    for(int h=1; ; ){
        if(h>n)break;
        G.push_back(h);
        h = 3*h + 1;
    }
    
    for(int i=G.size()-1; i>=0; i--){
        insertionSort(A, n ,G[i]);
    }
}

int main(){
    cin>>n;
    for(int i=0; i<n; i++)scanf("%d", &A[i]);
    cnt=0;
    
    shellSort(A, n);
    
    cout<<G.size()<<endl;
    for(int i=G.size()-1; i>=0; i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0; i<n; i++)printf("%d\n", A[i]);
    
    return 0;
}



Measured memory_bytes: 7160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
vll v[N];
ll dp[N];
vll topo;
ll col[N];
bool vis[N]={false};
void dfs1(ll i)
{
    col[i]=1;
    for(auto x:v[i])
    {
        if(col[x]==0){
            dfs1(x);
        }
    }
    col[i]=2;
    topo.pb(i);
}
void dfs(ll i)
{
    for(auto x:v[i]){
        dp[x]=max(dp[x],dp[i]+1);
    }

}
void solve()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    for(ll i=1;i<=n;i++){
        if(!col[i]){
            dfs1(i);
        }
    }
    reverse(all(topo));
    //dp[topo[0]]=1;
    for(ll i=0;i<sz(topo);i++){
        ll z=topo[i];
        dfs(z);
    }
    ll mx=-1;
    for(ll i=1;i<=n;i++)
        mx=max(mx,dp[i]);
    cout << mx <<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 13428
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

class UnionFind {
 protected:
  vl data;

 public:
  UnionFind(int size) : data(size, -1) {}
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) {
        swap(x, y);
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  //
  ll n;
  cin >> n;
  vl x(n), y(n);
  map<ll, ll> mx, my;
  rep(i, n) {
    cin >> x[i] >> y[i];
    mx[x[i]] = 0;
    my[y[i]] = 0;
  }
  int i = 0, j = 0;
  for (auto& xx : mx) mx[xx.first] = i++;
  for (auto& yy : my) my[yy.first] = j++;

  int nv = mx.size() + my.size();
  UnionFind uf(nv);
  int offset = mx.size();
  // cerr << offset << endl;
  rep(i, n) {
    ll xi = mx[x[i]];
    ll yi = my[y[i]] + offset;
    uf.unite(xi, yi);
  }
  map<ll, pair<ll, ll>> xycnt;
  rep(i, nv) {
    ll r = uf.root(i);
    if (xycnt.find(r) == xycnt.end()) {
      xycnt[r] = {0, 0};
    }
    if (i < offset) {
      // x
      xycnt[r].first++;
    } else {
      // y
      xycnt[r].second++;
    }
  }
  ll ans = 0;
  for (auto& p : xycnt) {
    auto cnt = p.second;
    // cerr << cnt.first << "," << cnt.second << endl;
    ans += cnt.first * cnt.second;
  }
  ans -= n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8832
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        List<Integer> l=new ArrayList<>();
        for(int i=0;i<n;i++){
            l.add(s.nextInt());
        }
        Collections.sort(l);
        l.set(n-1,(l.get(n-1)/2));
        int ans=0;
        for(int i=0;i<n;i++){
            ans+=l.get(i);
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 22868
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int left = stdin.nextInt() + stdin.nextInt();
		int right = stdin.nextInt() + stdin.nextInt();

		String result = "Left";
		if (left == right) {
			result = "Balanced";
		}
		else if (left < right) {
			result = "Right";
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int MOD=1e9+7;

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

    ll a,b,c,d;
    cin >>a>>b>>c>>d;
    cout <<min(a,b)+min(c,d)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t L,R;
  cin >> L >> R;
  int mod;
  int ans=2019;
  long long a=L%2019,b=R%2019;
  if((R-L)>=2018){
    for(int i=0;i<2018;i++){
      for(int j=i;j<=2018;j++){
        mod = (i*j)%2019;
        ans = min(ans ,mod);
      }
    }cout << ans << endl;
  }else{
    if(a<b){
      for(int i=a;i<b;i++){
        for(int j=i+1;j<=b;j++){
          mod = (i*j)%2019;
          ans = min(ans ,mod);
        }
      }
    }else{
      for(int i=0;i<b;i++){
        for(int j=i+1;j<=b;j++){
          mod = (i*j)%2019;
          ans = min(ans ,mod);
        }
      }for(int i=a;i<2018;i++){
        for(int j=i+1;j<=2018;j++){
          mod = (i*j)%2019;
          ans = min(ans ,mod);
        }
      }
    }
    cout << ans <<endl;
  }
}


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


int main() {
  long n,x;
  cin >>n>>x;
  
  vector<int>a(n),b(n);
  rep(i,n){
    cin>>a.at(i)>>b.at(i);
  }
  int ans=1001001001;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> s(tmp);
    int now=0;
    int ch=-1;
    int co=0;
    rep(i,n){
      if(s.test(i)){
        now+=(i+1)*100*a.at(i)+b.at(i);
        co+=a.at(i);
      }
      else{
        ch=i;
      }
    }   
    if(now<x&&x-now<100*(ch+1)*a.at(ch)){
      co+=((x-now)/100-1)/(ch+1)+1;
      ans=min(ans,co);
    }
    else if(now>=x){
      ans=min(ans,co);
    }
  }  
  cout<<ans<<endl;  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<List<Integer[]>> p = new ArrayList<>();
		int max = 0;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			List<Integer[]> ops = new ArrayList<>();
			for (int j = 0; j < Ai; j++) {
				Integer[] op = new Integer[2];
				op[0] = sc.nextInt();
				op[1] = sc.nextInt();
				ops.add(op);
			}
			p.add(ops);
		}
		for (int i = (1 << N) - 1; 0 < i; i--) {
			boolean[] ans = new boolean[N];
			int count = 0;
			for (int j = 0; j < N; j++) {
				if (((i>>j)&1) == 1) {
					ans[j] = true;
					count++;
				}
			}
			boolean flg = true;
			for (int k = 0; k < N; k++) {
				if (ans[k]) {
					for (Integer[] opi : p.get(k)) {
						if ((ans[opi[0]-1] && opi[1] == 1)
								|| (!ans[opi[0]-1] && opi[1] == 0)) {
							continue;
						} else {
							flg = false;
							break;
						}
					}
				}
			}
			if (flg) {
				if (max < count) {
					max = count;
				}
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 34736
def tripleDots(n, string):
	string_len = len(string)
	if string_len > n : 
		string = string[ 0 : n ] + "..."
	print(string)

arr = ["", ""]

for i in range(2):
	arr[i] = input()


tripleDots(int(arr[0]), arr[1])

Measured memory_bytes: 9064
# -*- coding: utf-8 -*-


def main():
    from itertools import accumulate

    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    summed_a = list(accumulate([0] + a))
    mod = 10 ** 9 + 7
    ans = 0

    for i in range(1, n):
        ans += a[i - 1] * (summed_a[n] - summed_a[i])
        ans %= mod

    print(ans % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31300
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 1e6+10;
const int inf = 1e9;
int p[mxn], x[mxn], y[mxn];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	for(int i=0; i<n; i++) cin>>x[i]>>y[i];

	for(int i=0; i<n; i++) {
		p[x[i]] = y[i];
	} 

	vector<int> appear(n+1, 0);
	vector<int> endOfComponent(n+1, 0);
	int mn = p[1]; appear[mn] = 1; int last = n;
	while(last>0 and appear[last]) last--;
	if(last==n-1) endOfComponent[1] = 1;

	for(int x0 = 2; x0<=n; x0++) {
		appear[p[x0]] = 1;
		while(last>0 and appear[last]) last--;
		if(last+x0==n) endOfComponent[x0] = 1;
	}

	/*for(int i=1; i<=n; i++) cout << endOfComponent[i] << " ";
	cout << '\n';*/

	vector<int> ans(n+1, 0);
	int prev = 0;
	for(int i=1; i<=n; i++) {
		if(endOfComponent[i]) {
			for(int j=i; j>=1; j--) {
				if(endOfComponent[j] and j!=i) break;
				ans[j] = i-prev;
			}
			prev = i;
		}
	}

	for(int i=0; i<n; i++) cout << ans[x[i]] << '\n';



	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 7896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,mx=-1;
    cin>>t;
    string s,ss;
    map<string, int> ump;
    map<string, int>::iterator it;
    for(int i=0;i<t;i++)
    {
        cin>>s; 
        ump[s]++;
        mx=max(mx,ump[s]);
    }

    for(it=ump.begin();it!=ump.end();it++)
    {
        if(it->second==mx)
        {
            cout<<it->first<<endl;
        }
    }





    return 0;
}


Measured memory_bytes: 25216
N, M = map(int, input().split())
List = list(range(1,M))
anser = []
def judge(N,M,List,anser):
  for i in range(N):
    L = list(map(int, input().split()))
    del L[0]
    if i==0:
      anser.extend(L)
    else:
      anser = list(set(L)&set(anser))
    
    
  print(len(anser))
judge(N,M,List,anser)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long ncrmodp(long ans,long rkai,long nmrkai){

  long const mod = 1000000007;
  long tmp = (rkai*nmrkai)%mod;
  long i;

  for(i=1;i<=(mod-2);i*=2){
    if(i & (mod-2)){
      ans *= tmp;
      ans %= mod;
    }
    tmp = tmp*tmp;
    tmp%=mod;
  }
  return ans;
}

int main(){

  long const mod = 1000000007;
  int n,k;
  cin >> n >> k;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }

  vector<long>kai(n+1,1);

  for(i=1;i<=n;i++){
    kai[i] = kai[i-1]*i;
    kai[i]%=mod;
  }

  long ans = 0;
  sort(a.begin(),a.end());

  for(i=0;i<=n-k;i++){
    ans += ncrmodp(kai[n-1-i],kai[k-1],kai[n-k-i])*(a[n-1-i]-a[i]);
    ans %= mod;
  }
  while(ans<0)ans += mod*mod;
  ans %= mod;
  cout << ans << endl;

}


Measured memory_bytes: 1792
s=input()
t=input()
if s==t:
    print("No")
    exit()

s1=[s[i] for i in range(len(s))]
t1=[t[i] for i in range(len(t))]
s1.sort()
t1.sort(reverse=True)
S="".join(s1)
T="".join(t1)
#print(S,T)
l=[S,T]
l.sort()
if l[0]==S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
a, b, c, x, y = [int(i) for i in input().split()]
#print(a, b, c, x, y)

z=max(x,y)

ans=1000000000000
for k in range(0,z+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {
	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	d := r.nextStringArray().toInts()

	dc := func(a []int) map[int]int {
		c := map[int]int{}
		for i := range a {
			c[a[i]]++
		}
		return c
	}(d)

	ans := 1
	const MOD = 998244353
	if d[0] != 0 || dc[0] != 1 {
		ans = 0
	} else {
		for i, endi := 1, len(dc); i < endi; i++ {
			if dc[i] == 0 {
				ans = 0
				break
			}
			ans = (ans * pow(dc[i-1], dc[i], MOD)) % MOD
		}

	}

	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 7424
#include<stdio.h>
int main(){
  int n,a,b,c,d,i,r=1,p[200010]={};
  char s[200010];
  scanf("%d %d %d %d %d %s",&n,&a,&b,&c,&d,s+1);
  for(i=1;s[i];i++){
    if(s[i]=='#')continue;
    if(p[i]==0)p[i]=r++;
    if(s[i+1]-'#')p[i+1]=p[i];
    if(s[i+2]-'#')p[i+2]=p[i];
  }
  if(c<d){
    if(p[a]==p[c]&&p[b]==p[d])printf("Yes\n");
    else printf("No\n");
  }
  else{
    if(p[a]==p[c]&&p[b]==p[d]){
      for(i=b;i<=d;i++){
	if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')break;
      }
      
      printf("%s\n",i>d?"No":"Yes");
    }
    else printf("No\n");
  }
  return 0;
}


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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

vector<int> fl,fr;
int fcnt=0;

void dfs(lint res)
{
	if(res<=1)return;
	if(res&1)fl.emplace_back(fcnt--),dfs(res-1);
	else fr.emplace_back(fcnt--),dfs(res>>1);
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	lint tar=ty()+1;
	fcnt=100,dfs(tar);
	cout<<so(fl)+so(fr)+100<<lf;
	for(auto i:fl)cout<<i<<' ';
	reverse(fr.begin(),fr.end());
	for(auto i:fr)cout<<i<<' ';
	for(int i=1;i<=100;i++)cout<<i<<" \n"[i==100];

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

int d[102][102];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = 1e9;
		}
		d[i][i] = 0;
	}
	vector<pair<pair<int, int>, int> > e(m);
	for (int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		e[i] = { {a, b}, c };
		d[a][b] = d[b][a] = c;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int ans = 0;
	for (int t = 0; t < m; t++) {
		int a = e[t].first.first, b = e[t].first.second, c = e[t].second;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			flag |= d[a][i] == d[b][i] + c;
		}
		if (!flag) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int W, H, N;
  cin >> W >> H >> N;

  int x, y, a; 
  int xl = 0;
  int xr = W;
  int yl = 0;
  int yh = H;

  for(int i=0; i<N; i++){
	cin >> x >> y >> a;
     	if(a==1) xl = max(xl, x);
     	if(a==2) xr = min(xr, x);
     	if(a==3) yl = max(yl, y);
     	if(a==4) yh = min(yh, y);
  }//for

  int wide   = max(0, xr - xl);
  int height = max(0, yh - yl);
  cout << wide * height << "\n";
}//main


Measured memory_bytes: 3568
import math
a,b,c,d = list(map(int,input().split()))

flag = True

while 1:
    if flag:
        c-=b
    else:
        a-=d
    if c<=0:
        print("Yes")
        exit()
    if a<=0:
        print("No")
        exit()
    flag = not flag


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int n,k;cin>>n>>k;
    int ans=k;
    for(int i=1;i<n;i++){
        ans*=(k-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int,input().split()))

m = 0
for i in range(N-1):
    l = A[i+1] - A[i]
    if m <= l:
        m = l
        
if m <= K-A[N-1]+A[0]:
    m = K-A[N-1]+A[0]
    
print(K-m)

Measured memory_bytes: 78412
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;



int main(){

	int n, m, p[100000], y[100000];
	vector<int> yd[100001];
	cin >> n >> m;
	for(int i=0; i<m; i++){
		cin >> p[i] >> y[i];
		yd[p[i]].push_back(y[i]);
	}
	for(int i=0; i<n; i++){
		sort(yd[i+1].begin(), yd[i+1].end());
	}
	for(int i=0; i<m; i++){
		printf("%012lld\n", ll(p[i])*1000000+int(lower_bound(yd[p[i]].begin(),
		yd[p[i]].end(), y[i])-yd[p[i]].begin())+1);
	}


	return 0;
}


Measured memory_bytes: 7808
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	int d=nextint();
	int t=nextint();
	int s=nextint();
	puts(d<=t*s?"Yes":"No");
}


Measured memory_bytes: 1540
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-(10**10)
for i in range(1,1024):
    bit=bin(i)[2:].zfill(10)
    a=0
    for j in range(n):
        b=0
        for k in range(10):
            if int(bit[k]) and f[j][k]:
                b+=1
        a+=p[j][b]
    ans=max(ans,a)
print(ans)

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

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

	long long W, H, x, y;
	scanf("%lld %lld %lld %lld", &W, &H, &x, &y);

	auto ret = W * H / 2.0;

	printf("%f", ret);
	if (W == 2 * x && H == 2 * y) {
		printf(" 1");
	} else {
		printf(" 0");
	}

	return 0;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint N,C;
    cin >> N >> C;
    lint D[31][31];
    for(lint i=1;i<=C;i++)
        for(lint j=1;j<=C;j++) cin >> D[i][j];
    
    lint c[501][501];
    for(lint i=0;i<N;i++){
        for(lint j=0;j<N;j++){
            cin >> c[i][j];
        }
    }

    lint bef[3][250000];
    lint next[3]={0,0,0};
    for(lint i=0;i<N*N;i++){
        lint x=i%N, y=i/N;
        lint id=(x+y)%3;
        bef[id][next[id]]=c[x][y];
        next[id]++;
    }
    lint table[3][31];
    for(lint i=1;i<=C;i++){
        for(lint m=0;m<3;m++){
            lint val=0;
            for(lint j=0;j<next[m];j++) val+=D[bef[m][j]][i];
            table[m][i]=val;
        }
    }
    vector<lint> value;
    for(lint i=1;i<=C;i++){
        for(lint j=1;j<=C;j++){
            if(i==j) continue;
            for(lint k=1;k<=C;k++){
                if(i==k || j==k) continue;
                value.push_back(table[0][i]+table[1][j]+table[2][k]);
            }
        }
    }
    sort(value.begin(),value.end());

    cout << value[0] << endl;
    
    return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef node* Node;
#define NIL NULL
 
node array[500000];
int size=0;
 
Node root = NIL;
  
Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}
  
Node treeSearch(Node u, int k){
  Node i=u;
  while(i!=NIL){
    if(i->key==k)return i;
    else if(i->key<k)i=i->right;
    else i=i->left;     
  }
  return NIL;
}
  
Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
  
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
    
  if(y->left!=NIL)x=y->left;
  else x=y->right;
  
  if(x!=NIL)x->parent=y->parent;
    
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;
  
  if(y!=z)z->key=y->key;
    
  //free(y);
}
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = &array[size++];
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;   
}
 
 
void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
 
int main(){
  int n,x;
  char str[20];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s", str);
    if(str[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if (t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(str[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(str[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
 
  return 0;
}



Measured memory_bytes: 15188
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
}Point;

void koch(int,Point,Point);

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}

void koch(int n,Point a, Point b){
  if(n==0) return;
  Point s,t,u;
  double th;

  th=M_PI*60.0/180.0;
  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
 
}


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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	string s;
	cin >> n >> s;
	if (n & 1) {
		cout << "No\n";
		return 0;
	}

	bool ok = 1;
	for (int i = 0; i < n / 2; ++i)
		if (s[i] != s[i + n / 2])
			ok = 0;
	cout << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = input()
    K = int(input())
    result = set()

    for i in range(5):
        for j in range(len(S)):
            result.add(S[j:j + i + 1])

    print(sorted(result)[K - 1])


if __name__ == "__main__":
    main()


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

const int MAX_N = 2e5+10;
int N;
int h[MAX_N];
int a[MAX_N];
ll V[MAX_N+1];
ll dp[MAX_N+1];

void update(int i, ll x)
{
	while(i<=MAX_N){
		V[i]=max(V[i],x);
		i+=(i&-i);
	}
}

ll query(int i)
{
	ll res = 0;
	while(i>0){
		res =max(res, V[i]);
		i -= (i&-i);
	}
	return res;
}

void solve()
{
	for(int i=1;i<=N;++i){
		dp[i]=max(dp[i], query(h[i]-1)+a[i]);
		update(h[i],dp[i]);
	}
	cout << *max_element(dp+1, dp+N+1) << '\n';
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i) cin >> h[i];
	for(int i=1;i<=N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

char S[2]={'+','-'};

char s[4];

int main(){
	int ans = 0;
	scanf("%s",s);
	char a=s[0],b=s[1],c=s[2],d=s[3];
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				ans = a-'0';
				if(i==0) ans+=b-'0';
				else ans-=b-'0';
				if(j==0) ans+=c-'0';
				else ans-=c-'0';
				if(k==0)ans+=d-'0';
				else ans-=d-'0';
				if(ans==7){
					printf("%c%c%c%c%c%c%c=7\n",a,S[i],b,S[j],c,S[k],d);
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]

que = deque([[0,0]])
seen = [[-1]*W for _ in range(H)]
seen[0][0] = 0
count = 0
for i in range(H):
    for j in range(W):
        if map[i][j]=="#":
            seen[i][j] = -2
        else:
            count +=1

while que:
    y, x = que.popleft()
    for dy, dx in ([0,1],[1,0],[0,-1],[-1,0]):
        ny, nx = y+dy, x+dx
        if 0<=ny<H and 0<=nx<W and seen[ny][nx]==-1 and map[ny][nx] != "#":
            seen[ny][nx] = seen[y][x] + 1
            que.append([ny, nx])

#print(*seen, sep="\n")
#print("\n")
max = seen[H-1][W-1]
if max >=0:
    cnt = count-max-1
elif max ==-1:
    cnt = -1
print(cnt)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int N,M,i,q;
  long goukei=0;
  cin >> N >> M;
  vector<int> A(N);
  for (i=0;i<N;i++){
    cin >> q;
    A[i]=q;
  }
  sort(A.begin(), A.end());
  for (i=0;i<M;i++){
    goukei=goukei+A[i];
  }
  cout << goukei << endl;

}
 

Measured memory_bytes: 3600
public class
Main
{
  @SuppressWarnings("unchecked")
  public void
  run (
    java.io.InputStream in,
    java.io.PrintStream out
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( in );
    java.util.List[ ] G, p;
    int[ ] res;
    int n, m, r;
    int i;

    n = sc.nextInt ( );
    m = sc.nextInt ( );
    r = sc.nextInt ( );

    G = new java.util.List[ n ];
    p = new java.util.List[ n ];
    for ( i = 0; i < n; ++i )
    {
      G[ i ] = new java.util.LinkedList ( );
      p[ i ] = new java.util.LinkedList ( );
    }
    for ( i = 0; i < m; ++i )
    {
      int s, t, d;

      s = sc.nextInt ( );
      t = sc.nextInt ( );
      d = sc.nextInt ( );
      G[ s ].add ( t );
      p[ s ].add ( d );
    }

    res = dijkstra ( convertGraph ( G ), convertGraph ( p ), r );
    for ( i = 0; i < res.length; ++i )
    {
      if ( res[ i ] < 0 )
        out.println ( "INF" );
      else
        out.println ( res[ i ] );
    }

    sc.close ( );
  }

  /** ??°?????????List ??¨???????¨?????????????????????? */
  private static int[ ][ ]
  convertGraph (
    java.util.List[ ] G
    )
  {
    int[ ][ ] r = new int[ G.length ][ ];
    java.util.Iterator it;
    int i, j;

    for ( i = 0; i < r.length; ++i )
    {
      r[ i ] = new int[ G[ i ].size ( ) ];
      for ( j = 0, it = G[ i ].iterator ( ); it.hasNext ( ); ++j )
        r[ i ][ j ] = ( (Integer)it.next ( ) ).intValue ( );
    }

    return ( r );
  }

  /** ??????????????°??????(G,p) ???????????????
    * ??????s ????§??????¨????????????????????????????????????????±??????????
    * 
    * r[ t ]: ??????s ????????????t ????????????????????? (???????????°?????????)
    */
  private static int[ ]
  dijkstra (
    int[ ][ ] G,
    int[ ][ ] p,
    int s
    )
  {
    class Status implements Comparable<Status> {
      int v, d;
      public Status ( int v, int d ) { this.v = v; this.d = d; }
      public int compareTo ( Status o ) { return ( this.d - o.d ); }
    }
    java.util.PriorityQueue<Status> lis;
    int[ ] r;
    int i;

    r = new int[ G.length ];
    java.util.Arrays.fill ( r, -1 );

    lis = new java.util.PriorityQueue<Status> ( );
    lis.add ( new Status ( s, 0 ) );
    while ( !lis.isEmpty ( ) )
    {
      Status st = lis.poll ( );

      if ( r[ st.v ] >= 0 )
        continue ;

      r[ st.v ] = st.d;
      for ( i = 0; i < G[ st.v ].length; ++i )
        lis.add ( new Status ( G[ st.v ][ i ], r[ st.v ] + p[ st.v ][ i ] ) );
    }

    return ( r );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( System.in, System.out );
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;
const ll INF = (ll) (1e18) + 5;
int main(){
  FASTER;
  int n;
  cin >> n;
  vector<int>dp(3, 0);
  for (int days = 0; days < n; days++){
    vector<int>cost(3);
    for (int j = 0; j < 3; j++){
      cin >> cost[j];
    }
    vector<int>temp(3, 0);
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (i != j){
          temp[j] = max(temp[j], dp[i] + cost[j]);
        }
      }
    }
    dp = temp;
  }
  cout << max(dp[0], max(dp[1], dp[2])) << endl;
  return 0;
}

Measured memory_bytes: 256
import fractions
A,B,C,D = map(int,input().split())
K = B-A+1
E = (C*D)//fractions.gcd(C,D)
c = B//C - (A-1)//C
d = B//D - (A-1)//D
e = B//E - (A-1)//E
print(K-c-d+e)

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


using namespace std;

const int MAXN = 100 * 1000 + 13;

 




int n, a[MAXN], ans;
set<int> s[2];


int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], s[i & 1].insert(a[i]);
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		if (s[i & 1].find(a[i]) == s[i & 1].end())
			ans++;
	cout << (ans >> 1) << endl;
	return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<iostream>
using namespace std;
int a[101],n,s[101],ans=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    for(int i=1;i<n;++i)
    {
        ans+=(s[n]-s[i])*a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];





void test_case() {

    
    set<int> st;
    rep(i,3) {
        int x;
        cin>>x;
        st.insert(x);
    }

    if(st.size() == 2) {
        yes;
    } else {
        no;
    }





}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


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

#define ll long long

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m, l, r;
    cin >> n >> m;
    
    l = 1, r = m;
    while(l < r) {
        cout << l << " " << r << '\n';
        ++l, --r;
    }

    l = m+1, r = 2*m+1;
    while(l < r) {
        cout << l << " " << r << '\n';
        ++l, --r;
    }
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int digitSum(int n) {

    int sum = 0;

    while (n != 0) {

        sum += (n % 10);

        n = n / 10;
    }

    return sum;
}

int main() {

    int N;
    int A, B;
    cin >> N >> A >> B;

    int result = 0;

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

        int ds = digitSum(i);

        if ((A <= ds) and (ds <= B)) {
            result += i;
        }

    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
if(s.at(0)=='S'){
cout << "Cloudy"<< endl;}
else if(s.at(0)=='C'){
cout << "Rainy" << endl;}
else{
cout << "Sunny" << endl;}}


Measured memory_bytes: 3540
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}
int main(void)
{
    string s;
    cin >> s;
    lli sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        int tmp = s[i] - '0';
        sum += tmp;
    }
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
A = [0,0,0]
N, A[0], A[1], A[2] = map(int, input().split())
l = []
for i in range(N):
    l.append(int(input()))
ans = 9999
for i in range(4 ** N):
    d = [[] for i in range(4)]
    j = i
    for k in range(N):
        d[j % 4].append(k)
        j //= 4
    mp = 0
    for j in range(3):
        if len(d[j]) == 0:
            break
        mp += abs(sum([l[k] for k in d[j]]) - A[j]) + 10 * (len(d[j]) - 1)
    else:
        ans = min(ans, mp)
print(ans)

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

using namespace std;

void solve() {
    string S, T;
    cin >> S;
    cin >> T;
    int ans = (int)T.size();
    for (int i = 0; i + (int)T.size() <= (int)S.size(); i++)
    {
        int a = 0;
        for (int j = 0; j < (int)T.size(); j++)
        {
            if (T[j] != S[i+j])
            {
                a++;
            }
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3636
N = int(input())
r = [[int(i) for i in input().split()] for i in range(N)]
b = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
for p in r:
    p[0],p[1] = p[1], p[0]
r,b = sorted(r, reverse=True), sorted(b)
for i in b:
    for j in r:
        if i[0]>j[1] and i[1] >j[0]:
            ans += 1
            r.remove(j)
            break

print(ans)



Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A;
  cin >> N >> A;
  if (N <= A + 500) {
    cout << "Yes" << endl;
  }
  else if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forab(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
const ll infll = (ll)(1e18) + 10;
const int inf = int(1e9) + 10;
const int maxn = int(1e5) + 10;
const ll mod = int(1e9) + 7;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<int> dp(n, 0);
    vector<int> used(n, 0);
    forn(i, m) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
    }
    function<void(int)> dfs = [&](int v) {
        used[v] = 1;
        forn(i, g[v].size()) {
            int to = g[v][i];
            if (!used[to]) {
                dfs(to);
            }
            dp[v] = max(dp[v], dp[to] + 1);
        }
    };
    forn(i, n) {
        if (!used[i]) {
            dfs(i);
        }
    }
    cout << *max_element(all(dp)) << "\n";
    return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main() {
  string s;
  cin >> s;
  cout << 2018;
  rep(i, s.size()-4){
    cout << s[i+4];
  }
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N, M;
    cin >> N >> M;

    if(N == M) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256